@paimaexample/explorer 0.3.124 → 0.3.126

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.
@@ -144,7 +144,7 @@ https://github.com/browserify/crypto-browserify`)},cryptoBrowserify.constants={D
144
144
  `+o+S.join(`,
145
145
  `+o)+`
146
146
  `+w+"}":"{"+S.join(",")+"}",o=w,y}}typeof r.stringify!="function"&&(r.stringify=function(c,d,p){var h;if(o="",i="",typeof p=="number")for(h=0;h<p;h+=1)i+=" ";else typeof p=="string"&&(i=p);if(a=d,d&&typeof d!="function"&&(typeof d!="object"||typeof d.length!="number"))throw new Error("JSON.stringify");return f("",{"":c})})})()})(stringify)),stringify.exports}var parse,hasRequiredParse;function requireParse(){if(hasRequiredParse)return parse;hasRequiredParse=1;var e=null;const t=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,r=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;var n=function(o){var i={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(o!=null){if(o.strict===!0&&(i.strict=!0),o.storeAsString===!0&&(i.storeAsString=!0),i.alwaysParseAsBig=o.alwaysParseAsBig===!0?o.alwaysParseAsBig:!1,i.useNativeBigInt=o.useNativeBigInt===!0?o.useNativeBigInt:!1,typeof o.constructorAction<"u")if(o.constructorAction==="error"||o.constructorAction==="ignore"||o.constructorAction==="preserve")i.constructorAction=o.constructorAction;else throw new Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${o.constructorAction}`);if(typeof o.protoAction<"u")if(o.protoAction==="error"||o.protoAction==="ignore"||o.protoAction==="preserve")i.protoAction=o.protoAction;else throw new Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${o.protoAction}`)}var u,a,s={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
147
- `,r:"\r",t:" "},f,c=function(B){throw{name:"SyntaxError",message:B,at:u,text:f}},d=function(B){return B&&B!==a&&c("Expected '"+B+"' instead of '"+a+"'"),a=f.charAt(u),u+=1,a},p=function(){var B,ae="";for(a==="-"&&(ae="-",d("-"));a>="0"&&a<="9";)ae+=a,d();if(a===".")for(ae+=".";d()&&a>="0"&&a<="9";)ae+=a;if(a==="e"||a==="E")for(ae+=a,d(),(a==="-"||a==="+")&&(ae+=a,d());a>="0"&&a<="9";)ae+=a,d();if(B=+ae,!isFinite(B))c("Bad number");else return e==null&&(e=requireBignumber()),ae.length>15?i.storeAsString?ae:i.useNativeBigInt?BigInt(ae):new e(ae):i.alwaysParseAsBig?i.useNativeBigInt?BigInt(B):new e(B):B},h=function(){var B,ae,W="",J;if(a==='"')for(var ve=u;d();){if(a==='"')return u-1>ve&&(W+=f.substring(ve,u-1)),d(),W;if(a==="\\"){if(u-1>ve&&(W+=f.substring(ve,u-1)),d(),a==="u"){for(J=0,ae=0;ae<4&&(B=parseInt(d(),16),!!isFinite(B));ae+=1)J=J*16+B;W+=String.fromCharCode(J)}else if(typeof s[a]=="string")W+=s[a];else break;ve=u}}c("Bad string")},y=function(){for(;a&&a<=" ";)d()},b=function(){switch(a){case"t":return d("t"),d("r"),d("u"),d("e"),!0;case"f":return d("f"),d("a"),d("l"),d("s"),d("e"),!1;case"n":return d("n"),d("u"),d("l"),d("l"),null}c("Unexpected '"+a+"'")},w,S=function(){var B=[];if(a==="["){if(d("["),y(),a==="]")return d("]"),B;for(;a;){if(B.push(w()),y(),a==="]")return d("]"),B;d(","),y()}}c("Bad array")},E=function(){var B,ae=Object.create(null);if(a==="{"){if(d("{"),y(),a==="}")return d("}"),ae;for(;a;){if(B=h(),y(),d(":"),i.strict===!0&&Object.hasOwnProperty.call(ae,B)&&c('Duplicate key "'+B+'"'),t.test(B)===!0?i.protoAction==="error"?c("Object contains forbidden prototype property"):i.protoAction==="ignore"?w():ae[B]=w():r.test(B)===!0?i.constructorAction==="error"?c("Object contains forbidden constructor property"):i.constructorAction==="ignore"?w():ae[B]=w():ae[B]=w(),y(),a==="}")return d("}"),ae;d(","),y()}}c("Bad object")};return w=function(){switch(y(),a){case"{":return E();case"[":return S();case'"':return h();case"-":return p();default:return a>="0"&&a<="9"?p():b()}},function(B,ae){var W;return f=B+"",u=0,a=" ",W=w(),y(),a&&c("Syntax error"),typeof ae=="function"?(function J(ve,Qe){var kt,nr=ve[Qe];return nr&&typeof nr=="object"&&Object.keys(nr).forEach(function(sr){kt=J(nr,sr),kt!==void 0?nr[sr]=kt:delete nr[sr]}),ae.call(ve,Qe,nr)})({"":W},""):W}};return parse=n,parse}var hasRequiredJsonBigint;function requireJsonBigint(){if(hasRequiredJsonBigint)return jsonBigint.exports;hasRequiredJsonBigint=1;var e=requireStringify().stringify,t=requireParse();return jsonBigint.exports=function(r){return{parse:t(r),stringify:e}},jsonBigint.exports.parse=t(),jsonBigint.exports.stringify=e,jsonBigint.exports}var jsonBigintExports=requireJsonBigint();const JSONbigWithoutConfig=getDefaultExportFromCjs(jsonBigintExports);var IntDecoding;(function(e){e.UNSAFE="unsafe",e.SAFE="safe",e.MIXED="mixed",e.BIGINT="bigint"})(IntDecoding||(IntDecoding={}));JSONbigWithoutConfig({useNativeBigInt:!0,strict:!0});function arrayEqual(e,t){return e.length!==t.length?!1:Array.from(e).every((r,n)=>r===t[n])}function concatArrays(...e){const t=e.reduce((o,i)=>o+i.length,0),r=new Uint8Array(t);let n=0;for(let o=0;o<e.length;o++)r.set(e[o],n),n+=e[o].length;return r}function isNode(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"}function ensureSafeInteger(e){if(typeof e>"u")throw new Error("Value is undefined");if(typeof e=="bigint"){if(e>BigInt(Number.MAX_SAFE_INTEGER)||e<BigInt(Number.MIN_SAFE_INTEGER))throw new Error(`BigInt value ${e} is not a safe integer`);return Number(e)}if(typeof e=="number"){if(Number.isSafeInteger(e))return e;throw new Error(`Value ${e} is not a safe integer`)}throw new Error(`Unexpected type ${typeof e}, ${e}`)}function ensureSafeUnsignedInteger(e){const t=ensureSafeInteger(e);if(t<0)throw new Error(`Value ${t} is negative`);return t}function ensureBigInt(e){if(typeof e>"u")throw new Error("Value is undefined");if(typeof e=="bigint")return e;if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`Value ${e} is not a safe integer`);return BigInt(e)}throw new Error(`Unexpected type ${typeof e}, ${e}`)}function ensureUint64(e){const t=ensureBigInt(e);if(t<0||t>BigInt("0xffffffffffffffff"))throw new Error(`Value ${t} is not a uint64`);return t}function genericHash(e){return sha512.sha512_256.array(e)}function isValidSignatureLength(e){return e===nacl.sign.signatureLength}function keyPairFromSecretKey(e){return nacl.sign.keyPair.fromSecretKey(e)}function sign(e,t){return nacl.sign.detached(e,t)}function verify(e,t,r){return nacl.sign.detached.verify(e,t,r)}const PUBLIC_KEY_LENGTH=nacl.sign.publicKeyLength;nacl.sign.secretKeyLength;const HASH_BYTES_LENGTH=32;function base64ToBytes(e){if(isNode())return new Uint8Array(bufferExports.Buffer.from(e,"base64"));const t=atob(e);return Uint8Array.from(t,r=>r.codePointAt(0))}function bytesToBase64(e){if(isNode())return bufferExports.Buffer.from(e).toString("base64");const t=Array.from(e,r=>String.fromCodePoint(r)).join("");return btoa(t)}function bytesToString(e){return new TextDecoder().decode(e)}function coerceToBytes(e){return typeof e=="string"?new TextEncoder().encode(e):e}function bytesToHex(e){return isNode()?bufferExports.Buffer.from(e).toString("hex"):Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}const ALGORAND_ADDRESS_BYTE_LENGTH=36,ALGORAND_CHECKSUM_BYTE_LENGTH=4,ALGORAND_ADDRESS_LENGTH=58,MALFORMED_ADDRESS_ERROR_MSG="address seems to be malformed",CHECKSUM_ADDRESS_ERROR_MSG="wrong checksum for address";function checksumFromPublicKey(e){return Uint8Array.from(genericHash(e).slice(HASH_BYTES_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH,HASH_BYTES_LENGTH))}class Address{constructor(t){if(!(t instanceof Uint8Array))throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: ${t} is not Uint8Array, type ${typeof t}`);if(t.length!==ALGORAND_ADDRESS_BYTE_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH)throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: 0x${bytesToHex(t)}, length ${t.length}`);this.publicKey=t}equals(t){return t instanceof Address&&arrayEqual(this.publicKey,t.publicKey)}checksum(){return checksumFromPublicKey(this.publicKey)}toString(){return base32.encode(concatArrays(this.publicKey,this.checksum())).slice(0,ALGORAND_ADDRESS_LENGTH)}static fromString(t){if(typeof t!="string")throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected string, got ${typeof t}, ${t}`);if(t.length!==ALGORAND_ADDRESS_LENGTH)throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected length ${ALGORAND_ADDRESS_LENGTH}, got ${t.length}: ${t}`);const r=base32.decode.asBytes(t);if(r.length!==ALGORAND_ADDRESS_BYTE_LENGTH)throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected byte length ${ALGORAND_ADDRESS_BYTE_LENGTH}, got ${r.length}`);const n=new Uint8Array(r.slice(0,ALGORAND_ADDRESS_BYTE_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH)),o=new Uint8Array(r.slice(PUBLIC_KEY_LENGTH,ALGORAND_ADDRESS_BYTE_LENGTH)),i=checksumFromPublicKey(n);if(!arrayEqual(i,o))throw new Error(CHECKSUM_ADDRESS_ERROR_MSG);return new Address(n)}static zeroAddress(){return new Address(new Uint8Array(ALGORAND_ADDRESS_BYTE_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH))}}function isValidAddress(e){try{Address.fromString(e)}catch{return!1}return!0}new TextEncoder().encode("appID");function utf8Count(e){for(var t=e.length,r=0,n=0;n<t;){var o=e.charCodeAt(n++);if((o&4294967168)===0){r++;continue}else if((o&4294965248)===0)r+=2;else{if(o>=55296&&o<=56319&&n<t){var i=e.charCodeAt(n);(i&64512)===56320&&(++n,o=((o&1023)<<10)+(i&1023)+65536)}(o&4294901760)===0?r+=3:r+=4}}return r}function utf8EncodeJs(e,t,r){for(var n=e.length,o=r,i=0;i<n;){var u=e.charCodeAt(i++);if((u&4294967168)===0){t[o++]=u;continue}else if((u&4294965248)===0)t[o++]=u>>6&31|192;else{if(u>=55296&&u<=56319&&i<n){var a=e.charCodeAt(i);(a&64512)===56320&&(++i,u=((u&1023)<<10)+(a&1023)+65536)}(u&4294901760)===0?(t[o++]=u>>12&15|224,t[o++]=u>>6&63|128):(t[o++]=u>>18&7|240,t[o++]=u>>12&63|128,t[o++]=u>>6&63|128)}t[o++]=u&63|128}}var sharedTextEncoder=new TextEncoder,TEXT_ENCODER_THRESHOLD=50;function utf8EncodeTE(e,t,r){sharedTextEncoder.encodeInto(e,t.subarray(r))}function utf8Encode(e,t,r){e.length>TEXT_ENCODER_THRESHOLD?utf8EncodeTE(e,t,r):utf8EncodeJs(e,t,r)}var CHUNK_SIZE=4096;function utf8DecodeJs(e,t,r){for(var n=t,o=n+r,i=[],u="";n<o;){var a=e[n++];if((a&128)===0)i.push(a);else if((a&224)===192){var s=e[n++]&63;i.push((a&31)<<6|s)}else if((a&240)===224){var s=e[n++]&63,f=e[n++]&63;i.push((a&31)<<12|s<<6|f)}else if((a&248)===240){var s=e[n++]&63,f=e[n++]&63,c=e[n++]&63,d=(a&7)<<18|s<<12|f<<6|c;d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d)}else i.push(a);i.length>=CHUNK_SIZE&&(u+=String.fromCharCode.apply(String,i),i.length=0)}return i.length>0&&(u+=String.fromCharCode.apply(String,i)),u}var sharedTextDecoder=new TextDecoder,TEXT_DECODER_THRESHOLD=200;function utf8DecodeTD(e,t,r){var n=e.subarray(t,t+r);return sharedTextDecoder.decode(n)}function utf8Decode(e,t,r){return r>TEXT_DECODER_THRESHOLD?utf8DecodeTD(e,t,r):utf8DecodeJs(e,t,r)}var ExtData=(function(){function e(t,r){this.type=t,this.data=r}return e})(),__extends=(function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})(),DecodeError=(function(e){__extends(t,e);function t(r){var n=e.call(this,r)||this,o=Object.create(t.prototype);return Object.setPrototypeOf(n,o),Object.defineProperty(n,"name",{configurable:!0,enumerable:!1,value:t.name}),n}return t})(Error),IntMode;(function(e){e[e.UNSAFE_NUMBER=0]="UNSAFE_NUMBER",e[e.SAFE_NUMBER=1]="SAFE_NUMBER",e[e.AS_ENCODED=2]="AS_ENCODED",e[e.MIXED=3]="MIXED",e[e.BIGINT=4]="BIGINT"})(IntMode||(IntMode={}));var UINT32_MAX=4294967295;function setUint64(e,t,r){var n=r/4294967296,o=r;e.setUint32(t,n),e.setUint32(t+4,o)}function setInt64(e,t,r){var n=Math.floor(r/4294967296),o=r;e.setUint32(t,n),e.setUint32(t+4,o)}function getInt64(e,t,r){if(r===IntMode.UNSAFE_NUMBER||r===IntMode.SAFE_NUMBER){var n=e.getInt32(t),o=e.getUint32(t+4);if(r===IntMode.SAFE_NUMBER&&(n<Math.floor(Number.MIN_SAFE_INTEGER/4294967296)||n===Math.floor(Number.MIN_SAFE_INTEGER/4294967296)&&o===0||n>(Number.MAX_SAFE_INTEGER-o)/4294967296)){var i="".concat(n<0?"-":"","0x").concat(Math.abs(n).toString(16)).concat(o.toString(16).padStart(8,"0"));throw new Error("Mode is IntMode.SAFE_NUMBER and value is not a safe integer: ".concat(i))}return n*4294967296+o}var u=e.getBigInt64(t);return r===IntMode.MIXED&&u>=Number.MIN_SAFE_INTEGER&&u<=Number.MAX_SAFE_INTEGER?Number(u):u}function getUint64(e,t,r){if(r===IntMode.UNSAFE_NUMBER||r===IntMode.SAFE_NUMBER){var n=e.getUint32(t),o=e.getUint32(t+4);if(r===IntMode.SAFE_NUMBER&&n>(Number.MAX_SAFE_INTEGER-o)/4294967296){var i="0x".concat(n.toString(16)).concat(o.toString(16).padStart(8,"0"));throw new Error("Mode is IntMode.SAFE_NUMBER and value is not a safe integer: ".concat(i))}return n*4294967296+o}var u=e.getBigUint64(t);return r===IntMode.MIXED&&u<=Number.MAX_SAFE_INTEGER?Number(u):u}function convertSafeIntegerToMode(e,t){return t===IntMode.BIGINT?BigInt(e):Number(e)}var EXT_TIMESTAMP=-1,TIMESTAMP32_MAX_SEC=4294967296-1,TIMESTAMP64_MAX_SEC=17179869184-1;function encodeTimeSpecToTimestamp(e){var t=e.sec,r=e.nsec;if(t>=0&&r>=0&&t<=TIMESTAMP64_MAX_SEC)if(r===0&&t<=TIMESTAMP32_MAX_SEC){var n=new Uint8Array(4),o=new DataView(n.buffer);return o.setUint32(0,t),n}else{var i=t/4294967296,u=t&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,r<<2|i&3),o.setUint32(4,u),n}else{var n=new Uint8Array(12),o=new DataView(n.buffer);return o.setUint32(0,r),setInt64(o,4,t),n}}function encodeDateToTimeSpec(e){var t=e.getTime(),r=Math.floor(t/1e3),n=(t-r*1e3)*1e6,o=Math.floor(n/1e9);return{sec:r+o,nsec:n-o*1e9}}function encodeTimestampExtension(e){if(e instanceof Date){var t=encodeDateToTimeSpec(e);return encodeTimeSpecToTimestamp(t)}else return null}function decodeTimestampToTimeSpec(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:{var r=t.getUint32(0),n=0;return{sec:r,nsec:n}}case 8:{var o=t.getUint32(0),i=t.getUint32(4),r=(o&3)*4294967296+i,n=o>>>2;return{sec:r,nsec:n}}case 12:{var r=getInt64(t,4,IntMode.UNSAFE_NUMBER),n=t.getUint32(0);return{sec:r,nsec:n}}default:throw new DecodeError("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}function decodeTimestampExtension(e){var t=decodeTimestampToTimeSpec(e);return new Date(t.sec*1e3+t.nsec/1e6)}var timestampExtension={type:EXT_TIMESTAMP,encode:encodeTimestampExtension,decode:decodeTimestampExtension},ExtensionCodec=(function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(timestampExtension)}return e.prototype.register=function(t){var r=t.type,n=t.encode,o=t.decode;if(r>=0)this.encoders[r]=n,this.decoders[r]=o;else{var i=1+r;this.builtInEncoders[i]=n,this.builtInDecoders[i]=o}},e.prototype.tryToEncode=function(t,r){for(var n=0;n<this.builtInEncoders.length;n++){var o=this.builtInEncoders[n];if(o!=null){var i=o(t,r);if(i!=null){var u=-1-n;return new ExtData(u,i)}}}for(var n=0;n<this.encoders.length;n++){var o=this.encoders[n];if(o!=null){var i=o(t,r);if(i!=null){var u=n;return new ExtData(u,i)}}}return t instanceof ExtData?t:null},e.prototype.decode=function(t,r,n){var o=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return o?o(t,r,n):new ExtData(r,t)},e.defaultCodec=new e,e})();function ensureUint8Array$1(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}function createDataView(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=ensureUint8Array$1(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}function compareUint8Arrays(e,t){for(var r=Math.min(e.length,t.length),n=0;n<r;n++){var o=e[n]-t[n];if(o!==0)return o}return e.length-t.length}var RawBinaryString=(function(){function e(t){if(this.rawBinaryValue=t,!ArrayBuffer.isView(t))throw new TypeError("RawBinaryString: rawBinaryValue must be an ArrayBufferView")}return e})(),DEFAULT_MAX_DEPTH=100,DEFAULT_INITIAL_BUFFER_SIZE=2048,Encoder=(function(){function e(t){var r,n,o,i,u,a,s,f;this.extensionCodec=(r=t?.extensionCodec)!==null&&r!==void 0?r:ExtensionCodec.defaultCodec,this.context=t?.context,this.forceBigIntToInt64=(n=t?.forceBigIntToInt64)!==null&&n!==void 0?n:!1,this.maxDepth=(o=t?.maxDepth)!==null&&o!==void 0?o:DEFAULT_MAX_DEPTH,this.initialBufferSize=(i=t?.initialBufferSize)!==null&&i!==void 0?i:DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=(u=t?.sortKeys)!==null&&u!==void 0?u:!1,this.forceFloat32=(a=t?.forceFloat32)!==null&&a!==void 0?a:!1,this.ignoreUndefined=(s=t?.ignoreUndefined)!==null&&s!==void 0?s:!1,this.forceIntegerToFloat=(f=t?.forceIntegerToFloat)!==null&&f!==void 0?f:!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}return e.prototype.reinitializeState=function(){this.pos=0},e.prototype.encodeSharedRef=function(t){return this.reinitializeState(),this.doEncode(t,1),this.bytes.subarray(0,this.pos)},e.prototype.encode=function(t){return this.reinitializeState(),this.doEncode(t,1),this.bytes.slice(0,this.pos)},e.prototype.doEncode=function(t,r){if(r>this.maxDepth)throw new Error("Too deep objects in depth ".concat(r));t==null?this.encodeNil():typeof t=="boolean"?this.encodeBoolean(t):typeof t=="number"?this.encodeNumber(t):typeof t=="string"?this.encodeString(t):this.encodeObject(t,r)},e.prototype.ensureBufferSizeToWrite=function(t){var r=this.pos+t;this.view.byteLength<r&&this.resizeBuffer(r*2)},e.prototype.resizeBuffer=function(t){var r=new ArrayBuffer(t),n=new Uint8Array(r),o=new DataView(r);n.set(this.bytes),this.view=o,this.bytes=n},e.prototype.encodeNil=function(){this.writeU8(192)},e.prototype.encodeBoolean=function(t){t===!1?this.writeU8(194):this.writeU8(195)},e.prototype.encodeNumber=function(t){!this.forceIntegerToFloat&&Number.isSafeInteger(t)?t>=0?t<128?this.writeU8(t):t<256?(this.writeU8(204),this.writeU8(t)):t<65536?(this.writeU8(205),this.writeU16(t)):t<4294967296?(this.writeU8(206),this.writeU32(t)):(this.writeU8(207),this.writeU64(t)):t>=-32?this.writeU8(224|t+32):t>=-128?(this.writeU8(208),this.writeI8(t)):t>=-32768?(this.writeU8(209),this.writeI16(t)):t>=-2147483648?(this.writeU8(210),this.writeI32(t)):(this.writeU8(211),this.writeI64(t)):this.encodeNumberAsFloat(t)},e.prototype.encodeNumberAsFloat=function(t){this.forceFloat32?(this.writeU8(202),this.writeF32(t)):(this.writeU8(203),this.writeF64(t))},e.prototype.encodeBigInt=function(t){if(this.forceBigIntToInt64)this.encodeBigIntAsInt64(t);else if(t>=0)if(t<4294967296||this.forceIntegerToFloat)this.encodeNumber(Number(t));else if(t<BigInt("0x10000000000000000"))this.encodeBigIntAsInt64(t);else throw new Error("Bigint is too large for uint64: ".concat(t));else if(t>=-2147483648||this.forceIntegerToFloat)this.encodeNumber(Number(t));else if(t>=BigInt(-1)*BigInt("0x8000000000000000"))this.encodeBigIntAsInt64(t);else throw new Error("Bigint is too small for int64: ".concat(t))},e.prototype.encodeBigIntAsInt64=function(t){t>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(t)):(this.writeU8(211),this.writeBigInt64(t))},e.prototype.writeStringHeader=function(t){if(t<32)this.writeU8(160+t);else if(t<256)this.writeU8(217),this.writeU8(t);else if(t<65536)this.writeU8(218),this.writeU16(t);else if(t<4294967296)this.writeU8(219),this.writeU32(t);else throw new Error("Too long string: ".concat(t," bytes in UTF-8"))},e.prototype.encodeString=function(t){var r=5,n=utf8Count(t);this.ensureBufferSizeToWrite(r+n),this.writeStringHeader(n),utf8Encode(t,this.bytes,this.pos),this.pos+=n},e.prototype.encodeObject=function(t,r){var n=this.extensionCodec.tryToEncode(t,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(t))this.encodeArray(t,r);else if(ArrayBuffer.isView(t))this.encodeBinary(t);else if(t instanceof RawBinaryString)this.encodeBinaryAsString(t);else if(typeof t=="bigint")this.encodeBigInt(t);else if(t instanceof Map)this.encodeMap(t,r);else if(typeof t=="object")this.encodeMapObject(t,r);else throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(t)))},e.prototype.encodeBinary=function(t){var r=t.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error("Too large binary: ".concat(r));var n=ensureUint8Array$1(t);this.writeU8a(n)},e.prototype.encodeBinaryAsString=function(t){var r=t.rawBinaryValue;this.writeStringHeader(r.byteLength);var n=ensureUint8Array$1(r);this.writeU8a(n)},e.prototype.encodeArray=function(t,r){var n=t.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error("Too large array: ".concat(n));for(var o=0,i=t;o<i.length;o++){var u=i[o];this.doEncode(u,r+1)}},e.prototype.countWithoutUndefined=function(t,r){for(var n=0,o=0,i=r;o<i.length;o++){var u=i[o];t.get(u)!==void 0&&n++}return n},e.prototype.sortMapKeys=function(t){for(var r=[],n=[],o=[],i=[],u=0,a=t;u<a.length;u++){var s=a[u];if(typeof s=="number"){if(isNaN(s))throw new Error("Cannot sort map keys with NaN value");r.push(s)}else if(typeof s=="bigint")r.push(s);else if(typeof s=="string")n.push(s);else if(ArrayBuffer.isView(s))i.push(ensureUint8Array$1(s));else if(s instanceof RawBinaryString)o.push(s);else throw new Error("Unsupported map key type: ".concat(Object.prototype.toString.apply(s)))}return r.sort(function(f,c){return f<c?-1:f>c?1:0}),n.sort(),o.sort(function(f,c){return compareUint8Arrays(ensureUint8Array$1(f.rawBinaryValue),ensureUint8Array$1(c.rawBinaryValue))}),i.sort(compareUint8Arrays),[].concat(r,n,o,i)},e.prototype.encodeMapObject=function(t,r){this.encodeMap(new Map(Object.entries(t)),r)},e.prototype.encodeMap=function(t,r){var n=Array.from(t.keys());this.sortKeys&&(n=this.sortMapKeys(n));var o=this.ignoreUndefined?this.countWithoutUndefined(t,n):n.length;if(o<16)this.writeU8(128+o);else if(o<65536)this.writeU8(222),this.writeU16(o);else if(o<4294967296)this.writeU8(223),this.writeU32(o);else throw new Error("Too large map object: ".concat(o));for(var i=0,u=n;i<u.length;i++){var a=u[i],s=t.get(a);if(!(this.ignoreUndefined&&s===void 0)){if(typeof a=="string")this.encodeString(a);else if(typeof a=="number")this.encodeNumber(a);else if(typeof a=="bigint")this.encodeBigInt(a);else if(ArrayBuffer.isView(a))this.encodeBinary(a);else if(a instanceof RawBinaryString)this.encodeBinaryAsString(a);else throw new Error("Unsupported map key type: ".concat(Object.prototype.toString.apply(a)));this.doEncode(s,r+1)}}},e.prototype.encodeExtension=function(t){var r=t.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error("Too large extension object: ".concat(r));this.writeI8(t.type),this.writeU8a(t.data)},e.prototype.writeU8=function(t){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,t),this.pos++},e.prototype.writeU8a=function(t){var r=t.length;this.ensureBufferSizeToWrite(r),this.bytes.set(t,this.pos),this.pos+=r},e.prototype.writeI8=function(t){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,t),this.pos++},e.prototype.writeU16=function(t){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,t),this.pos+=2},e.prototype.writeI16=function(t){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,t),this.pos+=2},e.prototype.writeU32=function(t){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,t),this.pos+=4},e.prototype.writeI32=function(t){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,t),this.pos+=4},e.prototype.writeF32=function(t){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,t),this.pos+=4},e.prototype.writeF64=function(t){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,t),this.pos+=8},e.prototype.writeU64=function(t){this.ensureBufferSizeToWrite(8),setUint64(this.view,this.pos,t),this.pos+=8},e.prototype.writeI64=function(t){this.ensureBufferSizeToWrite(8),setInt64(this.view,this.pos,t),this.pos+=8},e.prototype.writeBigUint64=function(t){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,t),this.pos+=8},e.prototype.writeBigInt64=function(t){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,t),this.pos+=8},e})();function encode(e,t){var r=new Encoder(t);return r.encodeSharedRef(e)}function prettyByte(e){return"".concat(e<0?"-":"","0x").concat(Math.abs(e).toString(16).padStart(2,"0"))}var DEFAULT_MAX_KEY_LENGTH=16,DEFAULT_MAX_LENGTH_PER_KEY=16,CachedKeyDecoder=(function(){function e(t,r){t===void 0&&(t=DEFAULT_MAX_KEY_LENGTH),r===void 0&&(r=DEFAULT_MAX_LENGTH_PER_KEY),this.maxKeyLength=t,this.maxLengthPerKey=r,this.hit=0,this.miss=0,this.caches=[];for(var n=0;n<this.maxKeyLength;n++)this.caches.push([])}return e.prototype.canBeCached=function(t){return t>0&&t<=this.maxKeyLength},e.prototype.find=function(t,r,n){var o=this.caches[n-1];e:for(var i=0,u=o;i<u.length;i++){for(var a=u[i],s=a.bytes,f=0;f<n;f++)if(s[f]!==t[r+f])continue e;return a.str}return null},e.prototype.store=function(t,r){var n=this.caches[t.length-1],o={bytes:t,str:r};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=o:n.push(o)},e.prototype.decode=function(t,r,n){var o=this.find(t,r,n);if(o!=null)return this.hit++,o;this.miss++;var i=utf8DecodeJs(t,r,n),u=Uint8Array.prototype.slice.call(t,r,r+n);return this.store(u,i),i},e})(),__awaiter=function(e,t,r,n){function o(i){return i instanceof r?i:new r(function(u){u(i)})}return new(r||(r=Promise))(function(i,u){function a(c){try{f(n.next(c))}catch(d){u(d)}}function s(c){try{f(n.throw(c))}catch(d){u(d)}}function f(c){c.done?i(c.value):o(c.value).then(a,s)}f((n=n.apply(e,t||[])).next())})},__generator=function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(f){return function(c){return s([f,c])}}function s(f){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,f[0]&&(r=0)),r;)try{if(n=1,o&&(i=f[0]&2?o.return:f[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,f[1])).done)return i;switch(o=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,o=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){r.label=f[1];break}if(f[0]===6&&r.label<i[1]){r.label=i[1],i=f;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(f);break}i[2]&&r.ops.pop(),r.trys.pop();continue}f=t.call(e,r)}catch(c){f=[6,c],o=0}finally{n=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},__asyncValues=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=e[i]&&function(u){return new Promise(function(a,s){u=e[i](u),o(a,s,u.done,u.value)})}}function o(i,u,a,s){Promise.resolve(s).then(function(f){i({value:f,done:a})},u)}},__await=function(e){return this instanceof __await?(this.v=e,this):new __await(e)},__asyncGenerator=function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,i=[];return o={},u("next"),u("throw"),u("return"),o[Symbol.asyncIterator]=function(){return this},o;function u(p){n[p]&&(o[p]=function(h){return new Promise(function(y,b){i.push([p,h,y,b])>1||a(p,h)})})}function a(p,h){try{s(n[p](h))}catch(y){d(i[0][3],y)}}function s(p){p.value instanceof __await?Promise.resolve(p.value.v).then(f,c):d(i[0][2],p)}function f(p){a("next",p)}function c(p){a("throw",p)}function d(p,h){p(h),i.shift(),i.length&&a(i[0][0],i[0][1])}},STATE_ARRAY="array",STATE_MAP_KEY="map_key",STATE_MAP_VALUE="map_value";function isValidMapKeyType(e,t,r){return t?typeof e=="string"||typeof e=="number"||typeof e=="bigint"||e instanceof Uint8Array||e instanceof RawBinaryString:typeof e=="string"||r&&typeof e=="number"}var StackPool=(function(){function e(t){this.useMap=t,this.stack=[],this.stackHeadPosition=-1}return Object.defineProperty(e.prototype,"length",{get:function(){return this.stackHeadPosition+1},enumerable:!1,configurable:!0}),e.prototype.top=function(){return this.stack[this.stackHeadPosition]},e.prototype.pushArrayState=function(t){var r=this.getUninitializedStateFromPool();r.type=STATE_ARRAY,r.position=0,r.size=t,r.array=new Array(t)},e.prototype.pushMapState=function(t){var r=this.getUninitializedStateFromPool();r.type=STATE_MAP_KEY,r.readCount=0,r.size=t,r.map=this.useMap?new Map:{}},e.prototype.getUninitializedStateFromPool=function(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){var t={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(t)}return this.stack[this.stackHeadPosition]},e.prototype.release=function(t){var r=this.stack[this.stackHeadPosition];if(r!==t)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(t.type===STATE_ARRAY){var n=t;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(t.type===STATE_MAP_KEY||t.type===STATE_MAP_VALUE){var n=t;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--},e.prototype.reset=function(){this.stack.length=0,this.stackHeadPosition=-1},e})(),HEAD_BYTE_REQUIRED=-1,EMPTY_VIEW=new DataView(new ArrayBuffer(0)),EMPTY_BYTES=new Uint8Array(EMPTY_VIEW.buffer);try{EMPTY_VIEW.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var DataViewIndexOutOfBoundsError=RangeError,MORE_DATA=new DataViewIndexOutOfBoundsError("Insufficient data"),sharedCachedKeyDecoder=new CachedKeyDecoder,Decoder=(function(){function e(t){var r,n,o,i,u,a,s,f,c,d,p,h;if(this.totalPos=0,this.pos=0,this.view=EMPTY_VIEW,this.bytes=EMPTY_BYTES,this.headByte=HEAD_BYTE_REQUIRED,this.extensionCodec=(r=t?.extensionCodec)!==null&&r!==void 0?r:ExtensionCodec.defaultCodec,this.context=t?.context,this.intMode=(n=t?.intMode)!==null&&n!==void 0?n:t?.useBigInt64?IntMode.AS_ENCODED:IntMode.UNSAFE_NUMBER,this.rawBinaryStringValues=(o=t?.rawBinaryStringValues)!==null&&o!==void 0?o:!1,this.rawBinaryStringKeys=(i=t?.rawBinaryStringKeys)!==null&&i!==void 0?i:!1,this.useRawBinaryStringClass=(u=t?.useRawBinaryStringClass)!==null&&u!==void 0?u:!1,this.useMap=(a=t?.useMap)!==null&&a!==void 0?a:!1,this.supportObjectNumberKeys=(s=t?.supportObjectNumberKeys)!==null&&s!==void 0?s:!1,this.maxStrLength=(f=t?.maxStrLength)!==null&&f!==void 0?f:UINT32_MAX,this.maxBinLength=(c=t?.maxBinLength)!==null&&c!==void 0?c:UINT32_MAX,this.maxArrayLength=(d=t?.maxArrayLength)!==null&&d!==void 0?d:UINT32_MAX,this.maxMapLength=(p=t?.maxMapLength)!==null&&p!==void 0?p:UINT32_MAX,this.maxExtLength=(h=t?.maxExtLength)!==null&&h!==void 0?h:UINT32_MAX,this.keyDecoder=t?.keyDecoder!==void 0?t.keyDecoder:sharedCachedKeyDecoder,this.rawBinaryStringKeys&&!this.useMap)throw new Error("rawBinaryStringKeys is only supported when useMap is true");this.stack=new StackPool(this.useMap)}return e.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=HEAD_BYTE_REQUIRED,this.stack.reset()},e.prototype.setBuffer=function(t){this.bytes=ensureUint8Array$1(t),this.view=createDataView(this.bytes),this.pos=0},e.prototype.appendBuffer=function(t){if(this.headByte===HEAD_BYTE_REQUIRED&&!this.hasRemaining(1))this.setBuffer(t);else{var r=this.bytes.subarray(this.pos),n=ensureUint8Array$1(t),o=new Uint8Array(r.length+n.length);o.set(r),o.set(n,r.length),this.setBuffer(o)}},e.prototype.hasRemaining=function(t){return this.view.byteLength-this.pos>=t},e.prototype.createExtraByteError=function(t){var r=this,n=r.view,o=r.pos;return new RangeError("Extra ".concat(n.byteLength-o," of ").concat(n.byteLength," byte(s) found at buffer[").concat(t,"]"))},e.prototype.decode=function(t){this.reinitializeState(),this.setBuffer(t);var r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r},e.prototype.decodeMulti=function(t){return __generator(this,function(r){switch(r.label){case 0:this.reinitializeState(),this.setBuffer(t),r.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return r.sent(),[3,1];case 3:return[2]}})},e.prototype.decodeAsync=function(t){var r,n,o,i,u,a,s;return __awaiter(this,void 0,void 0,function(){var f,c,d,p,h,y,b,w;return __generator(this,function(S){switch(S.label){case 0:f=!1,S.label=1;case 1:S.trys.push([1,6,7,12]),r=!0,n=__asyncValues(t),S.label=2;case 2:return[4,n.next()];case 3:if(o=S.sent(),i=o.done,!!i)return[3,5];if(s=o.value,r=!1,d=s,f)throw this.createExtraByteError(this.totalPos);this.appendBuffer(d);try{c=this.doDecodeSync(),f=!0}catch(E){if(!(E instanceof DataViewIndexOutOfBoundsError))throw E}this.totalPos+=this.pos,S.label=4;case 4:return r=!0,[3,2];case 5:return[3,12];case 6:return p=S.sent(),u={error:p},[3,12];case 7:return S.trys.push([7,,10,11]),!r&&!i&&(a=n.return)?[4,a.call(n)]:[3,9];case 8:S.sent(),S.label=9;case 9:return[3,11];case 10:if(u)throw u.error;return[7];case 11:return[7];case 12:if(f){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,c]}throw h=this,y=h.headByte,b=h.pos,w=h.totalPos,new RangeError("Insufficient data in parsing ".concat(prettyByte(y)," at ").concat(w," (").concat(b," in the current buffer)"))}})})},e.prototype.decodeArrayStream=function(t){return this.decodeMultiAsync(t,!0)},e.prototype.decodeStream=function(t){return this.decodeMultiAsync(t,!1)},e.prototype.decodeMultiAsync=function(t,r){return __asyncGenerator(this,arguments,function(){var o,i,u,a,s,f,c,d,p,h,y,b;return __generator(this,function(w){switch(w.label){case 0:o=r,i=-1,w.label=1;case 1:w.trys.push([1,13,14,19]),u=!0,a=__asyncValues(t),w.label=2;case 2:return[4,__await(a.next())];case 3:if(s=w.sent(),p=s.done,!!p)return[3,12];if(b=s.value,u=!1,f=b,r&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(f),o&&(i=this.readArraySize(),o=!1,this.complete()),w.label=4;case 4:w.trys.push([4,9,,10]),w.label=5;case 5:return[4,__await(this.doDecodeSync())];case 6:return[4,w.sent()];case 7:return w.sent(),--i===0?[3,8]:[3,5];case 8:return[3,10];case 9:if(c=w.sent(),!(c instanceof DataViewIndexOutOfBoundsError))throw c;return[3,10];case 10:this.totalPos+=this.pos,w.label=11;case 11:return u=!0,[3,2];case 12:return[3,19];case 13:return d=w.sent(),h={error:d},[3,19];case 14:return w.trys.push([14,,17,18]),!u&&!p&&(y=a.return)?[4,__await(y.call(a))]:[3,16];case 15:w.sent(),w.label=16;case 16:return[3,18];case 17:if(h)throw h.error;return[7];case 18:return[7];case 19:return[2]}})})},e.prototype.doDecodeSync=function(){e:for(;;){var t=this.readHeadByte(),r=void 0;if(t>=224)r=this.convertNumber(t-256);else if(t<192)if(t<128)r=this.convertNumber(t);else if(t<144){var n=t-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else r=this.useMap?new Map:{}}else if(t<160){var n=t-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else{var o=t-160;r=this.decodeString(o,0)}else if(t===192)r=null;else if(t===194)r=!1;else if(t===195)r=!0;else if(t===202)r=this.readF32();else if(t===203)r=this.readF64();else if(t===204)r=this.convertNumber(this.readU8());else if(t===205)r=this.convertNumber(this.readU16());else if(t===206)r=this.convertNumber(this.readU32());else if(t===207)r=this.readU64();else if(t===208)r=this.convertNumber(this.readI8());else if(t===209)r=this.convertNumber(this.readI16());else if(t===210)r=this.convertNumber(this.readI32());else if(t===211)r=this.readI64();else if(t===217){var o=this.lookU8();r=this.decodeString(o,1)}else if(t===218){var o=this.lookU16();r=this.decodeString(o,2)}else if(t===219){var o=this.lookU32();r=this.decodeString(o,4)}else if(t===220){var n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(t===221){var n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(t===222){var n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(t===223){var n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(t===196){var n=this.lookU8();r=this.decodeBinary(n,1)}else if(t===197){var n=this.lookU16();r=this.decodeBinary(n,2)}else if(t===198){var n=this.lookU32();r=this.decodeBinary(n,4)}else if(t===212)r=this.decodeExtension(1,0);else if(t===213)r=this.decodeExtension(2,0);else if(t===214)r=this.decodeExtension(4,0);else if(t===215)r=this.decodeExtension(8,0);else if(t===216)r=this.decodeExtension(16,0);else if(t===199){var n=this.lookU8();r=this.decodeExtension(n,1)}else if(t===200){var n=this.lookU16();r=this.decodeExtension(n,2)}else if(t===201){var n=this.lookU32();r=this.decodeExtension(n,4)}else throw new DecodeError("Unrecognized type byte: ".concat(prettyByte(t)));this.complete();for(var i=this.stack;i.length>0;){var u=i.top();if(u.type===STATE_ARRAY)if(u.array[u.position]=r,u.position++,u.position===u.size)r=u.array,i.release(u);else continue e;else if(u.type===STATE_MAP_KEY){if(!isValidMapKeyType(r,this.useMap,this.supportObjectNumberKeys)){var a=this.useMap?"string, number, bigint, or Uint8Array":this.supportObjectNumberKeys?"string or number":"string";throw new DecodeError("The type of key must be ".concat(a," but got ").concat(typeof r))}if(!this.useMap&&r==="__proto__")throw new DecodeError("The key __proto__ is not allowed");u.key=r,u.type=STATE_MAP_VALUE;continue e}else if(this.useMap?u.map.set(u.key,r):u.map[u.key]=r,u.readCount++,u.readCount===u.size)r=u.map,i.release(u);else{u.key=null,u.type=STATE_MAP_KEY;continue e}}return r}},e.prototype.readHeadByte=function(){return this.headByte===HEAD_BYTE_REQUIRED&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=HEAD_BYTE_REQUIRED},e.prototype.readArraySize=function(){var t=this.readHeadByte();switch(t){case 220:return this.readU16();case 221:return this.readU32();default:{if(t<160)return t-144;throw new DecodeError("Unrecognized array type byte: ".concat(prettyByte(t)))}}},e.prototype.pushMapState=function(t){if(t>this.maxMapLength)throw new DecodeError("Max length exceeded: map length (".concat(t,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.pushMapState(t)},e.prototype.pushArrayState=function(t){if(t>this.maxArrayLength)throw new DecodeError("Max length exceeded: array length (".concat(t,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.pushArrayState(t)},e.prototype.decodeString=function(t,r){if(this.stateIsMapKey()?this.rawBinaryStringKeys:this.rawBinaryStringValues){var n=this.decodeBinary(t,r);return this.useRawBinaryStringClass?new RawBinaryString(n):n}return this.decodeUtf8String(t,r)},e.prototype.decodeUtf8String=function(t,r){var n;if(t>this.maxStrLength)throw new DecodeError("Max length exceeded: UTF-8 byte length (".concat(t,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength<this.pos+r+t)throw MORE_DATA;var o=this.pos+r,i;return this.stateIsMapKey()&&(!((n=this.keyDecoder)===null||n===void 0)&&n.canBeCached(t))?i=this.keyDecoder.decode(this.bytes,o,t):i=utf8Decode(this.bytes,o,t),this.pos+=r+t,i},e.prototype.stateIsMapKey=function(){if(this.stack.length>0){var t=this.stack.top();return t.type===STATE_MAP_KEY}return!1},e.prototype.decodeBinary=function(t,r){if(t>this.maxBinLength)throw new DecodeError("Max length exceeded: bin length (".concat(t,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(t+r))throw MORE_DATA;var n=this.pos+r,o=this.bytes.subarray(n,n+t);return this.pos+=r+t,o},e.prototype.decodeExtension=function(t,r){if(t>this.maxExtLength)throw new DecodeError("Max length exceeded: ext length (".concat(t,") > maxExtLength (").concat(this.maxExtLength,")"));var n=this.view.getInt8(this.pos+r),o=this.decodeBinary(t,r+1);return this.extensionCodec.decode(o,n,this.context)},e.prototype.convertNumber=function(t){return convertSafeIntegerToMode(t,this.intMode)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var t=this.view.getUint8(this.pos);return this.pos++,t},e.prototype.readI8=function(){var t=this.view.getInt8(this.pos);return this.pos++,t},e.prototype.readU16=function(){var t=this.view.getUint16(this.pos);return this.pos+=2,t},e.prototype.readI16=function(){var t=this.view.getInt16(this.pos);return this.pos+=2,t},e.prototype.readU32=function(){var t=this.view.getUint32(this.pos);return this.pos+=4,t},e.prototype.readI32=function(){var t=this.view.getInt32(this.pos);return this.pos+=4,t},e.prototype.readU64=function(){var t=getUint64(this.view,this.pos,this.intMode);return this.pos+=8,t},e.prototype.readI64=function(){var t=getInt64(this.view,this.pos,this.intMode);return this.pos+=8,t},e.prototype.readF32=function(){var t=this.view.getFloat32(this.pos);return this.pos+=4,t},e.prototype.readF64=function(){var t=this.view.getFloat64(this.pos);return this.pos+=8,t},e})();function decode(e,t){var r=new Decoder(t);return r.decode(e)}function msgpackRawEncode(e){return encode(e,{sortKeys:!0})}function msgpackRawDecodeAsMap(e,t){const r={intMode:IntMode.BIGINT,useMap:!0};return decode(e,r)}function msgpackRawDecodeAsMapWithRawStrings(e,t){const r={intMode:IntMode.BIGINT,useMap:!0,rawBinaryStringKeys:!0,rawBinaryStringValues:!0,useRawBinaryStringClass:!0};return decode(e,r)}function msgpackEncodingDataToJSONEncodingData(e){if(e==null)return e;if(e instanceof Uint8Array)return bytesToBase64(e);if(Array.isArray(e))return e.map(msgpackEncodingDataToJSONEncodingData);if(e instanceof Map){const t={};for(const[r,n]of e){if(typeof r!="string")throw new Error(`JSON map key must be a string: ${r}`);t[r]=msgpackEncodingDataToJSONEncodingData(n)}return t}return e}function jsonEncodingDataToMsgpackEncodingData(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="bigint"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(jsonEncodingDataToMsgpackEncodingData);if(typeof e=="object"){const t=new Map;for(const[r,n]of Object.entries(e))t.set(r,jsonEncodingDataToMsgpackEncodingData(n));return t}throw new Error(`Invalid JSON encoding data: ${e}`)}var MsgpackObjectPathSegmentKind;(function(e){e[e.MAP_VALUE=0]="MAP_VALUE",e[e.ARRAY_ELEMENT=1]="ARRAY_ELEMENT"})(MsgpackObjectPathSegmentKind||(MsgpackObjectPathSegmentKind={}));class MsgpackRawStringProvider{constructor({parent:t,segment:r,baseObjectBytes:n}){this.resolvedCache=null,this.resolvedCachePresent=!1,this.parent=t,this.segment=r,this.baseObjectBytes=n}withMapValue(t){return new MsgpackRawStringProvider({parent:this,segment:{kind:MsgpackObjectPathSegmentKind.MAP_VALUE,key:t}})}withArrayElement(t){return new MsgpackRawStringProvider({parent:this,segment:{kind:MsgpackObjectPathSegmentKind.ARRAY_ELEMENT,key:t}})}getRawStringAtCurrentLocation(){const t=this.resolve();if(t instanceof RawBinaryString)return t.rawBinaryValue;throw new Error(`Invalid type. Expected RawBinaryString, got ${t} (${typeof t})`)}getRawStringKeysAndValuesAtCurrentLocation(){const t=this.resolve();if(!(t instanceof Map))throw new Error(`Invalid type. Expected Map, got ${t} (${typeof t})`);const r=new Map;for(const[n,o]of t)if(n instanceof RawBinaryString)r.set(n.rawBinaryValue,o);else throw new Error(`Invalid type for map key. Expected RawBinaryString, got ${n} (${typeof n})`);return r}resolve(){if(this.resolvedCachePresent)return this.resolvedCache;let t;if(this.parent?t=this.parent.resolve():t=msgpackRawDecodeAsMapWithRawStrings(this.baseObjectBytes),!this.segment)return this.resolvedCache=t,this.resolvedCachePresent=!0,t;if(this.segment.kind===MsgpackObjectPathSegmentKind.MAP_VALUE){if(!(t instanceof Map))throw new Error(`Invalid type. Expected Map, got ${t} (${typeof t})`);if(typeof this.segment.key=="string"||this.segment.key instanceof Uint8Array||this.segment.key instanceof RawBinaryString){const r=this.segment.key instanceof RawBinaryString?this.segment.key.rawBinaryValue:coerceToBytes(this.segment.key),n=typeof this.segment.key=="string"||this.segment.key instanceof RawBinaryString;for(const[o,i]of t){let u;if(n?o instanceof RawBinaryString&&(u=o.rawBinaryValue):o instanceof Uint8Array&&(u=o),u&&arrayEqual(r,u)){this.resolvedCache=i;break}}}else this.resolvedCache=t.get(this.segment.key);return this.resolvedCachePresent=!0,this.resolvedCache}if(this.segment.kind===MsgpackObjectPathSegmentKind.ARRAY_ELEMENT){if(!Array.isArray(t))throw new Error(`Invalid type. Expected Array, got ${t} (${typeof t})`);return this.resolvedCache=t[this.segment.key],this.resolvedCachePresent=!0,this.resolvedCache}throw new Error(`Invalid segment kind: ${this.segment.kind}`)}getPathString(){const t=this.parent?this.parent.getPathString():"root";return this.segment?this.segment.kind===MsgpackObjectPathSegmentKind.MAP_VALUE?`${t} -> map key "${this.segment.key}" (${typeof this.segment.key})`:this.segment.kind===MsgpackObjectPathSegmentKind.ARRAY_ELEMENT?`${t} -> array index ${this.segment.key} (${typeof this.segment.key})`:`${t} -> unknown segment kind ${this.segment.kind}`:t}}class Schema{}function decodeMsgpack(e,t){const r=msgpackRawDecodeAsMap(e),n=new MsgpackRawStringProvider({baseObjectBytes:e});return t.fromEncodingData(t.encodingSchema.fromPreparedMsgpack(r,n))}function encodeMsgpack(e){return msgpackRawEncode(e.getEncodingSchema().prepareMsgpack(e.toEncodingData()))}class BooleanSchema extends Schema{defaultValue(){return!1}isDefaultValue(t){return t===!1}prepareMsgpack(t){if(typeof t=="boolean")return t;throw new Error("Invalid boolean")}fromPreparedMsgpack(t,r){if(typeof t=="boolean")return t;throw new Error("Invalid boolean")}prepareJSON(t,r){if(typeof t=="boolean")return t;throw new Error("Invalid boolean")}fromPreparedJSON(t){if(typeof t=="boolean")return t;throw new Error("Invalid boolean")}}class StringSchema extends Schema{defaultValue(){return""}isDefaultValue(t){return t===""}prepareMsgpack(t){if(typeof t=="string")return t;throw new Error(`Invalid string: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){if(typeof t=="string")return t;throw new Error(`Invalid string: (${typeof t}) ${t}`)}prepareJSON(t,r){if(typeof t=="string")return t;throw new Error(`Invalid string: (${typeof t}) ${t}`)}fromPreparedJSON(t){if(typeof t=="string")return t;throw new Error(`Invalid string: (${typeof t}) ${t}`)}}class Uint64Schema extends Schema{defaultValue(){return BigInt(0)}isDefaultValue(t){return typeof t=="bigint"?t===BigInt(0):typeof t=="number"?t===0:!1}prepareMsgpack(t){return ensureUint64(t)}fromPreparedMsgpack(t,r){return ensureUint64(t)}prepareJSON(t,r){return ensureUint64(t)}fromPreparedJSON(t){return ensureUint64(t)}}class AddressSchema extends Schema{defaultValue(){return Address.zeroAddress()}isDefaultValue(t){return Address.zeroAddress().equals(t)}prepareMsgpack(t){if(t instanceof Address)return t.publicKey;throw new Error(`Invalid address: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){return new Address(t)}prepareJSON(t,r){if(t instanceof Address)return t.toString();throw new Error(`Invalid address: (${typeof t}) ${t}`)}fromPreparedJSON(t){return Address.fromString(t)}}class ByteArraySchema extends Schema{defaultValue(){return new Uint8Array}isDefaultValue(t){return t instanceof Uint8Array&&t.byteLength===0}prepareMsgpack(t){if(t instanceof Uint8Array)return t;throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){if(t instanceof Uint8Array)return t;throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}prepareJSON(t,r){if(t instanceof Uint8Array)return bytesToBase64(t);throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}fromPreparedJSON(t){if(t==null)return this.defaultValue();if(typeof t=="string")return base64ToBytes(t);throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}}class FixedLengthByteArraySchema extends Schema{constructor(t){super(),this.length=t}defaultValue(){return new Uint8Array(this.length)}isDefaultValue(t){return t instanceof Uint8Array&&t.byteLength===this.length&&t.every(r=>r===0)}prepareMsgpack(t){if(t instanceof Uint8Array){if(t.byteLength===this.length)return t;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${t.byteLength}`)}throw new Error("Invalid byte array")}fromPreparedMsgpack(t,r){if(t instanceof Uint8Array){if(t.byteLength===this.length)return t;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${t.byteLength}`)}throw new Error("Invalid byte array")}prepareJSON(t){if(t instanceof Uint8Array){if(t.byteLength===this.length)return bytesToBase64(t);throw new Error(`Invalid byte array length: wanted ${this.length}, got ${t.byteLength}`)}throw new Error("Invalid byte array")}fromPreparedJSON(t){if(typeof t=="string"){const r=base64ToBytes(t);if(r.byteLength===this.length)return r;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${r.byteLength}`)}throw new Error("Invalid base64 byte array")}}const blockHashByteLength=32,base32Length=52;class BlockHashSchema extends Schema{defaultValue(){return new Uint8Array(blockHashByteLength)}isDefaultValue(t){return t instanceof Uint8Array&&t.byteLength===blockHashByteLength&&t.every(r=>r===0)}prepareMsgpack(t){if(t instanceof Uint8Array&&t.byteLength===blockHashByteLength)return t;throw new Error(`Invalid block hash: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){if(t instanceof Uint8Array&&t.byteLength===blockHashByteLength)return t;throw new Error(`Invalid block hash: (${typeof t}) ${t}`)}prepareJSON(t,r){if(t instanceof Uint8Array&&t.byteLength===blockHashByteLength)return`blk-${base32.encode(t).slice(0,base32Length)}`;throw new Error(`Invalid block hash: (${typeof t}) ${t}`)}fromPreparedJSON(t){if(typeof t=="string"&&t.length===base32Length+4&&t.startsWith("blk-"))return Uint8Array.from(base32.decode.asBytes(t.slice(4)));throw new Error(`Invalid block hash: (${typeof t}) ${t}`)}}class SpecialCaseBinaryStringSchema extends Schema{defaultValue(){return new Uint8Array}isDefaultValue(t){return t instanceof Uint8Array&&t.byteLength===0}prepareMsgpack(t){if(t instanceof Uint8Array)return new RawBinaryString(t);throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){return r.getRawStringAtCurrentLocation()}prepareJSON(t,r){if(t instanceof Uint8Array){const n=bytesToString(t);if(!r.lossyBinaryStringConversion&&!arrayEqual(coerceToBytes(n),t))throw new Error(`Invalid UTF-8 byte array encountered. Encode with lossyBinaryStringConversion enabled to bypass this check. Base64 value: ${bytesToBase64(t)}`);return n}throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}fromPreparedJSON(t){if(typeof t=="string")return coerceToBytes(t);throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}}class ArraySchema extends Schema{constructor(t){super(),this.itemSchema=t}defaultValue(){return[]}isDefaultValue(t){return Array.isArray(t)&&t.length===0}prepareMsgpack(t){if(Array.isArray(t))return t.map(r=>this.itemSchema.prepareMsgpack(r));throw new Error("ArraySchema data must be an array")}fromPreparedMsgpack(t,r){if(Array.isArray(t))return t.map((n,o)=>this.itemSchema.fromPreparedMsgpack(n,r.withArrayElement(o)));throw new Error(`ArraySchema encoded data must be an array: ${t} (${typeof t})`)}prepareJSON(t,r){if(Array.isArray(t))return t.map(n=>this.itemSchema.prepareJSON(n,r));throw new Error("ArraySchema data must be an array")}fromPreparedJSON(t){if(Array.isArray(t))return t.map(r=>this.itemSchema.fromPreparedJSON(r));throw new Error(`ArraySchema encoded data must be an array: ${t} (${typeof t})`)}}function allOmitEmpty(e){return e.map(t=>({...t,omitEmpty:!0}))}class NamedMapSchema extends Schema{constructor(t){super(),this.entries=t,this.checkEntries()}pushEntries(...t){this.entries.push(...t),this.checkEntries()}checkEntries(){for(const r of this.entries)if(r.embedded){if(r.key!=="")throw new Error("Embedded entries must have an empty key");if(!(r.valueSchema instanceof NamedMapSchema))throw new Error("Embedded entry valueSchema must be a NamedMapSchema")}const t=new Set;for(const r of this.getEntries()){if(t.has(r.key))throw new Error(`Duplicate key: ${r.key}`);t.add(r.key)}}getEntries(){const t=[];for(const r of this.entries)if(r.embedded){const n=r.valueSchema;t.push(...n.getEntries())}else t.push(r);return t}defaultValue(){const t=new Map;for(const r of this.getEntries())t.set(r.key,r.valueSchema.defaultValue());return t}isDefaultValue(t){if(!(t instanceof Map))return!1;for(const r of this.getEntries())if(!r.valueSchema.isDefaultValue(t.get(r.key)))return!1;return!0}prepareMsgpack(t){if(!(t instanceof Map))throw new Error(`NamedMapSchema data must be a Map. Got (${typeof t}) ${t}`);const r=new Map;for(const n of this.getEntries()){const o=t.get(n.key);n.omitEmpty&&n.valueSchema.isDefaultValue(o)||r.set(n.key,n.valueSchema.prepareMsgpack(o))}return r}fromPreparedMsgpack(t,r){if(!(t instanceof Map))throw new Error("NamedMapSchema data must be a Map");const n=new Map;for(const o of this.getEntries())if(t.has(o.key))n.set(o.key,o.valueSchema.fromPreparedMsgpack(t.get(o.key),r.withMapValue(o.key)));else if(o.omitEmpty)n.set(o.key,o.valueSchema.defaultValue());else throw new Error(`Missing key: ${o.key}`);return n}prepareJSON(t,r){if(!(t instanceof Map))throw new Error("NamedMapSchema data must be a Map");const n={};for(const o of this.getEntries()){const i=t.get(o.key);o.omitEmpty&&o.valueSchema.isDefaultValue(i)||(n[o.key]=o.valueSchema.prepareJSON(i,r))}return n}fromPreparedJSON(t){if(t==null||typeof t!="object"||Array.isArray(t))throw new Error("NamedMapSchema data must be an object");const r=new Map;for(const n of this.getEntries())if(Object.prototype.hasOwnProperty.call(t,n.key))r.set(n.key,n.valueSchema.fromPreparedJSON(t[n.key]));else if(n.omitEmpty)r.set(n.key,n.valueSchema.defaultValue());else throw new Error(`Missing key: ${n.key}`);return r}}function combineMaps(...e){const t=new Map;for(const r of e)for(const[n,o]of r){if(t.has(n))throw new Error(`Duplicate key: ${n}`);t.set(n,o)}return t}function convertMap(e,t){const r=new Map;for(const[n,o]of e){const[i,u]=t(n,o);r.set(i,u)}return r}class Uint64MapSchema extends Schema{constructor(t){super(),this.valueSchema=t}defaultValue(){return new Map}isDefaultValue(t){return t instanceof Map&&t.size===0}prepareMsgpack(t){if(!(t instanceof Map))throw new Error(`Uint64MapSchema data must be a Map. Got (${typeof t}) ${t}`);const r=new Map;for(const[n,o]of t){const i=ensureUint64(n);if(r.has(i))throw new Error(`Duplicate key: ${i}`);r.set(i,this.valueSchema.prepareMsgpack(o))}return r}fromPreparedMsgpack(t,r){if(!(t instanceof Map))throw new Error("Uint64MapSchema data must be a Map");const n=new Map;for(const[o,i]of t){const u=ensureUint64(o);if(n.has(u))throw new Error(`Duplicate key: ${u}`);n.set(u,this.valueSchema.fromPreparedMsgpack(i,r.withMapValue(o)))}return n}prepareJSON(t,r){if(!(t instanceof Map))throw new Error(`Uint64MapSchema data must be a Map. Got (${typeof t}) ${t}`);const n=new Map;for(const[i,u]of t){const a=ensureUint64(i);if(n.has(a))throw new Error(`Duplicate key: ${a}`);n.set(a,this.valueSchema.prepareJSON(u,r))}const o={};for(const[i,u]of n)o[i.toString()]=u;return o}fromPreparedJSON(t){if(t==null||typeof t!="object"||Array.isArray(t))throw new Error("Uint64MapSchema data must be an object");const r=new Map;for(const[n,o]of Object.entries(t)){const i=BigInt(n);if(r.has(i))throw new Error(`Duplicate key: ${i}`);r.set(i,this.valueSchema.fromPreparedJSON(o))}return r}}class ByteArrayMapSchema extends Schema{constructor(t){super(),this.valueSchema=t}defaultValue(){return new Map}isDefaultValue(t){return t instanceof Map&&t.size===0}prepareMsgpack(t){if(!(t instanceof Map))throw new Error(`ByteArrayMapSchema data must be a Map. Got (${typeof t}) ${t}`);const r=new Map;for(const[n,o]of t){if(!(n instanceof Uint8Array))throw new Error(`Invalid key: ${n} (${typeof n})`);r.set(n,this.valueSchema.prepareMsgpack(o))}return r}fromPreparedMsgpack(t,r){if(!(t instanceof Map))throw new Error("ByteArrayMapSchema data must be a Map");const n=new Map;for(const[o,i]of t){if(!(o instanceof Uint8Array))throw new Error(`Invalid key: ${o} (${typeof o})`);n.set(o,this.valueSchema.fromPreparedMsgpack(i,r.withMapValue(o)))}return n}prepareJSON(t,r){if(!(t instanceof Map))throw new Error(`ByteArrayMapSchema data must be a Map. Got (${typeof t}) ${t}`);const n=new Map;for(const[i,u]of t){if(!(i instanceof Uint8Array))throw new Error(`Invalid key: ${i} (${typeof i})`);const a=bytesToBase64(i);if(n.has(a))throw new Error(`Duplicate key (base64): ${a}`);n.set(a,this.valueSchema.prepareJSON(u,r))}const o={};for(const[i,u]of n)o[i]=u;return o}fromPreparedJSON(t){if(t==null||typeof t!="object"||Array.isArray(t))throw new Error("ByteArrayMapSchema data must be an object");const r=new Map;for(const[n,o]of Object.entries(t))r.set(base64ToBytes(n),this.valueSchema.fromPreparedJSON(o));return r}}function convertRawStringsInMsgpackValue(e){if(e instanceof RawBinaryString)return bytesToString(e.rawBinaryValue);if(e instanceof Map){const t=new Map;for(const[r,n]of e)t.set(convertRawStringsInMsgpackValue(r),convertRawStringsInMsgpackValue(n));return t}return Array.isArray(e)?e.map(convertRawStringsInMsgpackValue):e}class SpecialCaseBinaryStringMapSchema extends Schema{constructor(t){super(),this.valueSchema=t}defaultValue(){return new Map}isDefaultValue(t){return t instanceof Map&&t.size===0}prepareMsgpack(t){if(!(t instanceof Map))throw new Error(`SpecialCaseBinaryStringMapSchema data must be a Map. Got (${typeof t}) ${t}`);const r=new Map;for(const[n,o]of t){if(!(n instanceof Uint8Array))throw new Error(`Invalid key: ${n} (${typeof n})`);r.set(new RawBinaryString(n),this.valueSchema.prepareMsgpack(o))}return r}fromPreparedMsgpack(t,r){const n=new Map,o=r.getRawStringKeysAndValuesAtCurrentLocation();for(const[i,u]of o)n.set(i,this.valueSchema.fromPreparedMsgpack(convertRawStringsInMsgpackValue(u),r.withMapValue(new RawBinaryString(i))));return n}prepareJSON(t,r){if(!(t instanceof Map))throw new Error(`SpecialCaseBinaryStringMapSchema data must be a Map. Got (${typeof t}) ${t}`);const n=new Map;for(const[i,u]of t){if(!(i instanceof Uint8Array))throw new Error(`Invalid key: ${i}`);const a=bytesToString(i);if(!r.lossyBinaryStringConversion&&!arrayEqual(coerceToBytes(a),i))throw new Error(`Invalid UTF-8 byte array encountered. Encode with lossyBinaryStringConversion enabled to bypass this check. Base64 value: ${bytesToBase64(i)}`);n.set(a,this.valueSchema.prepareJSON(u,r))}const o={};for(const[i,u]of n)o[i]=u;return o}fromPreparedJSON(t){if(t==null||typeof t!="object"||Array.isArray(t))throw new Error("SpecialCaseBinaryStringMapSchema data must be an object");const r=new Map;for(const[n,o]of Object.entries(t))r.set(coerceToBytes(n),this.valueSchema.fromPreparedJSON(o));return r}}class OptionalSchema extends Schema{constructor(t){super(),this.valueSchema=t}defaultValue(){}isDefaultValue(t){return t===void 0||this.valueSchema.isDefaultValue(t)}prepareMsgpack(t){if(t!==void 0)return this.valueSchema.prepareMsgpack(t)}fromPreparedMsgpack(t,r){if(t!=null)return this.valueSchema.fromPreparedMsgpack(t,r)}prepareJSON(t,r){return t===void 0?null:this.valueSchema.prepareJSON(t,r)}fromPreparedJSON(t){if(t!=null)return this.valueSchema.fromPreparedJSON(t)}}class UntypedSchema extends Schema{defaultValue(){}isDefaultValue(t){return t===void 0}prepareMsgpack(t){return t}fromPreparedMsgpack(t,r){return t}prepareJSON(t,r){return msgpackEncodingDataToJSONEncodingData(t)}fromPreparedJSON(t){return jsonEncodingDataToMsgpackEncodingData(t)}}function boxReferenceToEncodingData(e,t,r){const n=BigInt(e.appIndex),o=e.name,i=n===BigInt(0)||n===r,u=t.indexOf(n)+1;if(u===0&&!i)throw new Error(`Box ref with appId ${n} not in foreign-apps`);return new Map([["i",u],["n",o]])}function boxReferencesToEncodingData(e,t,r){const n=BigInt(r),o=t.map(BigInt);return e.map(i=>boxReferenceToEncodingData(i,o,n))}function resourceReferencesToEncodingData(e,t){const r=[];function n(i){for(let u=0;u<r.length;u++){const a=r[u],s=a.get("d");if((!i.address&&!s||i.address&&s&&i.address.equals(s))&&a.get("s")===i.assetIndex&&a.get("p")===i.appIndex)return u+1}return i.address&&r.push(new Map([["d",i.address]])),i.assetIndex&&r.push(new Map([["s",i.assetIndex]])),i.appIndex&&r.push(new Map([["p",i.appIndex]])),r.length}const o=Address.zeroAddress();for(const i of t){if(i.address||i.assetIndex||i.appIndex){n(i);continue}if(i.holding){const u=i.holding;let a=0;u.address&&!u.address.equals(o)&&(a=n({address:u.address}));const s=n({assetIndex:u.assetIndex});r.push(new Map([["h",new Map([["d",a],["s",s]])]]));continue}if(i.locals){const u=i.locals;let a=0;u.address&&!u.address.equals(o)&&(a=n({address:u.address}));let s=0;u.appIndex&&BigInt(u.appIndex)!==e&&(s=n({appIndex:u.appIndex})),r.push(new Map([["l",new Map([["d",a],["p",s]])]]));continue}if(i.box){const u=i.box;let a=0;u.appIndex&&BigInt(u.appIndex)!==e&&(a=n({appIndex:u.appIndex})),r.push(new Map([["b",new Map([["i",a],["n",u.name]])]]))}}return r}function convertIndicesToResourceReferences(e){const t=[];for(const r of e){const n=r.get("d"),o=r.get("s"),i=r.get("p");if(n){t.push({address:n});continue}if(o){t.push({assetIndex:o});continue}if(i){t.push({appIndex:i});continue}const u=r.get("h");if(u){const f=ensureSafeUnsignedInteger(u.get("d")??0),c=ensureSafeUnsignedInteger(u.get("s"));if(!c)throw new Error(`Holding missing asset index: ${u}`);const d=f===0?Address.zeroAddress():t[f-1].address,p=t[c-1].assetIndex;t.push({holding:{address:d,assetIndex:p}});continue}const a=r.get("l");if(a){const f=ensureSafeUnsignedInteger(a.get("d")??0),c=ensureSafeUnsignedInteger(a.get("p")??0),d=f===0?Address.zeroAddress():t[f-1].address,p=c===0?BigInt(0):t[c-1].appIndex;t.push({locals:{address:d,appIndex:p}});continue}const s=r.get("b");if(s){const f=ensureSafeUnsignedInteger(s.get("i")??0),c=s.get("n");if(!c)throw new Error(`Box missing name: ${s}`);const d=f===0?BigInt(0):t[f-1].appIndex;t.push({box:{appIndex:d,name:c}})}}return t}var TransactionType;(function(e){e.pay="pay",e.keyreg="keyreg",e.acfg="acfg",e.axfer="axfer",e.afrz="afrz",e.appl="appl",e.stpf="stpf",e.hb="hb"})(TransactionType||(TransactionType={}));function isTransactionType(e){return e===TransactionType.pay||e===TransactionType.keyreg||e===TransactionType.acfg||e===TransactionType.axfer||e===TransactionType.afrz||e===TransactionType.appl||e===TransactionType.stpf||e===TransactionType.hb}var OnApplicationComplete;(function(e){e[e.NoOpOC=0]="NoOpOC",e[e.OptInOC=1]="OptInOC",e[e.CloseOutOC=2]="CloseOutOC",e[e.ClearStateOC=3]="ClearStateOC",e[e.UpdateApplicationOC=4]="UpdateApplicationOC",e[e.DeleteApplicationOC=5]="DeleteApplicationOC"})(OnApplicationComplete||(OnApplicationComplete={}));function isOnApplicationComplete(e){return e===OnApplicationComplete.NoOpOC||e===OnApplicationComplete.OptInOC||e===OnApplicationComplete.CloseOutOC||e===OnApplicationComplete.ClearStateOC||e===OnApplicationComplete.UpdateApplicationOC||e===OnApplicationComplete.DeleteApplicationOC}class HashFactory{constructor(t){this.hashType=t.hashType}getEncodingSchema(){return HashFactory.encodingSchema}toEncodingData(){return new Map([["t",this.hashType]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded HashFactory: ${t}`);return new HashFactory({hashType:Number(t.get("t"))})}}HashFactory.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"t",valueSchema:new Uint64Schema}]));class MerkleArrayProof{constructor(t){this.path=t.path,this.hashFactory=t.hashFactory,this.treeDepth=t.treeDepth}getEncodingSchema(){return MerkleArrayProof.encodingSchema}toEncodingData(){return new Map([["pth",this.path],["hsh",this.hashFactory.toEncodingData()],["td",this.treeDepth]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded MerkleArrayProof: ${t}`);return new MerkleArrayProof({path:t.get("pth"),hashFactory:HashFactory.fromEncodingData(t.get("hsh")),treeDepth:Number(t.get("td"))})}}MerkleArrayProof.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"pth",valueSchema:new ArraySchema(new ByteArraySchema)},{key:"hsh",valueSchema:HashFactory.encodingSchema},{key:"td",valueSchema:new Uint64Schema}]));class MerkleSignatureVerifier{constructor(t){this.commitment=t.commitment,this.keyLifetime=t.keyLifetime}getEncodingSchema(){return MerkleSignatureVerifier.encodingSchema}toEncodingData(){return new Map([["cmt",this.commitment],["lf",this.keyLifetime]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded MerkleSignatureVerifier: ${t}`);return new MerkleSignatureVerifier({commitment:t.get("cmt"),keyLifetime:t.get("lf")})}}MerkleSignatureVerifier.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"cmt",valueSchema:new FixedLengthByteArraySchema(64)},{key:"lf",valueSchema:new Uint64Schema}]));class Participant{constructor(t){this.pk=t.pk,this.weight=t.weight}getEncodingSchema(){return Participant.encodingSchema}toEncodingData(){return new Map([["p",this.pk.toEncodingData()],["w",this.weight]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded Participant: ${t}`);return new Participant({pk:MerkleSignatureVerifier.fromEncodingData(t.get("p")),weight:t.get("w")})}}Participant.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"p",valueSchema:MerkleSignatureVerifier.encodingSchema},{key:"w",valueSchema:new Uint64Schema}]));class FalconVerifier{constructor(t){this.publicKey=t.publicKey}getEncodingSchema(){return FalconVerifier.encodingSchema}toEncodingData(){return new Map([["k",this.publicKey]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded FalconVerifier: ${t}`);return new FalconVerifier({publicKey:t.get("k")})}}FalconVerifier.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"k",valueSchema:new FixedLengthByteArraySchema(1793)}]));class FalconSignatureStruct{constructor(t){this.signature=t.signature,this.vectorCommitmentIndex=t.index,this.proof=t.proof,this.verifyingKey=t.verifyingKey}getEncodingSchema(){return FalconSignatureStruct.encodingSchema}toEncodingData(){return new Map([["sig",this.signature],["idx",this.vectorCommitmentIndex],["prf",this.proof.toEncodingData()],["vkey",this.verifyingKey.toEncodingData()]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded FalconSignatureStruct: ${t}`);return new FalconSignatureStruct({signature:t.get("sig"),index:t.get("idx"),proof:MerkleArrayProof.fromEncodingData(t.get("prf")),verifyingKey:FalconVerifier.fromEncodingData(t.get("vkey"))})}}FalconSignatureStruct.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"sig",valueSchema:new ByteArraySchema},{key:"idx",valueSchema:new Uint64Schema},{key:"prf",valueSchema:MerkleArrayProof.encodingSchema},{key:"vkey",valueSchema:FalconVerifier.encodingSchema}]));class SigslotCommit{constructor(t){this.sig=t.sig,this.l=t.l}getEncodingSchema(){return SigslotCommit.encodingSchema}toEncodingData(){return new Map([["s",this.sig.toEncodingData()],["l",this.l]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded SigslotCommit: ${t}`);return new SigslotCommit({sig:FalconSignatureStruct.fromEncodingData(t.get("s")),l:t.get("l")})}}SigslotCommit.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"s",valueSchema:FalconSignatureStruct.encodingSchema},{key:"l",valueSchema:new Uint64Schema}]));class Reveal{constructor(t){this.sigslot=t.sigslot,this.participant=t.participant}getEncodingSchema(){return Reveal.encodingSchema}toEncodingData(){return new Map([["s",this.sigslot.toEncodingData()],["p",this.participant.toEncodingData()]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded Reveal: ${t}`);return new Reveal({sigslot:SigslotCommit.fromEncodingData(t.get("s")),participant:Participant.fromEncodingData(t.get("p"))})}}Reveal.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"s",valueSchema:SigslotCommit.encodingSchema},{key:"p",valueSchema:Participant.encodingSchema}]));class StateProof{constructor(t){this.sigCommit=t.sigCommit,this.signedWeight=t.signedWeight,this.sigProofs=t.sigProofs,this.partProofs=t.partProofs,this.merkleSignatureSaltVersion=t.merkleSignatureSaltVersion,this.reveals=t.reveals,this.positionsToReveal=t.positionsToReveal}getEncodingSchema(){return StateProof.encodingSchema}toEncodingData(){return new Map([["c",this.sigCommit],["w",this.signedWeight],["S",this.sigProofs.toEncodingData()],["P",this.partProofs.toEncodingData()],["v",this.merkleSignatureSaltVersion],["r",convertMap(this.reveals,(t,r)=>[t,r.toEncodingData()])],["pr",this.positionsToReveal]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded StateProof: ${t}`);return new StateProof({sigCommit:t.get("c"),signedWeight:t.get("w"),sigProofs:MerkleArrayProof.fromEncodingData(t.get("S")),partProofs:MerkleArrayProof.fromEncodingData(t.get("P")),merkleSignatureSaltVersion:Number(t.get("v")),reveals:convertMap(t.get("r"),(r,n)=>[r,Reveal.fromEncodingData(n)]),positionsToReveal:t.get("pr")})}}StateProof.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"c",valueSchema:new ByteArraySchema},{key:"w",valueSchema:new Uint64Schema},{key:"S",valueSchema:MerkleArrayProof.encodingSchema},{key:"P",valueSchema:MerkleArrayProof.encodingSchema},{key:"v",valueSchema:new Uint64Schema},{key:"r",valueSchema:new Uint64MapSchema(Reveal.encodingSchema)},{key:"pr",valueSchema:new ArraySchema(new Uint64Schema)}]));class StateProofMessage{constructor(t){this.blockHeadersCommitment=t.blockHeadersCommitment,this.votersCommitment=t.votersCommitment,this.lnProvenWeight=t.lnProvenWeight,this.firstAttestedRound=t.firstAttestedRound,this.lastAttestedRound=t.lastAttestedRound}getEncodingSchema(){return StateProofMessage.encodingSchema}toEncodingData(){return new Map([["b",this.blockHeadersCommitment],["v",this.votersCommitment],["P",this.lnProvenWeight],["f",this.firstAttestedRound],["l",this.lastAttestedRound]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded StateProofMessage: ${t}`);return new StateProofMessage({blockHeadersCommitment:t.get("b"),votersCommitment:t.get("v"),lnProvenWeight:t.get("P"),firstAttestedRound:t.get("f"),lastAttestedRound:t.get("l")})}static fromMap(t){return new StateProofMessage({blockHeadersCommitment:t.get("b"),votersCommitment:t.get("v"),lnProvenWeight:t.get("P"),firstAttestedRound:t.get("f"),lastAttestedRound:t.get("l")})}}StateProofMessage.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"b",valueSchema:new ByteArraySchema},{key:"v",valueSchema:new ByteArraySchema},{key:"P",valueSchema:new Uint64Schema},{key:"f",valueSchema:new Uint64Schema},{key:"l",valueSchema:new Uint64Schema}]));class HeartbeatProof{constructor(t){this.sig=t.sig,this.pk=t.pk,this.pk2=t.pk2,this.pk1Sig=t.pk1Sig,this.pk2Sig=t.pk2Sig}getEncodingSchema(){return HeartbeatProof.encodingSchema}toEncodingData(){return new Map([["s",this.sig],["p",this.pk],["p2",this.pk2],["p1s",this.pk1Sig],["p2s",this.pk2Sig]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded HeartbeatProof: ${t}`);return new HeartbeatProof({sig:t.get("s"),pk:t.get("p"),pk2:t.get("p2"),pk1Sig:t.get("p1s"),pk2Sig:t.get("p2s")})}}HeartbeatProof.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"s",valueSchema:new FixedLengthByteArraySchema(64)},{key:"p",valueSchema:new FixedLengthByteArraySchema(32)},{key:"p2",valueSchema:new FixedLengthByteArraySchema(32)},{key:"p1s",valueSchema:new FixedLengthByteArraySchema(64)},{key:"p2s",valueSchema:new FixedLengthByteArraySchema(64)}]));class Heartbeat{constructor(t){this.address=t.address,this.proof=t.proof,this.seed=t.seed,this.voteID=t.voteID,this.keyDilution=t.keyDilution}getEncodingSchema(){return Heartbeat.encodingSchema}toEncodingData(){return new Map([["a",this.address],["prf",this.proof.toEncodingData()],["sd",this.seed],["vid",this.voteID],["kd",this.keyDilution]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded Heartbeat: ${t}`);return new Heartbeat({address:t.get("a"),proof:HeartbeatProof.fromEncodingData(t.get("prf")),seed:t.get("sd"),voteID:t.get("vid"),keyDilution:t.get("kd")})}}Heartbeat.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"a",valueSchema:new AddressSchema},{key:"prf",valueSchema:HeartbeatProof.encodingSchema},{key:"sd",valueSchema:new ByteArraySchema},{key:"vid",valueSchema:new FixedLengthByteArraySchema(32)},{key:"kd",valueSchema:new Uint64Schema}]));const ALGORAND_TRANSACTION_LENGTH=52,ALGORAND_TRANSACTION_LEASE_LENGTH=32,NUM_ADDL_BYTES_AFTER_SIGNING=75,ASSET_METADATA_HASH_LENGTH=32,KEYREG_VOTE_KEY_LENGTH=32,KEYREG_SELECTION_KEY_LENGTH=32,KEYREG_STATE_PROOF_KEY_LENGTH=64,ALGORAND_TRANSACTION_GROUP_LENGTH=32;function uint8ArrayIsEmpty(e){return e.every(t=>t===0)}function getKeyregKey(e,t,r){if(e==null)return;let n;if(e instanceof Uint8Array&&(n=e),n==null||n.byteLength!==r)throw Error(`${t} must be a ${r} byte Uint8Array`);return n}function ensureAddress(e){if(e==null)throw new Error("Address must not be null or undefined");if(typeof e=="string")return Address.fromString(e);if(e instanceof Address)return e;throw new Error(`Not an address: ${e}`)}function optionalAddress(e){if(e==null)return;let t;if(e instanceof Address)t=e;else if(typeof e=="string")t=Address.fromString(e);else throw new Error(`Not an address: ${e}`);if(uint8ArrayIsEmpty(t.publicKey))throw new Error("Invalid use of the zero address. To omit this value, pass in undefined");return t}function optionalUint8Array(e){if(!(typeof e>"u")){if(e instanceof Uint8Array)return e;throw new Error(`Not a Uint8Array: ${e}`)}}function ensureUint8Array(e){if(e instanceof Uint8Array)return e;throw new Error(`Not a Uint8Array: ${e}`)}function optionalUint64(e){if(!(typeof e>"u"))return ensureUint64(e)}function ensureBoolean(e){if(e===!0||e===!1)return e;throw new Error(`Not a boolean: ${e}`)}function ensureArray(e){if(Array.isArray(e))return e.slice();throw new Error(`Not an array: ${e}`)}function optionalFixedLengthByteArray(e,t,r){const n=optionalUint8Array(e);if(!(typeof n>"u")){if(n.byteLength!==t)throw new Error(`${r} must be ${t} bytes long, was ${n.byteLength}`);if(!uint8ArrayIsEmpty(n))return n}}function ensureBoxReference(e){if(e!=null&&typeof e=="object"){const{appIndex:t,name:r}=e;return{appIndex:ensureUint64(t),name:ensureUint8Array(r)}}throw new Error(`Not a box reference: ${e}`)}function ensureHoldingReference(e){if(e!=null&&typeof e=="object"){const{assetIndex:t,address:r}=e;return{assetIndex:ensureUint64(t),address:ensureAddress(r)}}throw new Error(`Not a holding reference: ${e}`)}function ensureLocalsReference(e){if(e!=null&&typeof e=="object"){const{appIndex:t,address:r}=e;return{appIndex:ensureUint64(t),address:ensureAddress(r)}}throw new Error(`Not a locals reference: ${e}`)}function ensureResourceReference(e){if(e!=null&&typeof e=="object"){const{address:t,appIndex:r,assetIndex:n,holding:o,locals:i,box:u}=e;if(t!==void 0)return{address:ensureAddress(t)};if(r!==void 0)return{appIndex:ensureUint64(r)};if(n!==void 0)return{assetIndex:ensureUint64(n)};if(o!==void 0)return{holding:ensureHoldingReference(o)};if(i!==void 0)return{locals:ensureLocalsReference(i)};if(u!==void 0)return{box:ensureBoxReference(u)}}throw new Error(`Not a resource reference: ${e}`)}const TX_TAG=new TextEncoder().encode("TX");class Transaction{constructor(t){if(!isTransactionType(t.type))throw new Error(`Invalid transaction type: ${t.type}`);if(this.type=t.type,this.sender=ensureAddress(t.sender),this.note=ensureUint8Array(t.note??new Uint8Array),this.lease=optionalFixedLengthByteArray(t.lease,ALGORAND_TRANSACTION_LEASE_LENGTH,"lease"),this.rekeyTo=optionalAddress(t.rekeyTo),this.group=void 0,this.firstValid=ensureUint64(t.suggestedParams.firstValid),this.lastValid=ensureUint64(t.suggestedParams.lastValid),t.suggestedParams.genesisID){if(typeof t.suggestedParams.genesisID!="string")throw new Error("Genesis ID must be a string if present");this.genesisID=t.suggestedParams.genesisID}this.genesisHash=optionalUint8Array(t.suggestedParams.genesisHash);const r=[];if(t.paymentParams&&r.push(TransactionType.pay),t.keyregParams&&r.push(TransactionType.keyreg),t.assetConfigParams&&r.push(TransactionType.acfg),t.assetTransferParams&&r.push(TransactionType.axfer),t.assetFreezeParams&&r.push(TransactionType.afrz),t.appCallParams&&r.push(TransactionType.appl),t.stateProofParams&&r.push(TransactionType.stpf),t.heartbeatParams&&r.push(TransactionType.hb),r.length!==1)throw new Error(`Transaction has wrong number of type fields present (${r.length}): ${r}`);if(this.type!==r[0])throw new Error(`Transaction has type ${this.type} but fields present for ${r[0]}`);if(t.paymentParams&&(this.payment={receiver:ensureAddress(t.paymentParams.receiver),amount:ensureUint64(t.paymentParams.amount),closeRemainderTo:optionalAddress(t.paymentParams.closeRemainderTo)}),t.keyregParams){if(this.keyreg={voteKey:getKeyregKey(t.keyregParams.voteKey,"voteKey",KEYREG_VOTE_KEY_LENGTH),selectionKey:getKeyregKey(t.keyregParams.selectionKey,"selectionKey",KEYREG_SELECTION_KEY_LENGTH),stateProofKey:getKeyregKey(t.keyregParams.stateProofKey,"stateProofKey",KEYREG_STATE_PROOF_KEY_LENGTH),voteFirst:optionalUint64(t.keyregParams.voteFirst),voteLast:optionalUint64(t.keyregParams.voteLast),voteKeyDilution:optionalUint64(t.keyregParams.voteKeyDilution),nonParticipation:ensureBoolean(t.keyregParams.nonParticipation??!1)},this.keyreg.nonParticipation&&(this.keyreg.voteKey||this.keyreg.selectionKey||this.keyreg.stateProofKey||typeof this.keyreg.voteFirst<"u"||typeof this.keyreg.voteLast<"u"||typeof this.keyreg.voteKeyDilution<"u"))throw new Error("nonParticipation is true but participation params are present.");if(!this.keyreg.nonParticipation&&(this.keyreg.voteKey||this.keyreg.selectionKey||this.keyreg.stateProofKey||typeof this.keyreg.voteFirst<"u"||typeof this.keyreg.voteLast<"u"||typeof this.keyreg.voteKeyDilution<"u")&&!(this.keyreg.voteKey&&this.keyreg.selectionKey&&typeof this.keyreg.voteFirst<"u"&&typeof this.keyreg.voteLast<"u"&&typeof this.keyreg.voteKeyDilution<"u"))throw new Error("Online key registration missing at least one of the following fields: voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution")}if(t.assetConfigParams&&(this.assetConfig={assetIndex:ensureUint64(t.assetConfigParams.assetIndex??0),total:ensureUint64(t.assetConfigParams.total??0),decimals:ensureSafeUnsignedInteger(t.assetConfigParams.decimals??0),defaultFrozen:ensureBoolean(t.assetConfigParams.defaultFrozen??!1),manager:optionalAddress(t.assetConfigParams.manager),reserve:optionalAddress(t.assetConfigParams.reserve),freeze:optionalAddress(t.assetConfigParams.freeze),clawback:optionalAddress(t.assetConfigParams.clawback),unitName:t.assetConfigParams.unitName,assetName:t.assetConfigParams.assetName,assetURL:t.assetConfigParams.assetURL,assetMetadataHash:optionalFixedLengthByteArray(t.assetConfigParams.assetMetadataHash,ASSET_METADATA_HASH_LENGTH,"assetMetadataHash")}),t.assetTransferParams&&(this.assetTransfer={assetIndex:ensureUint64(t.assetTransferParams.assetIndex),amount:ensureUint64(t.assetTransferParams.amount),assetSender:optionalAddress(t.assetTransferParams.assetSender),receiver:ensureAddress(t.assetTransferParams.receiver),closeRemainderTo:optionalAddress(t.assetTransferParams.closeRemainderTo)}),t.assetFreezeParams&&(this.assetFreeze={assetIndex:ensureUint64(t.assetFreezeParams.assetIndex),freezeAccount:ensureAddress(t.assetFreezeParams.freezeTarget),frozen:ensureBoolean(t.assetFreezeParams.frozen)}),t.appCallParams){const{onComplete:o}=t.appCallParams;if(!isOnApplicationComplete(o))throw new Error(`Invalid onCompletion value: ${o}`);this.applicationCall={appIndex:ensureUint64(t.appCallParams.appIndex),onComplete:o,numLocalInts:ensureSafeUnsignedInteger(t.appCallParams.numLocalInts??0),numLocalByteSlices:ensureSafeUnsignedInteger(t.appCallParams.numLocalByteSlices??0),numGlobalInts:ensureSafeUnsignedInteger(t.appCallParams.numGlobalInts??0),numGlobalByteSlices:ensureSafeUnsignedInteger(t.appCallParams.numGlobalByteSlices??0),extraPages:ensureSafeUnsignedInteger(t.appCallParams.extraPages??0),approvalProgram:ensureUint8Array(t.appCallParams.approvalProgram??new Uint8Array),clearProgram:ensureUint8Array(t.appCallParams.clearProgram??new Uint8Array),appArgs:ensureArray(t.appCallParams.appArgs??[]).map(ensureUint8Array),accounts:ensureArray(t.appCallParams.accounts??[]).map(ensureAddress),foreignApps:ensureArray(t.appCallParams.foreignApps??[]).map(ensureUint64),foreignAssets:ensureArray(t.appCallParams.foreignAssets??[]).map(ensureUint64),boxes:ensureArray(t.appCallParams.boxes??[]).map(ensureBoxReference),access:ensureArray(t.appCallParams.access??[]).map(ensureResourceReference),rejectVersion:ensureSafeUnsignedInteger(t.appCallParams.rejectVersion??0)}}if(t.stateProofParams&&(this.stateProof={stateProofType:ensureSafeUnsignedInteger(t.stateProofParams.stateProofType??0),stateProof:t.stateProofParams.stateProof,message:t.stateProofParams.message}),t.heartbeatParams&&(this.heartbeat=new Heartbeat({address:t.heartbeatParams.address,proof:t.heartbeatParams.proof,seed:t.heartbeatParams.seed,voteID:t.heartbeatParams.voteID,keyDilution:t.heartbeatParams.keyDilution})),this.fee=ensureUint64(t.suggestedParams.fee),!ensureBoolean(t.suggestedParams.flatFee??!1)){const o=ensureUint64(t.suggestedParams.minFee);this.fee*=BigInt(this.estimateSize()),this.fee<o&&(this.fee=o)}}getEncodingSchema(){return Transaction.encodingSchema}toEncodingData(){const t=new Map([["type",this.type],["fv",this.firstValid],["lv",this.lastValid],["snd",this.sender],["gen",this.genesisID],["gh",this.genesisHash],["fee",this.fee],["note",this.note],["lx",this.lease],["rekey",this.rekeyTo],["grp",this.group]]);if(this.payment)return t.set("amt",this.payment.amount),t.set("rcv",this.payment.receiver),t.set("close",this.payment.closeRemainderTo),t;if(this.keyreg)return t.set("votekey",this.keyreg.voteKey),t.set("selkey",this.keyreg.selectionKey),t.set("sprfkey",this.keyreg.stateProofKey),t.set("votefst",this.keyreg.voteFirst),t.set("votelst",this.keyreg.voteLast),t.set("votekd",this.keyreg.voteKeyDilution),t.set("nonpart",this.keyreg.nonParticipation),t;if(this.assetConfig){t.set("caid",this.assetConfig.assetIndex);const r=new Map([["t",this.assetConfig.total],["dc",this.assetConfig.decimals],["df",this.assetConfig.defaultFrozen],["m",this.assetConfig.manager],["r",this.assetConfig.reserve],["f",this.assetConfig.freeze],["c",this.assetConfig.clawback],["un",this.assetConfig.unitName],["an",this.assetConfig.assetName],["au",this.assetConfig.assetURL],["am",this.assetConfig.assetMetadataHash]]);return t.set("apar",r),t}if(this.assetTransfer)return t.set("xaid",this.assetTransfer.assetIndex),t.set("aamt",this.assetTransfer.amount),t.set("arcv",this.assetTransfer.receiver),t.set("aclose",this.assetTransfer.closeRemainderTo),t.set("asnd",this.assetTransfer.assetSender),t;if(this.assetFreeze)return t.set("faid",this.assetFreeze.assetIndex),t.set("afrz",this.assetFreeze.frozen),t.set("fadd",this.assetFreeze.freezeAccount),t;if(this.applicationCall)return t.set("apid",this.applicationCall.appIndex),t.set("apan",this.applicationCall.onComplete),t.set("apaa",this.applicationCall.appArgs),t.set("apat",this.applicationCall.accounts),t.set("apas",this.applicationCall.foreignAssets),t.set("apfa",this.applicationCall.foreignApps),t.set("apbx",boxReferencesToEncodingData(this.applicationCall.boxes,this.applicationCall.foreignApps,this.applicationCall.appIndex)),t.set("al",resourceReferencesToEncodingData(this.applicationCall.appIndex,this.applicationCall.access)),t.set("apap",this.applicationCall.approvalProgram),t.set("apsu",this.applicationCall.clearProgram),t.set("apls",new Map([["nui",this.applicationCall.numLocalInts],["nbs",this.applicationCall.numLocalByteSlices]])),t.set("apgs",new Map([["nui",this.applicationCall.numGlobalInts],["nbs",this.applicationCall.numGlobalByteSlices]])),t.set("apep",this.applicationCall.extraPages),t.set("aprv",this.applicationCall.rejectVersion),t;if(this.stateProof)return t.set("sptype",this.stateProof.stateProofType),t.set("sp",this.stateProof.stateProof?this.stateProof.stateProof.toEncodingData():void 0),t.set("spmsg",this.stateProof.message?this.stateProof.message.toEncodingData():void 0),t;if(this.heartbeat){const r=new Heartbeat({address:this.heartbeat.address,proof:this.heartbeat.proof,seed:this.heartbeat.seed,voteID:this.heartbeat.voteID,keyDilution:this.heartbeat.keyDilution});return t.set("hb",r.toEncodingData()),t}throw new Error(`Unexpected transaction type: ${this.type}`)}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded logic sig account: ${t}`);const r={minFee:BigInt(0),flatFee:!0,fee:t.get("fee")??0,firstValid:t.get("fv")??0,lastValid:t.get("lv")??0,genesisHash:t.get("gh"),genesisID:t.get("gen")},n=t.get("type");if(!isTransactionType(n))throw new Error(`Unrecognized transaction type: ${n}`);const o={type:n,sender:t.get("snd")??Address.zeroAddress(),note:t.get("note"),lease:t.get("lx"),suggestedParams:r};if(t.get("rekey")&&(o.rekeyTo=t.get("rekey")),o.type===TransactionType.pay){const u={amount:t.get("amt")??0,receiver:t.get("rcv")??Address.zeroAddress()};t.get("close")&&(u.closeRemainderTo=t.get("close")),o.paymentParams=u}else if(o.type===TransactionType.keyreg){const u={voteKey:t.get("votekey"),selectionKey:t.get("selkey"),stateProofKey:t.get("sprfkey"),voteFirst:t.get("votefst"),voteLast:t.get("votelst"),voteKeyDilution:t.get("votekd"),nonParticipation:t.get("nonpart")};o.keyregParams=u}else if(o.type===TransactionType.acfg){const u={assetIndex:t.get("caid")};if(t.get("apar")){const a=t.get("apar");u.total=a.get("t"),u.decimals=a.get("dc"),u.defaultFrozen=a.get("df"),u.unitName=a.get("un"),u.assetName=a.get("an"),u.assetURL=a.get("au"),u.assetMetadataHash=a.get("am"),a.get("m")&&(u.manager=a.get("m")),a.get("r")&&(u.reserve=a.get("r")),a.get("f")&&(u.freeze=a.get("f")),a.get("c")&&(u.clawback=a.get("c"))}o.assetConfigParams=u}else if(o.type===TransactionType.axfer){const u={assetIndex:t.get("xaid")??0,amount:t.get("aamt")??0,receiver:t.get("arcv")??Address.zeroAddress()};t.get("aclose")&&(u.closeRemainderTo=t.get("aclose")),t.get("asnd")&&(u.assetSender=t.get("asnd")),o.assetTransferParams=u}else if(o.type===TransactionType.afrz){const u={assetIndex:t.get("faid")??0,freezeTarget:t.get("fadd")??Address.zeroAddress(),frozen:t.get("afrz")??!1};o.assetFreezeParams=u}else if(o.type===TransactionType.appl){const u={appIndex:t.get("apid")??0,onComplete:ensureSafeUnsignedInteger(t.get("apan")??0),appArgs:t.get("apaa"),accounts:t.get("apat"),foreignAssets:t.get("apas"),foreignApps:t.get("apfa"),approvalProgram:t.get("apap"),clearProgram:t.get("apsu"),extraPages:t.get("apep"),rejectVersion:t.get("aprv")??0},a=t.get("apls");a&&(u.numLocalInts=a.get("nui"),u.numLocalByteSlices=a.get("nbs"));const s=t.get("apgs");s&&(u.numGlobalInts=s.get("nui"),u.numGlobalByteSlices=s.get("nbs"));const f=t.get("apbx");f&&(u.boxes=f.map(d=>{const p=ensureSafeUnsignedInteger(d.get("i")??0),h=ensureUint8Array(d.get("n")??new Uint8Array);if(p===0)return{appIndex:0,name:h};if(!u.foreignApps||p>u.foreignApps.length)throw new Error(`Cannot find foreign app index ${p} in ${u.foreignApps}`);return{appIndex:u.foreignApps[p-1],name:h}}));const c=t.get("al");c&&(u.access=convertIndicesToResourceReferences(c)),o.appCallParams=u}else if(o.type===TransactionType.stpf){const u={stateProofType:t.get("sptype"),stateProof:t.get("sp")?StateProof.fromEncodingData(t.get("sp")):void 0,message:t.get("spmsg")?StateProofMessage.fromEncodingData(t.get("spmsg")):void 0};o.stateProofParams=u}else if(o.type===TransactionType.hb){const u=Heartbeat.fromEncodingData(t.get("hb")),a={address:u.address,proof:u.proof,seed:u.seed,voteID:u.voteID,keyDilution:u.keyDilution};o.heartbeatParams=a}else{const u=o.type;throw new Error(`Unexpected transaction type: ${u}`)}const i=new Transaction(o);if(t.get("grp")){const u=ensureUint8Array(t.get("grp"));if(u.byteLength!==ALGORAND_TRANSACTION_GROUP_LENGTH)throw new Error(`Invalid group length: ${u.byteLength}`);i.group=u}return i}estimateSize(){return this.toByte().length+NUM_ADDL_BYTES_AFTER_SIGNING}bytesToSign(){const t=this.toByte();return concatArrays(TX_TAG,t)}toByte(){return encodeMsgpack(this)}rawSignTxn(t){const r=this.bytesToSign();return sign(r,t)}signTxn(t){const r=keyPairFromSecretKey(t),n=new Address(r.publicKey),o=this.rawSignTxn(t);return this.attachSignature(n,o)}attachSignature(t,r){if(!isValidSignatureLength(r.length))throw new Error("Invalid signature length");const n=new Map([["sig",r],["txn",this.toEncodingData()]]),o=ensureAddress(t);this.sender.equals(o)||n.set("sgnr",o);const i=new NamedMapSchema(allOmitEmpty([{key:"txn",valueSchema:Transaction.encodingSchema},{key:"sig",valueSchema:new FixedLengthByteArraySchema(64)},{key:"sgnr",valueSchema:new OptionalSchema(new AddressSchema)}]));return msgpackRawEncode(i.prepareMsgpack(n))}rawTxID(){const t=this.toByte(),r=concatArrays(TX_TAG,t);return Uint8Array.from(genericHash(r))}txID(){const t=this.rawTxID();return base32.encode(t).slice(0,ALGORAND_TRANSACTION_LENGTH)}}Transaction.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"type",valueSchema:new StringSchema},{key:"snd",valueSchema:new AddressSchema},{key:"lv",valueSchema:new Uint64Schema},{key:"gen",valueSchema:new OptionalSchema(new StringSchema)},{key:"gh",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"fee",valueSchema:new Uint64Schema},{key:"fv",valueSchema:new Uint64Schema},{key:"note",valueSchema:new ByteArraySchema},{key:"lx",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"rekey",valueSchema:new OptionalSchema(new AddressSchema)},{key:"grp",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"amt",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"rcv",valueSchema:new OptionalSchema(new AddressSchema)},{key:"close",valueSchema:new OptionalSchema(new AddressSchema)},{key:"votekey",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"selkey",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"sprfkey",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(64))},{key:"votefst",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"votelst",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"votekd",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"nonpart",valueSchema:new OptionalSchema(new BooleanSchema)},{key:"caid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"apar",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"t",valueSchema:new Uint64Schema},{key:"dc",valueSchema:new Uint64Schema},{key:"df",valueSchema:new BooleanSchema},{key:"m",valueSchema:new OptionalSchema(new AddressSchema)},{key:"r",valueSchema:new OptionalSchema(new AddressSchema)},{key:"f",valueSchema:new OptionalSchema(new AddressSchema)},{key:"c",valueSchema:new OptionalSchema(new AddressSchema)},{key:"un",valueSchema:new OptionalSchema(new StringSchema)},{key:"an",valueSchema:new OptionalSchema(new StringSchema)},{key:"au",valueSchema:new OptionalSchema(new StringSchema)},{key:"am",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))}])))},{key:"xaid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"aamt",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"arcv",valueSchema:new OptionalSchema(new AddressSchema)},{key:"aclose",valueSchema:new OptionalSchema(new AddressSchema)},{key:"asnd",valueSchema:new OptionalSchema(new AddressSchema)},{key:"faid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"afrz",valueSchema:new OptionalSchema(new BooleanSchema)},{key:"fadd",valueSchema:new OptionalSchema(new AddressSchema)},{key:"apid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"apan",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"apaa",valueSchema:new OptionalSchema(new ArraySchema(new ByteArraySchema))},{key:"apat",valueSchema:new OptionalSchema(new ArraySchema(new AddressSchema))},{key:"apas",valueSchema:new OptionalSchema(new ArraySchema(new Uint64Schema))},{key:"apfa",valueSchema:new OptionalSchema(new ArraySchema(new Uint64Schema))},{key:"apbx",valueSchema:new OptionalSchema(new ArraySchema(new NamedMapSchema(allOmitEmpty([{key:"i",valueSchema:new Uint64Schema},{key:"n",valueSchema:new ByteArraySchema}]))))},{key:"al",valueSchema:new OptionalSchema(new ArraySchema(new NamedMapSchema(allOmitEmpty([{key:"d",valueSchema:new OptionalSchema(new AddressSchema)},{key:"s",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"p",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"h",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"d",valueSchema:new Uint64Schema},{key:"s",valueSchema:new Uint64Schema}])))},{key:"l",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"d",valueSchema:new Uint64Schema},{key:"p",valueSchema:new Uint64Schema}])))},{key:"b",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"i",valueSchema:new Uint64Schema},{key:"n",valueSchema:new ByteArraySchema}])))}]))))},{key:"apap",valueSchema:new OptionalSchema(new ByteArraySchema)},{key:"apsu",valueSchema:new OptionalSchema(new ByteArraySchema)},{key:"apls",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"nui",valueSchema:new Uint64Schema},{key:"nbs",valueSchema:new Uint64Schema}])))},{key:"apgs",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"nui",valueSchema:new Uint64Schema},{key:"nbs",valueSchema:new Uint64Schema}])))},{key:"apep",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"aprv",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"sptype",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"sp",valueSchema:new OptionalSchema(StateProof.encodingSchema)},{key:"spmsg",valueSchema:new OptionalSchema(StateProofMessage.encodingSchema)},{key:"hb",valueSchema:new OptionalSchema(Heartbeat.encodingSchema)}]));const MULTISIG_PREIMG2ADDR_PREFIX=new Uint8Array([77,117,108,116,105,115,105,103,65,100,100,114]),INVALID_MSIG_VERSION_ERROR_MSG="invalid multisig version",INVALID_MSIG_THRESHOLD_ERROR_MSG="bad multisig threshold",INVALID_MSIG_PK_ERROR_MSG="bad multisig public key - wrong length",UNEXPECTED_PK_LEN_ERROR_MSG="nacl public key length is not 32 bytes";function pksFromAddresses(e){return e.map(t=>typeof t=="string"?Address.fromString(t).publicKey:t.publicKey)}function addressFromMultisigPreImg({version:e,threshold:t,pks:r}){if(e!==1||e>255||e<0)throw new Error(INVALID_MSIG_VERSION_ERROR_MSG);if(t===0||r.length===0||t>r.length||t>255)throw new Error(INVALID_MSIG_THRESHOLD_ERROR_MSG);const n=ALGORAND_ADDRESS_BYTE_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH;if(n!==PUBLIC_KEY_LENGTH)throw new Error(UNEXPECTED_PK_LEN_ERROR_MSG);const o=new Uint8Array(MULTISIG_PREIMG2ADDR_PREFIX.length+2+n*r.length);o.set(MULTISIG_PREIMG2ADDR_PREFIX,0),o.set([e],MULTISIG_PREIMG2ADDR_PREFIX.length),o.set([t],MULTISIG_PREIMG2ADDR_PREFIX.length+1);for(let i=0;i<r.length;i++){if(r[i].length!==n)throw new Error(INVALID_MSIG_PK_ERROR_MSG);o.set(r[i],MULTISIG_PREIMG2ADDR_PREFIX.length+2+i*n)}return new Address(Uint8Array.from(genericHash(o)))}function verifyMultisig$1(e,t,r){const n=t.v,o=t.thr,i=t.subsig,u=i.map(c=>c.pk);if(t.subsig.length<o)return!1;let a;try{a=addressFromMultisigPreImg({version:n,threshold:o,pks:u}).publicKey}catch{return!1}if(!arrayEqual(a,r))return!1;let s=0;for(const c of i)c.s!==void 0&&(s+=1);if(s<o)return!1;let f=0;for(const c of i)c.s!==void 0&&verify(e,c.s,c.pk)&&(f+=1);return!(f<o)}const ENCODED_SUBSIG_SCHEMA=new NamedMapSchema(allOmitEmpty([{key:"pk",valueSchema:new FixedLengthByteArraySchema(32)},{key:"s",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(64))}]));function encodedSubsigFromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EncodedSubsig: ${e}`);const t={pk:e.get("pk")};return e.get("s")&&(t.s=e.get("s")),t}function encodedSubsigToEncodingData(e){const t=new Map([["pk",e.pk]]);return e.s&&t.set("s",e.s),t}const ENCODED_MULTISIG_SCHEMA=new NamedMapSchema(allOmitEmpty([{key:"v",valueSchema:new Uint64Schema},{key:"thr",valueSchema:new Uint64Schema},{key:"subsig",valueSchema:new ArraySchema(ENCODED_SUBSIG_SCHEMA)}]));function encodedMultiSigFromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EncodedMultiSig: ${e}`);return{v:ensureSafeUnsignedInteger(e.get("v")),thr:ensureSafeUnsignedInteger(e.get("thr")),subsig:e.get("subsig").map(encodedSubsigFromEncodingData)}}function encodedMultiSigToEncodingData(e){return new Map([["v",e.v],["thr",e.thr],["subsig",e.subsig.map(encodedSubsigToEncodingData)]])}const base64regex=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;function sanityCheckProgram(e){if(!e||e.length===0)throw new Error("empty program");const t=10,r=32,n=126,o=u=>r<=u&&u<=n;if(e.every(u=>u===t||o(u))){const u=new TextDecoder().decode(e);throw isValidAddress(u)?new Error("requesting program bytes, get Algorand address"):base64regex.test(u)?new Error("program should not be b64 encoded"):new Error("program bytes are all ASCII printable characters, not looking like Teal byte code")}}const programTag=new TextEncoder().encode("Program"),multisigProgramTag=new TextEncoder().encode("MsigProgram");class LogicSig{constructor(t,r){if(r&&(!Array.isArray(r)||!r.every(o=>o.constructor===Uint8Array)))throw new TypeError("Invalid arguments");let n=[];r!=null&&(n=r.map(o=>new Uint8Array(o))),sanityCheckProgram(t),this.logic=t,this.args=n,this.sig=void 0,this.msig=void 0,this.lmsig=void 0}getEncodingSchema(){return LogicSig.encodingSchema}toEncodingData(){const t=new Map([["l",this.logic],["arg",this.args],["sig",this.sig]]);return this.msig&&t.set("msig",encodedMultiSigToEncodingData(this.msig)),this.lmsig&&t.set("lmsig",encodedMultiSigToEncodingData(this.lmsig)),t}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded logic sig: ${t}`);const r=new LogicSig(t.get("l"),t.get("arg"));return r.sig=t.get("sig"),t.get("msig")&&(r.msig=encodedMultiSigFromEncodingData(t.get("msig"))),t.get("lmsig")&&(r.lmsig=encodedMultiSigFromEncodingData(t.get("lmsig"))),r}verify(t){if([this.sig,this.msig,this.lmsig].filter(Boolean).length>1)return!1;try{sanityCheckProgram(this.logic)}catch{return!1}const n=concatArrays(programTag,this.logic);if(!this.sig&&!this.msig&&!this.lmsig){const o=genericHash(n);return arrayEqual(o,t)}if(this.sig)return verify(n,this.sig,t);if(this.lmsig){const o=addressFromMultisigPreImg({version:this.lmsig.v,threshold:this.lmsig.thr,pks:this.lmsig.subsig.map(u=>u.pk)}),i=concatArrays(multisigProgramTag,o.publicKey,this.logic);return verifyMultisig$1(i,this.lmsig,t)}return this.msig?verifyMultisig$1(n,this.msig,t):!1}address(){const t=concatArrays(programTag,this.logic),r=genericHash(t);return new Address(Uint8Array.from(r))}sign(t,r){if(r==null)this.sig=this.signProgram(t);else{const n=pksFromAddresses(r.addrs).map(u=>({pk:u}));this.lmsig={v:r.version,thr:r.threshold,subsig:n};const[o,i]=this.singleSignMultisig(t,this.lmsig);this.lmsig.subsig[i].s=o}}appendToMultisig(t){if(this.lmsig===void 0)throw new Error("no multisig present");const[r,n]=this.singleSignMultisig(t,this.lmsig);this.lmsig.subsig[n].s=r}signProgram(t){const r=concatArrays(programTag,this.logic);return sign(r,t)}signProgramMultisig(t,r){const n=addressFromMultisigPreImg({version:r.v,threshold:r.thr,pks:r.subsig.map(u=>u.pk)}),o=concatArrays(multisigProgramTag,n.publicKey,this.logic);return sign(o,t)}singleSignMultisig(t,r){let n=-1;const o=keyPairFromSecretKey(t).publicKey;for(let u=0;u<r.subsig.length;u++){const{pk:a}=r.subsig[u];if(arrayEqual(a,o)){n=u;break}}if(n===-1)throw new Error("invalid secret key");return[this.signProgramMultisig(t,r),n]}toByte(){return encodeMsgpack(this)}static fromByte(t){return decodeMsgpack(t,LogicSig)}}LogicSig.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"l",valueSchema:new ByteArraySchema},{key:"arg",valueSchema:new ArraySchema(new ByteArraySchema)},{key:"sig",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(64))},{key:"msig",valueSchema:new OptionalSchema(ENCODED_MULTISIG_SCHEMA)},{key:"lmsig",valueSchema:new OptionalSchema(ENCODED_MULTISIG_SCHEMA)}]));new NamedMapSchema(allOmitEmpty([{key:"lsig",valueSchema:LogicSig.encodingSchema},{key:"sigkey",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))}]));new TextEncoder().encode("ProgData");class SignedTransaction{constructor({txn:t,sig:r,msig:n,lsig:o,sgnr:i}){this.txn=t,this.sig=r,this.msig=n,this.lsig=o,this.sgnr=i;let u=0;if(r&&(u+=1),n&&(u+=1),o&&(u+=1),u>1)throw new Error(`SignedTransaction must not have more than 1 signature. Got ${u}`)}getEncodingSchema(){return SignedTransaction.encodingSchema}toEncodingData(){return new Map([["txn",this.txn.toEncodingData()],["sig",this.sig],["msig",this.msig?encodedMultiSigToEncodingData(this.msig):void 0],["lsig",this.lsig?this.lsig.toEncodingData():void 0],["sgnr",this.sgnr]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded SignedTransaction: ${t}`);return new SignedTransaction({txn:Transaction.fromEncodingData(t.get("txn")),sig:t.get("sig"),msig:t.get("msig")?encodedMultiSigFromEncodingData(t.get("msig")):void 0,lsig:t.get("lsig")?LogicSig.fromEncodingData(t.get("lsig")):void 0,sgnr:t.get("sgnr")})}}SignedTransaction.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"txn",valueSchema:Transaction.encodingSchema},{key:"sig",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(64))},{key:"msig",valueSchema:new OptionalSchema(ENCODED_MULTISIG_SCHEMA)},{key:"lsig",valueSchema:new OptionalSchema(LogicSig.encodingSchema)},{key:"sgnr",valueSchema:new OptionalSchema(new AddressSchema)}]));function decodeSignedTransaction(e){return decodeMsgpack(e,SignedTransaction)}class StateProofTrackingData{constructor(t){this.stateProofVotersCommitment=t.stateProofVotersCommitment,this.stateProofOnlineTotalWeight=t.stateProofOnlineTotalWeight,this.stateProofNextRound=t.stateProofNextRound}getEncodingSchema(){return StateProofTrackingData.encodingSchema}toEncodingData(){return new Map([["v",this.stateProofVotersCommitment],["t",this.stateProofOnlineTotalWeight],["n",this.stateProofNextRound]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded StateProofTrackingData: ${t}`);return new StateProofTrackingData({stateProofVotersCommitment:t.get("v"),stateProofOnlineTotalWeight:t.get("t"),stateProofNextRound:t.get("n")})}}StateProofTrackingData.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"v",valueSchema:new ByteArraySchema},{key:"t",valueSchema:new Uint64Schema},{key:"n",valueSchema:new Uint64Schema}]));class TxnCommitments{constructor(t){this.nativeSha512_256Commitment=t.nativeSha512_256Commitment,this.sha256Commitment=t.sha256Commitment}getEncodingSchema(){return TxnCommitments.encodingSchema}toEncodingData(){return new Map([["txn",this.nativeSha512_256Commitment],["txn256",this.sha256Commitment]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded TxnCommitments: ${t}`);return new TxnCommitments({nativeSha512_256Commitment:t.get("txn"),sha256Commitment:t.get("txn256")})}}TxnCommitments.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"txn",valueSchema:new FixedLengthByteArraySchema(32)},{key:"txn256",valueSchema:new FixedLengthByteArraySchema(32)}]));class RewardState{constructor(t){this.feeSink=t.feeSink,this.rewardsPool=t.rewardsPool,this.rewardsLevel=t.rewardsLevel,this.rewardsRate=t.rewardsRate,this.rewardsResidue=t.rewardsResidue,this.rewardsRecalculationRound=t.rewardsRecalculationRound}getEncodingSchema(){return RewardState.encodingSchema}toEncodingData(){return new Map([["fees",this.feeSink],["rwd",this.rewardsPool],["earn",this.rewardsLevel],["rate",this.rewardsRate],["frac",this.rewardsResidue],["rwcalr",this.rewardsRecalculationRound]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded RewardState: ${t}`);return new RewardState({feeSink:t.get("fees"),rewardsPool:t.get("rwd"),rewardsLevel:t.get("earn"),rewardsRate:t.get("rate"),rewardsResidue:t.get("frac"),rewardsRecalculationRound:t.get("rwcalr")})}}RewardState.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"fees",valueSchema:new AddressSchema},{key:"rwd",valueSchema:new AddressSchema},{key:"earn",valueSchema:new Uint64Schema},{key:"rate",valueSchema:new Uint64Schema},{key:"frac",valueSchema:new Uint64Schema},{key:"rwcalr",valueSchema:new Uint64Schema}]));class UpgradeState{constructor(t){this.currentProtocol=t.currentProtocol,this.nextProtocol=t.nextProtocol,this.nextProtocolApprovals=t.nextProtocolApprovals,this.nextProtocolVoteBefore=t.nextProtocolVoteBefore,this.nextProtocolSwitchOn=t.nextProtocolSwitchOn}getEncodingSchema(){return UpgradeState.encodingSchema}toEncodingData(){return new Map([["proto",this.currentProtocol],["nextproto",this.nextProtocol],["nextyes",this.nextProtocolApprovals],["nextbefore",this.nextProtocolVoteBefore],["nextswitch",this.nextProtocolSwitchOn]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded UpgradeState: ${t}`);return new UpgradeState({currentProtocol:t.get("proto"),nextProtocol:t.get("nextproto"),nextProtocolApprovals:t.get("nextyes"),nextProtocolVoteBefore:t.get("nextbefore"),nextProtocolSwitchOn:t.get("nextswitch")})}}UpgradeState.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"proto",valueSchema:new StringSchema},{key:"nextproto",valueSchema:new StringSchema},{key:"nextyes",valueSchema:new Uint64Schema},{key:"nextbefore",valueSchema:new Uint64Schema},{key:"nextswitch",valueSchema:new Uint64Schema}]));class UpgradeVote{constructor(t){this.upgradePropose=t.upgradePropose,this.upgradeDelay=t.upgradeDelay,this.upgradeApprove=t.upgradeApprove}getEncodingSchema(){return UpgradeVote.encodingSchema}toEncodingData(){return new Map([["upgradeprop",this.upgradePropose],["upgradedelay",this.upgradeDelay],["upgradeyes",this.upgradeApprove]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded UpgradeVote: ${t}`);return new UpgradeVote({upgradePropose:t.get("upgradeprop"),upgradeDelay:t.get("upgradedelay"),upgradeApprove:t.get("upgradeyes")})}}UpgradeVote.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"upgradeprop",valueSchema:new StringSchema},{key:"upgradedelay",valueSchema:new Uint64Schema},{key:"upgradeyes",valueSchema:new BooleanSchema}]));class ParticipationUpdates{constructor(t){this.expiredParticipationAccounts=t.expiredParticipationAccounts,this.absentParticipationAccounts=t.absentParticipationAccounts}getEncodingSchema(){return ParticipationUpdates.encodingSchema}toEncodingData(){return new Map([["partupdrmv",this.expiredParticipationAccounts],["partupdabs",this.absentParticipationAccounts]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded ParticipationUpdates: ${t}`);return new ParticipationUpdates({expiredParticipationAccounts:t.get("partupdrmv"),absentParticipationAccounts:t.get("partupdabs")})}}ParticipationUpdates.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"partupdrmv",valueSchema:new ArraySchema(new AddressSchema)},{key:"partupdabs",valueSchema:new ArraySchema(new AddressSchema)}]));class BlockHeader{constructor(t){this.round=t.round,this.branch=t.branch,this.seed=t.seed,this.txnCommitments=t.txnCommitments,this.timestamp=t.timestamp,this.genesisID=t.genesisID,this.genesisHash=t.genesisHash,this.proposer=t.proposer,this.feesCollected=t.feesCollected,this.bonus=t.bonus,this.proposerPayout=t.proposerPayout,this.rewardState=t.rewardState,this.upgradeState=t.upgradeState,this.upgradeVote=t.upgradeVote,this.txnCounter=t.txnCounter,this.stateproofTracking=t.stateproofTracking,this.participationUpdates=t.participationUpdates}getEncodingSchema(){return BlockHeader.encodingSchema}toEncodingData(){const t=new Map([["rnd",this.round],["prev",this.branch],["seed",this.seed],["ts",this.timestamp],["gen",this.genesisID],["gh",this.genesisHash],["prp",this.proposer],["fc",this.feesCollected],["bi",this.bonus],["pp",this.proposerPayout],["tc",this.txnCounter],["spt",convertMap(this.stateproofTracking,(r,n)=>[r,n.toEncodingData()])]]);return combineMaps(t,this.txnCommitments.toEncodingData(),this.rewardState.toEncodingData(),this.upgradeState.toEncodingData(),this.upgradeVote.toEncodingData(),this.participationUpdates.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded BlockHeader: ${t}`);return new BlockHeader({round:t.get("rnd"),branch:t.get("prev"),seed:t.get("seed"),txnCommitments:TxnCommitments.fromEncodingData(t),timestamp:t.get("ts"),genesisID:t.get("gen"),genesisHash:t.get("gh"),proposer:t.get("prp"),feesCollected:t.get("fc"),bonus:t.get("bi"),proposerPayout:t.get("pp"),rewardState:RewardState.fromEncodingData(t),upgradeState:UpgradeState.fromEncodingData(t),upgradeVote:UpgradeVote.fromEncodingData(t),txnCounter:t.get("tc"),stateproofTracking:convertMap(t.get("spt"),(r,n)=>[Number(r),StateProofTrackingData.fromEncodingData(n)]),participationUpdates:ParticipationUpdates.fromEncodingData(t)})}}BlockHeader.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"rnd",valueSchema:new Uint64Schema},{key:"prev",valueSchema:new BlockHashSchema},{key:"seed",valueSchema:new ByteArraySchema},{key:"",valueSchema:TxnCommitments.encodingSchema,embedded:!0},{key:"ts",valueSchema:new Uint64Schema},{key:"gen",valueSchema:new StringSchema},{key:"gh",valueSchema:new FixedLengthByteArraySchema(32)},{key:"prp",valueSchema:new AddressSchema},{key:"fc",valueSchema:new Uint64Schema},{key:"bi",valueSchema:new Uint64Schema},{key:"pp",valueSchema:new Uint64Schema},{key:"",valueSchema:RewardState.encodingSchema,embedded:!0},{key:"",valueSchema:UpgradeState.encodingSchema,embedded:!0},{key:"",valueSchema:UpgradeVote.encodingSchema,embedded:!0},{key:"tc",valueSchema:new Uint64Schema},{key:"spt",valueSchema:new Uint64MapSchema(StateProofTrackingData.encodingSchema)},{key:"",valueSchema:ParticipationUpdates.encodingSchema,embedded:!0}]));class ValueDelta{constructor(t){this.action=t.action,this.bytes=t.bytes,this.uint=t.uint}getEncodingSchema(){return ValueDelta.encodingSchema}toEncodingData(){return new Map([["at",this.action],["bs",this.bytes],["ui",this.uint]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded ValueDelta: ${t}`);return new ValueDelta({action:Number(t.get("at")),bytes:t.get("bs"),uint:t.get("ui")})}}ValueDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"at",valueSchema:new Uint64Schema},{key:"bs",valueSchema:new SpecialCaseBinaryStringSchema},{key:"ui",valueSchema:new Uint64Schema}]));class EvalDelta{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new NamedMapSchema([]),this.encodingSchemaValue.pushEntries(...allOmitEmpty([{key:"gd",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringMapSchema(ValueDelta.encodingSchema))},{key:"ld",valueSchema:new OptionalSchema(new Uint64MapSchema(new SpecialCaseBinaryStringMapSchema(ValueDelta.encodingSchema)))},{key:"sa",valueSchema:new OptionalSchema(new ArraySchema(new AddressSchema))},{key:"lg",valueSchema:new OptionalSchema(new ArraySchema(new SpecialCaseBinaryStringSchema))},{key:"itx",valueSchema:new OptionalSchema(new ArraySchema(SignedTxnWithAD.encodingSchema))}]))),this.encodingSchemaValue}constructor(t){this.globalDelta=t.globalDelta??new Map,this.localDeltas=t.localDeltas??new Map,this.sharedAccts=t.sharedAccts??[],this.logs=t.logs??[],this.innerTxns=t.innerTxns??[]}getEncodingSchema(){return EvalDelta.encodingSchema}toEncodingData(){return new Map([["gd",convertMap(this.globalDelta,(t,r)=>[t,r.toEncodingData()])],["ld",convertMap(this.localDeltas,(t,r)=>[t,convertMap(r,(n,o)=>[n,o.toEncodingData()])])],["sa",this.sharedAccts],["lg",this.logs],["itx",this.innerTxns.map(t=>t.toEncodingData())]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded EvalDelta: ${t}`);return new EvalDelta({globalDelta:t.get("gd")?convertMap(t.get("gd"),(r,n)=>[r,ValueDelta.fromEncodingData(n)]):void 0,localDeltas:t.get("ld")?convertMap(t.get("ld"),(r,n)=>[Number(r),convertMap(n,(o,i)=>[o,ValueDelta.fromEncodingData(i)])]):void 0,sharedAccts:t.get("sa"),logs:t.get("lg"),innerTxns:(t.get("itx")??[]).map(SignedTxnWithAD.fromEncodingData)})}}class ApplyData{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new NamedMapSchema([]),this.encodingSchemaValue.pushEntries(...allOmitEmpty([{key:"ca",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"aca",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"rs",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"rr",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"rc",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"dt",valueSchema:new OptionalSchema(EvalDelta.encodingSchema)},{key:"caid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"apid",valueSchema:new OptionalSchema(new Uint64Schema)}]))),this.encodingSchemaValue}constructor(t){this.closingAmount=t.closingAmount,this.assetClosingAmount=t.assetClosingAmount,this.senderRewards=t.senderRewards,this.receiverRewards=t.receiverRewards,this.closeRewards=t.closeRewards,this.evalDelta=t.evalDelta,this.configAsset=t.configAsset,this.applicationID=t.applicationID}getEncodingSchema(){return ApplyData.encodingSchema}toEncodingData(){return new Map([["ca",this.closingAmount],["aca",this.assetClosingAmount],["rs",this.senderRewards],["rr",this.receiverRewards],["rc",this.closeRewards],["dt",this.evalDelta?this.evalDelta.toEncodingData():void 0],["caid",this.configAsset],["apid",this.applicationID]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded ApplyData: ${t}`);return new ApplyData({closingAmount:t.get("ca"),assetClosingAmount:t.get("aca"),senderRewards:t.get("rs"),receiverRewards:t.get("rr"),closeRewards:t.get("rc"),evalDelta:t.get("dt")?EvalDelta.fromEncodingData(t.get("dt")):void 0,configAsset:t.get("caid"),applicationID:t.get("apid")})}}class SignedTxnWithAD{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new NamedMapSchema([]),this.encodingSchemaValue.pushEntries(...allOmitEmpty([{key:"",valueSchema:SignedTransaction.encodingSchema,embedded:!0},{key:"",valueSchema:ApplyData.encodingSchema,embedded:!0}]))),this.encodingSchemaValue}constructor(t){this.signedTxn=t.signedTxn,this.applyData=t.applyData}getEncodingSchema(){return SignedTxnWithAD.encodingSchema}toEncodingData(){return combineMaps(this.signedTxn.toEncodingData(),this.applyData.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded SignedTxnWithAD: ${t}`);return new SignedTxnWithAD({signedTxn:SignedTransaction.fromEncodingData(t),applyData:ApplyData.fromEncodingData(t)})}}class SignedTxnInBlock{constructor(t){this.signedTxn=t.signedTxn,this.hasGenesisID=t.hasGenesisID,this.hasGenesisHash=t.hasGenesisHash}getEncodingSchema(){return SignedTxnInBlock.encodingSchema}toEncodingData(){const t=new Map([["hgi",this.hasGenesisID],["hgh",this.hasGenesisHash]]);return combineMaps(t,this.signedTxn.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded SignedTxnInBlock: ${t}`);return new SignedTxnInBlock({signedTxn:SignedTxnWithAD.fromEncodingData(t),hasGenesisID:t.get("hgi"),hasGenesisHash:t.get("hgh")})}}SignedTxnInBlock.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"",valueSchema:SignedTxnWithAD.encodingSchema,embedded:!0},{key:"hgi",valueSchema:new BooleanSchema},{key:"hgh",valueSchema:new BooleanSchema}]));new NamedMapSchema(allOmitEmpty([{key:"",valueSchema:BlockHeader.encodingSchema,embedded:!0},{key:"txns",valueSchema:new ArraySchema(SignedTxnInBlock.encodingSchema)}]));class TealValue{constructor(t){this.type=t.type,this.bytes=t.bytes,this.uint=t.uint}getEncodingSchema(){return TealValue.encodingSchema}toEncodingData(){return new Map([["tt",this.type],["tb",this.bytes],["ui",this.uint]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded TealValue: ${t}`);return new TealValue({type:Number(t.get("tt")),bytes:t.get("tb"),uint:t.get("ui")})}}TealValue.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"tt",valueSchema:new Uint64Schema},{key:"tb",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringSchema)},{key:"ui",valueSchema:new OptionalSchema(new Uint64Schema)}]));class StateSchema{constructor(t){this.numUints=t.numUints,this.numByteSlices=t.numByteSlices}getEncodingSchema(){return StateSchema.encodingSchema}toEncodingData(){return new Map([["nui",this.numUints],["nbs",this.numByteSlices]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded StateSchema: ${t}`);return new StateSchema({numUints:Number(t.get("nui")),numByteSlices:Number(t.get("nbs"))})}}StateSchema.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"nui",valueSchema:new Uint64Schema},{key:"nbs",valueSchema:new Uint64Schema}]));class AppParams{constructor(t){this.approvalProgram=t.approvalProgram,this.clearStateProgram=t.clearStateProgram,this.globalState=t.globalState,this.localStateSchema=t.localStateSchema,this.globalStateSchema=t.globalStateSchema,this.extraProgramPages=t.extraProgramPages}getEncodingSchema(){return AppParams.encodingSchema}toEncodingData(){return new Map([["approv",this.approvalProgram],["clearp",this.clearStateProgram],["gs",convertMap(this.globalState,(t,r)=>[t,r.toEncodingData()])],["lsch",this.localStateSchema.toEncodingData()],["gsch",this.globalStateSchema.toEncodingData()],["epp",this.extraProgramPages]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppParams: ${t}`);return new AppParams({approvalProgram:t.get("approv"),clearStateProgram:t.get("clearp"),globalState:convertMap(t.get("gs"),(r,n)=>[r,TealValue.fromEncodingData(n)]),localStateSchema:StateSchema.fromEncodingData(t.get("lsch")),globalStateSchema:StateSchema.fromEncodingData(t.get("gsch")),extraProgramPages:Number(t.get("epp"))})}}AppParams.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"approv",valueSchema:new ByteArraySchema},{key:"clearp",valueSchema:new ByteArraySchema},{key:"gs",valueSchema:new SpecialCaseBinaryStringMapSchema(TealValue.encodingSchema)},{key:"lsch",valueSchema:StateSchema.encodingSchema},{key:"gsch",valueSchema:StateSchema.encodingSchema},{key:"epp",valueSchema:new Uint64Schema}]));class AppLocalState{constructor(t){this.schema=t.schema,this.keyValue=t.keyValue}getEncodingSchema(){return AppLocalState.encodingSchema}toEncodingData(){return new Map([["hsch",this.schema.toEncodingData()],["tkv",convertMap(this.keyValue,(t,r)=>[t,r.toEncodingData()])]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppLocalState: ${t}`);return new AppLocalState({schema:StateSchema.fromEncodingData(t.get("hsch")),keyValue:convertMap(t.get("tkv"),(r,n)=>[r,TealValue.fromEncodingData(n)])})}}AppLocalState.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"hsch",valueSchema:StateSchema.encodingSchema},{key:"tkv",valueSchema:new SpecialCaseBinaryStringMapSchema(TealValue.encodingSchema)}]));class AppLocalStateDelta{constructor(t){this.localState=t.localState,this.deleted=t.deleted}getEncodingSchema(){return AppLocalStateDelta.encodingSchema}toEncodingData(){return new Map([["LocalState",this.localState?this.localState.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppLocalStateDelta: ${t}`);return new AppLocalStateDelta({localState:t.get("LocalState")?AppLocalState.fromEncodingData(t.get("LocalState")):void 0,deleted:t.get("Deleted")})}}AppLocalStateDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"LocalState",valueSchema:new OptionalSchema(AppLocalState.encodingSchema)},{key:"Deleted",valueSchema:new BooleanSchema}]));class AppParamsDelta{constructor(t){this.params=t.params,this.deleted=t.deleted}getEncodingSchema(){return AppParamsDelta.encodingSchema}toEncodingData(){return new Map([["Params",this.params?this.params.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppParamsDelta: ${t}`);return new AppParamsDelta({params:t.get("Params")?AppParams.fromEncodingData(t.get("Params")):void 0,deleted:t.get("Deleted")})}}AppParamsDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Params",valueSchema:new OptionalSchema(AppParams.encodingSchema)},{key:"Deleted",valueSchema:new BooleanSchema}]));class AppResourceRecord{constructor(t){this.id=t.id,this.address=t.address,this.params=t.params,this.state=t.state}getEncodingSchema(){return AppResourceRecord.encodingSchema}toEncodingData(){return new Map([["Aidx",this.id],["Addr",this.address],["Params",this.params.toEncodingData()],["State",this.state.toEncodingData()]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppResourceRecord: ${t}`);return new AppResourceRecord({id:t.get("Aidx"),address:t.get("Addr"),params:AppParamsDelta.fromEncodingData(t.get("Params")),state:AppLocalStateDelta.fromEncodingData(t.get("State"))})}}AppResourceRecord.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Aidx",valueSchema:new Uint64Schema},{key:"Addr",valueSchema:new AddressSchema},{key:"Params",valueSchema:AppParamsDelta.encodingSchema},{key:"State",valueSchema:AppLocalStateDelta.encodingSchema}]));class AssetHolding{constructor(t){this.amount=t.amount,this.frozen=t.frozen}getEncodingSchema(){return AssetHolding.encodingSchema}toEncodingData(){return new Map([["a",this.amount],["f",this.frozen]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetHolding: ${t}`);return new AssetHolding({amount:t.get("a"),frozen:t.get("f")})}}AssetHolding.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"a",valueSchema:new Uint64Schema},{key:"f",valueSchema:new BooleanSchema}]));class AssetHoldingDelta{constructor(t){this.holding=t.holding,this.deleted=t.deleted}getEncodingSchema(){return AssetHoldingDelta.encodingSchema}toEncodingData(){return new Map([["Holding",this.holding?this.holding.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetHoldingDelta: ${t}`);return new AssetHoldingDelta({holding:t.get("Holding")?AssetHolding.fromEncodingData(t.get("Holding")):void 0,deleted:t.get("Deleted")})}}AssetHoldingDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Holding",valueSchema:new OptionalSchema(AssetHolding.encodingSchema)},{key:"Deleted",valueSchema:new BooleanSchema}]));class AssetParams{constructor(t){this.total=t.total,this.decimals=t.decimals,this.defaultFrozen=t.defaultFrozen,this.unitName=t.unitName,this.assetName=t.assetName,this.url=t.url,this.metadataHash=t.metadataHash,this.manager=t.manager,this.reserve=t.reserve,this.freeze=t.freeze,this.clawback=t.clawback}getEncodingSchema(){return AssetParams.encodingSchema}toEncodingData(){return new Map([["t",this.total],["dc",this.decimals],["df",this.defaultFrozen],["un",this.unitName],["an",this.assetName],["au",this.url],["am",this.metadataHash],["m",this.manager],["r",this.reserve],["f",this.freeze],["c",this.clawback]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetParams: ${t}`);return new AssetParams({total:t.get("t"),decimals:t.get("dc"),defaultFrozen:t.get("df"),unitName:t.get("un"),assetName:t.get("an"),url:t.get("au"),metadataHash:t.get("am"),manager:t.get("m"),reserve:t.get("r"),freeze:t.get("f"),clawback:t.get("c")})}}AssetParams.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"t",valueSchema:new Uint64Schema},{key:"dc",valueSchema:new Uint64Schema},{key:"df",valueSchema:new BooleanSchema},{key:"un",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringSchema)},{key:"an",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringSchema)},{key:"au",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringSchema)},{key:"am",valueSchema:new FixedLengthByteArraySchema(32)},{key:"m",valueSchema:new OptionalSchema(new AddressSchema)},{key:"r",valueSchema:new OptionalSchema(new AddressSchema)},{key:"f",valueSchema:new OptionalSchema(new AddressSchema)},{key:"c",valueSchema:new OptionalSchema(new AddressSchema)}]));class AssetParamsDelta{constructor(t){this.params=t.params,this.deleted=t.deleted}getEncodingSchema(){return AssetParamsDelta.encodingSchema}toEncodingData(){return new Map([["Params",this.params?this.params.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetParamsDelta: ${t}`);return new AssetParamsDelta({params:t.get("Params")?AssetParams.fromEncodingData(t.get("Params")):void 0,deleted:t.get("Deleted")})}}AssetParamsDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Params",valueSchema:new OptionalSchema(AssetParams.encodingSchema)},{key:"Deleted",valueSchema:new BooleanSchema}]));class AssetResourceRecord{constructor(t){this.id=t.id,this.address=t.address,this.params=t.params,this.holding=t.holding}getEncodingSchema(){return AssetResourceRecord.encodingSchema}toEncodingData(){return new Map([["Aidx",this.id],["Addr",this.address],["Params",this.params.toEncodingData()],["Holding",this.holding.toEncodingData()]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetResourceRecord: ${t}`);return new AssetResourceRecord({id:t.get("Aidx"),address:t.get("Addr"),params:AssetParamsDelta.fromEncodingData(t.get("Params")),holding:AssetHoldingDelta.fromEncodingData(t.get("Holding"))})}}AssetResourceRecord.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Aidx",valueSchema:new Uint64Schema},{key:"Addr",valueSchema:new AddressSchema},{key:"Params",valueSchema:AssetParamsDelta.encodingSchema},{key:"Holding",valueSchema:AssetHoldingDelta.encodingSchema}]));class VotingData{constructor(t){this.voteID=t.voteID,this.selectionID=t.selectionID,this.stateProofID=t.stateProofID,this.voteFirstValid=t.voteFirstValid,this.voteLastValid=t.voteLastValid,this.voteKeyDilution=t.voteKeyDilution}getEncodingSchema(){return VotingData.encodingSchema}toEncodingData(){return new Map([["VoteID",this.voteID],["SelectionID",this.selectionID],["StateProofID",this.stateProofID],["VoteFirstValid",this.voteFirstValid],["VoteLastValid",this.voteLastValid],["VoteKeyDilution",this.voteKeyDilution]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded VotingData: ${t}`);return new VotingData({voteID:t.get("VoteID"),selectionID:t.get("SelectionID"),stateProofID:t.get("StateProofID"),voteFirstValid:t.get("VoteFirstValid"),voteLastValid:t.get("VoteLastValid"),voteKeyDilution:t.get("VoteKeyDilution")})}}VotingData.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"VoteID",valueSchema:new FixedLengthByteArraySchema(32)},{key:"SelectionID",valueSchema:new FixedLengthByteArraySchema(32)},{key:"StateProofID",valueSchema:new FixedLengthByteArraySchema(64)},{key:"VoteFirstValid",valueSchema:new Uint64Schema},{key:"VoteLastValid",valueSchema:new Uint64Schema},{key:"VoteKeyDilution",valueSchema:new Uint64Schema}]));class AccountBaseData{constructor(t){this.status=t.status,this.microAlgos=t.microAlgos,this.rewardsBase=t.rewardsBase,this.rewardedMicroAlgos=t.rewardedMicroAlgos,this.authAddr=t.authAddr,this.incentiveEligible=t.incentiveEligible,this.totalAppSchema=t.totalAppSchema,this.totalExtraAppPages=t.totalExtraAppPages,this.totalAppParams=t.totalAppParams,this.totalAppLocalStates=t.totalAppLocalStates,this.totalAssetParams=t.totalAssetParams,this.totalAssets=t.totalAssets,this.totalBoxes=t.totalBoxes,this.totalBoxBytes=t.totalBoxBytes,this.lastProposed=t.lastProposed,this.lastHeartbeat=t.lastHeartbeat}getEncodingSchema(){return AccountBaseData.encodingSchema}toEncodingData(){return new Map([["Status",this.status],["MicroAlgos",this.microAlgos],["RewardsBase",this.rewardsBase],["RewardedMicroAlgos",this.rewardedMicroAlgos],["AuthAddr",this.authAddr],["IncentiveEligible",this.incentiveEligible],["TotalAppSchema",this.totalAppSchema.toEncodingData()],["TotalExtraAppPages",this.totalExtraAppPages],["TotalAppParams",this.totalAppParams],["TotalAppLocalStates",this.totalAppLocalStates],["TotalAssetParams",this.totalAssetParams],["TotalAssets",this.totalAssets],["TotalBoxes",this.totalBoxes],["TotalBoxBytes",this.totalBoxBytes],["LastProposed",this.lastProposed],["LastHeartbeat",this.lastHeartbeat]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AccountBaseData: ${t}`);return new AccountBaseData({status:Number(t.get("Status")),microAlgos:t.get("MicroAlgos"),rewardsBase:t.get("RewardsBase"),rewardedMicroAlgos:t.get("RewardedMicroAlgos"),authAddr:t.get("AuthAddr"),incentiveEligible:t.get("IncentiveEligible"),totalAppSchema:StateSchema.fromEncodingData(t.get("TotalAppSchema")),totalExtraAppPages:Number(t.get("TotalExtraAppPages")),totalAppParams:t.get("TotalAppParams"),totalAppLocalStates:t.get("TotalAppLocalStates"),totalAssetParams:t.get("TotalAssetParams"),totalAssets:t.get("TotalAssets"),totalBoxes:t.get("TotalBoxes"),totalBoxBytes:t.get("TotalBoxBytes"),lastProposed:t.get("LastProposed"),lastHeartbeat:t.get("LastHeartbeat")})}}AccountBaseData.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Status",valueSchema:new Uint64Schema},{key:"MicroAlgos",valueSchema:new Uint64Schema},{key:"RewardsBase",valueSchema:new Uint64Schema},{key:"RewardedMicroAlgos",valueSchema:new Uint64Schema},{key:"AuthAddr",valueSchema:new AddressSchema},{key:"IncentiveEligible",valueSchema:new BooleanSchema},{key:"TotalAppSchema",valueSchema:StateSchema.encodingSchema},{key:"TotalExtraAppPages",valueSchema:new Uint64Schema},{key:"TotalAppParams",valueSchema:new Uint64Schema},{key:"TotalAppLocalStates",valueSchema:new Uint64Schema},{key:"TotalAssetParams",valueSchema:new Uint64Schema},{key:"TotalAssets",valueSchema:new Uint64Schema},{key:"TotalBoxes",valueSchema:new Uint64Schema},{key:"TotalBoxBytes",valueSchema:new Uint64Schema},{key:"LastProposed",valueSchema:new Uint64Schema},{key:"LastHeartbeat",valueSchema:new Uint64Schema}]));class AccountData{constructor(t){this.accountBaseData=t.accountBaseData,this.votingData=t.votingData}getEncodingSchema(){return AccountData.encodingSchema}toEncodingData(){return combineMaps(this.accountBaseData.toEncodingData(),this.votingData.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AccountData: ${t}`);return new AccountData({accountBaseData:AccountBaseData.fromEncodingData(t),votingData:VotingData.fromEncodingData(t)})}}AccountData.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"",valueSchema:AccountBaseData.encodingSchema,embedded:!0},{key:"",valueSchema:VotingData.encodingSchema,embedded:!0}]));class BalanceRecord{constructor(t){this.addr=t.addr,this.accountData=t.accountData}getEncodingSchema(){return BalanceRecord.encodingSchema}toEncodingData(){return combineMaps(new Map([["Addr",this.addr]]),this.accountData.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded BalanceRecord: ${t}`);return new BalanceRecord({addr:t.get("Addr"),accountData:AccountData.fromEncodingData(t)})}}BalanceRecord.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Addr",valueSchema:new AddressSchema},{key:"",valueSchema:AccountData.encodingSchema,embedded:!0}]));class AccountDeltas{constructor(t){this.accounts=t.accounts,this.appResources=t.appResources,this.assetResources=t.assetResources}getEncodingSchema(){return AccountDeltas.encodingSchema}toEncodingData(){return new Map([["Accts",this.accounts.map(t=>t.toEncodingData())],["AppResources",this.appResources.length===0?void 0:this.appResources.map(t=>t.toEncodingData())],["AssetResources",this.assetResources.length===0?void 0:this.assetResources.map(t=>t.toEncodingData())]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AccountDeltas: ${t}`);return new AccountDeltas({accounts:(t.get("Accts")??[]).map(BalanceRecord.fromEncodingData),appResources:(t.get("AppResources")??[]).map(AppResourceRecord.fromEncodingData),assetResources:(t.get("AssetResources")??[]).map(AssetResourceRecord.fromEncodingData)})}}AccountDeltas.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Accts",valueSchema:new ArraySchema(BalanceRecord.encodingSchema)},{key:"AppResources",valueSchema:new OptionalSchema(new ArraySchema(AppResourceRecord.encodingSchema))},{key:"AssetResources",valueSchema:new OptionalSchema(new ArraySchema(AssetResourceRecord.encodingSchema))}]));class KvValueDelta{constructor(t){this.data=t.data,this.oldData=t.oldData}getEncodingSchema(){return KvValueDelta.encodingSchema}toEncodingData(){return new Map([["Data",this.data],["OldData",this.oldData]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded KvValueDelta: ${t}`);return new KvValueDelta({data:t.get("Data"),oldData:t.get("OldData")})}}KvValueDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Data",valueSchema:new OptionalSchema(new ByteArraySchema)},{key:"OldData",valueSchema:new OptionalSchema(new ByteArraySchema)}]));class IncludedTransactions{constructor(t){this.lastValid=t.lastValid,this.intra=t.intra}getEncodingSchema(){return IncludedTransactions.encodingSchema}toEncodingData(){return new Map([["LastValid",this.lastValid],["Intra",this.intra]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded IncludedTransactions: ${t}`);return new IncludedTransactions({lastValid:t.get("LastValid"),intra:Number(t.get("Intra"))})}}IncludedTransactions.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"LastValid",valueSchema:new Uint64Schema},{key:"Intra",valueSchema:new Uint64Schema}]));class ModifiedCreatable{constructor(t){this.creatableType=t.creatableType,this.created=t.created,this.creator=t.creator,this.ndeltas=t.ndeltas}getEncodingSchema(){return ModifiedCreatable.encodingSchema}toEncodingData(){return new Map([["Ctype",this.creatableType],["Created",this.created],["Creator",this.creator],["Ndeltas",this.ndeltas]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded ModifiedCreatable: ${t}`);return new ModifiedCreatable({creatableType:Number(t.get("Ctype")),created:t.get("Created"),creator:t.get("Creator"),ndeltas:Number(t.get("Ndeltas"))})}}ModifiedCreatable.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Ctype",valueSchema:new Uint64Schema},{key:"Created",valueSchema:new BooleanSchema},{key:"Creator",valueSchema:new AddressSchema},{key:"Ndeltas",valueSchema:new Uint64Schema}]));class AlgoCount{constructor(t){this.money=t.money,this.rewardUnits=t.rewardUnits}getEncodingSchema(){return AlgoCount.encodingSchema}toEncodingData(){return new Map([["mon",this.money],["rwd",this.rewardUnits]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AlgoCount: ${t}`);return new AlgoCount({money:t.get("mon"),rewardUnits:t.get("rwd")})}}AlgoCount.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"mon",valueSchema:new Uint64Schema},{key:"rwd",valueSchema:new Uint64Schema}]));class AccountTotals{constructor(t){this.online=t.online,this.offline=t.offline,this.notParticipating=t.notParticipating,this.rewardsLevel=t.rewardsLevel}getEncodingSchema(){return AccountTotals.encodingSchema}toEncodingData(){return new Map([["online",this.online.toEncodingData()],["offline",this.offline.toEncodingData()],["notpart",this.notParticipating.toEncodingData()],["rwdlvl",this.rewardsLevel]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AccountTotals: ${t}`);return new AccountTotals({online:AlgoCount.fromEncodingData(t.get("online")),offline:AlgoCount.fromEncodingData(t.get("offline")),notParticipating:AlgoCount.fromEncodingData(t.get("notpart")),rewardsLevel:t.get("rwdlvl")})}}AccountTotals.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"online",valueSchema:AlgoCount.encodingSchema},{key:"offline",valueSchema:AlgoCount.encodingSchema},{key:"notpart",valueSchema:AlgoCount.encodingSchema},{key:"rwdlvl",valueSchema:new Uint64Schema}]));new NamedMapSchema(allOmitEmpty([{key:"Accts",valueSchema:AccountDeltas.encodingSchema},{key:"KvMods",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringMapSchema(KvValueDelta.encodingSchema))},{key:"Txids",valueSchema:new ByteArrayMapSchema(IncludedTransactions.encodingSchema)},{key:"Txleases",valueSchema:new OptionalSchema(new UntypedSchema)},{key:"Creatables",valueSchema:new OptionalSchema(new Uint64MapSchema(ModifiedCreatable.encodingSchema))},{key:"Hdr",valueSchema:BlockHeader.encodingSchema},{key:"StateProofNext",valueSchema:new Uint64Schema},{key:"PrevTimestamp",valueSchema:new Uint64Schema},{key:"Totals",valueSchema:AccountTotals.encodingSchema}]));new TextEncoder().encode("TG");"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach(function(e,t){});function makePaymentTxnWithSuggestedParamsFromObject({sender:e,receiver:t,amount:r,closeRemainderTo:n,suggestedParams:o,note:i,lease:u,rekeyTo:a}){return new Transaction({type:TransactionType.pay,sender:e,note:i,lease:u,rekeyTo:a,suggestedParams:o,paymentParams:{receiver:t,amount:r,closeRemainderTo:n}})}var ABITransactionType;(function(e){e.any="txn",e.pay="pay",e.keyreg="keyreg",e.acfg="acfg",e.axfer="axfer",e.afrz="afrz",e.appl="appl"})(ABITransactionType||(ABITransactionType={}));var ABIReferenceType;(function(e){e.account="account",e.application="application",e.asset="asset"})(ABIReferenceType||(ABIReferenceType={}));var AtomicTransactionComposerStatus;(function(e){e[e.BUILDING=0]="BUILDING",e[e.BUILT=1]="BUILT",e[e.SIGNED=2]="SIGNED",e[e.SUBMITTED=3]="SUBMITTED",e[e.COMMITTED=4]="COMMITTED"})(AtomicTransactionComposerStatus||(AtomicTransactionComposerStatus={}));const SIGN_BYTES_PREFIX=Uint8Array.from([77,88]);function verifyBytes(e,t,r){const n=concatArrays(SIGN_BYTES_PREFIX,e),o=typeof r=="string"?Address.fromString(r):r;return verify(n,t,o.publicKey)}function hexStringToBytes(e){if(!/^[0-9a-fA-F]+$/.test(e))throw new Error("Non-hex digits found in hex string");const t=[];e.length%2!==0&&(e="0"+e);for(let r=0;r<e.length;r+=2){const n=e.slice(r,r+2);t.push(parseInt(n,16))}return t}function hexStringToUint8Array(e){return new Uint8Array(hexStringToBytes(e))}class AlgorandCrypto{constructor(){this.verifyAddress=t=>Check(TypeboxHelpers.Algorand.Address,t),this.verifySignature=async(t,r,n)=>{try{if(!this.verifyAddress(t))return!1;const i=(d=>new Uint8Array(d.match(/.{1,2}/g).map(p=>parseInt(p,16))))(n),u=new TextEncoder,a=u.encode(r),s=u.encode("MX"),f=new Uint8Array(s.length+a.length);f.set(s),f.set(a,s.length);const c=verifyBytes(a,i,t);return console.log("ALGORAND VERIFY RESULT:",{result:c,encodedMessage:a,signatureBytes:i,userAddress:t}),!0;return c}catch(o){return console.error("[address-validator] error verifying algorand signature:",o),!1}},this.buildAlgorandTransaction=async(t,r)=>{const n=utf8ToHex(r).slice(2),o=hexStringToUint8Array(n),i={fee:0,firstValid:10,lastValid:10,minFee:0,genesisID:"mainnet-v1.0",genesisHash:Uint8Array.from(bufferExports.Buffer.from("wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=","base64"))};return makePaymentTxnWithSuggestedParamsFromObject({sender:t,receiver:t,amount:0,closeRemainderTo:void 0,note:o,suggestedParams:i})},this.decodeSignedTransaction=async t=>decodeSignedTransaction(t)}decodeAddress(t){return Decode(TypeboxHelpers.Algorand.Address,t)}}var dist$1={exports:{}},dist=dist$1.exports,hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,(function(e,t){(function(r,n){e.exports=n()})(dist,(()=>(()=>{var r={3578:function(u,a,s){var f=this&&this.__importDefault||function(E){return E&&E.__esModule?E:{default:E}};Object.defineProperty(a,"__esModule",{value:!0});const c=s(8764),d=f(s(3550)),p=s(5632),h=f(s(230)),y=f(s(5529)),b=s(2049),w=new(s(7001));class S{constructor(B){this.xprv=B}static fromEntropy(B){return new Promise(((ae,W)=>{p.pbkdf2("",B,4096,96,"sha512",((J,ve)=>{J&&W(J),ve[0]&=248,ve[31]&=31,ve[31]|=64,ae(new S(ve))}))}))}derive(B){const ae=this.xprv.slice(0,32),W=this.xprv.slice(32,64),J=this.xprv.slice(64,96);let ve,Qe;if(B<2147483648){const vt=c.Buffer.allocUnsafe(37);vt.writeUInt32LE(B,33);const ur=w.keyFromSecret(ae.toString("hex"));c.Buffer.from(ur.pubBytes()).copy(vt,1),vt[0]=2,ve=b.hmac512(J,vt),vt[0]=3,Qe=b.hmac512(J,vt)}else{const vt=c.Buffer.allocUnsafe(69);vt.writeUInt32LE(B,65),ae.copy(vt,1),W.copy(vt,33),vt[0]=0,ve=b.hmac512(J,vt),vt[0]=1,Qe=b.hmac512(J,vt)}const kt=Qe.slice(32,64),nr=ve.slice(0,32),sr=ve.slice(32,64),ce=new d.default(ae,16,"le").add(new d.default(nr.slice(0,28),16,"le").mul(new d.default(8))).toArrayLike(c.Buffer,"le",32);let Ze=new d.default(W,16,"le").add(new d.default(sr,16,"le")).toArrayLike(c.Buffer,"le").slice(0,32);Ze.length!==32&&(Ze=c.Buffer.from(Ze.toString("hex").padEnd(32,"0"),"hex"));const se=c.Buffer.concat([ce,Ze,kt]);return new S(se)}toBip32PublicKey(){const B=w.keyFromSecret(this.xprv.slice(0,32).toString("hex")),ae=c.Buffer.from(B.pubBytes());return new h.default(c.Buffer.concat([ae,this.xprv.slice(64,96)]))}toBytes(){return this.xprv}toPrivateKey(){const B=w.keyFromSecret(this.xprv.slice(0,64));return new y.default(c.Buffer.from(B.privBytes()))}}a.default=S},230:function(u,a,s){var f=this&&this.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(a,"__esModule",{value:!0});const c=s(8764),d=f(s(3550)),p=f(s(4093)),h=s(2049),y=new(s(7001));class b{constructor(S){this.xpub=S}derive(S){const E=this.xpub.slice(0,32),B=this.xpub.slice(32,64),ae=c.Buffer.allocUnsafe(37);let W,J;if(ae.writeUInt32LE(S,33),!(S<2147483648))throw new Error("can not derive hardened public key");E.copy(ae,1),ae[0]=2,W=h.hmac512(B,ae),ae[0]=3,J=h.hmac512(B,ae);const ve=J.slice(32,64),Qe=W.slice(0,32),kt=new d.default(Qe.slice(0,28),16,"le").mul(new d.default(8)),nr=y.g.mul(kt),sr=y.decodePoint(E.toString("hex")).add(nr);return new b(c.Buffer.concat([c.Buffer.from(y.encodePoint(sr)),ve]))}toPublicKey(){const S=y.keyFromPublic(this.xpub.slice(0,32));return new p.default(c.Buffer.from(S.pubBytes()))}toBytes(){return this.xpub}static fromBytes(S){return new b(S)}}a.default=b},5529:function(u,a,s){var f=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(a,"__esModule",{value:!0});const c=s(8764),d=f(s(4093)),p=new(s(7001));a.default=class{constructor(h){this.privKey=h}toBytes(){return this.privKey}toPublicKey(){const h=p.keyFromSecret(this.privKey);return new d.default(c.Buffer.from(h.pubBytes()))}sign(h){const y=p.keyFromSecret(this.privKey).sign(h.toString("hex"));return c.Buffer.from(y.toBytes())}verify(h,y){return p.keyFromSecret(this.privKey).verify(y.toString("hex"),h.toString("hex"))}}},4093:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0});const f=s(2049),c=new(s(7001));a.default=class{constructor(d){this.pubKey=d}toBytes(){return this.pubKey}hash(){return f.hash28(this.pubKey)}verify(d,p){return c.keyFromPublic(this.pubKey.toString("hex")).verify(p.toString("hex"),d.toString("hex"))}}},7001:(u,a,s)=>{const f=s(3715),c=s(6266),d=c.utils,p=d.parseBytes,h=s(2568),y=s(6398);function b(){if(!(this instanceof b))return new b;const w=c.curves.ed25519.curve;this.curve=w,this.g=w.g,this.g.precompute(w.n.bitLength()+1),this.pointClass=w.point().constructor,this.encodingLength=Math.ceil(w.n.bitLength()/8),this.hash=f.sha512}u.exports=b,b.prototype.signExtended=function(w,S){w=p(w);const E=this.keyFromSecret(S),B=this.hashInt(E.messagePrefix(),w),ae=this.g.mul(B),W=this.encodePoint(ae),J=this.hashInt(W,E.pubBytes(),w).mul(E.kl()),ve=B.add(J).umod(this.curve.n);return this.makeSignature({R:ae,S:ve,Rencoded:W})},b.prototype.verify=function(w,S,E){w=p(w),S=this.makeSignature(S);const B=this.keyFromPublic(E),ae=this.hashInt(S.Rencoded(),B.pubBytes(),w),W=this.g.mul(S.S());return S.R().add(B.pub().mul(ae)).eq(W)},b.prototype.hashInt=function(){const w=this.hash();for(let S=0;S<arguments.length;S++)w.update(arguments[S]);return d.intFromLE(w.digest()).umod(this.curve.n)},b.prototype.keyFromPublic=function(w){return h.fromPublic(this,d.parseBytes(w))},b.prototype.keyFromSecret=function(w){return h.fromSecret(this,d.parseBytes(w))},b.prototype.makeSignature=function(w){return w instanceof y?w:new y(this,w)},b.prototype.encodePoint=function(w){const S=w.getY().toArray("le",this.encodingLength);return S[this.encodingLength-1]|=w.getX().isOdd()?128:0,S},b.prototype.decodePoint=function(w){const S=(w=d.parseBytes(w)).length-1,E=w.slice(0,S).concat(-129&w[S]),B=(128&w[S])!=0,ae=d.intFromLE(E);return this.curve.pointFromY(ae,B)},b.prototype.encodeInt=function(w){return w.toArray("le",this.encodingLength)},b.prototype.decodeInt=function(w){return d.intFromLE(w)},b.prototype.isPoint=function(w){return w instanceof this.pointClass}},2568:(u,a,s)=>{const f=s(6266).utils,c=f.assert,d=f.parseBytes,p=f.cachedProperty;function h(y,b){this.eddsa=y,this._secret=d(b.secret),y.isPoint(b.pub)?(console.log("Its point"),this._pub=b.pub):this._pubBytes=d(b.pub)}h.fromPublic=function(y,b){return b instanceof h?b:new h(y,{pub:b})},h.fromSecret=function(y,b){return b instanceof h?b:new h(y,{secret:b})},h.prototype.secret=function(){return this._secret.slice(0,32)},p(h,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),p(h,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.kl())})),p(h,"privBytes",(function(){return this._secret})),p(h,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),p(h,"kl",(function(){return this.eddsa.decodeInt(this.privBytes().slice(0,32))})),p(h,"messagePrefix",(function(){return this._secret.slice(32,64)})),h.prototype.sign=function(y){return c(this._secret,"KeyPair can only verify"),this.eddsa.signExtended(y,this)},h.prototype.verify=function(y,b){return this.eddsa.verify(y,b,this)},u.exports=h},6398:(u,a,s)=>{const f=s(3550),c=s(6266).utils,d=c.assert,p=c.cachedProperty,h=c.parseBytes;function y(b,w){this.eddsa=b,typeof w!="object"&&(w=h(w)),Array.isArray(w)&&(w={R:w.slice(0,b.encodingLength),S:w.slice(b.encodingLength)}),d(w.R&&w.S,"Signature without R or S"),b.isPoint(w.R)&&(this._R=w.R),f.isBN(w.S)&&(this._S=w.S),this._Rencoded=Array.isArray(w.R)?w.R:w.Rencoded,this._Sencoded=Array.isArray(w.S)?w.S:w.Sencoded}p(y,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),p(y,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),p(y,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),p(y,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),y.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},y.prototype.toHex=function(){return c.encode(this.toBytes(),"hex").toUpperCase()},u.exports=y},546:function(u,a,s){var f=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.PrivateKey=a.PublicKey=a.Bip32PublicKey=a.Bip32PrivateKey=void 0;var c=s(3578);Object.defineProperty(a,"Bip32PrivateKey",{enumerable:!0,get:function(){return f(c).default}});var d=s(230);Object.defineProperty(a,"Bip32PublicKey",{enumerable:!0,get:function(){return f(d).default}});var p=s(4093);Object.defineProperty(a,"PublicKey",{enumerable:!0,get:function(){return f(p).default}});var h=s(5529);Object.defineProperty(a,"PrivateKey",{enumerable:!0,get:function(){return f(h).default}})},2049:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(b,w,S,E){E===void 0&&(E=S),Object.defineProperty(b,E,{enumerable:!0,get:function(){return w[S]}})}:function(b,w,S,E){E===void 0&&(E=S),b[E]=w[S]}),c=this&&this.__setModuleDefault||(Object.create?function(b,w){Object.defineProperty(b,"default",{enumerable:!0,value:w})}:function(b,w){b.default=w}),d=this&&this.__importStar||function(b){if(b&&b.__esModule)return b;var w={};if(b!=null)for(var S in b)S!=="default"&&Object.prototype.hasOwnProperty.call(b,S)&&f(w,b,S);return c(w,b),w};Object.defineProperty(a,"__esModule",{value:!0}),a.hmac512=a.hash28=void 0;const p=s(8764),h=s(1191),y=d(s(3715));a.hash28=function(b){const w=h.blake2b(b,void 0,28);return p.Buffer.from(w)},a.hmac512=function(b,w){const S=y.hmac(y.sha512,b).update(w).digest();return p.Buffer.from(S)}},5723:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0});const f=s(8764);a.default=class{constructor(){this.buf=f.Buffer.alloc(0)}get length(){return this.buf.length}read(c){if(c===0)return f.Buffer.alloc(0);if(c<0)throw new Error("invalid length");const d=this.buf.slice(0,c);if(this.buf=this.buf.slice(c),d.length<c)throw new Error("Not enough buffer");return d}push(c){c.length&&(this.buf=f.Buffer.concat([this.buf,c]))}}},7640:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.default=class extends Array{constructor(){super(...arguments),this.byteSpan=[0,0]}setByteSpan(s){this.byteSpan=s}getByteSpan(){return this.byteSpan}}},1022:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0});class s extends Map{constructor(){super(...arguments),this.byteSpan=[0,0]}setByteSpan(c){this.byteSpan=c}getByteSpan(){return this.byteSpan}}a.default=s},5257:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.default=class{constructor(s,f){this.byteSpan=[0,0],this.value=s,this.tag=f}setByteSpan(s){this.byteSpan=s}getByteSpan(){return this.byteSpan}}},6217:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(Qe,kt,nr,sr){sr===void 0&&(sr=nr),Object.defineProperty(Qe,sr,{enumerable:!0,get:function(){return kt[nr]}})}:function(Qe,kt,nr,sr){sr===void 0&&(sr=nr),Qe[sr]=kt[nr]}),c=this&&this.__setModuleDefault||(Object.create?function(Qe,kt){Object.defineProperty(Qe,"default",{enumerable:!0,value:kt})}:function(Qe,kt){Qe.default=kt}),d=this&&this.__importStar||function(Qe){if(Qe&&Qe.__esModule)return Qe;var kt={};if(Qe!=null)for(var nr in Qe)nr!=="default"&&Object.prototype.hasOwnProperty.call(Qe,nr)&&f(kt,Qe,nr);return c(kt,Qe),kt},p=this&&this.__importDefault||function(Qe){return Qe&&Qe.__esModule?Qe:{default:Qe}};Object.defineProperty(a,"__esModule",{value:!0});const h=s(8764),y=d(s(2830)),b=p(s(4431)),w=s(3726),S=p(s(5723)),E=p(s(1604)),B=p(s(5257)),ae=p(s(7640)),W=p(s(1022)),J=Qe=>Qe===255;class ve extends y.Transform{constructor(){super({writableObjectMode:!1,readableObjectMode:!0}),this.needed=null,this.fresh=!0,this._parser=this.parse(),this.offset=0,this.usedBytes=[],this.bl=new S.default,this.restart()}static decode(kt){const nr=new ve,sr=new S.default;sr.push(kt);const ce=nr.parse();let Ze=ce.next();for(;!Ze.done;){const se=sr.read(Ze.value);if(se==null||se.length!==Ze.value)throw new Error("Insufficient data");Ze=ce.next(se)}if(sr.length>0)throw new Error("Remaining Bytes");return{bytes:kt,value:Ze.value}}readUInt64(kt,nr,sr){const ce=(0,w.getBigNum)(kt,nr);return b.default.isBigNumber(ce)?(0,w.addSpanBytesToObject)(ce,[sr,this.offset]):ce}updateTracker(kt){this.usedBytes.push(kt),this.offset+=kt.length}*readIndefiniteStringLength(kt,nr){let sr,ce=yield 1;const Ze=ce.readUInt8(0);if(Ze===255)sr=-1;else{const se=31&Ze,vt=this.readLength(se,nr);let ur=vt.next();for(;!ur.done;)ce=yield ur.value,this.updateTracker(ce),ur=vt.next(ce);if(sr=ur.value,sr<0||Ze>>5!==kt)throw new Error("Invalid indefinite length encoding")}return sr}*readLength(kt,nr){if(kt<24)return kt;if(kt===24)return(yield 1).readUInt8(0);if(kt===25)return(yield 2).readUInt16BE(0);if(kt===26)return(yield 4).readUInt32BE(0);if(kt===27){const sr=(yield 4).readUInt32BE(0),ce=(yield 4).readUInt32BE(0);return this.readUInt64(sr,ce,nr)}if(kt===31)return-1;throw new Error("Invalid length encoding")}_transform(kt,nr,sr){for(this.bl.push(kt);this.bl.length>=this.needed;){let ce,Ze=null;ce=this.needed===null?void 0:this.bl.read(this.needed);try{Ze=this._parser.next(ce)}catch(se){return sr(se)}this.needed&&(this.fresh=!1),Ze.done?(this.push({bytes:this.usedBytes,value:Ze.value}),this.restart()):this.needed=Ze.value||1/0}return sr()}*parse(kt){let nr,sr=this.offset;kt?(nr=kt,sr-=kt.length):(nr=yield 1,this.updateTracker(nr));const ce=nr.readUInt8(0),Ze=ce>>5,se=31&ce;let vt;if(Ze===7){if(se===25)return nr=yield 2,this.updateTracker(nr),(bt=>{const L=32768&bt;let _=31744&bt;const F=1023&bt;if(_===31744)_=261120;else if(_!==0)_+=114688;else if(F!==0)return(L?-1:1)*F*w.POW_2_24;const k=h.Buffer.alloc(4);return k.writeUInt32BE(L<<16|_<<13|F<<13),k.readFloatBE(0)})(nr.readUInt16BE(0));if(se===26)return nr=yield 4,this.updateTracker(nr),nr.readFloatBE(0);if(se===27)return nr=yield 8,this.updateTracker(nr),nr.readDoubleBE(0)}const ur=this.readLength(se,sr);let ue=ur.next();for(;!ue.done;)nr=yield ue.value,this.updateTracker(nr),ue=ur.next(nr);if(vt=ue.value,vt<0&&(Ze<2||Ze>6))throw new Error("Invalid length");switch(Ze){case 0:return vt;case 1:if(vt===Number.MAX_SAFE_INTEGER){const bt=new b.default(-1).minus(new b.default(Number.MAX_SAFE_INTEGER.toString(16),16));return(0,w.addSpanBytesToObject)(bt,[sr,this.offset])}if(b.default.isBigNumber(vt)){const bt=new b.default(-1).minus(vt);return(0,w.addSpanBytesToObject)(bt,[sr,this.offset])}return-1-vt;case 2:if(vt<0){const bt=[];{const _=this.readIndefiniteStringLength(Ze,sr);let F=_.next();for(;!F.done;)nr=yield F.value,this.updateTracker(nr),F=_.next(nr);vt=F.value}for(;vt>=0;){nr=yield vt,this.updateTracker(nr),bt.push(nr);{const _=this.readIndefiniteStringLength(Ze,sr);let F=_.next();for(;!F.done;)nr=yield F.value,this.updateTracker(nr),F=_.next(nr);vt=F.value}}const L=h.Buffer.concat(bt);return(0,w.addSpanBytesToObject)(L,[sr,this.offset])}return nr=yield vt,this.updateTracker(nr),(0,w.addSpanBytesToObject)(nr,[sr,this.offset]);case 3:{const bt=[];if(vt<0){{const L=this.readIndefiniteStringLength(Ze,sr);let _=L.next();for(;!_.done;)nr=yield _.value,this.updateTracker(nr),_=L.next(nr);vt=_.value}for(;vt>=0;){nr=yield vt,this.updateTracker(nr),bt.push(nr);{const L=this.readIndefiniteStringLength(Ze,sr);let _=L.next();for(;!_.done;)nr=yield _.value,this.updateTracker(nr),_=L.next(nr);vt=_.value}}return(0,w.utf8Decoder)(h.Buffer.concat(bt))}return nr=yield vt,this.updateTracker(nr),(0,w.utf8Decoder)(nr)}case 4:{if(vt<0){const L=new ae.default;nr=yield 1,this.updateTracker(nr);let _=nr.readUInt8(0);for(;!J(_);)L.push(yield*this.parse(nr)),nr=yield 1,this.updateTracker(nr),_=nr.readUInt8(0);return L.setByteSpan([sr,this.offset]),L}const bt=new ae.default;for(let L=0;L<vt;L+=1)bt.push(yield*this.parse());return bt.setByteSpan([sr,this.offset]),bt}case 5:{if(vt<0){const L=new W.default;nr=yield 1,this.updateTracker(nr);let _=nr.readUInt8(0);for(;!J(_);){const F=yield*this.parse(nr),k=yield*this.parse();L.set(F,k),nr=yield 1,this.updateTracker(nr),_=nr.readUInt8(0)}return L.setByteSpan([sr,this.offset]),L}const bt=new W.default;for(let L=0;L<vt;L+=1){const _=yield*this.parse(),F=yield*this.parse();bt.set(_,F)}return bt.setByteSpan([sr,this.offset]),bt}case 6:{const bt=new B.default(yield*this.parse(),vt);return bt.setByteSpan([sr,this.offset]),bt}case 7:switch(vt){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:return new E.default(vt)}default:throw new Error("Invalid CBOR encoding")}}restart(){this.needed=null,this._parser=this.parse(),this.fresh=!0,this.offset=0,this.usedBytes=[]}_flush(kt){kt(this.fresh?null:new Error("unexpected end of input"))}}a.default=ve},1604:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.default=class{constructor(s){this.value=s}}},7747:function(u,a,s){var f=this&&this.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(a,"__esModule",{value:!0});const c=s(8764),d=f(s(4431)),p=s(7730),h=s(2339),y=s(3726),b=c.Buffer.from("f97e00","hex"),w=c.Buffer.from("ff","hex");a.default=(S,E={collapseBigNumber:!0})=>{const B=[];function ae(nr){const sr=c.Buffer.allocUnsafe(1);sr.writeUInt8(nr,0),B.push(sr)}function W(nr){B.push(nr)}function J(nr){const sr=c.Buffer.allocUnsafe(4);sr.writeUInt32BE(nr,0),B.push(sr)}function ve(nr,sr){sr<24?ae(nr<<5|sr):sr<256?(ae(nr<<5|24),ae(sr)):sr<65536?(ae(nr<<5|25),(function(ce){const Ze=c.Buffer.allocUnsafe(2);Ze.writeUInt16BE(ce,0),B.push(Ze)})(sr)):sr<4294967296?(ae(nr<<5|26),J(sr)):(ae(nr<<5|27),(function(ce){const Ze=ce%y.POW_2_32,se=(ce-Ze)/y.POW_2_32,vt=c.Buffer.allocUnsafe(8);vt.writeUInt32BE(se,0),vt.writeUInt32BE(Ze,4),B.push(vt)})(sr))}function Qe(nr){return Object.is(nr,-0)?W(c.Buffer.from("f98000","hex")):nr>=0&&nr<=y.POW_2_53?ve(0,nr):-y.POW_2_53<=nr&&nr<0?ve(1,-(nr+1)):void 0}function kt(nr){let sr=nr,ce=0,Ze=2;if(sr.isNegative()&&(sr=sr.negated().minus(1),ce=1,Ze=3),E.collapseBigNumber&&sr.lte(y.MAX_BIG_NUM_INT64)){if(sr.lte(y.MAX_BIG_NUM_INT32))return ve(ce,sr.toNumber());ae(ce<<5|27),J(sr.dividedToIntegerBy(y.SHIFT32).toNumber()),J(sr.mod(y.SHIFT32).toNumber())}else{let se=sr.toString(16);se.length%2&&(se=`0${se}`),ve(6,Ze);const vt=c.Buffer.from(se,"hex");ve(2,vt.length),W(vt)}}return(function nr(sr){if(sr===!1)return ae(244);if(sr===!0)return ae(245);if(sr===null)return ae(246);if(sr===void 0)return ae(247);switch(typeof sr){case"number":return Math.round(sr)===sr?Qe(sr):(ae(251),(function(ce){const Ze=c.Buffer.allocUnsafe(8);Ze.writeDoubleBE(ce),B.push(Ze)})(sr));case"string":{const ce=c.Buffer.from(sr,"utf8");return ve(3,ce.length),W(ce)}default:if(Array.isArray(sr)){sr instanceof h.IndefiniteArray?ae(159):ve(4,sr.length);for(const ce of sr)nr(ce);sr instanceof h.IndefiniteArray&&W(w)}else if(sr instanceof c.Buffer)ve(2,sr.length),W(sr);else if(sr instanceof ArrayBuffer){const ce=c.Buffer.from(sr);ve(2,ce.length),W(ce)}else if(sr instanceof Uint8ClampedArray){const ce=c.Buffer.from(sr);ve(2,ce.length),W(ce)}else if(sr instanceof Uint8Array){const ce=c.Buffer.from(sr);ve(2,ce.length),W(ce)}else if(d.default.isBigNumber(sr))(function(ce){if(ce.isNaN())W(b);else if(ce.isInteger())kt(ce);else{ve(6,4),ve(4,2);const Ze=ce.decimalPlaces(),se=ce.shiftedBy(Ze);Qe(-Ze),se.abs().isLessThan(y.MAX_BIG_NUM_INT)?Qe(se.toNumber()):kt(se)}})(sr);else if(sr instanceof p.CborTag)ve(6,sr.tag),nr(sr.value);else{let ce;ce=sr instanceof Map?[...sr.entries()]:[...Object.entries(sr)],sr instanceof h.IndefiniteMap?ae(191):ve(5,ce.length);for(const[Ze,se]of ce)nr(Ze),nr(se);sr instanceof h.IndefiniteMap&&W(w)}}})(S),c.Buffer.concat(B)}},2339:function(u,a,s){var f=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(a,"__esModule",{value:!0}),a.CborTag=a.IndefiniteArray=a.IndefiniteMap=void 0;class c extends Map{}a.IndefiniteMap=c,a.IndefiniteArray=class extends Array{};var d=s(5257);Object.defineProperty(a,"CborTag",{enumerable:!0,get:function(){return f(d).default}})},7730:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(y,b,w,S){S===void 0&&(S=w),Object.defineProperty(y,S,{enumerable:!0,get:function(){return b[w]}})}:function(y,b,w,S){S===void 0&&(S=w),y[S]=b[w]}),c=this&&this.__exportStar||function(y,b){for(var w in y)w==="default"||Object.prototype.hasOwnProperty.call(b,w)||f(b,y,w)},d=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.Decoder=a.Encoder=void 0;const p=d(s(7747));a.Encoder={encode:p.default};var h=s(6217);Object.defineProperty(a,"Decoder",{enumerable:!0,get:function(){return d(h).default}}),c(s(2339),a)},3726:function(u,a,s){var f=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(a,"__esModule",{value:!0}),a.utf8Decoder=a.addSpanBytesToObject=a.getBigNum=a.MAX_BIG_NUM_INT64=a.MAX_BIG_NUM_INT32=a.MAX_BIG_NUM_INT=a.POW_2_53=a.POW_2_32=a.POW_2_24=a.SHIFT32=void 0;const c=f(s(4431));a.SHIFT32=4294967296,a.POW_2_24=5960464477539063e-23,a.POW_2_32=4294967296,a.POW_2_53=9007199254740992,a.MAX_BIG_NUM_INT=new c.default("0x20000000000000"),a.MAX_BIG_NUM_INT32=new c.default("0xffffffff"),a.MAX_BIG_NUM_INT64=new c.default("0xffffffffffffffff"),a.getBigNum=(p,h)=>p>2097151?new c.default(p).times(a.SHIFT32).plus(h):p*a.SHIFT32+h,a.addSpanBytesToObject=(p,h)=>{const y=p;return y.byteSpan=h,y.getByteSpan=function(){return this.byteSpan},y};const d=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0});a.utf8Decoder=p=>d.decode(p)},6084:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0});const f=s(7730),c=s(546),d=s(1191),p=s(8764);class h{constructor(b){this.protectedMap=b.protectedMap,this.unProtectedMap=b.unProtectedMap,this.payload=b.payload,this.unProtectedMap.get("hashed")==null&&this.unProtectedMap.set("hashed",!1),this.signature=b.signature}static fromCbor(b){const w=f.Decoder.decode(p.Buffer.from(b,"hex"));if(!(w.value instanceof Array))throw Error("Invalid CBOR");if(w.value.length!==4)throw Error("Invalid COSE_SIGN1");let S;const E=w.value[0];try{if(S=f.Decoder.decode(E).value,!(S instanceof Map))throw Error()}catch{throw Error("Invalid protected")}const B=w.value[1];if(!(B instanceof Map))throw Error("Invalid unprotected");const ae=w.value[2],W=w.value[3];return new h({protectedMap:S,unProtectedMap:B,payload:ae,signature:W})}createSigStructure(b=p.Buffer.alloc(0)){let w=p.Buffer.alloc(0);this.protectedMap.size!==0&&(w=f.Encoder.encode(this.protectedMap));const S=["Signature1",w,b,this.payload];return f.Encoder.encode(S)}buildMessage(b){this.signature=b;let w=p.Buffer.alloc(0);this.protectedMap.size!==0&&(w=f.Encoder.encode(this.protectedMap));const S=[w,this.unProtectedMap,this.payload,this.signature];return f.Encoder.encode(S)}verifySignature({externalAad:b=p.Buffer.alloc(0),publicKeyBuffer:w}={}){if(w||(w=this.getPublicKey()),!w)throw Error("Public key not found");if(!this.signature)throw Error("Signature not found");return new c.PublicKey(w).verify(this.signature,this.createSigStructure(b))}hashPayload(){if(!this.unProtectedMap)throw Error("Invalid unprotected map");if(!this.payload)throw Error("Invalid payload");if(this.unProtectedMap.get("hashed"))throw Error("Payload already hashed");if(this.unProtectedMap.get("hashed")!=0)throw Error("Invalid unprotected map");this.unProtectedMap.set("hashed",!0);const b=(0,d.blake2b)(this.payload,void 0,24);this.payload=p.Buffer.from(b)}getAddress(){return this.protectedMap.get("address")}getPublicKey(){return this.protectedMap.get(4)}getSignature(){return this.signature}}a.default=h},2716:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(h,y,b,w){w===void 0&&(w=b);var S=Object.getOwnPropertyDescriptor(y,b);S&&!("get"in S?!y.__esModule:S.writable||S.configurable)||(S={enumerable:!0,get:function(){return y[b]}}),Object.defineProperty(h,w,S)}:function(h,y,b,w){w===void 0&&(w=b),h[w]=y[b]}),c=this&&this.__exportStar||function(h,y){for(var b in h)b==="default"||Object.prototype.hasOwnProperty.call(y,b)||f(y,h,b)},d=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(a,"__esModule",{value:!0}),a.CoseSign1=void 0;var p=s(6084);Object.defineProperty(a,"CoseSign1",{enumerable:!0,get:function(){return d(p).default}}),c(s(7225),a)},7225:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.getPublicKeyFromCoseKey=void 0;const f=s(7730),c=s(8764);a.getPublicKeyFromCoseKey=d=>{const p=f.Decoder.decode(c.Buffer.from(d,"hex")).value.get(-2);if(p)return p;throw Error("Public key not found")}},7801:function(u,a,s){var f=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.BaseAddress=void 0;const c=s(8764),d=s(23),p=f(s(4483));class h extends p.default{constructor(b,w,S){super(b,w),this.stakeCredential=S,this.computeHex()}computeHex(){let b=0;this._paymentCredential.type===d.HashType.ADDRESS||this._paymentCredential.type===d.HashType.SCRIPT&&(b|=16),this.stakeCredential.type===d.HashType.ADDRESS||this.stakeCredential.type===d.HashType.SCRIPT&&(b|=32),b|=this.networkId;const w=`${b.toString(16).padStart(2,"0")}${this._paymentCredential.hash}${this.stakeCredential.hash}`;this.addressHex=w,this.addressBytes=c.Buffer.from(w,"hex"),this.addressBech32=this.computeBech32(this.addressBytes)}}a.BaseAddress=h,a.default=h},5027:function(u,a,s){var f=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(a,"__esModule",{value:!0}),a.ByronAddress=void 0;const c=f(s(7191));class d{constructor(h){this.addressBech32=c.default.encode(h),this.addressBytes=h,this.addressHex=h.toString("hex")}getHex(){return this.addressHex}getBytes(){return this.addressBytes}getBech32(){return this.addressBech32}}a.ByronAddress=d,a.default=d},1989:function(u,a,s){var f=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.EnterpriseAddress=void 0;const c=s(8764),d=s(23),p=f(s(4483));class h extends p.default{constructor(b,w){super(b,w),this.computeHex()}computeHex(){let b=96;this._paymentCredential.type===d.HashType.ADDRESS||this._paymentCredential.type===d.HashType.SCRIPT&&(b|=16),b|=this.networkId;const w=`${b.toString(16).padStart(2,"0")}${this._paymentCredential.hash}`;this.addressHex=w,this.addressBytes=c.Buffer.from(w,"hex"),this.addressBech32=this.computeBech32(this.addressBytes)}}a.EnterpriseAddress=h,a.default=h},9105:function(u,a,s){var f=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.PointerAddress=void 0;const c=s(8764),d=s(23),p=f(s(4483));class h extends p.default{constructor(b,w,S){super(b,w),this._vlq=S,this.computeHex()}computeHex(){let b=64;this._paymentCredential.type===d.HashType.ADDRESS||this._paymentCredential.type===d.HashType.SCRIPT&&(b|=16),b|=this.networkId;const w=`${b.toString(16).padStart(2,"0")}${this._paymentCredential.hash}${this._vlq}`;this.addressHex=w,this.addressBytes=c.Buffer.from(w,"hex"),this.addressBech32=this.computeBech32(this.addressBytes)}}a.PointerAddress=h,a.default=h},7452:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.RewardAddress=void 0;const f=s(8764),c=s(7715),d=s(23);class p{constructor(y,b){this.addressHex="",this.addressBytes=f.Buffer.alloc(0),this.addressBech32="",this._stakeCredential=b,this.networkId=y,this.computeHex()}computeBech32(y){const b=this.networkId===d.NetworkId.MAINNET?"stake":"stake_test",w=c.bech32.toWords(y);return c.bech32.encode(b,w,1e3)}computeHex(){let y=224;this._stakeCredential.type===d.HashType.ADDRESS||this._stakeCredential.type===d.HashType.SCRIPT&&(y|=16),y|=this.networkId;const b=`${y.toString(16).padStart(2,"0")}${this._stakeCredential.hash}`;this.addressHex=b,this.addressBytes=f.Buffer.from(b,"hex"),this.addressBech32=this.computeBech32(this.addressBytes)}get stakeCredential(){return this._stakeCredential}getHex(){return this.addressHex}getBytes(){return this.addressBytes}getBech32(){return this.addressBech32}getNetworkId(){return this.networkId}}a.RewardAddress=p,a.default=p},4483:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ShelleyTypeAddress=void 0;const f=s(8764),c=s(7715),d=s(23);class p{constructor(y,b){this.addressHex="",this.addressBytes=f.Buffer.alloc(0),this.addressBech32="",this.networkId=y,this._paymentCredential=b}computeBech32(y){const b=this.networkId===d.NetworkId.MAINNET?"addr":"addr_test",w=c.bech32.toWords(y);return c.bech32.encode(b,w,1e3)}get paymentCredential(){return this._paymentCredential}getHex(){return this.addressHex}getBytes(){return this.addressBytes}getBech32(){return this.addressBech32}getNetworkId(){return this.networkId}}a.ShelleyTypeAddress=p,a.default=p},3604:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.RewardAddress=a.PointerAddress=a.EnterpriseAddress=a.ByronAddress=a.BaseAddress=void 0;var f=s(7801);Object.defineProperty(a,"BaseAddress",{enumerable:!0,get:function(){return f.BaseAddress}});var c=s(5027);Object.defineProperty(a,"ByronAddress",{enumerable:!0,get:function(){return c.ByronAddress}});var d=s(1989);Object.defineProperty(a,"EnterpriseAddress",{enumerable:!0,get:function(){return d.EnterpriseAddress}});var p=s(9105);Object.defineProperty(a,"PointerAddress",{enumerable:!0,get:function(){return p.PointerAddress}});var h=s(7452);Object.defineProperty(a,"RewardAddress",{enumerable:!0,get:function(){return h.RewardAddress}})},1617:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.maxTokenAmount=void 0,a.maxTokenAmount="9223372036854775807"},9528:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(b,w,S,E){E===void 0&&(E=S);var B=Object.getOwnPropertyDescriptor(w,S);B&&!("get"in B?!w.__esModule:B.writable||B.configurable)||(B={enumerable:!0,get:function(){return w[S]}}),Object.defineProperty(b,E,B)}:function(b,w,S,E){E===void 0&&(E=S),b[E]=w[S]}),c=this&&this.__setModuleDefault||(Object.create?function(b,w){Object.defineProperty(b,"default",{enumerable:!0,value:w})}:function(b,w){b.default=w}),d=this&&this.__importStar||function(b){if(b&&b.__esModule)return b;var w={};if(b!=null)for(var S in b)S!=="default"&&Object.prototype.hasOwnProperty.call(b,S)&&f(w,b,S);return c(w,b),w};Object.defineProperty(a,"__esModule",{value:!0}),a.PlutusDataFactory=a.NativeScriptFactory=a.address=a.Transaction=a.types=a.utils=a.crypto=void 0,a.crypto=d(s(3678)),a.utils=d(s(6397)),a.types=d(s(23));var p=s(9779);Object.defineProperty(a,"Transaction",{enumerable:!0,get:function(){return p.Transaction}}),a.address=d(s(3604));var h=s(3117);Object.defineProperty(a,"NativeScriptFactory",{enumerable:!0,get:function(){return h.NativeScriptFactory}});var y=s(2383);Object.defineProperty(a,"PlutusDataFactory",{enumerable:!0,get:function(){return y.PlutusDataFactory}})},7067:(u,a)=>{var s;Object.defineProperty(a,"__esModule",{value:!0}),a.RedeemerTag=void 0,(s=a.RedeemerTag||(a.RedeemerTag={}))[s.SPEND=0]="SPEND",s[s.MINT=1]="MINT",s[s.CERT=2]="CERT",s[s.REWARD=3]="REWARD"},3117:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(S,E,B,ae){ae===void 0&&(ae=B);var W=Object.getOwnPropertyDescriptor(E,B);W&&!("get"in W?!E.__esModule:W.writable||W.configurable)||(W={enumerable:!0,get:function(){return E[B]}}),Object.defineProperty(S,ae,W)}:function(S,E,B,ae){ae===void 0&&(ae=B),S[ae]=E[B]}),c=this&&this.__setModuleDefault||(Object.create?function(S,E){Object.defineProperty(S,"default",{enumerable:!0,value:E})}:function(S,E){S.default=E}),d=this&&this.__importStar||function(S){if(S&&S.__esModule)return S;var E={};if(S!=null)for(var B in S)B!=="default"&&Object.prototype.hasOwnProperty.call(S,B)&&f(E,S,B);return c(E,S),E};Object.defineProperty(a,"__esModule",{value:!0}),a.NativeScriptFactory=void 0;const p=s(8764),h=d(s(7730)),y=s(3678),b=s(6171);class w{constructor(E){this.nativeScript=E;const B=(0,b.encodeNativeScript)(E);this._cbor=h.Encoder.encode(B),this._policyId=(0,y.hash28)(p.Buffer.from(`00${this._cbor.toString("hex")}`,"hex"))}cbor(){return this._cbor}policyId(){return this._policyId}json(){return this.nativeScript}}a.NativeScriptFactory=w,a.default=w},2383:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(b,w,S,E){E===void 0&&(E=S);var B=Object.getOwnPropertyDescriptor(w,S);B&&!("get"in B?!w.__esModule:B.writable||B.configurable)||(B={enumerable:!0,get:function(){return w[S]}}),Object.defineProperty(b,E,B)}:function(b,w,S,E){E===void 0&&(E=S),b[E]=w[S]}),c=this&&this.__setModuleDefault||(Object.create?function(b,w){Object.defineProperty(b,"default",{enumerable:!0,value:w})}:function(b,w){b.default=w}),d=this&&this.__importStar||function(b){if(b&&b.__esModule)return b;var w={};if(b!=null)for(var S in b)S!=="default"&&Object.prototype.hasOwnProperty.call(b,S)&&f(w,b,S);return c(w,b),w};Object.defineProperty(a,"__esModule",{value:!0}),a.PlutusDataFactory=void 0;const p=d(s(7730)),h=s(3678),y=s(6171);a.PlutusDataFactory=class{constructor(b){this.plutusData=b;const w=(0,y.encodePlutusData)(b);this._cbor=p.Encoder.encode(w),this._plutusDataHash=(0,h.hash32)(this._cbor)}cbor(){return this._cbor}plutusDataHash(){return this._plutusDataHash}json(){return this.plutusData}}},9779:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(kt,nr,sr,ce){ce===void 0&&(ce=sr);var Ze=Object.getOwnPropertyDescriptor(nr,sr);Ze&&!("get"in Ze?!nr.__esModule:Ze.writable||Ze.configurable)||(Ze={enumerable:!0,get:function(){return nr[sr]}}),Object.defineProperty(kt,ce,Ze)}:function(kt,nr,sr,ce){ce===void 0&&(ce=sr),kt[ce]=nr[sr]}),c=this&&this.__setModuleDefault||(Object.create?function(kt,nr){Object.defineProperty(kt,"default",{enumerable:!0,value:nr})}:function(kt,nr){kt.default=nr}),d=this&&this.__importStar||function(kt){if(kt&&kt.__esModule)return kt;var nr={};if(kt!=null)for(var sr in kt)sr!=="default"&&Object.prototype.hasOwnProperty.call(kt,sr)&&f(nr,kt,sr);return c(nr,kt),nr},p=this&&this.__importDefault||function(kt){return kt&&kt.__esModule?kt:{default:kt}};Object.defineProperty(a,"__esModule",{value:!0}),a.Transaction=void 0;const h=s(8764),y=d(s(7730)),b=p(s(4431)),w=p(s(6486)),S=s(2027),E=s(23),B=s(6171),ae=s(3678),W=s(6397),J=p(s(9677)),ve=s(9494);class Qe{constructor({protocolParams:nr}){this.inputs=[],this.outputs=[],this.certificates=[],this.withdrawals=[],this.requiredWitnesses=new Map,this.requiredNativeScriptWitnesses=new Map,this.fee=new b.default(5e6),this.witnesses=[],this.plutusScriptMap=new Map,this.nativeScriptList=[],this.collaterals=[],this.requiredSigners=new Map,this.plutusDataList=[],this._isPlutusTransaction=!1,this.mints=[],this._protocolParams=nr}get protocolParams(){return this._protocolParams}getTTL(){return this.ttl}setTTL(nr){this.ttl=nr}getValidityIntervalStart(){return this.validityIntervalStart}setValidityIntervalStart(nr){this.validityIntervalStart=nr}addInput(nr){if(nr.address.paymentCredential.type===E.HashType.ADDRESS)this.requiredWitnesses.set(nr.address.paymentCredential.hash,nr.address.paymentCredential.bipPath);else if(nr.address.paymentCredential.type===E.HashType.SCRIPT){if(nr.address.paymentCredential.plutusScript)this._isPlutusTransaction=!0,this.plutusScriptMap.set(nr.address.paymentCredential.plutusScript.cborHex,nr.address.paymentCredential.plutusScript.type);else if(nr.address.paymentCredential.nativeScript){const sr=nr.address.paymentCredential.nativeScript,ce=(0,S.getPubKeyHashListFromNativeScript)(sr);for(const Ze of ce)this.requiredNativeScriptWitnesses.set(Ze,void 0);this.nativeScriptList.push(sr)}}nr.plutusData&&this.plutusDataList.push(nr.plutusData),this.inputs.push(nr)}addRequiredSigner(nr){this.requiredSigners.set(nr.hash,nr.bipPath)}addCollateral(nr){nr.address.paymentCredential.type===E.HashType.ADDRESS&&this.requiredWitnesses.set(nr.address.paymentCredential.hash,nr.address.paymentCredential.bipPath),this.collaterals.push(nr)}addMint(nr){if(this.mints.push(nr),nr.plutusScript)this._isPlutusTransaction=!0,this.plutusScriptMap.set(nr.plutusScript.cborHex,nr.plutusScript.type);else if(nr.nativeScript){const sr=(0,S.getPubKeyHashListFromNativeScript)(nr.nativeScript);for(const ce of sr)this.requiredNativeScriptWitnesses.set(ce,void 0);this.nativeScriptList.push(nr.nativeScript)}}addCertificate(nr){nr.certType===E.CertificateType.STAKE_DELEGATION?nr.stakeCredential.type===E.HashType.ADDRESS&&this.requiredWitnesses.set(nr.stakeCredential.hash,nr.stakeCredential.bipPath):nr.certType===E.CertificateType.STAKE_DE_REGISTRATION&&nr.stakeCredential.type===E.HashType.ADDRESS&&this.requiredWitnesses.set(nr.stakeCredential.hash,nr.stakeCredential.bipPath),this.certificates.push(nr)}addOutput(nr){const sr=nr;if(sr.tokens=(0,S.sortTokens)(sr.tokens),sr.plutusData){const ce=y.Encoder.encode((0,B.encodePlutusData)(sr.plutusData));sr.plutusDataHash=(0,ae.hash32)(ce).toString("hex")}this.outputs.push(sr),sr.plutusData&&this.plutusDataList.push(sr.plutusData)}addWithdrawal(nr){nr.rewardAccount.stakeCredential.type===E.HashType.ADDRESS&&this.requiredWitnesses.set(nr.rewardAccount.stakeCredential.hash,nr.rewardAccount.stakeCredential.bipPath),this.withdrawals.push(nr)}transactionBody({extraOutputs:nr,scriptDataHash:sr}){const ce=new Map;ce.set(E.TransactionBodyItemType.INPUTS,(0,B.encodeInputs)(this.inputs));let Ze=this.outputs;if(nr&&nr.length>0&&(Ze=Ze.concat(nr)),ce.set(E.TransactionBodyItemType.OUTPUTS,(0,B.encodeOutputs)(Ze)),ce.set(E.TransactionBodyItemType.FEE,this.fee),this.ttl!==void 0&&ce.set(E.TransactionBodyItemType.TTL,this.ttl),this.validityIntervalStart!==void 0&&ce.set(E.TransactionBodyItemType.VALIDITY_INTERVAL_START,this.validityIntervalStart),this.certificates.length>0&&ce.set(E.TransactionBodyItemType.CERTIFICATES,(0,B.encodeCertificates)(this.certificates)),this.withdrawals.length>0&&ce.set(E.TransactionBodyItemType.WITHDRAWALS,(0,B.encodeWithdrawals)(this.withdrawals)),this.auxiliaryData){const vt=(0,B.encodeAuxiliaryData)(this.auxiliaryData),ur=y.Encoder.encode(vt),ue=(0,ae.hash32)(ur);ce.set(E.TransactionBodyItemType.AUXILIARY_DATA_HASH,ue)}w.default.isEmpty(this.mints)||ce.set(E.TransactionBodyItemType.MINT,(0,B.encodeMint)(this.mints)),sr&&ce.set(E.TransactionBodyItemType.SCRIPT_DATA_HASH,sr),w.default.isEmpty(this.collaterals)||ce.set(E.TransactionBodyItemType.COLLATERAL_INPUTS,(0,B.encodeCollaterals)(this.collaterals));const se=Array.from(this.requiredSigners.keys());return w.default.isEmpty(se)||ce.set(E.TransactionBodyItemType.REQUIRED_SIGNERS,se.map((vt=>h.Buffer.from(vt,"hex")))),ce}transactionFee(nr){return new b.default(nr).times(this._protocolParams.minFeeA).plus(this._protocolParams.minFeeB).integerValue(b.default.ROUND_CEIL)}contractFee(){let nr=0,sr=0;for(const se of this.inputs)se.redeemer&&(nr+=se.redeemer.exUnits.mem,sr+=se.redeemer.exUnits.steps);for(const se of this.mints)se.redeemer&&(nr+=se.redeemer.exUnits.mem,sr+=se.redeemer.exUnits.steps);const ce=new b.default(nr).times(this._protocolParams.priceMem),Ze=new b.default(sr).times(this._protocolParams.priceSteps);return ce.plus(Ze).integerValue(b.default.ROUND_CEIL)}calculateTxSize(nr){const sr=new Map;for(const[ur,ue]of this.requiredNativeScriptWitnesses.entries())sr.set(ur,ue);for(const[ur,ue]of this.requiredSigners.entries())sr.set(ur,ue);for(const[ur,ue]of this.requiredWitnesses.entries())sr.set(ur,ue);const ce=[];for(const[ur]of Array.from(sr.keys()).entries())ce.push({publicKey:h.Buffer.alloc(32,ur),signature:h.Buffer.alloc(64)});const Ze=(0,B.encodeWitnesses)(ce,this.inputs,this.plutusDataList,this.plutusScriptMap,this.nativeScriptList,this.mints),se=(0,S.generateScriptDataHash)(Ze,this._protocolParams.languageView),vt=[this.transactionBody({extraOutputs:nr,scriptDataHash:se}),Ze,!0,this.auxiliaryData?(0,B.encodeAuxiliaryData)(this.auxiliaryData):null];return y.Encoder.encode(vt).length}calculateFee(nr){const sr=this.calculateTxSize(nr),ce=this.transactionFee(sr),Ze=this.contractFee();return ce.plus(Ze)}setFee(nr){this.fee=nr}getFee(){return this.fee}calculateMinUtxoAmount(nr,sr){return(0,W.calculateMinUtxoAmount)(nr,this._protocolParams.lovelacePerUtxoWord,sr)}addWitness(nr){this.witnesses.push(nr)}getTransactionHash(){const nr=(0,B.encodeWitnesses)(this.witnesses,this.inputs,this.plutusDataList,this.plutusScriptMap,this.nativeScriptList,this.mints),sr=(0,S.generateScriptDataHash)(nr,this._protocolParams.languageView),ce=this.transactionBody({scriptDataHash:sr}),Ze=y.Encoder.encode(ce);return(0,ae.hash32)(Ze)}getAuxiliaryData(){return this.auxiliaryData}getAuxiliaryDataHashHex(){if(this.auxiliaryData){const nr=(0,B.encodeAuxiliaryData)(this.auxiliaryData),sr=y.Encoder.encode(nr);return(0,ae.hash32)(sr).toString("hex")}}buildTransaction(){const nr=(0,B.encodeWitnesses)(this.witnesses,this.inputs,this.plutusDataList,this.plutusScriptMap,this.nativeScriptList,this.mints),sr=(0,S.generateScriptDataHash)(nr,this._protocolParams.languageView),ce=this.transactionBody({scriptDataHash:sr}),Ze=[ce,nr,!0,this.auxiliaryData?(0,B.encodeAuxiliaryData)(this.auxiliaryData):null],se=y.Encoder.encode(Ze),vt=y.Encoder.encode(ce);return{hash:(0,ae.hash32)(vt).toString("hex"),payload:se.toString("hex")}}getInputs(){return this.inputs}getCertificates(){return this.certificates}getMints(){const nr=[];for(const ce of this.mints)for(const Ze of ce.assets)nr.push({policyId:ce.policyId,assetName:Ze.assetName,amount:Ze.amount});const sr=(0,S.sortTokens)(nr);return(0,w.default)(sr).groupBy((ce=>ce.policyId)).map(((ce,Ze)=>({policyId:Ze,assets:ce.map((se=>({assetName:se.assetName,amount:se.amount})))}))).value()}getMintTokens(){const nr=[];for(const sr of this.mints)for(const ce of sr.assets)ce.amount.isPositive()&&nr.push({policyId:sr.policyId,assetName:ce.assetName,amount:ce.amount});return nr}getBurnTokens(){const nr=[];for(const sr of this.mints)for(const ce of sr.assets)ce.amount.isNegative()&&nr.push({policyId:sr.policyId,assetName:ce.assetName,amount:ce.amount.abs()});return nr}getInputAmount(){let nr=[],sr=new b.default(0);return w.default.forEach(this.inputs,(ce=>{nr=nr.concat(ce.tokens),sr=sr.plus(ce.amount)})),nr=w.default.concat(nr,this.getMintTokens()),{ada:sr,tokens:(0,S.getUniqueTokens)(nr)}}getCollaterals(){return this.collaterals}getScriptIntegrityHash(){const nr=(0,B.encodeWitnesses)(this.witnesses,this.inputs,this.plutusDataList,this.plutusScriptMap,this.nativeScriptList,this.mints);return(0,S.generateScriptDataHash)(nr,this._protocolParams.languageView)}getCollateralAmount(){return this.collaterals.reduce(((nr,sr)=>nr.plus(sr.amount)),new b.default(0))}getOutputs(){return this.outputs}getOutputAmount(){let nr=[],sr=new b.default(0);return w.default.forEach(this.outputs,(ce=>{nr=nr.concat(ce.tokens),sr=sr.plus(ce.amount)})),nr=w.default.concat(nr,this.getBurnTokens()),{ada:sr,tokens:(0,S.getUniqueTokens)(nr)}}getAdditionalOutputAda(){return w.default.reduce(this.certificates,((nr,sr)=>sr.certType===E.CertificateType.STAKE_REGISTRATION?nr.plus(this._protocolParams.stakeKeyDeposit):nr),new b.default(0))}getAdditionalInputAda(){const nr=w.default.reduce(this.certificates,((ce,Ze)=>Ze.certType===E.CertificateType.STAKE_DE_REGISTRATION?ce.plus(this._protocolParams.stakeKeyDeposit):ce),new b.default(0)),sr=w.default.reduce(this.withdrawals,((ce,Ze)=>ce.plus(Ze.amount)),new b.default(0));return nr.plus(sr)}getWithdrawals(){return this.withdrawals}getRequiredWitnesses(){return this.requiredWitnesses}getRequiredNativeScriptWitnesses(){return this.requiredNativeScriptWitnesses}getRequiredSigners(){return this.requiredSigners}setAuxiliaryData(nr){this.auxiliaryData=nr}isPlutusTransaction(){return this._isPlutusTransaction}prepareTransaction({inputs:nr,changeAddress:sr,collateralInputs:ce=[]}){return(0,J.default)({transaction:this,inputs:nr,changeAddress:sr,collateralInputs:ce})}paymentTransaction({inputs:nr,outputs:sr,changeAddress:ce,auxiliaryData:Ze,ttl:se}){return(0,ve.paymentTransaction)({inputs:nr,outputs:sr,changeAddress:ce,auxiliaryData:Ze,ttl:se,protocolParams:this.protocolParams})}}a.Transaction=Qe,a.default=Qe},9494:function(u,a,s){var f=this&&this.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(a,"__esModule",{value:!0}),a.paymentTransaction=void 0;const c=f(s(9779));a.paymentTransaction=({inputs:d,outputs:p,changeAddress:h,auxiliaryData:y,ttl:b,protocolParams:w})=>{const S=new c.default({protocolParams:w});return p.forEach((E=>{S.addOutput(E)})),S.setTTL(b),y&&S.setAuxiliaryData(y),S.prepareTransaction({inputs:d,changeAddress:h})},a.default=a.paymentTransaction},9677:function(u,a,s){var f=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(a,"__esModule",{value:!0}),a.transactionBuilder=void 0;const c=f(s(4431)),d=s(6486),p=s(2027),h=s(6397);function y({transaction:b,inputs:w,changeAddress:S,collateralInputs:E=[]}){const B=bt=>{const L=b.getCollateralAmount(),_=bt.times(b.protocolParams.collateralPercent).div(100);if(b.isPlutusTransaction()&&L.lt(_))throw new Error("Not enough collateral supplied, collaterals with tokens are not valid collaterals")},ae=bt=>{if(E&&E.length>0){const L=b.getCollateralAmount(),_=bt.times(b.protocolParams.collateralPercent).div(100);for(;L.lt(_)&&E.length>0;){const F=E.pop();F&&b.addCollateral(F)}}},W=(0,h.calculateMinUtxoAmount)([],new c.default(b.protocolParams.lovelacePerUtxoWord)),J=d.cloneDeep(w);if(J.length>0){const bt=J.splice(0,1)[0];b.addInput(bt)}const ve=E.pop();ve&&b.addCollateral(ve);for(const bt of J){const{ada:L,tokens:_}=b.getInputAmount(),{ada:F,tokens:k}=b.getOutputAmount(),Ye=b.getAdditionalOutputAda(),rn=b.getAdditionalInputAda();let ii=b.calculateFee();ae(ii),ii=b.calculateFee();const ai=L.plus(rn),ni=F.plus(Ye).plus(ii),ri=(0,p.getTokenDiff)(_,k);if(ri.length===0){if(ai.eq(ni))break;if(ai.gt(ni)){const ui=ai.minus(F.plus(Ye));if(ui.gt(W)){let lr=b.calculateFee([{address:S,amount:ui,tokens:[]}]);if(ae(ii),lr=b.calculateFee([{address:S,amount:ui,tokens:[]}]),ui.gte(lr.plus(W)))break}}}else if(!ri.some((({amount:ui})=>ui.lt(0)))){const ui=(0,h.getMaximumTokenSets)(ri),lr=[];let ar=ai.minus(F.plus(Ye)),jr=new c.default(0);for(const[ci,mi]of ui.entries()){const pi=(0,h.calculateMinUtxoAmount)(mi,new c.default(b.protocolParams.lovelacePerUtxoWord));let ei=pi;if(ci===ui.length-1){let Gr=b.calculateFee([...lr,{address:S,amount:ar.lt(pi)?pi:ar,tokens:mi}]);ae(Gr),Gr=b.calculateFee([...lr,{address:S,amount:ar.lt(pi)?pi:ar,tokens:mi}]);const ti=pi.plus(Gr);ar.gte(ti)?ei=ar:jr=jr.plus(ti.minus(ar))}else ar.gte(pi)?ar=ar.minus(pi):jr=jr.plus(pi.minus(ar));lr.push({address:S,amount:ei,tokens:mi})}if(jr.eq(0))break}b.addInput(bt)}const{ada:Qe,tokens:kt}=b.getInputAmount(),{ada:nr,tokens:sr}=b.getOutputAmount(),ce=b.getAdditionalOutputAda(),Ze=b.getAdditionalInputAda(),se=Qe.plus(Ze),vt=nr.plus(ce),ur=(0,p.getTokenDiff)(kt,sr);if(ur.length===0){const bt=b.calculateFee(),L=vt.plus(bt);if(se.eq(L))b.setFee(bt),B(bt);else{if(!se.gt(L))throw new Error("Not enough ADA");{const _=se.minus(vt);if(_.gt(W.plus(bt))){const F=b.calculateFee([{address:S,amount:_,tokens:[]}]);B(F),b.setFee(F),b.addOutput({address:S,amount:_.minus(F),tokens:[]})}else b.setFee(_)}}}else{if(ur.some((({amount:bt})=>bt.lt(0))))throw new Error("Not enough tokens");{const bt=(0,h.getMaximumTokenSets)(d.clone(ur)),L=[];{let k=se.minus(vt);bt.forEach(((Ye,rn)=>{const ii=(0,h.calculateMinUtxoAmount)(Ye,new c.default(b.protocolParams.lovelacePerUtxoWord));let ai=ii;if(rn===bt.length-1){const ni=b.calculateFee([...L,{address:S,amount:k.lt(ii)?ii:k,tokens:Ye}]),ri=ii.plus(ni);if(!k.gte(ri))throw new Error("Not enough ADA");ai=k}else{if(!k.gte(ii))throw new Error("Not enough ADA");k=k.minus(ii)}L.push({address:S,amount:ai,tokens:Ye})}))}const _=b.calculateFee(L);B(_),b.setFee(_);let F=se.minus(vt).minus(_);bt.forEach(((k,Ye)=>{const rn=(0,h.calculateMinUtxoAmount)(k,new c.default(b.protocolParams.lovelacePerUtxoWord));let ii=rn;Ye===bt.length-1?ii=F:F.gte(rn)&&(F=F.minus(rn)),b.addOutput({address:S,amount:ii,tokens:k})}))}}const ue=b.calculateTxSize();if(b.protocolParams.maxTxSize&&ue>b.protocolParams.maxTxSize)throw new Error("Tx size limit reached, try spending lesser ADA/Tokens");return b}a.transactionBuilder=y,a.default=y},23:(u,a)=>{var s,f,c,d,p;Object.defineProperty(a,"__esModule",{value:!0}),a.TransactionBodyItemType=a.NetworkId=a.WitnessType=a.CertificateType=a.PlutusScriptType=a.HashType=void 0,(p=a.HashType||(a.HashType={}))[p.ADDRESS=0]="ADDRESS",p[p.SCRIPT=1]="SCRIPT",(a.PlutusScriptType||(a.PlutusScriptType={})).PlutusScriptV1="PlutusScriptV1",(d=a.CertificateType||(a.CertificateType={}))[d.STAKE_REGISTRATION=0]="STAKE_REGISTRATION",d[d.STAKE_DE_REGISTRATION=1]="STAKE_DE_REGISTRATION",d[d.STAKE_DELEGATION=2]="STAKE_DELEGATION",(c=a.WitnessType||(a.WitnessType={}))[c.V_KEY_WITNESS=0]="V_KEY_WITNESS",c[c.NATIVE_SCRIPT=1]="NATIVE_SCRIPT",c[c.PLUTUS_SCRIPT=3]="PLUTUS_SCRIPT",c[c.PLUTUS_DATA=4]="PLUTUS_DATA",c[c.REDEEMER=5]="REDEEMER",(f=a.NetworkId||(a.NetworkId={}))[f.MAINNET=1]="MAINNET",f[f.TESTNET=0]="TESTNET",(s=a.TransactionBodyItemType||(a.TransactionBodyItemType={}))[s.INPUTS=0]="INPUTS",s[s.OUTPUTS=1]="OUTPUTS",s[s.FEE=2]="FEE",s[s.TTL=3]="TTL",s[s.CERTIFICATES=4]="CERTIFICATES",s[s.WITHDRAWALS=5]="WITHDRAWALS",s[s.AUXILIARY_DATA_HASH=7]="AUXILIARY_DATA_HASH",s[s.VALIDITY_INTERVAL_START=8]="VALIDITY_INTERVAL_START",s[s.MINT=9]="MINT",s[s.SCRIPT_DATA_HASH=11]="SCRIPT_DATA_HASH",s[s.COLLATERAL_INPUTS=13]="COLLATERAL_INPUTS",s[s.REQUIRED_SIGNERS=14]="REQUIRED_SIGNERS"},3678:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.hash28=a.hash32=void 0;const f=s(8764),c=s(1191);a.hash32=d=>{const p=(0,c.blake2b)(d,void 0,32);return f.Buffer.from(p)},a.hash28=d=>{const p=(0,c.blake2b)(d,void 0,28);return f.Buffer.from(p)}},6171:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(ve,Qe,kt,nr){nr===void 0&&(nr=kt);var sr=Object.getOwnPropertyDescriptor(Qe,kt);sr&&!("get"in sr?!Qe.__esModule:sr.writable||sr.configurable)||(sr={enumerable:!0,get:function(){return Qe[kt]}}),Object.defineProperty(ve,nr,sr)}:function(ve,Qe,kt,nr){nr===void 0&&(nr=kt),ve[nr]=Qe[kt]}),c=this&&this.__setModuleDefault||(Object.create?function(ve,Qe){Object.defineProperty(ve,"default",{enumerable:!0,value:Qe})}:function(ve,Qe){ve.default=Qe}),d=this&&this.__importStar||function(ve){if(ve&&ve.__esModule)return ve;var Qe={};if(ve!=null)for(var kt in ve)kt!=="default"&&Object.prototype.hasOwnProperty.call(ve,kt)&&f(Qe,ve,kt);return c(Qe,ve),Qe},p=this&&this.__importDefault||function(ve){return ve&&ve.__esModule?ve:{default:ve}};Object.defineProperty(a,"__esModule",{value:!0}),a.encodeNativeScript=a.encodeLanguageViews=a.encodePlutusData=a.encodeAuxiliaryData=a.encodeMetadata=a.encodeWitnesses=a.encodeVKeyWitness=a.encodeCertificates=a.encodeStakeDelegationCertificate=a.encodeStakeDeRegistrationCertificate=a.encodeStakeRegistrationCertificate=a.encodeWithdrawals=a.encodeOutputs=a.encodeOutput=a.encodeMint=a.encodeOutputTokens=a.encodeCollaterals=a.encodeInputs=void 0;const h=s(8764),y=d(s(7730)),b=p(s(4431)),w=p(s(6486)),S=s(23),E=s(2027),B=s(3678),ae=s(7067);a.encodeInputs=ve=>ve.map((Qe=>[h.Buffer.from(Qe.txId,"hex"),Qe.index])),a.encodeCollaterals=ve=>ve.map((Qe=>[h.Buffer.from(Qe.txId,"hex"),Qe.index])),a.encodeOutputTokens=ve=>{const Qe=new Map,kt=(0,w.default)(ve).groupBy((({policyId:nr})=>nr)).value();return w.default.forEach(kt,((nr,sr)=>{const ce=new Map;nr.forEach((({assetName:Ze,amount:se})=>{ce.set(h.Buffer.from(Ze,"hex"),se)})),Qe.set(h.Buffer.from(sr,"hex"),ce)})),Qe},a.encodeMint=ve=>{const Qe=new Map;for(const kt of ve){const nr=new Map;kt.assets.forEach((({assetName:sr,amount:ce})=>{nr.set(h.Buffer.from(sr,"hex"),ce)})),Qe.set(h.Buffer.from(kt.policyId,"hex"),nr)}return Qe},a.encodeOutput=ve=>{const Qe=ve.tokens.length>0?[ve.amount,(0,a.encodeOutputTokens)(ve.tokens)]:ve.amount,kt=[ve.address.getBytes(),Qe],nr=ve.plutusDataHash?h.Buffer.from(ve.plutusDataHash,"hex"):void 0;return nr&&kt.push(nr),kt},a.encodeOutputs=ve=>ve.map((Qe=>(0,a.encodeOutput)(Qe)),[]),a.encodeWithdrawals=ve=>{const Qe=new Map;return ve.forEach((kt=>{const nr=kt.rewardAccount.getBytes();Qe.set(nr,kt.amount)})),Qe},a.encodeStakeRegistrationCertificate=ve=>{const Qe=h.Buffer.from(ve.stakeCredential.hash,"hex"),kt=[ve.stakeCredential.type,Qe];return[S.CertificateType.STAKE_REGISTRATION,kt]},a.encodeStakeDeRegistrationCertificate=ve=>{const Qe=h.Buffer.from(ve.stakeCredential.hash,"hex"),kt=[ve.stakeCredential.type,Qe];return[S.CertificateType.STAKE_DE_REGISTRATION,kt]},a.encodeStakeDelegationCertificate=ve=>{const Qe=h.Buffer.from(ve.stakeCredential.hash,"hex"),kt=[ve.stakeCredential.type,Qe],nr=h.Buffer.from(ve.poolHash,"hex");return[S.CertificateType.STAKE_DELEGATION,kt,nr]},a.encodeCertificates=ve=>{const Qe=[];return ve.forEach((kt=>{switch(kt.certType){case S.CertificateType.STAKE_REGISTRATION:Qe.push((0,a.encodeStakeRegistrationCertificate)(kt));break;case S.CertificateType.STAKE_DE_REGISTRATION:Qe.push((0,a.encodeStakeDeRegistrationCertificate)(kt));break;case S.CertificateType.STAKE_DELEGATION:Qe.push((0,a.encodeStakeDelegationCertificate)(kt));break;default:throw new Error("unsupported certificate type")}})),Qe},a.encodeVKeyWitness=ve=>{const Qe=new Map;for(const nr of ve)Qe.set(nr.publicKey.toString("hex"),nr.signature);const kt=[];for(const[nr,sr]of Qe)kt.push([h.Buffer.from(nr,"hex"),sr]);return kt},a.encodeWitnesses=(ve,Qe,kt,nr,sr,ce)=>{const Ze=new Map;ve.length>0&&Ze.set(S.WitnessType.V_KEY_WITNESS,(0,a.encodeVKeyWitness)(ve));const se=w.default.orderBy(Qe,["txId","index"],["asc","asc"]),vt=w.default.orderBy(ce,["policyId"],["asc"]),ur=[],ue=new Map;for(const k of kt){const Ye=(0,a.encodePlutusData)(k),rn=y.Encoder.encode(Ye),ii=(0,B.hash32)(rn);ue.set(ii.toString("hex"),Ye)}for(const[k,Ye]of se.entries())if(Ye.redeemer){const rn=(0,a.encodePlutusData)(Ye.redeemer.plutusData);ur.push([ae.RedeemerTag.SPEND,k,rn,[Ye.redeemer.exUnits.mem,Ye.redeemer.exUnits.steps]])}for(const[k,Ye]of vt.entries())if(Ye.plutusScript&&Ye.redeemer){const rn=(0,a.encodePlutusData)(Ye.redeemer.plutusData);ur.push([ae.RedeemerTag.MINT,k,rn,[Ye.redeemer.exUnits.mem,Ye.redeemer.exUnits.steps]])}const bt=[];for(const[,k]of ue)bt.push(k);const L=[];for(const[k,Ye]of nr){if(Ye!==S.PlutusScriptType.PlutusScriptV1)throw new Error("Unsupported PlutusScript Version");{const rn=y.Decoder.decode(h.Buffer.from(k,"hex"));L.push(rn.value)}}L.length&&Ze.set(S.WitnessType.PLUTUS_SCRIPT,L);const _=new Map;for(const k of sr){const Ye=(0,a.encodeNativeScript)(k),rn=y.Encoder.encode(Ye);_.set(rn.toString("hex"),Ye)}const F=[];for(const[,k]of _)F.push(k);return F.length&&Ze.set(S.WitnessType.NATIVE_SCRIPT,F),bt.length&&Ze.set(S.WitnessType.PLUTUS_DATA,bt),ur.length&&Ze.set(S.WitnessType.REDEEMER,ur),Ze},a.encodeMetadata=ve=>{const Qe=new Map;for(const kt of ve)Qe.set(kt.label,(0,E.sanitizeMetadata)(kt.data));return Qe},a.encodeAuxiliaryData=ve=>{const Qe=(0,a.encodeMetadata)(ve.metadata),kt=new Map;return kt.set(0,Qe),new y.CborTag(kt,259)};const W=["constructor","fields"];a.encodePlutusData=ve=>{if(ve instanceof Array){if(ve.length>0){const Qe=new y.IndefiniteArray;for(const kt of ve)Qe.push((0,a.encodePlutusData)(kt));return Qe}return[]}if(ve instanceof Uint8Array)return h.Buffer.from(ve);if(ve instanceof h.Buffer)return ve;if(typeof ve=="string")throw new Error("String not supported in PlutusData");if(ve instanceof Map){if(ve.size>0){const Qe=new y.IndefiniteMap;for(const[kt,nr]of ve.entries())Qe.set(kt,(0,a.encodePlutusData)(nr));return Qe}return new Map}return b.default.isBigNumber(ve)?ve:ve instanceof Object?(Qe=>{if(!(Object.keys(Qe).every((nr=>W.includes(nr)))&&Qe.fields instanceof Array))throw new Error("Invalid PlutusData supplied");let kt=[];if(Qe.fields.length>0){kt=new y.IndefiniteArray;for(const nr of Qe.fields)kt.push((0,a.encodePlutusData)(nr))}if(Qe.constructor<7)return new y.CborTag(kt,121+Qe.constructor);if(Qe.constructor>6&&Qe.constructor<128){const nr=Qe.constructor-7;return new y.CborTag(kt,1280+nr)}return new y.CborTag([Qe.constructor,kt],102)})(ve):ve},a.encodeLanguageViews=(ve,Qe)=>{const kt=new Map;if(Qe&&Qe.length>0){const nr=(0,w.default)(ve.PlutusScriptV1).map(((se,vt)=>({key:vt,value:se}))).orderBy(["key"],["asc"]).map((se=>se.value)).value(),sr=y.IndefiniteArray.from(nr),ce=y.Encoder.encode(sr),Ze=y.Encoder.encode(0);kt.set(Ze,ce)}return y.Encoder.encode(kt).toString("hex")};const J=ve=>{const Qe=[];for(const kt of ve)Qe.push((0,a.encodeNativeScript)(kt));return Qe};a.encodeNativeScript=ve=>{if(ve.pubKeyHash)return[0,h.Buffer.from(ve.pubKeyHash,"hex")];if(ve.all)return[1,J(ve.all)];if(ve.any)return[2,J(ve.any)];if(ve.n)return[3,ve.n,J(ve.k)];if(ve.invalidBefore)return[4,ve.invalidBefore];if(ve.invalidAfter)return[5,ve.invalidAfter];throw new Error("Invalid native script")}},2027:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(W,J,ve,Qe){Qe===void 0&&(Qe=ve);var kt=Object.getOwnPropertyDescriptor(J,ve);kt&&!("get"in kt?!J.__esModule:kt.writable||kt.configurable)||(kt={enumerable:!0,get:function(){return J[ve]}}),Object.defineProperty(W,Qe,kt)}:function(W,J,ve,Qe){Qe===void 0&&(Qe=ve),W[Qe]=J[ve]}),c=this&&this.__setModuleDefault||(Object.create?function(W,J){Object.defineProperty(W,"default",{enumerable:!0,value:J})}:function(W,J){W.default=J}),d=this&&this.__importStar||function(W){if(W&&W.__esModule)return W;var J={};if(W!=null)for(var ve in W)ve!=="default"&&Object.prototype.hasOwnProperty.call(W,ve)&&f(J,W,ve);return c(J,W),J},p=this&&this.__importDefault||function(W){return W&&W.__esModule?W:{default:W}};Object.defineProperty(a,"__esModule",{value:!0}),a.getPubKeyHashListFromNativeScript=a.generateScriptDataHash=a.sortTokens=a.compareCanonically=a.sanitizeMetadata=a.getTokenDiff=a.getUniqueTokens=void 0;const h=s(8764),y=d(s(7730)),b=p(s(4431)),w=p(s(6486)),S=s(6171),E=s(23),B=s(3678);a.getUniqueTokens=W=>(0,w.default)(W).groupBy((({policyId:J})=>J)).map(((J,ve)=>(0,w.default)(J).groupBy((({assetName:Qe})=>Qe)).map(((Qe,kt)=>({policyId:ve,assetName:kt,amount:Qe.reduce(((nr,sr)=>nr.plus(sr.amount)),new b.default(0))}))).value())).flatten().value(),a.getTokenDiff=(W,J)=>{const ve=w.default.map(J,(Qe=>Object.assign(Object.assign({},Qe),{amount:Qe.amount.negated()})));return(0,a.getUniqueTokens)(W.concat(ve)).filter((Qe=>Qe.amount.abs().gt(0)))},a.sanitizeMetadata=W=>{if(W instanceof Array){const J=[];for(const ve of W)J.push((0,a.sanitizeMetadata)(ve));return J}if(typeof W=="string"||W instanceof h.Buffer){if(W.length>64)throw new Error("string or buffer length invalid");return W}if(W instanceof Map){const J=new Map;for(const[ve,Qe]of W.entries())J.set(ve,(0,a.sanitizeMetadata)(Qe));return J}if(W instanceof Object){const J=new Map;for(const[ve,Qe]of Object.entries(W))J.set(ve,(0,a.sanitizeMetadata)(Qe));return J}return W},a.compareCanonically=(W,J)=>W.length!==J.length?W.length-J.length:(W=W.toLowerCase())<(J=J.toLowerCase())?-1:W>J?1:0,a.sortTokens=W=>(0,w.default)(W).orderBy(["policyId","assetName"],["asc","asc"]).sort(((J,ve)=>(0,a.compareCanonically)(J.assetName,ve.assetName))).sort(((J,ve)=>(0,a.compareCanonically)(J.policyId,ve.policyId))).value(),a.generateScriptDataHash=(W,J)=>{const ve=W.get(E.WitnessType.PLUTUS_DATA),Qe=W.get(E.WitnessType.REDEEMER);if(ve||Qe){const kt=W.get(E.WitnessType.PLUTUS_SCRIPT),nr=(0,S.encodeLanguageViews)(J,kt),sr=ve?.length?y.Encoder.encode(ve).toString("hex"):"",ce=Qe?y.Encoder.encode(Qe).toString("hex"):y.Encoder.encode([]).toString("hex"),Ze=h.Buffer.from(ce+sr+nr,"hex");return(0,B.hash32)(Ze)}};const ae=W=>{let J=[];for(const ve of W){const Qe=(0,a.getPubKeyHashListFromNativeScript)(ve);J=w.default.concat(J,w.default.flatten(Qe))}return J};a.getPubKeyHashListFromNativeScript=W=>{let J=[];if(W.pubKeyHash)J.push(W.pubKeyHash);else if(W.all){const ve=ae(W.all);J=w.default.concat(J,w.default.flatten(ve))}else if(W.any){const ve=ae(W.any);J=w.default.concat(J,w.default.flatten(ve))}else if(W.n){const ve=ae(W.k);J=w.default.concat(J,w.default.flatten(ve))}return J}},6397:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(ce,Ze,se,vt){vt===void 0&&(vt=se);var ur=Object.getOwnPropertyDescriptor(Ze,se);ur&&!("get"in ur?!Ze.__esModule:ur.writable||ur.configurable)||(ur={enumerable:!0,get:function(){return Ze[se]}}),Object.defineProperty(ce,vt,ur)}:function(ce,Ze,se,vt){vt===void 0&&(vt=se),ce[vt]=Ze[se]}),c=this&&this.__setModuleDefault||(Object.create?function(ce,Ze){Object.defineProperty(ce,"default",{enumerable:!0,value:Ze})}:function(ce,Ze){ce.default=Ze}),d=this&&this.__importStar||function(ce){if(ce&&ce.__esModule)return ce;var Ze={};if(ce!=null)for(var se in ce)se!=="default"&&Object.prototype.hasOwnProperty.call(ce,se)&&f(Ze,ce,se);return c(Ze,ce),Ze},p=this&&this.__importDefault||function(ce){return ce&&ce.__esModule?ce:{default:ce}};Object.defineProperty(a,"__esModule",{value:!0}),a.createPlutusDataCbor=a.createAuxiliaryDataCbor=a.getMaximumTokenSets=a.getAddressFromBech32=a.decodeBech32=a.getAddressFromHex=a.calculateMinUtxoAmount=void 0;const h=s(8764),y=d(s(7730)),b=p(s(4431)),w=s(6486),S=p(s(7191)),E=s(7715),B=s(1617),ae=p(s(7801)),W=p(s(5027)),J=p(s(1989)),ve=p(s(9105)),Qe=s(2027),kt=s(23),nr=p(s(7452)),sr=s(6171);a.calculateMinUtxoAmount=(ce,Ze,se)=>{const vt=(0,Qe.getUniqueTokens)(ce);let ur=27;se&&(ur+=10);const ue=ur+2,bt=w(vt).groupBy((({policyId:ai})=>ai)).value(),L=vt.reduce(((ai,ni)=>(ai[ni.assetName]=!0,ai)),{}),_=w.reduce(bt,(ai=>ai+1),0),F=w.reduce(L,((ai,ni,ri)=>ai+Math.max(h.Buffer.from(ri,"hex").length,1)),0),k=6+(Ye=12*vt.length+F+28*_,Math.floor((Ye+7)/8));var Ye;const rn=Ze.toNumber()*ue;if(vt.length===0)return new b.default(rn);const ii=Ze.toNumber()*(ur+k);return b.default.max(rn,ii)},a.getAddressFromHex=ce=>{const Ze=ce.toLowerCase().charAt(0),se=Number(ce.toLowerCase().charAt(1));let vt,ur;switch(Ze){case"e":return vt={hash:ce.slice(2).slice(0,56),type:kt.HashType.ADDRESS},new nr.default(se,vt);case"f":return vt={hash:ce.slice(2).slice(0,56),type:kt.HashType.SCRIPT},new nr.default(se,vt);case"7":return ur={hash:ce.slice(2),type:kt.HashType.SCRIPT},new J.default(se,ur);case"6":return ur={hash:ce.slice(2),type:kt.HashType.ADDRESS},new J.default(se,ur);case"5":{ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.SCRIPT};const ue=ce.slice(2).slice(56);return new ve.default(se,ur,ue)}case"4":{ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.ADDRESS};const ue=ce.slice(2).slice(56);return new ve.default(se,ur,ue)}case"3":return ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.SCRIPT},vt={hash:ce.slice(2).slice(56),type:kt.HashType.SCRIPT},new ae.default(se,ur,vt);case"2":return ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.ADDRESS},vt={hash:ce.slice(2).slice(56),type:kt.HashType.SCRIPT},new ae.default(se,ur,vt);case"1":return ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.SCRIPT},vt={hash:ce.slice(2).slice(56),type:kt.HashType.ADDRESS},new ae.default(se,ur,vt);case"0":return ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.ADDRESS},vt={hash:ce.slice(2).slice(56),type:kt.HashType.ADDRESS},new ae.default(se,ur,vt);case"8":return new W.default(h.Buffer.from(ce,"hex"));default:throw new Error("Unsupported address type")}},a.decodeBech32=ce=>{const Ze=E.bech32.decode(ce,114),se=E.bech32.fromWords(Ze.words),vt=h.Buffer.from(se).toString("hex");return{prefix:Ze.prefix,value:vt}},a.getAddressFromBech32=ce=>{try{const Ze=h.Buffer.from(S.default.decode(ce));try{y.Decoder.decode(Ze)}catch{throw new Error("Invalid Byron Address")}return new W.default(Ze)}catch{try{const se=(0,a.decodeBech32)(ce);if(se.prefix==="addr"||se.prefix==="addr_test"||se.prefix==="stake"||se.prefix==="stake_test")return(0,a.getAddressFromHex)(se.value);throw new Error("Invalid Address")}catch{throw new Error("Invalid Address")}}},a.getMaximumTokenSets=ce=>{const Ze=w.cloneDeep(ce),se=[];for(;Ze.length>0;){const vt=[],ur=Ze.length;for(let ue=0;ue<ur;ue+=1){const bt=Ze.pop();bt.amount.lte(B.maxTokenAmount)?vt.push(bt):(vt.push({assetName:bt.assetName,policyId:bt.policyId,amount:new b.default(B.maxTokenAmount)}),bt.amount=bt.amount.minus(B.maxTokenAmount),Ze.push(bt))}se.push(vt)}return se},a.createAuxiliaryDataCbor=ce=>{const Ze=(0,sr.encodeAuxiliaryData)(ce);return y.Encoder.encode(Ze)},a.createPlutusDataCbor=ce=>{const Ze=(0,sr.encodePlutusData)(ce);return y.Encoder.encode(Ze)}},8162:u=>{u.exports=function(a){if(a.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),f=0;f<s.length;f++)s[f]=255;for(var c=0;c<a.length;c++){var d=a.charAt(c),p=d.charCodeAt(0);if(s[p]!==255)throw new TypeError(d+" is ambiguous");s[p]=c}var h=a.length,y=a.charAt(0),b=Math.log(h)/Math.log(256),w=Math.log(256)/Math.log(h);function S(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;for(var B=0,ae=0,W=0;E[B]===y;)ae++,B++;for(var J=(E.length-B)*b+1>>>0,ve=new Uint8Array(J);E[B];){var Qe=s[E.charCodeAt(B)];if(Qe===255)return;for(var kt=0,nr=J-1;(Qe!==0||kt<W)&&nr!==-1;nr--,kt++)Qe+=h*ve[nr]>>>0,ve[nr]=Qe%256>>>0,Qe=Qe/256>>>0;if(Qe!==0)throw new Error("Non-zero carry");W=kt,B++}for(var sr=J-W;sr!==J&&ve[sr]===0;)sr++;for(var ce=new Uint8Array(ae+(J-sr)),Ze=ae;sr!==J;)ce[Ze++]=ve[sr++];return ce}return{encode:function(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var B=0,ae=0,W=0,J=E.length;W!==J&&E[W]===0;)W++,B++;for(var ve=(J-W)*w+1>>>0,Qe=new Uint8Array(ve);W!==J;){for(var kt=E[W],nr=0,sr=ve-1;(kt!==0||nr<ae)&&sr!==-1;sr--,nr++)kt+=256*Qe[sr]>>>0,Qe[sr]=kt%h>>>0,kt=kt/h>>>0;if(kt!==0)throw new Error("Non-zero carry");ae=nr,W++}for(var ce=ve-ae;ce!==ve&&Qe[ce]===0;)ce++;for(var Ze=y.repeat(B);ce<ve;++ce)Ze+=a.charAt(Qe[ce]);return Ze},decodeUnsafe:S,decode:function(E){var B=S(E);if(B)return B;throw new Error("Non-base"+h+" character")}}}},9742:(u,a)=>{a.byteLength=function(w){var S=y(w),E=S[0],B=S[1];return 3*(E+B)/4-B},a.toByteArray=function(w){var S,E,B=y(w),ae=B[0],W=B[1],J=new c((function(kt,nr,sr){return 3*(nr+sr)/4-sr})(0,ae,W)),ve=0,Qe=W>0?ae-4:ae;for(E=0;E<Qe;E+=4)S=f[w.charCodeAt(E)]<<18|f[w.charCodeAt(E+1)]<<12|f[w.charCodeAt(E+2)]<<6|f[w.charCodeAt(E+3)],J[ve++]=S>>16&255,J[ve++]=S>>8&255,J[ve++]=255&S;return W===2&&(S=f[w.charCodeAt(E)]<<2|f[w.charCodeAt(E+1)]>>4,J[ve++]=255&S),W===1&&(S=f[w.charCodeAt(E)]<<10|f[w.charCodeAt(E+1)]<<4|f[w.charCodeAt(E+2)]>>2,J[ve++]=S>>8&255,J[ve++]=255&S),J},a.fromByteArray=function(w){for(var S,E=w.length,B=E%3,ae=[],W=16383,J=0,ve=E-B;J<ve;J+=W)ae.push(b(w,J,J+W>ve?ve:J+W));return B===1?(S=w[E-1],ae.push(s[S>>2]+s[S<<4&63]+"==")):B===2&&(S=(w[E-2]<<8)+w[E-1],ae.push(s[S>>10]+s[S>>4&63]+s[S<<2&63]+"=")),ae.join("")};for(var s=[],f=[],c=typeof Uint8Array<"u"?Uint8Array:Array,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,h=d.length;p<h;++p)s[p]=d[p],f[d.charCodeAt(p)]=p;function y(w){var S=w.length;if(S%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var E=w.indexOf("=");return E===-1&&(E=S),[E,E===S?0:4-E%4]}function b(w,S,E){for(var B,ae,W=[],J=S;J<E;J+=3)B=(w[J]<<16&16711680)+(w[J+1]<<8&65280)+(255&w[J+2]),W.push(s[(ae=B)>>18&63]+s[ae>>12&63]+s[ae>>6&63]+s[63&ae]);return W.join("")}f[45]=62,f[95]=63},7715:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.bech32m=a.bech32=void 0;const s="qpzry9x8gf2tvdw0s3jn54khce6mua7l",f={};for(let S=0;S<s.length;S++){const E=s.charAt(S);f[E]=S}function c(S){const E=S>>25;return(33554431&S)<<5^996825010&-(E>>0&1)^642813549&-(E>>1&1)^513874426&-(E>>2&1)^1027748829&-(E>>3&1)^705979059&-(E>>4&1)}function d(S){let E=1;for(let B=0;B<S.length;++B){const ae=S.charCodeAt(B);if(ae<33||ae>126)return"Invalid prefix ("+S+")";E=c(E)^ae>>5}E=c(E);for(let B=0;B<S.length;++B){const ae=S.charCodeAt(B);E=c(E)^31&ae}return E}function p(S,E,B,ae){let W=0,J=0;const ve=(1<<B)-1,Qe=[];for(let kt=0;kt<S.length;++kt)for(W=W<<E|S[kt],J+=E;J>=B;)J-=B,Qe.push(W>>J&ve);if(ae)J>0&&Qe.push(W<<B-J&ve);else{if(J>=E)return"Excess padding";if(W<<B-J&ve)return"Non-zero padding"}return Qe}function h(S){return p(S,8,5,!0)}function y(S){const E=p(S,5,8,!1);if(Array.isArray(E))return E}function b(S){const E=p(S,5,8,!1);if(Array.isArray(E))return E;throw new Error(E)}function w(S){let E;function B(ae,W){if(W=W||90,ae.length<8)return ae+" too short";if(ae.length>W)return"Exceeds length limit";const J=ae.toLowerCase(),ve=ae.toUpperCase();if(ae!==J&&ae!==ve)return"Mixed-case string "+ae;const Qe=(ae=J).lastIndexOf("1");if(Qe===-1)return"No separator character for "+ae;if(Qe===0)return"Missing prefix for "+ae;const kt=ae.slice(0,Qe),nr=ae.slice(Qe+1);if(nr.length<6)return"Data too short";let sr=d(kt);if(typeof sr=="string")return sr;const ce=[];for(let Ze=0;Ze<nr.length;++Ze){const se=nr.charAt(Ze),vt=f[se];if(vt===void 0)return"Unknown character "+se;sr=c(sr)^vt,Ze+6>=nr.length||ce.push(vt)}return sr!==E?"Invalid checksum for "+ae:{prefix:kt,words:ce}}return E=S==="bech32"?1:734539939,{decodeUnsafe:function(ae,W){const J=B(ae,W);if(typeof J=="object")return J},decode:function(ae,W){const J=B(ae,W);if(typeof J=="object")return J;throw new Error(J)},encode:function(ae,W,J){if(J=J||90,ae.length+7+W.length>J)throw new TypeError("Exceeds length limit");let ve=d(ae=ae.toLowerCase());if(typeof ve=="string")throw new Error(ve);let Qe=ae+"1";for(let kt=0;kt<W.length;++kt){const nr=W[kt];if(nr>>5!=0)throw new Error("Non 5-bit word");ve=c(ve)^nr,Qe+=s.charAt(nr)}for(let kt=0;kt<6;++kt)ve=c(ve);ve^=E;for(let kt=0;kt<6;++kt)Qe+=s.charAt(ve>>5*(5-kt)&31);return Qe},toWords:h,fromWordsUnsafe:y,fromWords:b}}a.bech32=w("bech32"),a.bech32m=w("bech32m")},4431:function(u,a,s){var f;(function(c){var d,p=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,h=Math.ceil,y=Math.floor,b="[BigNumber Error] ",w=b+"Number primitive has more than 15 significant digits: ",S=1e14,E=14,B=9007199254740991,ae=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],W=1e7,J=1e9;function ve(se){var vt=0|se;return se>0||se===vt?vt:vt-1}function Qe(se){for(var vt,ur,ue=1,bt=se.length,L=se[0]+"";ue<bt;){for(vt=se[ue++]+"",ur=E-vt.length;ur--;vt="0"+vt);L+=vt}for(bt=L.length;L.charCodeAt(--bt)===48;);return L.slice(0,bt+1||1)}function kt(se,vt){var ur,ue,bt=se.c,L=vt.c,_=se.s,F=vt.s,k=se.e,Ye=vt.e;if(!_||!F)return null;if(ur=bt&&!bt[0],ue=L&&!L[0],ur||ue)return ur?ue?0:-F:_;if(_!=F)return _;if(ur=_<0,ue=k==Ye,!bt||!L)return ue?0:!bt^ur?1:-1;if(!ue)return k>Ye^ur?1:-1;for(F=(k=bt.length)<(Ye=L.length)?k:Ye,_=0;_<F;_++)if(bt[_]!=L[_])return bt[_]>L[_]^ur?1:-1;return k==Ye?0:k>Ye^ur?1:-1}function nr(se,vt,ur,ue){if(se<vt||se>ur||se!==y(se))throw Error(b+(ue||"Argument")+(typeof se=="number"?se<vt||se>ur?" out of range: ":" not an integer: ":" not a primitive number: ")+String(se))}function sr(se){var vt=se.c.length-1;return ve(se.e/E)==vt&&se.c[vt]%2!=0}function ce(se,vt){return(se.length>1?se.charAt(0)+"."+se.slice(1):se)+(vt<0?"e":"e+")+vt}function Ze(se,vt,ur){var ue,bt;if(vt<0){for(bt=ur+".";++vt;bt+=ur);se=bt+se}else if(++vt>(ue=se.length)){for(bt=ur,vt-=ue;--vt;bt+=ur);se+=bt}else vt<ue&&(se=se.slice(0,vt)+"."+se.slice(vt));return se}d=(function se(vt){var ur,ue,bt,L,_,F,k,Ye,rn,ii,ai=bi.prototype={constructor:bi,toString:null,valueOf:null},ni=new bi(1),ri=20,ui=4,lr=-7,ar=21,jr=-1e7,ci=1e7,mi=!1,pi=1,ei=0,Gr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},ti="0123456789abcdefghijklmnopqrstuvwxyz",fi=!0;function bi(rr,on){var si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi=this;if(!(Hi instanceof bi))return new bi(rr,on);if(on==null){if(rr&&rr._isBigNumber===!0)return Hi.s=rr.s,void(!rr.c||rr.e>ci?Hi.c=Hi.e=null:rr.e<jr?Hi.c=[Hi.e=0]:(Hi.e=rr.e,Hi.c=rr.c.slice()));if((Ii=typeof rr=="number")&&0*rr==0){if(Hi.s=1/rr<0?(rr=-rr,-1):1,rr===~~rr){for(Mi=0,Di=rr;Di>=10;Di/=10,Mi++);return void(Mi>ci?Hi.c=Hi.e=null:(Hi.e=Mi,Hi.c=[rr]))}Vi=String(rr)}else{if(!p.test(Vi=String(rr)))return bt(Hi,Vi,Ii);Hi.s=Vi.charCodeAt(0)==45?(Vi=Vi.slice(1),-1):1}(Mi=Vi.indexOf("."))>-1&&(Vi=Vi.replace(".","")),(Di=Vi.search(/e/i))>0?(Mi<0&&(Mi=Di),Mi+=+Vi.slice(Di+1),Vi=Vi.substring(0,Di)):Mi<0&&(Mi=Vi.length)}else{if(nr(on,2,ti.length,"Base"),on==10&&fi)return vn(Hi=new bi(rr),ri+Hi.e+1,ui);if(Vi=String(rr),Ii=typeof rr=="number"){if(0*rr!=0)return bt(Hi,Vi,Ii,on);if(Hi.s=1/rr<0?(Vi=Vi.slice(1),-1):1,bi.DEBUG&&Vi.replace(/^0\.0*|\./,"").length>15)throw Error(w+rr)}else Hi.s=Vi.charCodeAt(0)===45?(Vi=Vi.slice(1),-1):1;for(si=ti.slice(0,on),Mi=Di=0,Ci=Vi.length;Di<Ci;Di++)if(si.indexOf(vi=Vi.charAt(Di))<0){if(vi=="."){if(Di>Mi){Mi=Ci;continue}}else if(!Ei&&(Vi==Vi.toUpperCase()&&(Vi=Vi.toLowerCase())||Vi==Vi.toLowerCase()&&(Vi=Vi.toUpperCase()))){Ei=!0,Di=-1,Mi=0;continue}return bt(Hi,String(rr),Ii,on)}Ii=!1,(Mi=(Vi=ue(Vi,on,10,Hi.s)).indexOf("."))>-1?Vi=Vi.replace(".",""):Mi=Vi.length}for(Di=0;Vi.charCodeAt(Di)===48;Di++);for(Ci=Vi.length;Vi.charCodeAt(--Ci)===48;);if(Vi=Vi.slice(Di,++Ci)){if(Ci-=Di,Ii&&bi.DEBUG&&Ci>15&&(rr>B||rr!==y(rr)))throw Error(w+Hi.s*rr);if((Mi=Mi-Di-1)>ci)Hi.c=Hi.e=null;else if(Mi<jr)Hi.c=[Hi.e=0];else{if(Hi.e=Mi,Hi.c=[],Di=(Mi+1)%E,Mi<0&&(Di+=E),Di<Ci){for(Di&&Hi.c.push(+Vi.slice(0,Di)),Ci-=E;Di<Ci;)Hi.c.push(+Vi.slice(Di,Di+=E));Di=E-(Vi=Vi.slice(Di)).length}else Di-=Ci;for(;Di--;Vi+="0");Hi.c.push(+Vi)}}else Hi.c=[Hi.e=0]}function Ai(rr,on,si,vi){var Ei,Mi,Di,Ii,Ci;if(si==null?si=ui:nr(si,0,8),!rr.c)return rr.toString();if(Ei=rr.c[0],Di=rr.e,on==null)Ci=Qe(rr.c),Ci=vi==1||vi==2&&(Di<=lr||Di>=ar)?ce(Ci,Di):Ze(Ci,Di,"0");else if(Mi=(rr=vn(new bi(rr),on,si)).e,Ii=(Ci=Qe(rr.c)).length,vi==1||vi==2&&(on<=Mi||Mi<=lr)){for(;Ii<on;Ci+="0",Ii++);Ci=ce(Ci,Mi)}else if(on-=Di,Ci=Ze(Ci,Mi,"0"),Mi+1>Ii){if(--on>0)for(Ci+=".";on--;Ci+="0");}else if((on+=Mi-Ii)>0)for(Mi+1==Ii&&(Ci+=".");on--;Ci+="0");return rr.s<0&&Ei?"-"+Ci:Ci}function Bi(rr,on){for(var si,vi=1,Ei=new bi(rr[0]);vi<rr.length;vi++){if(!(si=new bi(rr[vi])).s){Ei=si;break}on.call(Ei,si)&&(Ei=si)}return Ei}function qi(rr,on,si){for(var vi=1,Ei=on.length;!on[--Ei];on.pop());for(Ei=on[0];Ei>=10;Ei/=10,vi++);return(si=vi+si*E-1)>ci?rr.c=rr.e=null:si<jr?rr.c=[rr.e=0]:(rr.e=si,rr.c=on),rr}function vn(rr,on,si,vi){var Ei,Mi,Di,Ii,Ci,Vi,Hi,Ji=rr.c,no=ae;if(Ji){e:{for(Ei=1,Ii=Ji[0];Ii>=10;Ii/=10,Ei++);if((Mi=on-Ei)<0)Mi+=E,Di=on,Hi=(Ci=Ji[Vi=0])/no[Ei-Di-1]%10|0;else if((Vi=h((Mi+1)/E))>=Ji.length){if(!vi)break e;for(;Ji.length<=Vi;Ji.push(0));Ci=Hi=0,Ei=1,Di=(Mi%=E)-E+1}else{for(Ci=Ii=Ji[Vi],Ei=1;Ii>=10;Ii/=10,Ei++);Hi=(Di=(Mi%=E)-E+Ei)<0?0:Ci/no[Ei-Di-1]%10|0}if(vi=vi||on<0||Ji[Vi+1]!=null||(Di<0?Ci:Ci%no[Ei-Di-1]),vi=si<4?(Hi||vi)&&(si==0||si==(rr.s<0?3:2)):Hi>5||Hi==5&&(si==4||vi||si==6&&(Mi>0?Di>0?Ci/no[Ei-Di]:0:Ji[Vi-1])%10&1||si==(rr.s<0?8:7)),on<1||!Ji[0])return Ji.length=0,vi?(on-=rr.e+1,Ji[0]=no[(E-on%E)%E],rr.e=-on||0):Ji[0]=rr.e=0,rr;if(Mi==0?(Ji.length=Vi,Ii=1,Vi--):(Ji.length=Vi+1,Ii=no[E-Mi],Ji[Vi]=Di>0?y(Ci/no[Ei-Di]%no[Di])*Ii:0),vi)for(;;){if(Vi==0){for(Mi=1,Di=Ji[0];Di>=10;Di/=10,Mi++);for(Di=Ji[0]+=Ii,Ii=1;Di>=10;Di/=10,Ii++);Mi!=Ii&&(rr.e++,Ji[0]==S&&(Ji[0]=1));break}if(Ji[Vi]+=Ii,Ji[Vi]!=S)break;Ji[Vi--]=0,Ii=1}for(Mi=Ji.length;Ji[--Mi]===0;Ji.pop());}rr.e>ci?rr.c=rr.e=null:rr.e<jr&&(rr.c=[rr.e=0])}return rr}function di(rr){var on,si=rr.e;return si===null?rr.toString():(on=Qe(rr.c),on=si<=lr||si>=ar?ce(on,si):Ze(on,si,"0"),rr.s<0?"-"+on:on)}return bi.clone=se,bi.ROUND_UP=0,bi.ROUND_DOWN=1,bi.ROUND_CEIL=2,bi.ROUND_FLOOR=3,bi.ROUND_HALF_UP=4,bi.ROUND_HALF_DOWN=5,bi.ROUND_HALF_EVEN=6,bi.ROUND_HALF_CEIL=7,bi.ROUND_HALF_FLOOR=8,bi.EUCLID=9,bi.config=bi.set=function(rr){var on,si;if(rr!=null){if(typeof rr!="object")throw Error(b+"Object expected: "+rr);if(rr.hasOwnProperty(on="DECIMAL_PLACES")&&(nr(si=rr[on],0,J,on),ri=si),rr.hasOwnProperty(on="ROUNDING_MODE")&&(nr(si=rr[on],0,8,on),ui=si),rr.hasOwnProperty(on="EXPONENTIAL_AT")&&((si=rr[on])&&si.pop?(nr(si[0],-J,0,on),nr(si[1],0,J,on),lr=si[0],ar=si[1]):(nr(si,-J,J,on),lr=-(ar=si<0?-si:si))),rr.hasOwnProperty(on="RANGE"))if((si=rr[on])&&si.pop)nr(si[0],-J,-1,on),nr(si[1],1,J,on),jr=si[0],ci=si[1];else{if(nr(si,-J,J,on),!si)throw Error(b+on+" cannot be zero: "+si);jr=-(ci=si<0?-si:si)}if(rr.hasOwnProperty(on="CRYPTO")){if((si=rr[on])!==!!si)throw Error(b+on+" not true or false: "+si);if(si){if(typeof crypto>"u"||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw mi=!si,Error(b+"crypto unavailable");mi=si}else mi=si}if(rr.hasOwnProperty(on="MODULO_MODE")&&(nr(si=rr[on],0,9,on),pi=si),rr.hasOwnProperty(on="POW_PRECISION")&&(nr(si=rr[on],0,J,on),ei=si),rr.hasOwnProperty(on="FORMAT")){if(typeof(si=rr[on])!="object")throw Error(b+on+" not an object: "+si);Gr=si}if(rr.hasOwnProperty(on="ALPHABET")){if(typeof(si=rr[on])!="string"||/^.?$|[+\-.\s]|(.).*\1/.test(si))throw Error(b+on+" invalid: "+si);fi=si.slice(0,10)=="0123456789",ti=si}}return{DECIMAL_PLACES:ri,ROUNDING_MODE:ui,EXPONENTIAL_AT:[lr,ar],RANGE:[jr,ci],CRYPTO:mi,MODULO_MODE:pi,POW_PRECISION:ei,FORMAT:Gr,ALPHABET:ti}},bi.isBigNumber=function(rr){if(!rr||rr._isBigNumber!==!0)return!1;if(!bi.DEBUG)return!0;var on,si,vi=rr.c,Ei=rr.e,Mi=rr.s;e:if({}.toString.call(vi)=="[object Array]"){if((Mi===1||Mi===-1)&&Ei>=-J&&Ei<=J&&Ei===y(Ei)){if(vi[0]===0){if(Ei===0&&vi.length===1)return!0;break e}if((on=(Ei+1)%E)<1&&(on+=E),String(vi[0]).length==on){for(on=0;on<vi.length;on++)if((si=vi[on])<0||si>=S||si!==y(si))break e;if(si!==0)return!0}}}else if(vi===null&&Ei===null&&(Mi===null||Mi===1||Mi===-1))return!0;throw Error(b+"Invalid BigNumber: "+rr)},bi.maximum=bi.max=function(){return Bi(arguments,ai.lt)},bi.minimum=bi.min=function(){return Bi(arguments,ai.gt)},bi.random=(L=9007199254740992,_=Math.random()*L&2097151?function(){return y(Math.random()*L)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(rr){var on,si,vi,Ei,Mi,Di=0,Ii=[],Ci=new bi(ni);if(rr==null?rr=ri:nr(rr,0,J),Ei=h(rr/E),mi)if(crypto.getRandomValues){for(on=crypto.getRandomValues(new Uint32Array(Ei*=2));Di<Ei;)(Mi=131072*on[Di]+(on[Di+1]>>>11))>=9e15?(si=crypto.getRandomValues(new Uint32Array(2)),on[Di]=si[0],on[Di+1]=si[1]):(Ii.push(Mi%1e14),Di+=2);Di=Ei/2}else{if(!crypto.randomBytes)throw mi=!1,Error(b+"crypto unavailable");for(on=crypto.randomBytes(Ei*=7);Di<Ei;)(Mi=281474976710656*(31&on[Di])+1099511627776*on[Di+1]+4294967296*on[Di+2]+16777216*on[Di+3]+(on[Di+4]<<16)+(on[Di+5]<<8)+on[Di+6])>=9e15?crypto.randomBytes(7).copy(on,Di):(Ii.push(Mi%1e14),Di+=7);Di=Ei/7}if(!mi)for(;Di<Ei;)(Mi=_())<9e15&&(Ii[Di++]=Mi%1e14);for(Ei=Ii[--Di],rr%=E,Ei&&rr&&(Mi=ae[E-rr],Ii[Di]=y(Ei/Mi)*Mi);Ii[Di]===0;Ii.pop(),Di--);if(Di<0)Ii=[vi=0];else{for(vi=-1;Ii[0]===0;Ii.splice(0,1),vi-=E);for(Di=1,Mi=Ii[0];Mi>=10;Mi/=10,Di++);Di<E&&(vi-=E-Di)}return Ci.e=vi,Ci.c=Ii,Ci}),bi.sum=function(){for(var rr=1,on=arguments,si=new bi(on[0]);rr<on.length;)si=si.plus(on[rr++]);return si},ue=(function(){var rr="0123456789";function on(si,vi,Ei,Mi){for(var Di,Ii,Ci=[0],Vi=0,Hi=si.length;Vi<Hi;){for(Ii=Ci.length;Ii--;Ci[Ii]*=vi);for(Ci[0]+=Mi.indexOf(si.charAt(Vi++)),Di=0;Di<Ci.length;Di++)Ci[Di]>Ei-1&&(Ci[Di+1]==null&&(Ci[Di+1]=0),Ci[Di+1]+=Ci[Di]/Ei|0,Ci[Di]%=Ei)}return Ci.reverse()}return function(si,vi,Ei,Mi,Di){var Ii,Ci,Vi,Hi,Ji,no,co,Fo,Io=si.indexOf("."),Ro=ri,Oo=ui;for(Io>=0&&(Hi=ei,ei=0,si=si.replace(".",""),no=(Fo=new bi(vi)).pow(si.length-Io),ei=Hi,Fo.c=on(Ze(Qe(no.c),no.e,"0"),10,Ei,rr),Fo.e=Fo.c.length),Vi=Hi=(co=on(si,vi,Ei,Di?(Ii=ti,rr):(Ii=rr,ti))).length;co[--Hi]==0;co.pop());if(!co[0])return Ii.charAt(0);if(Io<0?--Vi:(no.c=co,no.e=Vi,no.s=Mi,co=(no=ur(no,Fo,Ro,Oo,Ei)).c,Ji=no.r,Vi=no.e),Io=co[Ci=Vi+Ro+1],Hi=Ei/2,Ji=Ji||Ci<0||co[Ci+1]!=null,Ji=Oo<4?(Io!=null||Ji)&&(Oo==0||Oo==(no.s<0?3:2)):Io>Hi||Io==Hi&&(Oo==4||Ji||Oo==6&&1&co[Ci-1]||Oo==(no.s<0?8:7)),Ci<1||!co[0])si=Ji?Ze(Ii.charAt(1),-Ro,Ii.charAt(0)):Ii.charAt(0);else{if(co.length=Ci,Ji)for(--Ei;++co[--Ci]>Ei;)co[Ci]=0,Ci||(++Vi,co=[1].concat(co));for(Hi=co.length;!co[--Hi];);for(Io=0,si="";Io<=Hi;si+=Ii.charAt(co[Io++]));si=Ze(si,Vi,Ii.charAt(0))}return si}})(),ur=(function(){function rr(vi,Ei,Mi){var Di,Ii,Ci,Vi,Hi=0,Ji=vi.length,no=Ei%W,co=Ei/W|0;for(vi=vi.slice();Ji--;)Hi=((Ii=no*(Ci=vi[Ji]%W)+(Di=co*Ci+(Vi=vi[Ji]/W|0)*no)%W*W+Hi)/Mi|0)+(Di/W|0)+co*Vi,vi[Ji]=Ii%Mi;return Hi&&(vi=[Hi].concat(vi)),vi}function on(vi,Ei,Mi,Di){var Ii,Ci;if(Mi!=Di)Ci=Mi>Di?1:-1;else for(Ii=Ci=0;Ii<Mi;Ii++)if(vi[Ii]!=Ei[Ii]){Ci=vi[Ii]>Ei[Ii]?1:-1;break}return Ci}function si(vi,Ei,Mi,Di){for(var Ii=0;Mi--;)vi[Mi]-=Ii,Ii=vi[Mi]<Ei[Mi]?1:0,vi[Mi]=Ii*Di+vi[Mi]-Ei[Mi];for(;!vi[0]&&vi.length>1;vi.splice(0,1));}return function(vi,Ei,Mi,Di,Ii){var Ci,Vi,Hi,Ji,no,co,Fo,Io,Ro,Oo,To,Po,ia,Jo,ea,zi,Gi,uo=vi.s==Ei.s?1:-1,wo=vi.c,xi=Ei.c;if(!(wo&&wo[0]&&xi&&xi[0]))return new bi(vi.s&&Ei.s&&(wo?!xi||wo[0]!=xi[0]:xi)?wo&&wo[0]==0||!xi?0*uo:uo/0:NaN);for(Ro=(Io=new bi(uo)).c=[],uo=Mi+(Vi=vi.e-Ei.e)+1,Ii||(Ii=S,Vi=ve(vi.e/E)-ve(Ei.e/E),uo=uo/E|0),Hi=0;xi[Hi]==(wo[Hi]||0);Hi++);if(xi[Hi]>(wo[Hi]||0)&&Vi--,uo<0)Ro.push(1),Ji=!0;else{for(Jo=wo.length,zi=xi.length,Hi=0,uo+=2,(no=y(Ii/(xi[0]+1)))>1&&(xi=rr(xi,no,Ii),wo=rr(wo,no,Ii),zi=xi.length,Jo=wo.length),ia=zi,To=(Oo=wo.slice(0,zi)).length;To<zi;Oo[To++]=0);Gi=xi.slice(),Gi=[0].concat(Gi),ea=xi[0],xi[1]>=Ii/2&&ea++;do{if(no=0,(Ci=on(xi,Oo,zi,To))<0){if(Po=Oo[0],zi!=To&&(Po=Po*Ii+(Oo[1]||0)),(no=y(Po/ea))>1)for(no>=Ii&&(no=Ii-1),Fo=(co=rr(xi,no,Ii)).length,To=Oo.length;on(co,Oo,Fo,To)==1;)no--,si(co,zi<Fo?Gi:xi,Fo,Ii),Fo=co.length,Ci=1;else no==0&&(Ci=no=1),Fo=(co=xi.slice()).length;if(Fo<To&&(co=[0].concat(co)),si(Oo,co,To,Ii),To=Oo.length,Ci==-1)for(;on(xi,Oo,zi,To)<1;)no++,si(Oo,zi<To?Gi:xi,To,Ii),To=Oo.length}else Ci===0&&(no++,Oo=[0]);Ro[Hi++]=no,Oo[0]?Oo[To++]=wo[ia]||0:(Oo=[wo[ia]],To=1)}while((ia++<Jo||Oo[0]!=null)&&uo--);Ji=Oo[0]!=null,Ro[0]||Ro.splice(0,1)}if(Ii==S){for(Hi=1,uo=Ro[0];uo>=10;uo/=10,Hi++);vn(Io,Mi+(Io.e=Hi+Vi*E-1)+1,Di,Ji)}else Io.e=Vi,Io.r=+Ji;return Io}})(),F=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,Ye=/^\.([^.]+)$/,rn=/^-?(Infinity|NaN)$/,ii=/^\s*\+(?=[\w.])|^\s+|\s+$/g,bt=function(rr,on,si,vi){var Ei,Mi=si?on:on.replace(ii,"");if(rn.test(Mi))rr.s=isNaN(Mi)?null:Mi<0?-1:1;else{if(!si&&(Mi=Mi.replace(F,(function(Di,Ii,Ci){return Ei=(Ci=Ci.toLowerCase())=="x"?16:Ci=="b"?2:8,vi&&vi!=Ei?Di:Ii})),vi&&(Ei=vi,Mi=Mi.replace(k,"$1").replace(Ye,"0.$1")),on!=Mi))return new bi(Mi,Ei);if(bi.DEBUG)throw Error(b+"Not a"+(vi?" base "+vi:"")+" number: "+on);rr.s=null}rr.c=rr.e=null},ai.absoluteValue=ai.abs=function(){var rr=new bi(this);return rr.s<0&&(rr.s=1),rr},ai.comparedTo=function(rr,on){return kt(this,new bi(rr,on))},ai.decimalPlaces=ai.dp=function(rr,on){var si,vi,Ei,Mi=this;if(rr!=null)return nr(rr,0,J),on==null?on=ui:nr(on,0,8),vn(new bi(Mi),rr+Mi.e+1,on);if(!(si=Mi.c))return null;if(vi=((Ei=si.length-1)-ve(this.e/E))*E,Ei=si[Ei])for(;Ei%10==0;Ei/=10,vi--);return vi<0&&(vi=0),vi},ai.dividedBy=ai.div=function(rr,on){return ur(this,new bi(rr,on),ri,ui)},ai.dividedToIntegerBy=ai.idiv=function(rr,on){return ur(this,new bi(rr,on),0,1)},ai.exponentiatedBy=ai.pow=function(rr,on){var si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi=this;if((rr=new bi(rr)).c&&!rr.isInteger())throw Error(b+"Exponent not an integer: "+di(rr));if(on!=null&&(on=new bi(on)),Di=rr.e>14,!Hi.c||!Hi.c[0]||Hi.c[0]==1&&!Hi.e&&Hi.c.length==1||!rr.c||!rr.c[0])return Vi=new bi(Math.pow(+di(Hi),Di?rr.s*(2-sr(rr)):+di(rr))),on?Vi.mod(on):Vi;if(Ii=rr.s<0,on){if(on.c?!on.c[0]:!on.s)return new bi(NaN);(vi=!Ii&&Hi.isInteger()&&on.isInteger())&&(Hi=Hi.mod(on))}else{if(rr.e>9&&(Hi.e>0||Hi.e<-1||(Hi.e==0?Hi.c[0]>1||Di&&Hi.c[1]>=24e7:Hi.c[0]<8e13||Di&&Hi.c[0]<=9999975e7)))return Mi=Hi.s<0&&sr(rr)?-0:0,Hi.e>-1&&(Mi=1/Mi),new bi(Ii?1/Mi:Mi);ei&&(Mi=h(ei/E+2))}for(Di?(si=new bi(.5),Ii&&(rr.s=1),Ci=sr(rr)):Ci=(Ei=Math.abs(+di(rr)))%2,Vi=new bi(ni);;){if(Ci){if(!(Vi=Vi.times(Hi)).c)break;Mi?Vi.c.length>Mi&&(Vi.c.length=Mi):vi&&(Vi=Vi.mod(on))}if(Ei){if((Ei=y(Ei/2))===0)break;Ci=Ei%2}else if(vn(rr=rr.times(si),rr.e+1,1),rr.e>14)Ci=sr(rr);else{if((Ei=+di(rr))==0)break;Ci=Ei%2}Hi=Hi.times(Hi),Mi?Hi.c&&Hi.c.length>Mi&&(Hi.c.length=Mi):vi&&(Hi=Hi.mod(on))}return vi?Vi:(Ii&&(Vi=ni.div(Vi)),on?Vi.mod(on):Mi?vn(Vi,ei,ui,void 0):Vi)},ai.integerValue=function(rr){var on=new bi(this);return rr==null?rr=ui:nr(rr,0,8),vn(on,on.e+1,rr)},ai.isEqualTo=ai.eq=function(rr,on){return kt(this,new bi(rr,on))===0},ai.isFinite=function(){return!!this.c},ai.isGreaterThan=ai.gt=function(rr,on){return kt(this,new bi(rr,on))>0},ai.isGreaterThanOrEqualTo=ai.gte=function(rr,on){return(on=kt(this,new bi(rr,on)))===1||on===0},ai.isInteger=function(){return!!this.c&&ve(this.e/E)>this.c.length-2},ai.isLessThan=ai.lt=function(rr,on){return kt(this,new bi(rr,on))<0},ai.isLessThanOrEqualTo=ai.lte=function(rr,on){return(on=kt(this,new bi(rr,on)))===-1||on===0},ai.isNaN=function(){return!this.s},ai.isNegative=function(){return this.s<0},ai.isPositive=function(){return this.s>0},ai.isZero=function(){return!!this.c&&this.c[0]==0},ai.minus=function(rr,on){var si,vi,Ei,Mi,Di=this,Ii=Di.s;if(on=(rr=new bi(rr,on)).s,!Ii||!on)return new bi(NaN);if(Ii!=on)return rr.s=-on,Di.plus(rr);var Ci=Di.e/E,Vi=rr.e/E,Hi=Di.c,Ji=rr.c;if(!Ci||!Vi){if(!Hi||!Ji)return Hi?(rr.s=-on,rr):new bi(Ji?Di:NaN);if(!Hi[0]||!Ji[0])return Ji[0]?(rr.s=-on,rr):new bi(Hi[0]?Di:ui==3?-0:0)}if(Ci=ve(Ci),Vi=ve(Vi),Hi=Hi.slice(),Ii=Ci-Vi){for((Mi=Ii<0)?(Ii=-Ii,Ei=Hi):(Vi=Ci,Ei=Ji),Ei.reverse(),on=Ii;on--;Ei.push(0));Ei.reverse()}else for(vi=(Mi=(Ii=Hi.length)<(on=Ji.length))?Ii:on,Ii=on=0;on<vi;on++)if(Hi[on]!=Ji[on]){Mi=Hi[on]<Ji[on];break}if(Mi&&(Ei=Hi,Hi=Ji,Ji=Ei,rr.s=-rr.s),(on=(vi=Ji.length)-(si=Hi.length))>0)for(;on--;Hi[si++]=0);for(on=S-1;vi>Ii;){if(Hi[--vi]<Ji[vi]){for(si=vi;si&&!Hi[--si];Hi[si]=on);--Hi[si],Hi[vi]+=S}Hi[vi]-=Ji[vi]}for(;Hi[0]==0;Hi.splice(0,1),--Vi);return Hi[0]?qi(rr,Hi,Vi):(rr.s=ui==3?-1:1,rr.c=[rr.e=0],rr)},ai.modulo=ai.mod=function(rr,on){var si,vi,Ei=this;return rr=new bi(rr,on),!Ei.c||!rr.s||rr.c&&!rr.c[0]?new bi(NaN):!rr.c||Ei.c&&!Ei.c[0]?new bi(Ei):(pi==9?(vi=rr.s,rr.s=1,si=ur(Ei,rr,0,3),rr.s=vi,si.s*=vi):si=ur(Ei,rr,0,pi),(rr=Ei.minus(si.times(rr))).c[0]||pi!=1||(rr.s=Ei.s),rr)},ai.multipliedBy=ai.times=function(rr,on){var si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi,Ji,no,co,Fo,Io,Ro,Oo=this,To=Oo.c,Po=(rr=new bi(rr,on)).c;if(!(To&&Po&&To[0]&&Po[0]))return!Oo.s||!rr.s||To&&!To[0]&&!Po||Po&&!Po[0]&&!To?rr.c=rr.e=rr.s=null:(rr.s*=Oo.s,To&&Po?(rr.c=[0],rr.e=0):rr.c=rr.e=null),rr;for(vi=ve(Oo.e/E)+ve(rr.e/E),rr.s*=Oo.s,(Ci=To.length)<(Ji=Po.length)&&(Fo=To,To=Po,Po=Fo,Ei=Ci,Ci=Ji,Ji=Ei),Ei=Ci+Ji,Fo=[];Ei--;Fo.push(0));for(Io=S,Ro=W,Ei=Ji;--Ei>=0;){for(si=0,no=Po[Ei]%Ro,co=Po[Ei]/Ro|0,Mi=Ei+(Di=Ci);Mi>Ei;)si=((Vi=no*(Vi=To[--Di]%Ro)+(Ii=co*Vi+(Hi=To[Di]/Ro|0)*no)%Ro*Ro+Fo[Mi]+si)/Io|0)+(Ii/Ro|0)+co*Hi,Fo[Mi--]=Vi%Io;Fo[Mi]=si}return si?++vi:Fo.splice(0,1),qi(rr,Fo,vi)},ai.negated=function(){var rr=new bi(this);return rr.s=-rr.s||null,rr},ai.plus=function(rr,on){var si,vi=this,Ei=vi.s;if(on=(rr=new bi(rr,on)).s,!Ei||!on)return new bi(NaN);if(Ei!=on)return rr.s=-on,vi.minus(rr);var Mi=vi.e/E,Di=rr.e/E,Ii=vi.c,Ci=rr.c;if(!Mi||!Di){if(!Ii||!Ci)return new bi(Ei/0);if(!Ii[0]||!Ci[0])return Ci[0]?rr:new bi(Ii[0]?vi:0*Ei)}if(Mi=ve(Mi),Di=ve(Di),Ii=Ii.slice(),Ei=Mi-Di){for(Ei>0?(Di=Mi,si=Ci):(Ei=-Ei,si=Ii),si.reverse();Ei--;si.push(0));si.reverse()}for((Ei=Ii.length)-(on=Ci.length)<0&&(si=Ci,Ci=Ii,Ii=si,on=Ei),Ei=0;on;)Ei=(Ii[--on]=Ii[on]+Ci[on]+Ei)/S|0,Ii[on]=S===Ii[on]?0:Ii[on]%S;return Ei&&(Ii=[Ei].concat(Ii),++Di),qi(rr,Ii,Di)},ai.precision=ai.sd=function(rr,on){var si,vi,Ei,Mi=this;if(rr!=null&&rr!==!!rr)return nr(rr,1,J),on==null?on=ui:nr(on,0,8),vn(new bi(Mi),rr,on);if(!(si=Mi.c))return null;if(vi=(Ei=si.length-1)*E+1,Ei=si[Ei]){for(;Ei%10==0;Ei/=10,vi--);for(Ei=si[0];Ei>=10;Ei/=10,vi++);}return rr&&Mi.e+1>vi&&(vi=Mi.e+1),vi},ai.shiftedBy=function(rr){return nr(rr,-9007199254740991,B),this.times("1e"+rr)},ai.squareRoot=ai.sqrt=function(){var rr,on,si,vi,Ei,Mi=this,Di=Mi.c,Ii=Mi.s,Ci=Mi.e,Vi=ri+4,Hi=new bi("0.5");if(Ii!==1||!Di||!Di[0])return new bi(!Ii||Ii<0&&(!Di||Di[0])?NaN:Di?Mi:1/0);if((Ii=Math.sqrt(+di(Mi)))==0||Ii==1/0?(((on=Qe(Di)).length+Ci)%2==0&&(on+="0"),Ii=Math.sqrt(+on),Ci=ve((Ci+1)/2)-(Ci<0||Ci%2),si=new bi(on=Ii==1/0?"5e"+Ci:(on=Ii.toExponential()).slice(0,on.indexOf("e")+1)+Ci)):si=new bi(Ii+""),si.c[0]){for((Ii=(Ci=si.e)+Vi)<3&&(Ii=0);;)if(Ei=si,si=Hi.times(Ei.plus(ur(Mi,Ei,Vi,1))),Qe(Ei.c).slice(0,Ii)===(on=Qe(si.c)).slice(0,Ii)){if(si.e<Ci&&--Ii,(on=on.slice(Ii-3,Ii+1))!="9999"&&(vi||on!="4999")){+on&&(+on.slice(1)||on.charAt(0)!="5")||(vn(si,si.e+ri+2,1),rr=!si.times(si).eq(Mi));break}if(!vi&&(vn(Ei,Ei.e+ri+2,0),Ei.times(Ei).eq(Mi))){si=Ei;break}Vi+=4,Ii+=4,vi=1}}return vn(si,si.e+ri+1,ui,rr)},ai.toExponential=function(rr,on){return rr!=null&&(nr(rr,0,J),rr++),Ai(this,rr,on,1)},ai.toFixed=function(rr,on){return rr!=null&&(nr(rr,0,J),rr=rr+this.e+1),Ai(this,rr,on)},ai.toFormat=function(rr,on,si){var vi,Ei=this;if(si==null)rr!=null&&on&&typeof on=="object"?(si=on,on=null):rr&&typeof rr=="object"?(si=rr,rr=on=null):si=Gr;else if(typeof si!="object")throw Error(b+"Argument not an object: "+si);if(vi=Ei.toFixed(rr,on),Ei.c){var Mi,Di=vi.split("."),Ii=+si.groupSize,Ci=+si.secondaryGroupSize,Vi=si.groupSeparator||"",Hi=Di[0],Ji=Di[1],no=Ei.s<0,co=no?Hi.slice(1):Hi,Fo=co.length;if(Ci&&(Mi=Ii,Ii=Ci,Ci=Mi,Fo-=Mi),Ii>0&&Fo>0){for(Mi=Fo%Ii||Ii,Hi=co.substr(0,Mi);Mi<Fo;Mi+=Ii)Hi+=Vi+co.substr(Mi,Ii);Ci>0&&(Hi+=Vi+co.slice(Mi)),no&&(Hi="-"+Hi)}vi=Ji?Hi+(si.decimalSeparator||"")+((Ci=+si.fractionGroupSize)?Ji.replace(new RegExp("\\d{"+Ci+"}\\B","g"),"$&"+(si.fractionGroupSeparator||"")):Ji):Hi}return(si.prefix||"")+vi+(si.suffix||"")},ai.toFraction=function(rr){var on,si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi,Ji,no,co=this,Fo=co.c;if(rr!=null&&(!(Ii=new bi(rr)).isInteger()&&(Ii.c||Ii.s!==1)||Ii.lt(ni)))throw Error(b+"Argument "+(Ii.isInteger()?"out of range: ":"not an integer: ")+di(Ii));if(!Fo)return new bi(co);for(on=new bi(ni),Vi=si=new bi(ni),vi=Ci=new bi(ni),no=Qe(Fo),Mi=on.e=no.length-co.e-1,on.c[0]=ae[(Di=Mi%E)<0?E+Di:Di],rr=!rr||Ii.comparedTo(on)>0?Mi>0?on:Vi:Ii,Di=ci,ci=1/0,Ii=new bi(no),Ci.c[0]=0;Hi=ur(Ii,on,0,1),(Ei=si.plus(Hi.times(vi))).comparedTo(rr)!=1;)si=vi,vi=Ei,Vi=Ci.plus(Hi.times(Ei=Vi)),Ci=Ei,on=Ii.minus(Hi.times(Ei=on)),Ii=Ei;return Ei=ur(rr.minus(si),vi,0,1),Ci=Ci.plus(Ei.times(Vi)),si=si.plus(Ei.times(vi)),Ci.s=Vi.s=co.s,Ji=ur(Vi,vi,Mi*=2,ui).minus(co).abs().comparedTo(ur(Ci,si,Mi,ui).minus(co).abs())<1?[Vi,vi]:[Ci,si],ci=Di,Ji},ai.toNumber=function(){return+di(this)},ai.toPrecision=function(rr,on){return rr!=null&&nr(rr,1,J),Ai(this,rr,on,2)},ai.toString=function(rr){var on,si=this,vi=si.s,Ei=si.e;return Ei===null?vi?(on="Infinity",vi<0&&(on="-"+on)):on="NaN":(rr==null?on=Ei<=lr||Ei>=ar?ce(Qe(si.c),Ei):Ze(Qe(si.c),Ei,"0"):rr===10&&fi?on=Ze(Qe((si=vn(new bi(si),ri+Ei+1,ui)).c),si.e,"0"):(nr(rr,2,ti.length,"Base"),on=ue(Ze(Qe(si.c),Ei,"0"),10,rr,vi,!0)),vi<0&&si.c[0]&&(on="-"+on)),on},ai.valueOf=ai.toJSON=function(){return di(this)},ai._isBigNumber=!0,vt!=null&&bi.set(vt),bi})(),d.default=d.BigNumber=d,(f=(function(){return d}).call(a,s,a,u))===void 0||(u.exports=f)})()},8442:(u,a,s)=>{const f=s(9488);function c(Qe,kt,nr){const sr=Qe[kt]+Qe[nr];let ce=Qe[kt+1]+Qe[nr+1];sr>=4294967296&&ce++,Qe[kt]=sr,Qe[kt+1]=ce}function d(Qe,kt,nr,sr){let ce=Qe[kt]+nr;nr<0&&(ce+=4294967296);let Ze=Qe[kt+1]+sr;ce>=4294967296&&Ze++,Qe[kt]=ce,Qe[kt+1]=Ze}function p(Qe,kt){return Qe[kt]^Qe[kt+1]<<8^Qe[kt+2]<<16^Qe[kt+3]<<24}function h(Qe,kt,nr,sr,ce,Ze){const se=S[ce],vt=S[ce+1],ur=S[Ze],ue=S[Ze+1];c(w,Qe,kt),d(w,Qe,se,vt);let bt=w[sr]^w[Qe],L=w[sr+1]^w[Qe+1];w[sr]=L,w[sr+1]=bt,c(w,nr,sr),bt=w[kt]^w[nr],L=w[kt+1]^w[nr+1],w[kt]=bt>>>24^L<<8,w[kt+1]=L>>>24^bt<<8,c(w,Qe,kt),d(w,Qe,ur,ue),bt=w[sr]^w[Qe],L=w[sr+1]^w[Qe+1],w[sr]=bt>>>16^L<<16,w[sr+1]=L>>>16^bt<<16,c(w,nr,sr),bt=w[kt]^w[nr],L=w[kt+1]^w[nr+1],w[kt]=L>>>31^bt<<1,w[kt+1]=bt>>>31^L<<1}const y=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),b=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(Qe){return 2*Qe}))),w=new Uint32Array(32),S=new Uint32Array(32);function E(Qe,kt){let nr=0;for(nr=0;nr<16;nr++)w[nr]=Qe.h[nr],w[nr+16]=y[nr];for(w[24]=w[24]^Qe.t,w[25]=w[25]^Qe.t/4294967296,kt&&(w[28]=~w[28],w[29]=~w[29]),nr=0;nr<32;nr++)S[nr]=p(Qe.b,4*nr);for(nr=0;nr<12;nr++)h(0,8,16,24,b[16*nr+0],b[16*nr+1]),h(2,10,18,26,b[16*nr+2],b[16*nr+3]),h(4,12,20,28,b[16*nr+4],b[16*nr+5]),h(6,14,22,30,b[16*nr+6],b[16*nr+7]),h(0,10,20,30,b[16*nr+8],b[16*nr+9]),h(2,12,22,24,b[16*nr+10],b[16*nr+11]),h(4,14,16,26,b[16*nr+12],b[16*nr+13]),h(6,8,18,28,b[16*nr+14],b[16*nr+15]);for(nr=0;nr<16;nr++)Qe.h[nr]=Qe.h[nr]^w[nr]^w[nr+16]}const B=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function ae(Qe,kt,nr,sr){if(Qe===0||Qe>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(kt&&kt.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(nr&&nr.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(sr&&sr.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const ce={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:Qe};B.fill(0),B[0]=Qe,kt&&(B[1]=kt.length),B[2]=1,B[3]=1,nr&&B.set(nr,32),sr&&B.set(sr,48);for(let Ze=0;Ze<16;Ze++)ce.h[Ze]=y[Ze]^p(B,4*Ze);return kt&&(W(ce,kt),ce.c=128),ce}function W(Qe,kt){for(let nr=0;nr<kt.length;nr++)Qe.c===128&&(Qe.t+=Qe.c,E(Qe,!1),Qe.c=0),Qe.b[Qe.c++]=kt[nr]}function J(Qe){for(Qe.t+=Qe.c;Qe.c<128;)Qe.b[Qe.c++]=0;E(Qe,!0);const kt=new Uint8Array(Qe.outlen);for(let nr=0;nr<Qe.outlen;nr++)kt[nr]=Qe.h[nr>>2]>>8*(3&nr);return kt}function ve(Qe,kt,nr,sr,ce){nr=nr||64,Qe=f.normalizeInput(Qe),sr&&(sr=f.normalizeInput(sr)),ce&&(ce=f.normalizeInput(ce));const Ze=ae(nr,kt,sr,ce);return W(Ze,Qe),J(Ze)}u.exports={blake2b:ve,blake2bHex:function(Qe,kt,nr,sr,ce){const Ze=ve(Qe,kt,nr,sr,ce);return f.toHex(Ze)},blake2bInit:ae,blake2bUpdate:W,blake2bFinal:J}},5297:(u,a,s)=>{const f=s(9488);function c(J,ve){return J[ve]^J[ve+1]<<8^J[ve+2]<<16^J[ve+3]<<24}function d(J,ve,Qe,kt,nr,sr){b[J]=b[J]+b[ve]+nr,b[kt]=p(b[kt]^b[J],16),b[Qe]=b[Qe]+b[kt],b[ve]=p(b[ve]^b[Qe],12),b[J]=b[J]+b[ve]+sr,b[kt]=p(b[kt]^b[J],8),b[Qe]=b[Qe]+b[kt],b[ve]=p(b[ve]^b[Qe],7)}function p(J,ve){return J>>>ve^J<<32-ve}const h=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),y=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),b=new Uint32Array(16),w=new Uint32Array(16);function S(J,ve){let Qe=0;for(Qe=0;Qe<8;Qe++)b[Qe]=J.h[Qe],b[Qe+8]=h[Qe];for(b[12]^=J.t,b[13]^=J.t/4294967296,ve&&(b[14]=~b[14]),Qe=0;Qe<16;Qe++)w[Qe]=c(J.b,4*Qe);for(Qe=0;Qe<10;Qe++)d(0,4,8,12,w[y[16*Qe+0]],w[y[16*Qe+1]]),d(1,5,9,13,w[y[16*Qe+2]],w[y[16*Qe+3]]),d(2,6,10,14,w[y[16*Qe+4]],w[y[16*Qe+5]]),d(3,7,11,15,w[y[16*Qe+6]],w[y[16*Qe+7]]),d(0,5,10,15,w[y[16*Qe+8]],w[y[16*Qe+9]]),d(1,6,11,12,w[y[16*Qe+10]],w[y[16*Qe+11]]),d(2,7,8,13,w[y[16*Qe+12]],w[y[16*Qe+13]]),d(3,4,9,14,w[y[16*Qe+14]],w[y[16*Qe+15]]);for(Qe=0;Qe<8;Qe++)J.h[Qe]^=b[Qe]^b[Qe+8]}function E(J,ve){if(!(J>0&&J<=32))throw new Error("Incorrect output length, should be in [1, 32]");const Qe=ve?ve.length:0;if(ve&&!(Qe>0&&Qe<=32))throw new Error("Incorrect key length, should be in [1, 32]");const kt={h:new Uint32Array(h),b:new Uint8Array(64),c:0,t:0,outlen:J};return kt.h[0]^=16842752^Qe<<8^J,Qe>0&&(B(kt,ve),kt.c=64),kt}function B(J,ve){for(let Qe=0;Qe<ve.length;Qe++)J.c===64&&(J.t+=J.c,S(J,!1),J.c=0),J.b[J.c++]=ve[Qe]}function ae(J){for(J.t+=J.c;J.c<64;)J.b[J.c++]=0;S(J,!0);const ve=new Uint8Array(J.outlen);for(let Qe=0;Qe<J.outlen;Qe++)ve[Qe]=J.h[Qe>>2]>>8*(3&Qe)&255;return ve}function W(J,ve,Qe){Qe=Qe||32,J=f.normalizeInput(J);const kt=E(Qe,ve);return B(kt,J),ae(kt)}u.exports={blake2s:W,blake2sHex:function(J,ve,Qe){const kt=W(J,ve,Qe);return f.toHex(kt)},blake2sInit:E,blake2sUpdate:B,blake2sFinal:ae}},1191:(u,a,s)=>{const f=s(8442),c=s(5297);u.exports={blake2b:f.blake2b,blake2bHex:f.blake2bHex,blake2bInit:f.blake2bInit,blake2bUpdate:f.blake2bUpdate,blake2bFinal:f.blake2bFinal,blake2s:c.blake2s,blake2sHex:c.blake2sHex,blake2sInit:c.blake2sInit,blake2sUpdate:c.blake2sUpdate,blake2sFinal:c.blake2sFinal}},9488:u=>{function a(s){return(4294967296+s).toString(16).substring(1)}u.exports={normalizeInput:function(s){let f;if(s instanceof Uint8Array)f=s;else{if(typeof s!="string")throw new Error("Input must be an string, Buffer or Uint8Array");f=new TextEncoder().encode(s)}return f},toHex:function(s){return Array.prototype.map.call(s,(function(f){return(f<16?"0":"")+f.toString(16)})).join("")},debugPrint:function(s,f,c){let d=`
147
+ `,r:"\r",t:" "},f,c=function(B){throw{name:"SyntaxError",message:B,at:u,text:f}},d=function(B){return B&&B!==a&&c("Expected '"+B+"' instead of '"+a+"'"),a=f.charAt(u),u+=1,a},p=function(){var B,ae="";for(a==="-"&&(ae="-",d("-"));a>="0"&&a<="9";)ae+=a,d();if(a===".")for(ae+=".";d()&&a>="0"&&a<="9";)ae+=a;if(a==="e"||a==="E")for(ae+=a,d(),(a==="-"||a==="+")&&(ae+=a,d());a>="0"&&a<="9";)ae+=a,d();if(B=+ae,!isFinite(B))c("Bad number");else return e==null&&(e=requireBignumber()),ae.length>15?i.storeAsString?ae:i.useNativeBigInt?BigInt(ae):new e(ae):i.alwaysParseAsBig?i.useNativeBigInt?BigInt(B):new e(B):B},h=function(){var B,ae,W="",J;if(a==='"')for(var ve=u;d();){if(a==='"')return u-1>ve&&(W+=f.substring(ve,u-1)),d(),W;if(a==="\\"){if(u-1>ve&&(W+=f.substring(ve,u-1)),d(),a==="u"){for(J=0,ae=0;ae<4&&(B=parseInt(d(),16),!!isFinite(B));ae+=1)J=J*16+B;W+=String.fromCharCode(J)}else if(typeof s[a]=="string")W+=s[a];else break;ve=u}}c("Bad string")},y=function(){for(;a&&a<=" ";)d()},b=function(){switch(a){case"t":return d("t"),d("r"),d("u"),d("e"),!0;case"f":return d("f"),d("a"),d("l"),d("s"),d("e"),!1;case"n":return d("n"),d("u"),d("l"),d("l"),null}c("Unexpected '"+a+"'")},w,S=function(){var B=[];if(a==="["){if(d("["),y(),a==="]")return d("]"),B;for(;a;){if(B.push(w()),y(),a==="]")return d("]"),B;d(","),y()}}c("Bad array")},E=function(){var B,ae=Object.create(null);if(a==="{"){if(d("{"),y(),a==="}")return d("}"),ae;for(;a;){if(B=h(),y(),d(":"),i.strict===!0&&Object.hasOwnProperty.call(ae,B)&&c('Duplicate key "'+B+'"'),t.test(B)===!0?i.protoAction==="error"?c("Object contains forbidden prototype property"):i.protoAction==="ignore"?w():ae[B]=w():r.test(B)===!0?i.constructorAction==="error"?c("Object contains forbidden constructor property"):i.constructorAction==="ignore"?w():ae[B]=w():ae[B]=w(),y(),a==="}")return d("}"),ae;d(","),y()}}c("Bad object")};return w=function(){switch(y(),a){case"{":return E();case"[":return S();case'"':return h();case"-":return p();default:return a>="0"&&a<="9"?p():b()}},function(B,ae){var W;return f=B+"",u=0,a=" ",W=w(),y(),a&&c("Syntax error"),typeof ae=="function"?(function J(ve,Qe){var kt,nr=ve[Qe];return nr&&typeof nr=="object"&&Object.keys(nr).forEach(function(sr){kt=J(nr,sr),kt!==void 0?nr[sr]=kt:delete nr[sr]}),ae.call(ve,Qe,nr)})({"":W},""):W}};return parse=n,parse}var hasRequiredJsonBigint;function requireJsonBigint(){if(hasRequiredJsonBigint)return jsonBigint.exports;hasRequiredJsonBigint=1;var e=requireStringify().stringify,t=requireParse();return jsonBigint.exports=function(r){return{parse:t(r),stringify:e}},jsonBigint.exports.parse=t(),jsonBigint.exports.stringify=e,jsonBigint.exports}var jsonBigintExports=requireJsonBigint();const JSONbigWithoutConfig=getDefaultExportFromCjs(jsonBigintExports);var IntDecoding;(function(e){e.UNSAFE="unsafe",e.SAFE="safe",e.MIXED="mixed",e.BIGINT="bigint"})(IntDecoding||(IntDecoding={}));JSONbigWithoutConfig({useNativeBigInt:!0,strict:!0});function arrayEqual(e,t){return e.length!==t.length?!1:Array.from(e).every((r,n)=>r===t[n])}function concatArrays(...e){const t=e.reduce((o,i)=>o+i.length,0),r=new Uint8Array(t);let n=0;for(let o=0;o<e.length;o++)r.set(e[o],n),n+=e[o].length;return r}function isNode(){return typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node<"u"}function ensureSafeInteger(e){if(typeof e>"u")throw new Error("Value is undefined");if(typeof e=="bigint"){if(e>BigInt(Number.MAX_SAFE_INTEGER)||e<BigInt(Number.MIN_SAFE_INTEGER))throw new Error(`BigInt value ${e} is not a safe integer`);return Number(e)}if(typeof e=="number"){if(Number.isSafeInteger(e))return e;throw new Error(`Value ${e} is not a safe integer`)}throw new Error(`Unexpected type ${typeof e}, ${e}`)}function ensureSafeUnsignedInteger(e){const t=ensureSafeInteger(e);if(t<0)throw new Error(`Value ${t} is negative`);return t}function ensureBigInt(e){if(typeof e>"u")throw new Error("Value is undefined");if(typeof e=="bigint")return e;if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`Value ${e} is not a safe integer`);return BigInt(e)}throw new Error(`Unexpected type ${typeof e}, ${e}`)}function ensureUint64(e){const t=ensureBigInt(e);if(t<0||t>BigInt("0xffffffffffffffff"))throw new Error(`Value ${t} is not a uint64`);return t}function genericHash(e){return sha512.sha512_256.array(e)}function isValidSignatureLength(e){return e===nacl.sign.signatureLength}function keyPairFromSecretKey(e){return nacl.sign.keyPair.fromSecretKey(e)}function sign(e,t){return nacl.sign.detached(e,t)}function verify(e,t,r){return nacl.sign.detached.verify(e,t,r)}const PUBLIC_KEY_LENGTH=nacl.sign.publicKeyLength;nacl.sign.secretKeyLength;const HASH_BYTES_LENGTH=32;function base64ToBytes(e){if(isNode())return new Uint8Array(bufferExports.Buffer.from(e,"base64"));const t=atob(e);return Uint8Array.from(t,r=>r.codePointAt(0))}function bytesToBase64(e){if(isNode())return bufferExports.Buffer.from(e).toString("base64");const t=Array.from(e,r=>String.fromCodePoint(r)).join("");return btoa(t)}function bytesToString(e){return new TextDecoder().decode(e)}function coerceToBytes(e){return typeof e=="string"?new TextEncoder().encode(e):e}function bytesToHex(e){return isNode()?bufferExports.Buffer.from(e).toString("hex"):Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}const ALGORAND_ADDRESS_BYTE_LENGTH=36,ALGORAND_CHECKSUM_BYTE_LENGTH=4,ALGORAND_ADDRESS_LENGTH=58,MALFORMED_ADDRESS_ERROR_MSG="address seems to be malformed",CHECKSUM_ADDRESS_ERROR_MSG="wrong checksum for address";function checksumFromPublicKey(e){return Uint8Array.from(genericHash(e).slice(HASH_BYTES_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH,HASH_BYTES_LENGTH))}class Address{constructor(t){if(!(t instanceof Uint8Array))throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: ${t} is not Uint8Array, type ${typeof t}`);if(t.length!==ALGORAND_ADDRESS_BYTE_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH)throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: 0x${bytesToHex(t)}, length ${t.length}`);this.publicKey=t}equals(t){return t instanceof Address&&arrayEqual(this.publicKey,t.publicKey)}checksum(){return checksumFromPublicKey(this.publicKey)}toString(){return base32.encode(concatArrays(this.publicKey,this.checksum())).slice(0,ALGORAND_ADDRESS_LENGTH)}static fromString(t){if(typeof t!="string")throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected string, got ${typeof t}, ${t}`);if(t.length!==ALGORAND_ADDRESS_LENGTH)throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected length ${ALGORAND_ADDRESS_LENGTH}, got ${t.length}: ${t}`);const r=base32.decode.asBytes(t);if(r.length!==ALGORAND_ADDRESS_BYTE_LENGTH)throw new Error(`${MALFORMED_ADDRESS_ERROR_MSG}: expected byte length ${ALGORAND_ADDRESS_BYTE_LENGTH}, got ${r.length}`);const n=new Uint8Array(r.slice(0,ALGORAND_ADDRESS_BYTE_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH)),o=new Uint8Array(r.slice(PUBLIC_KEY_LENGTH,ALGORAND_ADDRESS_BYTE_LENGTH)),i=checksumFromPublicKey(n);if(!arrayEqual(i,o))throw new Error(CHECKSUM_ADDRESS_ERROR_MSG);return new Address(n)}static zeroAddress(){return new Address(new Uint8Array(ALGORAND_ADDRESS_BYTE_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH))}}function isValidAddress(e){try{Address.fromString(e)}catch{return!1}return!0}new TextEncoder().encode("appID");function utf8Count(e){for(var t=e.length,r=0,n=0;n<t;){var o=e.charCodeAt(n++);if((o&4294967168)===0){r++;continue}else if((o&4294965248)===0)r+=2;else{if(o>=55296&&o<=56319&&n<t){var i=e.charCodeAt(n);(i&64512)===56320&&(++n,o=((o&1023)<<10)+(i&1023)+65536)}(o&4294901760)===0?r+=3:r+=4}}return r}function utf8EncodeJs(e,t,r){for(var n=e.length,o=r,i=0;i<n;){var u=e.charCodeAt(i++);if((u&4294967168)===0){t[o++]=u;continue}else if((u&4294965248)===0)t[o++]=u>>6&31|192;else{if(u>=55296&&u<=56319&&i<n){var a=e.charCodeAt(i);(a&64512)===56320&&(++i,u=((u&1023)<<10)+(a&1023)+65536)}(u&4294901760)===0?(t[o++]=u>>12&15|224,t[o++]=u>>6&63|128):(t[o++]=u>>18&7|240,t[o++]=u>>12&63|128,t[o++]=u>>6&63|128)}t[o++]=u&63|128}}var sharedTextEncoder=new TextEncoder,TEXT_ENCODER_THRESHOLD=50;function utf8EncodeTE(e,t,r){sharedTextEncoder.encodeInto(e,t.subarray(r))}function utf8Encode(e,t,r){e.length>TEXT_ENCODER_THRESHOLD?utf8EncodeTE(e,t,r):utf8EncodeJs(e,t,r)}var CHUNK_SIZE=4096;function utf8DecodeJs(e,t,r){for(var n=t,o=n+r,i=[],u="";n<o;){var a=e[n++];if((a&128)===0)i.push(a);else if((a&224)===192){var s=e[n++]&63;i.push((a&31)<<6|s)}else if((a&240)===224){var s=e[n++]&63,f=e[n++]&63;i.push((a&31)<<12|s<<6|f)}else if((a&248)===240){var s=e[n++]&63,f=e[n++]&63,c=e[n++]&63,d=(a&7)<<18|s<<12|f<<6|c;d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d)}else i.push(a);i.length>=CHUNK_SIZE&&(u+=String.fromCharCode.apply(String,i),i.length=0)}return i.length>0&&(u+=String.fromCharCode.apply(String,i)),u}var sharedTextDecoder=new TextDecoder,TEXT_DECODER_THRESHOLD=200;function utf8DecodeTD(e,t,r){var n=e.subarray(t,t+r);return sharedTextDecoder.decode(n)}function utf8Decode(e,t,r){return r>TEXT_DECODER_THRESHOLD?utf8DecodeTD(e,t,r):utf8DecodeJs(e,t,r)}var ExtData=(function(){function e(t,r){this.type=t,this.data=r}return e})(),__extends=(function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})(),DecodeError=(function(e){__extends(t,e);function t(r){var n=e.call(this,r)||this,o=Object.create(t.prototype);return Object.setPrototypeOf(n,o),Object.defineProperty(n,"name",{configurable:!0,enumerable:!1,value:t.name}),n}return t})(Error),IntMode;(function(e){e[e.UNSAFE_NUMBER=0]="UNSAFE_NUMBER",e[e.SAFE_NUMBER=1]="SAFE_NUMBER",e[e.AS_ENCODED=2]="AS_ENCODED",e[e.MIXED=3]="MIXED",e[e.BIGINT=4]="BIGINT"})(IntMode||(IntMode={}));var UINT32_MAX=4294967295;function setUint64(e,t,r){var n=r/4294967296,o=r;e.setUint32(t,n),e.setUint32(t+4,o)}function setInt64(e,t,r){var n=Math.floor(r/4294967296),o=r;e.setUint32(t,n),e.setUint32(t+4,o)}function getInt64(e,t,r){if(r===IntMode.UNSAFE_NUMBER||r===IntMode.SAFE_NUMBER){var n=e.getInt32(t),o=e.getUint32(t+4);if(r===IntMode.SAFE_NUMBER&&(n<Math.floor(Number.MIN_SAFE_INTEGER/4294967296)||n===Math.floor(Number.MIN_SAFE_INTEGER/4294967296)&&o===0||n>(Number.MAX_SAFE_INTEGER-o)/4294967296)){var i="".concat(n<0?"-":"","0x").concat(Math.abs(n).toString(16)).concat(o.toString(16).padStart(8,"0"));throw new Error("Mode is IntMode.SAFE_NUMBER and value is not a safe integer: ".concat(i))}return n*4294967296+o}var u=e.getBigInt64(t);return r===IntMode.MIXED&&u>=Number.MIN_SAFE_INTEGER&&u<=Number.MAX_SAFE_INTEGER?Number(u):u}function getUint64(e,t,r){if(r===IntMode.UNSAFE_NUMBER||r===IntMode.SAFE_NUMBER){var n=e.getUint32(t),o=e.getUint32(t+4);if(r===IntMode.SAFE_NUMBER&&n>(Number.MAX_SAFE_INTEGER-o)/4294967296){var i="0x".concat(n.toString(16)).concat(o.toString(16).padStart(8,"0"));throw new Error("Mode is IntMode.SAFE_NUMBER and value is not a safe integer: ".concat(i))}return n*4294967296+o}var u=e.getBigUint64(t);return r===IntMode.MIXED&&u<=Number.MAX_SAFE_INTEGER?Number(u):u}function convertSafeIntegerToMode(e,t){return t===IntMode.BIGINT?BigInt(e):Number(e)}var EXT_TIMESTAMP=-1,TIMESTAMP32_MAX_SEC=4294967296-1,TIMESTAMP64_MAX_SEC=17179869184-1;function encodeTimeSpecToTimestamp(e){var t=e.sec,r=e.nsec;if(t>=0&&r>=0&&t<=TIMESTAMP64_MAX_SEC)if(r===0&&t<=TIMESTAMP32_MAX_SEC){var n=new Uint8Array(4),o=new DataView(n.buffer);return o.setUint32(0,t),n}else{var i=t/4294967296,u=t&4294967295,n=new Uint8Array(8),o=new DataView(n.buffer);return o.setUint32(0,r<<2|i&3),o.setUint32(4,u),n}else{var n=new Uint8Array(12),o=new DataView(n.buffer);return o.setUint32(0,r),setInt64(o,4,t),n}}function encodeDateToTimeSpec(e){var t=e.getTime(),r=Math.floor(t/1e3),n=(t-r*1e3)*1e6,o=Math.floor(n/1e9);return{sec:r+o,nsec:n-o*1e9}}function encodeTimestampExtension(e){if(e instanceof Date){var t=encodeDateToTimeSpec(e);return encodeTimeSpecToTimestamp(t)}else return null}function decodeTimestampToTimeSpec(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:{var r=t.getUint32(0),n=0;return{sec:r,nsec:n}}case 8:{var o=t.getUint32(0),i=t.getUint32(4),r=(o&3)*4294967296+i,n=o>>>2;return{sec:r,nsec:n}}case 12:{var r=getInt64(t,4,IntMode.UNSAFE_NUMBER),n=t.getUint32(0);return{sec:r,nsec:n}}default:throw new DecodeError("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}function decodeTimestampExtension(e){var t=decodeTimestampToTimeSpec(e);return new Date(t.sec*1e3+t.nsec/1e6)}var timestampExtension={type:EXT_TIMESTAMP,encode:encodeTimestampExtension,decode:decodeTimestampExtension},ExtensionCodec=(function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(timestampExtension)}return e.prototype.register=function(t){var r=t.type,n=t.encode,o=t.decode;if(r>=0)this.encoders[r]=n,this.decoders[r]=o;else{var i=1+r;this.builtInEncoders[i]=n,this.builtInDecoders[i]=o}},e.prototype.tryToEncode=function(t,r){for(var n=0;n<this.builtInEncoders.length;n++){var o=this.builtInEncoders[n];if(o!=null){var i=o(t,r);if(i!=null){var u=-1-n;return new ExtData(u,i)}}}for(var n=0;n<this.encoders.length;n++){var o=this.encoders[n];if(o!=null){var i=o(t,r);if(i!=null){var u=n;return new ExtData(u,i)}}}return t instanceof ExtData?t:null},e.prototype.decode=function(t,r,n){var o=r<0?this.builtInDecoders[-1-r]:this.decoders[r];return o?o(t,r,n):new ExtData(r,t)},e.defaultCodec=new e,e})();function ensureUint8Array$1(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}function createDataView(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=ensureUint8Array$1(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}function compareUint8Arrays(e,t){for(var r=Math.min(e.length,t.length),n=0;n<r;n++){var o=e[n]-t[n];if(o!==0)return o}return e.length-t.length}var RawBinaryString=(function(){function e(t){if(this.rawBinaryValue=t,!ArrayBuffer.isView(t))throw new TypeError("RawBinaryString: rawBinaryValue must be an ArrayBufferView")}return e})(),DEFAULT_MAX_DEPTH=100,DEFAULT_INITIAL_BUFFER_SIZE=2048,Encoder=(function(){function e(t){var r,n,o,i,u,a,s,f;this.extensionCodec=(r=t?.extensionCodec)!==null&&r!==void 0?r:ExtensionCodec.defaultCodec,this.context=t?.context,this.forceBigIntToInt64=(n=t?.forceBigIntToInt64)!==null&&n!==void 0?n:!1,this.maxDepth=(o=t?.maxDepth)!==null&&o!==void 0?o:DEFAULT_MAX_DEPTH,this.initialBufferSize=(i=t?.initialBufferSize)!==null&&i!==void 0?i:DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=(u=t?.sortKeys)!==null&&u!==void 0?u:!1,this.forceFloat32=(a=t?.forceFloat32)!==null&&a!==void 0?a:!1,this.ignoreUndefined=(s=t?.ignoreUndefined)!==null&&s!==void 0?s:!1,this.forceIntegerToFloat=(f=t?.forceIntegerToFloat)!==null&&f!==void 0?f:!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}return e.prototype.reinitializeState=function(){this.pos=0},e.prototype.encodeSharedRef=function(t){return this.reinitializeState(),this.doEncode(t,1),this.bytes.subarray(0,this.pos)},e.prototype.encode=function(t){return this.reinitializeState(),this.doEncode(t,1),this.bytes.slice(0,this.pos)},e.prototype.doEncode=function(t,r){if(r>this.maxDepth)throw new Error("Too deep objects in depth ".concat(r));t==null?this.encodeNil():typeof t=="boolean"?this.encodeBoolean(t):typeof t=="number"?this.encodeNumber(t):typeof t=="string"?this.encodeString(t):this.encodeObject(t,r)},e.prototype.ensureBufferSizeToWrite=function(t){var r=this.pos+t;this.view.byteLength<r&&this.resizeBuffer(r*2)},e.prototype.resizeBuffer=function(t){var r=new ArrayBuffer(t),n=new Uint8Array(r),o=new DataView(r);n.set(this.bytes),this.view=o,this.bytes=n},e.prototype.encodeNil=function(){this.writeU8(192)},e.prototype.encodeBoolean=function(t){t===!1?this.writeU8(194):this.writeU8(195)},e.prototype.encodeNumber=function(t){!this.forceIntegerToFloat&&Number.isSafeInteger(t)?t>=0?t<128?this.writeU8(t):t<256?(this.writeU8(204),this.writeU8(t)):t<65536?(this.writeU8(205),this.writeU16(t)):t<4294967296?(this.writeU8(206),this.writeU32(t)):(this.writeU8(207),this.writeU64(t)):t>=-32?this.writeU8(224|t+32):t>=-128?(this.writeU8(208),this.writeI8(t)):t>=-32768?(this.writeU8(209),this.writeI16(t)):t>=-2147483648?(this.writeU8(210),this.writeI32(t)):(this.writeU8(211),this.writeI64(t)):this.encodeNumberAsFloat(t)},e.prototype.encodeNumberAsFloat=function(t){this.forceFloat32?(this.writeU8(202),this.writeF32(t)):(this.writeU8(203),this.writeF64(t))},e.prototype.encodeBigInt=function(t){if(this.forceBigIntToInt64)this.encodeBigIntAsInt64(t);else if(t>=0)if(t<4294967296||this.forceIntegerToFloat)this.encodeNumber(Number(t));else if(t<BigInt("0x10000000000000000"))this.encodeBigIntAsInt64(t);else throw new Error("Bigint is too large for uint64: ".concat(t));else if(t>=-2147483648||this.forceIntegerToFloat)this.encodeNumber(Number(t));else if(t>=BigInt(-1)*BigInt("0x8000000000000000"))this.encodeBigIntAsInt64(t);else throw new Error("Bigint is too small for int64: ".concat(t))},e.prototype.encodeBigIntAsInt64=function(t){t>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(t)):(this.writeU8(211),this.writeBigInt64(t))},e.prototype.writeStringHeader=function(t){if(t<32)this.writeU8(160+t);else if(t<256)this.writeU8(217),this.writeU8(t);else if(t<65536)this.writeU8(218),this.writeU16(t);else if(t<4294967296)this.writeU8(219),this.writeU32(t);else throw new Error("Too long string: ".concat(t," bytes in UTF-8"))},e.prototype.encodeString=function(t){var r=5,n=utf8Count(t);this.ensureBufferSizeToWrite(r+n),this.writeStringHeader(n),utf8Encode(t,this.bytes,this.pos),this.pos+=n},e.prototype.encodeObject=function(t,r){var n=this.extensionCodec.tryToEncode(t,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(t))this.encodeArray(t,r);else if(ArrayBuffer.isView(t))this.encodeBinary(t);else if(t instanceof RawBinaryString)this.encodeBinaryAsString(t);else if(typeof t=="bigint")this.encodeBigInt(t);else if(t instanceof Map)this.encodeMap(t,r);else if(typeof t=="object")this.encodeMapObject(t,r);else throw new Error("Unrecognized object: ".concat(Object.prototype.toString.apply(t)))},e.prototype.encodeBinary=function(t){var r=t.byteLength;if(r<256)this.writeU8(196),this.writeU8(r);else if(r<65536)this.writeU8(197),this.writeU16(r);else if(r<4294967296)this.writeU8(198),this.writeU32(r);else throw new Error("Too large binary: ".concat(r));var n=ensureUint8Array$1(t);this.writeU8a(n)},e.prototype.encodeBinaryAsString=function(t){var r=t.rawBinaryValue;this.writeStringHeader(r.byteLength);var n=ensureUint8Array$1(r);this.writeU8a(n)},e.prototype.encodeArray=function(t,r){var n=t.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error("Too large array: ".concat(n));for(var o=0,i=t;o<i.length;o++){var u=i[o];this.doEncode(u,r+1)}},e.prototype.countWithoutUndefined=function(t,r){for(var n=0,o=0,i=r;o<i.length;o++){var u=i[o];t.get(u)!==void 0&&n++}return n},e.prototype.sortMapKeys=function(t){for(var r=[],n=[],o=[],i=[],u=0,a=t;u<a.length;u++){var s=a[u];if(typeof s=="number"){if(isNaN(s))throw new Error("Cannot sort map keys with NaN value");r.push(s)}else if(typeof s=="bigint")r.push(s);else if(typeof s=="string")n.push(s);else if(ArrayBuffer.isView(s))i.push(ensureUint8Array$1(s));else if(s instanceof RawBinaryString)o.push(s);else throw new Error("Unsupported map key type: ".concat(Object.prototype.toString.apply(s)))}return r.sort(function(f,c){return f<c?-1:f>c?1:0}),n.sort(),o.sort(function(f,c){return compareUint8Arrays(ensureUint8Array$1(f.rawBinaryValue),ensureUint8Array$1(c.rawBinaryValue))}),i.sort(compareUint8Arrays),[].concat(r,n,o,i)},e.prototype.encodeMapObject=function(t,r){this.encodeMap(new Map(Object.entries(t)),r)},e.prototype.encodeMap=function(t,r){var n=Array.from(t.keys());this.sortKeys&&(n=this.sortMapKeys(n));var o=this.ignoreUndefined?this.countWithoutUndefined(t,n):n.length;if(o<16)this.writeU8(128+o);else if(o<65536)this.writeU8(222),this.writeU16(o);else if(o<4294967296)this.writeU8(223),this.writeU32(o);else throw new Error("Too large map object: ".concat(o));for(var i=0,u=n;i<u.length;i++){var a=u[i],s=t.get(a);if(!(this.ignoreUndefined&&s===void 0)){if(typeof a=="string")this.encodeString(a);else if(typeof a=="number")this.encodeNumber(a);else if(typeof a=="bigint")this.encodeBigInt(a);else if(ArrayBuffer.isView(a))this.encodeBinary(a);else if(a instanceof RawBinaryString)this.encodeBinaryAsString(a);else throw new Error("Unsupported map key type: ".concat(Object.prototype.toString.apply(a)));this.doEncode(s,r+1)}}},e.prototype.encodeExtension=function(t){var r=t.data.length;if(r===1)this.writeU8(212);else if(r===2)this.writeU8(213);else if(r===4)this.writeU8(214);else if(r===8)this.writeU8(215);else if(r===16)this.writeU8(216);else if(r<256)this.writeU8(199),this.writeU8(r);else if(r<65536)this.writeU8(200),this.writeU16(r);else if(r<4294967296)this.writeU8(201),this.writeU32(r);else throw new Error("Too large extension object: ".concat(r));this.writeI8(t.type),this.writeU8a(t.data)},e.prototype.writeU8=function(t){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,t),this.pos++},e.prototype.writeU8a=function(t){var r=t.length;this.ensureBufferSizeToWrite(r),this.bytes.set(t,this.pos),this.pos+=r},e.prototype.writeI8=function(t){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,t),this.pos++},e.prototype.writeU16=function(t){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,t),this.pos+=2},e.prototype.writeI16=function(t){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,t),this.pos+=2},e.prototype.writeU32=function(t){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,t),this.pos+=4},e.prototype.writeI32=function(t){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,t),this.pos+=4},e.prototype.writeF32=function(t){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,t),this.pos+=4},e.prototype.writeF64=function(t){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,t),this.pos+=8},e.prototype.writeU64=function(t){this.ensureBufferSizeToWrite(8),setUint64(this.view,this.pos,t),this.pos+=8},e.prototype.writeI64=function(t){this.ensureBufferSizeToWrite(8),setInt64(this.view,this.pos,t),this.pos+=8},e.prototype.writeBigUint64=function(t){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,t),this.pos+=8},e.prototype.writeBigInt64=function(t){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,t),this.pos+=8},e})();function encode(e,t){var r=new Encoder(t);return r.encodeSharedRef(e)}function prettyByte(e){return"".concat(e<0?"-":"","0x").concat(Math.abs(e).toString(16).padStart(2,"0"))}var DEFAULT_MAX_KEY_LENGTH=16,DEFAULT_MAX_LENGTH_PER_KEY=16,CachedKeyDecoder=(function(){function e(t,r){t===void 0&&(t=DEFAULT_MAX_KEY_LENGTH),r===void 0&&(r=DEFAULT_MAX_LENGTH_PER_KEY),this.maxKeyLength=t,this.maxLengthPerKey=r,this.hit=0,this.miss=0,this.caches=[];for(var n=0;n<this.maxKeyLength;n++)this.caches.push([])}return e.prototype.canBeCached=function(t){return t>0&&t<=this.maxKeyLength},e.prototype.find=function(t,r,n){var o=this.caches[n-1];e:for(var i=0,u=o;i<u.length;i++){for(var a=u[i],s=a.bytes,f=0;f<n;f++)if(s[f]!==t[r+f])continue e;return a.str}return null},e.prototype.store=function(t,r){var n=this.caches[t.length-1],o={bytes:t,str:r};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=o:n.push(o)},e.prototype.decode=function(t,r,n){var o=this.find(t,r,n);if(o!=null)return this.hit++,o;this.miss++;var i=utf8DecodeJs(t,r,n),u=Uint8Array.prototype.slice.call(t,r,r+n);return this.store(u,i),i},e})(),__awaiter=function(e,t,r,n){function o(i){return i instanceof r?i:new r(function(u){u(i)})}return new(r||(r=Promise))(function(i,u){function a(c){try{f(n.next(c))}catch(d){u(d)}}function s(c){try{f(n.throw(c))}catch(d){u(d)}}function f(c){c.done?i(c.value):o(c.value).then(a,s)}f((n=n.apply(e,t||[])).next())})},__generator=function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(f){return function(c){return s([f,c])}}function s(f){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,f[0]&&(r=0)),r;)try{if(n=1,o&&(i=f[0]&2?o.return:f[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,f[1])).done)return i;switch(o=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,o=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){r.label=f[1];break}if(f[0]===6&&r.label<i[1]){r.label=i[1],i=f;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(f);break}i[2]&&r.ops.pop(),r.trys.pop();continue}f=t.call(e,r)}catch(c){f=[6,c],o=0}finally{n=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}},__asyncValues=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof __values=="function"?__values(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=e[i]&&function(u){return new Promise(function(a,s){u=e[i](u),o(a,s,u.done,u.value)})}}function o(i,u,a,s){Promise.resolve(s).then(function(f){i({value:f,done:a})},u)}},__await=function(e){return this instanceof __await?(this.v=e,this):new __await(e)},__asyncGenerator=function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,i=[];return o={},u("next"),u("throw"),u("return"),o[Symbol.asyncIterator]=function(){return this},o;function u(p){n[p]&&(o[p]=function(h){return new Promise(function(y,b){i.push([p,h,y,b])>1||a(p,h)})})}function a(p,h){try{s(n[p](h))}catch(y){d(i[0][3],y)}}function s(p){p.value instanceof __await?Promise.resolve(p.value.v).then(f,c):d(i[0][2],p)}function f(p){a("next",p)}function c(p){a("throw",p)}function d(p,h){p(h),i.shift(),i.length&&a(i[0][0],i[0][1])}},STATE_ARRAY="array",STATE_MAP_KEY="map_key",STATE_MAP_VALUE="map_value";function isValidMapKeyType(e,t,r){return t?typeof e=="string"||typeof e=="number"||typeof e=="bigint"||e instanceof Uint8Array||e instanceof RawBinaryString:typeof e=="string"||r&&typeof e=="number"}var StackPool=(function(){function e(t){this.useMap=t,this.stack=[],this.stackHeadPosition=-1}return Object.defineProperty(e.prototype,"length",{get:function(){return this.stackHeadPosition+1},enumerable:!1,configurable:!0}),e.prototype.top=function(){return this.stack[this.stackHeadPosition]},e.prototype.pushArrayState=function(t){var r=this.getUninitializedStateFromPool();r.type=STATE_ARRAY,r.position=0,r.size=t,r.array=new Array(t)},e.prototype.pushMapState=function(t){var r=this.getUninitializedStateFromPool();r.type=STATE_MAP_KEY,r.readCount=0,r.size=t,r.map=this.useMap?new Map:{}},e.prototype.getUninitializedStateFromPool=function(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){var t={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(t)}return this.stack[this.stackHeadPosition]},e.prototype.release=function(t){var r=this.stack[this.stackHeadPosition];if(r!==t)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(t.type===STATE_ARRAY){var n=t;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(t.type===STATE_MAP_KEY||t.type===STATE_MAP_VALUE){var n=t;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--},e.prototype.reset=function(){this.stack.length=0,this.stackHeadPosition=-1},e})(),HEAD_BYTE_REQUIRED=-1,EMPTY_VIEW=new DataView(new ArrayBuffer(0)),EMPTY_BYTES=new Uint8Array(EMPTY_VIEW.buffer);try{EMPTY_VIEW.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var DataViewIndexOutOfBoundsError=RangeError,MORE_DATA=new DataViewIndexOutOfBoundsError("Insufficient data"),sharedCachedKeyDecoder=new CachedKeyDecoder,Decoder=(function(){function e(t){var r,n,o,i,u,a,s,f,c,d,p,h;if(this.totalPos=0,this.pos=0,this.view=EMPTY_VIEW,this.bytes=EMPTY_BYTES,this.headByte=HEAD_BYTE_REQUIRED,this.extensionCodec=(r=t?.extensionCodec)!==null&&r!==void 0?r:ExtensionCodec.defaultCodec,this.context=t?.context,this.intMode=(n=t?.intMode)!==null&&n!==void 0?n:t?.useBigInt64?IntMode.AS_ENCODED:IntMode.UNSAFE_NUMBER,this.rawBinaryStringValues=(o=t?.rawBinaryStringValues)!==null&&o!==void 0?o:!1,this.rawBinaryStringKeys=(i=t?.rawBinaryStringKeys)!==null&&i!==void 0?i:!1,this.useRawBinaryStringClass=(u=t?.useRawBinaryStringClass)!==null&&u!==void 0?u:!1,this.useMap=(a=t?.useMap)!==null&&a!==void 0?a:!1,this.supportObjectNumberKeys=(s=t?.supportObjectNumberKeys)!==null&&s!==void 0?s:!1,this.maxStrLength=(f=t?.maxStrLength)!==null&&f!==void 0?f:UINT32_MAX,this.maxBinLength=(c=t?.maxBinLength)!==null&&c!==void 0?c:UINT32_MAX,this.maxArrayLength=(d=t?.maxArrayLength)!==null&&d!==void 0?d:UINT32_MAX,this.maxMapLength=(p=t?.maxMapLength)!==null&&p!==void 0?p:UINT32_MAX,this.maxExtLength=(h=t?.maxExtLength)!==null&&h!==void 0?h:UINT32_MAX,this.keyDecoder=t?.keyDecoder!==void 0?t.keyDecoder:sharedCachedKeyDecoder,this.rawBinaryStringKeys&&!this.useMap)throw new Error("rawBinaryStringKeys is only supported when useMap is true");this.stack=new StackPool(this.useMap)}return e.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=HEAD_BYTE_REQUIRED,this.stack.reset()},e.prototype.setBuffer=function(t){this.bytes=ensureUint8Array$1(t),this.view=createDataView(this.bytes),this.pos=0},e.prototype.appendBuffer=function(t){if(this.headByte===HEAD_BYTE_REQUIRED&&!this.hasRemaining(1))this.setBuffer(t);else{var r=this.bytes.subarray(this.pos),n=ensureUint8Array$1(t),o=new Uint8Array(r.length+n.length);o.set(r),o.set(n,r.length),this.setBuffer(o)}},e.prototype.hasRemaining=function(t){return this.view.byteLength-this.pos>=t},e.prototype.createExtraByteError=function(t){var r=this,n=r.view,o=r.pos;return new RangeError("Extra ".concat(n.byteLength-o," of ").concat(n.byteLength," byte(s) found at buffer[").concat(t,"]"))},e.prototype.decode=function(t){this.reinitializeState(),this.setBuffer(t);var r=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return r},e.prototype.decodeMulti=function(t){return __generator(this,function(r){switch(r.label){case 0:this.reinitializeState(),this.setBuffer(t),r.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return r.sent(),[3,1];case 3:return[2]}})},e.prototype.decodeAsync=function(t){var r,n,o,i,u,a,s;return __awaiter(this,void 0,void 0,function(){var f,c,d,p,h,y,b,w;return __generator(this,function(S){switch(S.label){case 0:f=!1,S.label=1;case 1:S.trys.push([1,6,7,12]),r=!0,n=__asyncValues(t),S.label=2;case 2:return[4,n.next()];case 3:if(o=S.sent(),i=o.done,!!i)return[3,5];if(s=o.value,r=!1,d=s,f)throw this.createExtraByteError(this.totalPos);this.appendBuffer(d);try{c=this.doDecodeSync(),f=!0}catch(E){if(!(E instanceof DataViewIndexOutOfBoundsError))throw E}this.totalPos+=this.pos,S.label=4;case 4:return r=!0,[3,2];case 5:return[3,12];case 6:return p=S.sent(),u={error:p},[3,12];case 7:return S.trys.push([7,,10,11]),!r&&!i&&(a=n.return)?[4,a.call(n)]:[3,9];case 8:S.sent(),S.label=9;case 9:return[3,11];case 10:if(u)throw u.error;return[7];case 11:return[7];case 12:if(f){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,c]}throw h=this,y=h.headByte,b=h.pos,w=h.totalPos,new RangeError("Insufficient data in parsing ".concat(prettyByte(y)," at ").concat(w," (").concat(b," in the current buffer)"))}})})},e.prototype.decodeArrayStream=function(t){return this.decodeMultiAsync(t,!0)},e.prototype.decodeStream=function(t){return this.decodeMultiAsync(t,!1)},e.prototype.decodeMultiAsync=function(t,r){return __asyncGenerator(this,arguments,function(){var o,i,u,a,s,f,c,d,p,h,y,b;return __generator(this,function(w){switch(w.label){case 0:o=r,i=-1,w.label=1;case 1:w.trys.push([1,13,14,19]),u=!0,a=__asyncValues(t),w.label=2;case 2:return[4,__await(a.next())];case 3:if(s=w.sent(),p=s.done,!!p)return[3,12];if(b=s.value,u=!1,f=b,r&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(f),o&&(i=this.readArraySize(),o=!1,this.complete()),w.label=4;case 4:w.trys.push([4,9,,10]),w.label=5;case 5:return[4,__await(this.doDecodeSync())];case 6:return[4,w.sent()];case 7:return w.sent(),--i===0?[3,8]:[3,5];case 8:return[3,10];case 9:if(c=w.sent(),!(c instanceof DataViewIndexOutOfBoundsError))throw c;return[3,10];case 10:this.totalPos+=this.pos,w.label=11;case 11:return u=!0,[3,2];case 12:return[3,19];case 13:return d=w.sent(),h={error:d},[3,19];case 14:return w.trys.push([14,,17,18]),!u&&!p&&(y=a.return)?[4,__await(y.call(a))]:[3,16];case 15:w.sent(),w.label=16;case 16:return[3,18];case 17:if(h)throw h.error;return[7];case 18:return[7];case 19:return[2]}})})},e.prototype.doDecodeSync=function(){e:for(;;){var t=this.readHeadByte(),r=void 0;if(t>=224)r=this.convertNumber(t-256);else if(t<192)if(t<128)r=this.convertNumber(t);else if(t<144){var n=t-128;if(n!==0){this.pushMapState(n),this.complete();continue e}else r=this.useMap?new Map:{}}else if(t<160){var n=t-144;if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else{var o=t-160;r=this.decodeString(o,0)}else if(t===192)r=null;else if(t===194)r=!1;else if(t===195)r=!0;else if(t===202)r=this.readF32();else if(t===203)r=this.readF64();else if(t===204)r=this.convertNumber(this.readU8());else if(t===205)r=this.convertNumber(this.readU16());else if(t===206)r=this.convertNumber(this.readU32());else if(t===207)r=this.readU64();else if(t===208)r=this.convertNumber(this.readI8());else if(t===209)r=this.convertNumber(this.readI16());else if(t===210)r=this.convertNumber(this.readI32());else if(t===211)r=this.readI64();else if(t===217){var o=this.lookU8();r=this.decodeString(o,1)}else if(t===218){var o=this.lookU16();r=this.decodeString(o,2)}else if(t===219){var o=this.lookU32();r=this.decodeString(o,4)}else if(t===220){var n=this.readU16();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(t===221){var n=this.readU32();if(n!==0){this.pushArrayState(n),this.complete();continue e}else r=[]}else if(t===222){var n=this.readU16();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(t===223){var n=this.readU32();if(n!==0){this.pushMapState(n),this.complete();continue e}else r={}}else if(t===196){var n=this.lookU8();r=this.decodeBinary(n,1)}else if(t===197){var n=this.lookU16();r=this.decodeBinary(n,2)}else if(t===198){var n=this.lookU32();r=this.decodeBinary(n,4)}else if(t===212)r=this.decodeExtension(1,0);else if(t===213)r=this.decodeExtension(2,0);else if(t===214)r=this.decodeExtension(4,0);else if(t===215)r=this.decodeExtension(8,0);else if(t===216)r=this.decodeExtension(16,0);else if(t===199){var n=this.lookU8();r=this.decodeExtension(n,1)}else if(t===200){var n=this.lookU16();r=this.decodeExtension(n,2)}else if(t===201){var n=this.lookU32();r=this.decodeExtension(n,4)}else throw new DecodeError("Unrecognized type byte: ".concat(prettyByte(t)));this.complete();for(var i=this.stack;i.length>0;){var u=i.top();if(u.type===STATE_ARRAY)if(u.array[u.position]=r,u.position++,u.position===u.size)r=u.array,i.release(u);else continue e;else if(u.type===STATE_MAP_KEY){if(!isValidMapKeyType(r,this.useMap,this.supportObjectNumberKeys)){var a=this.useMap?"string, number, bigint, or Uint8Array":this.supportObjectNumberKeys?"string or number":"string";throw new DecodeError("The type of key must be ".concat(a," but got ").concat(typeof r))}if(!this.useMap&&r==="__proto__")throw new DecodeError("The key __proto__ is not allowed");u.key=r,u.type=STATE_MAP_VALUE;continue e}else if(this.useMap?u.map.set(u.key,r):u.map[u.key]=r,u.readCount++,u.readCount===u.size)r=u.map,i.release(u);else{u.key=null,u.type=STATE_MAP_KEY;continue e}}return r}},e.prototype.readHeadByte=function(){return this.headByte===HEAD_BYTE_REQUIRED&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=HEAD_BYTE_REQUIRED},e.prototype.readArraySize=function(){var t=this.readHeadByte();switch(t){case 220:return this.readU16();case 221:return this.readU32();default:{if(t<160)return t-144;throw new DecodeError("Unrecognized array type byte: ".concat(prettyByte(t)))}}},e.prototype.pushMapState=function(t){if(t>this.maxMapLength)throw new DecodeError("Max length exceeded: map length (".concat(t,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.pushMapState(t)},e.prototype.pushArrayState=function(t){if(t>this.maxArrayLength)throw new DecodeError("Max length exceeded: array length (".concat(t,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.pushArrayState(t)},e.prototype.decodeString=function(t,r){if(this.stateIsMapKey()?this.rawBinaryStringKeys:this.rawBinaryStringValues){var n=this.decodeBinary(t,r);return this.useRawBinaryStringClass?new RawBinaryString(n):n}return this.decodeUtf8String(t,r)},e.prototype.decodeUtf8String=function(t,r){var n;if(t>this.maxStrLength)throw new DecodeError("Max length exceeded: UTF-8 byte length (".concat(t,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength<this.pos+r+t)throw MORE_DATA;var o=this.pos+r,i;return this.stateIsMapKey()&&(!((n=this.keyDecoder)===null||n===void 0)&&n.canBeCached(t))?i=this.keyDecoder.decode(this.bytes,o,t):i=utf8Decode(this.bytes,o,t),this.pos+=r+t,i},e.prototype.stateIsMapKey=function(){if(this.stack.length>0){var t=this.stack.top();return t.type===STATE_MAP_KEY}return!1},e.prototype.decodeBinary=function(t,r){if(t>this.maxBinLength)throw new DecodeError("Max length exceeded: bin length (".concat(t,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(t+r))throw MORE_DATA;var n=this.pos+r,o=this.bytes.subarray(n,n+t);return this.pos+=r+t,o},e.prototype.decodeExtension=function(t,r){if(t>this.maxExtLength)throw new DecodeError("Max length exceeded: ext length (".concat(t,") > maxExtLength (").concat(this.maxExtLength,")"));var n=this.view.getInt8(this.pos+r),o=this.decodeBinary(t,r+1);return this.extensionCodec.decode(o,n,this.context)},e.prototype.convertNumber=function(t){return convertSafeIntegerToMode(t,this.intMode)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var t=this.view.getUint8(this.pos);return this.pos++,t},e.prototype.readI8=function(){var t=this.view.getInt8(this.pos);return this.pos++,t},e.prototype.readU16=function(){var t=this.view.getUint16(this.pos);return this.pos+=2,t},e.prototype.readI16=function(){var t=this.view.getInt16(this.pos);return this.pos+=2,t},e.prototype.readU32=function(){var t=this.view.getUint32(this.pos);return this.pos+=4,t},e.prototype.readI32=function(){var t=this.view.getInt32(this.pos);return this.pos+=4,t},e.prototype.readU64=function(){var t=getUint64(this.view,this.pos,this.intMode);return this.pos+=8,t},e.prototype.readI64=function(){var t=getInt64(this.view,this.pos,this.intMode);return this.pos+=8,t},e.prototype.readF32=function(){var t=this.view.getFloat32(this.pos);return this.pos+=4,t},e.prototype.readF64=function(){var t=this.view.getFloat64(this.pos);return this.pos+=8,t},e})();function decode(e,t){var r=new Decoder(t);return r.decode(e)}function msgpackRawEncode(e){return encode(e,{sortKeys:!0})}function msgpackRawDecodeAsMap(e,t){const r={intMode:IntMode.BIGINT,useMap:!0};return decode(e,r)}function msgpackRawDecodeAsMapWithRawStrings(e,t){const r={intMode:IntMode.BIGINT,useMap:!0,rawBinaryStringKeys:!0,rawBinaryStringValues:!0,useRawBinaryStringClass:!0};return decode(e,r)}function msgpackEncodingDataToJSONEncodingData(e){if(e==null)return e;if(e instanceof Uint8Array)return bytesToBase64(e);if(Array.isArray(e))return e.map(msgpackEncodingDataToJSONEncodingData);if(e instanceof Map){const t={};for(const[r,n]of e){if(typeof r!="string")throw new Error(`JSON map key must be a string: ${r}`);t[r]=msgpackEncodingDataToJSONEncodingData(n)}return t}return e}function jsonEncodingDataToMsgpackEncodingData(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="bigint"||typeof e=="boolean")return e;if(Array.isArray(e))return e.map(jsonEncodingDataToMsgpackEncodingData);if(typeof e=="object"){const t=new Map;for(const[r,n]of Object.entries(e))t.set(r,jsonEncodingDataToMsgpackEncodingData(n));return t}throw new Error(`Invalid JSON encoding data: ${e}`)}var MsgpackObjectPathSegmentKind;(function(e){e[e.MAP_VALUE=0]="MAP_VALUE",e[e.ARRAY_ELEMENT=1]="ARRAY_ELEMENT"})(MsgpackObjectPathSegmentKind||(MsgpackObjectPathSegmentKind={}));class MsgpackRawStringProvider{constructor({parent:t,segment:r,baseObjectBytes:n}){this.resolvedCache=null,this.resolvedCachePresent=!1,this.parent=t,this.segment=r,this.baseObjectBytes=n}withMapValue(t){return new MsgpackRawStringProvider({parent:this,segment:{kind:MsgpackObjectPathSegmentKind.MAP_VALUE,key:t}})}withArrayElement(t){return new MsgpackRawStringProvider({parent:this,segment:{kind:MsgpackObjectPathSegmentKind.ARRAY_ELEMENT,key:t}})}getRawStringAtCurrentLocation(){const t=this.resolve();if(t instanceof RawBinaryString)return t.rawBinaryValue;throw new Error(`Invalid type. Expected RawBinaryString, got ${t} (${typeof t})`)}getRawStringKeysAndValuesAtCurrentLocation(){const t=this.resolve();if(!(t instanceof Map))throw new Error(`Invalid type. Expected Map, got ${t} (${typeof t})`);const r=new Map;for(const[n,o]of t)if(n instanceof RawBinaryString)r.set(n.rawBinaryValue,o);else throw new Error(`Invalid type for map key. Expected RawBinaryString, got ${n} (${typeof n})`);return r}resolve(){if(this.resolvedCachePresent)return this.resolvedCache;let t;if(this.parent?t=this.parent.resolve():t=msgpackRawDecodeAsMapWithRawStrings(this.baseObjectBytes),!this.segment)return this.resolvedCache=t,this.resolvedCachePresent=!0,t;if(this.segment.kind===MsgpackObjectPathSegmentKind.MAP_VALUE){if(!(t instanceof Map))throw new Error(`Invalid type. Expected Map, got ${t} (${typeof t})`);if(typeof this.segment.key=="string"||this.segment.key instanceof Uint8Array||this.segment.key instanceof RawBinaryString){const r=this.segment.key instanceof RawBinaryString?this.segment.key.rawBinaryValue:coerceToBytes(this.segment.key),n=typeof this.segment.key=="string"||this.segment.key instanceof RawBinaryString;for(const[o,i]of t){let u;if(n?o instanceof RawBinaryString&&(u=o.rawBinaryValue):o instanceof Uint8Array&&(u=o),u&&arrayEqual(r,u)){this.resolvedCache=i;break}}}else this.resolvedCache=t.get(this.segment.key);return this.resolvedCachePresent=!0,this.resolvedCache}if(this.segment.kind===MsgpackObjectPathSegmentKind.ARRAY_ELEMENT){if(!Array.isArray(t))throw new Error(`Invalid type. Expected Array, got ${t} (${typeof t})`);return this.resolvedCache=t[this.segment.key],this.resolvedCachePresent=!0,this.resolvedCache}throw new Error(`Invalid segment kind: ${this.segment.kind}`)}getPathString(){const t=this.parent?this.parent.getPathString():"root";return this.segment?this.segment.kind===MsgpackObjectPathSegmentKind.MAP_VALUE?`${t} -> map key "${this.segment.key}" (${typeof this.segment.key})`:this.segment.kind===MsgpackObjectPathSegmentKind.ARRAY_ELEMENT?`${t} -> array index ${this.segment.key} (${typeof this.segment.key})`:`${t} -> unknown segment kind ${this.segment.kind}`:t}}class Schema{}function decodeMsgpack(e,t){const r=msgpackRawDecodeAsMap(e),n=new MsgpackRawStringProvider({baseObjectBytes:e});return t.fromEncodingData(t.encodingSchema.fromPreparedMsgpack(r,n))}function encodeMsgpack(e){return msgpackRawEncode(e.getEncodingSchema().prepareMsgpack(e.toEncodingData()))}class BooleanSchema extends Schema{defaultValue(){return!1}isDefaultValue(t){return t===!1}prepareMsgpack(t){if(typeof t=="boolean")return t;throw new Error("Invalid boolean")}fromPreparedMsgpack(t,r){if(typeof t=="boolean")return t;throw new Error("Invalid boolean")}prepareJSON(t,r){if(typeof t=="boolean")return t;throw new Error("Invalid boolean")}fromPreparedJSON(t){if(typeof t=="boolean")return t;throw new Error("Invalid boolean")}}class StringSchema extends Schema{defaultValue(){return""}isDefaultValue(t){return t===""}prepareMsgpack(t){if(typeof t=="string")return t;throw new Error(`Invalid string: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){if(typeof t=="string")return t;throw new Error(`Invalid string: (${typeof t}) ${t}`)}prepareJSON(t,r){if(typeof t=="string")return t;throw new Error(`Invalid string: (${typeof t}) ${t}`)}fromPreparedJSON(t){if(typeof t=="string")return t;throw new Error(`Invalid string: (${typeof t}) ${t}`)}}class Uint64Schema extends Schema{defaultValue(){return BigInt(0)}isDefaultValue(t){return typeof t=="bigint"?t===BigInt(0):typeof t=="number"?t===0:!1}prepareMsgpack(t){return ensureUint64(t)}fromPreparedMsgpack(t,r){return ensureUint64(t)}prepareJSON(t,r){return ensureUint64(t)}fromPreparedJSON(t){return ensureUint64(t)}}class AddressSchema extends Schema{defaultValue(){return Address.zeroAddress()}isDefaultValue(t){return Address.zeroAddress().equals(t)}prepareMsgpack(t){if(t instanceof Address)return t.publicKey;throw new Error(`Invalid address: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){return new Address(t)}prepareJSON(t,r){if(t instanceof Address)return t.toString();throw new Error(`Invalid address: (${typeof t}) ${t}`)}fromPreparedJSON(t){return Address.fromString(t)}}class ByteArraySchema extends Schema{defaultValue(){return new Uint8Array}isDefaultValue(t){return t instanceof Uint8Array&&t.byteLength===0}prepareMsgpack(t){if(t instanceof Uint8Array)return t;throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){if(t instanceof Uint8Array)return t;throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}prepareJSON(t,r){if(t instanceof Uint8Array)return bytesToBase64(t);throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}fromPreparedJSON(t){if(t==null)return this.defaultValue();if(typeof t=="string")return base64ToBytes(t);throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}}class FixedLengthByteArraySchema extends Schema{constructor(t){super(),this.length=t}defaultValue(){return new Uint8Array(this.length)}isDefaultValue(t){return t instanceof Uint8Array&&t.byteLength===this.length&&t.every(r=>r===0)}prepareMsgpack(t){if(t instanceof Uint8Array){if(t.byteLength===this.length)return t;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${t.byteLength}`)}throw new Error("Invalid byte array")}fromPreparedMsgpack(t,r){if(t instanceof Uint8Array){if(t.byteLength===this.length)return t;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${t.byteLength}`)}throw new Error("Invalid byte array")}prepareJSON(t){if(t instanceof Uint8Array){if(t.byteLength===this.length)return bytesToBase64(t);throw new Error(`Invalid byte array length: wanted ${this.length}, got ${t.byteLength}`)}throw new Error("Invalid byte array")}fromPreparedJSON(t){if(typeof t=="string"){const r=base64ToBytes(t);if(r.byteLength===this.length)return r;throw new Error(`Invalid byte array length: wanted ${this.length}, got ${r.byteLength}`)}throw new Error("Invalid base64 byte array")}}const blockHashByteLength=32,base32Length=52;class BlockHashSchema extends Schema{defaultValue(){return new Uint8Array(blockHashByteLength)}isDefaultValue(t){return t instanceof Uint8Array&&t.byteLength===blockHashByteLength&&t.every(r=>r===0)}prepareMsgpack(t){if(t instanceof Uint8Array&&t.byteLength===blockHashByteLength)return t;throw new Error(`Invalid block hash: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){if(t instanceof Uint8Array&&t.byteLength===blockHashByteLength)return t;throw new Error(`Invalid block hash: (${typeof t}) ${t}`)}prepareJSON(t,r){if(t instanceof Uint8Array&&t.byteLength===blockHashByteLength)return`blk-${base32.encode(t).slice(0,base32Length)}`;throw new Error(`Invalid block hash: (${typeof t}) ${t}`)}fromPreparedJSON(t){if(typeof t=="string"&&t.length===base32Length+4&&t.startsWith("blk-"))return Uint8Array.from(base32.decode.asBytes(t.slice(4)));throw new Error(`Invalid block hash: (${typeof t}) ${t}`)}}class SpecialCaseBinaryStringSchema extends Schema{defaultValue(){return new Uint8Array}isDefaultValue(t){return t instanceof Uint8Array&&t.byteLength===0}prepareMsgpack(t){if(t instanceof Uint8Array)return new RawBinaryString(t);throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}fromPreparedMsgpack(t,r){return r.getRawStringAtCurrentLocation()}prepareJSON(t,r){if(t instanceof Uint8Array){const n=bytesToString(t);if(!r.lossyBinaryStringConversion&&!arrayEqual(coerceToBytes(n),t))throw new Error(`Invalid UTF-8 byte array encountered. Encode with lossyBinaryStringConversion enabled to bypass this check. Base64 value: ${bytesToBase64(t)}`);return n}throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}fromPreparedJSON(t){if(typeof t=="string")return coerceToBytes(t);throw new Error(`Invalid byte array: (${typeof t}) ${t}`)}}class ArraySchema extends Schema{constructor(t){super(),this.itemSchema=t}defaultValue(){return[]}isDefaultValue(t){return Array.isArray(t)&&t.length===0}prepareMsgpack(t){if(Array.isArray(t))return t.map(r=>this.itemSchema.prepareMsgpack(r));throw new Error("ArraySchema data must be an array")}fromPreparedMsgpack(t,r){if(Array.isArray(t))return t.map((n,o)=>this.itemSchema.fromPreparedMsgpack(n,r.withArrayElement(o)));throw new Error(`ArraySchema encoded data must be an array: ${t} (${typeof t})`)}prepareJSON(t,r){if(Array.isArray(t))return t.map(n=>this.itemSchema.prepareJSON(n,r));throw new Error("ArraySchema data must be an array")}fromPreparedJSON(t){if(Array.isArray(t))return t.map(r=>this.itemSchema.fromPreparedJSON(r));throw new Error(`ArraySchema encoded data must be an array: ${t} (${typeof t})`)}}function allOmitEmpty(e){return e.map(t=>({...t,omitEmpty:!0}))}class NamedMapSchema extends Schema{constructor(t){super(),this.entries=t,this.checkEntries()}pushEntries(...t){this.entries.push(...t),this.checkEntries()}checkEntries(){for(const r of this.entries)if(r.embedded){if(r.key!=="")throw new Error("Embedded entries must have an empty key");if(!(r.valueSchema instanceof NamedMapSchema))throw new Error("Embedded entry valueSchema must be a NamedMapSchema")}const t=new Set;for(const r of this.getEntries()){if(t.has(r.key))throw new Error(`Duplicate key: ${r.key}`);t.add(r.key)}}getEntries(){const t=[];for(const r of this.entries)if(r.embedded){const n=r.valueSchema;t.push(...n.getEntries())}else t.push(r);return t}defaultValue(){const t=new Map;for(const r of this.getEntries())t.set(r.key,r.valueSchema.defaultValue());return t}isDefaultValue(t){if(!(t instanceof Map))return!1;for(const r of this.getEntries())if(!r.valueSchema.isDefaultValue(t.get(r.key)))return!1;return!0}prepareMsgpack(t){if(!(t instanceof Map))throw new Error(`NamedMapSchema data must be a Map. Got (${typeof t}) ${t}`);const r=new Map;for(const n of this.getEntries()){const o=t.get(n.key);n.omitEmpty&&n.valueSchema.isDefaultValue(o)||r.set(n.key,n.valueSchema.prepareMsgpack(o))}return r}fromPreparedMsgpack(t,r){if(!(t instanceof Map))throw new Error("NamedMapSchema data must be a Map");const n=new Map;for(const o of this.getEntries())if(t.has(o.key))n.set(o.key,o.valueSchema.fromPreparedMsgpack(t.get(o.key),r.withMapValue(o.key)));else if(o.omitEmpty)n.set(o.key,o.valueSchema.defaultValue());else throw new Error(`Missing key: ${o.key}`);return n}prepareJSON(t,r){if(!(t instanceof Map))throw new Error("NamedMapSchema data must be a Map");const n={};for(const o of this.getEntries()){const i=t.get(o.key);o.omitEmpty&&o.valueSchema.isDefaultValue(i)||(n[o.key]=o.valueSchema.prepareJSON(i,r))}return n}fromPreparedJSON(t){if(t==null||typeof t!="object"||Array.isArray(t))throw new Error("NamedMapSchema data must be an object");const r=new Map;for(const n of this.getEntries())if(Object.prototype.hasOwnProperty.call(t,n.key))r.set(n.key,n.valueSchema.fromPreparedJSON(t[n.key]));else if(n.omitEmpty)r.set(n.key,n.valueSchema.defaultValue());else throw new Error(`Missing key: ${n.key}`);return r}}function combineMaps(...e){const t=new Map;for(const r of e)for(const[n,o]of r){if(t.has(n))throw new Error(`Duplicate key: ${n}`);t.set(n,o)}return t}function convertMap(e,t){const r=new Map;for(const[n,o]of e){const[i,u]=t(n,o);r.set(i,u)}return r}class Uint64MapSchema extends Schema{constructor(t){super(),this.valueSchema=t}defaultValue(){return new Map}isDefaultValue(t){return t instanceof Map&&t.size===0}prepareMsgpack(t){if(!(t instanceof Map))throw new Error(`Uint64MapSchema data must be a Map. Got (${typeof t}) ${t}`);const r=new Map;for(const[n,o]of t){const i=ensureUint64(n);if(r.has(i))throw new Error(`Duplicate key: ${i}`);r.set(i,this.valueSchema.prepareMsgpack(o))}return r}fromPreparedMsgpack(t,r){if(!(t instanceof Map))throw new Error("Uint64MapSchema data must be a Map");const n=new Map;for(const[o,i]of t){const u=ensureUint64(o);if(n.has(u))throw new Error(`Duplicate key: ${u}`);n.set(u,this.valueSchema.fromPreparedMsgpack(i,r.withMapValue(o)))}return n}prepareJSON(t,r){if(!(t instanceof Map))throw new Error(`Uint64MapSchema data must be a Map. Got (${typeof t}) ${t}`);const n=new Map;for(const[i,u]of t){const a=ensureUint64(i);if(n.has(a))throw new Error(`Duplicate key: ${a}`);n.set(a,this.valueSchema.prepareJSON(u,r))}const o={};for(const[i,u]of n)o[i.toString()]=u;return o}fromPreparedJSON(t){if(t==null||typeof t!="object"||Array.isArray(t))throw new Error("Uint64MapSchema data must be an object");const r=new Map;for(const[n,o]of Object.entries(t)){const i=BigInt(n);if(r.has(i))throw new Error(`Duplicate key: ${i}`);r.set(i,this.valueSchema.fromPreparedJSON(o))}return r}}class ByteArrayMapSchema extends Schema{constructor(t){super(),this.valueSchema=t}defaultValue(){return new Map}isDefaultValue(t){return t instanceof Map&&t.size===0}prepareMsgpack(t){if(!(t instanceof Map))throw new Error(`ByteArrayMapSchema data must be a Map. Got (${typeof t}) ${t}`);const r=new Map;for(const[n,o]of t){if(!(n instanceof Uint8Array))throw new Error(`Invalid key: ${n} (${typeof n})`);r.set(n,this.valueSchema.prepareMsgpack(o))}return r}fromPreparedMsgpack(t,r){if(!(t instanceof Map))throw new Error("ByteArrayMapSchema data must be a Map");const n=new Map;for(const[o,i]of t){if(!(o instanceof Uint8Array))throw new Error(`Invalid key: ${o} (${typeof o})`);n.set(o,this.valueSchema.fromPreparedMsgpack(i,r.withMapValue(o)))}return n}prepareJSON(t,r){if(!(t instanceof Map))throw new Error(`ByteArrayMapSchema data must be a Map. Got (${typeof t}) ${t}`);const n=new Map;for(const[i,u]of t){if(!(i instanceof Uint8Array))throw new Error(`Invalid key: ${i} (${typeof i})`);const a=bytesToBase64(i);if(n.has(a))throw new Error(`Duplicate key (base64): ${a}`);n.set(a,this.valueSchema.prepareJSON(u,r))}const o={};for(const[i,u]of n)o[i]=u;return o}fromPreparedJSON(t){if(t==null||typeof t!="object"||Array.isArray(t))throw new Error("ByteArrayMapSchema data must be an object");const r=new Map;for(const[n,o]of Object.entries(t))r.set(base64ToBytes(n),this.valueSchema.fromPreparedJSON(o));return r}}function convertRawStringsInMsgpackValue(e){if(e instanceof RawBinaryString)return bytesToString(e.rawBinaryValue);if(e instanceof Map){const t=new Map;for(const[r,n]of e)t.set(convertRawStringsInMsgpackValue(r),convertRawStringsInMsgpackValue(n));return t}return Array.isArray(e)?e.map(convertRawStringsInMsgpackValue):e}class SpecialCaseBinaryStringMapSchema extends Schema{constructor(t){super(),this.valueSchema=t}defaultValue(){return new Map}isDefaultValue(t){return t instanceof Map&&t.size===0}prepareMsgpack(t){if(!(t instanceof Map))throw new Error(`SpecialCaseBinaryStringMapSchema data must be a Map. Got (${typeof t}) ${t}`);const r=new Map;for(const[n,o]of t){if(!(n instanceof Uint8Array))throw new Error(`Invalid key: ${n} (${typeof n})`);r.set(new RawBinaryString(n),this.valueSchema.prepareMsgpack(o))}return r}fromPreparedMsgpack(t,r){const n=new Map,o=r.getRawStringKeysAndValuesAtCurrentLocation();for(const[i,u]of o)n.set(i,this.valueSchema.fromPreparedMsgpack(convertRawStringsInMsgpackValue(u),r.withMapValue(new RawBinaryString(i))));return n}prepareJSON(t,r){if(!(t instanceof Map))throw new Error(`SpecialCaseBinaryStringMapSchema data must be a Map. Got (${typeof t}) ${t}`);const n=new Map;for(const[i,u]of t){if(!(i instanceof Uint8Array))throw new Error(`Invalid key: ${i}`);const a=bytesToString(i);if(!r.lossyBinaryStringConversion&&!arrayEqual(coerceToBytes(a),i))throw new Error(`Invalid UTF-8 byte array encountered. Encode with lossyBinaryStringConversion enabled to bypass this check. Base64 value: ${bytesToBase64(i)}`);n.set(a,this.valueSchema.prepareJSON(u,r))}const o={};for(const[i,u]of n)o[i]=u;return o}fromPreparedJSON(t){if(t==null||typeof t!="object"||Array.isArray(t))throw new Error("SpecialCaseBinaryStringMapSchema data must be an object");const r=new Map;for(const[n,o]of Object.entries(t))r.set(coerceToBytes(n),this.valueSchema.fromPreparedJSON(o));return r}}class OptionalSchema extends Schema{constructor(t){super(),this.valueSchema=t}defaultValue(){}isDefaultValue(t){return t===void 0||this.valueSchema.isDefaultValue(t)}prepareMsgpack(t){if(t!==void 0)return this.valueSchema.prepareMsgpack(t)}fromPreparedMsgpack(t,r){if(t!=null)return this.valueSchema.fromPreparedMsgpack(t,r)}prepareJSON(t,r){return t===void 0?null:this.valueSchema.prepareJSON(t,r)}fromPreparedJSON(t){if(t!=null)return this.valueSchema.fromPreparedJSON(t)}}class UntypedSchema extends Schema{defaultValue(){}isDefaultValue(t){return t===void 0}prepareMsgpack(t){return t}fromPreparedMsgpack(t,r){return t}prepareJSON(t,r){return msgpackEncodingDataToJSONEncodingData(t)}fromPreparedJSON(t){return jsonEncodingDataToMsgpackEncodingData(t)}}function boxReferenceToEncodingData(e,t,r){const n=BigInt(e.appIndex),o=e.name,i=n===BigInt(0)||n===r,u=t.indexOf(n)+1;if(u===0&&!i)throw new Error(`Box ref with appId ${n} not in foreign-apps`);return new Map([["i",u],["n",o]])}function boxReferencesToEncodingData(e,t,r){const n=BigInt(r),o=t.map(BigInt);return e.map(i=>boxReferenceToEncodingData(i,o,n))}function resourceReferencesToEncodingData(e,t){const r=[];function n(i){for(let u=0;u<r.length;u++){const a=r[u],s=a.get("d");if((!i.address&&!s||i.address&&s&&i.address.equals(s))&&a.get("s")===i.assetIndex&&a.get("p")===i.appIndex)return u+1}return i.address&&r.push(new Map([["d",i.address]])),i.assetIndex&&r.push(new Map([["s",i.assetIndex]])),i.appIndex&&r.push(new Map([["p",i.appIndex]])),r.length}const o=Address.zeroAddress();for(const i of t){if(i.address||i.assetIndex||i.appIndex){n(i);continue}if(i.holding){const u=i.holding;let a=0;u.address&&!u.address.equals(o)&&(a=n({address:u.address}));const s=n({assetIndex:u.assetIndex});r.push(new Map([["h",new Map([["d",a],["s",s]])]]));continue}if(i.locals){const u=i.locals;let a=0;u.address&&!u.address.equals(o)&&(a=n({address:u.address}));let s=0;u.appIndex&&BigInt(u.appIndex)!==e&&(s=n({appIndex:u.appIndex})),r.push(new Map([["l",new Map([["d",a],["p",s]])]]));continue}if(i.box){const u=i.box;let a=0;u.appIndex&&BigInt(u.appIndex)!==e&&(a=n({appIndex:u.appIndex})),r.push(new Map([["b",new Map([["i",a],["n",u.name]])]]))}}return r}function convertIndicesToResourceReferences(e){const t=[];for(const r of e){const n=r.get("d"),o=r.get("s"),i=r.get("p");if(n){t.push({address:n});continue}if(o){t.push({assetIndex:o});continue}if(i){t.push({appIndex:i});continue}const u=r.get("h");if(u){const f=ensureSafeUnsignedInteger(u.get("d")??0),c=ensureSafeUnsignedInteger(u.get("s"));if(!c)throw new Error(`Holding missing asset index: ${u}`);const d=f===0?Address.zeroAddress():t[f-1].address,p=t[c-1].assetIndex;t.push({holding:{address:d,assetIndex:p}});continue}const a=r.get("l");if(a){const f=ensureSafeUnsignedInteger(a.get("d")??0),c=ensureSafeUnsignedInteger(a.get("p")??0),d=f===0?Address.zeroAddress():t[f-1].address,p=c===0?BigInt(0):t[c-1].appIndex;t.push({locals:{address:d,appIndex:p}});continue}const s=r.get("b");if(s){const f=ensureSafeUnsignedInteger(s.get("i")??0),c=s.get("n");if(!c)throw new Error(`Box missing name: ${s}`);const d=f===0?BigInt(0):t[f-1].appIndex;t.push({box:{appIndex:d,name:c}})}}return t}var TransactionType;(function(e){e.pay="pay",e.keyreg="keyreg",e.acfg="acfg",e.axfer="axfer",e.afrz="afrz",e.appl="appl",e.stpf="stpf",e.hb="hb"})(TransactionType||(TransactionType={}));function isTransactionType(e){return e===TransactionType.pay||e===TransactionType.keyreg||e===TransactionType.acfg||e===TransactionType.axfer||e===TransactionType.afrz||e===TransactionType.appl||e===TransactionType.stpf||e===TransactionType.hb}var OnApplicationComplete;(function(e){e[e.NoOpOC=0]="NoOpOC",e[e.OptInOC=1]="OptInOC",e[e.CloseOutOC=2]="CloseOutOC",e[e.ClearStateOC=3]="ClearStateOC",e[e.UpdateApplicationOC=4]="UpdateApplicationOC",e[e.DeleteApplicationOC=5]="DeleteApplicationOC"})(OnApplicationComplete||(OnApplicationComplete={}));function isOnApplicationComplete(e){return e===OnApplicationComplete.NoOpOC||e===OnApplicationComplete.OptInOC||e===OnApplicationComplete.CloseOutOC||e===OnApplicationComplete.ClearStateOC||e===OnApplicationComplete.UpdateApplicationOC||e===OnApplicationComplete.DeleteApplicationOC}class HashFactory{constructor(t){this.hashType=t.hashType}getEncodingSchema(){return HashFactory.encodingSchema}toEncodingData(){return new Map([["t",this.hashType]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded HashFactory: ${t}`);return new HashFactory({hashType:Number(t.get("t"))})}}HashFactory.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"t",valueSchema:new Uint64Schema}]));class MerkleArrayProof{constructor(t){this.path=t.path,this.hashFactory=t.hashFactory,this.treeDepth=t.treeDepth}getEncodingSchema(){return MerkleArrayProof.encodingSchema}toEncodingData(){return new Map([["pth",this.path],["hsh",this.hashFactory.toEncodingData()],["td",this.treeDepth]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded MerkleArrayProof: ${t}`);return new MerkleArrayProof({path:t.get("pth"),hashFactory:HashFactory.fromEncodingData(t.get("hsh")),treeDepth:Number(t.get("td"))})}}MerkleArrayProof.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"pth",valueSchema:new ArraySchema(new ByteArraySchema)},{key:"hsh",valueSchema:HashFactory.encodingSchema},{key:"td",valueSchema:new Uint64Schema}]));class MerkleSignatureVerifier{constructor(t){this.commitment=t.commitment,this.keyLifetime=t.keyLifetime}getEncodingSchema(){return MerkleSignatureVerifier.encodingSchema}toEncodingData(){return new Map([["cmt",this.commitment],["lf",this.keyLifetime]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded MerkleSignatureVerifier: ${t}`);return new MerkleSignatureVerifier({commitment:t.get("cmt"),keyLifetime:t.get("lf")})}}MerkleSignatureVerifier.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"cmt",valueSchema:new FixedLengthByteArraySchema(64)},{key:"lf",valueSchema:new Uint64Schema}]));class Participant{constructor(t){this.pk=t.pk,this.weight=t.weight}getEncodingSchema(){return Participant.encodingSchema}toEncodingData(){return new Map([["p",this.pk.toEncodingData()],["w",this.weight]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded Participant: ${t}`);return new Participant({pk:MerkleSignatureVerifier.fromEncodingData(t.get("p")),weight:t.get("w")})}}Participant.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"p",valueSchema:MerkleSignatureVerifier.encodingSchema},{key:"w",valueSchema:new Uint64Schema}]));class FalconVerifier{constructor(t){this.publicKey=t.publicKey}getEncodingSchema(){return FalconVerifier.encodingSchema}toEncodingData(){return new Map([["k",this.publicKey]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded FalconVerifier: ${t}`);return new FalconVerifier({publicKey:t.get("k")})}}FalconVerifier.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"k",valueSchema:new FixedLengthByteArraySchema(1793)}]));class FalconSignatureStruct{constructor(t){this.signature=t.signature,this.vectorCommitmentIndex=t.index,this.proof=t.proof,this.verifyingKey=t.verifyingKey}getEncodingSchema(){return FalconSignatureStruct.encodingSchema}toEncodingData(){return new Map([["sig",this.signature],["idx",this.vectorCommitmentIndex],["prf",this.proof.toEncodingData()],["vkey",this.verifyingKey.toEncodingData()]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded FalconSignatureStruct: ${t}`);return new FalconSignatureStruct({signature:t.get("sig"),index:t.get("idx"),proof:MerkleArrayProof.fromEncodingData(t.get("prf")),verifyingKey:FalconVerifier.fromEncodingData(t.get("vkey"))})}}FalconSignatureStruct.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"sig",valueSchema:new ByteArraySchema},{key:"idx",valueSchema:new Uint64Schema},{key:"prf",valueSchema:MerkleArrayProof.encodingSchema},{key:"vkey",valueSchema:FalconVerifier.encodingSchema}]));class SigslotCommit{constructor(t){this.sig=t.sig,this.l=t.l}getEncodingSchema(){return SigslotCommit.encodingSchema}toEncodingData(){return new Map([["s",this.sig.toEncodingData()],["l",this.l]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded SigslotCommit: ${t}`);return new SigslotCommit({sig:FalconSignatureStruct.fromEncodingData(t.get("s")),l:t.get("l")})}}SigslotCommit.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"s",valueSchema:FalconSignatureStruct.encodingSchema},{key:"l",valueSchema:new Uint64Schema}]));class Reveal{constructor(t){this.sigslot=t.sigslot,this.participant=t.participant}getEncodingSchema(){return Reveal.encodingSchema}toEncodingData(){return new Map([["s",this.sigslot.toEncodingData()],["p",this.participant.toEncodingData()]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded Reveal: ${t}`);return new Reveal({sigslot:SigslotCommit.fromEncodingData(t.get("s")),participant:Participant.fromEncodingData(t.get("p"))})}}Reveal.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"s",valueSchema:SigslotCommit.encodingSchema},{key:"p",valueSchema:Participant.encodingSchema}]));class StateProof{constructor(t){this.sigCommit=t.sigCommit,this.signedWeight=t.signedWeight,this.sigProofs=t.sigProofs,this.partProofs=t.partProofs,this.merkleSignatureSaltVersion=t.merkleSignatureSaltVersion,this.reveals=t.reveals,this.positionsToReveal=t.positionsToReveal}getEncodingSchema(){return StateProof.encodingSchema}toEncodingData(){return new Map([["c",this.sigCommit],["w",this.signedWeight],["S",this.sigProofs.toEncodingData()],["P",this.partProofs.toEncodingData()],["v",this.merkleSignatureSaltVersion],["r",convertMap(this.reveals,(t,r)=>[t,r.toEncodingData()])],["pr",this.positionsToReveal]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded StateProof: ${t}`);return new StateProof({sigCommit:t.get("c"),signedWeight:t.get("w"),sigProofs:MerkleArrayProof.fromEncodingData(t.get("S")),partProofs:MerkleArrayProof.fromEncodingData(t.get("P")),merkleSignatureSaltVersion:Number(t.get("v")),reveals:convertMap(t.get("r"),(r,n)=>[r,Reveal.fromEncodingData(n)]),positionsToReveal:t.get("pr")})}}StateProof.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"c",valueSchema:new ByteArraySchema},{key:"w",valueSchema:new Uint64Schema},{key:"S",valueSchema:MerkleArrayProof.encodingSchema},{key:"P",valueSchema:MerkleArrayProof.encodingSchema},{key:"v",valueSchema:new Uint64Schema},{key:"r",valueSchema:new Uint64MapSchema(Reveal.encodingSchema)},{key:"pr",valueSchema:new ArraySchema(new Uint64Schema)}]));class StateProofMessage{constructor(t){this.blockHeadersCommitment=t.blockHeadersCommitment,this.votersCommitment=t.votersCommitment,this.lnProvenWeight=t.lnProvenWeight,this.firstAttestedRound=t.firstAttestedRound,this.lastAttestedRound=t.lastAttestedRound}getEncodingSchema(){return StateProofMessage.encodingSchema}toEncodingData(){return new Map([["b",this.blockHeadersCommitment],["v",this.votersCommitment],["P",this.lnProvenWeight],["f",this.firstAttestedRound],["l",this.lastAttestedRound]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded StateProofMessage: ${t}`);return new StateProofMessage({blockHeadersCommitment:t.get("b"),votersCommitment:t.get("v"),lnProvenWeight:t.get("P"),firstAttestedRound:t.get("f"),lastAttestedRound:t.get("l")})}static fromMap(t){return new StateProofMessage({blockHeadersCommitment:t.get("b"),votersCommitment:t.get("v"),lnProvenWeight:t.get("P"),firstAttestedRound:t.get("f"),lastAttestedRound:t.get("l")})}}StateProofMessage.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"b",valueSchema:new ByteArraySchema},{key:"v",valueSchema:new ByteArraySchema},{key:"P",valueSchema:new Uint64Schema},{key:"f",valueSchema:new Uint64Schema},{key:"l",valueSchema:new Uint64Schema}]));class HeartbeatProof{constructor(t){this.sig=t.sig,this.pk=t.pk,this.pk2=t.pk2,this.pk1Sig=t.pk1Sig,this.pk2Sig=t.pk2Sig}getEncodingSchema(){return HeartbeatProof.encodingSchema}toEncodingData(){return new Map([["s",this.sig],["p",this.pk],["p2",this.pk2],["p1s",this.pk1Sig],["p2s",this.pk2Sig]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded HeartbeatProof: ${t}`);return new HeartbeatProof({sig:t.get("s"),pk:t.get("p"),pk2:t.get("p2"),pk1Sig:t.get("p1s"),pk2Sig:t.get("p2s")})}}HeartbeatProof.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"s",valueSchema:new FixedLengthByteArraySchema(64)},{key:"p",valueSchema:new FixedLengthByteArraySchema(32)},{key:"p2",valueSchema:new FixedLengthByteArraySchema(32)},{key:"p1s",valueSchema:new FixedLengthByteArraySchema(64)},{key:"p2s",valueSchema:new FixedLengthByteArraySchema(64)}]));class Heartbeat{constructor(t){this.address=t.address,this.proof=t.proof,this.seed=t.seed,this.voteID=t.voteID,this.keyDilution=t.keyDilution}getEncodingSchema(){return Heartbeat.encodingSchema}toEncodingData(){return new Map([["a",this.address],["prf",this.proof.toEncodingData()],["sd",this.seed],["vid",this.voteID],["kd",this.keyDilution]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded Heartbeat: ${t}`);return new Heartbeat({address:t.get("a"),proof:HeartbeatProof.fromEncodingData(t.get("prf")),seed:t.get("sd"),voteID:t.get("vid"),keyDilution:t.get("kd")})}}Heartbeat.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"a",valueSchema:new AddressSchema},{key:"prf",valueSchema:HeartbeatProof.encodingSchema},{key:"sd",valueSchema:new ByteArraySchema},{key:"vid",valueSchema:new FixedLengthByteArraySchema(32)},{key:"kd",valueSchema:new Uint64Schema}]));const ALGORAND_TRANSACTION_LENGTH=52,ALGORAND_TRANSACTION_LEASE_LENGTH=32,NUM_ADDL_BYTES_AFTER_SIGNING=75,ASSET_METADATA_HASH_LENGTH=32,KEYREG_VOTE_KEY_LENGTH=32,KEYREG_SELECTION_KEY_LENGTH=32,KEYREG_STATE_PROOF_KEY_LENGTH=64,ALGORAND_TRANSACTION_GROUP_LENGTH=32;function uint8ArrayIsEmpty(e){return e.every(t=>t===0)}function getKeyregKey(e,t,r){if(e==null)return;let n;if(e instanceof Uint8Array&&(n=e),n==null||n.byteLength!==r)throw Error(`${t} must be a ${r} byte Uint8Array`);return n}function ensureAddress(e){if(e==null)throw new Error("Address must not be null or undefined");if(typeof e=="string")return Address.fromString(e);if(e instanceof Address)return e;throw new Error(`Not an address: ${e}`)}function optionalAddress(e){if(e==null)return;let t;if(e instanceof Address)t=e;else if(typeof e=="string")t=Address.fromString(e);else throw new Error(`Not an address: ${e}`);if(uint8ArrayIsEmpty(t.publicKey))throw new Error("Invalid use of the zero address. To omit this value, pass in undefined");return t}function optionalUint8Array(e){if(!(typeof e>"u")){if(e instanceof Uint8Array)return e;throw new Error(`Not a Uint8Array: ${e}`)}}function ensureUint8Array(e){if(e instanceof Uint8Array)return e;throw new Error(`Not a Uint8Array: ${e}`)}function optionalUint64(e){if(!(typeof e>"u"))return ensureUint64(e)}function ensureBoolean(e){if(e===!0||e===!1)return e;throw new Error(`Not a boolean: ${e}`)}function ensureArray(e){if(Array.isArray(e))return e.slice();throw new Error(`Not an array: ${e}`)}function optionalFixedLengthByteArray(e,t,r){const n=optionalUint8Array(e);if(!(typeof n>"u")){if(n.byteLength!==t)throw new Error(`${r} must be ${t} bytes long, was ${n.byteLength}`);if(!uint8ArrayIsEmpty(n))return n}}function ensureBoxReference(e){if(e!=null&&typeof e=="object"){const{appIndex:t,name:r}=e;return{appIndex:ensureUint64(t),name:ensureUint8Array(r)}}throw new Error(`Not a box reference: ${e}`)}function ensureHoldingReference(e){if(e!=null&&typeof e=="object"){const{assetIndex:t,address:r}=e;return{assetIndex:ensureUint64(t),address:ensureAddress(r)}}throw new Error(`Not a holding reference: ${e}`)}function ensureLocalsReference(e){if(e!=null&&typeof e=="object"){const{appIndex:t,address:r}=e;return{appIndex:ensureUint64(t),address:ensureAddress(r)}}throw new Error(`Not a locals reference: ${e}`)}function ensureResourceReference(e){if(e!=null&&typeof e=="object"){const{address:t,appIndex:r,assetIndex:n,holding:o,locals:i,box:u}=e;if(t!==void 0)return{address:ensureAddress(t)};if(r!==void 0)return{appIndex:ensureUint64(r)};if(n!==void 0)return{assetIndex:ensureUint64(n)};if(o!==void 0)return{holding:ensureHoldingReference(o)};if(i!==void 0)return{locals:ensureLocalsReference(i)};if(u!==void 0)return{box:ensureBoxReference(u)}}throw new Error(`Not a resource reference: ${e}`)}const TX_TAG=new TextEncoder().encode("TX");class Transaction{constructor(t){if(!isTransactionType(t.type))throw new Error(`Invalid transaction type: ${t.type}`);if(this.type=t.type,this.sender=ensureAddress(t.sender),this.note=ensureUint8Array(t.note??new Uint8Array),this.lease=optionalFixedLengthByteArray(t.lease,ALGORAND_TRANSACTION_LEASE_LENGTH,"lease"),this.rekeyTo=optionalAddress(t.rekeyTo),this.group=void 0,this.firstValid=ensureUint64(t.suggestedParams.firstValid),this.lastValid=ensureUint64(t.suggestedParams.lastValid),t.suggestedParams.genesisID){if(typeof t.suggestedParams.genesisID!="string")throw new Error("Genesis ID must be a string if present");this.genesisID=t.suggestedParams.genesisID}this.genesisHash=optionalUint8Array(t.suggestedParams.genesisHash);const r=[];if(t.paymentParams&&r.push(TransactionType.pay),t.keyregParams&&r.push(TransactionType.keyreg),t.assetConfigParams&&r.push(TransactionType.acfg),t.assetTransferParams&&r.push(TransactionType.axfer),t.assetFreezeParams&&r.push(TransactionType.afrz),t.appCallParams&&r.push(TransactionType.appl),t.stateProofParams&&r.push(TransactionType.stpf),t.heartbeatParams&&r.push(TransactionType.hb),r.length!==1)throw new Error(`Transaction has wrong number of type fields present (${r.length}): ${r}`);if(this.type!==r[0])throw new Error(`Transaction has type ${this.type} but fields present for ${r[0]}`);if(t.paymentParams&&(this.payment={receiver:ensureAddress(t.paymentParams.receiver),amount:ensureUint64(t.paymentParams.amount),closeRemainderTo:optionalAddress(t.paymentParams.closeRemainderTo)}),t.keyregParams){if(this.keyreg={voteKey:getKeyregKey(t.keyregParams.voteKey,"voteKey",KEYREG_VOTE_KEY_LENGTH),selectionKey:getKeyregKey(t.keyregParams.selectionKey,"selectionKey",KEYREG_SELECTION_KEY_LENGTH),stateProofKey:getKeyregKey(t.keyregParams.stateProofKey,"stateProofKey",KEYREG_STATE_PROOF_KEY_LENGTH),voteFirst:optionalUint64(t.keyregParams.voteFirst),voteLast:optionalUint64(t.keyregParams.voteLast),voteKeyDilution:optionalUint64(t.keyregParams.voteKeyDilution),nonParticipation:ensureBoolean(t.keyregParams.nonParticipation??!1)},this.keyreg.nonParticipation&&(this.keyreg.voteKey||this.keyreg.selectionKey||this.keyreg.stateProofKey||typeof this.keyreg.voteFirst<"u"||typeof this.keyreg.voteLast<"u"||typeof this.keyreg.voteKeyDilution<"u"))throw new Error("nonParticipation is true but participation params are present.");if(!this.keyreg.nonParticipation&&(this.keyreg.voteKey||this.keyreg.selectionKey||this.keyreg.stateProofKey||typeof this.keyreg.voteFirst<"u"||typeof this.keyreg.voteLast<"u"||typeof this.keyreg.voteKeyDilution<"u")&&!(this.keyreg.voteKey&&this.keyreg.selectionKey&&typeof this.keyreg.voteFirst<"u"&&typeof this.keyreg.voteLast<"u"&&typeof this.keyreg.voteKeyDilution<"u"))throw new Error("Online key registration missing at least one of the following fields: voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution")}if(t.assetConfigParams&&(this.assetConfig={assetIndex:ensureUint64(t.assetConfigParams.assetIndex??0),total:ensureUint64(t.assetConfigParams.total??0),decimals:ensureSafeUnsignedInteger(t.assetConfigParams.decimals??0),defaultFrozen:ensureBoolean(t.assetConfigParams.defaultFrozen??!1),manager:optionalAddress(t.assetConfigParams.manager),reserve:optionalAddress(t.assetConfigParams.reserve),freeze:optionalAddress(t.assetConfigParams.freeze),clawback:optionalAddress(t.assetConfigParams.clawback),unitName:t.assetConfigParams.unitName,assetName:t.assetConfigParams.assetName,assetURL:t.assetConfigParams.assetURL,assetMetadataHash:optionalFixedLengthByteArray(t.assetConfigParams.assetMetadataHash,ASSET_METADATA_HASH_LENGTH,"assetMetadataHash")}),t.assetTransferParams&&(this.assetTransfer={assetIndex:ensureUint64(t.assetTransferParams.assetIndex),amount:ensureUint64(t.assetTransferParams.amount),assetSender:optionalAddress(t.assetTransferParams.assetSender),receiver:ensureAddress(t.assetTransferParams.receiver),closeRemainderTo:optionalAddress(t.assetTransferParams.closeRemainderTo)}),t.assetFreezeParams&&(this.assetFreeze={assetIndex:ensureUint64(t.assetFreezeParams.assetIndex),freezeAccount:ensureAddress(t.assetFreezeParams.freezeTarget),frozen:ensureBoolean(t.assetFreezeParams.frozen)}),t.appCallParams){const{onComplete:o}=t.appCallParams;if(!isOnApplicationComplete(o))throw new Error(`Invalid onCompletion value: ${o}`);this.applicationCall={appIndex:ensureUint64(t.appCallParams.appIndex),onComplete:o,numLocalInts:ensureSafeUnsignedInteger(t.appCallParams.numLocalInts??0),numLocalByteSlices:ensureSafeUnsignedInteger(t.appCallParams.numLocalByteSlices??0),numGlobalInts:ensureSafeUnsignedInteger(t.appCallParams.numGlobalInts??0),numGlobalByteSlices:ensureSafeUnsignedInteger(t.appCallParams.numGlobalByteSlices??0),extraPages:ensureSafeUnsignedInteger(t.appCallParams.extraPages??0),approvalProgram:ensureUint8Array(t.appCallParams.approvalProgram??new Uint8Array),clearProgram:ensureUint8Array(t.appCallParams.clearProgram??new Uint8Array),appArgs:ensureArray(t.appCallParams.appArgs??[]).map(ensureUint8Array),accounts:ensureArray(t.appCallParams.accounts??[]).map(ensureAddress),foreignApps:ensureArray(t.appCallParams.foreignApps??[]).map(ensureUint64),foreignAssets:ensureArray(t.appCallParams.foreignAssets??[]).map(ensureUint64),boxes:ensureArray(t.appCallParams.boxes??[]).map(ensureBoxReference),access:ensureArray(t.appCallParams.access??[]).map(ensureResourceReference),rejectVersion:ensureSafeUnsignedInteger(t.appCallParams.rejectVersion??0)}}if(t.stateProofParams&&(this.stateProof={stateProofType:ensureSafeUnsignedInteger(t.stateProofParams.stateProofType??0),stateProof:t.stateProofParams.stateProof,message:t.stateProofParams.message}),t.heartbeatParams&&(this.heartbeat=new Heartbeat({address:t.heartbeatParams.address,proof:t.heartbeatParams.proof,seed:t.heartbeatParams.seed,voteID:t.heartbeatParams.voteID,keyDilution:t.heartbeatParams.keyDilution})),this.fee=ensureUint64(t.suggestedParams.fee),!ensureBoolean(t.suggestedParams.flatFee??!1)){const o=ensureUint64(t.suggestedParams.minFee);this.fee*=BigInt(this.estimateSize()),this.fee<o&&(this.fee=o)}}getEncodingSchema(){return Transaction.encodingSchema}toEncodingData(){const t=new Map([["type",this.type],["fv",this.firstValid],["lv",this.lastValid],["snd",this.sender],["gen",this.genesisID],["gh",this.genesisHash],["fee",this.fee],["note",this.note],["lx",this.lease],["rekey",this.rekeyTo],["grp",this.group]]);if(this.payment)return t.set("amt",this.payment.amount),t.set("rcv",this.payment.receiver),t.set("close",this.payment.closeRemainderTo),t;if(this.keyreg)return t.set("votekey",this.keyreg.voteKey),t.set("selkey",this.keyreg.selectionKey),t.set("sprfkey",this.keyreg.stateProofKey),t.set("votefst",this.keyreg.voteFirst),t.set("votelst",this.keyreg.voteLast),t.set("votekd",this.keyreg.voteKeyDilution),t.set("nonpart",this.keyreg.nonParticipation),t;if(this.assetConfig){t.set("caid",this.assetConfig.assetIndex);const r=new Map([["t",this.assetConfig.total],["dc",this.assetConfig.decimals],["df",this.assetConfig.defaultFrozen],["m",this.assetConfig.manager],["r",this.assetConfig.reserve],["f",this.assetConfig.freeze],["c",this.assetConfig.clawback],["un",this.assetConfig.unitName],["an",this.assetConfig.assetName],["au",this.assetConfig.assetURL],["am",this.assetConfig.assetMetadataHash]]);return t.set("apar",r),t}if(this.assetTransfer)return t.set("xaid",this.assetTransfer.assetIndex),t.set("aamt",this.assetTransfer.amount),t.set("arcv",this.assetTransfer.receiver),t.set("aclose",this.assetTransfer.closeRemainderTo),t.set("asnd",this.assetTransfer.assetSender),t;if(this.assetFreeze)return t.set("faid",this.assetFreeze.assetIndex),t.set("afrz",this.assetFreeze.frozen),t.set("fadd",this.assetFreeze.freezeAccount),t;if(this.applicationCall)return t.set("apid",this.applicationCall.appIndex),t.set("apan",this.applicationCall.onComplete),t.set("apaa",this.applicationCall.appArgs),t.set("apat",this.applicationCall.accounts),t.set("apas",this.applicationCall.foreignAssets),t.set("apfa",this.applicationCall.foreignApps),t.set("apbx",boxReferencesToEncodingData(this.applicationCall.boxes,this.applicationCall.foreignApps,this.applicationCall.appIndex)),t.set("al",resourceReferencesToEncodingData(this.applicationCall.appIndex,this.applicationCall.access)),t.set("apap",this.applicationCall.approvalProgram),t.set("apsu",this.applicationCall.clearProgram),t.set("apls",new Map([["nui",this.applicationCall.numLocalInts],["nbs",this.applicationCall.numLocalByteSlices]])),t.set("apgs",new Map([["nui",this.applicationCall.numGlobalInts],["nbs",this.applicationCall.numGlobalByteSlices]])),t.set("apep",this.applicationCall.extraPages),t.set("aprv",this.applicationCall.rejectVersion),t;if(this.stateProof)return t.set("sptype",this.stateProof.stateProofType),t.set("sp",this.stateProof.stateProof?this.stateProof.stateProof.toEncodingData():void 0),t.set("spmsg",this.stateProof.message?this.stateProof.message.toEncodingData():void 0),t;if(this.heartbeat){const r=new Heartbeat({address:this.heartbeat.address,proof:this.heartbeat.proof,seed:this.heartbeat.seed,voteID:this.heartbeat.voteID,keyDilution:this.heartbeat.keyDilution});return t.set("hb",r.toEncodingData()),t}throw new Error(`Unexpected transaction type: ${this.type}`)}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded logic sig account: ${t}`);const r={minFee:BigInt(0),flatFee:!0,fee:t.get("fee")??0,firstValid:t.get("fv")??0,lastValid:t.get("lv")??0,genesisHash:t.get("gh"),genesisID:t.get("gen")},n=t.get("type");if(!isTransactionType(n))throw new Error(`Unrecognized transaction type: ${n}`);const o={type:n,sender:t.get("snd")??Address.zeroAddress(),note:t.get("note"),lease:t.get("lx"),suggestedParams:r};if(t.get("rekey")&&(o.rekeyTo=t.get("rekey")),o.type===TransactionType.pay){const u={amount:t.get("amt")??0,receiver:t.get("rcv")??Address.zeroAddress()};t.get("close")&&(u.closeRemainderTo=t.get("close")),o.paymentParams=u}else if(o.type===TransactionType.keyreg){const u={voteKey:t.get("votekey"),selectionKey:t.get("selkey"),stateProofKey:t.get("sprfkey"),voteFirst:t.get("votefst"),voteLast:t.get("votelst"),voteKeyDilution:t.get("votekd"),nonParticipation:t.get("nonpart")};o.keyregParams=u}else if(o.type===TransactionType.acfg){const u={assetIndex:t.get("caid")};if(t.get("apar")){const a=t.get("apar");u.total=a.get("t"),u.decimals=a.get("dc"),u.defaultFrozen=a.get("df"),u.unitName=a.get("un"),u.assetName=a.get("an"),u.assetURL=a.get("au"),u.assetMetadataHash=a.get("am"),a.get("m")&&(u.manager=a.get("m")),a.get("r")&&(u.reserve=a.get("r")),a.get("f")&&(u.freeze=a.get("f")),a.get("c")&&(u.clawback=a.get("c"))}o.assetConfigParams=u}else if(o.type===TransactionType.axfer){const u={assetIndex:t.get("xaid")??0,amount:t.get("aamt")??0,receiver:t.get("arcv")??Address.zeroAddress()};t.get("aclose")&&(u.closeRemainderTo=t.get("aclose")),t.get("asnd")&&(u.assetSender=t.get("asnd")),o.assetTransferParams=u}else if(o.type===TransactionType.afrz){const u={assetIndex:t.get("faid")??0,freezeTarget:t.get("fadd")??Address.zeroAddress(),frozen:t.get("afrz")??!1};o.assetFreezeParams=u}else if(o.type===TransactionType.appl){const u={appIndex:t.get("apid")??0,onComplete:ensureSafeUnsignedInteger(t.get("apan")??0),appArgs:t.get("apaa"),accounts:t.get("apat"),foreignAssets:t.get("apas"),foreignApps:t.get("apfa"),approvalProgram:t.get("apap"),clearProgram:t.get("apsu"),extraPages:t.get("apep"),rejectVersion:t.get("aprv")??0},a=t.get("apls");a&&(u.numLocalInts=a.get("nui"),u.numLocalByteSlices=a.get("nbs"));const s=t.get("apgs");s&&(u.numGlobalInts=s.get("nui"),u.numGlobalByteSlices=s.get("nbs"));const f=t.get("apbx");f&&(u.boxes=f.map(d=>{const p=ensureSafeUnsignedInteger(d.get("i")??0),h=ensureUint8Array(d.get("n")??new Uint8Array);if(p===0)return{appIndex:0,name:h};if(!u.foreignApps||p>u.foreignApps.length)throw new Error(`Cannot find foreign app index ${p} in ${u.foreignApps}`);return{appIndex:u.foreignApps[p-1],name:h}}));const c=t.get("al");c&&(u.access=convertIndicesToResourceReferences(c)),o.appCallParams=u}else if(o.type===TransactionType.stpf){const u={stateProofType:t.get("sptype"),stateProof:t.get("sp")?StateProof.fromEncodingData(t.get("sp")):void 0,message:t.get("spmsg")?StateProofMessage.fromEncodingData(t.get("spmsg")):void 0};o.stateProofParams=u}else if(o.type===TransactionType.hb){const u=Heartbeat.fromEncodingData(t.get("hb")),a={address:u.address,proof:u.proof,seed:u.seed,voteID:u.voteID,keyDilution:u.keyDilution};o.heartbeatParams=a}else{const u=o.type;throw new Error(`Unexpected transaction type: ${u}`)}const i=new Transaction(o);if(t.get("grp")){const u=ensureUint8Array(t.get("grp"));if(u.byteLength!==ALGORAND_TRANSACTION_GROUP_LENGTH)throw new Error(`Invalid group length: ${u.byteLength}`);i.group=u}return i}estimateSize(){return this.toByte().length+NUM_ADDL_BYTES_AFTER_SIGNING}bytesToSign(){const t=this.toByte();return concatArrays(TX_TAG,t)}toByte(){return encodeMsgpack(this)}rawSignTxn(t){const r=this.bytesToSign();return sign(r,t)}signTxn(t){const r=keyPairFromSecretKey(t),n=new Address(r.publicKey),o=this.rawSignTxn(t);return this.attachSignature(n,o)}attachSignature(t,r){if(!isValidSignatureLength(r.length))throw new Error("Invalid signature length");const n=new Map([["sig",r],["txn",this.toEncodingData()]]),o=ensureAddress(t);this.sender.equals(o)||n.set("sgnr",o);const i=new NamedMapSchema(allOmitEmpty([{key:"txn",valueSchema:Transaction.encodingSchema},{key:"sig",valueSchema:new FixedLengthByteArraySchema(64)},{key:"sgnr",valueSchema:new OptionalSchema(new AddressSchema)}]));return msgpackRawEncode(i.prepareMsgpack(n))}rawTxID(){const t=this.toByte(),r=concatArrays(TX_TAG,t);return Uint8Array.from(genericHash(r))}txID(){const t=this.rawTxID();return base32.encode(t).slice(0,ALGORAND_TRANSACTION_LENGTH)}}Transaction.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"type",valueSchema:new StringSchema},{key:"snd",valueSchema:new AddressSchema},{key:"lv",valueSchema:new Uint64Schema},{key:"gen",valueSchema:new OptionalSchema(new StringSchema)},{key:"gh",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"fee",valueSchema:new Uint64Schema},{key:"fv",valueSchema:new Uint64Schema},{key:"note",valueSchema:new ByteArraySchema},{key:"lx",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"rekey",valueSchema:new OptionalSchema(new AddressSchema)},{key:"grp",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"amt",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"rcv",valueSchema:new OptionalSchema(new AddressSchema)},{key:"close",valueSchema:new OptionalSchema(new AddressSchema)},{key:"votekey",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"selkey",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))},{key:"sprfkey",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(64))},{key:"votefst",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"votelst",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"votekd",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"nonpart",valueSchema:new OptionalSchema(new BooleanSchema)},{key:"caid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"apar",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"t",valueSchema:new Uint64Schema},{key:"dc",valueSchema:new Uint64Schema},{key:"df",valueSchema:new BooleanSchema},{key:"m",valueSchema:new OptionalSchema(new AddressSchema)},{key:"r",valueSchema:new OptionalSchema(new AddressSchema)},{key:"f",valueSchema:new OptionalSchema(new AddressSchema)},{key:"c",valueSchema:new OptionalSchema(new AddressSchema)},{key:"un",valueSchema:new OptionalSchema(new StringSchema)},{key:"an",valueSchema:new OptionalSchema(new StringSchema)},{key:"au",valueSchema:new OptionalSchema(new StringSchema)},{key:"am",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))}])))},{key:"xaid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"aamt",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"arcv",valueSchema:new OptionalSchema(new AddressSchema)},{key:"aclose",valueSchema:new OptionalSchema(new AddressSchema)},{key:"asnd",valueSchema:new OptionalSchema(new AddressSchema)},{key:"faid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"afrz",valueSchema:new OptionalSchema(new BooleanSchema)},{key:"fadd",valueSchema:new OptionalSchema(new AddressSchema)},{key:"apid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"apan",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"apaa",valueSchema:new OptionalSchema(new ArraySchema(new ByteArraySchema))},{key:"apat",valueSchema:new OptionalSchema(new ArraySchema(new AddressSchema))},{key:"apas",valueSchema:new OptionalSchema(new ArraySchema(new Uint64Schema))},{key:"apfa",valueSchema:new OptionalSchema(new ArraySchema(new Uint64Schema))},{key:"apbx",valueSchema:new OptionalSchema(new ArraySchema(new NamedMapSchema(allOmitEmpty([{key:"i",valueSchema:new Uint64Schema},{key:"n",valueSchema:new ByteArraySchema}]))))},{key:"al",valueSchema:new OptionalSchema(new ArraySchema(new NamedMapSchema(allOmitEmpty([{key:"d",valueSchema:new OptionalSchema(new AddressSchema)},{key:"s",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"p",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"h",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"d",valueSchema:new Uint64Schema},{key:"s",valueSchema:new Uint64Schema}])))},{key:"l",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"d",valueSchema:new Uint64Schema},{key:"p",valueSchema:new Uint64Schema}])))},{key:"b",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"i",valueSchema:new Uint64Schema},{key:"n",valueSchema:new ByteArraySchema}])))}]))))},{key:"apap",valueSchema:new OptionalSchema(new ByteArraySchema)},{key:"apsu",valueSchema:new OptionalSchema(new ByteArraySchema)},{key:"apls",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"nui",valueSchema:new Uint64Schema},{key:"nbs",valueSchema:new Uint64Schema}])))},{key:"apgs",valueSchema:new OptionalSchema(new NamedMapSchema(allOmitEmpty([{key:"nui",valueSchema:new Uint64Schema},{key:"nbs",valueSchema:new Uint64Schema}])))},{key:"apep",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"aprv",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"sptype",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"sp",valueSchema:new OptionalSchema(StateProof.encodingSchema)},{key:"spmsg",valueSchema:new OptionalSchema(StateProofMessage.encodingSchema)},{key:"hb",valueSchema:new OptionalSchema(Heartbeat.encodingSchema)}]));const MULTISIG_PREIMG2ADDR_PREFIX=new Uint8Array([77,117,108,116,105,115,105,103,65,100,100,114]),INVALID_MSIG_VERSION_ERROR_MSG="invalid multisig version",INVALID_MSIG_THRESHOLD_ERROR_MSG="bad multisig threshold",INVALID_MSIG_PK_ERROR_MSG="bad multisig public key - wrong length",UNEXPECTED_PK_LEN_ERROR_MSG="nacl public key length is not 32 bytes";function pksFromAddresses(e){return e.map(t=>typeof t=="string"?Address.fromString(t).publicKey:t.publicKey)}function addressFromMultisigPreImg({version:e,threshold:t,pks:r}){if(e!==1||e>255||e<0)throw new Error(INVALID_MSIG_VERSION_ERROR_MSG);if(t===0||r.length===0||t>r.length||t>255)throw new Error(INVALID_MSIG_THRESHOLD_ERROR_MSG);const n=ALGORAND_ADDRESS_BYTE_LENGTH-ALGORAND_CHECKSUM_BYTE_LENGTH;if(n!==PUBLIC_KEY_LENGTH)throw new Error(UNEXPECTED_PK_LEN_ERROR_MSG);const o=new Uint8Array(MULTISIG_PREIMG2ADDR_PREFIX.length+2+n*r.length);o.set(MULTISIG_PREIMG2ADDR_PREFIX,0),o.set([e],MULTISIG_PREIMG2ADDR_PREFIX.length),o.set([t],MULTISIG_PREIMG2ADDR_PREFIX.length+1);for(let i=0;i<r.length;i++){if(r[i].length!==n)throw new Error(INVALID_MSIG_PK_ERROR_MSG);o.set(r[i],MULTISIG_PREIMG2ADDR_PREFIX.length+2+i*n)}return new Address(Uint8Array.from(genericHash(o)))}function verifyMultisig$1(e,t,r){const n=t.v,o=t.thr,i=t.subsig,u=i.map(c=>c.pk);if(t.subsig.length<o)return!1;let a;try{a=addressFromMultisigPreImg({version:n,threshold:o,pks:u}).publicKey}catch{return!1}if(!arrayEqual(a,r))return!1;let s=0;for(const c of i)c.s!==void 0&&(s+=1);if(s<o)return!1;let f=0;for(const c of i)c.s!==void 0&&verify(e,c.s,c.pk)&&(f+=1);return!(f<o)}const ENCODED_SUBSIG_SCHEMA=new NamedMapSchema(allOmitEmpty([{key:"pk",valueSchema:new FixedLengthByteArraySchema(32)},{key:"s",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(64))}]));function encodedSubsigFromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EncodedSubsig: ${e}`);const t={pk:e.get("pk")};return e.get("s")&&(t.s=e.get("s")),t}function encodedSubsigToEncodingData(e){const t=new Map([["pk",e.pk]]);return e.s&&t.set("s",e.s),t}const ENCODED_MULTISIG_SCHEMA=new NamedMapSchema(allOmitEmpty([{key:"v",valueSchema:new Uint64Schema},{key:"thr",valueSchema:new Uint64Schema},{key:"subsig",valueSchema:new ArraySchema(ENCODED_SUBSIG_SCHEMA)}]));function encodedMultiSigFromEncodingData(e){if(!(e instanceof Map))throw new Error(`Invalid decoded EncodedMultiSig: ${e}`);return{v:ensureSafeUnsignedInteger(e.get("v")),thr:ensureSafeUnsignedInteger(e.get("thr")),subsig:e.get("subsig").map(encodedSubsigFromEncodingData)}}function encodedMultiSigToEncodingData(e){return new Map([["v",e.v],["thr",e.thr],["subsig",e.subsig.map(encodedSubsigToEncodingData)]])}const base64regex=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;function sanityCheckProgram(e){if(!e||e.length===0)throw new Error("empty program");const t=10,r=32,n=126,o=u=>r<=u&&u<=n;if(e.every(u=>u===t||o(u))){const u=new TextDecoder().decode(e);throw isValidAddress(u)?new Error("requesting program bytes, get Algorand address"):base64regex.test(u)?new Error("program should not be b64 encoded"):new Error("program bytes are all ASCII printable characters, not looking like Teal byte code")}}const programTag=new TextEncoder().encode("Program"),multisigProgramTag=new TextEncoder().encode("MsigProgram");class LogicSig{constructor(t,r){if(r&&(!Array.isArray(r)||!r.every(o=>o.constructor===Uint8Array)))throw new TypeError("Invalid arguments");let n=[];r!=null&&(n=r.map(o=>new Uint8Array(o))),sanityCheckProgram(t),this.logic=t,this.args=n,this.sig=void 0,this.msig=void 0,this.lmsig=void 0}getEncodingSchema(){return LogicSig.encodingSchema}toEncodingData(){const t=new Map([["l",this.logic],["arg",this.args],["sig",this.sig]]);return this.msig&&t.set("msig",encodedMultiSigToEncodingData(this.msig)),this.lmsig&&t.set("lmsig",encodedMultiSigToEncodingData(this.lmsig)),t}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded logic sig: ${t}`);const r=new LogicSig(t.get("l"),t.get("arg"));return r.sig=t.get("sig"),t.get("msig")&&(r.msig=encodedMultiSigFromEncodingData(t.get("msig"))),t.get("lmsig")&&(r.lmsig=encodedMultiSigFromEncodingData(t.get("lmsig"))),r}verify(t){if([this.sig,this.msig,this.lmsig].filter(Boolean).length>1)return!1;try{sanityCheckProgram(this.logic)}catch{return!1}const n=concatArrays(programTag,this.logic);if(!this.sig&&!this.msig&&!this.lmsig){const o=genericHash(n);return arrayEqual(o,t)}if(this.sig)return verify(n,this.sig,t);if(this.lmsig){const o=addressFromMultisigPreImg({version:this.lmsig.v,threshold:this.lmsig.thr,pks:this.lmsig.subsig.map(u=>u.pk)}),i=concatArrays(multisigProgramTag,o.publicKey,this.logic);return verifyMultisig$1(i,this.lmsig,t)}return this.msig?verifyMultisig$1(n,this.msig,t):!1}address(){const t=concatArrays(programTag,this.logic),r=genericHash(t);return new Address(Uint8Array.from(r))}sign(t,r){if(r==null)this.sig=this.signProgram(t);else{const n=pksFromAddresses(r.addrs).map(u=>({pk:u}));this.lmsig={v:r.version,thr:r.threshold,subsig:n};const[o,i]=this.singleSignMultisig(t,this.lmsig);this.lmsig.subsig[i].s=o}}appendToMultisig(t){if(this.lmsig===void 0)throw new Error("no multisig present");const[r,n]=this.singleSignMultisig(t,this.lmsig);this.lmsig.subsig[n].s=r}signProgram(t){const r=concatArrays(programTag,this.logic);return sign(r,t)}signProgramMultisig(t,r){const n=addressFromMultisigPreImg({version:r.v,threshold:r.thr,pks:r.subsig.map(u=>u.pk)}),o=concatArrays(multisigProgramTag,n.publicKey,this.logic);return sign(o,t)}singleSignMultisig(t,r){let n=-1;const o=keyPairFromSecretKey(t).publicKey;for(let u=0;u<r.subsig.length;u++){const{pk:a}=r.subsig[u];if(arrayEqual(a,o)){n=u;break}}if(n===-1)throw new Error("invalid secret key");return[this.signProgramMultisig(t,r),n]}toByte(){return encodeMsgpack(this)}static fromByte(t){return decodeMsgpack(t,LogicSig)}}LogicSig.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"l",valueSchema:new ByteArraySchema},{key:"arg",valueSchema:new ArraySchema(new ByteArraySchema)},{key:"sig",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(64))},{key:"msig",valueSchema:new OptionalSchema(ENCODED_MULTISIG_SCHEMA)},{key:"lmsig",valueSchema:new OptionalSchema(ENCODED_MULTISIG_SCHEMA)}]));new NamedMapSchema(allOmitEmpty([{key:"lsig",valueSchema:LogicSig.encodingSchema},{key:"sigkey",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(32))}]));new TextEncoder().encode("ProgData");class SignedTransaction{constructor({txn:t,sig:r,msig:n,lsig:o,sgnr:i}){this.txn=t,this.sig=r,this.msig=n,this.lsig=o,this.sgnr=i;let u=0;if(r&&(u+=1),n&&(u+=1),o&&(u+=1),u>1)throw new Error(`SignedTransaction must not have more than 1 signature. Got ${u}`)}getEncodingSchema(){return SignedTransaction.encodingSchema}toEncodingData(){return new Map([["txn",this.txn.toEncodingData()],["sig",this.sig],["msig",this.msig?encodedMultiSigToEncodingData(this.msig):void 0],["lsig",this.lsig?this.lsig.toEncodingData():void 0],["sgnr",this.sgnr]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded SignedTransaction: ${t}`);return new SignedTransaction({txn:Transaction.fromEncodingData(t.get("txn")),sig:t.get("sig"),msig:t.get("msig")?encodedMultiSigFromEncodingData(t.get("msig")):void 0,lsig:t.get("lsig")?LogicSig.fromEncodingData(t.get("lsig")):void 0,sgnr:t.get("sgnr")})}}SignedTransaction.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"txn",valueSchema:Transaction.encodingSchema},{key:"sig",valueSchema:new OptionalSchema(new FixedLengthByteArraySchema(64))},{key:"msig",valueSchema:new OptionalSchema(ENCODED_MULTISIG_SCHEMA)},{key:"lsig",valueSchema:new OptionalSchema(LogicSig.encodingSchema)},{key:"sgnr",valueSchema:new OptionalSchema(new AddressSchema)}]));function decodeSignedTransaction(e){return decodeMsgpack(e,SignedTransaction)}class StateProofTrackingData{constructor(t){this.stateProofVotersCommitment=t.stateProofVotersCommitment,this.stateProofOnlineTotalWeight=t.stateProofOnlineTotalWeight,this.stateProofNextRound=t.stateProofNextRound}getEncodingSchema(){return StateProofTrackingData.encodingSchema}toEncodingData(){return new Map([["v",this.stateProofVotersCommitment],["t",this.stateProofOnlineTotalWeight],["n",this.stateProofNextRound]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded StateProofTrackingData: ${t}`);return new StateProofTrackingData({stateProofVotersCommitment:t.get("v"),stateProofOnlineTotalWeight:t.get("t"),stateProofNextRound:t.get("n")})}}StateProofTrackingData.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"v",valueSchema:new ByteArraySchema},{key:"t",valueSchema:new Uint64Schema},{key:"n",valueSchema:new Uint64Schema}]));class TxnCommitments{constructor(t){this.nativeSha512_256Commitment=t.nativeSha512_256Commitment,this.sha256Commitment=t.sha256Commitment}getEncodingSchema(){return TxnCommitments.encodingSchema}toEncodingData(){return new Map([["txn",this.nativeSha512_256Commitment],["txn256",this.sha256Commitment]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded TxnCommitments: ${t}`);return new TxnCommitments({nativeSha512_256Commitment:t.get("txn"),sha256Commitment:t.get("txn256")})}}TxnCommitments.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"txn",valueSchema:new FixedLengthByteArraySchema(32)},{key:"txn256",valueSchema:new FixedLengthByteArraySchema(32)}]));class RewardState{constructor(t){this.feeSink=t.feeSink,this.rewardsPool=t.rewardsPool,this.rewardsLevel=t.rewardsLevel,this.rewardsRate=t.rewardsRate,this.rewardsResidue=t.rewardsResidue,this.rewardsRecalculationRound=t.rewardsRecalculationRound}getEncodingSchema(){return RewardState.encodingSchema}toEncodingData(){return new Map([["fees",this.feeSink],["rwd",this.rewardsPool],["earn",this.rewardsLevel],["rate",this.rewardsRate],["frac",this.rewardsResidue],["rwcalr",this.rewardsRecalculationRound]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded RewardState: ${t}`);return new RewardState({feeSink:t.get("fees"),rewardsPool:t.get("rwd"),rewardsLevel:t.get("earn"),rewardsRate:t.get("rate"),rewardsResidue:t.get("frac"),rewardsRecalculationRound:t.get("rwcalr")})}}RewardState.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"fees",valueSchema:new AddressSchema},{key:"rwd",valueSchema:new AddressSchema},{key:"earn",valueSchema:new Uint64Schema},{key:"rate",valueSchema:new Uint64Schema},{key:"frac",valueSchema:new Uint64Schema},{key:"rwcalr",valueSchema:new Uint64Schema}]));class UpgradeState{constructor(t){this.currentProtocol=t.currentProtocol,this.nextProtocol=t.nextProtocol,this.nextProtocolApprovals=t.nextProtocolApprovals,this.nextProtocolVoteBefore=t.nextProtocolVoteBefore,this.nextProtocolSwitchOn=t.nextProtocolSwitchOn}getEncodingSchema(){return UpgradeState.encodingSchema}toEncodingData(){return new Map([["proto",this.currentProtocol],["nextproto",this.nextProtocol],["nextyes",this.nextProtocolApprovals],["nextbefore",this.nextProtocolVoteBefore],["nextswitch",this.nextProtocolSwitchOn]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded UpgradeState: ${t}`);return new UpgradeState({currentProtocol:t.get("proto"),nextProtocol:t.get("nextproto"),nextProtocolApprovals:t.get("nextyes"),nextProtocolVoteBefore:t.get("nextbefore"),nextProtocolSwitchOn:t.get("nextswitch")})}}UpgradeState.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"proto",valueSchema:new StringSchema},{key:"nextproto",valueSchema:new StringSchema},{key:"nextyes",valueSchema:new Uint64Schema},{key:"nextbefore",valueSchema:new Uint64Schema},{key:"nextswitch",valueSchema:new Uint64Schema}]));class UpgradeVote{constructor(t){this.upgradePropose=t.upgradePropose,this.upgradeDelay=t.upgradeDelay,this.upgradeApprove=t.upgradeApprove}getEncodingSchema(){return UpgradeVote.encodingSchema}toEncodingData(){return new Map([["upgradeprop",this.upgradePropose],["upgradedelay",this.upgradeDelay],["upgradeyes",this.upgradeApprove]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded UpgradeVote: ${t}`);return new UpgradeVote({upgradePropose:t.get("upgradeprop"),upgradeDelay:t.get("upgradedelay"),upgradeApprove:t.get("upgradeyes")})}}UpgradeVote.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"upgradeprop",valueSchema:new StringSchema},{key:"upgradedelay",valueSchema:new Uint64Schema},{key:"upgradeyes",valueSchema:new BooleanSchema}]));class ParticipationUpdates{constructor(t){this.expiredParticipationAccounts=t.expiredParticipationAccounts,this.absentParticipationAccounts=t.absentParticipationAccounts}getEncodingSchema(){return ParticipationUpdates.encodingSchema}toEncodingData(){return new Map([["partupdrmv",this.expiredParticipationAccounts],["partupdabs",this.absentParticipationAccounts]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded ParticipationUpdates: ${t}`);return new ParticipationUpdates({expiredParticipationAccounts:t.get("partupdrmv"),absentParticipationAccounts:t.get("partupdabs")})}}ParticipationUpdates.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"partupdrmv",valueSchema:new ArraySchema(new AddressSchema)},{key:"partupdabs",valueSchema:new ArraySchema(new AddressSchema)}]));class BlockHeader{constructor(t){this.round=t.round,this.branch=t.branch,this.seed=t.seed,this.txnCommitments=t.txnCommitments,this.timestamp=t.timestamp,this.genesisID=t.genesisID,this.genesisHash=t.genesisHash,this.proposer=t.proposer,this.feesCollected=t.feesCollected,this.bonus=t.bonus,this.proposerPayout=t.proposerPayout,this.rewardState=t.rewardState,this.upgradeState=t.upgradeState,this.upgradeVote=t.upgradeVote,this.txnCounter=t.txnCounter,this.stateproofTracking=t.stateproofTracking,this.participationUpdates=t.participationUpdates}getEncodingSchema(){return BlockHeader.encodingSchema}toEncodingData(){const t=new Map([["rnd",this.round],["prev",this.branch],["seed",this.seed],["ts",this.timestamp],["gen",this.genesisID],["gh",this.genesisHash],["prp",this.proposer],["fc",this.feesCollected],["bi",this.bonus],["pp",this.proposerPayout],["tc",this.txnCounter],["spt",convertMap(this.stateproofTracking,(r,n)=>[r,n.toEncodingData()])]]);return combineMaps(t,this.txnCommitments.toEncodingData(),this.rewardState.toEncodingData(),this.upgradeState.toEncodingData(),this.upgradeVote.toEncodingData(),this.participationUpdates.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded BlockHeader: ${t}`);return new BlockHeader({round:t.get("rnd"),branch:t.get("prev"),seed:t.get("seed"),txnCommitments:TxnCommitments.fromEncodingData(t),timestamp:t.get("ts"),genesisID:t.get("gen"),genesisHash:t.get("gh"),proposer:t.get("prp"),feesCollected:t.get("fc"),bonus:t.get("bi"),proposerPayout:t.get("pp"),rewardState:RewardState.fromEncodingData(t),upgradeState:UpgradeState.fromEncodingData(t),upgradeVote:UpgradeVote.fromEncodingData(t),txnCounter:t.get("tc"),stateproofTracking:convertMap(t.get("spt"),(r,n)=>[Number(r),StateProofTrackingData.fromEncodingData(n)]),participationUpdates:ParticipationUpdates.fromEncodingData(t)})}}BlockHeader.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"rnd",valueSchema:new Uint64Schema},{key:"prev",valueSchema:new BlockHashSchema},{key:"seed",valueSchema:new ByteArraySchema},{key:"",valueSchema:TxnCommitments.encodingSchema,embedded:!0},{key:"ts",valueSchema:new Uint64Schema},{key:"gen",valueSchema:new StringSchema},{key:"gh",valueSchema:new FixedLengthByteArraySchema(32)},{key:"prp",valueSchema:new AddressSchema},{key:"fc",valueSchema:new Uint64Schema},{key:"bi",valueSchema:new Uint64Schema},{key:"pp",valueSchema:new Uint64Schema},{key:"",valueSchema:RewardState.encodingSchema,embedded:!0},{key:"",valueSchema:UpgradeState.encodingSchema,embedded:!0},{key:"",valueSchema:UpgradeVote.encodingSchema,embedded:!0},{key:"tc",valueSchema:new Uint64Schema},{key:"spt",valueSchema:new Uint64MapSchema(StateProofTrackingData.encodingSchema)},{key:"",valueSchema:ParticipationUpdates.encodingSchema,embedded:!0}]));class ValueDelta{constructor(t){this.action=t.action,this.bytes=t.bytes,this.uint=t.uint}getEncodingSchema(){return ValueDelta.encodingSchema}toEncodingData(){return new Map([["at",this.action],["bs",this.bytes],["ui",this.uint]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded ValueDelta: ${t}`);return new ValueDelta({action:Number(t.get("at")),bytes:t.get("bs"),uint:t.get("ui")})}}ValueDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"at",valueSchema:new Uint64Schema},{key:"bs",valueSchema:new SpecialCaseBinaryStringSchema},{key:"ui",valueSchema:new Uint64Schema}]));class EvalDelta{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new NamedMapSchema([]),this.encodingSchemaValue.pushEntries(...allOmitEmpty([{key:"gd",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringMapSchema(ValueDelta.encodingSchema))},{key:"ld",valueSchema:new OptionalSchema(new Uint64MapSchema(new SpecialCaseBinaryStringMapSchema(ValueDelta.encodingSchema)))},{key:"sa",valueSchema:new OptionalSchema(new ArraySchema(new AddressSchema))},{key:"lg",valueSchema:new OptionalSchema(new ArraySchema(new SpecialCaseBinaryStringSchema))},{key:"itx",valueSchema:new OptionalSchema(new ArraySchema(SignedTxnWithAD.encodingSchema))}]))),this.encodingSchemaValue}constructor(t){this.globalDelta=t.globalDelta??new Map,this.localDeltas=t.localDeltas??new Map,this.sharedAccts=t.sharedAccts??[],this.logs=t.logs??[],this.innerTxns=t.innerTxns??[]}getEncodingSchema(){return EvalDelta.encodingSchema}toEncodingData(){return new Map([["gd",convertMap(this.globalDelta,(t,r)=>[t,r.toEncodingData()])],["ld",convertMap(this.localDeltas,(t,r)=>[t,convertMap(r,(n,o)=>[n,o.toEncodingData()])])],["sa",this.sharedAccts],["lg",this.logs],["itx",this.innerTxns.map(t=>t.toEncodingData())]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded EvalDelta: ${t}`);return new EvalDelta({globalDelta:t.get("gd")?convertMap(t.get("gd"),(r,n)=>[r,ValueDelta.fromEncodingData(n)]):void 0,localDeltas:t.get("ld")?convertMap(t.get("ld"),(r,n)=>[Number(r),convertMap(n,(o,i)=>[o,ValueDelta.fromEncodingData(i)])]):void 0,sharedAccts:t.get("sa"),logs:t.get("lg"),innerTxns:(t.get("itx")??[]).map(SignedTxnWithAD.fromEncodingData)})}}class ApplyData{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new NamedMapSchema([]),this.encodingSchemaValue.pushEntries(...allOmitEmpty([{key:"ca",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"aca",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"rs",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"rr",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"rc",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"dt",valueSchema:new OptionalSchema(EvalDelta.encodingSchema)},{key:"caid",valueSchema:new OptionalSchema(new Uint64Schema)},{key:"apid",valueSchema:new OptionalSchema(new Uint64Schema)}]))),this.encodingSchemaValue}constructor(t){this.closingAmount=t.closingAmount,this.assetClosingAmount=t.assetClosingAmount,this.senderRewards=t.senderRewards,this.receiverRewards=t.receiverRewards,this.closeRewards=t.closeRewards,this.evalDelta=t.evalDelta,this.configAsset=t.configAsset,this.applicationID=t.applicationID}getEncodingSchema(){return ApplyData.encodingSchema}toEncodingData(){return new Map([["ca",this.closingAmount],["aca",this.assetClosingAmount],["rs",this.senderRewards],["rr",this.receiverRewards],["rc",this.closeRewards],["dt",this.evalDelta?this.evalDelta.toEncodingData():void 0],["caid",this.configAsset],["apid",this.applicationID]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded ApplyData: ${t}`);return new ApplyData({closingAmount:t.get("ca"),assetClosingAmount:t.get("aca"),senderRewards:t.get("rs"),receiverRewards:t.get("rr"),closeRewards:t.get("rc"),evalDelta:t.get("dt")?EvalDelta.fromEncodingData(t.get("dt")):void 0,configAsset:t.get("caid"),applicationID:t.get("apid")})}}class SignedTxnWithAD{static get encodingSchema(){return this.encodingSchemaValue||(this.encodingSchemaValue=new NamedMapSchema([]),this.encodingSchemaValue.pushEntries(...allOmitEmpty([{key:"",valueSchema:SignedTransaction.encodingSchema,embedded:!0},{key:"",valueSchema:ApplyData.encodingSchema,embedded:!0}]))),this.encodingSchemaValue}constructor(t){this.signedTxn=t.signedTxn,this.applyData=t.applyData}getEncodingSchema(){return SignedTxnWithAD.encodingSchema}toEncodingData(){return combineMaps(this.signedTxn.toEncodingData(),this.applyData.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded SignedTxnWithAD: ${t}`);return new SignedTxnWithAD({signedTxn:SignedTransaction.fromEncodingData(t),applyData:ApplyData.fromEncodingData(t)})}}class SignedTxnInBlock{constructor(t){this.signedTxn=t.signedTxn,this.hasGenesisID=t.hasGenesisID,this.hasGenesisHash=t.hasGenesisHash}getEncodingSchema(){return SignedTxnInBlock.encodingSchema}toEncodingData(){const t=new Map([["hgi",this.hasGenesisID],["hgh",this.hasGenesisHash]]);return combineMaps(t,this.signedTxn.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded SignedTxnInBlock: ${t}`);return new SignedTxnInBlock({signedTxn:SignedTxnWithAD.fromEncodingData(t),hasGenesisID:t.get("hgi"),hasGenesisHash:t.get("hgh")})}}SignedTxnInBlock.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"",valueSchema:SignedTxnWithAD.encodingSchema,embedded:!0},{key:"hgi",valueSchema:new BooleanSchema},{key:"hgh",valueSchema:new BooleanSchema}]));new NamedMapSchema(allOmitEmpty([{key:"",valueSchema:BlockHeader.encodingSchema,embedded:!0},{key:"txns",valueSchema:new ArraySchema(SignedTxnInBlock.encodingSchema)}]));class TealValue{constructor(t){this.type=t.type,this.bytes=t.bytes,this.uint=t.uint}getEncodingSchema(){return TealValue.encodingSchema}toEncodingData(){return new Map([["tt",this.type],["tb",this.bytes],["ui",this.uint]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded TealValue: ${t}`);return new TealValue({type:Number(t.get("tt")),bytes:t.get("tb"),uint:t.get("ui")})}}TealValue.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"tt",valueSchema:new Uint64Schema},{key:"tb",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringSchema)},{key:"ui",valueSchema:new OptionalSchema(new Uint64Schema)}]));class StateSchema{constructor(t){this.numUints=t.numUints,this.numByteSlices=t.numByteSlices}getEncodingSchema(){return StateSchema.encodingSchema}toEncodingData(){return new Map([["nui",this.numUints],["nbs",this.numByteSlices]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded StateSchema: ${t}`);return new StateSchema({numUints:Number(t.get("nui")),numByteSlices:Number(t.get("nbs"))})}}StateSchema.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"nui",valueSchema:new Uint64Schema},{key:"nbs",valueSchema:new Uint64Schema}]));class AppParams{constructor(t){this.approvalProgram=t.approvalProgram,this.clearStateProgram=t.clearStateProgram,this.globalState=t.globalState,this.localStateSchema=t.localStateSchema,this.globalStateSchema=t.globalStateSchema,this.extraProgramPages=t.extraProgramPages}getEncodingSchema(){return AppParams.encodingSchema}toEncodingData(){return new Map([["approv",this.approvalProgram],["clearp",this.clearStateProgram],["gs",convertMap(this.globalState,(t,r)=>[t,r.toEncodingData()])],["lsch",this.localStateSchema.toEncodingData()],["gsch",this.globalStateSchema.toEncodingData()],["epp",this.extraProgramPages]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppParams: ${t}`);return new AppParams({approvalProgram:t.get("approv"),clearStateProgram:t.get("clearp"),globalState:convertMap(t.get("gs"),(r,n)=>[r,TealValue.fromEncodingData(n)]),localStateSchema:StateSchema.fromEncodingData(t.get("lsch")),globalStateSchema:StateSchema.fromEncodingData(t.get("gsch")),extraProgramPages:Number(t.get("epp"))})}}AppParams.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"approv",valueSchema:new ByteArraySchema},{key:"clearp",valueSchema:new ByteArraySchema},{key:"gs",valueSchema:new SpecialCaseBinaryStringMapSchema(TealValue.encodingSchema)},{key:"lsch",valueSchema:StateSchema.encodingSchema},{key:"gsch",valueSchema:StateSchema.encodingSchema},{key:"epp",valueSchema:new Uint64Schema}]));class AppLocalState{constructor(t){this.schema=t.schema,this.keyValue=t.keyValue}getEncodingSchema(){return AppLocalState.encodingSchema}toEncodingData(){return new Map([["hsch",this.schema.toEncodingData()],["tkv",convertMap(this.keyValue,(t,r)=>[t,r.toEncodingData()])]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppLocalState: ${t}`);return new AppLocalState({schema:StateSchema.fromEncodingData(t.get("hsch")),keyValue:convertMap(t.get("tkv"),(r,n)=>[r,TealValue.fromEncodingData(n)])})}}AppLocalState.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"hsch",valueSchema:StateSchema.encodingSchema},{key:"tkv",valueSchema:new SpecialCaseBinaryStringMapSchema(TealValue.encodingSchema)}]));class AppLocalStateDelta{constructor(t){this.localState=t.localState,this.deleted=t.deleted}getEncodingSchema(){return AppLocalStateDelta.encodingSchema}toEncodingData(){return new Map([["LocalState",this.localState?this.localState.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppLocalStateDelta: ${t}`);return new AppLocalStateDelta({localState:t.get("LocalState")?AppLocalState.fromEncodingData(t.get("LocalState")):void 0,deleted:t.get("Deleted")})}}AppLocalStateDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"LocalState",valueSchema:new OptionalSchema(AppLocalState.encodingSchema)},{key:"Deleted",valueSchema:new BooleanSchema}]));class AppParamsDelta{constructor(t){this.params=t.params,this.deleted=t.deleted}getEncodingSchema(){return AppParamsDelta.encodingSchema}toEncodingData(){return new Map([["Params",this.params?this.params.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppParamsDelta: ${t}`);return new AppParamsDelta({params:t.get("Params")?AppParams.fromEncodingData(t.get("Params")):void 0,deleted:t.get("Deleted")})}}AppParamsDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Params",valueSchema:new OptionalSchema(AppParams.encodingSchema)},{key:"Deleted",valueSchema:new BooleanSchema}]));class AppResourceRecord{constructor(t){this.id=t.id,this.address=t.address,this.params=t.params,this.state=t.state}getEncodingSchema(){return AppResourceRecord.encodingSchema}toEncodingData(){return new Map([["Aidx",this.id],["Addr",this.address],["Params",this.params.toEncodingData()],["State",this.state.toEncodingData()]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AppResourceRecord: ${t}`);return new AppResourceRecord({id:t.get("Aidx"),address:t.get("Addr"),params:AppParamsDelta.fromEncodingData(t.get("Params")),state:AppLocalStateDelta.fromEncodingData(t.get("State"))})}}AppResourceRecord.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Aidx",valueSchema:new Uint64Schema},{key:"Addr",valueSchema:new AddressSchema},{key:"Params",valueSchema:AppParamsDelta.encodingSchema},{key:"State",valueSchema:AppLocalStateDelta.encodingSchema}]));class AssetHolding{constructor(t){this.amount=t.amount,this.frozen=t.frozen}getEncodingSchema(){return AssetHolding.encodingSchema}toEncodingData(){return new Map([["a",this.amount],["f",this.frozen]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetHolding: ${t}`);return new AssetHolding({amount:t.get("a"),frozen:t.get("f")})}}AssetHolding.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"a",valueSchema:new Uint64Schema},{key:"f",valueSchema:new BooleanSchema}]));class AssetHoldingDelta{constructor(t){this.holding=t.holding,this.deleted=t.deleted}getEncodingSchema(){return AssetHoldingDelta.encodingSchema}toEncodingData(){return new Map([["Holding",this.holding?this.holding.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetHoldingDelta: ${t}`);return new AssetHoldingDelta({holding:t.get("Holding")?AssetHolding.fromEncodingData(t.get("Holding")):void 0,deleted:t.get("Deleted")})}}AssetHoldingDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Holding",valueSchema:new OptionalSchema(AssetHolding.encodingSchema)},{key:"Deleted",valueSchema:new BooleanSchema}]));class AssetParams{constructor(t){this.total=t.total,this.decimals=t.decimals,this.defaultFrozen=t.defaultFrozen,this.unitName=t.unitName,this.assetName=t.assetName,this.url=t.url,this.metadataHash=t.metadataHash,this.manager=t.manager,this.reserve=t.reserve,this.freeze=t.freeze,this.clawback=t.clawback}getEncodingSchema(){return AssetParams.encodingSchema}toEncodingData(){return new Map([["t",this.total],["dc",this.decimals],["df",this.defaultFrozen],["un",this.unitName],["an",this.assetName],["au",this.url],["am",this.metadataHash],["m",this.manager],["r",this.reserve],["f",this.freeze],["c",this.clawback]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetParams: ${t}`);return new AssetParams({total:t.get("t"),decimals:t.get("dc"),defaultFrozen:t.get("df"),unitName:t.get("un"),assetName:t.get("an"),url:t.get("au"),metadataHash:t.get("am"),manager:t.get("m"),reserve:t.get("r"),freeze:t.get("f"),clawback:t.get("c")})}}AssetParams.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"t",valueSchema:new Uint64Schema},{key:"dc",valueSchema:new Uint64Schema},{key:"df",valueSchema:new BooleanSchema},{key:"un",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringSchema)},{key:"an",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringSchema)},{key:"au",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringSchema)},{key:"am",valueSchema:new FixedLengthByteArraySchema(32)},{key:"m",valueSchema:new OptionalSchema(new AddressSchema)},{key:"r",valueSchema:new OptionalSchema(new AddressSchema)},{key:"f",valueSchema:new OptionalSchema(new AddressSchema)},{key:"c",valueSchema:new OptionalSchema(new AddressSchema)}]));class AssetParamsDelta{constructor(t){this.params=t.params,this.deleted=t.deleted}getEncodingSchema(){return AssetParamsDelta.encodingSchema}toEncodingData(){return new Map([["Params",this.params?this.params.toEncodingData():void 0],["Deleted",this.deleted]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetParamsDelta: ${t}`);return new AssetParamsDelta({params:t.get("Params")?AssetParams.fromEncodingData(t.get("Params")):void 0,deleted:t.get("Deleted")})}}AssetParamsDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Params",valueSchema:new OptionalSchema(AssetParams.encodingSchema)},{key:"Deleted",valueSchema:new BooleanSchema}]));class AssetResourceRecord{constructor(t){this.id=t.id,this.address=t.address,this.params=t.params,this.holding=t.holding}getEncodingSchema(){return AssetResourceRecord.encodingSchema}toEncodingData(){return new Map([["Aidx",this.id],["Addr",this.address],["Params",this.params.toEncodingData()],["Holding",this.holding.toEncodingData()]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AssetResourceRecord: ${t}`);return new AssetResourceRecord({id:t.get("Aidx"),address:t.get("Addr"),params:AssetParamsDelta.fromEncodingData(t.get("Params")),holding:AssetHoldingDelta.fromEncodingData(t.get("Holding"))})}}AssetResourceRecord.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Aidx",valueSchema:new Uint64Schema},{key:"Addr",valueSchema:new AddressSchema},{key:"Params",valueSchema:AssetParamsDelta.encodingSchema},{key:"Holding",valueSchema:AssetHoldingDelta.encodingSchema}]));class VotingData{constructor(t){this.voteID=t.voteID,this.selectionID=t.selectionID,this.stateProofID=t.stateProofID,this.voteFirstValid=t.voteFirstValid,this.voteLastValid=t.voteLastValid,this.voteKeyDilution=t.voteKeyDilution}getEncodingSchema(){return VotingData.encodingSchema}toEncodingData(){return new Map([["VoteID",this.voteID],["SelectionID",this.selectionID],["StateProofID",this.stateProofID],["VoteFirstValid",this.voteFirstValid],["VoteLastValid",this.voteLastValid],["VoteKeyDilution",this.voteKeyDilution]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded VotingData: ${t}`);return new VotingData({voteID:t.get("VoteID"),selectionID:t.get("SelectionID"),stateProofID:t.get("StateProofID"),voteFirstValid:t.get("VoteFirstValid"),voteLastValid:t.get("VoteLastValid"),voteKeyDilution:t.get("VoteKeyDilution")})}}VotingData.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"VoteID",valueSchema:new FixedLengthByteArraySchema(32)},{key:"SelectionID",valueSchema:new FixedLengthByteArraySchema(32)},{key:"StateProofID",valueSchema:new FixedLengthByteArraySchema(64)},{key:"VoteFirstValid",valueSchema:new Uint64Schema},{key:"VoteLastValid",valueSchema:new Uint64Schema},{key:"VoteKeyDilution",valueSchema:new Uint64Schema}]));class AccountBaseData{constructor(t){this.status=t.status,this.microAlgos=t.microAlgos,this.rewardsBase=t.rewardsBase,this.rewardedMicroAlgos=t.rewardedMicroAlgos,this.authAddr=t.authAddr,this.incentiveEligible=t.incentiveEligible,this.totalAppSchema=t.totalAppSchema,this.totalExtraAppPages=t.totalExtraAppPages,this.totalAppParams=t.totalAppParams,this.totalAppLocalStates=t.totalAppLocalStates,this.totalAssetParams=t.totalAssetParams,this.totalAssets=t.totalAssets,this.totalBoxes=t.totalBoxes,this.totalBoxBytes=t.totalBoxBytes,this.lastProposed=t.lastProposed,this.lastHeartbeat=t.lastHeartbeat}getEncodingSchema(){return AccountBaseData.encodingSchema}toEncodingData(){return new Map([["Status",this.status],["MicroAlgos",this.microAlgos],["RewardsBase",this.rewardsBase],["RewardedMicroAlgos",this.rewardedMicroAlgos],["AuthAddr",this.authAddr],["IncentiveEligible",this.incentiveEligible],["TotalAppSchema",this.totalAppSchema.toEncodingData()],["TotalExtraAppPages",this.totalExtraAppPages],["TotalAppParams",this.totalAppParams],["TotalAppLocalStates",this.totalAppLocalStates],["TotalAssetParams",this.totalAssetParams],["TotalAssets",this.totalAssets],["TotalBoxes",this.totalBoxes],["TotalBoxBytes",this.totalBoxBytes],["LastProposed",this.lastProposed],["LastHeartbeat",this.lastHeartbeat]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AccountBaseData: ${t}`);return new AccountBaseData({status:Number(t.get("Status")),microAlgos:t.get("MicroAlgos"),rewardsBase:t.get("RewardsBase"),rewardedMicroAlgos:t.get("RewardedMicroAlgos"),authAddr:t.get("AuthAddr"),incentiveEligible:t.get("IncentiveEligible"),totalAppSchema:StateSchema.fromEncodingData(t.get("TotalAppSchema")),totalExtraAppPages:Number(t.get("TotalExtraAppPages")),totalAppParams:t.get("TotalAppParams"),totalAppLocalStates:t.get("TotalAppLocalStates"),totalAssetParams:t.get("TotalAssetParams"),totalAssets:t.get("TotalAssets"),totalBoxes:t.get("TotalBoxes"),totalBoxBytes:t.get("TotalBoxBytes"),lastProposed:t.get("LastProposed"),lastHeartbeat:t.get("LastHeartbeat")})}}AccountBaseData.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Status",valueSchema:new Uint64Schema},{key:"MicroAlgos",valueSchema:new Uint64Schema},{key:"RewardsBase",valueSchema:new Uint64Schema},{key:"RewardedMicroAlgos",valueSchema:new Uint64Schema},{key:"AuthAddr",valueSchema:new AddressSchema},{key:"IncentiveEligible",valueSchema:new BooleanSchema},{key:"TotalAppSchema",valueSchema:StateSchema.encodingSchema},{key:"TotalExtraAppPages",valueSchema:new Uint64Schema},{key:"TotalAppParams",valueSchema:new Uint64Schema},{key:"TotalAppLocalStates",valueSchema:new Uint64Schema},{key:"TotalAssetParams",valueSchema:new Uint64Schema},{key:"TotalAssets",valueSchema:new Uint64Schema},{key:"TotalBoxes",valueSchema:new Uint64Schema},{key:"TotalBoxBytes",valueSchema:new Uint64Schema},{key:"LastProposed",valueSchema:new Uint64Schema},{key:"LastHeartbeat",valueSchema:new Uint64Schema}]));class AccountData{constructor(t){this.accountBaseData=t.accountBaseData,this.votingData=t.votingData}getEncodingSchema(){return AccountData.encodingSchema}toEncodingData(){return combineMaps(this.accountBaseData.toEncodingData(),this.votingData.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AccountData: ${t}`);return new AccountData({accountBaseData:AccountBaseData.fromEncodingData(t),votingData:VotingData.fromEncodingData(t)})}}AccountData.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"",valueSchema:AccountBaseData.encodingSchema,embedded:!0},{key:"",valueSchema:VotingData.encodingSchema,embedded:!0}]));class BalanceRecord{constructor(t){this.addr=t.addr,this.accountData=t.accountData}getEncodingSchema(){return BalanceRecord.encodingSchema}toEncodingData(){return combineMaps(new Map([["Addr",this.addr]]),this.accountData.toEncodingData())}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded BalanceRecord: ${t}`);return new BalanceRecord({addr:t.get("Addr"),accountData:AccountData.fromEncodingData(t)})}}BalanceRecord.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Addr",valueSchema:new AddressSchema},{key:"",valueSchema:AccountData.encodingSchema,embedded:!0}]));class AccountDeltas{constructor(t){this.accounts=t.accounts,this.appResources=t.appResources,this.assetResources=t.assetResources}getEncodingSchema(){return AccountDeltas.encodingSchema}toEncodingData(){return new Map([["Accts",this.accounts.map(t=>t.toEncodingData())],["AppResources",this.appResources.length===0?void 0:this.appResources.map(t=>t.toEncodingData())],["AssetResources",this.assetResources.length===0?void 0:this.assetResources.map(t=>t.toEncodingData())]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AccountDeltas: ${t}`);return new AccountDeltas({accounts:(t.get("Accts")??[]).map(BalanceRecord.fromEncodingData),appResources:(t.get("AppResources")??[]).map(AppResourceRecord.fromEncodingData),assetResources:(t.get("AssetResources")??[]).map(AssetResourceRecord.fromEncodingData)})}}AccountDeltas.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Accts",valueSchema:new ArraySchema(BalanceRecord.encodingSchema)},{key:"AppResources",valueSchema:new OptionalSchema(new ArraySchema(AppResourceRecord.encodingSchema))},{key:"AssetResources",valueSchema:new OptionalSchema(new ArraySchema(AssetResourceRecord.encodingSchema))}]));class KvValueDelta{constructor(t){this.data=t.data,this.oldData=t.oldData}getEncodingSchema(){return KvValueDelta.encodingSchema}toEncodingData(){return new Map([["Data",this.data],["OldData",this.oldData]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded KvValueDelta: ${t}`);return new KvValueDelta({data:t.get("Data"),oldData:t.get("OldData")})}}KvValueDelta.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Data",valueSchema:new OptionalSchema(new ByteArraySchema)},{key:"OldData",valueSchema:new OptionalSchema(new ByteArraySchema)}]));class IncludedTransactions{constructor(t){this.lastValid=t.lastValid,this.intra=t.intra}getEncodingSchema(){return IncludedTransactions.encodingSchema}toEncodingData(){return new Map([["LastValid",this.lastValid],["Intra",this.intra]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded IncludedTransactions: ${t}`);return new IncludedTransactions({lastValid:t.get("LastValid"),intra:Number(t.get("Intra"))})}}IncludedTransactions.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"LastValid",valueSchema:new Uint64Schema},{key:"Intra",valueSchema:new Uint64Schema}]));class ModifiedCreatable{constructor(t){this.creatableType=t.creatableType,this.created=t.created,this.creator=t.creator,this.ndeltas=t.ndeltas}getEncodingSchema(){return ModifiedCreatable.encodingSchema}toEncodingData(){return new Map([["Ctype",this.creatableType],["Created",this.created],["Creator",this.creator],["Ndeltas",this.ndeltas]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded ModifiedCreatable: ${t}`);return new ModifiedCreatable({creatableType:Number(t.get("Ctype")),created:t.get("Created"),creator:t.get("Creator"),ndeltas:Number(t.get("Ndeltas"))})}}ModifiedCreatable.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"Ctype",valueSchema:new Uint64Schema},{key:"Created",valueSchema:new BooleanSchema},{key:"Creator",valueSchema:new AddressSchema},{key:"Ndeltas",valueSchema:new Uint64Schema}]));class AlgoCount{constructor(t){this.money=t.money,this.rewardUnits=t.rewardUnits}getEncodingSchema(){return AlgoCount.encodingSchema}toEncodingData(){return new Map([["mon",this.money],["rwd",this.rewardUnits]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AlgoCount: ${t}`);return new AlgoCount({money:t.get("mon"),rewardUnits:t.get("rwd")})}}AlgoCount.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"mon",valueSchema:new Uint64Schema},{key:"rwd",valueSchema:new Uint64Schema}]));class AccountTotals{constructor(t){this.online=t.online,this.offline=t.offline,this.notParticipating=t.notParticipating,this.rewardsLevel=t.rewardsLevel}getEncodingSchema(){return AccountTotals.encodingSchema}toEncodingData(){return new Map([["online",this.online.toEncodingData()],["offline",this.offline.toEncodingData()],["notpart",this.notParticipating.toEncodingData()],["rwdlvl",this.rewardsLevel]])}static fromEncodingData(t){if(!(t instanceof Map))throw new Error(`Invalid decoded AccountTotals: ${t}`);return new AccountTotals({online:AlgoCount.fromEncodingData(t.get("online")),offline:AlgoCount.fromEncodingData(t.get("offline")),notParticipating:AlgoCount.fromEncodingData(t.get("notpart")),rewardsLevel:t.get("rwdlvl")})}}AccountTotals.encodingSchema=new NamedMapSchema(allOmitEmpty([{key:"online",valueSchema:AlgoCount.encodingSchema},{key:"offline",valueSchema:AlgoCount.encodingSchema},{key:"notpart",valueSchema:AlgoCount.encodingSchema},{key:"rwdlvl",valueSchema:new Uint64Schema}]));new NamedMapSchema(allOmitEmpty([{key:"Accts",valueSchema:AccountDeltas.encodingSchema},{key:"KvMods",valueSchema:new OptionalSchema(new SpecialCaseBinaryStringMapSchema(KvValueDelta.encodingSchema))},{key:"Txids",valueSchema:new ByteArrayMapSchema(IncludedTransactions.encodingSchema)},{key:"Txleases",valueSchema:new OptionalSchema(new UntypedSchema)},{key:"Creatables",valueSchema:new OptionalSchema(new Uint64MapSchema(ModifiedCreatable.encodingSchema))},{key:"Hdr",valueSchema:BlockHeader.encodingSchema},{key:"StateProofNext",valueSchema:new Uint64Schema},{key:"PrevTimestamp",valueSchema:new Uint64Schema},{key:"Totals",valueSchema:AccountTotals.encodingSchema}]));new TextEncoder().encode("TG");"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach(function(e,t){});function makePaymentTxnWithSuggestedParamsFromObject({sender:e,receiver:t,amount:r,closeRemainderTo:n,suggestedParams:o,note:i,lease:u,rekeyTo:a}){return new Transaction({type:TransactionType.pay,sender:e,note:i,lease:u,rekeyTo:a,suggestedParams:o,paymentParams:{receiver:t,amount:r,closeRemainderTo:n}})}var ABITransactionType;(function(e){e.any="txn",e.pay="pay",e.keyreg="keyreg",e.acfg="acfg",e.axfer="axfer",e.afrz="afrz",e.appl="appl"})(ABITransactionType||(ABITransactionType={}));var ABIReferenceType;(function(e){e.account="account",e.application="application",e.asset="asset"})(ABIReferenceType||(ABIReferenceType={}));var AtomicTransactionComposerStatus;(function(e){e[e.BUILDING=0]="BUILDING",e[e.BUILT=1]="BUILT",e[e.SIGNED=2]="SIGNED",e[e.SUBMITTED=3]="SUBMITTED",e[e.COMMITTED=4]="COMMITTED"})(AtomicTransactionComposerStatus||(AtomicTransactionComposerStatus={}));const SIGN_BYTES_PREFIX=Uint8Array.from([77,88]);function verifyBytes(e,t,r){const n=concatArrays(SIGN_BYTES_PREFIX,e),o=typeof r=="string"?Address.fromString(r):r;return verify(n,t,o.publicKey)}function hexStringToBytes(e){if(!/^[0-9a-fA-F]+$/.test(e))throw new Error("Non-hex digits found in hex string");const t=[];e.length%2!==0&&(e="0"+e);for(let r=0;r<e.length;r+=2){const n=e.slice(r,r+2);t.push(parseInt(n,16))}return t}function hexStringToUint8Array(e){return new Uint8Array(hexStringToBytes(e))}class AlgorandCrypto{constructor(){this.verifyAddress=t=>Check(TypeboxHelpers.Algorand.Address,t),this.verifySignature=async(t,r,n)=>{try{if(!this.verifyAddress(t))return!1;const i=(d=>new Uint8Array(d.match(/.{1,2}/g).map(p=>parseInt(p,16))))(n),u=new TextEncoder,a=u.encode(r),s=u.encode("MX"),f=new Uint8Array(s.length+a.length);f.set(s),f.set(a,s.length);const c=verifyBytes(a,i,t);return console.log("TODO: ALGORAND VERIFY RESULT IS ALWAYS FALSE:",{result:c,encodedMessage:a,signatureBytes:i,userAddress:t}),c}catch(o){return console.error("[address-validator] error verifying algorand signature:",o),!1}},this.buildAlgorandTransaction=async(t,r)=>{const n=utf8ToHex(r).slice(2),o=hexStringToUint8Array(n),i={fee:0,firstValid:10,lastValid:10,minFee:0,genesisID:"mainnet-v1.0",genesisHash:Uint8Array.from(bufferExports.Buffer.from("wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=","base64"))};return makePaymentTxnWithSuggestedParamsFromObject({sender:t,receiver:t,amount:0,closeRemainderTo:void 0,note:o,suggestedParams:i})},this.decodeSignedTransaction=async t=>decodeSignedTransaction(t)}decodeAddress(t){return Decode(TypeboxHelpers.Algorand.Address,t)}}var dist$1={exports:{}},dist=dist$1.exports,hasRequiredDist;function requireDist(){return hasRequiredDist||(hasRequiredDist=1,(function(e,t){(function(r,n){e.exports=n()})(dist,(()=>(()=>{var r={3578:function(u,a,s){var f=this&&this.__importDefault||function(E){return E&&E.__esModule?E:{default:E}};Object.defineProperty(a,"__esModule",{value:!0});const c=s(8764),d=f(s(3550)),p=s(5632),h=f(s(230)),y=f(s(5529)),b=s(2049),w=new(s(7001));class S{constructor(B){this.xprv=B}static fromEntropy(B){return new Promise(((ae,W)=>{p.pbkdf2("",B,4096,96,"sha512",((J,ve)=>{J&&W(J),ve[0]&=248,ve[31]&=31,ve[31]|=64,ae(new S(ve))}))}))}derive(B){const ae=this.xprv.slice(0,32),W=this.xprv.slice(32,64),J=this.xprv.slice(64,96);let ve,Qe;if(B<2147483648){const vt=c.Buffer.allocUnsafe(37);vt.writeUInt32LE(B,33);const ur=w.keyFromSecret(ae.toString("hex"));c.Buffer.from(ur.pubBytes()).copy(vt,1),vt[0]=2,ve=b.hmac512(J,vt),vt[0]=3,Qe=b.hmac512(J,vt)}else{const vt=c.Buffer.allocUnsafe(69);vt.writeUInt32LE(B,65),ae.copy(vt,1),W.copy(vt,33),vt[0]=0,ve=b.hmac512(J,vt),vt[0]=1,Qe=b.hmac512(J,vt)}const kt=Qe.slice(32,64),nr=ve.slice(0,32),sr=ve.slice(32,64),ce=new d.default(ae,16,"le").add(new d.default(nr.slice(0,28),16,"le").mul(new d.default(8))).toArrayLike(c.Buffer,"le",32);let Ze=new d.default(W,16,"le").add(new d.default(sr,16,"le")).toArrayLike(c.Buffer,"le").slice(0,32);Ze.length!==32&&(Ze=c.Buffer.from(Ze.toString("hex").padEnd(32,"0"),"hex"));const se=c.Buffer.concat([ce,Ze,kt]);return new S(se)}toBip32PublicKey(){const B=w.keyFromSecret(this.xprv.slice(0,32).toString("hex")),ae=c.Buffer.from(B.pubBytes());return new h.default(c.Buffer.concat([ae,this.xprv.slice(64,96)]))}toBytes(){return this.xprv}toPrivateKey(){const B=w.keyFromSecret(this.xprv.slice(0,64));return new y.default(c.Buffer.from(B.privBytes()))}}a.default=S},230:function(u,a,s){var f=this&&this.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(a,"__esModule",{value:!0});const c=s(8764),d=f(s(3550)),p=f(s(4093)),h=s(2049),y=new(s(7001));class b{constructor(S){this.xpub=S}derive(S){const E=this.xpub.slice(0,32),B=this.xpub.slice(32,64),ae=c.Buffer.allocUnsafe(37);let W,J;if(ae.writeUInt32LE(S,33),!(S<2147483648))throw new Error("can not derive hardened public key");E.copy(ae,1),ae[0]=2,W=h.hmac512(B,ae),ae[0]=3,J=h.hmac512(B,ae);const ve=J.slice(32,64),Qe=W.slice(0,32),kt=new d.default(Qe.slice(0,28),16,"le").mul(new d.default(8)),nr=y.g.mul(kt),sr=y.decodePoint(E.toString("hex")).add(nr);return new b(c.Buffer.concat([c.Buffer.from(y.encodePoint(sr)),ve]))}toPublicKey(){const S=y.keyFromPublic(this.xpub.slice(0,32));return new p.default(c.Buffer.from(S.pubBytes()))}toBytes(){return this.xpub}static fromBytes(S){return new b(S)}}a.default=b},5529:function(u,a,s){var f=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(a,"__esModule",{value:!0});const c=s(8764),d=f(s(4093)),p=new(s(7001));a.default=class{constructor(h){this.privKey=h}toBytes(){return this.privKey}toPublicKey(){const h=p.keyFromSecret(this.privKey);return new d.default(c.Buffer.from(h.pubBytes()))}sign(h){const y=p.keyFromSecret(this.privKey).sign(h.toString("hex"));return c.Buffer.from(y.toBytes())}verify(h,y){return p.keyFromSecret(this.privKey).verify(y.toString("hex"),h.toString("hex"))}}},4093:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0});const f=s(2049),c=new(s(7001));a.default=class{constructor(d){this.pubKey=d}toBytes(){return this.pubKey}hash(){return f.hash28(this.pubKey)}verify(d,p){return c.keyFromPublic(this.pubKey.toString("hex")).verify(p.toString("hex"),d.toString("hex"))}}},7001:(u,a,s)=>{const f=s(3715),c=s(6266),d=c.utils,p=d.parseBytes,h=s(2568),y=s(6398);function b(){if(!(this instanceof b))return new b;const w=c.curves.ed25519.curve;this.curve=w,this.g=w.g,this.g.precompute(w.n.bitLength()+1),this.pointClass=w.point().constructor,this.encodingLength=Math.ceil(w.n.bitLength()/8),this.hash=f.sha512}u.exports=b,b.prototype.signExtended=function(w,S){w=p(w);const E=this.keyFromSecret(S),B=this.hashInt(E.messagePrefix(),w),ae=this.g.mul(B),W=this.encodePoint(ae),J=this.hashInt(W,E.pubBytes(),w).mul(E.kl()),ve=B.add(J).umod(this.curve.n);return this.makeSignature({R:ae,S:ve,Rencoded:W})},b.prototype.verify=function(w,S,E){w=p(w),S=this.makeSignature(S);const B=this.keyFromPublic(E),ae=this.hashInt(S.Rencoded(),B.pubBytes(),w),W=this.g.mul(S.S());return S.R().add(B.pub().mul(ae)).eq(W)},b.prototype.hashInt=function(){const w=this.hash();for(let S=0;S<arguments.length;S++)w.update(arguments[S]);return d.intFromLE(w.digest()).umod(this.curve.n)},b.prototype.keyFromPublic=function(w){return h.fromPublic(this,d.parseBytes(w))},b.prototype.keyFromSecret=function(w){return h.fromSecret(this,d.parseBytes(w))},b.prototype.makeSignature=function(w){return w instanceof y?w:new y(this,w)},b.prototype.encodePoint=function(w){const S=w.getY().toArray("le",this.encodingLength);return S[this.encodingLength-1]|=w.getX().isOdd()?128:0,S},b.prototype.decodePoint=function(w){const S=(w=d.parseBytes(w)).length-1,E=w.slice(0,S).concat(-129&w[S]),B=(128&w[S])!=0,ae=d.intFromLE(E);return this.curve.pointFromY(ae,B)},b.prototype.encodeInt=function(w){return w.toArray("le",this.encodingLength)},b.prototype.decodeInt=function(w){return d.intFromLE(w)},b.prototype.isPoint=function(w){return w instanceof this.pointClass}},2568:(u,a,s)=>{const f=s(6266).utils,c=f.assert,d=f.parseBytes,p=f.cachedProperty;function h(y,b){this.eddsa=y,this._secret=d(b.secret),y.isPoint(b.pub)?(console.log("Its point"),this._pub=b.pub):this._pubBytes=d(b.pub)}h.fromPublic=function(y,b){return b instanceof h?b:new h(y,{pub:b})},h.fromSecret=function(y,b){return b instanceof h?b:new h(y,{secret:b})},h.prototype.secret=function(){return this._secret.slice(0,32)},p(h,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),p(h,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.kl())})),p(h,"privBytes",(function(){return this._secret})),p(h,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),p(h,"kl",(function(){return this.eddsa.decodeInt(this.privBytes().slice(0,32))})),p(h,"messagePrefix",(function(){return this._secret.slice(32,64)})),h.prototype.sign=function(y){return c(this._secret,"KeyPair can only verify"),this.eddsa.signExtended(y,this)},h.prototype.verify=function(y,b){return this.eddsa.verify(y,b,this)},u.exports=h},6398:(u,a,s)=>{const f=s(3550),c=s(6266).utils,d=c.assert,p=c.cachedProperty,h=c.parseBytes;function y(b,w){this.eddsa=b,typeof w!="object"&&(w=h(w)),Array.isArray(w)&&(w={R:w.slice(0,b.encodingLength),S:w.slice(b.encodingLength)}),d(w.R&&w.S,"Signature without R or S"),b.isPoint(w.R)&&(this._R=w.R),f.isBN(w.S)&&(this._S=w.S),this._Rencoded=Array.isArray(w.R)?w.R:w.Rencoded,this._Sencoded=Array.isArray(w.S)?w.S:w.Sencoded}p(y,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),p(y,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),p(y,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),p(y,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),y.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},y.prototype.toHex=function(){return c.encode(this.toBytes(),"hex").toUpperCase()},u.exports=y},546:function(u,a,s){var f=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.PrivateKey=a.PublicKey=a.Bip32PublicKey=a.Bip32PrivateKey=void 0;var c=s(3578);Object.defineProperty(a,"Bip32PrivateKey",{enumerable:!0,get:function(){return f(c).default}});var d=s(230);Object.defineProperty(a,"Bip32PublicKey",{enumerable:!0,get:function(){return f(d).default}});var p=s(4093);Object.defineProperty(a,"PublicKey",{enumerable:!0,get:function(){return f(p).default}});var h=s(5529);Object.defineProperty(a,"PrivateKey",{enumerable:!0,get:function(){return f(h).default}})},2049:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(b,w,S,E){E===void 0&&(E=S),Object.defineProperty(b,E,{enumerable:!0,get:function(){return w[S]}})}:function(b,w,S,E){E===void 0&&(E=S),b[E]=w[S]}),c=this&&this.__setModuleDefault||(Object.create?function(b,w){Object.defineProperty(b,"default",{enumerable:!0,value:w})}:function(b,w){b.default=w}),d=this&&this.__importStar||function(b){if(b&&b.__esModule)return b;var w={};if(b!=null)for(var S in b)S!=="default"&&Object.prototype.hasOwnProperty.call(b,S)&&f(w,b,S);return c(w,b),w};Object.defineProperty(a,"__esModule",{value:!0}),a.hmac512=a.hash28=void 0;const p=s(8764),h=s(1191),y=d(s(3715));a.hash28=function(b){const w=h.blake2b(b,void 0,28);return p.Buffer.from(w)},a.hmac512=function(b,w){const S=y.hmac(y.sha512,b).update(w).digest();return p.Buffer.from(S)}},5723:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0});const f=s(8764);a.default=class{constructor(){this.buf=f.Buffer.alloc(0)}get length(){return this.buf.length}read(c){if(c===0)return f.Buffer.alloc(0);if(c<0)throw new Error("invalid length");const d=this.buf.slice(0,c);if(this.buf=this.buf.slice(c),d.length<c)throw new Error("Not enough buffer");return d}push(c){c.length&&(this.buf=f.Buffer.concat([this.buf,c]))}}},7640:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.default=class extends Array{constructor(){super(...arguments),this.byteSpan=[0,0]}setByteSpan(s){this.byteSpan=s}getByteSpan(){return this.byteSpan}}},1022:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0});class s extends Map{constructor(){super(...arguments),this.byteSpan=[0,0]}setByteSpan(c){this.byteSpan=c}getByteSpan(){return this.byteSpan}}a.default=s},5257:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.default=class{constructor(s,f){this.byteSpan=[0,0],this.value=s,this.tag=f}setByteSpan(s){this.byteSpan=s}getByteSpan(){return this.byteSpan}}},6217:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(Qe,kt,nr,sr){sr===void 0&&(sr=nr),Object.defineProperty(Qe,sr,{enumerable:!0,get:function(){return kt[nr]}})}:function(Qe,kt,nr,sr){sr===void 0&&(sr=nr),Qe[sr]=kt[nr]}),c=this&&this.__setModuleDefault||(Object.create?function(Qe,kt){Object.defineProperty(Qe,"default",{enumerable:!0,value:kt})}:function(Qe,kt){Qe.default=kt}),d=this&&this.__importStar||function(Qe){if(Qe&&Qe.__esModule)return Qe;var kt={};if(Qe!=null)for(var nr in Qe)nr!=="default"&&Object.prototype.hasOwnProperty.call(Qe,nr)&&f(kt,Qe,nr);return c(kt,Qe),kt},p=this&&this.__importDefault||function(Qe){return Qe&&Qe.__esModule?Qe:{default:Qe}};Object.defineProperty(a,"__esModule",{value:!0});const h=s(8764),y=d(s(2830)),b=p(s(4431)),w=s(3726),S=p(s(5723)),E=p(s(1604)),B=p(s(5257)),ae=p(s(7640)),W=p(s(1022)),J=Qe=>Qe===255;class ve extends y.Transform{constructor(){super({writableObjectMode:!1,readableObjectMode:!0}),this.needed=null,this.fresh=!0,this._parser=this.parse(),this.offset=0,this.usedBytes=[],this.bl=new S.default,this.restart()}static decode(kt){const nr=new ve,sr=new S.default;sr.push(kt);const ce=nr.parse();let Ze=ce.next();for(;!Ze.done;){const se=sr.read(Ze.value);if(se==null||se.length!==Ze.value)throw new Error("Insufficient data");Ze=ce.next(se)}if(sr.length>0)throw new Error("Remaining Bytes");return{bytes:kt,value:Ze.value}}readUInt64(kt,nr,sr){const ce=(0,w.getBigNum)(kt,nr);return b.default.isBigNumber(ce)?(0,w.addSpanBytesToObject)(ce,[sr,this.offset]):ce}updateTracker(kt){this.usedBytes.push(kt),this.offset+=kt.length}*readIndefiniteStringLength(kt,nr){let sr,ce=yield 1;const Ze=ce.readUInt8(0);if(Ze===255)sr=-1;else{const se=31&Ze,vt=this.readLength(se,nr);let ur=vt.next();for(;!ur.done;)ce=yield ur.value,this.updateTracker(ce),ur=vt.next(ce);if(sr=ur.value,sr<0||Ze>>5!==kt)throw new Error("Invalid indefinite length encoding")}return sr}*readLength(kt,nr){if(kt<24)return kt;if(kt===24)return(yield 1).readUInt8(0);if(kt===25)return(yield 2).readUInt16BE(0);if(kt===26)return(yield 4).readUInt32BE(0);if(kt===27){const sr=(yield 4).readUInt32BE(0),ce=(yield 4).readUInt32BE(0);return this.readUInt64(sr,ce,nr)}if(kt===31)return-1;throw new Error("Invalid length encoding")}_transform(kt,nr,sr){for(this.bl.push(kt);this.bl.length>=this.needed;){let ce,Ze=null;ce=this.needed===null?void 0:this.bl.read(this.needed);try{Ze=this._parser.next(ce)}catch(se){return sr(se)}this.needed&&(this.fresh=!1),Ze.done?(this.push({bytes:this.usedBytes,value:Ze.value}),this.restart()):this.needed=Ze.value||1/0}return sr()}*parse(kt){let nr,sr=this.offset;kt?(nr=kt,sr-=kt.length):(nr=yield 1,this.updateTracker(nr));const ce=nr.readUInt8(0),Ze=ce>>5,se=31&ce;let vt;if(Ze===7){if(se===25)return nr=yield 2,this.updateTracker(nr),(bt=>{const L=32768&bt;let _=31744&bt;const F=1023&bt;if(_===31744)_=261120;else if(_!==0)_+=114688;else if(F!==0)return(L?-1:1)*F*w.POW_2_24;const k=h.Buffer.alloc(4);return k.writeUInt32BE(L<<16|_<<13|F<<13),k.readFloatBE(0)})(nr.readUInt16BE(0));if(se===26)return nr=yield 4,this.updateTracker(nr),nr.readFloatBE(0);if(se===27)return nr=yield 8,this.updateTracker(nr),nr.readDoubleBE(0)}const ur=this.readLength(se,sr);let ue=ur.next();for(;!ue.done;)nr=yield ue.value,this.updateTracker(nr),ue=ur.next(nr);if(vt=ue.value,vt<0&&(Ze<2||Ze>6))throw new Error("Invalid length");switch(Ze){case 0:return vt;case 1:if(vt===Number.MAX_SAFE_INTEGER){const bt=new b.default(-1).minus(new b.default(Number.MAX_SAFE_INTEGER.toString(16),16));return(0,w.addSpanBytesToObject)(bt,[sr,this.offset])}if(b.default.isBigNumber(vt)){const bt=new b.default(-1).minus(vt);return(0,w.addSpanBytesToObject)(bt,[sr,this.offset])}return-1-vt;case 2:if(vt<0){const bt=[];{const _=this.readIndefiniteStringLength(Ze,sr);let F=_.next();for(;!F.done;)nr=yield F.value,this.updateTracker(nr),F=_.next(nr);vt=F.value}for(;vt>=0;){nr=yield vt,this.updateTracker(nr),bt.push(nr);{const _=this.readIndefiniteStringLength(Ze,sr);let F=_.next();for(;!F.done;)nr=yield F.value,this.updateTracker(nr),F=_.next(nr);vt=F.value}}const L=h.Buffer.concat(bt);return(0,w.addSpanBytesToObject)(L,[sr,this.offset])}return nr=yield vt,this.updateTracker(nr),(0,w.addSpanBytesToObject)(nr,[sr,this.offset]);case 3:{const bt=[];if(vt<0){{const L=this.readIndefiniteStringLength(Ze,sr);let _=L.next();for(;!_.done;)nr=yield _.value,this.updateTracker(nr),_=L.next(nr);vt=_.value}for(;vt>=0;){nr=yield vt,this.updateTracker(nr),bt.push(nr);{const L=this.readIndefiniteStringLength(Ze,sr);let _=L.next();for(;!_.done;)nr=yield _.value,this.updateTracker(nr),_=L.next(nr);vt=_.value}}return(0,w.utf8Decoder)(h.Buffer.concat(bt))}return nr=yield vt,this.updateTracker(nr),(0,w.utf8Decoder)(nr)}case 4:{if(vt<0){const L=new ae.default;nr=yield 1,this.updateTracker(nr);let _=nr.readUInt8(0);for(;!J(_);)L.push(yield*this.parse(nr)),nr=yield 1,this.updateTracker(nr),_=nr.readUInt8(0);return L.setByteSpan([sr,this.offset]),L}const bt=new ae.default;for(let L=0;L<vt;L+=1)bt.push(yield*this.parse());return bt.setByteSpan([sr,this.offset]),bt}case 5:{if(vt<0){const L=new W.default;nr=yield 1,this.updateTracker(nr);let _=nr.readUInt8(0);for(;!J(_);){const F=yield*this.parse(nr),k=yield*this.parse();L.set(F,k),nr=yield 1,this.updateTracker(nr),_=nr.readUInt8(0)}return L.setByteSpan([sr,this.offset]),L}const bt=new W.default;for(let L=0;L<vt;L+=1){const _=yield*this.parse(),F=yield*this.parse();bt.set(_,F)}return bt.setByteSpan([sr,this.offset]),bt}case 6:{const bt=new B.default(yield*this.parse(),vt);return bt.setByteSpan([sr,this.offset]),bt}case 7:switch(vt){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:return new E.default(vt)}default:throw new Error("Invalid CBOR encoding")}}restart(){this.needed=null,this._parser=this.parse(),this.fresh=!0,this.offset=0,this.usedBytes=[]}_flush(kt){kt(this.fresh?null:new Error("unexpected end of input"))}}a.default=ve},1604:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.default=class{constructor(s){this.value=s}}},7747:function(u,a,s){var f=this&&this.__importDefault||function(S){return S&&S.__esModule?S:{default:S}};Object.defineProperty(a,"__esModule",{value:!0});const c=s(8764),d=f(s(4431)),p=s(7730),h=s(2339),y=s(3726),b=c.Buffer.from("f97e00","hex"),w=c.Buffer.from("ff","hex");a.default=(S,E={collapseBigNumber:!0})=>{const B=[];function ae(nr){const sr=c.Buffer.allocUnsafe(1);sr.writeUInt8(nr,0),B.push(sr)}function W(nr){B.push(nr)}function J(nr){const sr=c.Buffer.allocUnsafe(4);sr.writeUInt32BE(nr,0),B.push(sr)}function ve(nr,sr){sr<24?ae(nr<<5|sr):sr<256?(ae(nr<<5|24),ae(sr)):sr<65536?(ae(nr<<5|25),(function(ce){const Ze=c.Buffer.allocUnsafe(2);Ze.writeUInt16BE(ce,0),B.push(Ze)})(sr)):sr<4294967296?(ae(nr<<5|26),J(sr)):(ae(nr<<5|27),(function(ce){const Ze=ce%y.POW_2_32,se=(ce-Ze)/y.POW_2_32,vt=c.Buffer.allocUnsafe(8);vt.writeUInt32BE(se,0),vt.writeUInt32BE(Ze,4),B.push(vt)})(sr))}function Qe(nr){return Object.is(nr,-0)?W(c.Buffer.from("f98000","hex")):nr>=0&&nr<=y.POW_2_53?ve(0,nr):-y.POW_2_53<=nr&&nr<0?ve(1,-(nr+1)):void 0}function kt(nr){let sr=nr,ce=0,Ze=2;if(sr.isNegative()&&(sr=sr.negated().minus(1),ce=1,Ze=3),E.collapseBigNumber&&sr.lte(y.MAX_BIG_NUM_INT64)){if(sr.lte(y.MAX_BIG_NUM_INT32))return ve(ce,sr.toNumber());ae(ce<<5|27),J(sr.dividedToIntegerBy(y.SHIFT32).toNumber()),J(sr.mod(y.SHIFT32).toNumber())}else{let se=sr.toString(16);se.length%2&&(se=`0${se}`),ve(6,Ze);const vt=c.Buffer.from(se,"hex");ve(2,vt.length),W(vt)}}return(function nr(sr){if(sr===!1)return ae(244);if(sr===!0)return ae(245);if(sr===null)return ae(246);if(sr===void 0)return ae(247);switch(typeof sr){case"number":return Math.round(sr)===sr?Qe(sr):(ae(251),(function(ce){const Ze=c.Buffer.allocUnsafe(8);Ze.writeDoubleBE(ce),B.push(Ze)})(sr));case"string":{const ce=c.Buffer.from(sr,"utf8");return ve(3,ce.length),W(ce)}default:if(Array.isArray(sr)){sr instanceof h.IndefiniteArray?ae(159):ve(4,sr.length);for(const ce of sr)nr(ce);sr instanceof h.IndefiniteArray&&W(w)}else if(sr instanceof c.Buffer)ve(2,sr.length),W(sr);else if(sr instanceof ArrayBuffer){const ce=c.Buffer.from(sr);ve(2,ce.length),W(ce)}else if(sr instanceof Uint8ClampedArray){const ce=c.Buffer.from(sr);ve(2,ce.length),W(ce)}else if(sr instanceof Uint8Array){const ce=c.Buffer.from(sr);ve(2,ce.length),W(ce)}else if(d.default.isBigNumber(sr))(function(ce){if(ce.isNaN())W(b);else if(ce.isInteger())kt(ce);else{ve(6,4),ve(4,2);const Ze=ce.decimalPlaces(),se=ce.shiftedBy(Ze);Qe(-Ze),se.abs().isLessThan(y.MAX_BIG_NUM_INT)?Qe(se.toNumber()):kt(se)}})(sr);else if(sr instanceof p.CborTag)ve(6,sr.tag),nr(sr.value);else{let ce;ce=sr instanceof Map?[...sr.entries()]:[...Object.entries(sr)],sr instanceof h.IndefiniteMap?ae(191):ve(5,ce.length);for(const[Ze,se]of ce)nr(Ze),nr(se);sr instanceof h.IndefiniteMap&&W(w)}}})(S),c.Buffer.concat(B)}},2339:function(u,a,s){var f=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(a,"__esModule",{value:!0}),a.CborTag=a.IndefiniteArray=a.IndefiniteMap=void 0;class c extends Map{}a.IndefiniteMap=c,a.IndefiniteArray=class extends Array{};var d=s(5257);Object.defineProperty(a,"CborTag",{enumerable:!0,get:function(){return f(d).default}})},7730:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(y,b,w,S){S===void 0&&(S=w),Object.defineProperty(y,S,{enumerable:!0,get:function(){return b[w]}})}:function(y,b,w,S){S===void 0&&(S=w),y[S]=b[w]}),c=this&&this.__exportStar||function(y,b){for(var w in y)w==="default"||Object.prototype.hasOwnProperty.call(b,w)||f(b,y,w)},d=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.Decoder=a.Encoder=void 0;const p=d(s(7747));a.Encoder={encode:p.default};var h=s(6217);Object.defineProperty(a,"Decoder",{enumerable:!0,get:function(){return d(h).default}}),c(s(2339),a)},3726:function(u,a,s){var f=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(a,"__esModule",{value:!0}),a.utf8Decoder=a.addSpanBytesToObject=a.getBigNum=a.MAX_BIG_NUM_INT64=a.MAX_BIG_NUM_INT32=a.MAX_BIG_NUM_INT=a.POW_2_53=a.POW_2_32=a.POW_2_24=a.SHIFT32=void 0;const c=f(s(4431));a.SHIFT32=4294967296,a.POW_2_24=5960464477539063e-23,a.POW_2_32=4294967296,a.POW_2_53=9007199254740992,a.MAX_BIG_NUM_INT=new c.default("0x20000000000000"),a.MAX_BIG_NUM_INT32=new c.default("0xffffffff"),a.MAX_BIG_NUM_INT64=new c.default("0xffffffffffffffff"),a.getBigNum=(p,h)=>p>2097151?new c.default(p).times(a.SHIFT32).plus(h):p*a.SHIFT32+h,a.addSpanBytesToObject=(p,h)=>{const y=p;return y.byteSpan=h,y.getByteSpan=function(){return this.byteSpan},y};const d=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0});a.utf8Decoder=p=>d.decode(p)},6084:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0});const f=s(7730),c=s(546),d=s(1191),p=s(8764);class h{constructor(b){this.protectedMap=b.protectedMap,this.unProtectedMap=b.unProtectedMap,this.payload=b.payload,this.unProtectedMap.get("hashed")==null&&this.unProtectedMap.set("hashed",!1),this.signature=b.signature}static fromCbor(b){const w=f.Decoder.decode(p.Buffer.from(b,"hex"));if(!(w.value instanceof Array))throw Error("Invalid CBOR");if(w.value.length!==4)throw Error("Invalid COSE_SIGN1");let S;const E=w.value[0];try{if(S=f.Decoder.decode(E).value,!(S instanceof Map))throw Error()}catch{throw Error("Invalid protected")}const B=w.value[1];if(!(B instanceof Map))throw Error("Invalid unprotected");const ae=w.value[2],W=w.value[3];return new h({protectedMap:S,unProtectedMap:B,payload:ae,signature:W})}createSigStructure(b=p.Buffer.alloc(0)){let w=p.Buffer.alloc(0);this.protectedMap.size!==0&&(w=f.Encoder.encode(this.protectedMap));const S=["Signature1",w,b,this.payload];return f.Encoder.encode(S)}buildMessage(b){this.signature=b;let w=p.Buffer.alloc(0);this.protectedMap.size!==0&&(w=f.Encoder.encode(this.protectedMap));const S=[w,this.unProtectedMap,this.payload,this.signature];return f.Encoder.encode(S)}verifySignature({externalAad:b=p.Buffer.alloc(0),publicKeyBuffer:w}={}){if(w||(w=this.getPublicKey()),!w)throw Error("Public key not found");if(!this.signature)throw Error("Signature not found");return new c.PublicKey(w).verify(this.signature,this.createSigStructure(b))}hashPayload(){if(!this.unProtectedMap)throw Error("Invalid unprotected map");if(!this.payload)throw Error("Invalid payload");if(this.unProtectedMap.get("hashed"))throw Error("Payload already hashed");if(this.unProtectedMap.get("hashed")!=0)throw Error("Invalid unprotected map");this.unProtectedMap.set("hashed",!0);const b=(0,d.blake2b)(this.payload,void 0,24);this.payload=p.Buffer.from(b)}getAddress(){return this.protectedMap.get("address")}getPublicKey(){return this.protectedMap.get(4)}getSignature(){return this.signature}}a.default=h},2716:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(h,y,b,w){w===void 0&&(w=b);var S=Object.getOwnPropertyDescriptor(y,b);S&&!("get"in S?!y.__esModule:S.writable||S.configurable)||(S={enumerable:!0,get:function(){return y[b]}}),Object.defineProperty(h,w,S)}:function(h,y,b,w){w===void 0&&(w=b),h[w]=y[b]}),c=this&&this.__exportStar||function(h,y){for(var b in h)b==="default"||Object.prototype.hasOwnProperty.call(y,b)||f(y,h,b)},d=this&&this.__importDefault||function(h){return h&&h.__esModule?h:{default:h}};Object.defineProperty(a,"__esModule",{value:!0}),a.CoseSign1=void 0;var p=s(6084);Object.defineProperty(a,"CoseSign1",{enumerable:!0,get:function(){return d(p).default}}),c(s(7225),a)},7225:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.getPublicKeyFromCoseKey=void 0;const f=s(7730),c=s(8764);a.getPublicKeyFromCoseKey=d=>{const p=f.Decoder.decode(c.Buffer.from(d,"hex")).value.get(-2);if(p)return p;throw Error("Public key not found")}},7801:function(u,a,s){var f=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.BaseAddress=void 0;const c=s(8764),d=s(23),p=f(s(4483));class h extends p.default{constructor(b,w,S){super(b,w),this.stakeCredential=S,this.computeHex()}computeHex(){let b=0;this._paymentCredential.type===d.HashType.ADDRESS||this._paymentCredential.type===d.HashType.SCRIPT&&(b|=16),this.stakeCredential.type===d.HashType.ADDRESS||this.stakeCredential.type===d.HashType.SCRIPT&&(b|=32),b|=this.networkId;const w=`${b.toString(16).padStart(2,"0")}${this._paymentCredential.hash}${this.stakeCredential.hash}`;this.addressHex=w,this.addressBytes=c.Buffer.from(w,"hex"),this.addressBech32=this.computeBech32(this.addressBytes)}}a.BaseAddress=h,a.default=h},5027:function(u,a,s){var f=this&&this.__importDefault||function(p){return p&&p.__esModule?p:{default:p}};Object.defineProperty(a,"__esModule",{value:!0}),a.ByronAddress=void 0;const c=f(s(7191));class d{constructor(h){this.addressBech32=c.default.encode(h),this.addressBytes=h,this.addressHex=h.toString("hex")}getHex(){return this.addressHex}getBytes(){return this.addressBytes}getBech32(){return this.addressBech32}}a.ByronAddress=d,a.default=d},1989:function(u,a,s){var f=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.EnterpriseAddress=void 0;const c=s(8764),d=s(23),p=f(s(4483));class h extends p.default{constructor(b,w){super(b,w),this.computeHex()}computeHex(){let b=96;this._paymentCredential.type===d.HashType.ADDRESS||this._paymentCredential.type===d.HashType.SCRIPT&&(b|=16),b|=this.networkId;const w=`${b.toString(16).padStart(2,"0")}${this._paymentCredential.hash}`;this.addressHex=w,this.addressBytes=c.Buffer.from(w,"hex"),this.addressBech32=this.computeBech32(this.addressBytes)}}a.EnterpriseAddress=h,a.default=h},9105:function(u,a,s){var f=this&&this.__importDefault||function(y){return y&&y.__esModule?y:{default:y}};Object.defineProperty(a,"__esModule",{value:!0}),a.PointerAddress=void 0;const c=s(8764),d=s(23),p=f(s(4483));class h extends p.default{constructor(b,w,S){super(b,w),this._vlq=S,this.computeHex()}computeHex(){let b=64;this._paymentCredential.type===d.HashType.ADDRESS||this._paymentCredential.type===d.HashType.SCRIPT&&(b|=16),b|=this.networkId;const w=`${b.toString(16).padStart(2,"0")}${this._paymentCredential.hash}${this._vlq}`;this.addressHex=w,this.addressBytes=c.Buffer.from(w,"hex"),this.addressBech32=this.computeBech32(this.addressBytes)}}a.PointerAddress=h,a.default=h},7452:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.RewardAddress=void 0;const f=s(8764),c=s(7715),d=s(23);class p{constructor(y,b){this.addressHex="",this.addressBytes=f.Buffer.alloc(0),this.addressBech32="",this._stakeCredential=b,this.networkId=y,this.computeHex()}computeBech32(y){const b=this.networkId===d.NetworkId.MAINNET?"stake":"stake_test",w=c.bech32.toWords(y);return c.bech32.encode(b,w,1e3)}computeHex(){let y=224;this._stakeCredential.type===d.HashType.ADDRESS||this._stakeCredential.type===d.HashType.SCRIPT&&(y|=16),y|=this.networkId;const b=`${y.toString(16).padStart(2,"0")}${this._stakeCredential.hash}`;this.addressHex=b,this.addressBytes=f.Buffer.from(b,"hex"),this.addressBech32=this.computeBech32(this.addressBytes)}get stakeCredential(){return this._stakeCredential}getHex(){return this.addressHex}getBytes(){return this.addressBytes}getBech32(){return this.addressBech32}getNetworkId(){return this.networkId}}a.RewardAddress=p,a.default=p},4483:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.ShelleyTypeAddress=void 0;const f=s(8764),c=s(7715),d=s(23);class p{constructor(y,b){this.addressHex="",this.addressBytes=f.Buffer.alloc(0),this.addressBech32="",this.networkId=y,this._paymentCredential=b}computeBech32(y){const b=this.networkId===d.NetworkId.MAINNET?"addr":"addr_test",w=c.bech32.toWords(y);return c.bech32.encode(b,w,1e3)}get paymentCredential(){return this._paymentCredential}getHex(){return this.addressHex}getBytes(){return this.addressBytes}getBech32(){return this.addressBech32}getNetworkId(){return this.networkId}}a.ShelleyTypeAddress=p,a.default=p},3604:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.RewardAddress=a.PointerAddress=a.EnterpriseAddress=a.ByronAddress=a.BaseAddress=void 0;var f=s(7801);Object.defineProperty(a,"BaseAddress",{enumerable:!0,get:function(){return f.BaseAddress}});var c=s(5027);Object.defineProperty(a,"ByronAddress",{enumerable:!0,get:function(){return c.ByronAddress}});var d=s(1989);Object.defineProperty(a,"EnterpriseAddress",{enumerable:!0,get:function(){return d.EnterpriseAddress}});var p=s(9105);Object.defineProperty(a,"PointerAddress",{enumerable:!0,get:function(){return p.PointerAddress}});var h=s(7452);Object.defineProperty(a,"RewardAddress",{enumerable:!0,get:function(){return h.RewardAddress}})},1617:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.maxTokenAmount=void 0,a.maxTokenAmount="9223372036854775807"},9528:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(b,w,S,E){E===void 0&&(E=S);var B=Object.getOwnPropertyDescriptor(w,S);B&&!("get"in B?!w.__esModule:B.writable||B.configurable)||(B={enumerable:!0,get:function(){return w[S]}}),Object.defineProperty(b,E,B)}:function(b,w,S,E){E===void 0&&(E=S),b[E]=w[S]}),c=this&&this.__setModuleDefault||(Object.create?function(b,w){Object.defineProperty(b,"default",{enumerable:!0,value:w})}:function(b,w){b.default=w}),d=this&&this.__importStar||function(b){if(b&&b.__esModule)return b;var w={};if(b!=null)for(var S in b)S!=="default"&&Object.prototype.hasOwnProperty.call(b,S)&&f(w,b,S);return c(w,b),w};Object.defineProperty(a,"__esModule",{value:!0}),a.PlutusDataFactory=a.NativeScriptFactory=a.address=a.Transaction=a.types=a.utils=a.crypto=void 0,a.crypto=d(s(3678)),a.utils=d(s(6397)),a.types=d(s(23));var p=s(9779);Object.defineProperty(a,"Transaction",{enumerable:!0,get:function(){return p.Transaction}}),a.address=d(s(3604));var h=s(3117);Object.defineProperty(a,"NativeScriptFactory",{enumerable:!0,get:function(){return h.NativeScriptFactory}});var y=s(2383);Object.defineProperty(a,"PlutusDataFactory",{enumerable:!0,get:function(){return y.PlutusDataFactory}})},7067:(u,a)=>{var s;Object.defineProperty(a,"__esModule",{value:!0}),a.RedeemerTag=void 0,(s=a.RedeemerTag||(a.RedeemerTag={}))[s.SPEND=0]="SPEND",s[s.MINT=1]="MINT",s[s.CERT=2]="CERT",s[s.REWARD=3]="REWARD"},3117:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(S,E,B,ae){ae===void 0&&(ae=B);var W=Object.getOwnPropertyDescriptor(E,B);W&&!("get"in W?!E.__esModule:W.writable||W.configurable)||(W={enumerable:!0,get:function(){return E[B]}}),Object.defineProperty(S,ae,W)}:function(S,E,B,ae){ae===void 0&&(ae=B),S[ae]=E[B]}),c=this&&this.__setModuleDefault||(Object.create?function(S,E){Object.defineProperty(S,"default",{enumerable:!0,value:E})}:function(S,E){S.default=E}),d=this&&this.__importStar||function(S){if(S&&S.__esModule)return S;var E={};if(S!=null)for(var B in S)B!=="default"&&Object.prototype.hasOwnProperty.call(S,B)&&f(E,S,B);return c(E,S),E};Object.defineProperty(a,"__esModule",{value:!0}),a.NativeScriptFactory=void 0;const p=s(8764),h=d(s(7730)),y=s(3678),b=s(6171);class w{constructor(E){this.nativeScript=E;const B=(0,b.encodeNativeScript)(E);this._cbor=h.Encoder.encode(B),this._policyId=(0,y.hash28)(p.Buffer.from(`00${this._cbor.toString("hex")}`,"hex"))}cbor(){return this._cbor}policyId(){return this._policyId}json(){return this.nativeScript}}a.NativeScriptFactory=w,a.default=w},2383:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(b,w,S,E){E===void 0&&(E=S);var B=Object.getOwnPropertyDescriptor(w,S);B&&!("get"in B?!w.__esModule:B.writable||B.configurable)||(B={enumerable:!0,get:function(){return w[S]}}),Object.defineProperty(b,E,B)}:function(b,w,S,E){E===void 0&&(E=S),b[E]=w[S]}),c=this&&this.__setModuleDefault||(Object.create?function(b,w){Object.defineProperty(b,"default",{enumerable:!0,value:w})}:function(b,w){b.default=w}),d=this&&this.__importStar||function(b){if(b&&b.__esModule)return b;var w={};if(b!=null)for(var S in b)S!=="default"&&Object.prototype.hasOwnProperty.call(b,S)&&f(w,b,S);return c(w,b),w};Object.defineProperty(a,"__esModule",{value:!0}),a.PlutusDataFactory=void 0;const p=d(s(7730)),h=s(3678),y=s(6171);a.PlutusDataFactory=class{constructor(b){this.plutusData=b;const w=(0,y.encodePlutusData)(b);this._cbor=p.Encoder.encode(w),this._plutusDataHash=(0,h.hash32)(this._cbor)}cbor(){return this._cbor}plutusDataHash(){return this._plutusDataHash}json(){return this.plutusData}}},9779:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(kt,nr,sr,ce){ce===void 0&&(ce=sr);var Ze=Object.getOwnPropertyDescriptor(nr,sr);Ze&&!("get"in Ze?!nr.__esModule:Ze.writable||Ze.configurable)||(Ze={enumerable:!0,get:function(){return nr[sr]}}),Object.defineProperty(kt,ce,Ze)}:function(kt,nr,sr,ce){ce===void 0&&(ce=sr),kt[ce]=nr[sr]}),c=this&&this.__setModuleDefault||(Object.create?function(kt,nr){Object.defineProperty(kt,"default",{enumerable:!0,value:nr})}:function(kt,nr){kt.default=nr}),d=this&&this.__importStar||function(kt){if(kt&&kt.__esModule)return kt;var nr={};if(kt!=null)for(var sr in kt)sr!=="default"&&Object.prototype.hasOwnProperty.call(kt,sr)&&f(nr,kt,sr);return c(nr,kt),nr},p=this&&this.__importDefault||function(kt){return kt&&kt.__esModule?kt:{default:kt}};Object.defineProperty(a,"__esModule",{value:!0}),a.Transaction=void 0;const h=s(8764),y=d(s(7730)),b=p(s(4431)),w=p(s(6486)),S=s(2027),E=s(23),B=s(6171),ae=s(3678),W=s(6397),J=p(s(9677)),ve=s(9494);class Qe{constructor({protocolParams:nr}){this.inputs=[],this.outputs=[],this.certificates=[],this.withdrawals=[],this.requiredWitnesses=new Map,this.requiredNativeScriptWitnesses=new Map,this.fee=new b.default(5e6),this.witnesses=[],this.plutusScriptMap=new Map,this.nativeScriptList=[],this.collaterals=[],this.requiredSigners=new Map,this.plutusDataList=[],this._isPlutusTransaction=!1,this.mints=[],this._protocolParams=nr}get protocolParams(){return this._protocolParams}getTTL(){return this.ttl}setTTL(nr){this.ttl=nr}getValidityIntervalStart(){return this.validityIntervalStart}setValidityIntervalStart(nr){this.validityIntervalStart=nr}addInput(nr){if(nr.address.paymentCredential.type===E.HashType.ADDRESS)this.requiredWitnesses.set(nr.address.paymentCredential.hash,nr.address.paymentCredential.bipPath);else if(nr.address.paymentCredential.type===E.HashType.SCRIPT){if(nr.address.paymentCredential.plutusScript)this._isPlutusTransaction=!0,this.plutusScriptMap.set(nr.address.paymentCredential.plutusScript.cborHex,nr.address.paymentCredential.plutusScript.type);else if(nr.address.paymentCredential.nativeScript){const sr=nr.address.paymentCredential.nativeScript,ce=(0,S.getPubKeyHashListFromNativeScript)(sr);for(const Ze of ce)this.requiredNativeScriptWitnesses.set(Ze,void 0);this.nativeScriptList.push(sr)}}nr.plutusData&&this.plutusDataList.push(nr.plutusData),this.inputs.push(nr)}addRequiredSigner(nr){this.requiredSigners.set(nr.hash,nr.bipPath)}addCollateral(nr){nr.address.paymentCredential.type===E.HashType.ADDRESS&&this.requiredWitnesses.set(nr.address.paymentCredential.hash,nr.address.paymentCredential.bipPath),this.collaterals.push(nr)}addMint(nr){if(this.mints.push(nr),nr.plutusScript)this._isPlutusTransaction=!0,this.plutusScriptMap.set(nr.plutusScript.cborHex,nr.plutusScript.type);else if(nr.nativeScript){const sr=(0,S.getPubKeyHashListFromNativeScript)(nr.nativeScript);for(const ce of sr)this.requiredNativeScriptWitnesses.set(ce,void 0);this.nativeScriptList.push(nr.nativeScript)}}addCertificate(nr){nr.certType===E.CertificateType.STAKE_DELEGATION?nr.stakeCredential.type===E.HashType.ADDRESS&&this.requiredWitnesses.set(nr.stakeCredential.hash,nr.stakeCredential.bipPath):nr.certType===E.CertificateType.STAKE_DE_REGISTRATION&&nr.stakeCredential.type===E.HashType.ADDRESS&&this.requiredWitnesses.set(nr.stakeCredential.hash,nr.stakeCredential.bipPath),this.certificates.push(nr)}addOutput(nr){const sr=nr;if(sr.tokens=(0,S.sortTokens)(sr.tokens),sr.plutusData){const ce=y.Encoder.encode((0,B.encodePlutusData)(sr.plutusData));sr.plutusDataHash=(0,ae.hash32)(ce).toString("hex")}this.outputs.push(sr),sr.plutusData&&this.plutusDataList.push(sr.plutusData)}addWithdrawal(nr){nr.rewardAccount.stakeCredential.type===E.HashType.ADDRESS&&this.requiredWitnesses.set(nr.rewardAccount.stakeCredential.hash,nr.rewardAccount.stakeCredential.bipPath),this.withdrawals.push(nr)}transactionBody({extraOutputs:nr,scriptDataHash:sr}){const ce=new Map;ce.set(E.TransactionBodyItemType.INPUTS,(0,B.encodeInputs)(this.inputs));let Ze=this.outputs;if(nr&&nr.length>0&&(Ze=Ze.concat(nr)),ce.set(E.TransactionBodyItemType.OUTPUTS,(0,B.encodeOutputs)(Ze)),ce.set(E.TransactionBodyItemType.FEE,this.fee),this.ttl!==void 0&&ce.set(E.TransactionBodyItemType.TTL,this.ttl),this.validityIntervalStart!==void 0&&ce.set(E.TransactionBodyItemType.VALIDITY_INTERVAL_START,this.validityIntervalStart),this.certificates.length>0&&ce.set(E.TransactionBodyItemType.CERTIFICATES,(0,B.encodeCertificates)(this.certificates)),this.withdrawals.length>0&&ce.set(E.TransactionBodyItemType.WITHDRAWALS,(0,B.encodeWithdrawals)(this.withdrawals)),this.auxiliaryData){const vt=(0,B.encodeAuxiliaryData)(this.auxiliaryData),ur=y.Encoder.encode(vt),ue=(0,ae.hash32)(ur);ce.set(E.TransactionBodyItemType.AUXILIARY_DATA_HASH,ue)}w.default.isEmpty(this.mints)||ce.set(E.TransactionBodyItemType.MINT,(0,B.encodeMint)(this.mints)),sr&&ce.set(E.TransactionBodyItemType.SCRIPT_DATA_HASH,sr),w.default.isEmpty(this.collaterals)||ce.set(E.TransactionBodyItemType.COLLATERAL_INPUTS,(0,B.encodeCollaterals)(this.collaterals));const se=Array.from(this.requiredSigners.keys());return w.default.isEmpty(se)||ce.set(E.TransactionBodyItemType.REQUIRED_SIGNERS,se.map((vt=>h.Buffer.from(vt,"hex")))),ce}transactionFee(nr){return new b.default(nr).times(this._protocolParams.minFeeA).plus(this._protocolParams.minFeeB).integerValue(b.default.ROUND_CEIL)}contractFee(){let nr=0,sr=0;for(const se of this.inputs)se.redeemer&&(nr+=se.redeemer.exUnits.mem,sr+=se.redeemer.exUnits.steps);for(const se of this.mints)se.redeemer&&(nr+=se.redeemer.exUnits.mem,sr+=se.redeemer.exUnits.steps);const ce=new b.default(nr).times(this._protocolParams.priceMem),Ze=new b.default(sr).times(this._protocolParams.priceSteps);return ce.plus(Ze).integerValue(b.default.ROUND_CEIL)}calculateTxSize(nr){const sr=new Map;for(const[ur,ue]of this.requiredNativeScriptWitnesses.entries())sr.set(ur,ue);for(const[ur,ue]of this.requiredSigners.entries())sr.set(ur,ue);for(const[ur,ue]of this.requiredWitnesses.entries())sr.set(ur,ue);const ce=[];for(const[ur]of Array.from(sr.keys()).entries())ce.push({publicKey:h.Buffer.alloc(32,ur),signature:h.Buffer.alloc(64)});const Ze=(0,B.encodeWitnesses)(ce,this.inputs,this.plutusDataList,this.plutusScriptMap,this.nativeScriptList,this.mints),se=(0,S.generateScriptDataHash)(Ze,this._protocolParams.languageView),vt=[this.transactionBody({extraOutputs:nr,scriptDataHash:se}),Ze,!0,this.auxiliaryData?(0,B.encodeAuxiliaryData)(this.auxiliaryData):null];return y.Encoder.encode(vt).length}calculateFee(nr){const sr=this.calculateTxSize(nr),ce=this.transactionFee(sr),Ze=this.contractFee();return ce.plus(Ze)}setFee(nr){this.fee=nr}getFee(){return this.fee}calculateMinUtxoAmount(nr,sr){return(0,W.calculateMinUtxoAmount)(nr,this._protocolParams.lovelacePerUtxoWord,sr)}addWitness(nr){this.witnesses.push(nr)}getTransactionHash(){const nr=(0,B.encodeWitnesses)(this.witnesses,this.inputs,this.plutusDataList,this.plutusScriptMap,this.nativeScriptList,this.mints),sr=(0,S.generateScriptDataHash)(nr,this._protocolParams.languageView),ce=this.transactionBody({scriptDataHash:sr}),Ze=y.Encoder.encode(ce);return(0,ae.hash32)(Ze)}getAuxiliaryData(){return this.auxiliaryData}getAuxiliaryDataHashHex(){if(this.auxiliaryData){const nr=(0,B.encodeAuxiliaryData)(this.auxiliaryData),sr=y.Encoder.encode(nr);return(0,ae.hash32)(sr).toString("hex")}}buildTransaction(){const nr=(0,B.encodeWitnesses)(this.witnesses,this.inputs,this.plutusDataList,this.plutusScriptMap,this.nativeScriptList,this.mints),sr=(0,S.generateScriptDataHash)(nr,this._protocolParams.languageView),ce=this.transactionBody({scriptDataHash:sr}),Ze=[ce,nr,!0,this.auxiliaryData?(0,B.encodeAuxiliaryData)(this.auxiliaryData):null],se=y.Encoder.encode(Ze),vt=y.Encoder.encode(ce);return{hash:(0,ae.hash32)(vt).toString("hex"),payload:se.toString("hex")}}getInputs(){return this.inputs}getCertificates(){return this.certificates}getMints(){const nr=[];for(const ce of this.mints)for(const Ze of ce.assets)nr.push({policyId:ce.policyId,assetName:Ze.assetName,amount:Ze.amount});const sr=(0,S.sortTokens)(nr);return(0,w.default)(sr).groupBy((ce=>ce.policyId)).map(((ce,Ze)=>({policyId:Ze,assets:ce.map((se=>({assetName:se.assetName,amount:se.amount})))}))).value()}getMintTokens(){const nr=[];for(const sr of this.mints)for(const ce of sr.assets)ce.amount.isPositive()&&nr.push({policyId:sr.policyId,assetName:ce.assetName,amount:ce.amount});return nr}getBurnTokens(){const nr=[];for(const sr of this.mints)for(const ce of sr.assets)ce.amount.isNegative()&&nr.push({policyId:sr.policyId,assetName:ce.assetName,amount:ce.amount.abs()});return nr}getInputAmount(){let nr=[],sr=new b.default(0);return w.default.forEach(this.inputs,(ce=>{nr=nr.concat(ce.tokens),sr=sr.plus(ce.amount)})),nr=w.default.concat(nr,this.getMintTokens()),{ada:sr,tokens:(0,S.getUniqueTokens)(nr)}}getCollaterals(){return this.collaterals}getScriptIntegrityHash(){const nr=(0,B.encodeWitnesses)(this.witnesses,this.inputs,this.plutusDataList,this.plutusScriptMap,this.nativeScriptList,this.mints);return(0,S.generateScriptDataHash)(nr,this._protocolParams.languageView)}getCollateralAmount(){return this.collaterals.reduce(((nr,sr)=>nr.plus(sr.amount)),new b.default(0))}getOutputs(){return this.outputs}getOutputAmount(){let nr=[],sr=new b.default(0);return w.default.forEach(this.outputs,(ce=>{nr=nr.concat(ce.tokens),sr=sr.plus(ce.amount)})),nr=w.default.concat(nr,this.getBurnTokens()),{ada:sr,tokens:(0,S.getUniqueTokens)(nr)}}getAdditionalOutputAda(){return w.default.reduce(this.certificates,((nr,sr)=>sr.certType===E.CertificateType.STAKE_REGISTRATION?nr.plus(this._protocolParams.stakeKeyDeposit):nr),new b.default(0))}getAdditionalInputAda(){const nr=w.default.reduce(this.certificates,((ce,Ze)=>Ze.certType===E.CertificateType.STAKE_DE_REGISTRATION?ce.plus(this._protocolParams.stakeKeyDeposit):ce),new b.default(0)),sr=w.default.reduce(this.withdrawals,((ce,Ze)=>ce.plus(Ze.amount)),new b.default(0));return nr.plus(sr)}getWithdrawals(){return this.withdrawals}getRequiredWitnesses(){return this.requiredWitnesses}getRequiredNativeScriptWitnesses(){return this.requiredNativeScriptWitnesses}getRequiredSigners(){return this.requiredSigners}setAuxiliaryData(nr){this.auxiliaryData=nr}isPlutusTransaction(){return this._isPlutusTransaction}prepareTransaction({inputs:nr,changeAddress:sr,collateralInputs:ce=[]}){return(0,J.default)({transaction:this,inputs:nr,changeAddress:sr,collateralInputs:ce})}paymentTransaction({inputs:nr,outputs:sr,changeAddress:ce,auxiliaryData:Ze,ttl:se}){return(0,ve.paymentTransaction)({inputs:nr,outputs:sr,changeAddress:ce,auxiliaryData:Ze,ttl:se,protocolParams:this.protocolParams})}}a.Transaction=Qe,a.default=Qe},9494:function(u,a,s){var f=this&&this.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(a,"__esModule",{value:!0}),a.paymentTransaction=void 0;const c=f(s(9779));a.paymentTransaction=({inputs:d,outputs:p,changeAddress:h,auxiliaryData:y,ttl:b,protocolParams:w})=>{const S=new c.default({protocolParams:w});return p.forEach((E=>{S.addOutput(E)})),S.setTTL(b),y&&S.setAuxiliaryData(y),S.prepareTransaction({inputs:d,changeAddress:h})},a.default=a.paymentTransaction},9677:function(u,a,s){var f=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(a,"__esModule",{value:!0}),a.transactionBuilder=void 0;const c=f(s(4431)),d=s(6486),p=s(2027),h=s(6397);function y({transaction:b,inputs:w,changeAddress:S,collateralInputs:E=[]}){const B=bt=>{const L=b.getCollateralAmount(),_=bt.times(b.protocolParams.collateralPercent).div(100);if(b.isPlutusTransaction()&&L.lt(_))throw new Error("Not enough collateral supplied, collaterals with tokens are not valid collaterals")},ae=bt=>{if(E&&E.length>0){const L=b.getCollateralAmount(),_=bt.times(b.protocolParams.collateralPercent).div(100);for(;L.lt(_)&&E.length>0;){const F=E.pop();F&&b.addCollateral(F)}}},W=(0,h.calculateMinUtxoAmount)([],new c.default(b.protocolParams.lovelacePerUtxoWord)),J=d.cloneDeep(w);if(J.length>0){const bt=J.splice(0,1)[0];b.addInput(bt)}const ve=E.pop();ve&&b.addCollateral(ve);for(const bt of J){const{ada:L,tokens:_}=b.getInputAmount(),{ada:F,tokens:k}=b.getOutputAmount(),Ye=b.getAdditionalOutputAda(),rn=b.getAdditionalInputAda();let ii=b.calculateFee();ae(ii),ii=b.calculateFee();const ai=L.plus(rn),ni=F.plus(Ye).plus(ii),ri=(0,p.getTokenDiff)(_,k);if(ri.length===0){if(ai.eq(ni))break;if(ai.gt(ni)){const ui=ai.minus(F.plus(Ye));if(ui.gt(W)){let lr=b.calculateFee([{address:S,amount:ui,tokens:[]}]);if(ae(ii),lr=b.calculateFee([{address:S,amount:ui,tokens:[]}]),ui.gte(lr.plus(W)))break}}}else if(!ri.some((({amount:ui})=>ui.lt(0)))){const ui=(0,h.getMaximumTokenSets)(ri),lr=[];let ar=ai.minus(F.plus(Ye)),jr=new c.default(0);for(const[ci,mi]of ui.entries()){const pi=(0,h.calculateMinUtxoAmount)(mi,new c.default(b.protocolParams.lovelacePerUtxoWord));let ei=pi;if(ci===ui.length-1){let Gr=b.calculateFee([...lr,{address:S,amount:ar.lt(pi)?pi:ar,tokens:mi}]);ae(Gr),Gr=b.calculateFee([...lr,{address:S,amount:ar.lt(pi)?pi:ar,tokens:mi}]);const ti=pi.plus(Gr);ar.gte(ti)?ei=ar:jr=jr.plus(ti.minus(ar))}else ar.gte(pi)?ar=ar.minus(pi):jr=jr.plus(pi.minus(ar));lr.push({address:S,amount:ei,tokens:mi})}if(jr.eq(0))break}b.addInput(bt)}const{ada:Qe,tokens:kt}=b.getInputAmount(),{ada:nr,tokens:sr}=b.getOutputAmount(),ce=b.getAdditionalOutputAda(),Ze=b.getAdditionalInputAda(),se=Qe.plus(Ze),vt=nr.plus(ce),ur=(0,p.getTokenDiff)(kt,sr);if(ur.length===0){const bt=b.calculateFee(),L=vt.plus(bt);if(se.eq(L))b.setFee(bt),B(bt);else{if(!se.gt(L))throw new Error("Not enough ADA");{const _=se.minus(vt);if(_.gt(W.plus(bt))){const F=b.calculateFee([{address:S,amount:_,tokens:[]}]);B(F),b.setFee(F),b.addOutput({address:S,amount:_.minus(F),tokens:[]})}else b.setFee(_)}}}else{if(ur.some((({amount:bt})=>bt.lt(0))))throw new Error("Not enough tokens");{const bt=(0,h.getMaximumTokenSets)(d.clone(ur)),L=[];{let k=se.minus(vt);bt.forEach(((Ye,rn)=>{const ii=(0,h.calculateMinUtxoAmount)(Ye,new c.default(b.protocolParams.lovelacePerUtxoWord));let ai=ii;if(rn===bt.length-1){const ni=b.calculateFee([...L,{address:S,amount:k.lt(ii)?ii:k,tokens:Ye}]),ri=ii.plus(ni);if(!k.gte(ri))throw new Error("Not enough ADA");ai=k}else{if(!k.gte(ii))throw new Error("Not enough ADA");k=k.minus(ii)}L.push({address:S,amount:ai,tokens:Ye})}))}const _=b.calculateFee(L);B(_),b.setFee(_);let F=se.minus(vt).minus(_);bt.forEach(((k,Ye)=>{const rn=(0,h.calculateMinUtxoAmount)(k,new c.default(b.protocolParams.lovelacePerUtxoWord));let ii=rn;Ye===bt.length-1?ii=F:F.gte(rn)&&(F=F.minus(rn)),b.addOutput({address:S,amount:ii,tokens:k})}))}}const ue=b.calculateTxSize();if(b.protocolParams.maxTxSize&&ue>b.protocolParams.maxTxSize)throw new Error("Tx size limit reached, try spending lesser ADA/Tokens");return b}a.transactionBuilder=y,a.default=y},23:(u,a)=>{var s,f,c,d,p;Object.defineProperty(a,"__esModule",{value:!0}),a.TransactionBodyItemType=a.NetworkId=a.WitnessType=a.CertificateType=a.PlutusScriptType=a.HashType=void 0,(p=a.HashType||(a.HashType={}))[p.ADDRESS=0]="ADDRESS",p[p.SCRIPT=1]="SCRIPT",(a.PlutusScriptType||(a.PlutusScriptType={})).PlutusScriptV1="PlutusScriptV1",(d=a.CertificateType||(a.CertificateType={}))[d.STAKE_REGISTRATION=0]="STAKE_REGISTRATION",d[d.STAKE_DE_REGISTRATION=1]="STAKE_DE_REGISTRATION",d[d.STAKE_DELEGATION=2]="STAKE_DELEGATION",(c=a.WitnessType||(a.WitnessType={}))[c.V_KEY_WITNESS=0]="V_KEY_WITNESS",c[c.NATIVE_SCRIPT=1]="NATIVE_SCRIPT",c[c.PLUTUS_SCRIPT=3]="PLUTUS_SCRIPT",c[c.PLUTUS_DATA=4]="PLUTUS_DATA",c[c.REDEEMER=5]="REDEEMER",(f=a.NetworkId||(a.NetworkId={}))[f.MAINNET=1]="MAINNET",f[f.TESTNET=0]="TESTNET",(s=a.TransactionBodyItemType||(a.TransactionBodyItemType={}))[s.INPUTS=0]="INPUTS",s[s.OUTPUTS=1]="OUTPUTS",s[s.FEE=2]="FEE",s[s.TTL=3]="TTL",s[s.CERTIFICATES=4]="CERTIFICATES",s[s.WITHDRAWALS=5]="WITHDRAWALS",s[s.AUXILIARY_DATA_HASH=7]="AUXILIARY_DATA_HASH",s[s.VALIDITY_INTERVAL_START=8]="VALIDITY_INTERVAL_START",s[s.MINT=9]="MINT",s[s.SCRIPT_DATA_HASH=11]="SCRIPT_DATA_HASH",s[s.COLLATERAL_INPUTS=13]="COLLATERAL_INPUTS",s[s.REQUIRED_SIGNERS=14]="REQUIRED_SIGNERS"},3678:(u,a,s)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.hash28=a.hash32=void 0;const f=s(8764),c=s(1191);a.hash32=d=>{const p=(0,c.blake2b)(d,void 0,32);return f.Buffer.from(p)},a.hash28=d=>{const p=(0,c.blake2b)(d,void 0,28);return f.Buffer.from(p)}},6171:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(ve,Qe,kt,nr){nr===void 0&&(nr=kt);var sr=Object.getOwnPropertyDescriptor(Qe,kt);sr&&!("get"in sr?!Qe.__esModule:sr.writable||sr.configurable)||(sr={enumerable:!0,get:function(){return Qe[kt]}}),Object.defineProperty(ve,nr,sr)}:function(ve,Qe,kt,nr){nr===void 0&&(nr=kt),ve[nr]=Qe[kt]}),c=this&&this.__setModuleDefault||(Object.create?function(ve,Qe){Object.defineProperty(ve,"default",{enumerable:!0,value:Qe})}:function(ve,Qe){ve.default=Qe}),d=this&&this.__importStar||function(ve){if(ve&&ve.__esModule)return ve;var Qe={};if(ve!=null)for(var kt in ve)kt!=="default"&&Object.prototype.hasOwnProperty.call(ve,kt)&&f(Qe,ve,kt);return c(Qe,ve),Qe},p=this&&this.__importDefault||function(ve){return ve&&ve.__esModule?ve:{default:ve}};Object.defineProperty(a,"__esModule",{value:!0}),a.encodeNativeScript=a.encodeLanguageViews=a.encodePlutusData=a.encodeAuxiliaryData=a.encodeMetadata=a.encodeWitnesses=a.encodeVKeyWitness=a.encodeCertificates=a.encodeStakeDelegationCertificate=a.encodeStakeDeRegistrationCertificate=a.encodeStakeRegistrationCertificate=a.encodeWithdrawals=a.encodeOutputs=a.encodeOutput=a.encodeMint=a.encodeOutputTokens=a.encodeCollaterals=a.encodeInputs=void 0;const h=s(8764),y=d(s(7730)),b=p(s(4431)),w=p(s(6486)),S=s(23),E=s(2027),B=s(3678),ae=s(7067);a.encodeInputs=ve=>ve.map((Qe=>[h.Buffer.from(Qe.txId,"hex"),Qe.index])),a.encodeCollaterals=ve=>ve.map((Qe=>[h.Buffer.from(Qe.txId,"hex"),Qe.index])),a.encodeOutputTokens=ve=>{const Qe=new Map,kt=(0,w.default)(ve).groupBy((({policyId:nr})=>nr)).value();return w.default.forEach(kt,((nr,sr)=>{const ce=new Map;nr.forEach((({assetName:Ze,amount:se})=>{ce.set(h.Buffer.from(Ze,"hex"),se)})),Qe.set(h.Buffer.from(sr,"hex"),ce)})),Qe},a.encodeMint=ve=>{const Qe=new Map;for(const kt of ve){const nr=new Map;kt.assets.forEach((({assetName:sr,amount:ce})=>{nr.set(h.Buffer.from(sr,"hex"),ce)})),Qe.set(h.Buffer.from(kt.policyId,"hex"),nr)}return Qe},a.encodeOutput=ve=>{const Qe=ve.tokens.length>0?[ve.amount,(0,a.encodeOutputTokens)(ve.tokens)]:ve.amount,kt=[ve.address.getBytes(),Qe],nr=ve.plutusDataHash?h.Buffer.from(ve.plutusDataHash,"hex"):void 0;return nr&&kt.push(nr),kt},a.encodeOutputs=ve=>ve.map((Qe=>(0,a.encodeOutput)(Qe)),[]),a.encodeWithdrawals=ve=>{const Qe=new Map;return ve.forEach((kt=>{const nr=kt.rewardAccount.getBytes();Qe.set(nr,kt.amount)})),Qe},a.encodeStakeRegistrationCertificate=ve=>{const Qe=h.Buffer.from(ve.stakeCredential.hash,"hex"),kt=[ve.stakeCredential.type,Qe];return[S.CertificateType.STAKE_REGISTRATION,kt]},a.encodeStakeDeRegistrationCertificate=ve=>{const Qe=h.Buffer.from(ve.stakeCredential.hash,"hex"),kt=[ve.stakeCredential.type,Qe];return[S.CertificateType.STAKE_DE_REGISTRATION,kt]},a.encodeStakeDelegationCertificate=ve=>{const Qe=h.Buffer.from(ve.stakeCredential.hash,"hex"),kt=[ve.stakeCredential.type,Qe],nr=h.Buffer.from(ve.poolHash,"hex");return[S.CertificateType.STAKE_DELEGATION,kt,nr]},a.encodeCertificates=ve=>{const Qe=[];return ve.forEach((kt=>{switch(kt.certType){case S.CertificateType.STAKE_REGISTRATION:Qe.push((0,a.encodeStakeRegistrationCertificate)(kt));break;case S.CertificateType.STAKE_DE_REGISTRATION:Qe.push((0,a.encodeStakeDeRegistrationCertificate)(kt));break;case S.CertificateType.STAKE_DELEGATION:Qe.push((0,a.encodeStakeDelegationCertificate)(kt));break;default:throw new Error("unsupported certificate type")}})),Qe},a.encodeVKeyWitness=ve=>{const Qe=new Map;for(const nr of ve)Qe.set(nr.publicKey.toString("hex"),nr.signature);const kt=[];for(const[nr,sr]of Qe)kt.push([h.Buffer.from(nr,"hex"),sr]);return kt},a.encodeWitnesses=(ve,Qe,kt,nr,sr,ce)=>{const Ze=new Map;ve.length>0&&Ze.set(S.WitnessType.V_KEY_WITNESS,(0,a.encodeVKeyWitness)(ve));const se=w.default.orderBy(Qe,["txId","index"],["asc","asc"]),vt=w.default.orderBy(ce,["policyId"],["asc"]),ur=[],ue=new Map;for(const k of kt){const Ye=(0,a.encodePlutusData)(k),rn=y.Encoder.encode(Ye),ii=(0,B.hash32)(rn);ue.set(ii.toString("hex"),Ye)}for(const[k,Ye]of se.entries())if(Ye.redeemer){const rn=(0,a.encodePlutusData)(Ye.redeemer.plutusData);ur.push([ae.RedeemerTag.SPEND,k,rn,[Ye.redeemer.exUnits.mem,Ye.redeemer.exUnits.steps]])}for(const[k,Ye]of vt.entries())if(Ye.plutusScript&&Ye.redeemer){const rn=(0,a.encodePlutusData)(Ye.redeemer.plutusData);ur.push([ae.RedeemerTag.MINT,k,rn,[Ye.redeemer.exUnits.mem,Ye.redeemer.exUnits.steps]])}const bt=[];for(const[,k]of ue)bt.push(k);const L=[];for(const[k,Ye]of nr){if(Ye!==S.PlutusScriptType.PlutusScriptV1)throw new Error("Unsupported PlutusScript Version");{const rn=y.Decoder.decode(h.Buffer.from(k,"hex"));L.push(rn.value)}}L.length&&Ze.set(S.WitnessType.PLUTUS_SCRIPT,L);const _=new Map;for(const k of sr){const Ye=(0,a.encodeNativeScript)(k),rn=y.Encoder.encode(Ye);_.set(rn.toString("hex"),Ye)}const F=[];for(const[,k]of _)F.push(k);return F.length&&Ze.set(S.WitnessType.NATIVE_SCRIPT,F),bt.length&&Ze.set(S.WitnessType.PLUTUS_DATA,bt),ur.length&&Ze.set(S.WitnessType.REDEEMER,ur),Ze},a.encodeMetadata=ve=>{const Qe=new Map;for(const kt of ve)Qe.set(kt.label,(0,E.sanitizeMetadata)(kt.data));return Qe},a.encodeAuxiliaryData=ve=>{const Qe=(0,a.encodeMetadata)(ve.metadata),kt=new Map;return kt.set(0,Qe),new y.CborTag(kt,259)};const W=["constructor","fields"];a.encodePlutusData=ve=>{if(ve instanceof Array){if(ve.length>0){const Qe=new y.IndefiniteArray;for(const kt of ve)Qe.push((0,a.encodePlutusData)(kt));return Qe}return[]}if(ve instanceof Uint8Array)return h.Buffer.from(ve);if(ve instanceof h.Buffer)return ve;if(typeof ve=="string")throw new Error("String not supported in PlutusData");if(ve instanceof Map){if(ve.size>0){const Qe=new y.IndefiniteMap;for(const[kt,nr]of ve.entries())Qe.set(kt,(0,a.encodePlutusData)(nr));return Qe}return new Map}return b.default.isBigNumber(ve)?ve:ve instanceof Object?(Qe=>{if(!(Object.keys(Qe).every((nr=>W.includes(nr)))&&Qe.fields instanceof Array))throw new Error("Invalid PlutusData supplied");let kt=[];if(Qe.fields.length>0){kt=new y.IndefiniteArray;for(const nr of Qe.fields)kt.push((0,a.encodePlutusData)(nr))}if(Qe.constructor<7)return new y.CborTag(kt,121+Qe.constructor);if(Qe.constructor>6&&Qe.constructor<128){const nr=Qe.constructor-7;return new y.CborTag(kt,1280+nr)}return new y.CborTag([Qe.constructor,kt],102)})(ve):ve},a.encodeLanguageViews=(ve,Qe)=>{const kt=new Map;if(Qe&&Qe.length>0){const nr=(0,w.default)(ve.PlutusScriptV1).map(((se,vt)=>({key:vt,value:se}))).orderBy(["key"],["asc"]).map((se=>se.value)).value(),sr=y.IndefiniteArray.from(nr),ce=y.Encoder.encode(sr),Ze=y.Encoder.encode(0);kt.set(Ze,ce)}return y.Encoder.encode(kt).toString("hex")};const J=ve=>{const Qe=[];for(const kt of ve)Qe.push((0,a.encodeNativeScript)(kt));return Qe};a.encodeNativeScript=ve=>{if(ve.pubKeyHash)return[0,h.Buffer.from(ve.pubKeyHash,"hex")];if(ve.all)return[1,J(ve.all)];if(ve.any)return[2,J(ve.any)];if(ve.n)return[3,ve.n,J(ve.k)];if(ve.invalidBefore)return[4,ve.invalidBefore];if(ve.invalidAfter)return[5,ve.invalidAfter];throw new Error("Invalid native script")}},2027:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(W,J,ve,Qe){Qe===void 0&&(Qe=ve);var kt=Object.getOwnPropertyDescriptor(J,ve);kt&&!("get"in kt?!J.__esModule:kt.writable||kt.configurable)||(kt={enumerable:!0,get:function(){return J[ve]}}),Object.defineProperty(W,Qe,kt)}:function(W,J,ve,Qe){Qe===void 0&&(Qe=ve),W[Qe]=J[ve]}),c=this&&this.__setModuleDefault||(Object.create?function(W,J){Object.defineProperty(W,"default",{enumerable:!0,value:J})}:function(W,J){W.default=J}),d=this&&this.__importStar||function(W){if(W&&W.__esModule)return W;var J={};if(W!=null)for(var ve in W)ve!=="default"&&Object.prototype.hasOwnProperty.call(W,ve)&&f(J,W,ve);return c(J,W),J},p=this&&this.__importDefault||function(W){return W&&W.__esModule?W:{default:W}};Object.defineProperty(a,"__esModule",{value:!0}),a.getPubKeyHashListFromNativeScript=a.generateScriptDataHash=a.sortTokens=a.compareCanonically=a.sanitizeMetadata=a.getTokenDiff=a.getUniqueTokens=void 0;const h=s(8764),y=d(s(7730)),b=p(s(4431)),w=p(s(6486)),S=s(6171),E=s(23),B=s(3678);a.getUniqueTokens=W=>(0,w.default)(W).groupBy((({policyId:J})=>J)).map(((J,ve)=>(0,w.default)(J).groupBy((({assetName:Qe})=>Qe)).map(((Qe,kt)=>({policyId:ve,assetName:kt,amount:Qe.reduce(((nr,sr)=>nr.plus(sr.amount)),new b.default(0))}))).value())).flatten().value(),a.getTokenDiff=(W,J)=>{const ve=w.default.map(J,(Qe=>Object.assign(Object.assign({},Qe),{amount:Qe.amount.negated()})));return(0,a.getUniqueTokens)(W.concat(ve)).filter((Qe=>Qe.amount.abs().gt(0)))},a.sanitizeMetadata=W=>{if(W instanceof Array){const J=[];for(const ve of W)J.push((0,a.sanitizeMetadata)(ve));return J}if(typeof W=="string"||W instanceof h.Buffer){if(W.length>64)throw new Error("string or buffer length invalid");return W}if(W instanceof Map){const J=new Map;for(const[ve,Qe]of W.entries())J.set(ve,(0,a.sanitizeMetadata)(Qe));return J}if(W instanceof Object){const J=new Map;for(const[ve,Qe]of Object.entries(W))J.set(ve,(0,a.sanitizeMetadata)(Qe));return J}return W},a.compareCanonically=(W,J)=>W.length!==J.length?W.length-J.length:(W=W.toLowerCase())<(J=J.toLowerCase())?-1:W>J?1:0,a.sortTokens=W=>(0,w.default)(W).orderBy(["policyId","assetName"],["asc","asc"]).sort(((J,ve)=>(0,a.compareCanonically)(J.assetName,ve.assetName))).sort(((J,ve)=>(0,a.compareCanonically)(J.policyId,ve.policyId))).value(),a.generateScriptDataHash=(W,J)=>{const ve=W.get(E.WitnessType.PLUTUS_DATA),Qe=W.get(E.WitnessType.REDEEMER);if(ve||Qe){const kt=W.get(E.WitnessType.PLUTUS_SCRIPT),nr=(0,S.encodeLanguageViews)(J,kt),sr=ve?.length?y.Encoder.encode(ve).toString("hex"):"",ce=Qe?y.Encoder.encode(Qe).toString("hex"):y.Encoder.encode([]).toString("hex"),Ze=h.Buffer.from(ce+sr+nr,"hex");return(0,B.hash32)(Ze)}};const ae=W=>{let J=[];for(const ve of W){const Qe=(0,a.getPubKeyHashListFromNativeScript)(ve);J=w.default.concat(J,w.default.flatten(Qe))}return J};a.getPubKeyHashListFromNativeScript=W=>{let J=[];if(W.pubKeyHash)J.push(W.pubKeyHash);else if(W.all){const ve=ae(W.all);J=w.default.concat(J,w.default.flatten(ve))}else if(W.any){const ve=ae(W.any);J=w.default.concat(J,w.default.flatten(ve))}else if(W.n){const ve=ae(W.k);J=w.default.concat(J,w.default.flatten(ve))}return J}},6397:function(u,a,s){var f=this&&this.__createBinding||(Object.create?function(ce,Ze,se,vt){vt===void 0&&(vt=se);var ur=Object.getOwnPropertyDescriptor(Ze,se);ur&&!("get"in ur?!Ze.__esModule:ur.writable||ur.configurable)||(ur={enumerable:!0,get:function(){return Ze[se]}}),Object.defineProperty(ce,vt,ur)}:function(ce,Ze,se,vt){vt===void 0&&(vt=se),ce[vt]=Ze[se]}),c=this&&this.__setModuleDefault||(Object.create?function(ce,Ze){Object.defineProperty(ce,"default",{enumerable:!0,value:Ze})}:function(ce,Ze){ce.default=Ze}),d=this&&this.__importStar||function(ce){if(ce&&ce.__esModule)return ce;var Ze={};if(ce!=null)for(var se in ce)se!=="default"&&Object.prototype.hasOwnProperty.call(ce,se)&&f(Ze,ce,se);return c(Ze,ce),Ze},p=this&&this.__importDefault||function(ce){return ce&&ce.__esModule?ce:{default:ce}};Object.defineProperty(a,"__esModule",{value:!0}),a.createPlutusDataCbor=a.createAuxiliaryDataCbor=a.getMaximumTokenSets=a.getAddressFromBech32=a.decodeBech32=a.getAddressFromHex=a.calculateMinUtxoAmount=void 0;const h=s(8764),y=d(s(7730)),b=p(s(4431)),w=s(6486),S=p(s(7191)),E=s(7715),B=s(1617),ae=p(s(7801)),W=p(s(5027)),J=p(s(1989)),ve=p(s(9105)),Qe=s(2027),kt=s(23),nr=p(s(7452)),sr=s(6171);a.calculateMinUtxoAmount=(ce,Ze,se)=>{const vt=(0,Qe.getUniqueTokens)(ce);let ur=27;se&&(ur+=10);const ue=ur+2,bt=w(vt).groupBy((({policyId:ai})=>ai)).value(),L=vt.reduce(((ai,ni)=>(ai[ni.assetName]=!0,ai)),{}),_=w.reduce(bt,(ai=>ai+1),0),F=w.reduce(L,((ai,ni,ri)=>ai+Math.max(h.Buffer.from(ri,"hex").length,1)),0),k=6+(Ye=12*vt.length+F+28*_,Math.floor((Ye+7)/8));var Ye;const rn=Ze.toNumber()*ue;if(vt.length===0)return new b.default(rn);const ii=Ze.toNumber()*(ur+k);return b.default.max(rn,ii)},a.getAddressFromHex=ce=>{const Ze=ce.toLowerCase().charAt(0),se=Number(ce.toLowerCase().charAt(1));let vt,ur;switch(Ze){case"e":return vt={hash:ce.slice(2).slice(0,56),type:kt.HashType.ADDRESS},new nr.default(se,vt);case"f":return vt={hash:ce.slice(2).slice(0,56),type:kt.HashType.SCRIPT},new nr.default(se,vt);case"7":return ur={hash:ce.slice(2),type:kt.HashType.SCRIPT},new J.default(se,ur);case"6":return ur={hash:ce.slice(2),type:kt.HashType.ADDRESS},new J.default(se,ur);case"5":{ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.SCRIPT};const ue=ce.slice(2).slice(56);return new ve.default(se,ur,ue)}case"4":{ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.ADDRESS};const ue=ce.slice(2).slice(56);return new ve.default(se,ur,ue)}case"3":return ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.SCRIPT},vt={hash:ce.slice(2).slice(56),type:kt.HashType.SCRIPT},new ae.default(se,ur,vt);case"2":return ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.ADDRESS},vt={hash:ce.slice(2).slice(56),type:kt.HashType.SCRIPT},new ae.default(se,ur,vt);case"1":return ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.SCRIPT},vt={hash:ce.slice(2).slice(56),type:kt.HashType.ADDRESS},new ae.default(se,ur,vt);case"0":return ur={hash:ce.slice(2).slice(0,56),type:kt.HashType.ADDRESS},vt={hash:ce.slice(2).slice(56),type:kt.HashType.ADDRESS},new ae.default(se,ur,vt);case"8":return new W.default(h.Buffer.from(ce,"hex"));default:throw new Error("Unsupported address type")}},a.decodeBech32=ce=>{const Ze=E.bech32.decode(ce,114),se=E.bech32.fromWords(Ze.words),vt=h.Buffer.from(se).toString("hex");return{prefix:Ze.prefix,value:vt}},a.getAddressFromBech32=ce=>{try{const Ze=h.Buffer.from(S.default.decode(ce));try{y.Decoder.decode(Ze)}catch{throw new Error("Invalid Byron Address")}return new W.default(Ze)}catch{try{const se=(0,a.decodeBech32)(ce);if(se.prefix==="addr"||se.prefix==="addr_test"||se.prefix==="stake"||se.prefix==="stake_test")return(0,a.getAddressFromHex)(se.value);throw new Error("Invalid Address")}catch{throw new Error("Invalid Address")}}},a.getMaximumTokenSets=ce=>{const Ze=w.cloneDeep(ce),se=[];for(;Ze.length>0;){const vt=[],ur=Ze.length;for(let ue=0;ue<ur;ue+=1){const bt=Ze.pop();bt.amount.lte(B.maxTokenAmount)?vt.push(bt):(vt.push({assetName:bt.assetName,policyId:bt.policyId,amount:new b.default(B.maxTokenAmount)}),bt.amount=bt.amount.minus(B.maxTokenAmount),Ze.push(bt))}se.push(vt)}return se},a.createAuxiliaryDataCbor=ce=>{const Ze=(0,sr.encodeAuxiliaryData)(ce);return y.Encoder.encode(Ze)},a.createPlutusDataCbor=ce=>{const Ze=(0,sr.encodePlutusData)(ce);return y.Encoder.encode(Ze)}},8162:u=>{u.exports=function(a){if(a.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),f=0;f<s.length;f++)s[f]=255;for(var c=0;c<a.length;c++){var d=a.charAt(c),p=d.charCodeAt(0);if(s[p]!==255)throw new TypeError(d+" is ambiguous");s[p]=c}var h=a.length,y=a.charAt(0),b=Math.log(h)/Math.log(256),w=Math.log(256)/Math.log(h);function S(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;for(var B=0,ae=0,W=0;E[B]===y;)ae++,B++;for(var J=(E.length-B)*b+1>>>0,ve=new Uint8Array(J);E[B];){var Qe=s[E.charCodeAt(B)];if(Qe===255)return;for(var kt=0,nr=J-1;(Qe!==0||kt<W)&&nr!==-1;nr--,kt++)Qe+=h*ve[nr]>>>0,ve[nr]=Qe%256>>>0,Qe=Qe/256>>>0;if(Qe!==0)throw new Error("Non-zero carry");W=kt,B++}for(var sr=J-W;sr!==J&&ve[sr]===0;)sr++;for(var ce=new Uint8Array(ae+(J-sr)),Ze=ae;sr!==J;)ce[Ze++]=ve[sr++];return ce}return{encode:function(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var B=0,ae=0,W=0,J=E.length;W!==J&&E[W]===0;)W++,B++;for(var ve=(J-W)*w+1>>>0,Qe=new Uint8Array(ve);W!==J;){for(var kt=E[W],nr=0,sr=ve-1;(kt!==0||nr<ae)&&sr!==-1;sr--,nr++)kt+=256*Qe[sr]>>>0,Qe[sr]=kt%h>>>0,kt=kt/h>>>0;if(kt!==0)throw new Error("Non-zero carry");ae=nr,W++}for(var ce=ve-ae;ce!==ve&&Qe[ce]===0;)ce++;for(var Ze=y.repeat(B);ce<ve;++ce)Ze+=a.charAt(Qe[ce]);return Ze},decodeUnsafe:S,decode:function(E){var B=S(E);if(B)return B;throw new Error("Non-base"+h+" character")}}}},9742:(u,a)=>{a.byteLength=function(w){var S=y(w),E=S[0],B=S[1];return 3*(E+B)/4-B},a.toByteArray=function(w){var S,E,B=y(w),ae=B[0],W=B[1],J=new c((function(kt,nr,sr){return 3*(nr+sr)/4-sr})(0,ae,W)),ve=0,Qe=W>0?ae-4:ae;for(E=0;E<Qe;E+=4)S=f[w.charCodeAt(E)]<<18|f[w.charCodeAt(E+1)]<<12|f[w.charCodeAt(E+2)]<<6|f[w.charCodeAt(E+3)],J[ve++]=S>>16&255,J[ve++]=S>>8&255,J[ve++]=255&S;return W===2&&(S=f[w.charCodeAt(E)]<<2|f[w.charCodeAt(E+1)]>>4,J[ve++]=255&S),W===1&&(S=f[w.charCodeAt(E)]<<10|f[w.charCodeAt(E+1)]<<4|f[w.charCodeAt(E+2)]>>2,J[ve++]=S>>8&255,J[ve++]=255&S),J},a.fromByteArray=function(w){for(var S,E=w.length,B=E%3,ae=[],W=16383,J=0,ve=E-B;J<ve;J+=W)ae.push(b(w,J,J+W>ve?ve:J+W));return B===1?(S=w[E-1],ae.push(s[S>>2]+s[S<<4&63]+"==")):B===2&&(S=(w[E-2]<<8)+w[E-1],ae.push(s[S>>10]+s[S>>4&63]+s[S<<2&63]+"=")),ae.join("")};for(var s=[],f=[],c=typeof Uint8Array<"u"?Uint8Array:Array,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,h=d.length;p<h;++p)s[p]=d[p],f[d.charCodeAt(p)]=p;function y(w){var S=w.length;if(S%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var E=w.indexOf("=");return E===-1&&(E=S),[E,E===S?0:4-E%4]}function b(w,S,E){for(var B,ae,W=[],J=S;J<E;J+=3)B=(w[J]<<16&16711680)+(w[J+1]<<8&65280)+(255&w[J+2]),W.push(s[(ae=B)>>18&63]+s[ae>>12&63]+s[ae>>6&63]+s[63&ae]);return W.join("")}f[45]=62,f[95]=63},7715:(u,a)=>{Object.defineProperty(a,"__esModule",{value:!0}),a.bech32m=a.bech32=void 0;const s="qpzry9x8gf2tvdw0s3jn54khce6mua7l",f={};for(let S=0;S<s.length;S++){const E=s.charAt(S);f[E]=S}function c(S){const E=S>>25;return(33554431&S)<<5^996825010&-(E>>0&1)^642813549&-(E>>1&1)^513874426&-(E>>2&1)^1027748829&-(E>>3&1)^705979059&-(E>>4&1)}function d(S){let E=1;for(let B=0;B<S.length;++B){const ae=S.charCodeAt(B);if(ae<33||ae>126)return"Invalid prefix ("+S+")";E=c(E)^ae>>5}E=c(E);for(let B=0;B<S.length;++B){const ae=S.charCodeAt(B);E=c(E)^31&ae}return E}function p(S,E,B,ae){let W=0,J=0;const ve=(1<<B)-1,Qe=[];for(let kt=0;kt<S.length;++kt)for(W=W<<E|S[kt],J+=E;J>=B;)J-=B,Qe.push(W>>J&ve);if(ae)J>0&&Qe.push(W<<B-J&ve);else{if(J>=E)return"Excess padding";if(W<<B-J&ve)return"Non-zero padding"}return Qe}function h(S){return p(S,8,5,!0)}function y(S){const E=p(S,5,8,!1);if(Array.isArray(E))return E}function b(S){const E=p(S,5,8,!1);if(Array.isArray(E))return E;throw new Error(E)}function w(S){let E;function B(ae,W){if(W=W||90,ae.length<8)return ae+" too short";if(ae.length>W)return"Exceeds length limit";const J=ae.toLowerCase(),ve=ae.toUpperCase();if(ae!==J&&ae!==ve)return"Mixed-case string "+ae;const Qe=(ae=J).lastIndexOf("1");if(Qe===-1)return"No separator character for "+ae;if(Qe===0)return"Missing prefix for "+ae;const kt=ae.slice(0,Qe),nr=ae.slice(Qe+1);if(nr.length<6)return"Data too short";let sr=d(kt);if(typeof sr=="string")return sr;const ce=[];for(let Ze=0;Ze<nr.length;++Ze){const se=nr.charAt(Ze),vt=f[se];if(vt===void 0)return"Unknown character "+se;sr=c(sr)^vt,Ze+6>=nr.length||ce.push(vt)}return sr!==E?"Invalid checksum for "+ae:{prefix:kt,words:ce}}return E=S==="bech32"?1:734539939,{decodeUnsafe:function(ae,W){const J=B(ae,W);if(typeof J=="object")return J},decode:function(ae,W){const J=B(ae,W);if(typeof J=="object")return J;throw new Error(J)},encode:function(ae,W,J){if(J=J||90,ae.length+7+W.length>J)throw new TypeError("Exceeds length limit");let ve=d(ae=ae.toLowerCase());if(typeof ve=="string")throw new Error(ve);let Qe=ae+"1";for(let kt=0;kt<W.length;++kt){const nr=W[kt];if(nr>>5!=0)throw new Error("Non 5-bit word");ve=c(ve)^nr,Qe+=s.charAt(nr)}for(let kt=0;kt<6;++kt)ve=c(ve);ve^=E;for(let kt=0;kt<6;++kt)Qe+=s.charAt(ve>>5*(5-kt)&31);return Qe},toWords:h,fromWordsUnsafe:y,fromWords:b}}a.bech32=w("bech32"),a.bech32m=w("bech32m")},4431:function(u,a,s){var f;(function(c){var d,p=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,h=Math.ceil,y=Math.floor,b="[BigNumber Error] ",w=b+"Number primitive has more than 15 significant digits: ",S=1e14,E=14,B=9007199254740991,ae=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],W=1e7,J=1e9;function ve(se){var vt=0|se;return se>0||se===vt?vt:vt-1}function Qe(se){for(var vt,ur,ue=1,bt=se.length,L=se[0]+"";ue<bt;){for(vt=se[ue++]+"",ur=E-vt.length;ur--;vt="0"+vt);L+=vt}for(bt=L.length;L.charCodeAt(--bt)===48;);return L.slice(0,bt+1||1)}function kt(se,vt){var ur,ue,bt=se.c,L=vt.c,_=se.s,F=vt.s,k=se.e,Ye=vt.e;if(!_||!F)return null;if(ur=bt&&!bt[0],ue=L&&!L[0],ur||ue)return ur?ue?0:-F:_;if(_!=F)return _;if(ur=_<0,ue=k==Ye,!bt||!L)return ue?0:!bt^ur?1:-1;if(!ue)return k>Ye^ur?1:-1;for(F=(k=bt.length)<(Ye=L.length)?k:Ye,_=0;_<F;_++)if(bt[_]!=L[_])return bt[_]>L[_]^ur?1:-1;return k==Ye?0:k>Ye^ur?1:-1}function nr(se,vt,ur,ue){if(se<vt||se>ur||se!==y(se))throw Error(b+(ue||"Argument")+(typeof se=="number"?se<vt||se>ur?" out of range: ":" not an integer: ":" not a primitive number: ")+String(se))}function sr(se){var vt=se.c.length-1;return ve(se.e/E)==vt&&se.c[vt]%2!=0}function ce(se,vt){return(se.length>1?se.charAt(0)+"."+se.slice(1):se)+(vt<0?"e":"e+")+vt}function Ze(se,vt,ur){var ue,bt;if(vt<0){for(bt=ur+".";++vt;bt+=ur);se=bt+se}else if(++vt>(ue=se.length)){for(bt=ur,vt-=ue;--vt;bt+=ur);se+=bt}else vt<ue&&(se=se.slice(0,vt)+"."+se.slice(vt));return se}d=(function se(vt){var ur,ue,bt,L,_,F,k,Ye,rn,ii,ai=bi.prototype={constructor:bi,toString:null,valueOf:null},ni=new bi(1),ri=20,ui=4,lr=-7,ar=21,jr=-1e7,ci=1e7,mi=!1,pi=1,ei=0,Gr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},ti="0123456789abcdefghijklmnopqrstuvwxyz",fi=!0;function bi(rr,on){var si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi=this;if(!(Hi instanceof bi))return new bi(rr,on);if(on==null){if(rr&&rr._isBigNumber===!0)return Hi.s=rr.s,void(!rr.c||rr.e>ci?Hi.c=Hi.e=null:rr.e<jr?Hi.c=[Hi.e=0]:(Hi.e=rr.e,Hi.c=rr.c.slice()));if((Ii=typeof rr=="number")&&0*rr==0){if(Hi.s=1/rr<0?(rr=-rr,-1):1,rr===~~rr){for(Mi=0,Di=rr;Di>=10;Di/=10,Mi++);return void(Mi>ci?Hi.c=Hi.e=null:(Hi.e=Mi,Hi.c=[rr]))}Vi=String(rr)}else{if(!p.test(Vi=String(rr)))return bt(Hi,Vi,Ii);Hi.s=Vi.charCodeAt(0)==45?(Vi=Vi.slice(1),-1):1}(Mi=Vi.indexOf("."))>-1&&(Vi=Vi.replace(".","")),(Di=Vi.search(/e/i))>0?(Mi<0&&(Mi=Di),Mi+=+Vi.slice(Di+1),Vi=Vi.substring(0,Di)):Mi<0&&(Mi=Vi.length)}else{if(nr(on,2,ti.length,"Base"),on==10&&fi)return vn(Hi=new bi(rr),ri+Hi.e+1,ui);if(Vi=String(rr),Ii=typeof rr=="number"){if(0*rr!=0)return bt(Hi,Vi,Ii,on);if(Hi.s=1/rr<0?(Vi=Vi.slice(1),-1):1,bi.DEBUG&&Vi.replace(/^0\.0*|\./,"").length>15)throw Error(w+rr)}else Hi.s=Vi.charCodeAt(0)===45?(Vi=Vi.slice(1),-1):1;for(si=ti.slice(0,on),Mi=Di=0,Ci=Vi.length;Di<Ci;Di++)if(si.indexOf(vi=Vi.charAt(Di))<0){if(vi=="."){if(Di>Mi){Mi=Ci;continue}}else if(!Ei&&(Vi==Vi.toUpperCase()&&(Vi=Vi.toLowerCase())||Vi==Vi.toLowerCase()&&(Vi=Vi.toUpperCase()))){Ei=!0,Di=-1,Mi=0;continue}return bt(Hi,String(rr),Ii,on)}Ii=!1,(Mi=(Vi=ue(Vi,on,10,Hi.s)).indexOf("."))>-1?Vi=Vi.replace(".",""):Mi=Vi.length}for(Di=0;Vi.charCodeAt(Di)===48;Di++);for(Ci=Vi.length;Vi.charCodeAt(--Ci)===48;);if(Vi=Vi.slice(Di,++Ci)){if(Ci-=Di,Ii&&bi.DEBUG&&Ci>15&&(rr>B||rr!==y(rr)))throw Error(w+Hi.s*rr);if((Mi=Mi-Di-1)>ci)Hi.c=Hi.e=null;else if(Mi<jr)Hi.c=[Hi.e=0];else{if(Hi.e=Mi,Hi.c=[],Di=(Mi+1)%E,Mi<0&&(Di+=E),Di<Ci){for(Di&&Hi.c.push(+Vi.slice(0,Di)),Ci-=E;Di<Ci;)Hi.c.push(+Vi.slice(Di,Di+=E));Di=E-(Vi=Vi.slice(Di)).length}else Di-=Ci;for(;Di--;Vi+="0");Hi.c.push(+Vi)}}else Hi.c=[Hi.e=0]}function Ai(rr,on,si,vi){var Ei,Mi,Di,Ii,Ci;if(si==null?si=ui:nr(si,0,8),!rr.c)return rr.toString();if(Ei=rr.c[0],Di=rr.e,on==null)Ci=Qe(rr.c),Ci=vi==1||vi==2&&(Di<=lr||Di>=ar)?ce(Ci,Di):Ze(Ci,Di,"0");else if(Mi=(rr=vn(new bi(rr),on,si)).e,Ii=(Ci=Qe(rr.c)).length,vi==1||vi==2&&(on<=Mi||Mi<=lr)){for(;Ii<on;Ci+="0",Ii++);Ci=ce(Ci,Mi)}else if(on-=Di,Ci=Ze(Ci,Mi,"0"),Mi+1>Ii){if(--on>0)for(Ci+=".";on--;Ci+="0");}else if((on+=Mi-Ii)>0)for(Mi+1==Ii&&(Ci+=".");on--;Ci+="0");return rr.s<0&&Ei?"-"+Ci:Ci}function Bi(rr,on){for(var si,vi=1,Ei=new bi(rr[0]);vi<rr.length;vi++){if(!(si=new bi(rr[vi])).s){Ei=si;break}on.call(Ei,si)&&(Ei=si)}return Ei}function qi(rr,on,si){for(var vi=1,Ei=on.length;!on[--Ei];on.pop());for(Ei=on[0];Ei>=10;Ei/=10,vi++);return(si=vi+si*E-1)>ci?rr.c=rr.e=null:si<jr?rr.c=[rr.e=0]:(rr.e=si,rr.c=on),rr}function vn(rr,on,si,vi){var Ei,Mi,Di,Ii,Ci,Vi,Hi,Ji=rr.c,no=ae;if(Ji){e:{for(Ei=1,Ii=Ji[0];Ii>=10;Ii/=10,Ei++);if((Mi=on-Ei)<0)Mi+=E,Di=on,Hi=(Ci=Ji[Vi=0])/no[Ei-Di-1]%10|0;else if((Vi=h((Mi+1)/E))>=Ji.length){if(!vi)break e;for(;Ji.length<=Vi;Ji.push(0));Ci=Hi=0,Ei=1,Di=(Mi%=E)-E+1}else{for(Ci=Ii=Ji[Vi],Ei=1;Ii>=10;Ii/=10,Ei++);Hi=(Di=(Mi%=E)-E+Ei)<0?0:Ci/no[Ei-Di-1]%10|0}if(vi=vi||on<0||Ji[Vi+1]!=null||(Di<0?Ci:Ci%no[Ei-Di-1]),vi=si<4?(Hi||vi)&&(si==0||si==(rr.s<0?3:2)):Hi>5||Hi==5&&(si==4||vi||si==6&&(Mi>0?Di>0?Ci/no[Ei-Di]:0:Ji[Vi-1])%10&1||si==(rr.s<0?8:7)),on<1||!Ji[0])return Ji.length=0,vi?(on-=rr.e+1,Ji[0]=no[(E-on%E)%E],rr.e=-on||0):Ji[0]=rr.e=0,rr;if(Mi==0?(Ji.length=Vi,Ii=1,Vi--):(Ji.length=Vi+1,Ii=no[E-Mi],Ji[Vi]=Di>0?y(Ci/no[Ei-Di]%no[Di])*Ii:0),vi)for(;;){if(Vi==0){for(Mi=1,Di=Ji[0];Di>=10;Di/=10,Mi++);for(Di=Ji[0]+=Ii,Ii=1;Di>=10;Di/=10,Ii++);Mi!=Ii&&(rr.e++,Ji[0]==S&&(Ji[0]=1));break}if(Ji[Vi]+=Ii,Ji[Vi]!=S)break;Ji[Vi--]=0,Ii=1}for(Mi=Ji.length;Ji[--Mi]===0;Ji.pop());}rr.e>ci?rr.c=rr.e=null:rr.e<jr&&(rr.c=[rr.e=0])}return rr}function di(rr){var on,si=rr.e;return si===null?rr.toString():(on=Qe(rr.c),on=si<=lr||si>=ar?ce(on,si):Ze(on,si,"0"),rr.s<0?"-"+on:on)}return bi.clone=se,bi.ROUND_UP=0,bi.ROUND_DOWN=1,bi.ROUND_CEIL=2,bi.ROUND_FLOOR=3,bi.ROUND_HALF_UP=4,bi.ROUND_HALF_DOWN=5,bi.ROUND_HALF_EVEN=6,bi.ROUND_HALF_CEIL=7,bi.ROUND_HALF_FLOOR=8,bi.EUCLID=9,bi.config=bi.set=function(rr){var on,si;if(rr!=null){if(typeof rr!="object")throw Error(b+"Object expected: "+rr);if(rr.hasOwnProperty(on="DECIMAL_PLACES")&&(nr(si=rr[on],0,J,on),ri=si),rr.hasOwnProperty(on="ROUNDING_MODE")&&(nr(si=rr[on],0,8,on),ui=si),rr.hasOwnProperty(on="EXPONENTIAL_AT")&&((si=rr[on])&&si.pop?(nr(si[0],-J,0,on),nr(si[1],0,J,on),lr=si[0],ar=si[1]):(nr(si,-J,J,on),lr=-(ar=si<0?-si:si))),rr.hasOwnProperty(on="RANGE"))if((si=rr[on])&&si.pop)nr(si[0],-J,-1,on),nr(si[1],1,J,on),jr=si[0],ci=si[1];else{if(nr(si,-J,J,on),!si)throw Error(b+on+" cannot be zero: "+si);jr=-(ci=si<0?-si:si)}if(rr.hasOwnProperty(on="CRYPTO")){if((si=rr[on])!==!!si)throw Error(b+on+" not true or false: "+si);if(si){if(typeof crypto>"u"||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw mi=!si,Error(b+"crypto unavailable");mi=si}else mi=si}if(rr.hasOwnProperty(on="MODULO_MODE")&&(nr(si=rr[on],0,9,on),pi=si),rr.hasOwnProperty(on="POW_PRECISION")&&(nr(si=rr[on],0,J,on),ei=si),rr.hasOwnProperty(on="FORMAT")){if(typeof(si=rr[on])!="object")throw Error(b+on+" not an object: "+si);Gr=si}if(rr.hasOwnProperty(on="ALPHABET")){if(typeof(si=rr[on])!="string"||/^.?$|[+\-.\s]|(.).*\1/.test(si))throw Error(b+on+" invalid: "+si);fi=si.slice(0,10)=="0123456789",ti=si}}return{DECIMAL_PLACES:ri,ROUNDING_MODE:ui,EXPONENTIAL_AT:[lr,ar],RANGE:[jr,ci],CRYPTO:mi,MODULO_MODE:pi,POW_PRECISION:ei,FORMAT:Gr,ALPHABET:ti}},bi.isBigNumber=function(rr){if(!rr||rr._isBigNumber!==!0)return!1;if(!bi.DEBUG)return!0;var on,si,vi=rr.c,Ei=rr.e,Mi=rr.s;e:if({}.toString.call(vi)=="[object Array]"){if((Mi===1||Mi===-1)&&Ei>=-J&&Ei<=J&&Ei===y(Ei)){if(vi[0]===0){if(Ei===0&&vi.length===1)return!0;break e}if((on=(Ei+1)%E)<1&&(on+=E),String(vi[0]).length==on){for(on=0;on<vi.length;on++)if((si=vi[on])<0||si>=S||si!==y(si))break e;if(si!==0)return!0}}}else if(vi===null&&Ei===null&&(Mi===null||Mi===1||Mi===-1))return!0;throw Error(b+"Invalid BigNumber: "+rr)},bi.maximum=bi.max=function(){return Bi(arguments,ai.lt)},bi.minimum=bi.min=function(){return Bi(arguments,ai.gt)},bi.random=(L=9007199254740992,_=Math.random()*L&2097151?function(){return y(Math.random()*L)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(rr){var on,si,vi,Ei,Mi,Di=0,Ii=[],Ci=new bi(ni);if(rr==null?rr=ri:nr(rr,0,J),Ei=h(rr/E),mi)if(crypto.getRandomValues){for(on=crypto.getRandomValues(new Uint32Array(Ei*=2));Di<Ei;)(Mi=131072*on[Di]+(on[Di+1]>>>11))>=9e15?(si=crypto.getRandomValues(new Uint32Array(2)),on[Di]=si[0],on[Di+1]=si[1]):(Ii.push(Mi%1e14),Di+=2);Di=Ei/2}else{if(!crypto.randomBytes)throw mi=!1,Error(b+"crypto unavailable");for(on=crypto.randomBytes(Ei*=7);Di<Ei;)(Mi=281474976710656*(31&on[Di])+1099511627776*on[Di+1]+4294967296*on[Di+2]+16777216*on[Di+3]+(on[Di+4]<<16)+(on[Di+5]<<8)+on[Di+6])>=9e15?crypto.randomBytes(7).copy(on,Di):(Ii.push(Mi%1e14),Di+=7);Di=Ei/7}if(!mi)for(;Di<Ei;)(Mi=_())<9e15&&(Ii[Di++]=Mi%1e14);for(Ei=Ii[--Di],rr%=E,Ei&&rr&&(Mi=ae[E-rr],Ii[Di]=y(Ei/Mi)*Mi);Ii[Di]===0;Ii.pop(),Di--);if(Di<0)Ii=[vi=0];else{for(vi=-1;Ii[0]===0;Ii.splice(0,1),vi-=E);for(Di=1,Mi=Ii[0];Mi>=10;Mi/=10,Di++);Di<E&&(vi-=E-Di)}return Ci.e=vi,Ci.c=Ii,Ci}),bi.sum=function(){for(var rr=1,on=arguments,si=new bi(on[0]);rr<on.length;)si=si.plus(on[rr++]);return si},ue=(function(){var rr="0123456789";function on(si,vi,Ei,Mi){for(var Di,Ii,Ci=[0],Vi=0,Hi=si.length;Vi<Hi;){for(Ii=Ci.length;Ii--;Ci[Ii]*=vi);for(Ci[0]+=Mi.indexOf(si.charAt(Vi++)),Di=0;Di<Ci.length;Di++)Ci[Di]>Ei-1&&(Ci[Di+1]==null&&(Ci[Di+1]=0),Ci[Di+1]+=Ci[Di]/Ei|0,Ci[Di]%=Ei)}return Ci.reverse()}return function(si,vi,Ei,Mi,Di){var Ii,Ci,Vi,Hi,Ji,no,co,Fo,Io=si.indexOf("."),Ro=ri,Oo=ui;for(Io>=0&&(Hi=ei,ei=0,si=si.replace(".",""),no=(Fo=new bi(vi)).pow(si.length-Io),ei=Hi,Fo.c=on(Ze(Qe(no.c),no.e,"0"),10,Ei,rr),Fo.e=Fo.c.length),Vi=Hi=(co=on(si,vi,Ei,Di?(Ii=ti,rr):(Ii=rr,ti))).length;co[--Hi]==0;co.pop());if(!co[0])return Ii.charAt(0);if(Io<0?--Vi:(no.c=co,no.e=Vi,no.s=Mi,co=(no=ur(no,Fo,Ro,Oo,Ei)).c,Ji=no.r,Vi=no.e),Io=co[Ci=Vi+Ro+1],Hi=Ei/2,Ji=Ji||Ci<0||co[Ci+1]!=null,Ji=Oo<4?(Io!=null||Ji)&&(Oo==0||Oo==(no.s<0?3:2)):Io>Hi||Io==Hi&&(Oo==4||Ji||Oo==6&&1&co[Ci-1]||Oo==(no.s<0?8:7)),Ci<1||!co[0])si=Ji?Ze(Ii.charAt(1),-Ro,Ii.charAt(0)):Ii.charAt(0);else{if(co.length=Ci,Ji)for(--Ei;++co[--Ci]>Ei;)co[Ci]=0,Ci||(++Vi,co=[1].concat(co));for(Hi=co.length;!co[--Hi];);for(Io=0,si="";Io<=Hi;si+=Ii.charAt(co[Io++]));si=Ze(si,Vi,Ii.charAt(0))}return si}})(),ur=(function(){function rr(vi,Ei,Mi){var Di,Ii,Ci,Vi,Hi=0,Ji=vi.length,no=Ei%W,co=Ei/W|0;for(vi=vi.slice();Ji--;)Hi=((Ii=no*(Ci=vi[Ji]%W)+(Di=co*Ci+(Vi=vi[Ji]/W|0)*no)%W*W+Hi)/Mi|0)+(Di/W|0)+co*Vi,vi[Ji]=Ii%Mi;return Hi&&(vi=[Hi].concat(vi)),vi}function on(vi,Ei,Mi,Di){var Ii,Ci;if(Mi!=Di)Ci=Mi>Di?1:-1;else for(Ii=Ci=0;Ii<Mi;Ii++)if(vi[Ii]!=Ei[Ii]){Ci=vi[Ii]>Ei[Ii]?1:-1;break}return Ci}function si(vi,Ei,Mi,Di){for(var Ii=0;Mi--;)vi[Mi]-=Ii,Ii=vi[Mi]<Ei[Mi]?1:0,vi[Mi]=Ii*Di+vi[Mi]-Ei[Mi];for(;!vi[0]&&vi.length>1;vi.splice(0,1));}return function(vi,Ei,Mi,Di,Ii){var Ci,Vi,Hi,Ji,no,co,Fo,Io,Ro,Oo,To,Po,ia,Jo,ea,zi,Gi,uo=vi.s==Ei.s?1:-1,wo=vi.c,xi=Ei.c;if(!(wo&&wo[0]&&xi&&xi[0]))return new bi(vi.s&&Ei.s&&(wo?!xi||wo[0]!=xi[0]:xi)?wo&&wo[0]==0||!xi?0*uo:uo/0:NaN);for(Ro=(Io=new bi(uo)).c=[],uo=Mi+(Vi=vi.e-Ei.e)+1,Ii||(Ii=S,Vi=ve(vi.e/E)-ve(Ei.e/E),uo=uo/E|0),Hi=0;xi[Hi]==(wo[Hi]||0);Hi++);if(xi[Hi]>(wo[Hi]||0)&&Vi--,uo<0)Ro.push(1),Ji=!0;else{for(Jo=wo.length,zi=xi.length,Hi=0,uo+=2,(no=y(Ii/(xi[0]+1)))>1&&(xi=rr(xi,no,Ii),wo=rr(wo,no,Ii),zi=xi.length,Jo=wo.length),ia=zi,To=(Oo=wo.slice(0,zi)).length;To<zi;Oo[To++]=0);Gi=xi.slice(),Gi=[0].concat(Gi),ea=xi[0],xi[1]>=Ii/2&&ea++;do{if(no=0,(Ci=on(xi,Oo,zi,To))<0){if(Po=Oo[0],zi!=To&&(Po=Po*Ii+(Oo[1]||0)),(no=y(Po/ea))>1)for(no>=Ii&&(no=Ii-1),Fo=(co=rr(xi,no,Ii)).length,To=Oo.length;on(co,Oo,Fo,To)==1;)no--,si(co,zi<Fo?Gi:xi,Fo,Ii),Fo=co.length,Ci=1;else no==0&&(Ci=no=1),Fo=(co=xi.slice()).length;if(Fo<To&&(co=[0].concat(co)),si(Oo,co,To,Ii),To=Oo.length,Ci==-1)for(;on(xi,Oo,zi,To)<1;)no++,si(Oo,zi<To?Gi:xi,To,Ii),To=Oo.length}else Ci===0&&(no++,Oo=[0]);Ro[Hi++]=no,Oo[0]?Oo[To++]=wo[ia]||0:(Oo=[wo[ia]],To=1)}while((ia++<Jo||Oo[0]!=null)&&uo--);Ji=Oo[0]!=null,Ro[0]||Ro.splice(0,1)}if(Ii==S){for(Hi=1,uo=Ro[0];uo>=10;uo/=10,Hi++);vn(Io,Mi+(Io.e=Hi+Vi*E-1)+1,Di,Ji)}else Io.e=Vi,Io.r=+Ji;return Io}})(),F=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,Ye=/^\.([^.]+)$/,rn=/^-?(Infinity|NaN)$/,ii=/^\s*\+(?=[\w.])|^\s+|\s+$/g,bt=function(rr,on,si,vi){var Ei,Mi=si?on:on.replace(ii,"");if(rn.test(Mi))rr.s=isNaN(Mi)?null:Mi<0?-1:1;else{if(!si&&(Mi=Mi.replace(F,(function(Di,Ii,Ci){return Ei=(Ci=Ci.toLowerCase())=="x"?16:Ci=="b"?2:8,vi&&vi!=Ei?Di:Ii})),vi&&(Ei=vi,Mi=Mi.replace(k,"$1").replace(Ye,"0.$1")),on!=Mi))return new bi(Mi,Ei);if(bi.DEBUG)throw Error(b+"Not a"+(vi?" base "+vi:"")+" number: "+on);rr.s=null}rr.c=rr.e=null},ai.absoluteValue=ai.abs=function(){var rr=new bi(this);return rr.s<0&&(rr.s=1),rr},ai.comparedTo=function(rr,on){return kt(this,new bi(rr,on))},ai.decimalPlaces=ai.dp=function(rr,on){var si,vi,Ei,Mi=this;if(rr!=null)return nr(rr,0,J),on==null?on=ui:nr(on,0,8),vn(new bi(Mi),rr+Mi.e+1,on);if(!(si=Mi.c))return null;if(vi=((Ei=si.length-1)-ve(this.e/E))*E,Ei=si[Ei])for(;Ei%10==0;Ei/=10,vi--);return vi<0&&(vi=0),vi},ai.dividedBy=ai.div=function(rr,on){return ur(this,new bi(rr,on),ri,ui)},ai.dividedToIntegerBy=ai.idiv=function(rr,on){return ur(this,new bi(rr,on),0,1)},ai.exponentiatedBy=ai.pow=function(rr,on){var si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi=this;if((rr=new bi(rr)).c&&!rr.isInteger())throw Error(b+"Exponent not an integer: "+di(rr));if(on!=null&&(on=new bi(on)),Di=rr.e>14,!Hi.c||!Hi.c[0]||Hi.c[0]==1&&!Hi.e&&Hi.c.length==1||!rr.c||!rr.c[0])return Vi=new bi(Math.pow(+di(Hi),Di?rr.s*(2-sr(rr)):+di(rr))),on?Vi.mod(on):Vi;if(Ii=rr.s<0,on){if(on.c?!on.c[0]:!on.s)return new bi(NaN);(vi=!Ii&&Hi.isInteger()&&on.isInteger())&&(Hi=Hi.mod(on))}else{if(rr.e>9&&(Hi.e>0||Hi.e<-1||(Hi.e==0?Hi.c[0]>1||Di&&Hi.c[1]>=24e7:Hi.c[0]<8e13||Di&&Hi.c[0]<=9999975e7)))return Mi=Hi.s<0&&sr(rr)?-0:0,Hi.e>-1&&(Mi=1/Mi),new bi(Ii?1/Mi:Mi);ei&&(Mi=h(ei/E+2))}for(Di?(si=new bi(.5),Ii&&(rr.s=1),Ci=sr(rr)):Ci=(Ei=Math.abs(+di(rr)))%2,Vi=new bi(ni);;){if(Ci){if(!(Vi=Vi.times(Hi)).c)break;Mi?Vi.c.length>Mi&&(Vi.c.length=Mi):vi&&(Vi=Vi.mod(on))}if(Ei){if((Ei=y(Ei/2))===0)break;Ci=Ei%2}else if(vn(rr=rr.times(si),rr.e+1,1),rr.e>14)Ci=sr(rr);else{if((Ei=+di(rr))==0)break;Ci=Ei%2}Hi=Hi.times(Hi),Mi?Hi.c&&Hi.c.length>Mi&&(Hi.c.length=Mi):vi&&(Hi=Hi.mod(on))}return vi?Vi:(Ii&&(Vi=ni.div(Vi)),on?Vi.mod(on):Mi?vn(Vi,ei,ui,void 0):Vi)},ai.integerValue=function(rr){var on=new bi(this);return rr==null?rr=ui:nr(rr,0,8),vn(on,on.e+1,rr)},ai.isEqualTo=ai.eq=function(rr,on){return kt(this,new bi(rr,on))===0},ai.isFinite=function(){return!!this.c},ai.isGreaterThan=ai.gt=function(rr,on){return kt(this,new bi(rr,on))>0},ai.isGreaterThanOrEqualTo=ai.gte=function(rr,on){return(on=kt(this,new bi(rr,on)))===1||on===0},ai.isInteger=function(){return!!this.c&&ve(this.e/E)>this.c.length-2},ai.isLessThan=ai.lt=function(rr,on){return kt(this,new bi(rr,on))<0},ai.isLessThanOrEqualTo=ai.lte=function(rr,on){return(on=kt(this,new bi(rr,on)))===-1||on===0},ai.isNaN=function(){return!this.s},ai.isNegative=function(){return this.s<0},ai.isPositive=function(){return this.s>0},ai.isZero=function(){return!!this.c&&this.c[0]==0},ai.minus=function(rr,on){var si,vi,Ei,Mi,Di=this,Ii=Di.s;if(on=(rr=new bi(rr,on)).s,!Ii||!on)return new bi(NaN);if(Ii!=on)return rr.s=-on,Di.plus(rr);var Ci=Di.e/E,Vi=rr.e/E,Hi=Di.c,Ji=rr.c;if(!Ci||!Vi){if(!Hi||!Ji)return Hi?(rr.s=-on,rr):new bi(Ji?Di:NaN);if(!Hi[0]||!Ji[0])return Ji[0]?(rr.s=-on,rr):new bi(Hi[0]?Di:ui==3?-0:0)}if(Ci=ve(Ci),Vi=ve(Vi),Hi=Hi.slice(),Ii=Ci-Vi){for((Mi=Ii<0)?(Ii=-Ii,Ei=Hi):(Vi=Ci,Ei=Ji),Ei.reverse(),on=Ii;on--;Ei.push(0));Ei.reverse()}else for(vi=(Mi=(Ii=Hi.length)<(on=Ji.length))?Ii:on,Ii=on=0;on<vi;on++)if(Hi[on]!=Ji[on]){Mi=Hi[on]<Ji[on];break}if(Mi&&(Ei=Hi,Hi=Ji,Ji=Ei,rr.s=-rr.s),(on=(vi=Ji.length)-(si=Hi.length))>0)for(;on--;Hi[si++]=0);for(on=S-1;vi>Ii;){if(Hi[--vi]<Ji[vi]){for(si=vi;si&&!Hi[--si];Hi[si]=on);--Hi[si],Hi[vi]+=S}Hi[vi]-=Ji[vi]}for(;Hi[0]==0;Hi.splice(0,1),--Vi);return Hi[0]?qi(rr,Hi,Vi):(rr.s=ui==3?-1:1,rr.c=[rr.e=0],rr)},ai.modulo=ai.mod=function(rr,on){var si,vi,Ei=this;return rr=new bi(rr,on),!Ei.c||!rr.s||rr.c&&!rr.c[0]?new bi(NaN):!rr.c||Ei.c&&!Ei.c[0]?new bi(Ei):(pi==9?(vi=rr.s,rr.s=1,si=ur(Ei,rr,0,3),rr.s=vi,si.s*=vi):si=ur(Ei,rr,0,pi),(rr=Ei.minus(si.times(rr))).c[0]||pi!=1||(rr.s=Ei.s),rr)},ai.multipliedBy=ai.times=function(rr,on){var si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi,Ji,no,co,Fo,Io,Ro,Oo=this,To=Oo.c,Po=(rr=new bi(rr,on)).c;if(!(To&&Po&&To[0]&&Po[0]))return!Oo.s||!rr.s||To&&!To[0]&&!Po||Po&&!Po[0]&&!To?rr.c=rr.e=rr.s=null:(rr.s*=Oo.s,To&&Po?(rr.c=[0],rr.e=0):rr.c=rr.e=null),rr;for(vi=ve(Oo.e/E)+ve(rr.e/E),rr.s*=Oo.s,(Ci=To.length)<(Ji=Po.length)&&(Fo=To,To=Po,Po=Fo,Ei=Ci,Ci=Ji,Ji=Ei),Ei=Ci+Ji,Fo=[];Ei--;Fo.push(0));for(Io=S,Ro=W,Ei=Ji;--Ei>=0;){for(si=0,no=Po[Ei]%Ro,co=Po[Ei]/Ro|0,Mi=Ei+(Di=Ci);Mi>Ei;)si=((Vi=no*(Vi=To[--Di]%Ro)+(Ii=co*Vi+(Hi=To[Di]/Ro|0)*no)%Ro*Ro+Fo[Mi]+si)/Io|0)+(Ii/Ro|0)+co*Hi,Fo[Mi--]=Vi%Io;Fo[Mi]=si}return si?++vi:Fo.splice(0,1),qi(rr,Fo,vi)},ai.negated=function(){var rr=new bi(this);return rr.s=-rr.s||null,rr},ai.plus=function(rr,on){var si,vi=this,Ei=vi.s;if(on=(rr=new bi(rr,on)).s,!Ei||!on)return new bi(NaN);if(Ei!=on)return rr.s=-on,vi.minus(rr);var Mi=vi.e/E,Di=rr.e/E,Ii=vi.c,Ci=rr.c;if(!Mi||!Di){if(!Ii||!Ci)return new bi(Ei/0);if(!Ii[0]||!Ci[0])return Ci[0]?rr:new bi(Ii[0]?vi:0*Ei)}if(Mi=ve(Mi),Di=ve(Di),Ii=Ii.slice(),Ei=Mi-Di){for(Ei>0?(Di=Mi,si=Ci):(Ei=-Ei,si=Ii),si.reverse();Ei--;si.push(0));si.reverse()}for((Ei=Ii.length)-(on=Ci.length)<0&&(si=Ci,Ci=Ii,Ii=si,on=Ei),Ei=0;on;)Ei=(Ii[--on]=Ii[on]+Ci[on]+Ei)/S|0,Ii[on]=S===Ii[on]?0:Ii[on]%S;return Ei&&(Ii=[Ei].concat(Ii),++Di),qi(rr,Ii,Di)},ai.precision=ai.sd=function(rr,on){var si,vi,Ei,Mi=this;if(rr!=null&&rr!==!!rr)return nr(rr,1,J),on==null?on=ui:nr(on,0,8),vn(new bi(Mi),rr,on);if(!(si=Mi.c))return null;if(vi=(Ei=si.length-1)*E+1,Ei=si[Ei]){for(;Ei%10==0;Ei/=10,vi--);for(Ei=si[0];Ei>=10;Ei/=10,vi++);}return rr&&Mi.e+1>vi&&(vi=Mi.e+1),vi},ai.shiftedBy=function(rr){return nr(rr,-9007199254740991,B),this.times("1e"+rr)},ai.squareRoot=ai.sqrt=function(){var rr,on,si,vi,Ei,Mi=this,Di=Mi.c,Ii=Mi.s,Ci=Mi.e,Vi=ri+4,Hi=new bi("0.5");if(Ii!==1||!Di||!Di[0])return new bi(!Ii||Ii<0&&(!Di||Di[0])?NaN:Di?Mi:1/0);if((Ii=Math.sqrt(+di(Mi)))==0||Ii==1/0?(((on=Qe(Di)).length+Ci)%2==0&&(on+="0"),Ii=Math.sqrt(+on),Ci=ve((Ci+1)/2)-(Ci<0||Ci%2),si=new bi(on=Ii==1/0?"5e"+Ci:(on=Ii.toExponential()).slice(0,on.indexOf("e")+1)+Ci)):si=new bi(Ii+""),si.c[0]){for((Ii=(Ci=si.e)+Vi)<3&&(Ii=0);;)if(Ei=si,si=Hi.times(Ei.plus(ur(Mi,Ei,Vi,1))),Qe(Ei.c).slice(0,Ii)===(on=Qe(si.c)).slice(0,Ii)){if(si.e<Ci&&--Ii,(on=on.slice(Ii-3,Ii+1))!="9999"&&(vi||on!="4999")){+on&&(+on.slice(1)||on.charAt(0)!="5")||(vn(si,si.e+ri+2,1),rr=!si.times(si).eq(Mi));break}if(!vi&&(vn(Ei,Ei.e+ri+2,0),Ei.times(Ei).eq(Mi))){si=Ei;break}Vi+=4,Ii+=4,vi=1}}return vn(si,si.e+ri+1,ui,rr)},ai.toExponential=function(rr,on){return rr!=null&&(nr(rr,0,J),rr++),Ai(this,rr,on,1)},ai.toFixed=function(rr,on){return rr!=null&&(nr(rr,0,J),rr=rr+this.e+1),Ai(this,rr,on)},ai.toFormat=function(rr,on,si){var vi,Ei=this;if(si==null)rr!=null&&on&&typeof on=="object"?(si=on,on=null):rr&&typeof rr=="object"?(si=rr,rr=on=null):si=Gr;else if(typeof si!="object")throw Error(b+"Argument not an object: "+si);if(vi=Ei.toFixed(rr,on),Ei.c){var Mi,Di=vi.split("."),Ii=+si.groupSize,Ci=+si.secondaryGroupSize,Vi=si.groupSeparator||"",Hi=Di[0],Ji=Di[1],no=Ei.s<0,co=no?Hi.slice(1):Hi,Fo=co.length;if(Ci&&(Mi=Ii,Ii=Ci,Ci=Mi,Fo-=Mi),Ii>0&&Fo>0){for(Mi=Fo%Ii||Ii,Hi=co.substr(0,Mi);Mi<Fo;Mi+=Ii)Hi+=Vi+co.substr(Mi,Ii);Ci>0&&(Hi+=Vi+co.slice(Mi)),no&&(Hi="-"+Hi)}vi=Ji?Hi+(si.decimalSeparator||"")+((Ci=+si.fractionGroupSize)?Ji.replace(new RegExp("\\d{"+Ci+"}\\B","g"),"$&"+(si.fractionGroupSeparator||"")):Ji):Hi}return(si.prefix||"")+vi+(si.suffix||"")},ai.toFraction=function(rr){var on,si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi,Ji,no,co=this,Fo=co.c;if(rr!=null&&(!(Ii=new bi(rr)).isInteger()&&(Ii.c||Ii.s!==1)||Ii.lt(ni)))throw Error(b+"Argument "+(Ii.isInteger()?"out of range: ":"not an integer: ")+di(Ii));if(!Fo)return new bi(co);for(on=new bi(ni),Vi=si=new bi(ni),vi=Ci=new bi(ni),no=Qe(Fo),Mi=on.e=no.length-co.e-1,on.c[0]=ae[(Di=Mi%E)<0?E+Di:Di],rr=!rr||Ii.comparedTo(on)>0?Mi>0?on:Vi:Ii,Di=ci,ci=1/0,Ii=new bi(no),Ci.c[0]=0;Hi=ur(Ii,on,0,1),(Ei=si.plus(Hi.times(vi))).comparedTo(rr)!=1;)si=vi,vi=Ei,Vi=Ci.plus(Hi.times(Ei=Vi)),Ci=Ei,on=Ii.minus(Hi.times(Ei=on)),Ii=Ei;return Ei=ur(rr.minus(si),vi,0,1),Ci=Ci.plus(Ei.times(Vi)),si=si.plus(Ei.times(vi)),Ci.s=Vi.s=co.s,Ji=ur(Vi,vi,Mi*=2,ui).minus(co).abs().comparedTo(ur(Ci,si,Mi,ui).minus(co).abs())<1?[Vi,vi]:[Ci,si],ci=Di,Ji},ai.toNumber=function(){return+di(this)},ai.toPrecision=function(rr,on){return rr!=null&&nr(rr,1,J),Ai(this,rr,on,2)},ai.toString=function(rr){var on,si=this,vi=si.s,Ei=si.e;return Ei===null?vi?(on="Infinity",vi<0&&(on="-"+on)):on="NaN":(rr==null?on=Ei<=lr||Ei>=ar?ce(Qe(si.c),Ei):Ze(Qe(si.c),Ei,"0"):rr===10&&fi?on=Ze(Qe((si=vn(new bi(si),ri+Ei+1,ui)).c),si.e,"0"):(nr(rr,2,ti.length,"Base"),on=ue(Ze(Qe(si.c),Ei,"0"),10,rr,vi,!0)),vi<0&&si.c[0]&&(on="-"+on)),on},ai.valueOf=ai.toJSON=function(){return di(this)},ai._isBigNumber=!0,vt!=null&&bi.set(vt),bi})(),d.default=d.BigNumber=d,(f=(function(){return d}).call(a,s,a,u))===void 0||(u.exports=f)})()},8442:(u,a,s)=>{const f=s(9488);function c(Qe,kt,nr){const sr=Qe[kt]+Qe[nr];let ce=Qe[kt+1]+Qe[nr+1];sr>=4294967296&&ce++,Qe[kt]=sr,Qe[kt+1]=ce}function d(Qe,kt,nr,sr){let ce=Qe[kt]+nr;nr<0&&(ce+=4294967296);let Ze=Qe[kt+1]+sr;ce>=4294967296&&Ze++,Qe[kt]=ce,Qe[kt+1]=Ze}function p(Qe,kt){return Qe[kt]^Qe[kt+1]<<8^Qe[kt+2]<<16^Qe[kt+3]<<24}function h(Qe,kt,nr,sr,ce,Ze){const se=S[ce],vt=S[ce+1],ur=S[Ze],ue=S[Ze+1];c(w,Qe,kt),d(w,Qe,se,vt);let bt=w[sr]^w[Qe],L=w[sr+1]^w[Qe+1];w[sr]=L,w[sr+1]=bt,c(w,nr,sr),bt=w[kt]^w[nr],L=w[kt+1]^w[nr+1],w[kt]=bt>>>24^L<<8,w[kt+1]=L>>>24^bt<<8,c(w,Qe,kt),d(w,Qe,ur,ue),bt=w[sr]^w[Qe],L=w[sr+1]^w[Qe+1],w[sr]=bt>>>16^L<<16,w[sr+1]=L>>>16^bt<<16,c(w,nr,sr),bt=w[kt]^w[nr],L=w[kt+1]^w[nr+1],w[kt]=L>>>31^bt<<1,w[kt+1]=bt>>>31^L<<1}const y=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),b=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(Qe){return 2*Qe}))),w=new Uint32Array(32),S=new Uint32Array(32);function E(Qe,kt){let nr=0;for(nr=0;nr<16;nr++)w[nr]=Qe.h[nr],w[nr+16]=y[nr];for(w[24]=w[24]^Qe.t,w[25]=w[25]^Qe.t/4294967296,kt&&(w[28]=~w[28],w[29]=~w[29]),nr=0;nr<32;nr++)S[nr]=p(Qe.b,4*nr);for(nr=0;nr<12;nr++)h(0,8,16,24,b[16*nr+0],b[16*nr+1]),h(2,10,18,26,b[16*nr+2],b[16*nr+3]),h(4,12,20,28,b[16*nr+4],b[16*nr+5]),h(6,14,22,30,b[16*nr+6],b[16*nr+7]),h(0,10,20,30,b[16*nr+8],b[16*nr+9]),h(2,12,22,24,b[16*nr+10],b[16*nr+11]),h(4,14,16,26,b[16*nr+12],b[16*nr+13]),h(6,8,18,28,b[16*nr+14],b[16*nr+15]);for(nr=0;nr<16;nr++)Qe.h[nr]=Qe.h[nr]^w[nr]^w[nr+16]}const B=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function ae(Qe,kt,nr,sr){if(Qe===0||Qe>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(kt&&kt.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(nr&&nr.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(sr&&sr.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const ce={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:Qe};B.fill(0),B[0]=Qe,kt&&(B[1]=kt.length),B[2]=1,B[3]=1,nr&&B.set(nr,32),sr&&B.set(sr,48);for(let Ze=0;Ze<16;Ze++)ce.h[Ze]=y[Ze]^p(B,4*Ze);return kt&&(W(ce,kt),ce.c=128),ce}function W(Qe,kt){for(let nr=0;nr<kt.length;nr++)Qe.c===128&&(Qe.t+=Qe.c,E(Qe,!1),Qe.c=0),Qe.b[Qe.c++]=kt[nr]}function J(Qe){for(Qe.t+=Qe.c;Qe.c<128;)Qe.b[Qe.c++]=0;E(Qe,!0);const kt=new Uint8Array(Qe.outlen);for(let nr=0;nr<Qe.outlen;nr++)kt[nr]=Qe.h[nr>>2]>>8*(3&nr);return kt}function ve(Qe,kt,nr,sr,ce){nr=nr||64,Qe=f.normalizeInput(Qe),sr&&(sr=f.normalizeInput(sr)),ce&&(ce=f.normalizeInput(ce));const Ze=ae(nr,kt,sr,ce);return W(Ze,Qe),J(Ze)}u.exports={blake2b:ve,blake2bHex:function(Qe,kt,nr,sr,ce){const Ze=ve(Qe,kt,nr,sr,ce);return f.toHex(Ze)},blake2bInit:ae,blake2bUpdate:W,blake2bFinal:J}},5297:(u,a,s)=>{const f=s(9488);function c(J,ve){return J[ve]^J[ve+1]<<8^J[ve+2]<<16^J[ve+3]<<24}function d(J,ve,Qe,kt,nr,sr){b[J]=b[J]+b[ve]+nr,b[kt]=p(b[kt]^b[J],16),b[Qe]=b[Qe]+b[kt],b[ve]=p(b[ve]^b[Qe],12),b[J]=b[J]+b[ve]+sr,b[kt]=p(b[kt]^b[J],8),b[Qe]=b[Qe]+b[kt],b[ve]=p(b[ve]^b[Qe],7)}function p(J,ve){return J>>>ve^J<<32-ve}const h=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),y=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),b=new Uint32Array(16),w=new Uint32Array(16);function S(J,ve){let Qe=0;for(Qe=0;Qe<8;Qe++)b[Qe]=J.h[Qe],b[Qe+8]=h[Qe];for(b[12]^=J.t,b[13]^=J.t/4294967296,ve&&(b[14]=~b[14]),Qe=0;Qe<16;Qe++)w[Qe]=c(J.b,4*Qe);for(Qe=0;Qe<10;Qe++)d(0,4,8,12,w[y[16*Qe+0]],w[y[16*Qe+1]]),d(1,5,9,13,w[y[16*Qe+2]],w[y[16*Qe+3]]),d(2,6,10,14,w[y[16*Qe+4]],w[y[16*Qe+5]]),d(3,7,11,15,w[y[16*Qe+6]],w[y[16*Qe+7]]),d(0,5,10,15,w[y[16*Qe+8]],w[y[16*Qe+9]]),d(1,6,11,12,w[y[16*Qe+10]],w[y[16*Qe+11]]),d(2,7,8,13,w[y[16*Qe+12]],w[y[16*Qe+13]]),d(3,4,9,14,w[y[16*Qe+14]],w[y[16*Qe+15]]);for(Qe=0;Qe<8;Qe++)J.h[Qe]^=b[Qe]^b[Qe+8]}function E(J,ve){if(!(J>0&&J<=32))throw new Error("Incorrect output length, should be in [1, 32]");const Qe=ve?ve.length:0;if(ve&&!(Qe>0&&Qe<=32))throw new Error("Incorrect key length, should be in [1, 32]");const kt={h:new Uint32Array(h),b:new Uint8Array(64),c:0,t:0,outlen:J};return kt.h[0]^=16842752^Qe<<8^J,Qe>0&&(B(kt,ve),kt.c=64),kt}function B(J,ve){for(let Qe=0;Qe<ve.length;Qe++)J.c===64&&(J.t+=J.c,S(J,!1),J.c=0),J.b[J.c++]=ve[Qe]}function ae(J){for(J.t+=J.c;J.c<64;)J.b[J.c++]=0;S(J,!0);const ve=new Uint8Array(J.outlen);for(let Qe=0;Qe<J.outlen;Qe++)ve[Qe]=J.h[Qe>>2]>>8*(3&Qe)&255;return ve}function W(J,ve,Qe){Qe=Qe||32,J=f.normalizeInput(J);const kt=E(Qe,ve);return B(kt,J),ae(kt)}u.exports={blake2s:W,blake2sHex:function(J,ve,Qe){const kt=W(J,ve,Qe);return f.toHex(kt)},blake2sInit:E,blake2sUpdate:B,blake2sFinal:ae}},1191:(u,a,s)=>{const f=s(8442),c=s(5297);u.exports={blake2b:f.blake2b,blake2bHex:f.blake2bHex,blake2bInit:f.blake2bInit,blake2bUpdate:f.blake2bUpdate,blake2bFinal:f.blake2bFinal,blake2s:c.blake2s,blake2sHex:c.blake2sHex,blake2sInit:c.blake2sInit,blake2sUpdate:c.blake2sUpdate,blake2sFinal:c.blake2sFinal}},9488:u=>{function a(s){return(4294967296+s).toString(16).substring(1)}u.exports={normalizeInput:function(s){let f;if(s instanceof Uint8Array)f=s;else{if(typeof s!="string")throw new Error("Input must be an string, Buffer or Uint8Array");f=new TextEncoder().encode(s)}return f},toHex:function(s){return Array.prototype.map.call(s,(function(f){return(f<16?"0":"")+f.toString(16)})).join("")},debugPrint:function(s,f,c){let d=`
148
148
  `+s+" = ";for(let p=0;p<f.length;p+=2){if(c===32)d+=a(f[p]).toUpperCase(),d+=" ",d+=a(f[p+1]).toUpperCase();else{if(c!==64)throw new Error("Invalid size "+c);d+=a(f[p+1]).toUpperCase(),d+=a(f[p]).toUpperCase()}p%6==4?d+=`
149
149
  `+new Array(s.length+4).join(" "):p<f.length-2&&(d+=" ")}console.log(d)},testSpeed:function(s,f,c){let d=new Date().getTime();const p=new Uint8Array(f);for(let y=0;y<f;y++)p[y]=y%256;const h=new Date().getTime();console.log("Generated random input in "+(h-d)+"ms"),d=h;for(let y=0;y<c;y++){const b=s(p),w=new Date().getTime(),S=w-d;d=w,console.log("Hashed in "+S+"ms: "+b.substring(0,20)+"..."),console.log(Math.round(f/1048576/(S/1e3)*100)/100+" MB PER SECOND")}}}},3550:function(u,a,s){(function(f,c){function d(L,_){if(!L)throw new Error(_||"Assertion failed")}function p(L,_){L.super_=_;var F=function(){};F.prototype=_.prototype,L.prototype=new F,L.prototype.constructor=L}function h(L,_,F){if(h.isBN(L))return L;this.negative=0,this.words=null,this.length=0,this.red=null,L!==null&&(_!=="le"&&_!=="be"||(F=_,_=10),this._init(L||0,_||10,F||"be"))}var y;typeof f=="object"?f.exports=h:c.BN=h,h.BN=h,h.wordSize=26;try{y=typeof window<"u"&&window.Buffer!==void 0?window.Buffer:s(6601).Buffer}catch{}function b(L,_){var F=L.charCodeAt(_);return F>=48&&F<=57?F-48:F>=65&&F<=70?F-55:F>=97&&F<=102?F-87:void d(!1,"Invalid character in "+L)}function w(L,_,F){var k=b(L,F);return F-1>=_&&(k|=b(L,F-1)<<4),k}function S(L,_,F,k){for(var Ye=0,rn=0,ii=Math.min(L.length,F),ai=_;ai<ii;ai++){var ni=L.charCodeAt(ai)-48;Ye*=k,rn=ni>=49?ni-49+10:ni>=17?ni-17+10:ni,d(ni>=0&&rn<k,"Invalid character"),Ye+=rn}return Ye}function E(L,_){L.words=_.words,L.length=_.length,L.negative=_.negative,L.red=_.red}if(h.isBN=function(L){return L instanceof h||L!==null&&typeof L=="object"&&L.constructor.wordSize===h.wordSize&&Array.isArray(L.words)},h.max=function(L,_){return L.cmp(_)>0?L:_},h.min=function(L,_){return L.cmp(_)<0?L:_},h.prototype._init=function(L,_,F){if(typeof L=="number")return this._initNumber(L,_,F);if(typeof L=="object")return this._initArray(L,_,F);_==="hex"&&(_=16),d(_===(0|_)&&_>=2&&_<=36);var k=0;(L=L.toString().replace(/\s+/g,""))[0]==="-"&&(k++,this.negative=1),k<L.length&&(_===16?this._parseHex(L,k,F):(this._parseBase(L,_,k),F==="le"&&this._initArray(this.toArray(),_,F)))},h.prototype._initNumber=function(L,_,F){L<0&&(this.negative=1,L=-L),L<67108864?(this.words=[67108863&L],this.length=1):L<4503599627370496?(this.words=[67108863&L,L/67108864&67108863],this.length=2):(d(L<9007199254740992),this.words=[67108863&L,L/67108864&67108863,1],this.length=3),F==="le"&&this._initArray(this.toArray(),_,F)},h.prototype._initArray=function(L,_,F){if(d(typeof L.length=="number"),L.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(L.length/3),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var Ye,rn,ii=0;if(F==="be")for(k=L.length-1,Ye=0;k>=0;k-=3)rn=L[k]|L[k-1]<<8|L[k-2]<<16,this.words[Ye]|=rn<<ii&67108863,this.words[Ye+1]=rn>>>26-ii&67108863,(ii+=24)>=26&&(ii-=26,Ye++);else if(F==="le")for(k=0,Ye=0;k<L.length;k+=3)rn=L[k]|L[k+1]<<8|L[k+2]<<16,this.words[Ye]|=rn<<ii&67108863,this.words[Ye+1]=rn>>>26-ii&67108863,(ii+=24)>=26&&(ii-=26,Ye++);return this._strip()},h.prototype._parseHex=function(L,_,F){this.length=Math.ceil((L.length-_)/6),this.words=new Array(this.length);for(var k=0;k<this.length;k++)this.words[k]=0;var Ye,rn=0,ii=0;if(F==="be")for(k=L.length-1;k>=_;k-=2)Ye=w(L,_,k)<<rn,this.words[ii]|=67108863&Ye,rn>=18?(rn-=18,ii+=1,this.words[ii]|=Ye>>>26):rn+=8;else for(k=(L.length-_)%2==0?_+1:_;k<L.length;k+=2)Ye=w(L,_,k)<<rn,this.words[ii]|=67108863&Ye,rn>=18?(rn-=18,ii+=1,this.words[ii]|=Ye>>>26):rn+=8;this._strip()},h.prototype._parseBase=function(L,_,F){this.words=[0],this.length=1;for(var k=0,Ye=1;Ye<=67108863;Ye*=_)k++;k--,Ye=Ye/_|0;for(var rn=L.length-F,ii=rn%k,ai=Math.min(rn,rn-ii)+F,ni=0,ri=F;ri<ai;ri+=k)ni=S(L,ri,ri+k,_),this.imuln(Ye),this.words[0]+ni<67108864?this.words[0]+=ni:this._iaddn(ni);if(ii!==0){var ui=1;for(ni=S(L,ri,L.length,_),ri=0;ri<ii;ri++)ui*=_;this.imuln(ui),this.words[0]+ni<67108864?this.words[0]+=ni:this._iaddn(ni)}this._strip()},h.prototype.copy=function(L){L.words=new Array(this.length);for(var _=0;_<this.length;_++)L.words[_]=this.words[_];L.length=this.length,L.negative=this.negative,L.red=this.red},h.prototype._move=function(L){E(L,this)},h.prototype.clone=function(){var L=new h(null);return this.copy(L),L},h.prototype._expand=function(L){for(;this.length<L;)this.words[this.length++]=0;return this},h.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},h.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{h.prototype[Symbol.for("nodejs.util.inspect.custom")]=B}catch{h.prototype.inspect=B}else h.prototype.inspect=B;function B(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var ae=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],W=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],J=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function ve(L,_,F){F.negative=_.negative^L.negative;var k=L.length+_.length|0;F.length=k,k=k-1|0;var Ye=0|L.words[0],rn=0|_.words[0],ii=Ye*rn,ai=67108863&ii,ni=ii/67108864|0;F.words[0]=ai;for(var ri=1;ri<k;ri++){for(var ui=ni>>>26,lr=67108863&ni,ar=Math.min(ri,_.length-1),jr=Math.max(0,ri-L.length+1);jr<=ar;jr++){var ci=ri-jr|0;ui+=(ii=(Ye=0|L.words[ci])*(rn=0|_.words[jr])+lr)/67108864|0,lr=67108863&ii}F.words[ri]=0|lr,ni=0|ui}return ni!==0?F.words[ri]=0|ni:F.length--,F._strip()}h.prototype.toString=function(L,_){var F;if(_=0|_||1,(L=L||10)===16||L==="hex"){F="";for(var k=0,Ye=0,rn=0;rn<this.length;rn++){var ii=this.words[rn],ai=(16777215&(ii<<k|Ye)).toString(16);Ye=ii>>>24-k&16777215,(k+=2)>=26&&(k-=26,rn--),F=Ye!==0||rn!==this.length-1?ae[6-ai.length]+ai+F:ai+F}for(Ye!==0&&(F=Ye.toString(16)+F);F.length%_!=0;)F="0"+F;return this.negative!==0&&(F="-"+F),F}if(L===(0|L)&&L>=2&&L<=36){var ni=W[L],ri=J[L];F="";var ui=this.clone();for(ui.negative=0;!ui.isZero();){var lr=ui.modrn(ri).toString(L);F=(ui=ui.idivn(ri)).isZero()?lr+F:ae[ni-lr.length]+lr+F}for(this.isZero()&&(F="0"+F);F.length%_!=0;)F="0"+F;return this.negative!==0&&(F="-"+F),F}d(!1,"Base should be between 2 and 36")},h.prototype.toNumber=function(){var L=this.words[0];return this.length===2?L+=67108864*this.words[1]:this.length===3&&this.words[2]===1?L+=4503599627370496+67108864*this.words[1]:this.length>2&&d(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-L:L},h.prototype.toJSON=function(){return this.toString(16,2)},y&&(h.prototype.toBuffer=function(L,_){return this.toArrayLike(y,L,_)}),h.prototype.toArray=function(L,_){return this.toArrayLike(Array,L,_)},h.prototype.toArrayLike=function(L,_,F){this._strip();var k=this.byteLength(),Ye=F||Math.max(1,k);d(k<=Ye,"byte array longer than desired length"),d(Ye>0,"Requested array length <= 0");var rn=(function(ii,ai){return ii.allocUnsafe?ii.allocUnsafe(ai):new ii(ai)})(L,Ye);return this["_toArrayLike"+(_==="le"?"LE":"BE")](rn,k),rn},h.prototype._toArrayLikeLE=function(L,_){for(var F=0,k=0,Ye=0,rn=0;Ye<this.length;Ye++){var ii=this.words[Ye]<<rn|k;L[F++]=255&ii,F<L.length&&(L[F++]=ii>>8&255),F<L.length&&(L[F++]=ii>>16&255),rn===6?(F<L.length&&(L[F++]=ii>>24&255),k=0,rn=0):(k=ii>>>24,rn+=2)}if(F<L.length)for(L[F++]=k;F<L.length;)L[F++]=0},h.prototype._toArrayLikeBE=function(L,_){for(var F=L.length-1,k=0,Ye=0,rn=0;Ye<this.length;Ye++){var ii=this.words[Ye]<<rn|k;L[F--]=255&ii,F>=0&&(L[F--]=ii>>8&255),F>=0&&(L[F--]=ii>>16&255),rn===6?(F>=0&&(L[F--]=ii>>24&255),k=0,rn=0):(k=ii>>>24,rn+=2)}if(F>=0)for(L[F--]=k;F>=0;)L[F--]=0},Math.clz32?h.prototype._countBits=function(L){return 32-Math.clz32(L)}:h.prototype._countBits=function(L){var _=L,F=0;return _>=4096&&(F+=13,_>>>=13),_>=64&&(F+=7,_>>>=7),_>=8&&(F+=4,_>>>=4),_>=2&&(F+=2,_>>>=2),F+_},h.prototype._zeroBits=function(L){if(L===0)return 26;var _=L,F=0;return(8191&_)==0&&(F+=13,_>>>=13),(127&_)==0&&(F+=7,_>>>=7),(15&_)==0&&(F+=4,_>>>=4),(3&_)==0&&(F+=2,_>>>=2),(1&_)==0&&F++,F},h.prototype.bitLength=function(){var L=this.words[this.length-1],_=this._countBits(L);return 26*(this.length-1)+_},h.prototype.zeroBits=function(){if(this.isZero())return 0;for(var L=0,_=0;_<this.length;_++){var F=this._zeroBits(this.words[_]);if(L+=F,F!==26)break}return L},h.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},h.prototype.toTwos=function(L){return this.negative!==0?this.abs().inotn(L).iaddn(1):this.clone()},h.prototype.fromTwos=function(L){return this.testn(L-1)?this.notn(L).iaddn(1).ineg():this.clone()},h.prototype.isNeg=function(){return this.negative!==0},h.prototype.neg=function(){return this.clone().ineg()},h.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},h.prototype.iuor=function(L){for(;this.length<L.length;)this.words[this.length++]=0;for(var _=0;_<L.length;_++)this.words[_]=this.words[_]|L.words[_];return this._strip()},h.prototype.ior=function(L){return d((this.negative|L.negative)==0),this.iuor(L)},h.prototype.or=function(L){return this.length>L.length?this.clone().ior(L):L.clone().ior(this)},h.prototype.uor=function(L){return this.length>L.length?this.clone().iuor(L):L.clone().iuor(this)},h.prototype.iuand=function(L){var _;_=this.length>L.length?L:this;for(var F=0;F<_.length;F++)this.words[F]=this.words[F]&L.words[F];return this.length=_.length,this._strip()},h.prototype.iand=function(L){return d((this.negative|L.negative)==0),this.iuand(L)},h.prototype.and=function(L){return this.length>L.length?this.clone().iand(L):L.clone().iand(this)},h.prototype.uand=function(L){return this.length>L.length?this.clone().iuand(L):L.clone().iuand(this)},h.prototype.iuxor=function(L){var _,F;this.length>L.length?(_=this,F=L):(_=L,F=this);for(var k=0;k<F.length;k++)this.words[k]=_.words[k]^F.words[k];if(this!==_)for(;k<_.length;k++)this.words[k]=_.words[k];return this.length=_.length,this._strip()},h.prototype.ixor=function(L){return d((this.negative|L.negative)==0),this.iuxor(L)},h.prototype.xor=function(L){return this.length>L.length?this.clone().ixor(L):L.clone().ixor(this)},h.prototype.uxor=function(L){return this.length>L.length?this.clone().iuxor(L):L.clone().iuxor(this)},h.prototype.inotn=function(L){d(typeof L=="number"&&L>=0);var _=0|Math.ceil(L/26),F=L%26;this._expand(_),F>0&&_--;for(var k=0;k<_;k++)this.words[k]=67108863&~this.words[k];return F>0&&(this.words[k]=~this.words[k]&67108863>>26-F),this._strip()},h.prototype.notn=function(L){return this.clone().inotn(L)},h.prototype.setn=function(L,_){d(typeof L=="number"&&L>=0);var F=L/26|0,k=L%26;return this._expand(F+1),this.words[F]=_?this.words[F]|1<<k:this.words[F]&~(1<<k),this._strip()},h.prototype.iadd=function(L){var _,F,k;if(this.negative!==0&&L.negative===0)return this.negative=0,_=this.isub(L),this.negative^=1,this._normSign();if(this.negative===0&&L.negative!==0)return L.negative=0,_=this.isub(L),L.negative=1,_._normSign();this.length>L.length?(F=this,k=L):(F=L,k=this);for(var Ye=0,rn=0;rn<k.length;rn++)_=(0|F.words[rn])+(0|k.words[rn])+Ye,this.words[rn]=67108863&_,Ye=_>>>26;for(;Ye!==0&&rn<F.length;rn++)_=(0|F.words[rn])+Ye,this.words[rn]=67108863&_,Ye=_>>>26;if(this.length=F.length,Ye!==0)this.words[this.length]=Ye,this.length++;else if(F!==this)for(;rn<F.length;rn++)this.words[rn]=F.words[rn];return this},h.prototype.add=function(L){var _;return L.negative!==0&&this.negative===0?(L.negative=0,_=this.sub(L),L.negative^=1,_):L.negative===0&&this.negative!==0?(this.negative=0,_=L.sub(this),this.negative=1,_):this.length>L.length?this.clone().iadd(L):L.clone().iadd(this)},h.prototype.isub=function(L){if(L.negative!==0){L.negative=0;var _=this.iadd(L);return L.negative=1,_._normSign()}if(this.negative!==0)return this.negative=0,this.iadd(L),this.negative=1,this._normSign();var F,k,Ye=this.cmp(L);if(Ye===0)return this.negative=0,this.length=1,this.words[0]=0,this;Ye>0?(F=this,k=L):(F=L,k=this);for(var rn=0,ii=0;ii<k.length;ii++)rn=(_=(0|F.words[ii])-(0|k.words[ii])+rn)>>26,this.words[ii]=67108863&_;for(;rn!==0&&ii<F.length;ii++)rn=(_=(0|F.words[ii])+rn)>>26,this.words[ii]=67108863&_;if(rn===0&&ii<F.length&&F!==this)for(;ii<F.length;ii++)this.words[ii]=F.words[ii];return this.length=Math.max(this.length,ii),F!==this&&(this.negative=1),this._strip()},h.prototype.sub=function(L){return this.clone().isub(L)};var Qe=function(L,_,F){var k,Ye,rn,ii=L.words,ai=_.words,ni=F.words,ri=0,ui=0|ii[0],lr=8191&ui,ar=ui>>>13,jr=0|ii[1],ci=8191&jr,mi=jr>>>13,pi=0|ii[2],ei=8191&pi,Gr=pi>>>13,ti=0|ii[3],fi=8191&ti,bi=ti>>>13,Ai=0|ii[4],Bi=8191&Ai,qi=Ai>>>13,vn=0|ii[5],di=8191&vn,rr=vn>>>13,on=0|ii[6],si=8191&on,vi=on>>>13,Ei=0|ii[7],Mi=8191&Ei,Di=Ei>>>13,Ii=0|ii[8],Ci=8191&Ii,Vi=Ii>>>13,Hi=0|ii[9],Ji=8191&Hi,no=Hi>>>13,co=0|ai[0],Fo=8191&co,Io=co>>>13,Ro=0|ai[1],Oo=8191&Ro,To=Ro>>>13,Po=0|ai[2],ia=8191&Po,Jo=Po>>>13,ea=0|ai[3],zi=8191&ea,Gi=ea>>>13,uo=0|ai[4],wo=8191&uo,xi=uo>>>13,Fi=0|ai[5],Ui=8191&Fi,gi=Fi>>>13,Li=0|ai[6],Qi=8191&Li,Wi=Li>>>13,io=0|ai[7],lo=8191&io,Ao=io>>>13,_o=0|ai[8],ca=8191&_o,Co=_o>>>13,$o=0|ai[9],ta=8191&$o,sa=$o>>>13;F.negative=L.negative^_.negative,F.length=19;var ga=(ri+(k=Math.imul(lr,Fo))|0)+((8191&(Ye=(Ye=Math.imul(lr,Io))+Math.imul(ar,Fo)|0))<<13)|0;ri=((rn=Math.imul(ar,Io))+(Ye>>>13)|0)+(ga>>>26)|0,ga&=67108863,k=Math.imul(ci,Fo),Ye=(Ye=Math.imul(ci,Io))+Math.imul(mi,Fo)|0,rn=Math.imul(mi,Io);var ya=(ri+(k=k+Math.imul(lr,Oo)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(lr,To)|0)+Math.imul(ar,Oo)|0))<<13)|0;ri=((rn=rn+Math.imul(ar,To)|0)+(Ye>>>13)|0)+(ya>>>26)|0,ya&=67108863,k=Math.imul(ei,Fo),Ye=(Ye=Math.imul(ei,Io))+Math.imul(Gr,Fo)|0,rn=Math.imul(Gr,Io),k=k+Math.imul(ci,Oo)|0,Ye=(Ye=Ye+Math.imul(ci,To)|0)+Math.imul(mi,Oo)|0,rn=rn+Math.imul(mi,To)|0;var ma=(ri+(k=k+Math.imul(lr,ia)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(lr,Jo)|0)+Math.imul(ar,ia)|0))<<13)|0;ri=((rn=rn+Math.imul(ar,Jo)|0)+(Ye>>>13)|0)+(ma>>>26)|0,ma&=67108863,k=Math.imul(fi,Fo),Ye=(Ye=Math.imul(fi,Io))+Math.imul(bi,Fo)|0,rn=Math.imul(bi,Io),k=k+Math.imul(ei,Oo)|0,Ye=(Ye=Ye+Math.imul(ei,To)|0)+Math.imul(Gr,Oo)|0,rn=rn+Math.imul(Gr,To)|0,k=k+Math.imul(ci,ia)|0,Ye=(Ye=Ye+Math.imul(ci,Jo)|0)+Math.imul(mi,ia)|0,rn=rn+Math.imul(mi,Jo)|0;var fa=(ri+(k=k+Math.imul(lr,zi)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(lr,Gi)|0)+Math.imul(ar,zi)|0))<<13)|0;ri=((rn=rn+Math.imul(ar,Gi)|0)+(Ye>>>13)|0)+(fa>>>26)|0,fa&=67108863,k=Math.imul(Bi,Fo),Ye=(Ye=Math.imul(Bi,Io))+Math.imul(qi,Fo)|0,rn=Math.imul(qi,Io),k=k+Math.imul(fi,Oo)|0,Ye=(Ye=Ye+Math.imul(fi,To)|0)+Math.imul(bi,Oo)|0,rn=rn+Math.imul(bi,To)|0,k=k+Math.imul(ei,ia)|0,Ye=(Ye=Ye+Math.imul(ei,Jo)|0)+Math.imul(Gr,ia)|0,rn=rn+Math.imul(Gr,Jo)|0,k=k+Math.imul(ci,zi)|0,Ye=(Ye=Ye+Math.imul(ci,Gi)|0)+Math.imul(mi,zi)|0,rn=rn+Math.imul(mi,Gi)|0;var ra=(ri+(k=k+Math.imul(lr,wo)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(lr,xi)|0)+Math.imul(ar,wo)|0))<<13)|0;ri=((rn=rn+Math.imul(ar,xi)|0)+(Ye>>>13)|0)+(ra>>>26)|0,ra&=67108863,k=Math.imul(di,Fo),Ye=(Ye=Math.imul(di,Io))+Math.imul(rr,Fo)|0,rn=Math.imul(rr,Io),k=k+Math.imul(Bi,Oo)|0,Ye=(Ye=Ye+Math.imul(Bi,To)|0)+Math.imul(qi,Oo)|0,rn=rn+Math.imul(qi,To)|0,k=k+Math.imul(fi,ia)|0,Ye=(Ye=Ye+Math.imul(fi,Jo)|0)+Math.imul(bi,ia)|0,rn=rn+Math.imul(bi,Jo)|0,k=k+Math.imul(ei,zi)|0,Ye=(Ye=Ye+Math.imul(ei,Gi)|0)+Math.imul(Gr,zi)|0,rn=rn+Math.imul(Gr,Gi)|0,k=k+Math.imul(ci,wo)|0,Ye=(Ye=Ye+Math.imul(ci,xi)|0)+Math.imul(mi,wo)|0,rn=rn+Math.imul(mi,xi)|0;var ha=(ri+(k=k+Math.imul(lr,Ui)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(lr,gi)|0)+Math.imul(ar,Ui)|0))<<13)|0;ri=((rn=rn+Math.imul(ar,gi)|0)+(Ye>>>13)|0)+(ha>>>26)|0,ha&=67108863,k=Math.imul(si,Fo),Ye=(Ye=Math.imul(si,Io))+Math.imul(vi,Fo)|0,rn=Math.imul(vi,Io),k=k+Math.imul(di,Oo)|0,Ye=(Ye=Ye+Math.imul(di,To)|0)+Math.imul(rr,Oo)|0,rn=rn+Math.imul(rr,To)|0,k=k+Math.imul(Bi,ia)|0,Ye=(Ye=Ye+Math.imul(Bi,Jo)|0)+Math.imul(qi,ia)|0,rn=rn+Math.imul(qi,Jo)|0,k=k+Math.imul(fi,zi)|0,Ye=(Ye=Ye+Math.imul(fi,Gi)|0)+Math.imul(bi,zi)|0,rn=rn+Math.imul(bi,Gi)|0,k=k+Math.imul(ei,wo)|0,Ye=(Ye=Ye+Math.imul(ei,xi)|0)+Math.imul(Gr,wo)|0,rn=rn+Math.imul(Gr,xi)|0,k=k+Math.imul(ci,Ui)|0,Ye=(Ye=Ye+Math.imul(ci,gi)|0)+Math.imul(mi,Ui)|0,rn=rn+Math.imul(mi,gi)|0;var Wo=(ri+(k=k+Math.imul(lr,Qi)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(lr,Wi)|0)+Math.imul(ar,Qi)|0))<<13)|0;ri=((rn=rn+Math.imul(ar,Wi)|0)+(Ye>>>13)|0)+(Wo>>>26)|0,Wo&=67108863,k=Math.imul(Mi,Fo),Ye=(Ye=Math.imul(Mi,Io))+Math.imul(Di,Fo)|0,rn=Math.imul(Di,Io),k=k+Math.imul(si,Oo)|0,Ye=(Ye=Ye+Math.imul(si,To)|0)+Math.imul(vi,Oo)|0,rn=rn+Math.imul(vi,To)|0,k=k+Math.imul(di,ia)|0,Ye=(Ye=Ye+Math.imul(di,Jo)|0)+Math.imul(rr,ia)|0,rn=rn+Math.imul(rr,Jo)|0,k=k+Math.imul(Bi,zi)|0,Ye=(Ye=Ye+Math.imul(Bi,Gi)|0)+Math.imul(qi,zi)|0,rn=rn+Math.imul(qi,Gi)|0,k=k+Math.imul(fi,wo)|0,Ye=(Ye=Ye+Math.imul(fi,xi)|0)+Math.imul(bi,wo)|0,rn=rn+Math.imul(bi,xi)|0,k=k+Math.imul(ei,Ui)|0,Ye=(Ye=Ye+Math.imul(ei,gi)|0)+Math.imul(Gr,Ui)|0,rn=rn+Math.imul(Gr,gi)|0,k=k+Math.imul(ci,Qi)|0,Ye=(Ye=Ye+Math.imul(ci,Wi)|0)+Math.imul(mi,Qi)|0,rn=rn+Math.imul(mi,Wi)|0;var na=(ri+(k=k+Math.imul(lr,lo)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(lr,Ao)|0)+Math.imul(ar,lo)|0))<<13)|0;ri=((rn=rn+Math.imul(ar,Ao)|0)+(Ye>>>13)|0)+(na>>>26)|0,na&=67108863,k=Math.imul(Ci,Fo),Ye=(Ye=Math.imul(Ci,Io))+Math.imul(Vi,Fo)|0,rn=Math.imul(Vi,Io),k=k+Math.imul(Mi,Oo)|0,Ye=(Ye=Ye+Math.imul(Mi,To)|0)+Math.imul(Di,Oo)|0,rn=rn+Math.imul(Di,To)|0,k=k+Math.imul(si,ia)|0,Ye=(Ye=Ye+Math.imul(si,Jo)|0)+Math.imul(vi,ia)|0,rn=rn+Math.imul(vi,Jo)|0,k=k+Math.imul(di,zi)|0,Ye=(Ye=Ye+Math.imul(di,Gi)|0)+Math.imul(rr,zi)|0,rn=rn+Math.imul(rr,Gi)|0,k=k+Math.imul(Bi,wo)|0,Ye=(Ye=Ye+Math.imul(Bi,xi)|0)+Math.imul(qi,wo)|0,rn=rn+Math.imul(qi,xi)|0,k=k+Math.imul(fi,Ui)|0,Ye=(Ye=Ye+Math.imul(fi,gi)|0)+Math.imul(bi,Ui)|0,rn=rn+Math.imul(bi,gi)|0,k=k+Math.imul(ei,Qi)|0,Ye=(Ye=Ye+Math.imul(ei,Wi)|0)+Math.imul(Gr,Qi)|0,rn=rn+Math.imul(Gr,Wi)|0,k=k+Math.imul(ci,lo)|0,Ye=(Ye=Ye+Math.imul(ci,Ao)|0)+Math.imul(mi,lo)|0,rn=rn+Math.imul(mi,Ao)|0;var la=(ri+(k=k+Math.imul(lr,ca)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(lr,Co)|0)+Math.imul(ar,ca)|0))<<13)|0;ri=((rn=rn+Math.imul(ar,Co)|0)+(Ye>>>13)|0)+(la>>>26)|0,la&=67108863,k=Math.imul(Ji,Fo),Ye=(Ye=Math.imul(Ji,Io))+Math.imul(no,Fo)|0,rn=Math.imul(no,Io),k=k+Math.imul(Ci,Oo)|0,Ye=(Ye=Ye+Math.imul(Ci,To)|0)+Math.imul(Vi,Oo)|0,rn=rn+Math.imul(Vi,To)|0,k=k+Math.imul(Mi,ia)|0,Ye=(Ye=Ye+Math.imul(Mi,Jo)|0)+Math.imul(Di,ia)|0,rn=rn+Math.imul(Di,Jo)|0,k=k+Math.imul(si,zi)|0,Ye=(Ye=Ye+Math.imul(si,Gi)|0)+Math.imul(vi,zi)|0,rn=rn+Math.imul(vi,Gi)|0,k=k+Math.imul(di,wo)|0,Ye=(Ye=Ye+Math.imul(di,xi)|0)+Math.imul(rr,wo)|0,rn=rn+Math.imul(rr,xi)|0,k=k+Math.imul(Bi,Ui)|0,Ye=(Ye=Ye+Math.imul(Bi,gi)|0)+Math.imul(qi,Ui)|0,rn=rn+Math.imul(qi,gi)|0,k=k+Math.imul(fi,Qi)|0,Ye=(Ye=Ye+Math.imul(fi,Wi)|0)+Math.imul(bi,Qi)|0,rn=rn+Math.imul(bi,Wi)|0,k=k+Math.imul(ei,lo)|0,Ye=(Ye=Ye+Math.imul(ei,Ao)|0)+Math.imul(Gr,lo)|0,rn=rn+Math.imul(Gr,Ao)|0,k=k+Math.imul(ci,ca)|0,Ye=(Ye=Ye+Math.imul(ci,Co)|0)+Math.imul(mi,ca)|0,rn=rn+Math.imul(mi,Co)|0;var Yo=(ri+(k=k+Math.imul(lr,ta)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(lr,sa)|0)+Math.imul(ar,ta)|0))<<13)|0;ri=((rn=rn+Math.imul(ar,sa)|0)+(Ye>>>13)|0)+(Yo>>>26)|0,Yo&=67108863,k=Math.imul(Ji,Oo),Ye=(Ye=Math.imul(Ji,To))+Math.imul(no,Oo)|0,rn=Math.imul(no,To),k=k+Math.imul(Ci,ia)|0,Ye=(Ye=Ye+Math.imul(Ci,Jo)|0)+Math.imul(Vi,ia)|0,rn=rn+Math.imul(Vi,Jo)|0,k=k+Math.imul(Mi,zi)|0,Ye=(Ye=Ye+Math.imul(Mi,Gi)|0)+Math.imul(Di,zi)|0,rn=rn+Math.imul(Di,Gi)|0,k=k+Math.imul(si,wo)|0,Ye=(Ye=Ye+Math.imul(si,xi)|0)+Math.imul(vi,wo)|0,rn=rn+Math.imul(vi,xi)|0,k=k+Math.imul(di,Ui)|0,Ye=(Ye=Ye+Math.imul(di,gi)|0)+Math.imul(rr,Ui)|0,rn=rn+Math.imul(rr,gi)|0,k=k+Math.imul(Bi,Qi)|0,Ye=(Ye=Ye+Math.imul(Bi,Wi)|0)+Math.imul(qi,Qi)|0,rn=rn+Math.imul(qi,Wi)|0,k=k+Math.imul(fi,lo)|0,Ye=(Ye=Ye+Math.imul(fi,Ao)|0)+Math.imul(bi,lo)|0,rn=rn+Math.imul(bi,Ao)|0,k=k+Math.imul(ei,ca)|0,Ye=(Ye=Ye+Math.imul(ei,Co)|0)+Math.imul(Gr,ca)|0,rn=rn+Math.imul(Gr,Co)|0;var ho=(ri+(k=k+Math.imul(ci,ta)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(ci,sa)|0)+Math.imul(mi,ta)|0))<<13)|0;ri=((rn=rn+Math.imul(mi,sa)|0)+(Ye>>>13)|0)+(ho>>>26)|0,ho&=67108863,k=Math.imul(Ji,ia),Ye=(Ye=Math.imul(Ji,Jo))+Math.imul(no,ia)|0,rn=Math.imul(no,Jo),k=k+Math.imul(Ci,zi)|0,Ye=(Ye=Ye+Math.imul(Ci,Gi)|0)+Math.imul(Vi,zi)|0,rn=rn+Math.imul(Vi,Gi)|0,k=k+Math.imul(Mi,wo)|0,Ye=(Ye=Ye+Math.imul(Mi,xi)|0)+Math.imul(Di,wo)|0,rn=rn+Math.imul(Di,xi)|0,k=k+Math.imul(si,Ui)|0,Ye=(Ye=Ye+Math.imul(si,gi)|0)+Math.imul(vi,Ui)|0,rn=rn+Math.imul(vi,gi)|0,k=k+Math.imul(di,Qi)|0,Ye=(Ye=Ye+Math.imul(di,Wi)|0)+Math.imul(rr,Qi)|0,rn=rn+Math.imul(rr,Wi)|0,k=k+Math.imul(Bi,lo)|0,Ye=(Ye=Ye+Math.imul(Bi,Ao)|0)+Math.imul(qi,lo)|0,rn=rn+Math.imul(qi,Ao)|0,k=k+Math.imul(fi,ca)|0,Ye=(Ye=Ye+Math.imul(fi,Co)|0)+Math.imul(bi,ca)|0,rn=rn+Math.imul(bi,Co)|0;var yo=(ri+(k=k+Math.imul(ei,ta)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(ei,sa)|0)+Math.imul(Gr,ta)|0))<<13)|0;ri=((rn=rn+Math.imul(Gr,sa)|0)+(Ye>>>13)|0)+(yo>>>26)|0,yo&=67108863,k=Math.imul(Ji,zi),Ye=(Ye=Math.imul(Ji,Gi))+Math.imul(no,zi)|0,rn=Math.imul(no,Gi),k=k+Math.imul(Ci,wo)|0,Ye=(Ye=Ye+Math.imul(Ci,xi)|0)+Math.imul(Vi,wo)|0,rn=rn+Math.imul(Vi,xi)|0,k=k+Math.imul(Mi,Ui)|0,Ye=(Ye=Ye+Math.imul(Mi,gi)|0)+Math.imul(Di,Ui)|0,rn=rn+Math.imul(Di,gi)|0,k=k+Math.imul(si,Qi)|0,Ye=(Ye=Ye+Math.imul(si,Wi)|0)+Math.imul(vi,Qi)|0,rn=rn+Math.imul(vi,Wi)|0,k=k+Math.imul(di,lo)|0,Ye=(Ye=Ye+Math.imul(di,Ao)|0)+Math.imul(rr,lo)|0,rn=rn+Math.imul(rr,Ao)|0,k=k+Math.imul(Bi,ca)|0,Ye=(Ye=Ye+Math.imul(Bi,Co)|0)+Math.imul(qi,ca)|0,rn=rn+Math.imul(qi,Co)|0;var No=(ri+(k=k+Math.imul(fi,ta)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(fi,sa)|0)+Math.imul(bi,ta)|0))<<13)|0;ri=((rn=rn+Math.imul(bi,sa)|0)+(Ye>>>13)|0)+(No>>>26)|0,No&=67108863,k=Math.imul(Ji,wo),Ye=(Ye=Math.imul(Ji,xi))+Math.imul(no,wo)|0,rn=Math.imul(no,xi),k=k+Math.imul(Ci,Ui)|0,Ye=(Ye=Ye+Math.imul(Ci,gi)|0)+Math.imul(Vi,Ui)|0,rn=rn+Math.imul(Vi,gi)|0,k=k+Math.imul(Mi,Qi)|0,Ye=(Ye=Ye+Math.imul(Mi,Wi)|0)+Math.imul(Di,Qi)|0,rn=rn+Math.imul(Di,Wi)|0,k=k+Math.imul(si,lo)|0,Ye=(Ye=Ye+Math.imul(si,Ao)|0)+Math.imul(vi,lo)|0,rn=rn+Math.imul(vi,Ao)|0,k=k+Math.imul(di,ca)|0,Ye=(Ye=Ye+Math.imul(di,Co)|0)+Math.imul(rr,ca)|0,rn=rn+Math.imul(rr,Co)|0;var vo=(ri+(k=k+Math.imul(Bi,ta)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(Bi,sa)|0)+Math.imul(qi,ta)|0))<<13)|0;ri=((rn=rn+Math.imul(qi,sa)|0)+(Ye>>>13)|0)+(vo>>>26)|0,vo&=67108863,k=Math.imul(Ji,Ui),Ye=(Ye=Math.imul(Ji,gi))+Math.imul(no,Ui)|0,rn=Math.imul(no,gi),k=k+Math.imul(Ci,Qi)|0,Ye=(Ye=Ye+Math.imul(Ci,Wi)|0)+Math.imul(Vi,Qi)|0,rn=rn+Math.imul(Vi,Wi)|0,k=k+Math.imul(Mi,lo)|0,Ye=(Ye=Ye+Math.imul(Mi,Ao)|0)+Math.imul(Di,lo)|0,rn=rn+Math.imul(Di,Ao)|0,k=k+Math.imul(si,ca)|0,Ye=(Ye=Ye+Math.imul(si,Co)|0)+Math.imul(vi,ca)|0,rn=rn+Math.imul(vi,Co)|0;var bo=(ri+(k=k+Math.imul(di,ta)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(di,sa)|0)+Math.imul(rr,ta)|0))<<13)|0;ri=((rn=rn+Math.imul(rr,sa)|0)+(Ye>>>13)|0)+(bo>>>26)|0,bo&=67108863,k=Math.imul(Ji,Qi),Ye=(Ye=Math.imul(Ji,Wi))+Math.imul(no,Qi)|0,rn=Math.imul(no,Wi),k=k+Math.imul(Ci,lo)|0,Ye=(Ye=Ye+Math.imul(Ci,Ao)|0)+Math.imul(Vi,lo)|0,rn=rn+Math.imul(Vi,Ao)|0,k=k+Math.imul(Mi,ca)|0,Ye=(Ye=Ye+Math.imul(Mi,Co)|0)+Math.imul(Di,ca)|0,rn=rn+Math.imul(Di,Co)|0;var Uo=(ri+(k=k+Math.imul(si,ta)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(si,sa)|0)+Math.imul(vi,ta)|0))<<13)|0;ri=((rn=rn+Math.imul(vi,sa)|0)+(Ye>>>13)|0)+(Uo>>>26)|0,Uo&=67108863,k=Math.imul(Ji,lo),Ye=(Ye=Math.imul(Ji,Ao))+Math.imul(no,lo)|0,rn=Math.imul(no,Ao),k=k+Math.imul(Ci,ca)|0,Ye=(Ye=Ye+Math.imul(Ci,Co)|0)+Math.imul(Vi,ca)|0,rn=rn+Math.imul(Vi,Co)|0;var Aa=(ri+(k=k+Math.imul(Mi,ta)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(Mi,sa)|0)+Math.imul(Di,ta)|0))<<13)|0;ri=((rn=rn+Math.imul(Di,sa)|0)+(Ye>>>13)|0)+(Aa>>>26)|0,Aa&=67108863,k=Math.imul(Ji,ca),Ye=(Ye=Math.imul(Ji,Co))+Math.imul(no,ca)|0,rn=Math.imul(no,Co);var Ua=(ri+(k=k+Math.imul(Ci,ta)|0)|0)+((8191&(Ye=(Ye=Ye+Math.imul(Ci,sa)|0)+Math.imul(Vi,ta)|0))<<13)|0;ri=((rn=rn+Math.imul(Vi,sa)|0)+(Ye>>>13)|0)+(Ua>>>26)|0,Ua&=67108863;var Fa=(ri+(k=Math.imul(Ji,ta))|0)+((8191&(Ye=(Ye=Math.imul(Ji,sa))+Math.imul(no,ta)|0))<<13)|0;return ri=((rn=Math.imul(no,sa))+(Ye>>>13)|0)+(Fa>>>26)|0,Fa&=67108863,ni[0]=ga,ni[1]=ya,ni[2]=ma,ni[3]=fa,ni[4]=ra,ni[5]=ha,ni[6]=Wo,ni[7]=na,ni[8]=la,ni[9]=Yo,ni[10]=ho,ni[11]=yo,ni[12]=No,ni[13]=vo,ni[14]=bo,ni[15]=Uo,ni[16]=Aa,ni[17]=Ua,ni[18]=Fa,ri!==0&&(ni[19]=ri,F.length++),F};function kt(L,_,F){F.negative=_.negative^L.negative,F.length=L.length+_.length;for(var k=0,Ye=0,rn=0;rn<F.length-1;rn++){var ii=Ye;Ye=0;for(var ai=67108863&k,ni=Math.min(rn,_.length-1),ri=Math.max(0,rn-L.length+1);ri<=ni;ri++){var ui=rn-ri,lr=(0|L.words[ui])*(0|_.words[ri]),ar=67108863&lr;ai=67108863&(ar=ar+ai|0),Ye+=(ii=(ii=ii+(lr/67108864|0)|0)+(ar>>>26)|0)>>>26,ii&=67108863}F.words[rn]=ai,k=ii,ii=Ye}return k!==0?F.words[rn]=k:F.length--,F._strip()}function nr(L,_,F){return kt(L,_,F)}Math.imul||(Qe=ve),h.prototype.mulTo=function(L,_){var F=this.length+L.length;return this.length===10&&L.length===10?Qe(this,L,_):F<63?ve(this,L,_):F<1024?kt(this,L,_):nr(this,L,_)},h.prototype.mul=function(L){var _=new h(null);return _.words=new Array(this.length+L.length),this.mulTo(L,_)},h.prototype.mulf=function(L){var _=new h(null);return _.words=new Array(this.length+L.length),nr(this,L,_)},h.prototype.imul=function(L){return this.clone().mulTo(L,this)},h.prototype.imuln=function(L){var _=L<0;_&&(L=-L),d(typeof L=="number"),d(L<67108864);for(var F=0,k=0;k<this.length;k++){var Ye=(0|this.words[k])*L,rn=(67108863&Ye)+(67108863&F);F>>=26,F+=Ye/67108864|0,F+=rn>>>26,this.words[k]=67108863&rn}return F!==0&&(this.words[k]=F,this.length++),_?this.ineg():this},h.prototype.muln=function(L){return this.clone().imuln(L)},h.prototype.sqr=function(){return this.mul(this)},h.prototype.isqr=function(){return this.imul(this.clone())},h.prototype.pow=function(L){var _=(function(rn){for(var ii=new Array(rn.bitLength()),ai=0;ai<ii.length;ai++){var ni=ai/26|0,ri=ai%26;ii[ai]=rn.words[ni]>>>ri&1}return ii})(L);if(_.length===0)return new h(1);for(var F=this,k=0;k<_.length&&_[k]===0;k++,F=F.sqr());if(++k<_.length)for(var Ye=F.sqr();k<_.length;k++,Ye=Ye.sqr())_[k]!==0&&(F=F.mul(Ye));return F},h.prototype.iushln=function(L){d(typeof L=="number"&&L>=0);var _,F=L%26,k=(L-F)/26,Ye=67108863>>>26-F<<26-F;if(F!==0){var rn=0;for(_=0;_<this.length;_++){var ii=this.words[_]&Ye,ai=(0|this.words[_])-ii<<F;this.words[_]=ai|rn,rn=ii>>>26-F}rn&&(this.words[_]=rn,this.length++)}if(k!==0){for(_=this.length-1;_>=0;_--)this.words[_+k]=this.words[_];for(_=0;_<k;_++)this.words[_]=0;this.length+=k}return this._strip()},h.prototype.ishln=function(L){return d(this.negative===0),this.iushln(L)},h.prototype.iushrn=function(L,_,F){var k;d(typeof L=="number"&&L>=0),k=_?(_-_%26)/26:0;var Ye=L%26,rn=Math.min((L-Ye)/26,this.length),ii=67108863^67108863>>>Ye<<Ye,ai=F;if(k-=rn,k=Math.max(0,k),ai){for(var ni=0;ni<rn;ni++)ai.words[ni]=this.words[ni];ai.length=rn}if(rn!==0)if(this.length>rn)for(this.length-=rn,ni=0;ni<this.length;ni++)this.words[ni]=this.words[ni+rn];else this.words[0]=0,this.length=1;var ri=0;for(ni=this.length-1;ni>=0&&(ri!==0||ni>=k);ni--){var ui=0|this.words[ni];this.words[ni]=ri<<26-Ye|ui>>>Ye,ri=ui&ii}return ai&&ri!==0&&(ai.words[ai.length++]=ri),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},h.prototype.ishrn=function(L,_,F){return d(this.negative===0),this.iushrn(L,_,F)},h.prototype.shln=function(L){return this.clone().ishln(L)},h.prototype.ushln=function(L){return this.clone().iushln(L)},h.prototype.shrn=function(L){return this.clone().ishrn(L)},h.prototype.ushrn=function(L){return this.clone().iushrn(L)},h.prototype.testn=function(L){d(typeof L=="number"&&L>=0);var _=L%26,F=(L-_)/26,k=1<<_;return!(this.length<=F||!(this.words[F]&k))},h.prototype.imaskn=function(L){d(typeof L=="number"&&L>=0);var _=L%26,F=(L-_)/26;if(d(this.negative===0,"imaskn works only with positive numbers"),this.length<=F)return this;if(_!==0&&F++,this.length=Math.min(F,this.length),_!==0){var k=67108863^67108863>>>_<<_;this.words[this.length-1]&=k}return this._strip()},h.prototype.maskn=function(L){return this.clone().imaskn(L)},h.prototype.iaddn=function(L){return d(typeof L=="number"),d(L<67108864),L<0?this.isubn(-L):this.negative!==0?this.length===1&&(0|this.words[0])<=L?(this.words[0]=L-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(L),this.negative=1,this):this._iaddn(L)},h.prototype._iaddn=function(L){this.words[0]+=L;for(var _=0;_<this.length&&this.words[_]>=67108864;_++)this.words[_]-=67108864,_===this.length-1?this.words[_+1]=1:this.words[_+1]++;return this.length=Math.max(this.length,_+1),this},h.prototype.isubn=function(L){if(d(typeof L=="number"),d(L<67108864),L<0)return this.iaddn(-L);if(this.negative!==0)return this.negative=0,this.iaddn(L),this.negative=1,this;if(this.words[0]-=L,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var _=0;_<this.length&&this.words[_]<0;_++)this.words[_]+=67108864,this.words[_+1]-=1;return this._strip()},h.prototype.addn=function(L){return this.clone().iaddn(L)},h.prototype.subn=function(L){return this.clone().isubn(L)},h.prototype.iabs=function(){return this.negative=0,this},h.prototype.abs=function(){return this.clone().iabs()},h.prototype._ishlnsubmul=function(L,_,F){var k,Ye,rn=L.length+F;this._expand(rn);var ii=0;for(k=0;k<L.length;k++){Ye=(0|this.words[k+F])+ii;var ai=(0|L.words[k])*_;ii=((Ye-=67108863&ai)>>26)-(ai/67108864|0),this.words[k+F]=67108863&Ye}for(;k<this.length-F;k++)ii=(Ye=(0|this.words[k+F])+ii)>>26,this.words[k+F]=67108863&Ye;if(ii===0)return this._strip();for(d(ii===-1),ii=0,k=0;k<this.length;k++)ii=(Ye=-(0|this.words[k])+ii)>>26,this.words[k]=67108863&Ye;return this.negative=1,this._strip()},h.prototype._wordDiv=function(L,_){var F=(this.length,L.length),k=this.clone(),Ye=L,rn=0|Ye.words[Ye.length-1];(F=26-this._countBits(rn))!=0&&(Ye=Ye.ushln(F),k.iushln(F),rn=0|Ye.words[Ye.length-1]);var ii,ai=k.length-Ye.length;if(_!=="mod"){(ii=new h(null)).length=ai+1,ii.words=new Array(ii.length);for(var ni=0;ni<ii.length;ni++)ii.words[ni]=0}var ri=k.clone()._ishlnsubmul(Ye,1,ai);ri.negative===0&&(k=ri,ii&&(ii.words[ai]=1));for(var ui=ai-1;ui>=0;ui--){var lr=67108864*(0|k.words[Ye.length+ui])+(0|k.words[Ye.length+ui-1]);for(lr=Math.min(lr/rn|0,67108863),k._ishlnsubmul(Ye,lr,ui);k.negative!==0;)lr--,k.negative=0,k._ishlnsubmul(Ye,1,ui),k.isZero()||(k.negative^=1);ii&&(ii.words[ui]=lr)}return ii&&ii._strip(),k._strip(),_!=="div"&&F!==0&&k.iushrn(F),{div:ii||null,mod:k}},h.prototype.divmod=function(L,_,F){return d(!L.isZero()),this.isZero()?{div:new h(0),mod:new h(0)}:this.negative!==0&&L.negative===0?(rn=this.neg().divmod(L,_),_!=="mod"&&(k=rn.div.neg()),_!=="div"&&(Ye=rn.mod.neg(),F&&Ye.negative!==0&&Ye.iadd(L)),{div:k,mod:Ye}):this.negative===0&&L.negative!==0?(rn=this.divmod(L.neg(),_),_!=="mod"&&(k=rn.div.neg()),{div:k,mod:rn.mod}):(this.negative&L.negative)!=0?(rn=this.neg().divmod(L.neg(),_),_!=="div"&&(Ye=rn.mod.neg(),F&&Ye.negative!==0&&Ye.isub(L)),{div:rn.div,mod:Ye}):L.length>this.length||this.cmp(L)<0?{div:new h(0),mod:this}:L.length===1?_==="div"?{div:this.divn(L.words[0]),mod:null}:_==="mod"?{div:null,mod:new h(this.modrn(L.words[0]))}:{div:this.divn(L.words[0]),mod:new h(this.modrn(L.words[0]))}:this._wordDiv(L,_);var k,Ye,rn},h.prototype.div=function(L){return this.divmod(L,"div",!1).div},h.prototype.mod=function(L){return this.divmod(L,"mod",!1).mod},h.prototype.umod=function(L){return this.divmod(L,"mod",!0).mod},h.prototype.divRound=function(L){var _=this.divmod(L);if(_.mod.isZero())return _.div;var F=_.div.negative!==0?_.mod.isub(L):_.mod,k=L.ushrn(1),Ye=L.andln(1),rn=F.cmp(k);return rn<0||Ye===1&&rn===0?_.div:_.div.negative!==0?_.div.isubn(1):_.div.iaddn(1)},h.prototype.modrn=function(L){var _=L<0;_&&(L=-L),d(L<=67108863);for(var F=67108864%L,k=0,Ye=this.length-1;Ye>=0;Ye--)k=(F*k+(0|this.words[Ye]))%L;return _?-k:k},h.prototype.modn=function(L){return this.modrn(L)},h.prototype.idivn=function(L){var _=L<0;_&&(L=-L),d(L<=67108863);for(var F=0,k=this.length-1;k>=0;k--){var Ye=(0|this.words[k])+67108864*F;this.words[k]=Ye/L|0,F=Ye%L}return this._strip(),_?this.ineg():this},h.prototype.divn=function(L){return this.clone().idivn(L)},h.prototype.egcd=function(L){d(L.negative===0),d(!L.isZero());var _=this,F=L.clone();_=_.negative!==0?_.umod(L):_.clone();for(var k=new h(1),Ye=new h(0),rn=new h(0),ii=new h(1),ai=0;_.isEven()&&F.isEven();)_.iushrn(1),F.iushrn(1),++ai;for(var ni=F.clone(),ri=_.clone();!_.isZero();){for(var ui=0,lr=1;(_.words[0]&lr)==0&&ui<26;++ui,lr<<=1);if(ui>0)for(_.iushrn(ui);ui-- >0;)(k.isOdd()||Ye.isOdd())&&(k.iadd(ni),Ye.isub(ri)),k.iushrn(1),Ye.iushrn(1);for(var ar=0,jr=1;(F.words[0]&jr)==0&&ar<26;++ar,jr<<=1);if(ar>0)for(F.iushrn(ar);ar-- >0;)(rn.isOdd()||ii.isOdd())&&(rn.iadd(ni),ii.isub(ri)),rn.iushrn(1),ii.iushrn(1);_.cmp(F)>=0?(_.isub(F),k.isub(rn),Ye.isub(ii)):(F.isub(_),rn.isub(k),ii.isub(Ye))}return{a:rn,b:ii,gcd:F.iushln(ai)}},h.prototype._invmp=function(L){d(L.negative===0),d(!L.isZero());var _=this,F=L.clone();_=_.negative!==0?_.umod(L):_.clone();for(var k,Ye=new h(1),rn=new h(0),ii=F.clone();_.cmpn(1)>0&&F.cmpn(1)>0;){for(var ai=0,ni=1;(_.words[0]&ni)==0&&ai<26;++ai,ni<<=1);if(ai>0)for(_.iushrn(ai);ai-- >0;)Ye.isOdd()&&Ye.iadd(ii),Ye.iushrn(1);for(var ri=0,ui=1;(F.words[0]&ui)==0&&ri<26;++ri,ui<<=1);if(ri>0)for(F.iushrn(ri);ri-- >0;)rn.isOdd()&&rn.iadd(ii),rn.iushrn(1);_.cmp(F)>=0?(_.isub(F),Ye.isub(rn)):(F.isub(_),rn.isub(Ye))}return(k=_.cmpn(1)===0?Ye:rn).cmpn(0)<0&&k.iadd(L),k},h.prototype.gcd=function(L){if(this.isZero())return L.abs();if(L.isZero())return this.abs();var _=this.clone(),F=L.clone();_.negative=0,F.negative=0;for(var k=0;_.isEven()&&F.isEven();k++)_.iushrn(1),F.iushrn(1);for(;;){for(;_.isEven();)_.iushrn(1);for(;F.isEven();)F.iushrn(1);var Ye=_.cmp(F);if(Ye<0){var rn=_;_=F,F=rn}else if(Ye===0||F.cmpn(1)===0)break;_.isub(F)}return F.iushln(k)},h.prototype.invm=function(L){return this.egcd(L).a.umod(L)},h.prototype.isEven=function(){return(1&this.words[0])==0},h.prototype.isOdd=function(){return(1&this.words[0])==1},h.prototype.andln=function(L){return this.words[0]&L},h.prototype.bincn=function(L){d(typeof L=="number");var _=L%26,F=(L-_)/26,k=1<<_;if(this.length<=F)return this._expand(F+1),this.words[F]|=k,this;for(var Ye=k,rn=F;Ye!==0&&rn<this.length;rn++){var ii=0|this.words[rn];Ye=(ii+=Ye)>>>26,ii&=67108863,this.words[rn]=ii}return Ye!==0&&(this.words[rn]=Ye,this.length++),this},h.prototype.isZero=function(){return this.length===1&&this.words[0]===0},h.prototype.cmpn=function(L){var _,F=L<0;if(this.negative!==0&&!F)return-1;if(this.negative===0&&F)return 1;if(this._strip(),this.length>1)_=1;else{F&&(L=-L),d(L<=67108863,"Number is too big");var k=0|this.words[0];_=k===L?0:k<L?-1:1}return this.negative!==0?0|-_:_},h.prototype.cmp=function(L){if(this.negative!==0&&L.negative===0)return-1;if(this.negative===0&&L.negative!==0)return 1;var _=this.ucmp(L);return this.negative!==0?0|-_:_},h.prototype.ucmp=function(L){if(this.length>L.length)return 1;if(this.length<L.length)return-1;for(var _=0,F=this.length-1;F>=0;F--){var k=0|this.words[F],Ye=0|L.words[F];if(k!==Ye){k<Ye?_=-1:k>Ye&&(_=1);break}}return _},h.prototype.gtn=function(L){return this.cmpn(L)===1},h.prototype.gt=function(L){return this.cmp(L)===1},h.prototype.gten=function(L){return this.cmpn(L)>=0},h.prototype.gte=function(L){return this.cmp(L)>=0},h.prototype.ltn=function(L){return this.cmpn(L)===-1},h.prototype.lt=function(L){return this.cmp(L)===-1},h.prototype.lten=function(L){return this.cmpn(L)<=0},h.prototype.lte=function(L){return this.cmp(L)<=0},h.prototype.eqn=function(L){return this.cmpn(L)===0},h.prototype.eq=function(L){return this.cmp(L)===0},h.red=function(L){return new ue(L)},h.prototype.toRed=function(L){return d(!this.red,"Already a number in reduction context"),d(this.negative===0,"red works only with positives"),L.convertTo(this)._forceRed(L)},h.prototype.fromRed=function(){return d(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},h.prototype._forceRed=function(L){return this.red=L,this},h.prototype.forceRed=function(L){return d(!this.red,"Already a number in reduction context"),this._forceRed(L)},h.prototype.redAdd=function(L){return d(this.red,"redAdd works only with red numbers"),this.red.add(this,L)},h.prototype.redIAdd=function(L){return d(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,L)},h.prototype.redSub=function(L){return d(this.red,"redSub works only with red numbers"),this.red.sub(this,L)},h.prototype.redISub=function(L){return d(this.red,"redISub works only with red numbers"),this.red.isub(this,L)},h.prototype.redShl=function(L){return d(this.red,"redShl works only with red numbers"),this.red.shl(this,L)},h.prototype.redMul=function(L){return d(this.red,"redMul works only with red numbers"),this.red._verify2(this,L),this.red.mul(this,L)},h.prototype.redIMul=function(L){return d(this.red,"redMul works only with red numbers"),this.red._verify2(this,L),this.red.imul(this,L)},h.prototype.redSqr=function(){return d(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},h.prototype.redISqr=function(){return d(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},h.prototype.redSqrt=function(){return d(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},h.prototype.redInvm=function(){return d(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},h.prototype.redNeg=function(){return d(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},h.prototype.redPow=function(L){return d(this.red&&!L.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,L)};var sr={k256:null,p224:null,p192:null,p25519:null};function ce(L,_){this.name=L,this.p=new h(_,16),this.n=this.p.bitLength(),this.k=new h(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function Ze(){ce.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function se(){ce.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function vt(){ce.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function ur(){ce.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function ue(L){if(typeof L=="string"){var _=h._prime(L);this.m=_.p,this.prime=_}else d(L.gtn(1),"modulus must be greater than 1"),this.m=L,this.prime=null}function bt(L){ue.call(this,L),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new h(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}ce.prototype._tmp=function(){var L=new h(null);return L.words=new Array(Math.ceil(this.n/13)),L},ce.prototype.ireduce=function(L){var _,F=L;do this.split(F,this.tmp),_=(F=(F=this.imulK(F)).iadd(this.tmp)).bitLength();while(_>this.n);var k=_<this.n?-1:F.ucmp(this.p);return k===0?(F.words[0]=0,F.length=1):k>0?F.isub(this.p):F.strip!==void 0?F.strip():F._strip(),F},ce.prototype.split=function(L,_){L.iushrn(this.n,0,_)},ce.prototype.imulK=function(L){return L.imul(this.k)},p(Ze,ce),Ze.prototype.split=function(L,_){for(var F=4194303,k=Math.min(L.length,9),Ye=0;Ye<k;Ye++)_.words[Ye]=L.words[Ye];if(_.length=k,L.length<=9)return L.words[0]=0,void(L.length=1);var rn=L.words[9];for(_.words[_.length++]=rn&F,Ye=10;Ye<L.length;Ye++){var ii=0|L.words[Ye];L.words[Ye-10]=(ii&F)<<4|rn>>>22,rn=ii}rn>>>=22,L.words[Ye-10]=rn,rn===0&&L.length>10?L.length-=10:L.length-=9},Ze.prototype.imulK=function(L){L.words[L.length]=0,L.words[L.length+1]=0,L.length+=2;for(var _=0,F=0;F<L.length;F++){var k=0|L.words[F];_+=977*k,L.words[F]=67108863&_,_=64*k+(_/67108864|0)}return L.words[L.length-1]===0&&(L.length--,L.words[L.length-1]===0&&L.length--),L},p(se,ce),p(vt,ce),p(ur,ce),ur.prototype.imulK=function(L){for(var _=0,F=0;F<L.length;F++){var k=19*(0|L.words[F])+_,Ye=67108863&k;k>>>=26,L.words[F]=Ye,_=k}return _!==0&&(L.words[L.length++]=_),L},h._prime=function(L){if(sr[L])return sr[L];var _;if(L==="k256")_=new Ze;else if(L==="p224")_=new se;else if(L==="p192")_=new vt;else{if(L!=="p25519")throw new Error("Unknown prime "+L);_=new ur}return sr[L]=_,_},ue.prototype._verify1=function(L){d(L.negative===0,"red works only with positives"),d(L.red,"red works only with red numbers")},ue.prototype._verify2=function(L,_){d((L.negative|_.negative)==0,"red works only with positives"),d(L.red&&L.red===_.red,"red works only with red numbers")},ue.prototype.imod=function(L){return this.prime?this.prime.ireduce(L)._forceRed(this):(E(L,L.umod(this.m)._forceRed(this)),L)},ue.prototype.neg=function(L){return L.isZero()?L.clone():this.m.sub(L)._forceRed(this)},ue.prototype.add=function(L,_){this._verify2(L,_);var F=L.add(_);return F.cmp(this.m)>=0&&F.isub(this.m),F._forceRed(this)},ue.prototype.iadd=function(L,_){this._verify2(L,_);var F=L.iadd(_);return F.cmp(this.m)>=0&&F.isub(this.m),F},ue.prototype.sub=function(L,_){this._verify2(L,_);var F=L.sub(_);return F.cmpn(0)<0&&F.iadd(this.m),F._forceRed(this)},ue.prototype.isub=function(L,_){this._verify2(L,_);var F=L.isub(_);return F.cmpn(0)<0&&F.iadd(this.m),F},ue.prototype.shl=function(L,_){return this._verify1(L),this.imod(L.ushln(_))},ue.prototype.imul=function(L,_){return this._verify2(L,_),this.imod(L.imul(_))},ue.prototype.mul=function(L,_){return this._verify2(L,_),this.imod(L.mul(_))},ue.prototype.isqr=function(L){return this.imul(L,L.clone())},ue.prototype.sqr=function(L){return this.mul(L,L)},ue.prototype.sqrt=function(L){if(L.isZero())return L.clone();var _=this.m.andln(3);if(d(_%2==1),_===3){var F=this.m.add(new h(1)).iushrn(2);return this.pow(L,F)}for(var k=this.m.subn(1),Ye=0;!k.isZero()&&k.andln(1)===0;)Ye++,k.iushrn(1);d(!k.isZero());var rn=new h(1).toRed(this),ii=rn.redNeg(),ai=this.m.subn(1).iushrn(1),ni=this.m.bitLength();for(ni=new h(2*ni*ni).toRed(this);this.pow(ni,ai).cmp(ii)!==0;)ni.redIAdd(ii);for(var ri=this.pow(ni,k),ui=this.pow(L,k.addn(1).iushrn(1)),lr=this.pow(L,k),ar=Ye;lr.cmp(rn)!==0;){for(var jr=lr,ci=0;jr.cmp(rn)!==0;ci++)jr=jr.redSqr();d(ci<ar);var mi=this.pow(ri,new h(1).iushln(ar-ci-1));ui=ui.redMul(mi),ri=mi.redSqr(),lr=lr.redMul(ri),ar=ci}return ui},ue.prototype.invm=function(L){var _=L._invmp(this.m);return _.negative!==0?(_.negative=0,this.imod(_).redNeg()):this.imod(_)},ue.prototype.pow=function(L,_){if(_.isZero())return new h(1).toRed(this);if(_.cmpn(1)===0)return L.clone();var F=new Array(16);F[0]=new h(1).toRed(this),F[1]=L;for(var k=2;k<F.length;k++)F[k]=this.mul(F[k-1],L);var Ye=F[0],rn=0,ii=0,ai=_.bitLength()%26;for(ai===0&&(ai=26),k=_.length-1;k>=0;k--){for(var ni=_.words[k],ri=ai-1;ri>=0;ri--){var ui=ni>>ri&1;Ye!==F[0]&&(Ye=this.sqr(Ye)),ui!==0||rn!==0?(rn<<=1,rn|=ui,(++ii==4||k===0&&ri===0)&&(Ye=this.mul(Ye,F[rn]),ii=0,rn=0)):ii=0}ai=26}return Ye},ue.prototype.convertTo=function(L){var _=L.umod(this.m);return _===L?_.clone():_},ue.prototype.convertFrom=function(L){var _=L.clone();return _.red=null,_},h.mont=function(L){return new bt(L)},p(bt,ue),bt.prototype.convertTo=function(L){return this.imod(L.ushln(this.shift))},bt.prototype.convertFrom=function(L){var _=this.imod(L.mul(this.rinv));return _.red=null,_},bt.prototype.imul=function(L,_){if(L.isZero()||_.isZero())return L.words[0]=0,L.length=1,L;var F=L.imul(_),k=F.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Ye=F.isub(k).iushrn(this.shift),rn=Ye;return Ye.cmp(this.m)>=0?rn=Ye.isub(this.m):Ye.cmpn(0)<0&&(rn=Ye.iadd(this.m)),rn._forceRed(this)},bt.prototype.mul=function(L,_){if(L.isZero()||_.isZero())return new h(0)._forceRed(this);var F=L.mul(_),k=F.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Ye=F.isub(k).iushrn(this.shift),rn=Ye;return Ye.cmp(this.m)>=0?rn=Ye.isub(this.m):Ye.cmpn(0)<0&&(rn=Ye.iadd(this.m)),rn._forceRed(this)},bt.prototype.invm=function(L){return this.imod(L._invmp(this.m).mul(this.r2))._forceRed(this)}})(u=s.nmd(u),this)},9931:(u,a,s)=>{var f;function c(p){this.rand=p}if(u.exports=function(p){return f||(f=new c(null)),f.generate(p)},u.exports.Rand=c,c.prototype.generate=function(p){return this._rand(p)},c.prototype._rand=function(p){if(this.rand.getBytes)return this.rand.getBytes(p);for(var h=new Uint8Array(p),y=0;y<h.length;y++)h[y]=this.rand.getByte();return h},typeof self=="object")self.crypto&&self.crypto.getRandomValues?c.prototype._rand=function(p){var h=new Uint8Array(p);return self.crypto.getRandomValues(h),h}:self.msCrypto&&self.msCrypto.getRandomValues?c.prototype._rand=function(p){var h=new Uint8Array(p);return self.msCrypto.getRandomValues(h),h}:typeof window=="object"&&(c.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var d=s(9214);if(typeof d.randomBytes!="function")throw new Error("Not supported");c.prototype._rand=function(p){return d.randomBytes(p)}}catch{}},7191:(u,a,s)=>{const f=s(8162);u.exports=f("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},8764:(u,a,s)=>{const f=s(9742),c=s(645),d=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;a.Buffer=y,a.SlowBuffer=function(vn){return+vn!=vn&&(vn=0),y.alloc(+vn)},a.INSPECT_MAX_BYTES=50;const p=2147483647;function h(vn){if(vn>p)throw new RangeError('The value "'+vn+'" is invalid for option "size"');const di=new Uint8Array(vn);return Object.setPrototypeOf(di,y.prototype),di}function y(vn,di,rr){if(typeof vn=="number"){if(typeof di=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return S(vn)}return b(vn,di,rr)}function b(vn,di,rr){if(typeof vn=="string")return(function(vi,Ei){if(typeof Ei=="string"&&Ei!==""||(Ei="utf8"),!y.isEncoding(Ei))throw new TypeError("Unknown encoding: "+Ei);const Mi=0|W(vi,Ei);let Di=h(Mi);const Ii=Di.write(vi,Ei);return Ii!==Mi&&(Di=Di.slice(0,Ii)),Di})(vn,di);if(ArrayBuffer.isView(vn))return(function(vi){if(fi(vi,Uint8Array)){const Ei=new Uint8Array(vi);return B(Ei.buffer,Ei.byteOffset,Ei.byteLength)}return E(vi)})(vn);if(vn==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof vn);if(fi(vn,ArrayBuffer)||vn&&fi(vn.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(fi(vn,SharedArrayBuffer)||vn&&fi(vn.buffer,SharedArrayBuffer)))return B(vn,di,rr);if(typeof vn=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const on=vn.valueOf&&vn.valueOf();if(on!=null&&on!==vn)return y.from(on,di,rr);const si=(function(vi){if(y.isBuffer(vi)){const Ei=0|ae(vi.length),Mi=h(Ei);return Mi.length===0||vi.copy(Mi,0,0,Ei),Mi}return vi.length!==void 0?typeof vi.length!="number"||bi(vi.length)?h(0):E(vi):vi.type==="Buffer"&&Array.isArray(vi.data)?E(vi.data):void 0})(vn);if(si)return si;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof vn[Symbol.toPrimitive]=="function")return y.from(vn[Symbol.toPrimitive]("string"),di,rr);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof vn)}function w(vn){if(typeof vn!="number")throw new TypeError('"size" argument must be of type number');if(vn<0)throw new RangeError('The value "'+vn+'" is invalid for option "size"')}function S(vn){return w(vn),h(vn<0?0:0|ae(vn))}function E(vn){const di=vn.length<0?0:0|ae(vn.length),rr=h(di);for(let on=0;on<di;on+=1)rr[on]=255&vn[on];return rr}function B(vn,di,rr){if(di<0||vn.byteLength<di)throw new RangeError('"offset" is outside of buffer bounds');if(vn.byteLength<di+(rr||0))throw new RangeError('"length" is outside of buffer bounds');let on;return on=di===void 0&&rr===void 0?new Uint8Array(vn):rr===void 0?new Uint8Array(vn,di):new Uint8Array(vn,di,rr),Object.setPrototypeOf(on,y.prototype),on}function ae(vn){if(vn>=p)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+p.toString(16)+" bytes");return 0|vn}function W(vn,di){if(y.isBuffer(vn))return vn.length;if(ArrayBuffer.isView(vn)||fi(vn,ArrayBuffer))return vn.byteLength;if(typeof vn!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof vn);const rr=vn.length,on=arguments.length>2&&arguments[2]===!0;if(!on&&rr===0)return 0;let si=!1;for(;;)switch(di){case"ascii":case"latin1":case"binary":return rr;case"utf8":case"utf-8":return ei(vn).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*rr;case"hex":return rr>>>1;case"base64":return Gr(vn).length;default:if(si)return on?-1:ei(vn).length;di=(""+di).toLowerCase(),si=!0}}function J(vn,di,rr){let on=!1;if((di===void 0||di<0)&&(di=0),di>this.length||((rr===void 0||rr>this.length)&&(rr=this.length),rr<=0)||(rr>>>=0)<=(di>>>=0))return"";for(vn||(vn="utf8");;)switch(vn){case"hex":return _(this,di,rr);case"utf8":case"utf-8":return ur(this,di,rr);case"ascii":return bt(this,di,rr);case"latin1":case"binary":return L(this,di,rr);case"base64":return vt(this,di,rr);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,di,rr);default:if(on)throw new TypeError("Unknown encoding: "+vn);vn=(vn+"").toLowerCase(),on=!0}}function ve(vn,di,rr){const on=vn[di];vn[di]=vn[rr],vn[rr]=on}function Qe(vn,di,rr,on,si){if(vn.length===0)return-1;if(typeof rr=="string"?(on=rr,rr=0):rr>2147483647?rr=2147483647:rr<-2147483648&&(rr=-2147483648),bi(rr=+rr)&&(rr=si?0:vn.length-1),rr<0&&(rr=vn.length+rr),rr>=vn.length){if(si)return-1;rr=vn.length-1}else if(rr<0){if(!si)return-1;rr=0}if(typeof di=="string"&&(di=y.from(di,on)),y.isBuffer(di))return di.length===0?-1:kt(vn,di,rr,on,si);if(typeof di=="number")return di&=255,typeof Uint8Array.prototype.indexOf=="function"?si?Uint8Array.prototype.indexOf.call(vn,di,rr):Uint8Array.prototype.lastIndexOf.call(vn,di,rr):kt(vn,[di],rr,on,si);throw new TypeError("val must be string, number or Buffer")}function kt(vn,di,rr,on,si){let vi,Ei=1,Mi=vn.length,Di=di.length;if(on!==void 0&&((on=String(on).toLowerCase())==="ucs2"||on==="ucs-2"||on==="utf16le"||on==="utf-16le")){if(vn.length<2||di.length<2)return-1;Ei=2,Mi/=2,Di/=2,rr/=2}function Ii(Ci,Vi){return Ei===1?Ci[Vi]:Ci.readUInt16BE(Vi*Ei)}if(si){let Ci=-1;for(vi=rr;vi<Mi;vi++)if(Ii(vn,vi)===Ii(di,Ci===-1?0:vi-Ci)){if(Ci===-1&&(Ci=vi),vi-Ci+1===Di)return Ci*Ei}else Ci!==-1&&(vi-=vi-Ci),Ci=-1}else for(rr+Di>Mi&&(rr=Mi-Di),vi=rr;vi>=0;vi--){let Ci=!0;for(let Vi=0;Vi<Di;Vi++)if(Ii(vn,vi+Vi)!==Ii(di,Vi)){Ci=!1;break}if(Ci)return vi}return-1}function nr(vn,di,rr,on){rr=Number(rr)||0;const si=vn.length-rr;on?(on=Number(on))>si&&(on=si):on=si;const vi=di.length;let Ei;for(on>vi/2&&(on=vi/2),Ei=0;Ei<on;++Ei){const Mi=parseInt(di.substr(2*Ei,2),16);if(bi(Mi))return Ei;vn[rr+Ei]=Mi}return Ei}function sr(vn,di,rr,on){return ti(ei(di,vn.length-rr),vn,rr,on)}function ce(vn,di,rr,on){return ti((function(si){const vi=[];for(let Ei=0;Ei<si.length;++Ei)vi.push(255&si.charCodeAt(Ei));return vi})(di),vn,rr,on)}function Ze(vn,di,rr,on){return ti(Gr(di),vn,rr,on)}function se(vn,di,rr,on){return ti((function(si,vi){let Ei,Mi,Di;const Ii=[];for(let Ci=0;Ci<si.length&&!((vi-=2)<0);++Ci)Ei=si.charCodeAt(Ci),Mi=Ei>>8,Di=Ei%256,Ii.push(Di),Ii.push(Mi);return Ii})(di,vn.length-rr),vn,rr,on)}function vt(vn,di,rr){return di===0&&rr===vn.length?f.fromByteArray(vn):f.fromByteArray(vn.slice(di,rr))}function ur(vn,di,rr){rr=Math.min(vn.length,rr);const on=[];let si=di;for(;si<rr;){const vi=vn[si];let Ei=null,Mi=vi>239?4:vi>223?3:vi>191?2:1;if(si+Mi<=rr){let Di,Ii,Ci,Vi;switch(Mi){case 1:vi<128&&(Ei=vi);break;case 2:Di=vn[si+1],(192&Di)==128&&(Vi=(31&vi)<<6|63&Di,Vi>127&&(Ei=Vi));break;case 3:Di=vn[si+1],Ii=vn[si+2],(192&Di)==128&&(192&Ii)==128&&(Vi=(15&vi)<<12|(63&Di)<<6|63&Ii,Vi>2047&&(Vi<55296||Vi>57343)&&(Ei=Vi));break;case 4:Di=vn[si+1],Ii=vn[si+2],Ci=vn[si+3],(192&Di)==128&&(192&Ii)==128&&(192&Ci)==128&&(Vi=(15&vi)<<18|(63&Di)<<12|(63&Ii)<<6|63&Ci,Vi>65535&&Vi<1114112&&(Ei=Vi))}}Ei===null?(Ei=65533,Mi=1):Ei>65535&&(Ei-=65536,on.push(Ei>>>10&1023|55296),Ei=56320|1023&Ei),on.push(Ei),si+=Mi}return(function(vi){const Ei=vi.length;if(Ei<=ue)return String.fromCharCode.apply(String,vi);let Mi="",Di=0;for(;Di<Ei;)Mi+=String.fromCharCode.apply(String,vi.slice(Di,Di+=ue));return Mi})(on)}a.kMaxLength=p,y.TYPED_ARRAY_SUPPORT=(function(){try{const vn=new Uint8Array(1),di={foo:function(){return 42}};return Object.setPrototypeOf(di,Uint8Array.prototype),Object.setPrototypeOf(vn,di),vn.foo()===42}catch{return!1}})(),y.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(y.prototype,"parent",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.buffer}}),Object.defineProperty(y.prototype,"offset",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.byteOffset}}),y.poolSize=8192,y.from=function(vn,di,rr){return b(vn,di,rr)},Object.setPrototypeOf(y.prototype,Uint8Array.prototype),Object.setPrototypeOf(y,Uint8Array),y.alloc=function(vn,di,rr){return(function(on,si,vi){return w(on),on<=0?h(on):si!==void 0?typeof vi=="string"?h(on).fill(si,vi):h(on).fill(si):h(on)})(vn,di,rr)},y.allocUnsafe=function(vn){return S(vn)},y.allocUnsafeSlow=function(vn){return S(vn)},y.isBuffer=function(vn){return vn!=null&&vn._isBuffer===!0&&vn!==y.prototype},y.compare=function(vn,di){if(fi(vn,Uint8Array)&&(vn=y.from(vn,vn.offset,vn.byteLength)),fi(di,Uint8Array)&&(di=y.from(di,di.offset,di.byteLength)),!y.isBuffer(vn)||!y.isBuffer(di))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(vn===di)return 0;let rr=vn.length,on=di.length;for(let si=0,vi=Math.min(rr,on);si<vi;++si)if(vn[si]!==di[si]){rr=vn[si],on=di[si];break}return rr<on?-1:on<rr?1:0},y.isEncoding=function(vn){switch(String(vn).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},y.concat=function(vn,di){if(!Array.isArray(vn))throw new TypeError('"list" argument must be an Array of Buffers');if(vn.length===0)return y.alloc(0);let rr;if(di===void 0)for(di=0,rr=0;rr<vn.length;++rr)di+=vn[rr].length;const on=y.allocUnsafe(di);let si=0;for(rr=0;rr<vn.length;++rr){let vi=vn[rr];if(fi(vi,Uint8Array))si+vi.length>on.length?(y.isBuffer(vi)||(vi=y.from(vi)),vi.copy(on,si)):Uint8Array.prototype.set.call(on,vi,si);else{if(!y.isBuffer(vi))throw new TypeError('"list" argument must be an Array of Buffers');vi.copy(on,si)}si+=vi.length}return on},y.byteLength=W,y.prototype._isBuffer=!0,y.prototype.swap16=function(){const vn=this.length;if(vn%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let di=0;di<vn;di+=2)ve(this,di,di+1);return this},y.prototype.swap32=function(){const vn=this.length;if(vn%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let di=0;di<vn;di+=4)ve(this,di,di+3),ve(this,di+1,di+2);return this},y.prototype.swap64=function(){const vn=this.length;if(vn%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let di=0;di<vn;di+=8)ve(this,di,di+7),ve(this,di+1,di+6),ve(this,di+2,di+5),ve(this,di+3,di+4);return this},y.prototype.toString=function(){const vn=this.length;return vn===0?"":arguments.length===0?ur(this,0,vn):J.apply(this,arguments)},y.prototype.toLocaleString=y.prototype.toString,y.prototype.equals=function(vn){if(!y.isBuffer(vn))throw new TypeError("Argument must be a Buffer");return this===vn||y.compare(this,vn)===0},y.prototype.inspect=function(){let vn="";const di=a.INSPECT_MAX_BYTES;return vn=this.toString("hex",0,di).replace(/(.{2})/g,"$1 ").trim(),this.length>di&&(vn+=" ... "),"<Buffer "+vn+">"},d&&(y.prototype[d]=y.prototype.inspect),y.prototype.compare=function(vn,di,rr,on,si){if(fi(vn,Uint8Array)&&(vn=y.from(vn,vn.offset,vn.byteLength)),!y.isBuffer(vn))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof vn);if(di===void 0&&(di=0),rr===void 0&&(rr=vn?vn.length:0),on===void 0&&(on=0),si===void 0&&(si=this.length),di<0||rr>vn.length||on<0||si>this.length)throw new RangeError("out of range index");if(on>=si&&di>=rr)return 0;if(on>=si)return-1;if(di>=rr)return 1;if(this===vn)return 0;let vi=(si>>>=0)-(on>>>=0),Ei=(rr>>>=0)-(di>>>=0);const Mi=Math.min(vi,Ei),Di=this.slice(on,si),Ii=vn.slice(di,rr);for(let Ci=0;Ci<Mi;++Ci)if(Di[Ci]!==Ii[Ci]){vi=Di[Ci],Ei=Ii[Ci];break}return vi<Ei?-1:Ei<vi?1:0},y.prototype.includes=function(vn,di,rr){return this.indexOf(vn,di,rr)!==-1},y.prototype.indexOf=function(vn,di,rr){return Qe(this,vn,di,rr,!0)},y.prototype.lastIndexOf=function(vn,di,rr){return Qe(this,vn,di,rr,!1)},y.prototype.write=function(vn,di,rr,on){if(di===void 0)on="utf8",rr=this.length,di=0;else if(rr===void 0&&typeof di=="string")on=di,rr=this.length,di=0;else{if(!isFinite(di))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");di>>>=0,isFinite(rr)?(rr>>>=0,on===void 0&&(on="utf8")):(on=rr,rr=void 0)}const si=this.length-di;if((rr===void 0||rr>si)&&(rr=si),vn.length>0&&(rr<0||di<0)||di>this.length)throw new RangeError("Attempt to write outside buffer bounds");on||(on="utf8");let vi=!1;for(;;)switch(on){case"hex":return nr(this,vn,di,rr);case"utf8":case"utf-8":return sr(this,vn,di,rr);case"ascii":case"latin1":case"binary":return ce(this,vn,di,rr);case"base64":return Ze(this,vn,di,rr);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return se(this,vn,di,rr);default:if(vi)throw new TypeError("Unknown encoding: "+on);on=(""+on).toLowerCase(),vi=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const ue=4096;function bt(vn,di,rr){let on="";rr=Math.min(vn.length,rr);for(let si=di;si<rr;++si)on+=String.fromCharCode(127&vn[si]);return on}function L(vn,di,rr){let on="";rr=Math.min(vn.length,rr);for(let si=di;si<rr;++si)on+=String.fromCharCode(vn[si]);return on}function _(vn,di,rr){const on=vn.length;(!di||di<0)&&(di=0),(!rr||rr<0||rr>on)&&(rr=on);let si="";for(let vi=di;vi<rr;++vi)si+=Ai[vn[vi]];return si}function F(vn,di,rr){const on=vn.slice(di,rr);let si="";for(let vi=0;vi<on.length-1;vi+=2)si+=String.fromCharCode(on[vi]+256*on[vi+1]);return si}function k(vn,di,rr){if(vn%1!=0||vn<0)throw new RangeError("offset is not uint");if(vn+di>rr)throw new RangeError("Trying to access beyond buffer length")}function Ye(vn,di,rr,on,si,vi){if(!y.isBuffer(vn))throw new TypeError('"buffer" argument must be a Buffer instance');if(di>si||di<vi)throw new RangeError('"value" argument is out of bounds');if(rr+on>vn.length)throw new RangeError("Index out of range")}function rn(vn,di,rr,on,si){jr(di,on,si,vn,rr,7);let vi=Number(di&BigInt(4294967295));vn[rr++]=vi,vi>>=8,vn[rr++]=vi,vi>>=8,vn[rr++]=vi,vi>>=8,vn[rr++]=vi;let Ei=Number(di>>BigInt(32)&BigInt(4294967295));return vn[rr++]=Ei,Ei>>=8,vn[rr++]=Ei,Ei>>=8,vn[rr++]=Ei,Ei>>=8,vn[rr++]=Ei,rr}function ii(vn,di,rr,on,si){jr(di,on,si,vn,rr,7);let vi=Number(di&BigInt(4294967295));vn[rr+7]=vi,vi>>=8,vn[rr+6]=vi,vi>>=8,vn[rr+5]=vi,vi>>=8,vn[rr+4]=vi;let Ei=Number(di>>BigInt(32)&BigInt(4294967295));return vn[rr+3]=Ei,Ei>>=8,vn[rr+2]=Ei,Ei>>=8,vn[rr+1]=Ei,Ei>>=8,vn[rr]=Ei,rr+8}function ai(vn,di,rr,on,si,vi){if(rr+on>vn.length)throw new RangeError("Index out of range");if(rr<0)throw new RangeError("Index out of range")}function ni(vn,di,rr,on,si){return di=+di,rr>>>=0,si||ai(vn,0,rr,4),c.write(vn,di,rr,on,23,4),rr+4}function ri(vn,di,rr,on,si){return di=+di,rr>>>=0,si||ai(vn,0,rr,8),c.write(vn,di,rr,on,52,8),rr+8}y.prototype.slice=function(vn,di){const rr=this.length;(vn=~~vn)<0?(vn+=rr)<0&&(vn=0):vn>rr&&(vn=rr),(di=di===void 0?rr:~~di)<0?(di+=rr)<0&&(di=0):di>rr&&(di=rr),di<vn&&(di=vn);const on=this.subarray(vn,di);return Object.setPrototypeOf(on,y.prototype),on},y.prototype.readUintLE=y.prototype.readUIntLE=function(vn,di,rr){vn>>>=0,di>>>=0,rr||k(vn,di,this.length);let on=this[vn],si=1,vi=0;for(;++vi<di&&(si*=256);)on+=this[vn+vi]*si;return on},y.prototype.readUintBE=y.prototype.readUIntBE=function(vn,di,rr){vn>>>=0,di>>>=0,rr||k(vn,di,this.length);let on=this[vn+--di],si=1;for(;di>0&&(si*=256);)on+=this[vn+--di]*si;return on},y.prototype.readUint8=y.prototype.readUInt8=function(vn,di){return vn>>>=0,di||k(vn,1,this.length),this[vn]},y.prototype.readUint16LE=y.prototype.readUInt16LE=function(vn,di){return vn>>>=0,di||k(vn,2,this.length),this[vn]|this[vn+1]<<8},y.prototype.readUint16BE=y.prototype.readUInt16BE=function(vn,di){return vn>>>=0,di||k(vn,2,this.length),this[vn]<<8|this[vn+1]},y.prototype.readUint32LE=y.prototype.readUInt32LE=function(vn,di){return vn>>>=0,di||k(vn,4,this.length),(this[vn]|this[vn+1]<<8|this[vn+2]<<16)+16777216*this[vn+3]},y.prototype.readUint32BE=y.prototype.readUInt32BE=function(vn,di){return vn>>>=0,di||k(vn,4,this.length),16777216*this[vn]+(this[vn+1]<<16|this[vn+2]<<8|this[vn+3])},y.prototype.readBigUInt64LE=Bi((function(vn){ci(vn>>>=0,"offset");const di=this[vn],rr=this[vn+7];di!==void 0&&rr!==void 0||mi(vn,this.length-8);const on=di+256*this[++vn]+65536*this[++vn]+this[++vn]*2**24,si=this[++vn]+256*this[++vn]+65536*this[++vn]+rr*2**24;return BigInt(on)+(BigInt(si)<<BigInt(32))})),y.prototype.readBigUInt64BE=Bi((function(vn){ci(vn>>>=0,"offset");const di=this[vn],rr=this[vn+7];di!==void 0&&rr!==void 0||mi(vn,this.length-8);const on=di*2**24+65536*this[++vn]+256*this[++vn]+this[++vn],si=this[++vn]*2**24+65536*this[++vn]+256*this[++vn]+rr;return(BigInt(on)<<BigInt(32))+BigInt(si)})),y.prototype.readIntLE=function(vn,di,rr){vn>>>=0,di>>>=0,rr||k(vn,di,this.length);let on=this[vn],si=1,vi=0;for(;++vi<di&&(si*=256);)on+=this[vn+vi]*si;return si*=128,on>=si&&(on-=Math.pow(2,8*di)),on},y.prototype.readIntBE=function(vn,di,rr){vn>>>=0,di>>>=0,rr||k(vn,di,this.length);let on=di,si=1,vi=this[vn+--on];for(;on>0&&(si*=256);)vi+=this[vn+--on]*si;return si*=128,vi>=si&&(vi-=Math.pow(2,8*di)),vi},y.prototype.readInt8=function(vn,di){return vn>>>=0,di||k(vn,1,this.length),128&this[vn]?-1*(255-this[vn]+1):this[vn]},y.prototype.readInt16LE=function(vn,di){vn>>>=0,di||k(vn,2,this.length);const rr=this[vn]|this[vn+1]<<8;return 32768&rr?4294901760|rr:rr},y.prototype.readInt16BE=function(vn,di){vn>>>=0,di||k(vn,2,this.length);const rr=this[vn+1]|this[vn]<<8;return 32768&rr?4294901760|rr:rr},y.prototype.readInt32LE=function(vn,di){return vn>>>=0,di||k(vn,4,this.length),this[vn]|this[vn+1]<<8|this[vn+2]<<16|this[vn+3]<<24},y.prototype.readInt32BE=function(vn,di){return vn>>>=0,di||k(vn,4,this.length),this[vn]<<24|this[vn+1]<<16|this[vn+2]<<8|this[vn+3]},y.prototype.readBigInt64LE=Bi((function(vn){ci(vn>>>=0,"offset");const di=this[vn],rr=this[vn+7];di!==void 0&&rr!==void 0||mi(vn,this.length-8);const on=this[vn+4]+256*this[vn+5]+65536*this[vn+6]+(rr<<24);return(BigInt(on)<<BigInt(32))+BigInt(di+256*this[++vn]+65536*this[++vn]+this[++vn]*16777216)})),y.prototype.readBigInt64BE=Bi((function(vn){ci(vn>>>=0,"offset");const di=this[vn],rr=this[vn+7];di!==void 0&&rr!==void 0||mi(vn,this.length-8);const on=(di<<24)+65536*this[++vn]+256*this[++vn]+this[++vn];return(BigInt(on)<<BigInt(32))+BigInt(this[++vn]*16777216+65536*this[++vn]+256*this[++vn]+rr)})),y.prototype.readFloatLE=function(vn,di){return vn>>>=0,di||k(vn,4,this.length),c.read(this,vn,!0,23,4)},y.prototype.readFloatBE=function(vn,di){return vn>>>=0,di||k(vn,4,this.length),c.read(this,vn,!1,23,4)},y.prototype.readDoubleLE=function(vn,di){return vn>>>=0,di||k(vn,8,this.length),c.read(this,vn,!0,52,8)},y.prototype.readDoubleBE=function(vn,di){return vn>>>=0,di||k(vn,8,this.length),c.read(this,vn,!1,52,8)},y.prototype.writeUintLE=y.prototype.writeUIntLE=function(vn,di,rr,on){vn=+vn,di>>>=0,rr>>>=0,on||Ye(this,vn,di,rr,Math.pow(2,8*rr)-1,0);let si=1,vi=0;for(this[di]=255&vn;++vi<rr&&(si*=256);)this[di+vi]=vn/si&255;return di+rr},y.prototype.writeUintBE=y.prototype.writeUIntBE=function(vn,di,rr,on){vn=+vn,di>>>=0,rr>>>=0,on||Ye(this,vn,di,rr,Math.pow(2,8*rr)-1,0);let si=rr-1,vi=1;for(this[di+si]=255&vn;--si>=0&&(vi*=256);)this[di+si]=vn/vi&255;return di+rr},y.prototype.writeUint8=y.prototype.writeUInt8=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,1,255,0),this[di]=255&vn,di+1},y.prototype.writeUint16LE=y.prototype.writeUInt16LE=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,2,65535,0),this[di]=255&vn,this[di+1]=vn>>>8,di+2},y.prototype.writeUint16BE=y.prototype.writeUInt16BE=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,2,65535,0),this[di]=vn>>>8,this[di+1]=255&vn,di+2},y.prototype.writeUint32LE=y.prototype.writeUInt32LE=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,4,4294967295,0),this[di+3]=vn>>>24,this[di+2]=vn>>>16,this[di+1]=vn>>>8,this[di]=255&vn,di+4},y.prototype.writeUint32BE=y.prototype.writeUInt32BE=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,4,4294967295,0),this[di]=vn>>>24,this[di+1]=vn>>>16,this[di+2]=vn>>>8,this[di+3]=255&vn,di+4},y.prototype.writeBigUInt64LE=Bi((function(vn,di=0){return rn(this,vn,di,BigInt(0),BigInt("0xffffffffffffffff"))})),y.prototype.writeBigUInt64BE=Bi((function(vn,di=0){return ii(this,vn,di,BigInt(0),BigInt("0xffffffffffffffff"))})),y.prototype.writeIntLE=function(vn,di,rr,on){if(vn=+vn,di>>>=0,!on){const Mi=Math.pow(2,8*rr-1);Ye(this,vn,di,rr,Mi-1,-Mi)}let si=0,vi=1,Ei=0;for(this[di]=255&vn;++si<rr&&(vi*=256);)vn<0&&Ei===0&&this[di+si-1]!==0&&(Ei=1),this[di+si]=(vn/vi>>0)-Ei&255;return di+rr},y.prototype.writeIntBE=function(vn,di,rr,on){if(vn=+vn,di>>>=0,!on){const Mi=Math.pow(2,8*rr-1);Ye(this,vn,di,rr,Mi-1,-Mi)}let si=rr-1,vi=1,Ei=0;for(this[di+si]=255&vn;--si>=0&&(vi*=256);)vn<0&&Ei===0&&this[di+si+1]!==0&&(Ei=1),this[di+si]=(vn/vi>>0)-Ei&255;return di+rr},y.prototype.writeInt8=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,1,127,-128),vn<0&&(vn=255+vn+1),this[di]=255&vn,di+1},y.prototype.writeInt16LE=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,2,32767,-32768),this[di]=255&vn,this[di+1]=vn>>>8,di+2},y.prototype.writeInt16BE=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,2,32767,-32768),this[di]=vn>>>8,this[di+1]=255&vn,di+2},y.prototype.writeInt32LE=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,4,2147483647,-2147483648),this[di]=255&vn,this[di+1]=vn>>>8,this[di+2]=vn>>>16,this[di+3]=vn>>>24,di+4},y.prototype.writeInt32BE=function(vn,di,rr){return vn=+vn,di>>>=0,rr||Ye(this,vn,di,4,2147483647,-2147483648),vn<0&&(vn=4294967295+vn+1),this[di]=vn>>>24,this[di+1]=vn>>>16,this[di+2]=vn>>>8,this[di+3]=255&vn,di+4},y.prototype.writeBigInt64LE=Bi((function(vn,di=0){return rn(this,vn,di,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),y.prototype.writeBigInt64BE=Bi((function(vn,di=0){return ii(this,vn,di,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),y.prototype.writeFloatLE=function(vn,di,rr){return ni(this,vn,di,!0,rr)},y.prototype.writeFloatBE=function(vn,di,rr){return ni(this,vn,di,!1,rr)},y.prototype.writeDoubleLE=function(vn,di,rr){return ri(this,vn,di,!0,rr)},y.prototype.writeDoubleBE=function(vn,di,rr){return ri(this,vn,di,!1,rr)},y.prototype.copy=function(vn,di,rr,on){if(!y.isBuffer(vn))throw new TypeError("argument should be a Buffer");if(rr||(rr=0),on||on===0||(on=this.length),di>=vn.length&&(di=vn.length),di||(di=0),on>0&&on<rr&&(on=rr),on===rr||vn.length===0||this.length===0)return 0;if(di<0)throw new RangeError("targetStart out of bounds");if(rr<0||rr>=this.length)throw new RangeError("Index out of range");if(on<0)throw new RangeError("sourceEnd out of bounds");on>this.length&&(on=this.length),vn.length-di<on-rr&&(on=vn.length-di+rr);const si=on-rr;return this===vn&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(di,rr,on):Uint8Array.prototype.set.call(vn,this.subarray(rr,on),di),si},y.prototype.fill=function(vn,di,rr,on){if(typeof vn=="string"){if(typeof di=="string"?(on=di,di=0,rr=this.length):typeof rr=="string"&&(on=rr,rr=this.length),on!==void 0&&typeof on!="string")throw new TypeError("encoding must be a string");if(typeof on=="string"&&!y.isEncoding(on))throw new TypeError("Unknown encoding: "+on);if(vn.length===1){const vi=vn.charCodeAt(0);(on==="utf8"&&vi<128||on==="latin1")&&(vn=vi)}}else typeof vn=="number"?vn&=255:typeof vn=="boolean"&&(vn=Number(vn));if(di<0||this.length<di||this.length<rr)throw new RangeError("Out of range index");if(rr<=di)return this;let si;if(di>>>=0,rr=rr===void 0?this.length:rr>>>0,vn||(vn=0),typeof vn=="number")for(si=di;si<rr;++si)this[si]=vn;else{const vi=y.isBuffer(vn)?vn:y.from(vn,on),Ei=vi.length;if(Ei===0)throw new TypeError('The value "'+vn+'" is invalid for argument "value"');for(si=0;si<rr-di;++si)this[si+di]=vi[si%Ei]}return this};const ui={};function lr(vn,di,rr){ui[vn]=class extends rr{constructor(){super(),Object.defineProperty(this,"message",{value:di.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${vn}]`,this.stack,delete this.name}get code(){return vn}set code(on){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:on,writable:!0})}toString(){return`${this.name} [${vn}]: ${this.message}`}}}function ar(vn){let di="",rr=vn.length;const on=vn[0]==="-"?1:0;for(;rr>=on+4;rr-=3)di=`_${vn.slice(rr-3,rr)}${di}`;return`${vn.slice(0,rr)}${di}`}function jr(vn,di,rr,on,si,vi){if(vn>rr||vn<di){const Ei=typeof di=="bigint"?"n":"";let Mi;throw Mi=di===0||di===BigInt(0)?`>= 0${Ei} and < 2${Ei} ** ${8*(vi+1)}${Ei}`:`>= -(2${Ei} ** ${8*(vi+1)-1}${Ei}) and < 2 ** ${8*(vi+1)-1}${Ei}`,new ui.ERR_OUT_OF_RANGE("value",Mi,vn)}(function(Ei,Mi,Di){ci(Mi,"offset"),Ei[Mi]!==void 0&&Ei[Mi+Di]!==void 0||mi(Mi,Ei.length-(Di+1))})(on,si,vi)}function ci(vn,di){if(typeof vn!="number")throw new ui.ERR_INVALID_ARG_TYPE(di,"number",vn)}function mi(vn,di,rr){throw Math.floor(vn)!==vn?(ci(vn,rr),new ui.ERR_OUT_OF_RANGE("offset","an integer",vn)):di<0?new ui.ERR_BUFFER_OUT_OF_BOUNDS:new ui.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${di}`,vn)}lr("ERR_BUFFER_OUT_OF_BOUNDS",(function(vn){return vn?`${vn} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),lr("ERR_INVALID_ARG_TYPE",(function(vn,di){return`The "${vn}" argument must be of type number. Received type ${typeof di}`}),TypeError),lr("ERR_OUT_OF_RANGE",(function(vn,di,rr){let on=`The value of "${vn}" is out of range.`,si=rr;return Number.isInteger(rr)&&Math.abs(rr)>4294967296?si=ar(String(rr)):typeof rr=="bigint"&&(si=String(rr),(rr>BigInt(2)**BigInt(32)||rr<-(BigInt(2)**BigInt(32)))&&(si=ar(si)),si+="n"),on+=` It must be ${di}. Received ${si}`,on}),RangeError);const pi=/[^+/0-9A-Za-z-_]/g;function ei(vn,di){let rr;di=di||1/0;const on=vn.length;let si=null;const vi=[];for(let Ei=0;Ei<on;++Ei){if(rr=vn.charCodeAt(Ei),rr>55295&&rr<57344){if(!si){if(rr>56319){(di-=3)>-1&&vi.push(239,191,189);continue}if(Ei+1===on){(di-=3)>-1&&vi.push(239,191,189);continue}si=rr;continue}if(rr<56320){(di-=3)>-1&&vi.push(239,191,189),si=rr;continue}rr=65536+(si-55296<<10|rr-56320)}else si&&(di-=3)>-1&&vi.push(239,191,189);if(si=null,rr<128){if((di-=1)<0)break;vi.push(rr)}else if(rr<2048){if((di-=2)<0)break;vi.push(rr>>6|192,63&rr|128)}else if(rr<65536){if((di-=3)<0)break;vi.push(rr>>12|224,rr>>6&63|128,63&rr|128)}else{if(!(rr<1114112))throw new Error("Invalid code point");if((di-=4)<0)break;vi.push(rr>>18|240,rr>>12&63|128,rr>>6&63|128,63&rr|128)}}return vi}function Gr(vn){return f.toByteArray((function(di){if((di=(di=di.split("=")[0]).trim().replace(pi,"")).length<2)return"";for(;di.length%4!=0;)di+="=";return di})(vn))}function ti(vn,di,rr,on){let si;for(si=0;si<on&&!(si+rr>=di.length||si>=vn.length);++si)di[si+rr]=vn[si];return si}function fi(vn,di){return vn instanceof di||vn!=null&&vn.constructor!=null&&vn.constructor.name!=null&&vn.constructor.name===di.name}function bi(vn){return vn!=vn}const Ai=(function(){const vn="0123456789abcdef",di=new Array(256);for(let rr=0;rr<16;++rr){const on=16*rr;for(let si=0;si<16;++si)di[on+si]=vn[rr]+vn[si]}return di})();function Bi(vn){return typeof BigInt>"u"?qi:vn}function qi(){throw new Error("BigInt not supported")}},8028:(u,a,s)=>{var f=s(2318);u.exports=function(c){return new f().update(c).digest()}},6266:(u,a,s)=>{var f=a;f.version=s(8597).i8,f.utils=s(953),f.rand=s(9931),f.curve=s(8254),f.curves=s(5427),f.ec=s(7954),f.eddsa=s(5980)},4918:(u,a,s)=>{var f=s(3785),c=s(953),d=c.getNAF,p=c.getJSF,h=c.assert;function y(w,S){this.type=w,this.p=new f(S.p,16),this.red=S.prime?f.red(S.prime):f.mont(this.p),this.zero=new f(0).toRed(this.red),this.one=new f(1).toRed(this.red),this.two=new f(2).toRed(this.red),this.n=S.n&&new f(S.n,16),this.g=S.g&&this.pointFromJSON(S.g,S.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var E=this.n&&this.p.div(this.n);!E||E.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function b(w,S){this.curve=w,this.type=S,this.precomputed=null}u.exports=y,y.prototype.point=function(){throw new Error("Not implemented")},y.prototype.validate=function(){throw new Error("Not implemented")},y.prototype._fixedNafMul=function(w,S){h(w.precomputed);var E=w._getDoubles(),B=d(S,1,this._bitLength),ae=(1<<E.step+1)-(E.step%2==0?2:1);ae/=3;var W,J,ve=[];for(W=0;W<B.length;W+=E.step){J=0;for(var Qe=W+E.step-1;Qe>=W;Qe--)J=(J<<1)+B[Qe];ve.push(J)}for(var kt=this.jpoint(null,null,null),nr=this.jpoint(null,null,null),sr=ae;sr>0;sr--){for(W=0;W<ve.length;W++)(J=ve[W])===sr?nr=nr.mixedAdd(E.points[W]):J===-sr&&(nr=nr.mixedAdd(E.points[W].neg()));kt=kt.add(nr)}return kt.toP()},y.prototype._wnafMul=function(w,S){var E=4,B=w._getNAFPoints(E);E=B.wnd;for(var ae=B.points,W=d(S,E,this._bitLength),J=this.jpoint(null,null,null),ve=W.length-1;ve>=0;ve--){for(var Qe=0;ve>=0&&W[ve]===0;ve--)Qe++;if(ve>=0&&Qe++,J=J.dblp(Qe),ve<0)break;var kt=W[ve];h(kt!==0),J=w.type==="affine"?kt>0?J.mixedAdd(ae[kt-1>>1]):J.mixedAdd(ae[-kt-1>>1].neg()):kt>0?J.add(ae[kt-1>>1]):J.add(ae[-kt-1>>1].neg())}return w.type==="affine"?J.toP():J},y.prototype._wnafMulAdd=function(w,S,E,B,ae){var W,J,ve,Qe=this._wnafT1,kt=this._wnafT2,nr=this._wnafT3,sr=0;for(W=0;W<B;W++){var ce=(ve=S[W])._getNAFPoints(w);Qe[W]=ce.wnd,kt[W]=ce.points}for(W=B-1;W>=1;W-=2){var Ze=W-1,se=W;if(Qe[Ze]===1&&Qe[se]===1){var vt=[S[Ze],null,null,S[se]];S[Ze].y.cmp(S[se].y)===0?(vt[1]=S[Ze].add(S[se]),vt[2]=S[Ze].toJ().mixedAdd(S[se].neg())):S[Ze].y.cmp(S[se].y.redNeg())===0?(vt[1]=S[Ze].toJ().mixedAdd(S[se]),vt[2]=S[Ze].add(S[se].neg())):(vt[1]=S[Ze].toJ().mixedAdd(S[se]),vt[2]=S[Ze].toJ().mixedAdd(S[se].neg()));var ur=[-3,-1,-5,-7,0,7,5,1,3],ue=p(E[Ze],E[se]);for(sr=Math.max(ue[0].length,sr),nr[Ze]=new Array(sr),nr[se]=new Array(sr),J=0;J<sr;J++){var bt=0|ue[0][J],L=0|ue[1][J];nr[Ze][J]=ur[3*(bt+1)+(L+1)],nr[se][J]=0,kt[Ze]=vt}}else nr[Ze]=d(E[Ze],Qe[Ze],this._bitLength),nr[se]=d(E[se],Qe[se],this._bitLength),sr=Math.max(nr[Ze].length,sr),sr=Math.max(nr[se].length,sr)}var _=this.jpoint(null,null,null),F=this._wnafT4;for(W=sr;W>=0;W--){for(var k=0;W>=0;){var Ye=!0;for(J=0;J<B;J++)F[J]=0|nr[J][W],F[J]!==0&&(Ye=!1);if(!Ye)break;k++,W--}if(W>=0&&k++,_=_.dblp(k),W<0)break;for(J=0;J<B;J++){var rn=F[J];rn!==0&&(rn>0?ve=kt[J][rn-1>>1]:rn<0&&(ve=kt[J][-rn-1>>1].neg()),_=ve.type==="affine"?_.mixedAdd(ve):_.add(ve))}}for(W=0;W<B;W++)kt[W]=null;return ae?_:_.toP()},y.BasePoint=b,b.prototype.eq=function(){throw new Error("Not implemented")},b.prototype.validate=function(){return this.curve.validate(this)},y.prototype.decodePoint=function(w,S){w=c.toArray(w,S);var E=this.p.byteLength();if((w[0]===4||w[0]===6||w[0]===7)&&w.length-1==2*E)return w[0]===6?h(w[w.length-1]%2==0):w[0]===7&&h(w[w.length-1]%2==1),this.point(w.slice(1,1+E),w.slice(1+E,1+2*E));if((w[0]===2||w[0]===3)&&w.length-1===E)return this.pointFromX(w.slice(1,1+E),w[0]===3);throw new Error("Unknown point format")},b.prototype.encodeCompressed=function(w){return this.encode(w,!0)},b.prototype._encode=function(w){var S=this.curve.p.byteLength(),E=this.getX().toArray("be",S);return w?[this.getY().isEven()?2:3].concat(E):[4].concat(E,this.getY().toArray("be",S))},b.prototype.encode=function(w,S){return c.encode(this._encode(S),w)},b.prototype.precompute=function(w){if(this.precomputed)return this;var S={doubles:null,naf:null,beta:null};return S.naf=this._getNAFPoints(8),S.doubles=this._getDoubles(4,w),S.beta=this._getBeta(),this.precomputed=S,this},b.prototype._hasDoubles=function(w){if(!this.precomputed)return!1;var S=this.precomputed.doubles;return!!S&&S.points.length>=Math.ceil((w.bitLength()+1)/S.step)},b.prototype._getDoubles=function(w,S){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var E=[this],B=this,ae=0;ae<S;ae+=w){for(var W=0;W<w;W++)B=B.dbl();E.push(B)}return{step:w,points:E}},b.prototype._getNAFPoints=function(w){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var S=[this],E=(1<<w)-1,B=E===1?null:this.dbl(),ae=1;ae<E;ae++)S[ae]=S[ae-1].add(B);return{wnd:w,points:S}},b.prototype._getBeta=function(){return null},b.prototype.dblp=function(w){for(var S=this,E=0;E<w;E++)S=S.dbl();return S}},1138:(u,a,s)=>{var f=s(953),c=s(3785),d=s(5717),p=s(4918),h=f.assert;function y(w){this.twisted=(0|w.a)!=1,this.mOneA=this.twisted&&(0|w.a)==-1,this.extended=this.mOneA,p.call(this,"edwards",w),this.a=new c(w.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new c(w.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new c(w.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),h(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(0|w.c)==1}function b(w,S,E,B,ae){p.BasePoint.call(this,w,"projective"),S===null&&E===null&&B===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new c(S,16),this.y=new c(E,16),this.z=B?new c(B,16):this.curve.one,this.t=ae&&new c(ae,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}d(y,p),u.exports=y,y.prototype._mulA=function(w){return this.mOneA?w.redNeg():this.a.redMul(w)},y.prototype._mulC=function(w){return this.oneC?w:this.c.redMul(w)},y.prototype.jpoint=function(w,S,E,B){return this.point(w,S,E,B)},y.prototype.pointFromX=function(w,S){(w=new c(w,16)).red||(w=w.toRed(this.red));var E=w.redSqr(),B=this.c2.redSub(this.a.redMul(E)),ae=this.one.redSub(this.c2.redMul(this.d).redMul(E)),W=B.redMul(ae.redInvm()),J=W.redSqrt();if(J.redSqr().redSub(W).cmp(this.zero)!==0)throw new Error("invalid point");var ve=J.fromRed().isOdd();return(S&&!ve||!S&&ve)&&(J=J.redNeg()),this.point(w,J)},y.prototype.pointFromY=function(w,S){(w=new c(w,16)).red||(w=w.toRed(this.red));var E=w.redSqr(),B=E.redSub(this.c2),ae=E.redMul(this.d).redMul(this.c2).redSub(this.a),W=B.redMul(ae.redInvm());if(W.cmp(this.zero)===0){if(S)throw new Error("invalid point");return this.point(this.zero,w)}var J=W.redSqrt();if(J.redSqr().redSub(W).cmp(this.zero)!==0)throw new Error("invalid point");return J.fromRed().isOdd()!==S&&(J=J.redNeg()),this.point(J,w)},y.prototype.validate=function(w){if(w.isInfinity())return!0;w.normalize();var S=w.x.redSqr(),E=w.y.redSqr(),B=S.redMul(this.a).redAdd(E),ae=this.c2.redMul(this.one.redAdd(this.d.redMul(S).redMul(E)));return B.cmp(ae)===0},d(b,p.BasePoint),y.prototype.pointFromJSON=function(w){return b.fromJSON(this,w)},y.prototype.point=function(w,S,E,B){return new b(this,w,S,E,B)},b.fromJSON=function(w,S){return new b(w,S[0],S[1],S[2])},b.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},b.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},b.prototype._extDbl=function(){var w=this.x.redSqr(),S=this.y.redSqr(),E=this.z.redSqr();E=E.redIAdd(E);var B=this.curve._mulA(w),ae=this.x.redAdd(this.y).redSqr().redISub(w).redISub(S),W=B.redAdd(S),J=W.redSub(E),ve=B.redSub(S),Qe=ae.redMul(J),kt=W.redMul(ve),nr=ae.redMul(ve),sr=J.redMul(W);return this.curve.point(Qe,kt,sr,nr)},b.prototype._projDbl=function(){var w,S,E,B,ae,W,J=this.x.redAdd(this.y).redSqr(),ve=this.x.redSqr(),Qe=this.y.redSqr();if(this.curve.twisted){var kt=(B=this.curve._mulA(ve)).redAdd(Qe);this.zOne?(w=J.redSub(ve).redSub(Qe).redMul(kt.redSub(this.curve.two)),S=kt.redMul(B.redSub(Qe)),E=kt.redSqr().redSub(kt).redSub(kt)):(ae=this.z.redSqr(),W=kt.redSub(ae).redISub(ae),w=J.redSub(ve).redISub(Qe).redMul(W),S=kt.redMul(B.redSub(Qe)),E=kt.redMul(W))}else B=ve.redAdd(Qe),ae=this.curve._mulC(this.z).redSqr(),W=B.redSub(ae).redSub(ae),w=this.curve._mulC(J.redISub(B)).redMul(W),S=this.curve._mulC(B).redMul(ve.redISub(Qe)),E=B.redMul(W);return this.curve.point(w,S,E)},b.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},b.prototype._extAdd=function(w){var S=this.y.redSub(this.x).redMul(w.y.redSub(w.x)),E=this.y.redAdd(this.x).redMul(w.y.redAdd(w.x)),B=this.t.redMul(this.curve.dd).redMul(w.t),ae=this.z.redMul(w.z.redAdd(w.z)),W=E.redSub(S),J=ae.redSub(B),ve=ae.redAdd(B),Qe=E.redAdd(S),kt=W.redMul(J),nr=ve.redMul(Qe),sr=W.redMul(Qe),ce=J.redMul(ve);return this.curve.point(kt,nr,ce,sr)},b.prototype._projAdd=function(w){var S,E,B=this.z.redMul(w.z),ae=B.redSqr(),W=this.x.redMul(w.x),J=this.y.redMul(w.y),ve=this.curve.d.redMul(W).redMul(J),Qe=ae.redSub(ve),kt=ae.redAdd(ve),nr=this.x.redAdd(this.y).redMul(w.x.redAdd(w.y)).redISub(W).redISub(J),sr=B.redMul(Qe).redMul(nr);return this.curve.twisted?(S=B.redMul(kt).redMul(J.redSub(this.curve._mulA(W))),E=Qe.redMul(kt)):(S=B.redMul(kt).redMul(J.redSub(W)),E=this.curve._mulC(Qe).redMul(kt)),this.curve.point(sr,S,E)},b.prototype.add=function(w){return this.isInfinity()?w:w.isInfinity()?this:this.curve.extended?this._extAdd(w):this._projAdd(w)},b.prototype.mul=function(w){return this._hasDoubles(w)?this.curve._fixedNafMul(this,w):this.curve._wnafMul(this,w)},b.prototype.mulAdd=function(w,S,E){return this.curve._wnafMulAdd(1,[this,S],[w,E],2,!1)},b.prototype.jmulAdd=function(w,S,E){return this.curve._wnafMulAdd(1,[this,S],[w,E],2,!0)},b.prototype.normalize=function(){if(this.zOne)return this;var w=this.z.redInvm();return this.x=this.x.redMul(w),this.y=this.y.redMul(w),this.t&&(this.t=this.t.redMul(w)),this.z=this.curve.one,this.zOne=!0,this},b.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},b.prototype.getX=function(){return this.normalize(),this.x.fromRed()},b.prototype.getY=function(){return this.normalize(),this.y.fromRed()},b.prototype.eq=function(w){return this===w||this.getX().cmp(w.getX())===0&&this.getY().cmp(w.getY())===0},b.prototype.eqXToP=function(w){var S=w.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(S)===0)return!0;for(var E=w.clone(),B=this.curve.redN.redMul(this.z);;){if(E.iadd(this.curve.n),E.cmp(this.curve.p)>=0)return!1;if(S.redIAdd(B),this.x.cmp(S)===0)return!0}},b.prototype.toP=b.prototype.normalize,b.prototype.mixedAdd=b.prototype.add},8254:(u,a,s)=>{var f=a;f.base=s(4918),f.short=s(6673),f.mont=s(2881),f.edwards=s(1138)},2881:(u,a,s)=>{var f=s(3785),c=s(5717),d=s(4918),p=s(953);function h(b){d.call(this,"mont",b),this.a=new f(b.a,16).toRed(this.red),this.b=new f(b.b,16).toRed(this.red),this.i4=new f(4).toRed(this.red).redInvm(),this.two=new f(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function y(b,w,S){d.BasePoint.call(this,b,"projective"),w===null&&S===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new f(w,16),this.z=new f(S,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}c(h,d),u.exports=h,h.prototype.validate=function(b){var w=b.normalize().x,S=w.redSqr(),E=S.redMul(w).redAdd(S.redMul(this.a)).redAdd(w);return E.redSqrt().redSqr().cmp(E)===0},c(y,d.BasePoint),h.prototype.decodePoint=function(b,w){return this.point(p.toArray(b,w),1)},h.prototype.point=function(b,w){return new y(this,b,w)},h.prototype.pointFromJSON=function(b){return y.fromJSON(this,b)},y.prototype.precompute=function(){},y.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},y.fromJSON=function(b,w){return new y(b,w[0],w[1]||b.one)},y.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},y.prototype.isInfinity=function(){return this.z.cmpn(0)===0},y.prototype.dbl=function(){var b=this.x.redAdd(this.z).redSqr(),w=this.x.redSub(this.z).redSqr(),S=b.redSub(w),E=b.redMul(w),B=S.redMul(w.redAdd(this.curve.a24.redMul(S)));return this.curve.point(E,B)},y.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},y.prototype.diffAdd=function(b,w){var S=this.x.redAdd(this.z),E=this.x.redSub(this.z),B=b.x.redAdd(b.z),ae=b.x.redSub(b.z).redMul(S),W=B.redMul(E),J=w.z.redMul(ae.redAdd(W).redSqr()),ve=w.x.redMul(ae.redISub(W).redSqr());return this.curve.point(J,ve)},y.prototype.mul=function(b){for(var w=b.clone(),S=this,E=this.curve.point(null,null),B=[];w.cmpn(0)!==0;w.iushrn(1))B.push(w.andln(1));for(var ae=B.length-1;ae>=0;ae--)B[ae]===0?(S=S.diffAdd(E,this),E=E.dbl()):(E=S.diffAdd(E,this),S=S.dbl());return E},y.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},y.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},y.prototype.eq=function(b){return this.getX().cmp(b.getX())===0},y.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},y.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},6673:(u,a,s)=>{var f=s(953),c=s(3785),d=s(5717),p=s(4918),h=f.assert;function y(S){p.call(this,"short",S),this.a=new c(S.a,16).toRed(this.red),this.b=new c(S.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(S),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function b(S,E,B,ae){p.BasePoint.call(this,S,"affine"),E===null&&B===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new c(E,16),this.y=new c(B,16),ae&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function w(S,E,B,ae){p.BasePoint.call(this,S,"jacobian"),E===null&&B===null&&ae===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new c(0)):(this.x=new c(E,16),this.y=new c(B,16),this.z=new c(ae,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}d(y,p),u.exports=y,y.prototype._getEndomorphism=function(S){if(this.zeroA&&this.g&&this.n&&this.p.modn(3)===1){var E,B;if(S.beta)E=new c(S.beta,16).toRed(this.red);else{var ae=this._getEndoRoots(this.p);E=(E=ae[0].cmp(ae[1])<0?ae[0]:ae[1]).toRed(this.red)}if(S.lambda)B=new c(S.lambda,16);else{var W=this._getEndoRoots(this.n);this.g.mul(W[0]).x.cmp(this.g.x.redMul(E))===0?B=W[0]:(B=W[1],h(this.g.mul(B).x.cmp(this.g.x.redMul(E))===0))}return{beta:E,lambda:B,basis:S.basis?S.basis.map((function(J){return{a:new c(J.a,16),b:new c(J.b,16)}})):this._getEndoBasis(B)}}},y.prototype._getEndoRoots=function(S){var E=S===this.p?this.red:c.mont(S),B=new c(2).toRed(E).redInvm(),ae=B.redNeg(),W=new c(3).toRed(E).redNeg().redSqrt().redMul(B);return[ae.redAdd(W).fromRed(),ae.redSub(W).fromRed()]},y.prototype._getEndoBasis=function(S){for(var E,B,ae,W,J,ve,Qe,kt,nr,sr=this.n.ushrn(Math.floor(this.n.bitLength()/2)),ce=S,Ze=this.n.clone(),se=new c(1),vt=new c(0),ur=new c(0),ue=new c(1),bt=0;ce.cmpn(0)!==0;){var L=Ze.div(ce);kt=Ze.sub(L.mul(ce)),nr=ur.sub(L.mul(se));var _=ue.sub(L.mul(vt));if(!ae&&kt.cmp(sr)<0)E=Qe.neg(),B=se,ae=kt.neg(),W=nr;else if(ae&&++bt==2)break;Qe=kt,Ze=ce,ce=kt,ur=se,se=nr,ue=vt,vt=_}J=kt.neg(),ve=nr;var F=ae.sqr().add(W.sqr());return J.sqr().add(ve.sqr()).cmp(F)>=0&&(J=E,ve=B),ae.negative&&(ae=ae.neg(),W=W.neg()),J.negative&&(J=J.neg(),ve=ve.neg()),[{a:ae,b:W},{a:J,b:ve}]},y.prototype._endoSplit=function(S){var E=this.endo.basis,B=E[0],ae=E[1],W=ae.b.mul(S).divRound(this.n),J=B.b.neg().mul(S).divRound(this.n),ve=W.mul(B.a),Qe=J.mul(ae.a),kt=W.mul(B.b),nr=J.mul(ae.b);return{k1:S.sub(ve).sub(Qe),k2:kt.add(nr).neg()}},y.prototype.pointFromX=function(S,E){(S=new c(S,16)).red||(S=S.toRed(this.red));var B=S.redSqr().redMul(S).redIAdd(S.redMul(this.a)).redIAdd(this.b),ae=B.redSqrt();if(ae.redSqr().redSub(B).cmp(this.zero)!==0)throw new Error("invalid point");var W=ae.fromRed().isOdd();return(E&&!W||!E&&W)&&(ae=ae.redNeg()),this.point(S,ae)},y.prototype.validate=function(S){if(S.inf)return!0;var E=S.x,B=S.y,ae=this.a.redMul(E),W=E.redSqr().redMul(E).redIAdd(ae).redIAdd(this.b);return B.redSqr().redISub(W).cmpn(0)===0},y.prototype._endoWnafMulAdd=function(S,E,B){for(var ae=this._endoWnafT1,W=this._endoWnafT2,J=0;J<S.length;J++){var ve=this._endoSplit(E[J]),Qe=S[J],kt=Qe._getBeta();ve.k1.negative&&(ve.k1.ineg(),Qe=Qe.neg(!0)),ve.k2.negative&&(ve.k2.ineg(),kt=kt.neg(!0)),ae[2*J]=Qe,ae[2*J+1]=kt,W[2*J]=ve.k1,W[2*J+1]=ve.k2}for(var nr=this._wnafMulAdd(1,ae,W,2*J,B),sr=0;sr<2*J;sr++)ae[sr]=null,W[sr]=null;return nr},d(b,p.BasePoint),y.prototype.point=function(S,E,B){return new b(this,S,E,B)},y.prototype.pointFromJSON=function(S,E){return b.fromJSON(this,S,E)},b.prototype._getBeta=function(){if(this.curve.endo){var S=this.precomputed;if(S&&S.beta)return S.beta;var E=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(S){var B=this.curve,ae=function(W){return B.point(W.x.redMul(B.endo.beta),W.y)};S.beta=E,E.precomputed={beta:null,naf:S.naf&&{wnd:S.naf.wnd,points:S.naf.points.map(ae)},doubles:S.doubles&&{step:S.doubles.step,points:S.doubles.points.map(ae)}}}return E}},b.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},b.fromJSON=function(S,E,B){typeof E=="string"&&(E=JSON.parse(E));var ae=S.point(E[0],E[1],B);if(!E[2])return ae;function W(ve){return S.point(ve[0],ve[1],B)}var J=E[2];return ae.precomputed={beta:null,doubles:J.doubles&&{step:J.doubles.step,points:[ae].concat(J.doubles.points.map(W))},naf:J.naf&&{wnd:J.naf.wnd,points:[ae].concat(J.naf.points.map(W))}},ae},b.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},b.prototype.isInfinity=function(){return this.inf},b.prototype.add=function(S){if(this.inf)return S;if(S.inf)return this;if(this.eq(S))return this.dbl();if(this.neg().eq(S))return this.curve.point(null,null);if(this.x.cmp(S.x)===0)return this.curve.point(null,null);var E=this.y.redSub(S.y);E.cmpn(0)!==0&&(E=E.redMul(this.x.redSub(S.x).redInvm()));var B=E.redSqr().redISub(this.x).redISub(S.x),ae=E.redMul(this.x.redSub(B)).redISub(this.y);return this.curve.point(B,ae)},b.prototype.dbl=function(){if(this.inf)return this;var S=this.y.redAdd(this.y);if(S.cmpn(0)===0)return this.curve.point(null,null);var E=this.curve.a,B=this.x.redSqr(),ae=S.redInvm(),W=B.redAdd(B).redIAdd(B).redIAdd(E).redMul(ae),J=W.redSqr().redISub(this.x.redAdd(this.x)),ve=W.redMul(this.x.redSub(J)).redISub(this.y);return this.curve.point(J,ve)},b.prototype.getX=function(){return this.x.fromRed()},b.prototype.getY=function(){return this.y.fromRed()},b.prototype.mul=function(S){return S=new c(S,16),this.isInfinity()?this:this._hasDoubles(S)?this.curve._fixedNafMul(this,S):this.curve.endo?this.curve._endoWnafMulAdd([this],[S]):this.curve._wnafMul(this,S)},b.prototype.mulAdd=function(S,E,B){var ae=[this,E],W=[S,B];return this.curve.endo?this.curve._endoWnafMulAdd(ae,W):this.curve._wnafMulAdd(1,ae,W,2)},b.prototype.jmulAdd=function(S,E,B){var ae=[this,E],W=[S,B];return this.curve.endo?this.curve._endoWnafMulAdd(ae,W,!0):this.curve._wnafMulAdd(1,ae,W,2,!0)},b.prototype.eq=function(S){return this===S||this.inf===S.inf&&(this.inf||this.x.cmp(S.x)===0&&this.y.cmp(S.y)===0)},b.prototype.neg=function(S){if(this.inf)return this;var E=this.curve.point(this.x,this.y.redNeg());if(S&&this.precomputed){var B=this.precomputed,ae=function(W){return W.neg()};E.precomputed={naf:B.naf&&{wnd:B.naf.wnd,points:B.naf.points.map(ae)},doubles:B.doubles&&{step:B.doubles.step,points:B.doubles.points.map(ae)}}}return E},b.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},d(w,p.BasePoint),y.prototype.jpoint=function(S,E,B){return new w(this,S,E,B)},w.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var S=this.z.redInvm(),E=S.redSqr(),B=this.x.redMul(E),ae=this.y.redMul(E).redMul(S);return this.curve.point(B,ae)},w.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},w.prototype.add=function(S){if(this.isInfinity())return S;if(S.isInfinity())return this;var E=S.z.redSqr(),B=this.z.redSqr(),ae=this.x.redMul(E),W=S.x.redMul(B),J=this.y.redMul(E.redMul(S.z)),ve=S.y.redMul(B.redMul(this.z)),Qe=ae.redSub(W),kt=J.redSub(ve);if(Qe.cmpn(0)===0)return kt.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var nr=Qe.redSqr(),sr=nr.redMul(Qe),ce=ae.redMul(nr),Ze=kt.redSqr().redIAdd(sr).redISub(ce).redISub(ce),se=kt.redMul(ce.redISub(Ze)).redISub(J.redMul(sr)),vt=this.z.redMul(S.z).redMul(Qe);return this.curve.jpoint(Ze,se,vt)},w.prototype.mixedAdd=function(S){if(this.isInfinity())return S.toJ();if(S.isInfinity())return this;var E=this.z.redSqr(),B=this.x,ae=S.x.redMul(E),W=this.y,J=S.y.redMul(E).redMul(this.z),ve=B.redSub(ae),Qe=W.redSub(J);if(ve.cmpn(0)===0)return Qe.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var kt=ve.redSqr(),nr=kt.redMul(ve),sr=B.redMul(kt),ce=Qe.redSqr().redIAdd(nr).redISub(sr).redISub(sr),Ze=Qe.redMul(sr.redISub(ce)).redISub(W.redMul(nr)),se=this.z.redMul(ve);return this.curve.jpoint(ce,Ze,se)},w.prototype.dblp=function(S){if(S===0)return this;if(this.isInfinity())return this;if(!S)return this.dbl();var E;if(this.curve.zeroA||this.curve.threeA){var B=this;for(E=0;E<S;E++)B=B.dbl();return B}var ae=this.curve.a,W=this.curve.tinv,J=this.x,ve=this.y,Qe=this.z,kt=Qe.redSqr().redSqr(),nr=ve.redAdd(ve);for(E=0;E<S;E++){var sr=J.redSqr(),ce=nr.redSqr(),Ze=ce.redSqr(),se=sr.redAdd(sr).redIAdd(sr).redIAdd(ae.redMul(kt)),vt=J.redMul(ce),ur=se.redSqr().redISub(vt.redAdd(vt)),ue=vt.redISub(ur),bt=se.redMul(ue);bt=bt.redIAdd(bt).redISub(Ze);var L=nr.redMul(Qe);E+1<S&&(kt=kt.redMul(Ze)),J=ur,Qe=L,nr=bt}return this.curve.jpoint(J,nr.redMul(W),Qe)},w.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},w.prototype._zeroDbl=function(){var S,E,B;if(this.zOne){var ae=this.x.redSqr(),W=this.y.redSqr(),J=W.redSqr(),ve=this.x.redAdd(W).redSqr().redISub(ae).redISub(J);ve=ve.redIAdd(ve);var Qe=ae.redAdd(ae).redIAdd(ae),kt=Qe.redSqr().redISub(ve).redISub(ve),nr=J.redIAdd(J);nr=(nr=nr.redIAdd(nr)).redIAdd(nr),S=kt,E=Qe.redMul(ve.redISub(kt)).redISub(nr),B=this.y.redAdd(this.y)}else{var sr=this.x.redSqr(),ce=this.y.redSqr(),Ze=ce.redSqr(),se=this.x.redAdd(ce).redSqr().redISub(sr).redISub(Ze);se=se.redIAdd(se);var vt=sr.redAdd(sr).redIAdd(sr),ur=vt.redSqr(),ue=Ze.redIAdd(Ze);ue=(ue=ue.redIAdd(ue)).redIAdd(ue),S=ur.redISub(se).redISub(se),E=vt.redMul(se.redISub(S)).redISub(ue),B=(B=this.y.redMul(this.z)).redIAdd(B)}return this.curve.jpoint(S,E,B)},w.prototype._threeDbl=function(){var S,E,B;if(this.zOne){var ae=this.x.redSqr(),W=this.y.redSqr(),J=W.redSqr(),ve=this.x.redAdd(W).redSqr().redISub(ae).redISub(J);ve=ve.redIAdd(ve);var Qe=ae.redAdd(ae).redIAdd(ae).redIAdd(this.curve.a),kt=Qe.redSqr().redISub(ve).redISub(ve);S=kt;var nr=J.redIAdd(J);nr=(nr=nr.redIAdd(nr)).redIAdd(nr),E=Qe.redMul(ve.redISub(kt)).redISub(nr),B=this.y.redAdd(this.y)}else{var sr=this.z.redSqr(),ce=this.y.redSqr(),Ze=this.x.redMul(ce),se=this.x.redSub(sr).redMul(this.x.redAdd(sr));se=se.redAdd(se).redIAdd(se);var vt=Ze.redIAdd(Ze),ur=(vt=vt.redIAdd(vt)).redAdd(vt);S=se.redSqr().redISub(ur),B=this.y.redAdd(this.z).redSqr().redISub(ce).redISub(sr);var ue=ce.redSqr();ue=(ue=(ue=ue.redIAdd(ue)).redIAdd(ue)).redIAdd(ue),E=se.redMul(vt.redISub(S)).redISub(ue)}return this.curve.jpoint(S,E,B)},w.prototype._dbl=function(){var S=this.curve.a,E=this.x,B=this.y,ae=this.z,W=ae.redSqr().redSqr(),J=E.redSqr(),ve=B.redSqr(),Qe=J.redAdd(J).redIAdd(J).redIAdd(S.redMul(W)),kt=E.redAdd(E),nr=(kt=kt.redIAdd(kt)).redMul(ve),sr=Qe.redSqr().redISub(nr.redAdd(nr)),ce=nr.redISub(sr),Ze=ve.redSqr();Ze=(Ze=(Ze=Ze.redIAdd(Ze)).redIAdd(Ze)).redIAdd(Ze);var se=Qe.redMul(ce).redISub(Ze),vt=B.redAdd(B).redMul(ae);return this.curve.jpoint(sr,se,vt)},w.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var S=this.x.redSqr(),E=this.y.redSqr(),B=this.z.redSqr(),ae=E.redSqr(),W=S.redAdd(S).redIAdd(S),J=W.redSqr(),ve=this.x.redAdd(E).redSqr().redISub(S).redISub(ae),Qe=(ve=(ve=(ve=ve.redIAdd(ve)).redAdd(ve).redIAdd(ve)).redISub(J)).redSqr(),kt=ae.redIAdd(ae);kt=(kt=(kt=kt.redIAdd(kt)).redIAdd(kt)).redIAdd(kt);var nr=W.redIAdd(ve).redSqr().redISub(J).redISub(Qe).redISub(kt),sr=E.redMul(nr);sr=(sr=sr.redIAdd(sr)).redIAdd(sr);var ce=this.x.redMul(Qe).redISub(sr);ce=(ce=ce.redIAdd(ce)).redIAdd(ce);var Ze=this.y.redMul(nr.redMul(kt.redISub(nr)).redISub(ve.redMul(Qe)));Ze=(Ze=(Ze=Ze.redIAdd(Ze)).redIAdd(Ze)).redIAdd(Ze);var se=this.z.redAdd(ve).redSqr().redISub(B).redISub(Qe);return this.curve.jpoint(ce,Ze,se)},w.prototype.mul=function(S,E){return S=new c(S,E),this.curve._wnafMul(this,S)},w.prototype.eq=function(S){if(S.type==="affine")return this.eq(S.toJ());if(this===S)return!0;var E=this.z.redSqr(),B=S.z.redSqr();if(this.x.redMul(B).redISub(S.x.redMul(E)).cmpn(0)!==0)return!1;var ae=E.redMul(this.z),W=B.redMul(S.z);return this.y.redMul(W).redISub(S.y.redMul(ae)).cmpn(0)===0},w.prototype.eqXToP=function(S){var E=this.z.redSqr(),B=S.toRed(this.curve.red).redMul(E);if(this.x.cmp(B)===0)return!0;for(var ae=S.clone(),W=this.curve.redN.redMul(E);;){if(ae.iadd(this.curve.n),ae.cmp(this.curve.p)>=0)return!1;if(B.redIAdd(W),this.x.cmp(B)===0)return!0}},w.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},w.prototype.isInfinity=function(){return this.z.cmpn(0)===0}},5427:(u,a,s)=>{var f,c=a,d=s(3715),p=s(8254),h=s(953).assert;function y(w){w.type==="short"?this.curve=new p.short(w):w.type==="edwards"?this.curve=new p.edwards(w):this.curve=new p.mont(w),this.g=this.curve.g,this.n=this.curve.n,this.hash=w.hash,h(this.g.validate(),"Invalid curve"),h(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function b(w,S){Object.defineProperty(c,w,{configurable:!0,enumerable:!0,get:function(){var E=new y(S);return Object.defineProperty(c,w,{configurable:!0,enumerable:!0,value:E}),E}})}c.PresetCurve=y,b("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:d.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),b("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:d.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),b("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:d.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),b("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:d.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),b("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:d.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),b("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:d.sha256,gRed:!1,g:["9"]}),b("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:d.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{f=s(1037)}catch{f=void 0}b("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:d.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})},7954:(u,a,s)=>{var f=s(3785),c=s(2156),d=s(953),p=s(5427),h=s(9931),y=d.assert,b=s(1251),w=s(611);function S(E){if(!(this instanceof S))return new S(E);typeof E=="string"&&(y(Object.prototype.hasOwnProperty.call(p,E),"Unknown curve "+E),E=p[E]),E instanceof p.PresetCurve&&(E={curve:E}),this.curve=E.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=E.curve.g,this.g.precompute(E.curve.n.bitLength()+1),this.hash=E.hash||E.curve.hash}u.exports=S,S.prototype.keyPair=function(E){return new b(this,E)},S.prototype.keyFromPrivate=function(E,B){return b.fromPrivate(this,E,B)},S.prototype.keyFromPublic=function(E,B){return b.fromPublic(this,E,B)},S.prototype.genKeyPair=function(E){E||(E={});for(var B=new c({hash:this.hash,pers:E.pers,persEnc:E.persEnc||"utf8",entropy:E.entropy||h(this.hash.hmacStrength),entropyEnc:E.entropy&&E.entropyEnc||"utf8",nonce:this.n.toArray()}),ae=this.n.byteLength(),W=this.n.sub(new f(2));;){var J=new f(B.generate(ae));if(!(J.cmp(W)>0))return J.iaddn(1),this.keyFromPrivate(J)}},S.prototype._truncateToN=function(E,B){var ae=8*E.byteLength()-this.n.bitLength();return ae>0&&(E=E.ushrn(ae)),!B&&E.cmp(this.n)>=0?E.sub(this.n):E},S.prototype.sign=function(E,B,ae,W){typeof ae=="object"&&(W=ae,ae=null),W||(W={}),B=this.keyFromPrivate(B,ae),E=this._truncateToN(new f(E,16));for(var J=this.n.byteLength(),ve=B.getPrivate().toArray("be",J),Qe=E.toArray("be",J),kt=new c({hash:this.hash,entropy:ve,nonce:Qe,pers:W.pers,persEnc:W.persEnc||"utf8"}),nr=this.n.sub(new f(1)),sr=0;;sr++){var ce=W.k?W.k(sr):new f(kt.generate(this.n.byteLength()));if(!((ce=this._truncateToN(ce,!0)).cmpn(1)<=0||ce.cmp(nr)>=0)){var Ze=this.g.mul(ce);if(!Ze.isInfinity()){var se=Ze.getX(),vt=se.umod(this.n);if(vt.cmpn(0)!==0){var ur=ce.invm(this.n).mul(vt.mul(B.getPrivate()).iadd(E));if((ur=ur.umod(this.n)).cmpn(0)!==0){var ue=(Ze.getY().isOdd()?1:0)|(se.cmp(vt)!==0?2:0);return W.canonical&&ur.cmp(this.nh)>0&&(ur=this.n.sub(ur),ue^=1),new w({r:vt,s:ur,recoveryParam:ue})}}}}}},S.prototype.verify=function(E,B,ae,W){E=this._truncateToN(new f(E,16)),ae=this.keyFromPublic(ae,W);var J=(B=new w(B,"hex")).r,ve=B.s;if(J.cmpn(1)<0||J.cmp(this.n)>=0||ve.cmpn(1)<0||ve.cmp(this.n)>=0)return!1;var Qe,kt=ve.invm(this.n),nr=kt.mul(E).umod(this.n),sr=kt.mul(J).umod(this.n);return this.curve._maxwellTrick?!(Qe=this.g.jmulAdd(nr,ae.getPublic(),sr)).isInfinity()&&Qe.eqXToP(J):!(Qe=this.g.mulAdd(nr,ae.getPublic(),sr)).isInfinity()&&Qe.getX().umod(this.n).cmp(J)===0},S.prototype.recoverPubKey=function(E,B,ae,W){y((3&ae)===ae,"The recovery param is more than two bits"),B=new w(B,W);var J=this.n,ve=new f(E),Qe=B.r,kt=B.s,nr=1&ae,sr=ae>>1;if(Qe.cmp(this.curve.p.umod(this.curve.n))>=0&&sr)throw new Error("Unable to find sencond key candinate");Qe=sr?this.curve.pointFromX(Qe.add(this.curve.n),nr):this.curve.pointFromX(Qe,nr);var ce=B.r.invm(J),Ze=J.sub(ve).mul(ce).umod(J),se=kt.mul(ce).umod(J);return this.g.mulAdd(Ze,Qe,se)},S.prototype.getKeyRecoveryParam=function(E,B,ae,W){if((B=new w(B,W)).recoveryParam!==null)return B.recoveryParam;for(var J=0;J<4;J++){var ve;try{ve=this.recoverPubKey(E,B,J)}catch{continue}if(ve.eq(ae))return J}throw new Error("Unable to find valid recovery factor")}},1251:(u,a,s)=>{var f=s(3785),c=s(953).assert;function d(p,h){this.ec=p,this.priv=null,this.pub=null,h.priv&&this._importPrivate(h.priv,h.privEnc),h.pub&&this._importPublic(h.pub,h.pubEnc)}u.exports=d,d.fromPublic=function(p,h,y){return h instanceof d?h:new d(p,{pub:h,pubEnc:y})},d.fromPrivate=function(p,h,y){return h instanceof d?h:new d(p,{priv:h,privEnc:y})},d.prototype.validate=function(){var p=this.getPublic();return p.isInfinity()?{result:!1,reason:"Invalid public key"}:p.validate()?p.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},d.prototype.getPublic=function(p,h){return typeof p=="string"&&(h=p,p=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),h?this.pub.encode(h,p):this.pub},d.prototype.getPrivate=function(p){return p==="hex"?this.priv.toString(16,2):this.priv},d.prototype._importPrivate=function(p,h){this.priv=new f(p,h||16),this.priv=this.priv.umod(this.ec.curve.n)},d.prototype._importPublic=function(p,h){if(p.x||p.y)return this.ec.curve.type==="mont"?c(p.x,"Need x coordinate"):this.ec.curve.type!=="short"&&this.ec.curve.type!=="edwards"||c(p.x&&p.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(p.x,p.y));this.pub=this.ec.curve.decodePoint(p,h)},d.prototype.derive=function(p){return p.validate()||c(p.validate(),"public point not validated"),p.mul(this.priv).getX()},d.prototype.sign=function(p,h,y){return this.ec.sign(p,this,h,y)},d.prototype.verify=function(p,h){return this.ec.verify(p,h,this)},d.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},611:(u,a,s)=>{var f=s(3785),c=s(953),d=c.assert;function p(S,E){if(S instanceof p)return S;this._importDER(S,E)||(d(S.r&&S.s,"Signature without r or s"),this.r=new f(S.r,16),this.s=new f(S.s,16),S.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=S.recoveryParam)}function h(){this.place=0}function y(S,E){var B=S[E.place++];if(!(128&B))return B;var ae=15&B;if(ae===0||ae>4)return!1;for(var W=0,J=0,ve=E.place;J<ae;J++,ve++)W<<=8,W|=S[ve],W>>>=0;return!(W<=127)&&(E.place=ve,W)}function b(S){for(var E=0,B=S.length-1;!S[E]&&!(128&S[E+1])&&E<B;)E++;return E===0?S:S.slice(E)}function w(S,E){if(E<128)S.push(E);else{var B=1+(Math.log(E)/Math.LN2>>>3);for(S.push(128|B);--B;)S.push(E>>>(B<<3)&255);S.push(E)}}u.exports=p,p.prototype._importDER=function(S,E){S=c.toArray(S,E);var B=new h;if(S[B.place++]!==48)return!1;var ae=y(S,B);if(ae===!1||ae+B.place!==S.length||S[B.place++]!==2)return!1;var W=y(S,B);if(W===!1)return!1;var J=S.slice(B.place,W+B.place);if(B.place+=W,S[B.place++]!==2)return!1;var ve=y(S,B);if(ve===!1||S.length!==ve+B.place)return!1;var Qe=S.slice(B.place,ve+B.place);if(J[0]===0){if(!(128&J[1]))return!1;J=J.slice(1)}if(Qe[0]===0){if(!(128&Qe[1]))return!1;Qe=Qe.slice(1)}return this.r=new f(J),this.s=new f(Qe),this.recoveryParam=null,!0},p.prototype.toDER=function(S){var E=this.r.toArray(),B=this.s.toArray();for(128&E[0]&&(E=[0].concat(E)),128&B[0]&&(B=[0].concat(B)),E=b(E),B=b(B);!(B[0]||128&B[1]);)B=B.slice(1);var ae=[2];w(ae,E.length),(ae=ae.concat(E)).push(2),w(ae,B.length);var W=ae.concat(B),J=[48];return w(J,W.length),J=J.concat(W),c.encode(J,S)}},5980:(u,a,s)=>{var f=s(3715),c=s(5427),d=s(953),p=d.assert,h=d.parseBytes,y=s(9087),b=s(3622);function w(S){if(p(S==="ed25519","only tested with ed25519 so far"),!(this instanceof w))return new w(S);S=c[S].curve,this.curve=S,this.g=S.g,this.g.precompute(S.n.bitLength()+1),this.pointClass=S.point().constructor,this.encodingLength=Math.ceil(S.n.bitLength()/8),this.hash=f.sha512}u.exports=w,w.prototype.sign=function(S,E){S=h(S);var B=this.keyFromSecret(E),ae=this.hashInt(B.messagePrefix(),S),W=this.g.mul(ae),J=this.encodePoint(W),ve=this.hashInt(J,B.pubBytes(),S).mul(B.priv()),Qe=ae.add(ve).umod(this.curve.n);return this.makeSignature({R:W,S:Qe,Rencoded:J})},w.prototype.verify=function(S,E,B){S=h(S),E=this.makeSignature(E);var ae=this.keyFromPublic(B),W=this.hashInt(E.Rencoded(),ae.pubBytes(),S),J=this.g.mul(E.S());return E.R().add(ae.pub().mul(W)).eq(J)},w.prototype.hashInt=function(){for(var S=this.hash(),E=0;E<arguments.length;E++)S.update(arguments[E]);return d.intFromLE(S.digest()).umod(this.curve.n)},w.prototype.keyFromPublic=function(S){return y.fromPublic(this,S)},w.prototype.keyFromSecret=function(S){return y.fromSecret(this,S)},w.prototype.makeSignature=function(S){return S instanceof b?S:new b(this,S)},w.prototype.encodePoint=function(S){var E=S.getY().toArray("le",this.encodingLength);return E[this.encodingLength-1]|=S.getX().isOdd()?128:0,E},w.prototype.decodePoint=function(S){var E=(S=d.parseBytes(S)).length-1,B=S.slice(0,E).concat(-129&S[E]),ae=(128&S[E])!=0,W=d.intFromLE(B);return this.curve.pointFromY(W,ae)},w.prototype.encodeInt=function(S){return S.toArray("le",this.encodingLength)},w.prototype.decodeInt=function(S){return d.intFromLE(S)},w.prototype.isPoint=function(S){return S instanceof this.pointClass}},9087:(u,a,s)=>{var f=s(953),c=f.assert,d=f.parseBytes,p=f.cachedProperty;function h(y,b){this.eddsa=y,this._secret=d(b.secret),y.isPoint(b.pub)?this._pub=b.pub:this._pubBytes=d(b.pub)}h.fromPublic=function(y,b){return b instanceof h?b:new h(y,{pub:b})},h.fromSecret=function(y,b){return b instanceof h?b:new h(y,{secret:b})},h.prototype.secret=function(){return this._secret},p(h,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),p(h,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),p(h,"privBytes",(function(){var y=this.eddsa,b=this.hash(),w=y.encodingLength-1,S=b.slice(0,y.encodingLength);return S[0]&=248,S[w]&=127,S[w]|=64,S})),p(h,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),p(h,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),p(h,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),h.prototype.sign=function(y){return c(this._secret,"KeyPair can only verify"),this.eddsa.sign(y,this)},h.prototype.verify=function(y,b){return this.eddsa.verify(y,b,this)},h.prototype.getSecret=function(y){return c(this._secret,"KeyPair is public only"),f.encode(this.secret(),y)},h.prototype.getPublic=function(y){return f.encode(this.pubBytes(),y)},u.exports=h},3622:(u,a,s)=>{var f=s(3785),c=s(953),d=c.assert,p=c.cachedProperty,h=c.parseBytes;function y(b,w){this.eddsa=b,typeof w!="object"&&(w=h(w)),Array.isArray(w)&&(w={R:w.slice(0,b.encodingLength),S:w.slice(b.encodingLength)}),d(w.R&&w.S,"Signature without R or S"),b.isPoint(w.R)&&(this._R=w.R),w.S instanceof f&&(this._S=w.S),this._Rencoded=Array.isArray(w.R)?w.R:w.Rencoded,this._Sencoded=Array.isArray(w.S)?w.S:w.Sencoded}p(y,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),p(y,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),p(y,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),p(y,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),y.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},y.prototype.toHex=function(){return c.encode(this.toBytes(),"hex").toUpperCase()},u.exports=y},1037:u=>{u.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},953:(u,a,s)=>{var f=a,c=s(3785),d=s(9746),p=s(4504);f.assert=d,f.toArray=p.toArray,f.zero2=p.zero2,f.toHex=p.toHex,f.encode=p.encode,f.getNAF=function(h,y,b){var w=new Array(Math.max(h.bitLength(),b)+1);w.fill(0);for(var S=1<<y+1,E=h.clone(),B=0;B<w.length;B++){var ae,W=E.andln(S-1);E.isOdd()?(ae=W>(S>>1)-1?(S>>1)-W:W,E.isubn(ae)):ae=0,w[B]=ae,E.iushrn(1)}return w},f.getJSF=function(h,y){var b=[[],[]];h=h.clone(),y=y.clone();for(var w,S=0,E=0;h.cmpn(-S)>0||y.cmpn(-E)>0;){var B,ae,W=h.andln(3)+S&3,J=y.andln(3)+E&3;W===3&&(W=-1),J===3&&(J=-1),B=(1&W)==0?0:(w=h.andln(7)+S&7)!=3&&w!==5||J!==2?W:-W,b[0].push(B),ae=(1&J)==0?0:(w=y.andln(7)+E&7)!=3&&w!==5||W!==2?J:-J,b[1].push(ae),2*S===B+1&&(S=1-S),2*E===ae+1&&(E=1-E),h.iushrn(1),y.iushrn(1)}return b},f.cachedProperty=function(h,y,b){var w="_"+y;h.prototype[y]=function(){return this[w]!==void 0?this[w]:this[w]=b.call(this)}},f.parseBytes=function(h){return typeof h=="string"?f.toArray(h,"hex"):h},f.intFromLE=function(h){return new c(h,"hex","le")}},3785:function(u,a,s){(function(f,c){function d(ue,bt){if(!ue)throw new Error(bt||"Assertion failed")}function p(ue,bt){ue.super_=bt;var L=function(){};L.prototype=bt.prototype,ue.prototype=new L,ue.prototype.constructor=ue}function h(ue,bt,L){if(h.isBN(ue))return ue;this.negative=0,this.words=null,this.length=0,this.red=null,ue!==null&&(bt!=="le"&&bt!=="be"||(L=bt,bt=10),this._init(ue||0,bt||10,L||"be"))}var y;typeof f=="object"?f.exports=h:c.BN=h,h.BN=h,h.wordSize=26;try{y=typeof window<"u"&&window.Buffer!==void 0?window.Buffer:s(5568).Buffer}catch{}function b(ue,bt){var L=ue.charCodeAt(bt);return L>=65&&L<=70?L-55:L>=97&&L<=102?L-87:L-48&15}function w(ue,bt,L){var _=b(ue,L);return L-1>=bt&&(_|=b(ue,L-1)<<4),_}function S(ue,bt,L,_){for(var F=0,k=Math.min(ue.length,L),Ye=bt;Ye<k;Ye++){var rn=ue.charCodeAt(Ye)-48;F*=_,F+=rn>=49?rn-49+10:rn>=17?rn-17+10:rn}return F}h.isBN=function(ue){return ue instanceof h||ue!==null&&typeof ue=="object"&&ue.constructor.wordSize===h.wordSize&&Array.isArray(ue.words)},h.max=function(ue,bt){return ue.cmp(bt)>0?ue:bt},h.min=function(ue,bt){return ue.cmp(bt)<0?ue:bt},h.prototype._init=function(ue,bt,L){if(typeof ue=="number")return this._initNumber(ue,bt,L);if(typeof ue=="object")return this._initArray(ue,bt,L);bt==="hex"&&(bt=16),d(bt===(0|bt)&&bt>=2&&bt<=36);var _=0;(ue=ue.toString().replace(/\s+/g,""))[0]==="-"&&(_++,this.negative=1),_<ue.length&&(bt===16?this._parseHex(ue,_,L):(this._parseBase(ue,bt,_),L==="le"&&this._initArray(this.toArray(),bt,L)))},h.prototype._initNumber=function(ue,bt,L){ue<0&&(this.negative=1,ue=-ue),ue<67108864?(this.words=[67108863&ue],this.length=1):ue<4503599627370496?(this.words=[67108863&ue,ue/67108864&67108863],this.length=2):(d(ue<9007199254740992),this.words=[67108863&ue,ue/67108864&67108863,1],this.length=3),L==="le"&&this._initArray(this.toArray(),bt,L)},h.prototype._initArray=function(ue,bt,L){if(d(typeof ue.length=="number"),ue.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(ue.length/3),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var F,k,Ye=0;if(L==="be")for(_=ue.length-1,F=0;_>=0;_-=3)k=ue[_]|ue[_-1]<<8|ue[_-2]<<16,this.words[F]|=k<<Ye&67108863,this.words[F+1]=k>>>26-Ye&67108863,(Ye+=24)>=26&&(Ye-=26,F++);else if(L==="le")for(_=0,F=0;_<ue.length;_+=3)k=ue[_]|ue[_+1]<<8|ue[_+2]<<16,this.words[F]|=k<<Ye&67108863,this.words[F+1]=k>>>26-Ye&67108863,(Ye+=24)>=26&&(Ye-=26,F++);return this.strip()},h.prototype._parseHex=function(ue,bt,L){this.length=Math.ceil((ue.length-bt)/6),this.words=new Array(this.length);for(var _=0;_<this.length;_++)this.words[_]=0;var F,k=0,Ye=0;if(L==="be")for(_=ue.length-1;_>=bt;_-=2)F=w(ue,bt,_)<<k,this.words[Ye]|=67108863&F,k>=18?(k-=18,Ye+=1,this.words[Ye]|=F>>>26):k+=8;else for(_=(ue.length-bt)%2==0?bt+1:bt;_<ue.length;_+=2)F=w(ue,bt,_)<<k,this.words[Ye]|=67108863&F,k>=18?(k-=18,Ye+=1,this.words[Ye]|=F>>>26):k+=8;this.strip()},h.prototype._parseBase=function(ue,bt,L){this.words=[0],this.length=1;for(var _=0,F=1;F<=67108863;F*=bt)_++;_--,F=F/bt|0;for(var k=ue.length-L,Ye=k%_,rn=Math.min(k,k-Ye)+L,ii=0,ai=L;ai<rn;ai+=_)ii=S(ue,ai,ai+_,bt),this.imuln(F),this.words[0]+ii<67108864?this.words[0]+=ii:this._iaddn(ii);if(Ye!==0){var ni=1;for(ii=S(ue,ai,ue.length,bt),ai=0;ai<Ye;ai++)ni*=bt;this.imuln(ni),this.words[0]+ii<67108864?this.words[0]+=ii:this._iaddn(ii)}this.strip()},h.prototype.copy=function(ue){ue.words=new Array(this.length);for(var bt=0;bt<this.length;bt++)ue.words[bt]=this.words[bt];ue.length=this.length,ue.negative=this.negative,ue.red=this.red},h.prototype.clone=function(){var ue=new h(null);return this.copy(ue),ue},h.prototype._expand=function(ue){for(;this.length<ue;)this.words[this.length++]=0;return this},h.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},h.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},h.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var E=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],B=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],ae=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function W(ue,bt,L){L.negative=bt.negative^ue.negative;var _=ue.length+bt.length|0;L.length=_,_=_-1|0;var F=0|ue.words[0],k=0|bt.words[0],Ye=F*k,rn=67108863&Ye,ii=Ye/67108864|0;L.words[0]=rn;for(var ai=1;ai<_;ai++){for(var ni=ii>>>26,ri=67108863&ii,ui=Math.min(ai,bt.length-1),lr=Math.max(0,ai-ue.length+1);lr<=ui;lr++){var ar=ai-lr|0;ni+=(Ye=(F=0|ue.words[ar])*(k=0|bt.words[lr])+ri)/67108864|0,ri=67108863&Ye}L.words[ai]=0|ri,ii=0|ni}return ii!==0?L.words[ai]=0|ii:L.length--,L.strip()}h.prototype.toString=function(ue,bt){var L;if(bt=0|bt||1,(ue=ue||10)===16||ue==="hex"){L="";for(var _=0,F=0,k=0;k<this.length;k++){var Ye=this.words[k],rn=(16777215&(Ye<<_|F)).toString(16);L=(F=Ye>>>24-_&16777215)!=0||k!==this.length-1?E[6-rn.length]+rn+L:rn+L,(_+=2)>=26&&(_-=26,k--)}for(F!==0&&(L=F.toString(16)+L);L.length%bt!=0;)L="0"+L;return this.negative!==0&&(L="-"+L),L}if(ue===(0|ue)&&ue>=2&&ue<=36){var ii=B[ue],ai=ae[ue];L="";var ni=this.clone();for(ni.negative=0;!ni.isZero();){var ri=ni.modn(ai).toString(ue);L=(ni=ni.idivn(ai)).isZero()?ri+L:E[ii-ri.length]+ri+L}for(this.isZero()&&(L="0"+L);L.length%bt!=0;)L="0"+L;return this.negative!==0&&(L="-"+L),L}d(!1,"Base should be between 2 and 36")},h.prototype.toNumber=function(){var ue=this.words[0];return this.length===2?ue+=67108864*this.words[1]:this.length===3&&this.words[2]===1?ue+=4503599627370496+67108864*this.words[1]:this.length>2&&d(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-ue:ue},h.prototype.toJSON=function(){return this.toString(16)},h.prototype.toBuffer=function(ue,bt){return d(y!==void 0),this.toArrayLike(y,ue,bt)},h.prototype.toArray=function(ue,bt){return this.toArrayLike(Array,ue,bt)},h.prototype.toArrayLike=function(ue,bt,L){var _=this.byteLength(),F=L||Math.max(1,_);d(_<=F,"byte array longer than desired length"),d(F>0,"Requested array length <= 0"),this.strip();var k,Ye,rn=bt==="le",ii=new ue(F),ai=this.clone();if(rn){for(Ye=0;!ai.isZero();Ye++)k=ai.andln(255),ai.iushrn(8),ii[Ye]=k;for(;Ye<F;Ye++)ii[Ye]=0}else{for(Ye=0;Ye<F-_;Ye++)ii[Ye]=0;for(Ye=0;!ai.isZero();Ye++)k=ai.andln(255),ai.iushrn(8),ii[F-Ye-1]=k}return ii},Math.clz32?h.prototype._countBits=function(ue){return 32-Math.clz32(ue)}:h.prototype._countBits=function(ue){var bt=ue,L=0;return bt>=4096&&(L+=13,bt>>>=13),bt>=64&&(L+=7,bt>>>=7),bt>=8&&(L+=4,bt>>>=4),bt>=2&&(L+=2,bt>>>=2),L+bt},h.prototype._zeroBits=function(ue){if(ue===0)return 26;var bt=ue,L=0;return(8191&bt)==0&&(L+=13,bt>>>=13),(127&bt)==0&&(L+=7,bt>>>=7),(15&bt)==0&&(L+=4,bt>>>=4),(3&bt)==0&&(L+=2,bt>>>=2),(1&bt)==0&&L++,L},h.prototype.bitLength=function(){var ue=this.words[this.length-1],bt=this._countBits(ue);return 26*(this.length-1)+bt},h.prototype.zeroBits=function(){if(this.isZero())return 0;for(var ue=0,bt=0;bt<this.length;bt++){var L=this._zeroBits(this.words[bt]);if(ue+=L,L!==26)break}return ue},h.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},h.prototype.toTwos=function(ue){return this.negative!==0?this.abs().inotn(ue).iaddn(1):this.clone()},h.prototype.fromTwos=function(ue){return this.testn(ue-1)?this.notn(ue).iaddn(1).ineg():this.clone()},h.prototype.isNeg=function(){return this.negative!==0},h.prototype.neg=function(){return this.clone().ineg()},h.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},h.prototype.iuor=function(ue){for(;this.length<ue.length;)this.words[this.length++]=0;for(var bt=0;bt<ue.length;bt++)this.words[bt]=this.words[bt]|ue.words[bt];return this.strip()},h.prototype.ior=function(ue){return d((this.negative|ue.negative)==0),this.iuor(ue)},h.prototype.or=function(ue){return this.length>ue.length?this.clone().ior(ue):ue.clone().ior(this)},h.prototype.uor=function(ue){return this.length>ue.length?this.clone().iuor(ue):ue.clone().iuor(this)},h.prototype.iuand=function(ue){var bt;bt=this.length>ue.length?ue:this;for(var L=0;L<bt.length;L++)this.words[L]=this.words[L]&ue.words[L];return this.length=bt.length,this.strip()},h.prototype.iand=function(ue){return d((this.negative|ue.negative)==0),this.iuand(ue)},h.prototype.and=function(ue){return this.length>ue.length?this.clone().iand(ue):ue.clone().iand(this)},h.prototype.uand=function(ue){return this.length>ue.length?this.clone().iuand(ue):ue.clone().iuand(this)},h.prototype.iuxor=function(ue){var bt,L;this.length>ue.length?(bt=this,L=ue):(bt=ue,L=this);for(var _=0;_<L.length;_++)this.words[_]=bt.words[_]^L.words[_];if(this!==bt)for(;_<bt.length;_++)this.words[_]=bt.words[_];return this.length=bt.length,this.strip()},h.prototype.ixor=function(ue){return d((this.negative|ue.negative)==0),this.iuxor(ue)},h.prototype.xor=function(ue){return this.length>ue.length?this.clone().ixor(ue):ue.clone().ixor(this)},h.prototype.uxor=function(ue){return this.length>ue.length?this.clone().iuxor(ue):ue.clone().iuxor(this)},h.prototype.inotn=function(ue){d(typeof ue=="number"&&ue>=0);var bt=0|Math.ceil(ue/26),L=ue%26;this._expand(bt),L>0&&bt--;for(var _=0;_<bt;_++)this.words[_]=67108863&~this.words[_];return L>0&&(this.words[_]=~this.words[_]&67108863>>26-L),this.strip()},h.prototype.notn=function(ue){return this.clone().inotn(ue)},h.prototype.setn=function(ue,bt){d(typeof ue=="number"&&ue>=0);var L=ue/26|0,_=ue%26;return this._expand(L+1),this.words[L]=bt?this.words[L]|1<<_:this.words[L]&~(1<<_),this.strip()},h.prototype.iadd=function(ue){var bt,L,_;if(this.negative!==0&&ue.negative===0)return this.negative=0,bt=this.isub(ue),this.negative^=1,this._normSign();if(this.negative===0&&ue.negative!==0)return ue.negative=0,bt=this.isub(ue),ue.negative=1,bt._normSign();this.length>ue.length?(L=this,_=ue):(L=ue,_=this);for(var F=0,k=0;k<_.length;k++)bt=(0|L.words[k])+(0|_.words[k])+F,this.words[k]=67108863&bt,F=bt>>>26;for(;F!==0&&k<L.length;k++)bt=(0|L.words[k])+F,this.words[k]=67108863&bt,F=bt>>>26;if(this.length=L.length,F!==0)this.words[this.length]=F,this.length++;else if(L!==this)for(;k<L.length;k++)this.words[k]=L.words[k];return this},h.prototype.add=function(ue){var bt;return ue.negative!==0&&this.negative===0?(ue.negative=0,bt=this.sub(ue),ue.negative^=1,bt):ue.negative===0&&this.negative!==0?(this.negative=0,bt=ue.sub(this),this.negative=1,bt):this.length>ue.length?this.clone().iadd(ue):ue.clone().iadd(this)},h.prototype.isub=function(ue){if(ue.negative!==0){ue.negative=0;var bt=this.iadd(ue);return ue.negative=1,bt._normSign()}if(this.negative!==0)return this.negative=0,this.iadd(ue),this.negative=1,this._normSign();var L,_,F=this.cmp(ue);if(F===0)return this.negative=0,this.length=1,this.words[0]=0,this;F>0?(L=this,_=ue):(L=ue,_=this);for(var k=0,Ye=0;Ye<_.length;Ye++)k=(bt=(0|L.words[Ye])-(0|_.words[Ye])+k)>>26,this.words[Ye]=67108863&bt;for(;k!==0&&Ye<L.length;Ye++)k=(bt=(0|L.words[Ye])+k)>>26,this.words[Ye]=67108863&bt;if(k===0&&Ye<L.length&&L!==this)for(;Ye<L.length;Ye++)this.words[Ye]=L.words[Ye];return this.length=Math.max(this.length,Ye),L!==this&&(this.negative=1),this.strip()},h.prototype.sub=function(ue){return this.clone().isub(ue)};var J=function(ue,bt,L){var _,F,k,Ye=ue.words,rn=bt.words,ii=L.words,ai=0,ni=0|Ye[0],ri=8191&ni,ui=ni>>>13,lr=0|Ye[1],ar=8191&lr,jr=lr>>>13,ci=0|Ye[2],mi=8191&ci,pi=ci>>>13,ei=0|Ye[3],Gr=8191&ei,ti=ei>>>13,fi=0|Ye[4],bi=8191&fi,Ai=fi>>>13,Bi=0|Ye[5],qi=8191&Bi,vn=Bi>>>13,di=0|Ye[6],rr=8191&di,on=di>>>13,si=0|Ye[7],vi=8191&si,Ei=si>>>13,Mi=0|Ye[8],Di=8191&Mi,Ii=Mi>>>13,Ci=0|Ye[9],Vi=8191&Ci,Hi=Ci>>>13,Ji=0|rn[0],no=8191&Ji,co=Ji>>>13,Fo=0|rn[1],Io=8191&Fo,Ro=Fo>>>13,Oo=0|rn[2],To=8191&Oo,Po=Oo>>>13,ia=0|rn[3],Jo=8191&ia,ea=ia>>>13,zi=0|rn[4],Gi=8191&zi,uo=zi>>>13,wo=0|rn[5],xi=8191&wo,Fi=wo>>>13,Ui=0|rn[6],gi=8191&Ui,Li=Ui>>>13,Qi=0|rn[7],Wi=8191&Qi,io=Qi>>>13,lo=0|rn[8],Ao=8191&lo,_o=lo>>>13,ca=0|rn[9],Co=8191&ca,$o=ca>>>13;L.negative=ue.negative^bt.negative,L.length=19;var ta=(ai+(_=Math.imul(ri,no))|0)+((8191&(F=(F=Math.imul(ri,co))+Math.imul(ui,no)|0))<<13)|0;ai=((k=Math.imul(ui,co))+(F>>>13)|0)+(ta>>>26)|0,ta&=67108863,_=Math.imul(ar,no),F=(F=Math.imul(ar,co))+Math.imul(jr,no)|0,k=Math.imul(jr,co);var sa=(ai+(_=_+Math.imul(ri,Io)|0)|0)+((8191&(F=(F=F+Math.imul(ri,Ro)|0)+Math.imul(ui,Io)|0))<<13)|0;ai=((k=k+Math.imul(ui,Ro)|0)+(F>>>13)|0)+(sa>>>26)|0,sa&=67108863,_=Math.imul(mi,no),F=(F=Math.imul(mi,co))+Math.imul(pi,no)|0,k=Math.imul(pi,co),_=_+Math.imul(ar,Io)|0,F=(F=F+Math.imul(ar,Ro)|0)+Math.imul(jr,Io)|0,k=k+Math.imul(jr,Ro)|0;var ga=(ai+(_=_+Math.imul(ri,To)|0)|0)+((8191&(F=(F=F+Math.imul(ri,Po)|0)+Math.imul(ui,To)|0))<<13)|0;ai=((k=k+Math.imul(ui,Po)|0)+(F>>>13)|0)+(ga>>>26)|0,ga&=67108863,_=Math.imul(Gr,no),F=(F=Math.imul(Gr,co))+Math.imul(ti,no)|0,k=Math.imul(ti,co),_=_+Math.imul(mi,Io)|0,F=(F=F+Math.imul(mi,Ro)|0)+Math.imul(pi,Io)|0,k=k+Math.imul(pi,Ro)|0,_=_+Math.imul(ar,To)|0,F=(F=F+Math.imul(ar,Po)|0)+Math.imul(jr,To)|0,k=k+Math.imul(jr,Po)|0;var ya=(ai+(_=_+Math.imul(ri,Jo)|0)|0)+((8191&(F=(F=F+Math.imul(ri,ea)|0)+Math.imul(ui,Jo)|0))<<13)|0;ai=((k=k+Math.imul(ui,ea)|0)+(F>>>13)|0)+(ya>>>26)|0,ya&=67108863,_=Math.imul(bi,no),F=(F=Math.imul(bi,co))+Math.imul(Ai,no)|0,k=Math.imul(Ai,co),_=_+Math.imul(Gr,Io)|0,F=(F=F+Math.imul(Gr,Ro)|0)+Math.imul(ti,Io)|0,k=k+Math.imul(ti,Ro)|0,_=_+Math.imul(mi,To)|0,F=(F=F+Math.imul(mi,Po)|0)+Math.imul(pi,To)|0,k=k+Math.imul(pi,Po)|0,_=_+Math.imul(ar,Jo)|0,F=(F=F+Math.imul(ar,ea)|0)+Math.imul(jr,Jo)|0,k=k+Math.imul(jr,ea)|0;var ma=(ai+(_=_+Math.imul(ri,Gi)|0)|0)+((8191&(F=(F=F+Math.imul(ri,uo)|0)+Math.imul(ui,Gi)|0))<<13)|0;ai=((k=k+Math.imul(ui,uo)|0)+(F>>>13)|0)+(ma>>>26)|0,ma&=67108863,_=Math.imul(qi,no),F=(F=Math.imul(qi,co))+Math.imul(vn,no)|0,k=Math.imul(vn,co),_=_+Math.imul(bi,Io)|0,F=(F=F+Math.imul(bi,Ro)|0)+Math.imul(Ai,Io)|0,k=k+Math.imul(Ai,Ro)|0,_=_+Math.imul(Gr,To)|0,F=(F=F+Math.imul(Gr,Po)|0)+Math.imul(ti,To)|0,k=k+Math.imul(ti,Po)|0,_=_+Math.imul(mi,Jo)|0,F=(F=F+Math.imul(mi,ea)|0)+Math.imul(pi,Jo)|0,k=k+Math.imul(pi,ea)|0,_=_+Math.imul(ar,Gi)|0,F=(F=F+Math.imul(ar,uo)|0)+Math.imul(jr,Gi)|0,k=k+Math.imul(jr,uo)|0;var fa=(ai+(_=_+Math.imul(ri,xi)|0)|0)+((8191&(F=(F=F+Math.imul(ri,Fi)|0)+Math.imul(ui,xi)|0))<<13)|0;ai=((k=k+Math.imul(ui,Fi)|0)+(F>>>13)|0)+(fa>>>26)|0,fa&=67108863,_=Math.imul(rr,no),F=(F=Math.imul(rr,co))+Math.imul(on,no)|0,k=Math.imul(on,co),_=_+Math.imul(qi,Io)|0,F=(F=F+Math.imul(qi,Ro)|0)+Math.imul(vn,Io)|0,k=k+Math.imul(vn,Ro)|0,_=_+Math.imul(bi,To)|0,F=(F=F+Math.imul(bi,Po)|0)+Math.imul(Ai,To)|0,k=k+Math.imul(Ai,Po)|0,_=_+Math.imul(Gr,Jo)|0,F=(F=F+Math.imul(Gr,ea)|0)+Math.imul(ti,Jo)|0,k=k+Math.imul(ti,ea)|0,_=_+Math.imul(mi,Gi)|0,F=(F=F+Math.imul(mi,uo)|0)+Math.imul(pi,Gi)|0,k=k+Math.imul(pi,uo)|0,_=_+Math.imul(ar,xi)|0,F=(F=F+Math.imul(ar,Fi)|0)+Math.imul(jr,xi)|0,k=k+Math.imul(jr,Fi)|0;var ra=(ai+(_=_+Math.imul(ri,gi)|0)|0)+((8191&(F=(F=F+Math.imul(ri,Li)|0)+Math.imul(ui,gi)|0))<<13)|0;ai=((k=k+Math.imul(ui,Li)|0)+(F>>>13)|0)+(ra>>>26)|0,ra&=67108863,_=Math.imul(vi,no),F=(F=Math.imul(vi,co))+Math.imul(Ei,no)|0,k=Math.imul(Ei,co),_=_+Math.imul(rr,Io)|0,F=(F=F+Math.imul(rr,Ro)|0)+Math.imul(on,Io)|0,k=k+Math.imul(on,Ro)|0,_=_+Math.imul(qi,To)|0,F=(F=F+Math.imul(qi,Po)|0)+Math.imul(vn,To)|0,k=k+Math.imul(vn,Po)|0,_=_+Math.imul(bi,Jo)|0,F=(F=F+Math.imul(bi,ea)|0)+Math.imul(Ai,Jo)|0,k=k+Math.imul(Ai,ea)|0,_=_+Math.imul(Gr,Gi)|0,F=(F=F+Math.imul(Gr,uo)|0)+Math.imul(ti,Gi)|0,k=k+Math.imul(ti,uo)|0,_=_+Math.imul(mi,xi)|0,F=(F=F+Math.imul(mi,Fi)|0)+Math.imul(pi,xi)|0,k=k+Math.imul(pi,Fi)|0,_=_+Math.imul(ar,gi)|0,F=(F=F+Math.imul(ar,Li)|0)+Math.imul(jr,gi)|0,k=k+Math.imul(jr,Li)|0;var ha=(ai+(_=_+Math.imul(ri,Wi)|0)|0)+((8191&(F=(F=F+Math.imul(ri,io)|0)+Math.imul(ui,Wi)|0))<<13)|0;ai=((k=k+Math.imul(ui,io)|0)+(F>>>13)|0)+(ha>>>26)|0,ha&=67108863,_=Math.imul(Di,no),F=(F=Math.imul(Di,co))+Math.imul(Ii,no)|0,k=Math.imul(Ii,co),_=_+Math.imul(vi,Io)|0,F=(F=F+Math.imul(vi,Ro)|0)+Math.imul(Ei,Io)|0,k=k+Math.imul(Ei,Ro)|0,_=_+Math.imul(rr,To)|0,F=(F=F+Math.imul(rr,Po)|0)+Math.imul(on,To)|0,k=k+Math.imul(on,Po)|0,_=_+Math.imul(qi,Jo)|0,F=(F=F+Math.imul(qi,ea)|0)+Math.imul(vn,Jo)|0,k=k+Math.imul(vn,ea)|0,_=_+Math.imul(bi,Gi)|0,F=(F=F+Math.imul(bi,uo)|0)+Math.imul(Ai,Gi)|0,k=k+Math.imul(Ai,uo)|0,_=_+Math.imul(Gr,xi)|0,F=(F=F+Math.imul(Gr,Fi)|0)+Math.imul(ti,xi)|0,k=k+Math.imul(ti,Fi)|0,_=_+Math.imul(mi,gi)|0,F=(F=F+Math.imul(mi,Li)|0)+Math.imul(pi,gi)|0,k=k+Math.imul(pi,Li)|0,_=_+Math.imul(ar,Wi)|0,F=(F=F+Math.imul(ar,io)|0)+Math.imul(jr,Wi)|0,k=k+Math.imul(jr,io)|0;var Wo=(ai+(_=_+Math.imul(ri,Ao)|0)|0)+((8191&(F=(F=F+Math.imul(ri,_o)|0)+Math.imul(ui,Ao)|0))<<13)|0;ai=((k=k+Math.imul(ui,_o)|0)+(F>>>13)|0)+(Wo>>>26)|0,Wo&=67108863,_=Math.imul(Vi,no),F=(F=Math.imul(Vi,co))+Math.imul(Hi,no)|0,k=Math.imul(Hi,co),_=_+Math.imul(Di,Io)|0,F=(F=F+Math.imul(Di,Ro)|0)+Math.imul(Ii,Io)|0,k=k+Math.imul(Ii,Ro)|0,_=_+Math.imul(vi,To)|0,F=(F=F+Math.imul(vi,Po)|0)+Math.imul(Ei,To)|0,k=k+Math.imul(Ei,Po)|0,_=_+Math.imul(rr,Jo)|0,F=(F=F+Math.imul(rr,ea)|0)+Math.imul(on,Jo)|0,k=k+Math.imul(on,ea)|0,_=_+Math.imul(qi,Gi)|0,F=(F=F+Math.imul(qi,uo)|0)+Math.imul(vn,Gi)|0,k=k+Math.imul(vn,uo)|0,_=_+Math.imul(bi,xi)|0,F=(F=F+Math.imul(bi,Fi)|0)+Math.imul(Ai,xi)|0,k=k+Math.imul(Ai,Fi)|0,_=_+Math.imul(Gr,gi)|0,F=(F=F+Math.imul(Gr,Li)|0)+Math.imul(ti,gi)|0,k=k+Math.imul(ti,Li)|0,_=_+Math.imul(mi,Wi)|0,F=(F=F+Math.imul(mi,io)|0)+Math.imul(pi,Wi)|0,k=k+Math.imul(pi,io)|0,_=_+Math.imul(ar,Ao)|0,F=(F=F+Math.imul(ar,_o)|0)+Math.imul(jr,Ao)|0,k=k+Math.imul(jr,_o)|0;var na=(ai+(_=_+Math.imul(ri,Co)|0)|0)+((8191&(F=(F=F+Math.imul(ri,$o)|0)+Math.imul(ui,Co)|0))<<13)|0;ai=((k=k+Math.imul(ui,$o)|0)+(F>>>13)|0)+(na>>>26)|0,na&=67108863,_=Math.imul(Vi,Io),F=(F=Math.imul(Vi,Ro))+Math.imul(Hi,Io)|0,k=Math.imul(Hi,Ro),_=_+Math.imul(Di,To)|0,F=(F=F+Math.imul(Di,Po)|0)+Math.imul(Ii,To)|0,k=k+Math.imul(Ii,Po)|0,_=_+Math.imul(vi,Jo)|0,F=(F=F+Math.imul(vi,ea)|0)+Math.imul(Ei,Jo)|0,k=k+Math.imul(Ei,ea)|0,_=_+Math.imul(rr,Gi)|0,F=(F=F+Math.imul(rr,uo)|0)+Math.imul(on,Gi)|0,k=k+Math.imul(on,uo)|0,_=_+Math.imul(qi,xi)|0,F=(F=F+Math.imul(qi,Fi)|0)+Math.imul(vn,xi)|0,k=k+Math.imul(vn,Fi)|0,_=_+Math.imul(bi,gi)|0,F=(F=F+Math.imul(bi,Li)|0)+Math.imul(Ai,gi)|0,k=k+Math.imul(Ai,Li)|0,_=_+Math.imul(Gr,Wi)|0,F=(F=F+Math.imul(Gr,io)|0)+Math.imul(ti,Wi)|0,k=k+Math.imul(ti,io)|0,_=_+Math.imul(mi,Ao)|0,F=(F=F+Math.imul(mi,_o)|0)+Math.imul(pi,Ao)|0,k=k+Math.imul(pi,_o)|0;var la=(ai+(_=_+Math.imul(ar,Co)|0)|0)+((8191&(F=(F=F+Math.imul(ar,$o)|0)+Math.imul(jr,Co)|0))<<13)|0;ai=((k=k+Math.imul(jr,$o)|0)+(F>>>13)|0)+(la>>>26)|0,la&=67108863,_=Math.imul(Vi,To),F=(F=Math.imul(Vi,Po))+Math.imul(Hi,To)|0,k=Math.imul(Hi,Po),_=_+Math.imul(Di,Jo)|0,F=(F=F+Math.imul(Di,ea)|0)+Math.imul(Ii,Jo)|0,k=k+Math.imul(Ii,ea)|0,_=_+Math.imul(vi,Gi)|0,F=(F=F+Math.imul(vi,uo)|0)+Math.imul(Ei,Gi)|0,k=k+Math.imul(Ei,uo)|0,_=_+Math.imul(rr,xi)|0,F=(F=F+Math.imul(rr,Fi)|0)+Math.imul(on,xi)|0,k=k+Math.imul(on,Fi)|0,_=_+Math.imul(qi,gi)|0,F=(F=F+Math.imul(qi,Li)|0)+Math.imul(vn,gi)|0,k=k+Math.imul(vn,Li)|0,_=_+Math.imul(bi,Wi)|0,F=(F=F+Math.imul(bi,io)|0)+Math.imul(Ai,Wi)|0,k=k+Math.imul(Ai,io)|0,_=_+Math.imul(Gr,Ao)|0,F=(F=F+Math.imul(Gr,_o)|0)+Math.imul(ti,Ao)|0,k=k+Math.imul(ti,_o)|0;var Yo=(ai+(_=_+Math.imul(mi,Co)|0)|0)+((8191&(F=(F=F+Math.imul(mi,$o)|0)+Math.imul(pi,Co)|0))<<13)|0;ai=((k=k+Math.imul(pi,$o)|0)+(F>>>13)|0)+(Yo>>>26)|0,Yo&=67108863,_=Math.imul(Vi,Jo),F=(F=Math.imul(Vi,ea))+Math.imul(Hi,Jo)|0,k=Math.imul(Hi,ea),_=_+Math.imul(Di,Gi)|0,F=(F=F+Math.imul(Di,uo)|0)+Math.imul(Ii,Gi)|0,k=k+Math.imul(Ii,uo)|0,_=_+Math.imul(vi,xi)|0,F=(F=F+Math.imul(vi,Fi)|0)+Math.imul(Ei,xi)|0,k=k+Math.imul(Ei,Fi)|0,_=_+Math.imul(rr,gi)|0,F=(F=F+Math.imul(rr,Li)|0)+Math.imul(on,gi)|0,k=k+Math.imul(on,Li)|0,_=_+Math.imul(qi,Wi)|0,F=(F=F+Math.imul(qi,io)|0)+Math.imul(vn,Wi)|0,k=k+Math.imul(vn,io)|0,_=_+Math.imul(bi,Ao)|0,F=(F=F+Math.imul(bi,_o)|0)+Math.imul(Ai,Ao)|0,k=k+Math.imul(Ai,_o)|0;var ho=(ai+(_=_+Math.imul(Gr,Co)|0)|0)+((8191&(F=(F=F+Math.imul(Gr,$o)|0)+Math.imul(ti,Co)|0))<<13)|0;ai=((k=k+Math.imul(ti,$o)|0)+(F>>>13)|0)+(ho>>>26)|0,ho&=67108863,_=Math.imul(Vi,Gi),F=(F=Math.imul(Vi,uo))+Math.imul(Hi,Gi)|0,k=Math.imul(Hi,uo),_=_+Math.imul(Di,xi)|0,F=(F=F+Math.imul(Di,Fi)|0)+Math.imul(Ii,xi)|0,k=k+Math.imul(Ii,Fi)|0,_=_+Math.imul(vi,gi)|0,F=(F=F+Math.imul(vi,Li)|0)+Math.imul(Ei,gi)|0,k=k+Math.imul(Ei,Li)|0,_=_+Math.imul(rr,Wi)|0,F=(F=F+Math.imul(rr,io)|0)+Math.imul(on,Wi)|0,k=k+Math.imul(on,io)|0,_=_+Math.imul(qi,Ao)|0,F=(F=F+Math.imul(qi,_o)|0)+Math.imul(vn,Ao)|0,k=k+Math.imul(vn,_o)|0;var yo=(ai+(_=_+Math.imul(bi,Co)|0)|0)+((8191&(F=(F=F+Math.imul(bi,$o)|0)+Math.imul(Ai,Co)|0))<<13)|0;ai=((k=k+Math.imul(Ai,$o)|0)+(F>>>13)|0)+(yo>>>26)|0,yo&=67108863,_=Math.imul(Vi,xi),F=(F=Math.imul(Vi,Fi))+Math.imul(Hi,xi)|0,k=Math.imul(Hi,Fi),_=_+Math.imul(Di,gi)|0,F=(F=F+Math.imul(Di,Li)|0)+Math.imul(Ii,gi)|0,k=k+Math.imul(Ii,Li)|0,_=_+Math.imul(vi,Wi)|0,F=(F=F+Math.imul(vi,io)|0)+Math.imul(Ei,Wi)|0,k=k+Math.imul(Ei,io)|0,_=_+Math.imul(rr,Ao)|0,F=(F=F+Math.imul(rr,_o)|0)+Math.imul(on,Ao)|0,k=k+Math.imul(on,_o)|0;var No=(ai+(_=_+Math.imul(qi,Co)|0)|0)+((8191&(F=(F=F+Math.imul(qi,$o)|0)+Math.imul(vn,Co)|0))<<13)|0;ai=((k=k+Math.imul(vn,$o)|0)+(F>>>13)|0)+(No>>>26)|0,No&=67108863,_=Math.imul(Vi,gi),F=(F=Math.imul(Vi,Li))+Math.imul(Hi,gi)|0,k=Math.imul(Hi,Li),_=_+Math.imul(Di,Wi)|0,F=(F=F+Math.imul(Di,io)|0)+Math.imul(Ii,Wi)|0,k=k+Math.imul(Ii,io)|0,_=_+Math.imul(vi,Ao)|0,F=(F=F+Math.imul(vi,_o)|0)+Math.imul(Ei,Ao)|0,k=k+Math.imul(Ei,_o)|0;var vo=(ai+(_=_+Math.imul(rr,Co)|0)|0)+((8191&(F=(F=F+Math.imul(rr,$o)|0)+Math.imul(on,Co)|0))<<13)|0;ai=((k=k+Math.imul(on,$o)|0)+(F>>>13)|0)+(vo>>>26)|0,vo&=67108863,_=Math.imul(Vi,Wi),F=(F=Math.imul(Vi,io))+Math.imul(Hi,Wi)|0,k=Math.imul(Hi,io),_=_+Math.imul(Di,Ao)|0,F=(F=F+Math.imul(Di,_o)|0)+Math.imul(Ii,Ao)|0,k=k+Math.imul(Ii,_o)|0;var bo=(ai+(_=_+Math.imul(vi,Co)|0)|0)+((8191&(F=(F=F+Math.imul(vi,$o)|0)+Math.imul(Ei,Co)|0))<<13)|0;ai=((k=k+Math.imul(Ei,$o)|0)+(F>>>13)|0)+(bo>>>26)|0,bo&=67108863,_=Math.imul(Vi,Ao),F=(F=Math.imul(Vi,_o))+Math.imul(Hi,Ao)|0,k=Math.imul(Hi,_o);var Uo=(ai+(_=_+Math.imul(Di,Co)|0)|0)+((8191&(F=(F=F+Math.imul(Di,$o)|0)+Math.imul(Ii,Co)|0))<<13)|0;ai=((k=k+Math.imul(Ii,$o)|0)+(F>>>13)|0)+(Uo>>>26)|0,Uo&=67108863;var Aa=(ai+(_=Math.imul(Vi,Co))|0)+((8191&(F=(F=Math.imul(Vi,$o))+Math.imul(Hi,Co)|0))<<13)|0;return ai=((k=Math.imul(Hi,$o))+(F>>>13)|0)+(Aa>>>26)|0,Aa&=67108863,ii[0]=ta,ii[1]=sa,ii[2]=ga,ii[3]=ya,ii[4]=ma,ii[5]=fa,ii[6]=ra,ii[7]=ha,ii[8]=Wo,ii[9]=na,ii[10]=la,ii[11]=Yo,ii[12]=ho,ii[13]=yo,ii[14]=No,ii[15]=vo,ii[16]=bo,ii[17]=Uo,ii[18]=Aa,ai!==0&&(ii[19]=ai,L.length++),L};function ve(ue,bt,L){return new Qe().mulp(ue,bt,L)}function Qe(ue,bt){this.x=ue,this.y=bt}Math.imul||(J=W),h.prototype.mulTo=function(ue,bt){var L,_=this.length+ue.length;return L=this.length===10&&ue.length===10?J(this,ue,bt):_<63?W(this,ue,bt):_<1024?(function(F,k,Ye){Ye.negative=k.negative^F.negative,Ye.length=F.length+k.length;for(var rn=0,ii=0,ai=0;ai<Ye.length-1;ai++){var ni=ii;ii=0;for(var ri=67108863&rn,ui=Math.min(ai,k.length-1),lr=Math.max(0,ai-F.length+1);lr<=ui;lr++){var ar=ai-lr,jr=(0|F.words[ar])*(0|k.words[lr]),ci=67108863&jr;ri=67108863&(ci=ci+ri|0),ii+=(ni=(ni=ni+(jr/67108864|0)|0)+(ci>>>26)|0)>>>26,ni&=67108863}Ye.words[ai]=ri,rn=ni,ni=ii}return rn!==0?Ye.words[ai]=rn:Ye.length--,Ye.strip()})(this,ue,bt):ve(this,ue,bt),L},Qe.prototype.makeRBT=function(ue){for(var bt=new Array(ue),L=h.prototype._countBits(ue)-1,_=0;_<ue;_++)bt[_]=this.revBin(_,L,ue);return bt},Qe.prototype.revBin=function(ue,bt,L){if(ue===0||ue===L-1)return ue;for(var _=0,F=0;F<bt;F++)_|=(1&ue)<<bt-F-1,ue>>=1;return _},Qe.prototype.permute=function(ue,bt,L,_,F,k){for(var Ye=0;Ye<k;Ye++)_[Ye]=bt[ue[Ye]],F[Ye]=L[ue[Ye]]},Qe.prototype.transform=function(ue,bt,L,_,F,k){this.permute(k,ue,bt,L,_,F);for(var Ye=1;Ye<F;Ye<<=1)for(var rn=Ye<<1,ii=Math.cos(2*Math.PI/rn),ai=Math.sin(2*Math.PI/rn),ni=0;ni<F;ni+=rn)for(var ri=ii,ui=ai,lr=0;lr<Ye;lr++){var ar=L[ni+lr],jr=_[ni+lr],ci=L[ni+lr+Ye],mi=_[ni+lr+Ye],pi=ri*ci-ui*mi;mi=ri*mi+ui*ci,ci=pi,L[ni+lr]=ar+ci,_[ni+lr]=jr+mi,L[ni+lr+Ye]=ar-ci,_[ni+lr+Ye]=jr-mi,lr!==rn&&(pi=ii*ri-ai*ui,ui=ii*ui+ai*ri,ri=pi)}},Qe.prototype.guessLen13b=function(ue,bt){var L=1|Math.max(bt,ue),_=1&L,F=0;for(L=L/2|0;L;L>>>=1)F++;return 1<<F+1+_},Qe.prototype.conjugate=function(ue,bt,L){if(!(L<=1))for(var _=0;_<L/2;_++){var F=ue[_];ue[_]=ue[L-_-1],ue[L-_-1]=F,F=bt[_],bt[_]=-bt[L-_-1],bt[L-_-1]=-F}},Qe.prototype.normalize13b=function(ue,bt){for(var L=0,_=0;_<bt/2;_++){var F=8192*Math.round(ue[2*_+1]/bt)+Math.round(ue[2*_]/bt)+L;ue[_]=67108863&F,L=F<67108864?0:F/67108864|0}return ue},Qe.prototype.convert13b=function(ue,bt,L,_){for(var F=0,k=0;k<bt;k++)F+=0|ue[k],L[2*k]=8191&F,F>>>=13,L[2*k+1]=8191&F,F>>>=13;for(k=2*bt;k<_;++k)L[k]=0;d(F===0),d((-8192&F)==0)},Qe.prototype.stub=function(ue){for(var bt=new Array(ue),L=0;L<ue;L++)bt[L]=0;return bt},Qe.prototype.mulp=function(ue,bt,L){var _=2*this.guessLen13b(ue.length,bt.length),F=this.makeRBT(_),k=this.stub(_),Ye=new Array(_),rn=new Array(_),ii=new Array(_),ai=new Array(_),ni=new Array(_),ri=new Array(_),ui=L.words;ui.length=_,this.convert13b(ue.words,ue.length,Ye,_),this.convert13b(bt.words,bt.length,ai,_),this.transform(Ye,k,rn,ii,_,F),this.transform(ai,k,ni,ri,_,F);for(var lr=0;lr<_;lr++){var ar=rn[lr]*ni[lr]-ii[lr]*ri[lr];ii[lr]=rn[lr]*ri[lr]+ii[lr]*ni[lr],rn[lr]=ar}return this.conjugate(rn,ii,_),this.transform(rn,ii,ui,k,_,F),this.conjugate(ui,k,_),this.normalize13b(ui,_),L.negative=ue.negative^bt.negative,L.length=ue.length+bt.length,L.strip()},h.prototype.mul=function(ue){var bt=new h(null);return bt.words=new Array(this.length+ue.length),this.mulTo(ue,bt)},h.prototype.mulf=function(ue){var bt=new h(null);return bt.words=new Array(this.length+ue.length),ve(this,ue,bt)},h.prototype.imul=function(ue){return this.clone().mulTo(ue,this)},h.prototype.imuln=function(ue){d(typeof ue=="number"),d(ue<67108864);for(var bt=0,L=0;L<this.length;L++){var _=(0|this.words[L])*ue,F=(67108863&_)+(67108863&bt);bt>>=26,bt+=_/67108864|0,bt+=F>>>26,this.words[L]=67108863&F}return bt!==0&&(this.words[L]=bt,this.length++),this},h.prototype.muln=function(ue){return this.clone().imuln(ue)},h.prototype.sqr=function(){return this.mul(this)},h.prototype.isqr=function(){return this.imul(this.clone())},h.prototype.pow=function(ue){var bt=(function(k){for(var Ye=new Array(k.bitLength()),rn=0;rn<Ye.length;rn++){var ii=rn/26|0,ai=rn%26;Ye[rn]=(k.words[ii]&1<<ai)>>>ai}return Ye})(ue);if(bt.length===0)return new h(1);for(var L=this,_=0;_<bt.length&&bt[_]===0;_++,L=L.sqr());if(++_<bt.length)for(var F=L.sqr();_<bt.length;_++,F=F.sqr())bt[_]!==0&&(L=L.mul(F));return L},h.prototype.iushln=function(ue){d(typeof ue=="number"&&ue>=0);var bt,L=ue%26,_=(ue-L)/26,F=67108863>>>26-L<<26-L;if(L!==0){var k=0;for(bt=0;bt<this.length;bt++){var Ye=this.words[bt]&F,rn=(0|this.words[bt])-Ye<<L;this.words[bt]=rn|k,k=Ye>>>26-L}k&&(this.words[bt]=k,this.length++)}if(_!==0){for(bt=this.length-1;bt>=0;bt--)this.words[bt+_]=this.words[bt];for(bt=0;bt<_;bt++)this.words[bt]=0;this.length+=_}return this.strip()},h.prototype.ishln=function(ue){return d(this.negative===0),this.iushln(ue)},h.prototype.iushrn=function(ue,bt,L){var _;d(typeof ue=="number"&&ue>=0),_=bt?(bt-bt%26)/26:0;var F=ue%26,k=Math.min((ue-F)/26,this.length),Ye=67108863^67108863>>>F<<F,rn=L;if(_-=k,_=Math.max(0,_),rn){for(var ii=0;ii<k;ii++)rn.words[ii]=this.words[ii];rn.length=k}if(k!==0)if(this.length>k)for(this.length-=k,ii=0;ii<this.length;ii++)this.words[ii]=this.words[ii+k];else this.words[0]=0,this.length=1;var ai=0;for(ii=this.length-1;ii>=0&&(ai!==0||ii>=_);ii--){var ni=0|this.words[ii];this.words[ii]=ai<<26-F|ni>>>F,ai=ni&Ye}return rn&&ai!==0&&(rn.words[rn.length++]=ai),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},h.prototype.ishrn=function(ue,bt,L){return d(this.negative===0),this.iushrn(ue,bt,L)},h.prototype.shln=function(ue){return this.clone().ishln(ue)},h.prototype.ushln=function(ue){return this.clone().iushln(ue)},h.prototype.shrn=function(ue){return this.clone().ishrn(ue)},h.prototype.ushrn=function(ue){return this.clone().iushrn(ue)},h.prototype.testn=function(ue){d(typeof ue=="number"&&ue>=0);var bt=ue%26,L=(ue-bt)/26,_=1<<bt;return!(this.length<=L||!(this.words[L]&_))},h.prototype.imaskn=function(ue){d(typeof ue=="number"&&ue>=0);var bt=ue%26,L=(ue-bt)/26;if(d(this.negative===0,"imaskn works only with positive numbers"),this.length<=L)return this;if(bt!==0&&L++,this.length=Math.min(L,this.length),bt!==0){var _=67108863^67108863>>>bt<<bt;this.words[this.length-1]&=_}return this.strip()},h.prototype.maskn=function(ue){return this.clone().imaskn(ue)},h.prototype.iaddn=function(ue){return d(typeof ue=="number"),d(ue<67108864),ue<0?this.isubn(-ue):this.negative!==0?this.length===1&&(0|this.words[0])<ue?(this.words[0]=ue-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(ue),this.negative=1,this):this._iaddn(ue)},h.prototype._iaddn=function(ue){this.words[0]+=ue;for(var bt=0;bt<this.length&&this.words[bt]>=67108864;bt++)this.words[bt]-=67108864,bt===this.length-1?this.words[bt+1]=1:this.words[bt+1]++;return this.length=Math.max(this.length,bt+1),this},h.prototype.isubn=function(ue){if(d(typeof ue=="number"),d(ue<67108864),ue<0)return this.iaddn(-ue);if(this.negative!==0)return this.negative=0,this.iaddn(ue),this.negative=1,this;if(this.words[0]-=ue,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var bt=0;bt<this.length&&this.words[bt]<0;bt++)this.words[bt]+=67108864,this.words[bt+1]-=1;return this.strip()},h.prototype.addn=function(ue){return this.clone().iaddn(ue)},h.prototype.subn=function(ue){return this.clone().isubn(ue)},h.prototype.iabs=function(){return this.negative=0,this},h.prototype.abs=function(){return this.clone().iabs()},h.prototype._ishlnsubmul=function(ue,bt,L){var _,F,k=ue.length+L;this._expand(k);var Ye=0;for(_=0;_<ue.length;_++){F=(0|this.words[_+L])+Ye;var rn=(0|ue.words[_])*bt;Ye=((F-=67108863&rn)>>26)-(rn/67108864|0),this.words[_+L]=67108863&F}for(;_<this.length-L;_++)Ye=(F=(0|this.words[_+L])+Ye)>>26,this.words[_+L]=67108863&F;if(Ye===0)return this.strip();for(d(Ye===-1),Ye=0,_=0;_<this.length;_++)Ye=(F=-(0|this.words[_])+Ye)>>26,this.words[_]=67108863&F;return this.negative=1,this.strip()},h.prototype._wordDiv=function(ue,bt){var L=(this.length,ue.length),_=this.clone(),F=ue,k=0|F.words[F.length-1];(L=26-this._countBits(k))!=0&&(F=F.ushln(L),_.iushln(L),k=0|F.words[F.length-1]);var Ye,rn=_.length-F.length;if(bt!=="mod"){(Ye=new h(null)).length=rn+1,Ye.words=new Array(Ye.length);for(var ii=0;ii<Ye.length;ii++)Ye.words[ii]=0}var ai=_.clone()._ishlnsubmul(F,1,rn);ai.negative===0&&(_=ai,Ye&&(Ye.words[rn]=1));for(var ni=rn-1;ni>=0;ni--){var ri=67108864*(0|_.words[F.length+ni])+(0|_.words[F.length+ni-1]);for(ri=Math.min(ri/k|0,67108863),_._ishlnsubmul(F,ri,ni);_.negative!==0;)ri--,_.negative=0,_._ishlnsubmul(F,1,ni),_.isZero()||(_.negative^=1);Ye&&(Ye.words[ni]=ri)}return Ye&&Ye.strip(),_.strip(),bt!=="div"&&L!==0&&_.iushrn(L),{div:Ye||null,mod:_}},h.prototype.divmod=function(ue,bt,L){return d(!ue.isZero()),this.isZero()?{div:new h(0),mod:new h(0)}:this.negative!==0&&ue.negative===0?(k=this.neg().divmod(ue,bt),bt!=="mod"&&(_=k.div.neg()),bt!=="div"&&(F=k.mod.neg(),L&&F.negative!==0&&F.iadd(ue)),{div:_,mod:F}):this.negative===0&&ue.negative!==0?(k=this.divmod(ue.neg(),bt),bt!=="mod"&&(_=k.div.neg()),{div:_,mod:k.mod}):(this.negative&ue.negative)!=0?(k=this.neg().divmod(ue.neg(),bt),bt!=="div"&&(F=k.mod.neg(),L&&F.negative!==0&&F.isub(ue)),{div:k.div,mod:F}):ue.length>this.length||this.cmp(ue)<0?{div:new h(0),mod:this}:ue.length===1?bt==="div"?{div:this.divn(ue.words[0]),mod:null}:bt==="mod"?{div:null,mod:new h(this.modn(ue.words[0]))}:{div:this.divn(ue.words[0]),mod:new h(this.modn(ue.words[0]))}:this._wordDiv(ue,bt);var _,F,k},h.prototype.div=function(ue){return this.divmod(ue,"div",!1).div},h.prototype.mod=function(ue){return this.divmod(ue,"mod",!1).mod},h.prototype.umod=function(ue){return this.divmod(ue,"mod",!0).mod},h.prototype.divRound=function(ue){var bt=this.divmod(ue);if(bt.mod.isZero())return bt.div;var L=bt.div.negative!==0?bt.mod.isub(ue):bt.mod,_=ue.ushrn(1),F=ue.andln(1),k=L.cmp(_);return k<0||F===1&&k===0?bt.div:bt.div.negative!==0?bt.div.isubn(1):bt.div.iaddn(1)},h.prototype.modn=function(ue){d(ue<=67108863);for(var bt=67108864%ue,L=0,_=this.length-1;_>=0;_--)L=(bt*L+(0|this.words[_]))%ue;return L},h.prototype.idivn=function(ue){d(ue<=67108863);for(var bt=0,L=this.length-1;L>=0;L--){var _=(0|this.words[L])+67108864*bt;this.words[L]=_/ue|0,bt=_%ue}return this.strip()},h.prototype.divn=function(ue){return this.clone().idivn(ue)},h.prototype.egcd=function(ue){d(ue.negative===0),d(!ue.isZero());var bt=this,L=ue.clone();bt=bt.negative!==0?bt.umod(ue):bt.clone();for(var _=new h(1),F=new h(0),k=new h(0),Ye=new h(1),rn=0;bt.isEven()&&L.isEven();)bt.iushrn(1),L.iushrn(1),++rn;for(var ii=L.clone(),ai=bt.clone();!bt.isZero();){for(var ni=0,ri=1;(bt.words[0]&ri)==0&&ni<26;++ni,ri<<=1);if(ni>0)for(bt.iushrn(ni);ni-- >0;)(_.isOdd()||F.isOdd())&&(_.iadd(ii),F.isub(ai)),_.iushrn(1),F.iushrn(1);for(var ui=0,lr=1;(L.words[0]&lr)==0&&ui<26;++ui,lr<<=1);if(ui>0)for(L.iushrn(ui);ui-- >0;)(k.isOdd()||Ye.isOdd())&&(k.iadd(ii),Ye.isub(ai)),k.iushrn(1),Ye.iushrn(1);bt.cmp(L)>=0?(bt.isub(L),_.isub(k),F.isub(Ye)):(L.isub(bt),k.isub(_),Ye.isub(F))}return{a:k,b:Ye,gcd:L.iushln(rn)}},h.prototype._invmp=function(ue){d(ue.negative===0),d(!ue.isZero());var bt=this,L=ue.clone();bt=bt.negative!==0?bt.umod(ue):bt.clone();for(var _,F=new h(1),k=new h(0),Ye=L.clone();bt.cmpn(1)>0&&L.cmpn(1)>0;){for(var rn=0,ii=1;(bt.words[0]&ii)==0&&rn<26;++rn,ii<<=1);if(rn>0)for(bt.iushrn(rn);rn-- >0;)F.isOdd()&&F.iadd(Ye),F.iushrn(1);for(var ai=0,ni=1;(L.words[0]&ni)==0&&ai<26;++ai,ni<<=1);if(ai>0)for(L.iushrn(ai);ai-- >0;)k.isOdd()&&k.iadd(Ye),k.iushrn(1);bt.cmp(L)>=0?(bt.isub(L),F.isub(k)):(L.isub(bt),k.isub(F))}return(_=bt.cmpn(1)===0?F:k).cmpn(0)<0&&_.iadd(ue),_},h.prototype.gcd=function(ue){if(this.isZero())return ue.abs();if(ue.isZero())return this.abs();var bt=this.clone(),L=ue.clone();bt.negative=0,L.negative=0;for(var _=0;bt.isEven()&&L.isEven();_++)bt.iushrn(1),L.iushrn(1);for(;;){for(;bt.isEven();)bt.iushrn(1);for(;L.isEven();)L.iushrn(1);var F=bt.cmp(L);if(F<0){var k=bt;bt=L,L=k}else if(F===0||L.cmpn(1)===0)break;bt.isub(L)}return L.iushln(_)},h.prototype.invm=function(ue){return this.egcd(ue).a.umod(ue)},h.prototype.isEven=function(){return(1&this.words[0])==0},h.prototype.isOdd=function(){return(1&this.words[0])==1},h.prototype.andln=function(ue){return this.words[0]&ue},h.prototype.bincn=function(ue){d(typeof ue=="number");var bt=ue%26,L=(ue-bt)/26,_=1<<bt;if(this.length<=L)return this._expand(L+1),this.words[L]|=_,this;for(var F=_,k=L;F!==0&&k<this.length;k++){var Ye=0|this.words[k];F=(Ye+=F)>>>26,Ye&=67108863,this.words[k]=Ye}return F!==0&&(this.words[k]=F,this.length++),this},h.prototype.isZero=function(){return this.length===1&&this.words[0]===0},h.prototype.cmpn=function(ue){var bt,L=ue<0;if(this.negative!==0&&!L)return-1;if(this.negative===0&&L)return 1;if(this.strip(),this.length>1)bt=1;else{L&&(ue=-ue),d(ue<=67108863,"Number is too big");var _=0|this.words[0];bt=_===ue?0:_<ue?-1:1}return this.negative!==0?0|-bt:bt},h.prototype.cmp=function(ue){if(this.negative!==0&&ue.negative===0)return-1;if(this.negative===0&&ue.negative!==0)return 1;var bt=this.ucmp(ue);return this.negative!==0?0|-bt:bt},h.prototype.ucmp=function(ue){if(this.length>ue.length)return 1;if(this.length<ue.length)return-1;for(var bt=0,L=this.length-1;L>=0;L--){var _=0|this.words[L],F=0|ue.words[L];if(_!==F){_<F?bt=-1:_>F&&(bt=1);break}}return bt},h.prototype.gtn=function(ue){return this.cmpn(ue)===1},h.prototype.gt=function(ue){return this.cmp(ue)===1},h.prototype.gten=function(ue){return this.cmpn(ue)>=0},h.prototype.gte=function(ue){return this.cmp(ue)>=0},h.prototype.ltn=function(ue){return this.cmpn(ue)===-1},h.prototype.lt=function(ue){return this.cmp(ue)===-1},h.prototype.lten=function(ue){return this.cmpn(ue)<=0},h.prototype.lte=function(ue){return this.cmp(ue)<=0},h.prototype.eqn=function(ue){return this.cmpn(ue)===0},h.prototype.eq=function(ue){return this.cmp(ue)===0},h.red=function(ue){return new vt(ue)},h.prototype.toRed=function(ue){return d(!this.red,"Already a number in reduction context"),d(this.negative===0,"red works only with positives"),ue.convertTo(this)._forceRed(ue)},h.prototype.fromRed=function(){return d(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},h.prototype._forceRed=function(ue){return this.red=ue,this},h.prototype.forceRed=function(ue){return d(!this.red,"Already a number in reduction context"),this._forceRed(ue)},h.prototype.redAdd=function(ue){return d(this.red,"redAdd works only with red numbers"),this.red.add(this,ue)},h.prototype.redIAdd=function(ue){return d(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,ue)},h.prototype.redSub=function(ue){return d(this.red,"redSub works only with red numbers"),this.red.sub(this,ue)},h.prototype.redISub=function(ue){return d(this.red,"redISub works only with red numbers"),this.red.isub(this,ue)},h.prototype.redShl=function(ue){return d(this.red,"redShl works only with red numbers"),this.red.shl(this,ue)},h.prototype.redMul=function(ue){return d(this.red,"redMul works only with red numbers"),this.red._verify2(this,ue),this.red.mul(this,ue)},h.prototype.redIMul=function(ue){return d(this.red,"redMul works only with red numbers"),this.red._verify2(this,ue),this.red.imul(this,ue)},h.prototype.redSqr=function(){return d(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},h.prototype.redISqr=function(){return d(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},h.prototype.redSqrt=function(){return d(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},h.prototype.redInvm=function(){return d(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},h.prototype.redNeg=function(){return d(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},h.prototype.redPow=function(ue){return d(this.red&&!ue.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,ue)};var kt={k256:null,p224:null,p192:null,p25519:null};function nr(ue,bt){this.name=ue,this.p=new h(bt,16),this.n=this.p.bitLength(),this.k=new h(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function sr(){nr.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function ce(){nr.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function Ze(){nr.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function se(){nr.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function vt(ue){if(typeof ue=="string"){var bt=h._prime(ue);this.m=bt.p,this.prime=bt}else d(ue.gtn(1),"modulus must be greater than 1"),this.m=ue,this.prime=null}function ur(ue){vt.call(this,ue),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new h(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}nr.prototype._tmp=function(){var ue=new h(null);return ue.words=new Array(Math.ceil(this.n/13)),ue},nr.prototype.ireduce=function(ue){var bt,L=ue;do this.split(L,this.tmp),bt=(L=(L=this.imulK(L)).iadd(this.tmp)).bitLength();while(bt>this.n);var _=bt<this.n?-1:L.ucmp(this.p);return _===0?(L.words[0]=0,L.length=1):_>0?L.isub(this.p):L.strip!==void 0?L.strip():L._strip(),L},nr.prototype.split=function(ue,bt){ue.iushrn(this.n,0,bt)},nr.prototype.imulK=function(ue){return ue.imul(this.k)},p(sr,nr),sr.prototype.split=function(ue,bt){for(var L=4194303,_=Math.min(ue.length,9),F=0;F<_;F++)bt.words[F]=ue.words[F];if(bt.length=_,ue.length<=9)return ue.words[0]=0,void(ue.length=1);var k=ue.words[9];for(bt.words[bt.length++]=k&L,F=10;F<ue.length;F++){var Ye=0|ue.words[F];ue.words[F-10]=(Ye&L)<<4|k>>>22,k=Ye}k>>>=22,ue.words[F-10]=k,k===0&&ue.length>10?ue.length-=10:ue.length-=9},sr.prototype.imulK=function(ue){ue.words[ue.length]=0,ue.words[ue.length+1]=0,ue.length+=2;for(var bt=0,L=0;L<ue.length;L++){var _=0|ue.words[L];bt+=977*_,ue.words[L]=67108863&bt,bt=64*_+(bt/67108864|0)}return ue.words[ue.length-1]===0&&(ue.length--,ue.words[ue.length-1]===0&&ue.length--),ue},p(ce,nr),p(Ze,nr),p(se,nr),se.prototype.imulK=function(ue){for(var bt=0,L=0;L<ue.length;L++){var _=19*(0|ue.words[L])+bt,F=67108863&_;_>>>=26,ue.words[L]=F,bt=_}return bt!==0&&(ue.words[ue.length++]=bt),ue},h._prime=function(ue){if(kt[ue])return kt[ue];var bt;if(ue==="k256")bt=new sr;else if(ue==="p224")bt=new ce;else if(ue==="p192")bt=new Ze;else{if(ue!=="p25519")throw new Error("Unknown prime "+ue);bt=new se}return kt[ue]=bt,bt},vt.prototype._verify1=function(ue){d(ue.negative===0,"red works only with positives"),d(ue.red,"red works only with red numbers")},vt.prototype._verify2=function(ue,bt){d((ue.negative|bt.negative)==0,"red works only with positives"),d(ue.red&&ue.red===bt.red,"red works only with red numbers")},vt.prototype.imod=function(ue){return this.prime?this.prime.ireduce(ue)._forceRed(this):ue.umod(this.m)._forceRed(this)},vt.prototype.neg=function(ue){return ue.isZero()?ue.clone():this.m.sub(ue)._forceRed(this)},vt.prototype.add=function(ue,bt){this._verify2(ue,bt);var L=ue.add(bt);return L.cmp(this.m)>=0&&L.isub(this.m),L._forceRed(this)},vt.prototype.iadd=function(ue,bt){this._verify2(ue,bt);var L=ue.iadd(bt);return L.cmp(this.m)>=0&&L.isub(this.m),L},vt.prototype.sub=function(ue,bt){this._verify2(ue,bt);var L=ue.sub(bt);return L.cmpn(0)<0&&L.iadd(this.m),L._forceRed(this)},vt.prototype.isub=function(ue,bt){this._verify2(ue,bt);var L=ue.isub(bt);return L.cmpn(0)<0&&L.iadd(this.m),L},vt.prototype.shl=function(ue,bt){return this._verify1(ue),this.imod(ue.ushln(bt))},vt.prototype.imul=function(ue,bt){return this._verify2(ue,bt),this.imod(ue.imul(bt))},vt.prototype.mul=function(ue,bt){return this._verify2(ue,bt),this.imod(ue.mul(bt))},vt.prototype.isqr=function(ue){return this.imul(ue,ue.clone())},vt.prototype.sqr=function(ue){return this.mul(ue,ue)},vt.prototype.sqrt=function(ue){if(ue.isZero())return ue.clone();var bt=this.m.andln(3);if(d(bt%2==1),bt===3){var L=this.m.add(new h(1)).iushrn(2);return this.pow(ue,L)}for(var _=this.m.subn(1),F=0;!_.isZero()&&_.andln(1)===0;)F++,_.iushrn(1);d(!_.isZero());var k=new h(1).toRed(this),Ye=k.redNeg(),rn=this.m.subn(1).iushrn(1),ii=this.m.bitLength();for(ii=new h(2*ii*ii).toRed(this);this.pow(ii,rn).cmp(Ye)!==0;)ii.redIAdd(Ye);for(var ai=this.pow(ii,_),ni=this.pow(ue,_.addn(1).iushrn(1)),ri=this.pow(ue,_),ui=F;ri.cmp(k)!==0;){for(var lr=ri,ar=0;lr.cmp(k)!==0;ar++)lr=lr.redSqr();d(ar<ui);var jr=this.pow(ai,new h(1).iushln(ui-ar-1));ni=ni.redMul(jr),ai=jr.redSqr(),ri=ri.redMul(ai),ui=ar}return ni},vt.prototype.invm=function(ue){var bt=ue._invmp(this.m);return bt.negative!==0?(bt.negative=0,this.imod(bt).redNeg()):this.imod(bt)},vt.prototype.pow=function(ue,bt){if(bt.isZero())return new h(1).toRed(this);if(bt.cmpn(1)===0)return ue.clone();var L=new Array(16);L[0]=new h(1).toRed(this),L[1]=ue;for(var _=2;_<L.length;_++)L[_]=this.mul(L[_-1],ue);var F=L[0],k=0,Ye=0,rn=bt.bitLength()%26;for(rn===0&&(rn=26),_=bt.length-1;_>=0;_--){for(var ii=bt.words[_],ai=rn-1;ai>=0;ai--){var ni=ii>>ai&1;F!==L[0]&&(F=this.sqr(F)),ni!==0||k!==0?(k<<=1,k|=ni,(++Ye==4||_===0&&ai===0)&&(F=this.mul(F,L[k]),Ye=0,k=0)):Ye=0}rn=26}return F},vt.prototype.convertTo=function(ue){var bt=ue.umod(this.m);return bt===ue?bt.clone():bt},vt.prototype.convertFrom=function(ue){var bt=ue.clone();return bt.red=null,bt},h.mont=function(ue){return new ur(ue)},p(ur,vt),ur.prototype.convertTo=function(ue){return this.imod(ue.ushln(this.shift))},ur.prototype.convertFrom=function(ue){var bt=this.imod(ue.mul(this.rinv));return bt.red=null,bt},ur.prototype.imul=function(ue,bt){if(ue.isZero()||bt.isZero())return ue.words[0]=0,ue.length=1,ue;var L=ue.imul(bt),_=L.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),F=L.isub(_).iushrn(this.shift),k=F;return F.cmp(this.m)>=0?k=F.isub(this.m):F.cmpn(0)<0&&(k=F.iadd(this.m)),k._forceRed(this)},ur.prototype.mul=function(ue,bt){if(ue.isZero()||bt.isZero())return new h(0)._forceRed(this);var L=ue.mul(bt),_=L.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),F=L.isub(_).iushrn(this.shift),k=F;return F.cmp(this.m)>=0?k=F.isub(this.m):F.cmpn(0)<0&&(k=F.iadd(this.m)),k._forceRed(this)},ur.prototype.invm=function(ue){return this.imod(ue._invmp(this.m).mul(this.r2))._forceRed(this)}})(u=s.nmd(u),this)},7187:u=>{var a,s=typeof Reflect=="object"?Reflect:null,f=s&&typeof s.apply=="function"?s.apply:function(J,ve,Qe){return Function.prototype.apply.call(J,ve,Qe)};a=s&&typeof s.ownKeys=="function"?s.ownKeys:Object.getOwnPropertySymbols?function(J){return Object.getOwnPropertyNames(J).concat(Object.getOwnPropertySymbols(J))}:function(J){return Object.getOwnPropertyNames(J)};var c=Number.isNaN||function(J){return J!=J};function d(){d.init.call(this)}u.exports=d,u.exports.once=function(J,ve){return new Promise((function(Qe,kt){function nr(ce){J.removeListener(ve,sr),kt(ce)}function sr(){typeof J.removeListener=="function"&&J.removeListener("error",nr),Qe([].slice.call(arguments))}W(J,ve,sr,{once:!0}),ve!=="error"&&(function(ce,Ze,se){typeof ce.on=="function"&&W(ce,"error",Ze,{once:!0})})(J,nr)}))},d.EventEmitter=d,d.prototype._events=void 0,d.prototype._eventsCount=0,d.prototype._maxListeners=void 0;var p=10;function h(J){if(typeof J!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof J)}function y(J){return J._maxListeners===void 0?d.defaultMaxListeners:J._maxListeners}function b(J,ve,Qe,kt){var nr,sr,ce,Ze;if(h(Qe),(sr=J._events)===void 0?(sr=J._events=Object.create(null),J._eventsCount=0):(sr.newListener!==void 0&&(J.emit("newListener",ve,Qe.listener?Qe.listener:Qe),sr=J._events),ce=sr[ve]),ce===void 0)ce=sr[ve]=Qe,++J._eventsCount;else if(typeof ce=="function"?ce=sr[ve]=kt?[Qe,ce]:[ce,Qe]:kt?ce.unshift(Qe):ce.push(Qe),(nr=y(J))>0&&ce.length>nr&&!ce.warned){ce.warned=!0;var se=new Error("Possible EventEmitter memory leak detected. "+ce.length+" "+String(ve)+" listeners added. Use emitter.setMaxListeners() to increase limit");se.name="MaxListenersExceededWarning",se.emitter=J,se.type=ve,se.count=ce.length,Ze=se,console&&console.warn&&console.warn(Ze)}return J}function w(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function S(J,ve,Qe){var kt={fired:!1,wrapFn:void 0,target:J,type:ve,listener:Qe},nr=w.bind(kt);return nr.listener=Qe,kt.wrapFn=nr,nr}function E(J,ve,Qe){var kt=J._events;if(kt===void 0)return[];var nr=kt[ve];return nr===void 0?[]:typeof nr=="function"?Qe?[nr.listener||nr]:[nr]:Qe?(function(sr){for(var ce=new Array(sr.length),Ze=0;Ze<ce.length;++Ze)ce[Ze]=sr[Ze].listener||sr[Ze];return ce})(nr):ae(nr,nr.length)}function B(J){var ve=this._events;if(ve!==void 0){var Qe=ve[J];if(typeof Qe=="function")return 1;if(Qe!==void 0)return Qe.length}return 0}function ae(J,ve){for(var Qe=new Array(ve),kt=0;kt<ve;++kt)Qe[kt]=J[kt];return Qe}function W(J,ve,Qe,kt){if(typeof J.on=="function")kt.once?J.once(ve,Qe):J.on(ve,Qe);else{if(typeof J.addEventListener!="function")throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof J);J.addEventListener(ve,(function nr(sr){kt.once&&J.removeEventListener(ve,nr),Qe(sr)}))}}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return p},set:function(J){if(typeof J!="number"||J<0||c(J))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+J+".");p=J}}),d.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},d.prototype.setMaxListeners=function(J){if(typeof J!="number"||J<0||c(J))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+J+".");return this._maxListeners=J,this},d.prototype.getMaxListeners=function(){return y(this)},d.prototype.emit=function(J){for(var ve=[],Qe=1;Qe<arguments.length;Qe++)ve.push(arguments[Qe]);var kt=J==="error",nr=this._events;if(nr!==void 0)kt=kt&&nr.error===void 0;else if(!kt)return!1;if(kt){var sr;if(ve.length>0&&(sr=ve[0]),sr instanceof Error)throw sr;var ce=new Error("Unhandled error."+(sr?" ("+sr.message+")":""));throw ce.context=sr,ce}var Ze=nr[J];if(Ze===void 0)return!1;if(typeof Ze=="function")f(Ze,this,ve);else{var se=Ze.length,vt=ae(Ze,se);for(Qe=0;Qe<se;++Qe)f(vt[Qe],this,ve)}return!0},d.prototype.addListener=function(J,ve){return b(this,J,ve,!1)},d.prototype.on=d.prototype.addListener,d.prototype.prependListener=function(J,ve){return b(this,J,ve,!0)},d.prototype.once=function(J,ve){return h(ve),this.on(J,S(this,J,ve)),this},d.prototype.prependOnceListener=function(J,ve){return h(ve),this.prependListener(J,S(this,J,ve)),this},d.prototype.removeListener=function(J,ve){var Qe,kt,nr,sr,ce;if(h(ve),(kt=this._events)===void 0)return this;if((Qe=kt[J])===void 0)return this;if(Qe===ve||Qe.listener===ve)--this._eventsCount==0?this._events=Object.create(null):(delete kt[J],kt.removeListener&&this.emit("removeListener",J,Qe.listener||ve));else if(typeof Qe!="function"){for(nr=-1,sr=Qe.length-1;sr>=0;sr--)if(Qe[sr]===ve||Qe[sr].listener===ve){ce=Qe[sr].listener,nr=sr;break}if(nr<0)return this;nr===0?Qe.shift():(function(Ze,se){for(;se+1<Ze.length;se++)Ze[se]=Ze[se+1];Ze.pop()})(Qe,nr),Qe.length===1&&(kt[J]=Qe[0]),kt.removeListener!==void 0&&this.emit("removeListener",J,ce||ve)}return this},d.prototype.off=d.prototype.removeListener,d.prototype.removeAllListeners=function(J){var ve,Qe,kt;if((Qe=this._events)===void 0)return this;if(Qe.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):Qe[J]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete Qe[J]),this;if(arguments.length===0){var nr,sr=Object.keys(Qe);for(kt=0;kt<sr.length;++kt)(nr=sr[kt])!=="removeListener"&&this.removeAllListeners(nr);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(ve=Qe[J])=="function")this.removeListener(J,ve);else if(ve!==void 0)for(kt=ve.length-1;kt>=0;kt--)this.removeListener(J,ve[kt]);return this},d.prototype.listeners=function(J){return E(this,J,!0)},d.prototype.rawListeners=function(J){return E(this,J,!1)},d.listenerCount=function(J,ve){return typeof J.listenerCount=="function"?J.listenerCount(ve):B.call(J,ve)},d.prototype.listenerCount=B,d.prototype.eventNames=function(){return this._eventsCount>0?a(this._events):[]}},3349:(u,a,s)=>{var f=s(9509).Buffer,c=s(8473).Transform;function d(p){c.call(this),this._block=f.allocUnsafe(p),this._blockSize=p,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}s(5717)(d,c),d.prototype._transform=function(p,h,y){var b=null;try{this.update(p,h)}catch(w){b=w}y(b)},d.prototype._flush=function(p){var h=null;try{this.push(this.digest())}catch(y){h=y}p(h)},d.prototype.update=function(p,h){if((function(B,ae){if(!f.isBuffer(B)&&typeof B!="string")throw new TypeError("Data must be a string or a buffer")})(p),this._finalized)throw new Error("Digest already called");f.isBuffer(p)||(p=f.from(p,h));for(var y=this._block,b=0;this._blockOffset+p.length-b>=this._blockSize;){for(var w=this._blockOffset;w<this._blockSize;)y[w++]=p[b++];this._update(),this._blockOffset=0}for(;b<p.length;)y[this._blockOffset++]=p[b++];for(var S=0,E=8*p.length;E>0;++S)this._length[S]+=E,(E=this._length[S]/4294967296|0)>0&&(this._length[S]-=4294967296*E);return this},d.prototype._update=function(){throw new Error("_update is not implemented")},d.prototype.digest=function(p){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var h=this._digest();p!==void 0&&(h=h.toString(p)),this._block.fill(0),this._blockOffset=0;for(var y=0;y<4;++y)this._length[y]=0;return h},d.prototype._digest=function(){throw new Error("_digest is not implemented")},u.exports=d},3715:(u,a,s)=>{var f=a;f.utils=s(6436),f.common=s(5772),f.sha=s(9041),f.ripemd=s(2949),f.hmac=s(2344),f.sha1=f.sha.sha1,f.sha256=f.sha.sha256,f.sha224=f.sha.sha224,f.sha384=f.sha.sha384,f.sha512=f.sha.sha512,f.ripemd160=f.ripemd.ripemd160},5772:(u,a,s)=>{var f=s(6436),c=s(9746);function d(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}a.BlockHash=d,d.prototype.update=function(p,h){if(p=f.toArray(p,h),this.pending?this.pending=this.pending.concat(p):this.pending=p,this.pendingTotal+=p.length,this.pending.length>=this._delta8){var y=(p=this.pending).length%this._delta8;this.pending=p.slice(p.length-y,p.length),this.pending.length===0&&(this.pending=null),p=f.join32(p,0,p.length-y,this.endian);for(var b=0;b<p.length;b+=this._delta32)this._update(p,b,b+this._delta32)}return this},d.prototype.digest=function(p){return this.update(this._pad()),c(this.pending===null),this._digest(p)},d.prototype._pad=function(){var p=this.pendingTotal,h=this._delta8,y=h-(p+this.padLength)%h,b=new Array(y+this.padLength);b[0]=128;for(var w=1;w<y;w++)b[w]=0;if(p<<=3,this.endian==="big"){for(var S=8;S<this.padLength;S++)b[w++]=0;b[w++]=0,b[w++]=0,b[w++]=0,b[w++]=0,b[w++]=p>>>24&255,b[w++]=p>>>16&255,b[w++]=p>>>8&255,b[w++]=255&p}else for(b[w++]=255&p,b[w++]=p>>>8&255,b[w++]=p>>>16&255,b[w++]=p>>>24&255,b[w++]=0,b[w++]=0,b[w++]=0,b[w++]=0,S=8;S<this.padLength;S++)b[w++]=0;return b}},2344:(u,a,s)=>{var f=s(6436),c=s(9746);function d(p,h,y){if(!(this instanceof d))return new d(p,h,y);this.Hash=p,this.blockSize=p.blockSize/8,this.outSize=p.outSize/8,this.inner=null,this.outer=null,this._init(f.toArray(h,y))}u.exports=d,d.prototype._init=function(p){p.length>this.blockSize&&(p=new this.Hash().update(p).digest()),c(p.length<=this.blockSize);for(var h=p.length;h<this.blockSize;h++)p.push(0);for(h=0;h<p.length;h++)p[h]^=54;for(this.inner=new this.Hash().update(p),h=0;h<p.length;h++)p[h]^=106;this.outer=new this.Hash().update(p)},d.prototype.update=function(p,h){return this.inner.update(p,h),this},d.prototype.digest=function(p){return this.outer.update(this.inner.digest()),this.outer.digest(p)}},2949:(u,a,s)=>{var f=s(6436),c=s(5772),d=f.rotl32,p=f.sum32,h=f.sum32_3,y=f.sum32_4,b=c.BlockHash;function w(){if(!(this instanceof w))return new w;b.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function S(Qe,kt,nr,sr){return Qe<=15?kt^nr^sr:Qe<=31?kt&nr|~kt&sr:Qe<=47?(kt|~nr)^sr:Qe<=63?kt&sr|nr&~sr:kt^(nr|~sr)}function E(Qe){return Qe<=15?0:Qe<=31?1518500249:Qe<=47?1859775393:Qe<=63?2400959708:2840853838}function B(Qe){return Qe<=15?1352829926:Qe<=31?1548603684:Qe<=47?1836072691:Qe<=63?2053994217:0}f.inherits(w,b),a.ripemd160=w,w.blockSize=512,w.outSize=160,w.hmacStrength=192,w.padLength=64,w.prototype._update=function(Qe,kt){for(var nr=this.h[0],sr=this.h[1],ce=this.h[2],Ze=this.h[3],se=this.h[4],vt=nr,ur=sr,ue=ce,bt=Ze,L=se,_=0;_<80;_++){var F=p(d(y(nr,S(_,sr,ce,Ze),Qe[ae[_]+kt],E(_)),J[_]),se);nr=se,se=Ze,Ze=d(ce,10),ce=sr,sr=F,F=p(d(y(vt,S(79-_,ur,ue,bt),Qe[W[_]+kt],B(_)),ve[_]),L),vt=L,L=bt,bt=d(ue,10),ue=ur,ur=F}F=h(this.h[1],ce,bt),this.h[1]=h(this.h[2],Ze,L),this.h[2]=h(this.h[3],se,vt),this.h[3]=h(this.h[4],nr,ur),this.h[4]=h(this.h[0],sr,ue),this.h[0]=F},w.prototype._digest=function(Qe){return Qe==="hex"?f.toHex32(this.h,"little"):f.split32(this.h,"little")};var ae=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],W=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],J=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],ve=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},9041:(u,a,s)=>{a.sha1=s(4761),a.sha224=s(799),a.sha256=s(9344),a.sha384=s(772),a.sha512=s(5900)},4761:(u,a,s)=>{var f=s(6436),c=s(5772),d=s(7038),p=f.rotl32,h=f.sum32,y=f.sum32_5,b=d.ft_1,w=c.BlockHash,S=[1518500249,1859775393,2400959708,3395469782];function E(){if(!(this instanceof E))return new E;w.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}f.inherits(E,w),u.exports=E,E.blockSize=512,E.outSize=160,E.hmacStrength=80,E.padLength=64,E.prototype._update=function(B,ae){for(var W=this.W,J=0;J<16;J++)W[J]=B[ae+J];for(;J<W.length;J++)W[J]=p(W[J-3]^W[J-8]^W[J-14]^W[J-16],1);var ve=this.h[0],Qe=this.h[1],kt=this.h[2],nr=this.h[3],sr=this.h[4];for(J=0;J<W.length;J++){var ce=~~(J/20),Ze=y(p(ve,5),b(ce,Qe,kt,nr),sr,W[J],S[ce]);sr=nr,nr=kt,kt=p(Qe,30),Qe=ve,ve=Ze}this.h[0]=h(this.h[0],ve),this.h[1]=h(this.h[1],Qe),this.h[2]=h(this.h[2],kt),this.h[3]=h(this.h[3],nr),this.h[4]=h(this.h[4],sr)},E.prototype._digest=function(B){return B==="hex"?f.toHex32(this.h,"big"):f.split32(this.h,"big")}},799:(u,a,s)=>{var f=s(6436),c=s(9344);function d(){if(!(this instanceof d))return new d;c.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}f.inherits(d,c),u.exports=d,d.blockSize=512,d.outSize=224,d.hmacStrength=192,d.padLength=64,d.prototype._digest=function(p){return p==="hex"?f.toHex32(this.h.slice(0,7),"big"):f.split32(this.h.slice(0,7),"big")}},9344:(u,a,s)=>{var f=s(6436),c=s(5772),d=s(7038),p=s(9746),h=f.sum32,y=f.sum32_4,b=f.sum32_5,w=d.ch32,S=d.maj32,E=d.s0_256,B=d.s1_256,ae=d.g0_256,W=d.g1_256,J=c.BlockHash,ve=[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];function Qe(){if(!(this instanceof Qe))return new Qe;J.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=ve,this.W=new Array(64)}f.inherits(Qe,J),u.exports=Qe,Qe.blockSize=512,Qe.outSize=256,Qe.hmacStrength=192,Qe.padLength=64,Qe.prototype._update=function(kt,nr){for(var sr=this.W,ce=0;ce<16;ce++)sr[ce]=kt[nr+ce];for(;ce<sr.length;ce++)sr[ce]=y(W(sr[ce-2]),sr[ce-7],ae(sr[ce-15]),sr[ce-16]);var Ze=this.h[0],se=this.h[1],vt=this.h[2],ur=this.h[3],ue=this.h[4],bt=this.h[5],L=this.h[6],_=this.h[7];for(p(this.k.length===sr.length),ce=0;ce<sr.length;ce++){var F=b(_,B(ue),w(ue,bt,L),this.k[ce],sr[ce]),k=h(E(Ze),S(Ze,se,vt));_=L,L=bt,bt=ue,ue=h(ur,F),ur=vt,vt=se,se=Ze,Ze=h(F,k)}this.h[0]=h(this.h[0],Ze),this.h[1]=h(this.h[1],se),this.h[2]=h(this.h[2],vt),this.h[3]=h(this.h[3],ur),this.h[4]=h(this.h[4],ue),this.h[5]=h(this.h[5],bt),this.h[6]=h(this.h[6],L),this.h[7]=h(this.h[7],_)},Qe.prototype._digest=function(kt){return kt==="hex"?f.toHex32(this.h,"big"):f.split32(this.h,"big")}},772:(u,a,s)=>{var f=s(6436),c=s(5900);function d(){if(!(this instanceof d))return new d;c.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}f.inherits(d,c),u.exports=d,d.blockSize=1024,d.outSize=384,d.hmacStrength=192,d.padLength=128,d.prototype._digest=function(p){return p==="hex"?f.toHex32(this.h.slice(0,12),"big"):f.split32(this.h.slice(0,12),"big")}},5900:(u,a,s)=>{var f=s(6436),c=s(5772),d=s(9746),p=f.rotr64_hi,h=f.rotr64_lo,y=f.shr64_hi,b=f.shr64_lo,w=f.sum64,S=f.sum64_hi,E=f.sum64_lo,B=f.sum64_4_hi,ae=f.sum64_4_lo,W=f.sum64_5_hi,J=f.sum64_5_lo,ve=c.BlockHash,Qe=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function kt(){if(!(this instanceof kt))return new kt;ve.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=Qe,this.W=new Array(160)}function nr(_,F,k,Ye,rn){var ii=_&k^~_&rn;return ii<0&&(ii+=4294967296),ii}function sr(_,F,k,Ye,rn,ii){var ai=F&Ye^~F&ii;return ai<0&&(ai+=4294967296),ai}function ce(_,F,k,Ye,rn){var ii=_&k^_&rn^k&rn;return ii<0&&(ii+=4294967296),ii}function Ze(_,F,k,Ye,rn,ii){var ai=F&Ye^F&ii^Ye&ii;return ai<0&&(ai+=4294967296),ai}function se(_,F){var k=p(_,F,28)^p(F,_,2)^p(F,_,7);return k<0&&(k+=4294967296),k}function vt(_,F){var k=h(_,F,28)^h(F,_,2)^h(F,_,7);return k<0&&(k+=4294967296),k}function ur(_,F){var k=h(_,F,14)^h(_,F,18)^h(F,_,9);return k<0&&(k+=4294967296),k}function ue(_,F){var k=p(_,F,1)^p(_,F,8)^y(_,F,7);return k<0&&(k+=4294967296),k}function bt(_,F){var k=h(_,F,1)^h(_,F,8)^b(_,F,7);return k<0&&(k+=4294967296),k}function L(_,F){var k=h(_,F,19)^h(F,_,29)^b(_,F,6);return k<0&&(k+=4294967296),k}f.inherits(kt,ve),u.exports=kt,kt.blockSize=1024,kt.outSize=512,kt.hmacStrength=192,kt.padLength=128,kt.prototype._prepareBlock=function(_,F){for(var k=this.W,Ye=0;Ye<32;Ye++)k[Ye]=_[F+Ye];for(;Ye<k.length;Ye+=2){var rn=(jr=k[Ye-4],ci=k[Ye-3],mi=void 0,(mi=p(jr,ci,19)^p(ci,jr,29)^y(jr,ci,6))<0&&(mi+=4294967296),mi),ii=L(k[Ye-4],k[Ye-3]),ai=k[Ye-14],ni=k[Ye-13],ri=ue(k[Ye-30],k[Ye-29]),ui=bt(k[Ye-30],k[Ye-29]),lr=k[Ye-32],ar=k[Ye-31];k[Ye]=B(rn,ii,ai,ni,ri,ui,lr,ar),k[Ye+1]=ae(rn,ii,ai,ni,ri,ui,lr,ar)}var jr,ci,mi},kt.prototype._update=function(_,F){this._prepareBlock(_,F);var k,Ye,rn,ii=this.W,ai=this.h[0],ni=this.h[1],ri=this.h[2],ui=this.h[3],lr=this.h[4],ar=this.h[5],jr=this.h[6],ci=this.h[7],mi=this.h[8],pi=this.h[9],ei=this.h[10],Gr=this.h[11],ti=this.h[12],fi=this.h[13],bi=this.h[14],Ai=this.h[15];d(this.k.length===ii.length);for(var Bi=0;Bi<ii.length;Bi+=2){var qi=bi,vn=Ai,di=(rn=void 0,(rn=p(k=mi,Ye=pi,14)^p(k,Ye,18)^p(Ye,k,9))<0&&(rn+=4294967296),rn),rr=ur(mi,pi),on=nr(mi,0,ei,0,ti),si=sr(0,pi,0,Gr,0,fi),vi=this.k[Bi],Ei=this.k[Bi+1],Mi=ii[Bi],Di=ii[Bi+1],Ii=W(qi,vn,di,rr,on,si,vi,Ei,Mi,Di),Ci=J(qi,vn,di,rr,on,si,vi,Ei,Mi,Di);qi=se(ai,ni),vn=vt(ai,ni),di=ce(ai,0,ri,0,lr),rr=Ze(0,ni,0,ui,0,ar);var Vi=S(qi,vn,di,rr),Hi=E(qi,vn,di,rr);bi=ti,Ai=fi,ti=ei,fi=Gr,ei=mi,Gr=pi,mi=S(jr,ci,Ii,Ci),pi=E(ci,ci,Ii,Ci),jr=lr,ci=ar,lr=ri,ar=ui,ri=ai,ui=ni,ai=S(Ii,Ci,Vi,Hi),ni=E(Ii,Ci,Vi,Hi)}w(this.h,0,ai,ni),w(this.h,2,ri,ui),w(this.h,4,lr,ar),w(this.h,6,jr,ci),w(this.h,8,mi,pi),w(this.h,10,ei,Gr),w(this.h,12,ti,fi),w(this.h,14,bi,Ai)},kt.prototype._digest=function(_){return _==="hex"?f.toHex32(this.h,"big"):f.split32(this.h,"big")}},7038:(u,a,s)=>{var f=s(6436).rotr32;function c(h,y,b){return h&y^~h&b}function d(h,y,b){return h&y^h&b^y&b}function p(h,y,b){return h^y^b}a.ft_1=function(h,y,b,w){return h===0?c(y,b,w):h===1||h===3?p(y,b,w):h===2?d(y,b,w):void 0},a.ch32=c,a.maj32=d,a.p32=p,a.s0_256=function(h){return f(h,2)^f(h,13)^f(h,22)},a.s1_256=function(h){return f(h,6)^f(h,11)^f(h,25)},a.g0_256=function(h){return f(h,7)^f(h,18)^h>>>3},a.g1_256=function(h){return f(h,17)^f(h,19)^h>>>10}},6436:(u,a,s)=>{var f=s(9746),c=s(5717);function d(b,w){return(64512&b.charCodeAt(w))==55296&&!(w<0||w+1>=b.length)&&(64512&b.charCodeAt(w+1))==56320}function p(b){return(b>>>24|b>>>8&65280|b<<8&16711680|(255&b)<<24)>>>0}function h(b){return b.length===1?"0"+b:b}function y(b){return b.length===7?"0"+b:b.length===6?"00"+b:b.length===5?"000"+b:b.length===4?"0000"+b:b.length===3?"00000"+b:b.length===2?"000000"+b:b.length===1?"0000000"+b:b}a.inherits=c,a.toArray=function(b,w){if(Array.isArray(b))return b.slice();if(!b)return[];var S=[];if(typeof b=="string")if(w){if(w==="hex")for((b=b.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(b="0"+b),B=0;B<b.length;B+=2)S.push(parseInt(b[B]+b[B+1],16))}else for(var E=0,B=0;B<b.length;B++){var ae=b.charCodeAt(B);ae<128?S[E++]=ae:ae<2048?(S[E++]=ae>>6|192,S[E++]=63&ae|128):d(b,B)?(ae=65536+((1023&ae)<<10)+(1023&b.charCodeAt(++B)),S[E++]=ae>>18|240,S[E++]=ae>>12&63|128,S[E++]=ae>>6&63|128,S[E++]=63&ae|128):(S[E++]=ae>>12|224,S[E++]=ae>>6&63|128,S[E++]=63&ae|128)}else for(B=0;B<b.length;B++)S[B]=0|b[B];return S},a.toHex=function(b){for(var w="",S=0;S<b.length;S++)w+=h(b[S].toString(16));return w},a.htonl=p,a.toHex32=function(b,w){for(var S="",E=0;E<b.length;E++){var B=b[E];w==="little"&&(B=p(B)),S+=y(B.toString(16))}return S},a.zero2=h,a.zero8=y,a.join32=function(b,w,S,E){var B=S-w;f(B%4==0);for(var ae=new Array(B/4),W=0,J=w;W<ae.length;W++,J+=4){var ve;ve=E==="big"?b[J]<<24|b[J+1]<<16|b[J+2]<<8|b[J+3]:b[J+3]<<24|b[J+2]<<16|b[J+1]<<8|b[J],ae[W]=ve>>>0}return ae},a.split32=function(b,w){for(var S=new Array(4*b.length),E=0,B=0;E<b.length;E++,B+=4){var ae=b[E];w==="big"?(S[B]=ae>>>24,S[B+1]=ae>>>16&255,S[B+2]=ae>>>8&255,S[B+3]=255&ae):(S[B+3]=ae>>>24,S[B+2]=ae>>>16&255,S[B+1]=ae>>>8&255,S[B]=255&ae)}return S},a.rotr32=function(b,w){return b>>>w|b<<32-w},a.rotl32=function(b,w){return b<<w|b>>>32-w},a.sum32=function(b,w){return b+w>>>0},a.sum32_3=function(b,w,S){return b+w+S>>>0},a.sum32_4=function(b,w,S,E){return b+w+S+E>>>0},a.sum32_5=function(b,w,S,E,B){return b+w+S+E+B>>>0},a.sum64=function(b,w,S,E){var B=b[w],ae=E+b[w+1]>>>0,W=(ae<E?1:0)+S+B;b[w]=W>>>0,b[w+1]=ae},a.sum64_hi=function(b,w,S,E){return(w+E>>>0<w?1:0)+b+S>>>0},a.sum64_lo=function(b,w,S,E){return w+E>>>0},a.sum64_4_hi=function(b,w,S,E,B,ae,W,J){var ve=0,Qe=w;return ve+=(Qe=Qe+E>>>0)<w?1:0,ve+=(Qe=Qe+ae>>>0)<ae?1:0,b+S+B+W+(ve+=(Qe=Qe+J>>>0)<J?1:0)>>>0},a.sum64_4_lo=function(b,w,S,E,B,ae,W,J){return w+E+ae+J>>>0},a.sum64_5_hi=function(b,w,S,E,B,ae,W,J,ve,Qe){var kt=0,nr=w;return kt+=(nr=nr+E>>>0)<w?1:0,kt+=(nr=nr+ae>>>0)<ae?1:0,kt+=(nr=nr+J>>>0)<J?1:0,b+S+B+W+ve+(kt+=(nr=nr+Qe>>>0)<Qe?1:0)>>>0},a.sum64_5_lo=function(b,w,S,E,B,ae,W,J,ve,Qe){return w+E+ae+J+Qe>>>0},a.rotr64_hi=function(b,w,S){return(w<<32-S|b>>>S)>>>0},a.rotr64_lo=function(b,w,S){return(b<<32-S|w>>>S)>>>0},a.shr64_hi=function(b,w,S){return b>>>S},a.shr64_lo=function(b,w,S){return(b<<32-S|w>>>S)>>>0}},2156:(u,a,s)=>{var f=s(3715),c=s(4504),d=s(9746);function p(h){if(!(this instanceof p))return new p(h);this.hash=h.hash,this.predResist=!!h.predResist,this.outLen=this.hash.outSize,this.minEntropy=h.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var y=c.toArray(h.entropy,h.entropyEnc||"hex"),b=c.toArray(h.nonce,h.nonceEnc||"hex"),w=c.toArray(h.pers,h.persEnc||"hex");d(y.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(y,b,w)}u.exports=p,p.prototype._init=function(h,y,b){var w=h.concat(y).concat(b);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var S=0;S<this.V.length;S++)this.K[S]=0,this.V[S]=1;this._update(w),this._reseed=1,this.reseedInterval=281474976710656},p.prototype._hmac=function(){return new f.hmac(this.hash,this.K)},p.prototype._update=function(h){var y=this._hmac().update(this.V).update([0]);h&&(y=y.update(h)),this.K=y.digest(),this.V=this._hmac().update(this.V).digest(),h&&(this.K=this._hmac().update(this.V).update([1]).update(h).digest(),this.V=this._hmac().update(this.V).digest())},p.prototype.reseed=function(h,y,b,w){typeof y!="string"&&(w=b,b=y,y=null),h=c.toArray(h,y),b=c.toArray(b,w),d(h.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(h.concat(b||[])),this._reseed=1},p.prototype.generate=function(h,y,b,w){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof y!="string"&&(w=b,b=y,y=null),b&&(b=c.toArray(b,w||"hex"),this._update(b));for(var S=[];S.length<h;)this.V=this._hmac().update(this.V).digest(),S=S.concat(this.V);var E=S.slice(0,h);return this._update(b),this._reseed++,c.encode(E,y)}},645:(u,a)=>{a.read=function(s,f,c,d,p){var h,y,b=8*p-d-1,w=(1<<b)-1,S=w>>1,E=-7,B=c?p-1:0,ae=c?-1:1,W=s[f+B];for(B+=ae,h=W&(1<<-E)-1,W>>=-E,E+=b;E>0;h=256*h+s[f+B],B+=ae,E-=8);for(y=h&(1<<-E)-1,h>>=-E,E+=d;E>0;y=256*y+s[f+B],B+=ae,E-=8);if(h===0)h=1-S;else{if(h===w)return y?NaN:1/0*(W?-1:1);y+=Math.pow(2,d),h-=S}return(W?-1:1)*y*Math.pow(2,h-d)},a.write=function(s,f,c,d,p,h){var y,b,w,S=8*h-p-1,E=(1<<S)-1,B=E>>1,ae=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,W=d?0:h-1,J=d?1:-1,ve=f<0||f===0&&1/f<0?1:0;for(f=Math.abs(f),isNaN(f)||f===1/0?(b=isNaN(f)?1:0,y=E):(y=Math.floor(Math.log(f)/Math.LN2),f*(w=Math.pow(2,-y))<1&&(y--,w*=2),(f+=y+B>=1?ae/w:ae*Math.pow(2,1-B))*w>=2&&(y++,w/=2),y+B>=E?(b=0,y=E):y+B>=1?(b=(f*w-1)*Math.pow(2,p),y+=B):(b=f*Math.pow(2,B-1)*Math.pow(2,p),y=0));p>=8;s[c+W]=255&b,W+=J,b/=256,p-=8);for(y=y<<p|b,S+=p;S>0;s[c+W]=255&y,W+=J,y/=256,S-=8);s[c+W-J]|=128*ve}},5717:u=>{typeof Object.create=="function"?u.exports=function(a,s){s&&(a.super_=s,a.prototype=Object.create(s.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:u.exports=function(a,s){if(s){a.super_=s;var f=function(){};f.prototype=s.prototype,a.prototype=new f,a.prototype.constructor=a}}},6486:function(u,a,s){var f;u=s.nmd(u),(function(){var c,d="Expected a function",p="__lodash_hash_undefined__",h="__lodash_placeholder__",y=32,b=128,w=1/0,S=9007199254740991,E=NaN,B=4294967295,ae=[["ary",b],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",y],["partialRight",64],["rearg",256]],W="[object Arguments]",J="[object Array]",ve="[object Boolean]",Qe="[object Date]",kt="[object Error]",nr="[object Function]",sr="[object GeneratorFunction]",ce="[object Map]",Ze="[object Number]",se="[object Object]",vt="[object Promise]",ur="[object RegExp]",ue="[object Set]",bt="[object String]",L="[object Symbol]",_="[object WeakMap]",F="[object ArrayBuffer]",k="[object DataView]",Ye="[object Float32Array]",rn="[object Float64Array]",ii="[object Int8Array]",ai="[object Int16Array]",ni="[object Int32Array]",ri="[object Uint8Array]",ui="[object Uint8ClampedArray]",lr="[object Uint16Array]",ar="[object Uint32Array]",jr=/\b__p \+= '';/g,ci=/\b(__p \+=) '' \+/g,mi=/(__e\(.*?\)|\b__t\)) \+\n'';/g,pi=/&(?:amp|lt|gt|quot|#39);/g,ei=/[&<>"']/g,Gr=RegExp(pi.source),ti=RegExp(ei.source),fi=/<%-([\s\S]+?)%>/g,bi=/<%([\s\S]+?)%>/g,Ai=/<%=([\s\S]+?)%>/g,Bi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,qi=/^\w*$/,vn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,di=/[\\^$.*+?()[\]{}|]/g,rr=RegExp(di.source),on=/^\s+/,si=/\s/,vi=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ei=/\{\n\/\* \[wrapped with (.+)\] \*/,Mi=/,? & /,Di=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ii=/[()=,{}\[\]\/\s]/,Ci=/\\(\\)?/g,Vi=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Hi=/\w*$/,Ji=/^[-+]0x[0-9a-f]+$/i,no=/^0b[01]+$/i,co=/^\[object .+?Constructor\]$/,Fo=/^0o[0-7]+$/i,Io=/^(?:0|[1-9]\d*)$/,Ro=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Oo=/($^)/,To=/['\n\r\u2028\u2029\\]/g,Po="\\ud800-\\udfff",ia="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Jo="\\u2700-\\u27bf",ea="a-z\\xdf-\\xf6\\xf8-\\xff",zi="A-Z\\xc0-\\xd6\\xd8-\\xde",Gi="\\ufe0e\\ufe0f",uo="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",wo="["+Po+"]",xi="["+uo+"]",Fi="["+ia+"]",Ui="\\d+",gi="["+Jo+"]",Li="["+ea+"]",Qi="[^"+Po+uo+Ui+Jo+ea+zi+"]",Wi="\\ud83c[\\udffb-\\udfff]",io="[^"+Po+"]",lo="(?:\\ud83c[\\udde6-\\uddff]){2}",Ao="[\\ud800-\\udbff][\\udc00-\\udfff]",_o="["+zi+"]",ca="\\u200d",Co="(?:"+Li+"|"+Qi+")",$o="(?:"+_o+"|"+Qi+")",ta="(?:['’](?:d|ll|m|re|s|t|ve))?",sa="(?:['’](?:D|LL|M|RE|S|T|VE))?",ga="(?:"+Fi+"|"+Wi+")?",ya="["+Gi+"]?",ma=ya+ga+"(?:"+ca+"(?:"+[io,lo,Ao].join("|")+")"+ya+ga+")*",fa="(?:"+[gi,lo,Ao].join("|")+")"+ma,ra="(?:"+[io+Fi+"?",Fi,lo,Ao,wo].join("|")+")",ha=RegExp("['’]","g"),Wo=RegExp(Fi,"g"),na=RegExp(Wi+"(?="+Wi+")|"+ra+ma,"g"),la=RegExp([_o+"?"+Li+"+"+ta+"(?="+[xi,_o,"$"].join("|")+")",$o+"+"+sa+"(?="+[xi,_o+Co,"$"].join("|")+")",_o+"?"+Co+"+"+ta,_o+"+"+sa,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ui,fa].join("|"),"g"),Yo=RegExp("["+ca+Po+ia+Gi+"]"),ho=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,yo=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],No=-1,vo={};vo[Ye]=vo[rn]=vo[ii]=vo[ai]=vo[ni]=vo[ri]=vo[ui]=vo[lr]=vo[ar]=!0,vo[W]=vo[J]=vo[F]=vo[ve]=vo[k]=vo[Qe]=vo[kt]=vo[nr]=vo[ce]=vo[Ze]=vo[se]=vo[ur]=vo[ue]=vo[bt]=vo[_]=!1;var bo={};bo[W]=bo[J]=bo[F]=bo[k]=bo[ve]=bo[Qe]=bo[Ye]=bo[rn]=bo[ii]=bo[ai]=bo[ni]=bo[ce]=bo[Ze]=bo[se]=bo[ur]=bo[ue]=bo[bt]=bo[L]=bo[ri]=bo[ui]=bo[lr]=bo[ar]=!0,bo[kt]=bo[nr]=bo[_]=!1;var Uo={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Aa=parseFloat,Ua=parseInt,Fa=typeof s.g=="object"&&s.g&&s.g.Object===Object&&s.g,qa=typeof self=="object"&&self&&self.Object===Object&&self,Yi=Fa||qa||Function("return this")(),Xa=a&&!a.nodeType&&a,ka=Xa&&u&&!u.nodeType&&u,Qa=ka&&ka.exports===Xa,za=Qa&&Fa.process,Na=(function(){try{return ka&&ka.require&&ka.require("util").types||za&&za.binding&&za.binding("util")}catch{}})(),Wa=Na&&Na.isArrayBuffer,Ms=Na&&Na.isDate,ss=Na&&Na.isMap,ys=Na&&Na.isRegExp,Bs=Na&&Na.isSet,Ss=Na&&Na.isTypedArray;function rs(Eo,Zo,qo){switch(qo.length){case 0:return Eo.call(Zo);case 1:return Eo.call(Zo,qo[0]);case 2:return Eo.call(Zo,qo[0],qo[1]);case 3:return Eo.call(Zo,qo[0],qo[1],qo[2])}return Eo.apply(Zo,qo)}function Zs(Eo,Zo,qo,pa){for(var Ha=-1,ns=Eo==null?0:Eo.length;++Ha<ns;){var Gs=Eo[Ha];Zo(pa,Gs,qo(Gs),Eo)}return pa}function vs(Eo,Zo){for(var qo=-1,pa=Eo==null?0:Eo.length;++qo<pa&&Zo(Eo[qo],qo,Eo)!==!1;);return Eo}function uu(Eo,Zo){for(var qo=Eo==null?0:Eo.length;qo--&&Zo(Eo[qo],qo,Eo)!==!1;);return Eo}function Z0(Eo,Zo){for(var qo=-1,pa=Eo==null?0:Eo.length;++qo<pa;)if(!Zo(Eo[qo],qo,Eo))return!1;return!0}function mu(Eo,Zo){for(var qo=-1,pa=Eo==null?0:Eo.length,Ha=0,ns=[];++qo<pa;){var Gs=Eo[qo];Zo(Gs,qo,Eo)&&(ns[Ha++]=Gs)}return ns}function Ah(Eo,Zo){return!(Eo==null||!Eo.length)&&Gl(Eo,Zo,0)>-1}function G0(Eo,Zo,qo){for(var pa=-1,Ha=Eo==null?0:Eo.length;++pa<Ha;)if(qo(Zo,Eo[pa]))return!0;return!1}function ws(Eo,Zo){for(var qo=-1,pa=Eo==null?0:Eo.length,Ha=Array(pa);++qo<pa;)Ha[qo]=Zo(Eo[qo],qo,Eo);return Ha}function Tf(Eo,Zo){for(var qo=-1,pa=Zo.length,Ha=Eo.length;++qo<pa;)Eo[Ha+qo]=Zo[qo];return Eo}function Xp(Eo,Zo,qo,pa){var Ha=-1,ns=Eo==null?0:Eo.length;for(pa&&ns&&(qo=Eo[++Ha]);++Ha<ns;)qo=Zo(qo,Eo[Ha],Ha,Eo);return qo}function _m(Eo,Zo,qo,pa){var Ha=Eo==null?0:Eo.length;for(pa&&Ha&&(qo=Eo[--Ha]);Ha--;)qo=Zo(qo,Eo[Ha],Ha,Eo);return qo}function Wp(Eo,Zo){for(var qo=-1,pa=Eo==null?0:Eo.length;++qo<pa;)if(Zo(Eo[qo],qo,Eo))return!0;return!1}var $0=Qp("length");function Zl(Eo,Zo,qo){var pa;return qo(Eo,(function(Ha,ns,Gs){if(Zo(Ha,ns,Gs))return pa=ns,!1})),pa}function Sh(Eo,Zo,qo,pa){for(var Ha=Eo.length,ns=qo+(pa?1:-1);pa?ns--:++ns<Ha;)if(Zo(Eo[ns],ns,Eo))return ns;return-1}function Gl(Eo,Zo,qo){return Zo==Zo?(function(pa,Ha,ns){for(var Gs=ns-1,$l=pa.length;++Gs<$l;)if(pa[Gs]===Ha)return Gs;return-1})(Eo,Zo,qo):Sh(Eo,Yp,qo)}function _d(Eo,Zo,qo,pa){for(var Ha=qo-1,ns=Eo.length;++Ha<ns;)if(pa(Eo[Ha],Zo))return Ha;return-1}function Yp(Eo){return Eo!=Eo}function X0(Eo,Zo){var qo=Eo==null?0:Eo.length;return qo?Jp(Eo,Zo)/qo:E}function Qp(Eo){return function(Zo){return Zo==null?c:Zo[Eo]}}function Ih(Eo){return function(Zo){return Eo==null?c:Eo[Zo]}}function W0(Eo,Zo,qo,pa,Ha){return Ha(Eo,(function(ns,Gs,$l){qo=pa?(pa=!1,ns):Zo(qo,ns,Gs,$l)})),qo}function Jp(Eo,Zo){for(var qo,pa=-1,Ha=Eo.length;++pa<Ha;){var ns=Zo(Eo[pa]);ns!==c&&(qo=qo===c?ns:qo+ns)}return qo}function gu(Eo,Zo){for(var qo=-1,pa=Array(Eo);++qo<Eo;)pa[qo]=Zo(qo);return pa}function Td(Eo){return Eo&&Eo.slice(0,Rm(Eo)+1).replace(on,"")}function bu(Eo){return function(Zo){return Eo(Zo)}}function Jd(Eo,Zo){return ws(Zo,(function(qo){return Eo[qo]}))}function Q0(Eo,Zo){return Eo.has(Zo)}function z1(Eo,Zo){for(var qo=-1,pa=Eo.length;++qo<pa&&Gl(Zo,Eo[qo],0)>-1;);return qo}function K1(Eo,Zo){for(var qo=Eo.length;qo--&&Gl(Zo,Eo[qo],0)>-1;);return qo}function J0(Eo,Zo){for(var qo=Eo.length,pa=0;qo--;)Eo[qo]===Zo&&++pa;return pa}var ey=Ih({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),r3=Ih({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function T6(Eo){return"\\"+Uo[Eo]}function _h(Eo){return Yo.test(Eo)}function Tm(Eo){var Zo=-1,qo=Array(Eo.size);return Eo.forEach((function(pa,Ha){qo[++Zo]=[Ha,pa]})),qo}function ty(Eo,Zo){return function(qo){return Eo(Zo(qo))}}function Rd(Eo,Zo){for(var qo=-1,pa=Eo.length,Ha=0,ns=[];++qo<pa;){var Gs=Eo[qo];Gs!==Zo&&Gs!==h||(Eo[qo]=h,ns[Ha++]=qo)}return ns}function ry(Eo){var Zo=-1,qo=Array(Eo.size);return Eo.forEach((function(pa){qo[++Zo]=pa})),qo}function R6(Eo){var Zo=-1,qo=Array(Eo.size);return Eo.forEach((function(pa){qo[++Zo]=[pa,pa]})),qo}function Th(Eo){return _h(Eo)?(function(Zo){for(var qo=na.lastIndex=0;na.test(Zo);)++qo;return qo})(Eo):$0(Eo)}function Wf(Eo){return _h(Eo)?(function(Zo){return Zo.match(na)||[]})(Eo):(function(Zo){return Zo.split("")})(Eo)}function Rm(Eo){for(var Zo=Eo.length;Zo--&&si.test(Eo.charAt(Zo)););return Zo}var M6=Ih({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),oy=(function Eo(Zo){var qo,pa=(Zo=Zo==null?Yi:oy.defaults(Yi.Object(),Zo,oy.pick(Yi,yo))).Array,Ha=Zo.Date,ns=Zo.Error,Gs=Zo.Function,$l=Zo.Math,Os=Zo.Object,Mm=Zo.RegExp,B6=Zo.String,Df=Zo.TypeError,ay=pa.prototype,O6=Gs.prototype,Rh=Os.prototype,fy=Zo["__core-js_shared__"],Mh=O6.toString,fs=Rh.hasOwnProperty,C6=0,Bm=(qo=/[^.]+$/.exec(fy&&fy.keys&&fy.keys.IE_PROTO||""))?"Symbol(src)_1."+qo:"",ep=Rh.toString,n3=Mh.call(Os),i3=Yi._,o3=Mm("^"+Mh.call(fs).replace(di,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),cd=Qa?Zo.Buffer:c,Md=Zo.Symbol,ly=Zo.Uint8Array,a3=cd?cd.allocUnsafe:c,tp=ty(Os.getPrototypeOf,Os),Om=Os.create,Bh=Rh.propertyIsEnumerable,Bd=ay.splice,s3=Md?Md.isConcatSpreadable:c,Od=Md?Md.iterator:c,Cd=Md?Md.toStringTag:c,rp=(function(){try{var Xe=ja(Os,"defineProperty");return Xe({},"",{}),Xe}catch{}})(),Cm=Zo.clearTimeout!==Yi.clearTimeout&&Zo.clearTimeout,Fm=Ha&&Ha.now!==Yi.Date.now&&Ha.now,u3=Zo.setTimeout!==Yi.setTimeout&&Zo.setTimeout,np=$l.ceil,ip=$l.floor,Pm=Os.getOwnPropertySymbols,F6=cd?cd.isBuffer:c,f3=Zo.isFinite,P6=ay.join,k6=ty(Os.keys,Os),ps=$l.max,$s=$l.min,c3=Ha.now,l3=Zo.parseInt,km=$l.random,d3=ay.reverse,op=ja(Zo,"DataView"),ap=ja(Zo,"Map"),Fd=ja(Zo,"Promise"),Pd=ja(Zo,"Set"),ld=ja(Zo,"WeakMap"),eh=ja(Os,"create"),sp=ld&&new ld,Uf={},Oh=$d(op),Nm=$d(ap),h3=$d(Fd),th=$d(Pd),p3=$d(ld),up=Md?Md.prototype:c,Ch=up?up.valueOf:c,y3=up?up.toString:c;function Zi(Xe){if(ks(Xe)&&!Ka(Xe)&&!(Xe instanceof Ja)){if(Xe instanceof Rf)return Xe;if(fs.call(Xe,"__wrapped__"))return Wm(Xe)}return new Rf(Xe)}var Fh=(function(){function Xe(){}return function(qr){if(!Ds(qr))return{};if(Om)return Om(qr);Xe.prototype=qr;var hi=new Xe;return Xe.prototype=c,hi}})();function fp(){}function Rf(Xe,qr){this.__wrapped__=Xe,this.__actions__=[],this.__chain__=!!qr,this.__index__=0,this.__values__=c}function Ja(Xe){this.__wrapped__=Xe,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=B,this.__views__=[]}function du(Xe){var qr=-1,hi=Xe==null?0:Xe.length;for(this.clear();++qr<hi;){var Si=Xe[qr];this.set(Si[0],Si[1])}}function jf(Xe){var qr=-1,hi=Xe==null?0:Xe.length;for(this.clear();++qr<hi;){var Si=Xe[qr];this.set(Si[0],Si[1])}}function Xs(Xe){var qr=-1,hi=Xe==null?0:Xe.length;for(this.clear();++qr<hi;){var Si=Xe[qr];this.set(Si[0],Si[1])}}function Lf(Xe){var qr=-1,hi=Xe==null?0:Xe.length;for(this.__data__=new Xs;++qr<hi;)this.add(Xe[qr])}function Mf(Xe){var qr=this.__data__=new jf(Xe);this.size=qr.size}function cp(Xe,qr){var hi=Ka(Xe),Si=!hi&&Yd(Xe),ji=!hi&&!Si&&vd(Xe),Xi=!hi&&!Si&&!ji&&mh(Xe),eo=hi||Si||ji||Xi,oo=eo?gu(Xe.length,B6):[],po=oo.length;for(var jo in Xe)!qr&&!fs.call(Xe,jo)||eo&&(jo=="length"||ji&&(jo=="offset"||jo=="parent")||Xi&&(jo=="buffer"||jo=="byteLength"||jo=="byteOffset")||Pf(jo,po))||oo.push(jo);return oo}function lp(Xe){var qr=Xe.length;return qr?Xe[hp(0,qr-1)]:c}function Dm(Xe,qr){return Xh(Tu(Xe),Nd(qr,0,Xe.length))}function rh(Xe){return Xh(Tu(Xe))}function py(Xe,qr,hi){(hi!==c&&!Gf(Xe[qr],hi)||hi===c&&!(qr in Xe))&&Yf(Xe,qr,hi)}function kd(Xe,qr,hi){var Si=Xe[qr];fs.call(Xe,qr)&&Gf(Si,hi)&&(hi!==c||qr in Xe)||Yf(Xe,qr,hi)}function dd(Xe,qr){for(var hi=Xe.length;hi--;)if(Gf(Xe[hi][0],qr))return hi;return-1}function N6(Xe,qr,hi,Si){return Xl(Xe,(function(ji,Xi,eo){qr(Si,ji,hi(ji),eo)})),Si}function ju(Xe,qr){return Xe&&Bu(qr,su(qr),Xe)}function Yf(Xe,qr,hi){qr=="__proto__"&&rp?rp(Xe,qr,{configurable:!0,enumerable:!0,value:hi,writable:!0}):Xe[qr]=hi}function Qf(Xe,qr){for(var hi=-1,Si=qr.length,ji=pa(Si),Xi=Xe==null;++hi<Si;)ji[hi]=Xi?c:Dp(Xe,qr[hi]);return ji}function Nd(Xe,qr,hi){return Xe==Xe&&(hi!==c&&(Xe=Xe<=hi?Xe:hi),qr!==c&&(Xe=Xe>=qr?Xe:qr)),Xe}function Iu(Xe,qr,hi,Si,ji,Xi){var eo,oo=1&qr,po=2&qr,jo=4&qr;if(hi&&(eo=ji?hi(Xe,Si,ji,Xi):hi(Xe)),eo!==c)return eo;if(!Ds(Xe))return Xe;var Ho=Ka(Xe);if(Ho){if(eo=(function(Mo){var Lo=Mo.length,ua=new Mo.constructor(Lo);return Lo&&typeof Mo[0]=="string"&&fs.call(Mo,"index")&&(ua.index=Mo.index,ua.input=Mo.input),ua})(Xe),!oo)return Tu(Xe,eo)}else{var Xo=iu(Xe),va=Xo==nr||Xo==sr;if(vd(Xe))return xp(Xe,oo);if(Xo==se||Xo==W||va&&!ji){if(eo=po||va?{}:Gd(Xe),!oo)return po?(function(Mo,Lo){return Bu(Mo,Vs(Mo),Lo)})(Xe,(function(Mo,Lo){return Mo&&Bu(Lo,Ls(Lo),Mo)})(eo,Xe)):(function(Mo,Lo){return Bu(Mo,ms(Mo),Lo)})(Xe,ju(eo,Xe))}else{if(!bo[Xo])return ji?Xe:{};eo=(function(Mo,Lo,ua){var Go,da=Mo.constructor;switch(Lo){case F:return Fy(Mo);case ve:case Qe:return new da(+Mo);case k:return(function(Ta,Ga){var _a=Ga?Fy(Ta.buffer):Ta.buffer;return new Ta.constructor(_a,Ta.byteOffset,Ta.byteLength)})(Mo,ua);case Ye:case rn:case ii:case ai:case ni:case ri:case ui:case lr:case ar:return Lm(Mo,ua);case ce:return new da;case Ze:case bt:return new da(Mo);case ur:return(function(Ta){var Ga=new Ta.constructor(Ta.source,Hi.exec(Ta));return Ga.lastIndex=Ta.lastIndex,Ga})(Mo);case ue:return new da;case L:return Go=Mo,Ch?Os(Ch.call(Go)):{}}})(Xe,Xo,oo)}}Xi||(Xi=new Mf);var xa=Xi.get(Xe);if(xa)return xa;Xi.set(Xe,eo),Bg(Xe)?Xe.forEach((function(Mo){eo.add(Iu(Mo,qr,hi,Mo,Xe,Xi))})):Ks(Xe)&&Xe.forEach((function(Mo,Lo){eo.set(Lo,Iu(Mo,qr,hi,Lo,Xe,Xi))}));var Oa=Ho?c:(jo?po?Ap:id:po?Ls:su)(Xe);return vs(Oa||Xe,(function(Mo,Lo){Oa&&(Mo=Xe[Lo=Mo]),kd(eo,Lo,Iu(Mo,qr,hi,Lo,Xe,Xi))})),eo}function Dd(Xe,qr,hi){var Si=hi.length;if(Xe==null)return!Si;for(Xe=Os(Xe);Si--;){var ji=hi[Si],Xi=qr[ji],eo=Xe[ji];if(eo===c&&!(ji in Xe)||!Xi(eo))return!1}return!0}function yy(Xe,qr,hi){if(typeof Xe!="function")throw new Df(d);return Cs((function(){Xe.apply(c,hi)}),qr)}function Ph(Xe,qr,hi,Si){var ji=-1,Xi=Ah,eo=!0,oo=Xe.length,po=[],jo=qr.length;if(!oo)return po;hi&&(qr=ws(qr,bu(hi))),Si?(Xi=G0,eo=!1):qr.length>=200&&(Xi=Q0,eo=!1,qr=new Lf(qr));e:for(;++ji<oo;){var Ho=Xe[ji],Xo=hi==null?Ho:hi(Ho);if(Ho=Si||Ho!==0?Ho:0,eo&&Xo==Xo){for(var va=jo;va--;)if(qr[va]===Xo)continue e;po.push(Ho)}else Xi(qr,Xo,Si)||po.push(Ho)}return po}Zi.templateSettings={escape:fi,evaluate:bi,interpolate:Ai,variable:"",imports:{_:Zi}},Zi.prototype=fp.prototype,Zi.prototype.constructor=Zi,Rf.prototype=Fh(fp.prototype),Rf.prototype.constructor=Rf,Ja.prototype=Fh(fp.prototype),Ja.prototype.constructor=Ja,du.prototype.clear=function(){this.__data__=eh?eh(null):{},this.size=0},du.prototype.delete=function(Xe){var qr=this.has(Xe)&&delete this.__data__[Xe];return this.size-=qr?1:0,qr},du.prototype.get=function(Xe){var qr=this.__data__;if(eh){var hi=qr[Xe];return hi===p?c:hi}return fs.call(qr,Xe)?qr[Xe]:c},du.prototype.has=function(Xe){var qr=this.__data__;return eh?qr[Xe]!==c:fs.call(qr,Xe)},du.prototype.set=function(Xe,qr){var hi=this.__data__;return this.size+=this.has(Xe)?0:1,hi[Xe]=eh&&qr===c?p:qr,this},jf.prototype.clear=function(){this.__data__=[],this.size=0},jf.prototype.delete=function(Xe){var qr=this.__data__,hi=dd(qr,Xe);return!(hi<0||(hi==qr.length-1?qr.pop():Bd.call(qr,hi,1),--this.size,0))},jf.prototype.get=function(Xe){var qr=this.__data__,hi=dd(qr,Xe);return hi<0?c:qr[hi][1]},jf.prototype.has=function(Xe){return dd(this.__data__,Xe)>-1},jf.prototype.set=function(Xe,qr){var hi=this.__data__,Si=dd(hi,Xe);return Si<0?(++this.size,hi.push([Xe,qr])):hi[Si][1]=qr,this},Xs.prototype.clear=function(){this.size=0,this.__data__={hash:new du,map:new(ap||jf),string:new du}},Xs.prototype.delete=function(Xe){var qr=fh(this,Xe).delete(Xe);return this.size-=qr?1:0,qr},Xs.prototype.get=function(Xe){return fh(this,Xe).get(Xe)},Xs.prototype.has=function(Xe){return fh(this,Xe).has(Xe)},Xs.prototype.set=function(Xe,qr){var hi=fh(this,Xe),Si=hi.size;return hi.set(Xe,qr),this.size+=hi.size==Si?0:1,this},Lf.prototype.add=Lf.prototype.push=function(Xe){return this.__data__.set(Xe,p),this},Lf.prototype.has=function(Xe){return this.__data__.has(Xe)},Mf.prototype.clear=function(){this.__data__=new jf,this.size=0},Mf.prototype.delete=function(Xe){var qr=this.__data__,hi=qr.delete(Xe);return this.size=qr.size,hi},Mf.prototype.get=function(Xe){return this.__data__.get(Xe)},Mf.prototype.has=function(Xe){return this.__data__.has(Xe)},Mf.prototype.set=function(Xe,qr){var hi=this.__data__;if(hi instanceof jf){var Si=hi.__data__;if(!ap||Si.length<199)return Si.push([Xe,qr]),this.size=++hi.size,this;hi=this.__data__=new Xs(Si)}return hi.set(Xe,qr),this.size=hi.size,this};var Xl=jh(zs),Um=jh(Yl,!0);function qf(Xe,qr){var hi=!0;return Xl(Xe,(function(Si,ji,Xi){return hi=!!qr(Si,ji,Xi)})),hi}function hd(Xe,qr,hi){for(var Si=-1,ji=Xe.length;++Si<ji;){var Xi=Xe[Si],eo=qr(Xi);if(eo!=null&&(oo===c?eo==eo&&!hu(eo):hi(eo,oo)))var oo=eo,po=Xi}return po}function nh(Xe,qr){var hi=[];return Xl(Xe,(function(Si,ji,Xi){qr(Si,ji,Xi)&&hi.push(Si)})),hi}function Ws(Xe,qr,hi,Si,ji){var Xi=-1,eo=Xe.length;for(hi||(hi=Yy),ji||(ji=[]);++Xi<eo;){var oo=Xe[Xi];qr>0&&hi(oo)?qr>1?Ws(oo,qr-1,hi,Si,ji):Tf(ji,oo):Si||(ji[ji.length]=oo)}return ji}var ih=Ep(),Of=Ep(!0);function zs(Xe,qr){return Xe&&ih(Xe,qr,su)}function Yl(Xe,qr){return Xe&&Of(Xe,qr,su)}function Cf(Xe,qr){return mu(qr,(function(hi){return Ml(Xe[hi])}))}function vu(Xe,qr){for(var hi=0,Si=(qr=yd(qr,Xe)).length;Xe!=null&&hi<Si;)Xe=Xe[Zf(qr[hi++])];return hi&&hi==Si?Xe:c}function Jl(Xe,qr,hi){var Si=qr(Xe);return Ka(Xe)?Si:Tf(Si,hi(Xe))}function xu(Xe){return Xe==null?Xe===c?"[object Undefined]":"[object Null]":Cd&&Cd in Os(Xe)?(function(qr){var hi=fs.call(qr,Cd),Si=qr[Cd];try{qr[Cd]=c;var ji=!0}catch{}var Xi=ep.call(qr);return ji&&(hi?qr[Cd]=Si:delete qr[Cd]),Xi})(Xe):(function(qr){return ep.call(qr)})(Xe)}function dp(Xe,qr){return Xe>qr}function jm(Xe,qr){return Xe!=null&&fs.call(Xe,qr)}function m3(Xe,qr){return Xe!=null&&qr in Os(Xe)}function nu(Xe,qr,hi){for(var Si=hi?G0:Ah,ji=Xe[0].length,Xi=Xe.length,eo=Xi,oo=pa(Xi),po=1/0,jo=[];eo--;){var Ho=Xe[eo];eo&&qr&&(Ho=ws(Ho,bu(qr))),po=$s(Ho.length,po),oo[eo]=!hi&&(qr||ji>=120&&Ho.length>=120)?new Lf(eo&&Ho):c}Ho=Xe[0];var Xo=-1,va=oo[0];e:for(;++Xo<ji&&jo.length<po;){var xa=Ho[Xo],Oa=qr?qr(xa):xa;if(xa=hi||xa!==0?xa:0,!(va?Q0(va,Oa):Si(jo,Oa,hi))){for(eo=Xi;--eo;){var Mo=oo[eo];if(!(Mo?Q0(Mo,Oa):Si(Xe[eo],Oa,hi)))continue e}va&&va.push(Oa),jo.push(xa)}}return jo}function xs(Xe,qr,hi){var Si=(Xe=em(Xe,qr=yd(qr,Xe)))==null?Xe:Xe[Zf(Hu(qr))];return Si==null?c:rs(Si,Xe,hi)}function es(Xe){return ks(Xe)&&xu(Xe)==W}function zf(Xe,qr,hi,Si,ji){return Xe===qr||(Xe==null||qr==null||!ks(Xe)&&!ks(qr)?Xe!=Xe&&qr!=qr:(function(Xi,eo,oo,po,jo,Ho){var Xo=Ka(Xi),va=Ka(eo),xa=Xo?J:iu(Xi),Oa=va?J:iu(eo),Mo=(xa=xa==W?se:xa)==se,Lo=(Oa=Oa==W?se:Oa)==se,ua=xa==Oa;if(ua&&vd(Xi)){if(!vd(eo))return!1;Xo=!0,Mo=!1}if(ua&&!Mo)return Ho||(Ho=new Mf),Xo||mh(Xi)?qu(Xi,eo,oo,po,jo,Ho):(function(_a,Ca,Es,is,pu,Fs,Fl){switch(Es){case k:if(_a.byteLength!=Ca.byteLength||_a.byteOffset!=Ca.byteOffset)return!1;_a=_a.buffer,Ca=Ca.buffer;case F:return!(_a.byteLength!=Ca.byteLength||!Fs(new ly(_a),new ly(Ca)));case ve:case Qe:case Ze:return Gf(+_a,+Ca);case kt:return _a.name==Ca.name&&_a.message==Ca.message;case ur:case bt:return _a==Ca+"";case ce:var tu=Tm;case ue:var ad=1&is;if(tu||(tu=ry),_a.size!=Ca.size&&!ad)return!1;var Nl=Fl.get(_a);if(Nl)return Nl==Ca;is|=2,Fl.set(_a,Ca);var qs=qu(tu(_a),tu(Ca),is,pu,Fs,Fl);return Fl.delete(_a),qs;case L:if(Ch)return Ch.call(_a)==Ch.call(Ca)}return!1})(Xi,eo,xa,oo,po,jo,Ho);if(!(1&oo)){var Go=Mo&&fs.call(Xi,"__wrapped__"),da=Lo&&fs.call(eo,"__wrapped__");if(Go||da){var Ta=Go?Xi.value():Xi,Ga=da?eo.value():eo;return Ho||(Ho=new Mf),jo(Ta,Ga,oo,po,Ho)}}return!!ua&&(Ho||(Ho=new Mf),(function(_a,Ca,Es,is,pu,Fs){var Fl=1&Es,tu=id(_a),ad=tu.length;if(ad!=id(Ca).length&&!Fl)return!1;for(var Nl=ad;Nl--;){var qs=tu[Nl];if(!(Fl?qs in Ca:fs.call(Ca,qs)))return!1}var gm=Fs.get(_a),Zp=Fs.get(Ca);if(gm&&Zp)return gm==Ca&&Zp==_a;var $p=!0;Fs.set(_a,Ca),Fs.set(Ca,_a);for(var R0=Fl;++Nl<ad;){var vh=_a[qs=tu[Nl]],Dl=Ca[qs];if(is)var ru=Fl?is(Dl,vh,qs,Ca,_a,Fs):is(vh,Dl,qs,_a,Ca,Fs);if(!(ru===c?vh===Dl||pu(vh,Dl,Es,is,Fs):ru)){$p=!1;break}R0||(R0=qs=="constructor")}if($p&&!R0){var zl=_a.constructor,Id=Ca.constructor;zl==Id||!("constructor"in _a)||!("constructor"in Ca)||typeof zl=="function"&&zl instanceof zl&&typeof Id=="function"&&Id instanceof Id||($p=!1)}return Fs.delete(_a),Fs.delete(Ca),$p})(Xi,eo,oo,po,jo,Ho))})(Xe,qr,hi,Si,zf,ji))}function Lu(Xe,qr,hi,Si){var ji=hi.length,Xi=ji,eo=!Si;if(Xe==null)return!Xi;for(Xe=Os(Xe);ji--;){var oo=hi[ji];if(eo&&oo[2]?oo[1]!==Xe[oo[0]]:!(oo[0]in Xe))return!1}for(;++ji<Xi;){var po=(oo=hi[ji])[0],jo=Xe[po],Ho=oo[1];if(eo&&oo[2]){if(jo===c&&!(po in Xe))return!1}else{var Xo=new Mf;if(Si)var va=Si(jo,Ho,po,Xe,qr,Xo);if(!(va===c?zf(Ho,jo,3,Si,Xo):va))return!1}}return!0}function my(Xe){return!(!Ds(Xe)||(qr=Xe,Bm&&Bm in qr))&&(Ml(Xe)?o3:co).test($d(Xe));var qr}function pd(Xe){return typeof Xe=="function"?Xe:Xe==null?Fu:typeof Xe=="object"?Ka(Xe)?_y(Xe[0],Xe[1]):Ud(Xe):Db(Xe)}function by(Xe){if(!lh(Xe))return k6(Xe);var qr=[];for(var hi in Os(Xe))fs.call(Xe,hi)&&hi!="constructor"&&qr.push(hi);return qr}function wy(Xe,qr){return Xe<qr}function oh(Xe,qr){var hi=-1,Si=Cu(Xe)?pa(Xe.length):[];return Xl(Xe,(function(ji,Xi,eo){Si[++hi]=qr(ji,Xi,eo)})),Si}function Ud(Xe){var qr=rc(Xe);return qr.length==1&&qr[0][2]?$m(qr[0][0],qr[0][1]):function(hi){return hi===Xe||Lu(hi,Xe,qr)}}function _y(Xe,qr){return Km(Xe)&&Gm(qr)?$m(Zf(Xe),qr):function(hi){var Si=Dp(hi,Xe);return Si===c&&Si===qr?hm(hi,Xe):zf(qr,Si,3)}}function jd(Xe,qr,hi,Si,ji){Xe!==qr&&ih(qr,(function(Xi,eo){if(ji||(ji=new Mf),Ds(Xi))(function(po,jo,Ho,Xo,va,xa,Oa){var Mo=Sp(po,Ho),Lo=Sp(jo,Ho),ua=Oa.get(Lo);if(ua)py(po,Ho,ua);else{var Go=xa?xa(Mo,Lo,Ho+"",po,jo,Oa):c,da=Go===c;if(da){var Ta=Ka(Lo),Ga=!Ta&&vd(Lo),_a=!Ta&&!Ga&&mh(Lo);Go=Lo,Ta||Ga||_a?Ka(Mo)?Go=Mo:js(Mo)?Go=Tu(Mo):Ga?(da=!1,Go=xp(Lo,!0)):_a?(da=!1,Go=Lm(Lo,!0)):Go=[]:Jh(Lo)||Yd(Lo)?(Go=Mo,Yd(Mo)?Go=Pg(Mo):Ds(Mo)&&!Ml(Mo)||(Go=Gd(Lo))):da=!1}da&&(Oa.set(Lo,Go),va(Go,Lo,Xo,xa,Oa),Oa.delete(Lo)),py(po,Ho,Go)}})(Xe,qr,eo,hi,jd,Si,ji);else{var oo=Si?Si(Sp(Xe,eo),Xi,eo+"",Xe,qr,ji):c;oo===c&&(oo=Xi),py(Xe,eo,oo)}}),Ls)}function Ry(Xe,qr){var hi=Xe.length;if(hi)return Pf(qr+=qr<0?hi:0,hi)?Xe[qr]:c}function Ld(Xe,qr,hi){qr=qr.length?ws(qr,(function(Xi){return Ka(Xi)?function(eo){return vu(eo,Xi.length===1?Xi[0]:Xi)}:Xi})):[Fu];var Si=-1;qr=ws(qr,bu(ba()));var ji=oh(Xe,(function(Xi,eo,oo){var po=ws(qr,(function(jo){return jo(Xi)}));return{criteria:po,index:++Si,value:Xi}}));return(function(Xi,eo){var oo=Xi.length;for(Xi.sort((function(po,jo){return(function(Ho,Xo,va){for(var xa=-1,Oa=Ho.criteria,Mo=Xo.criteria,Lo=Oa.length,ua=va.length;++xa<Lo;){var Go=Hd(Oa[xa],Mo[xa]);if(Go)return xa>=ua?Go:Go*(va[xa]=="desc"?-1:1)}return Ho.index-Xo.index})(po,jo,hi)}));oo--;)Xi[oo]=Xi[oo].value;return Xi})(ji)}function ed(Xe,qr,hi){for(var Si=-1,ji=qr.length,Xi={};++Si<ji;){var eo=qr[Si],oo=vu(Xe,eo);hi(oo,eo)&&Hs(Xi,yd(eo,Xe),oo)}return Xi}function td(Xe,qr,hi,Si){var ji=Si?_d:Gl,Xi=-1,eo=qr.length,oo=Xe;for(Xe===qr&&(qr=Tu(qr)),hi&&(oo=ws(Xe,bu(hi)));++Xi<eo;)for(var po=0,jo=qr[Xi],Ho=hi?hi(jo):jo;(po=ji(oo,Ho,po,Si))>-1;)oo!==Xe&&Bd.call(oo,po,1),Bd.call(Xe,po,1);return Xe}function rd(Xe,qr){for(var hi=Xe?qr.length:0,Si=hi-1;hi--;){var ji=qr[hi];if(hi==Si||ji!==Xi){var Xi=ji;Pf(ji)?Bd.call(Xe,ji,1):qd(Xe,ji)}}return Xe}function hp(Xe,qr){return Xe+ip(km()*(qr-Xe+1))}function pp(Xe,qr){var hi="";if(!Xe||qr<1||qr>S)return hi;do qr%2&&(hi+=Xe),(qr=ip(qr/2))&&(Xe+=Xe);while(qr);return hi}function Va(Xe,qr){return Gh(x3(Xe,qr,Fu),Xe+"")}function By(Xe){return lp(gh(Xe))}function ah(Xe,qr){var hi=gh(Xe);return Xh(hi,Nd(qr,0,hi.length))}function Hs(Xe,qr,hi,Si){if(!Ds(Xe))return Xe;for(var ji=-1,Xi=(qr=yd(qr,Xe)).length,eo=Xi-1,oo=Xe;oo!=null&&++ji<Xi;){var po=Zf(qr[ji]),jo=hi;if(po==="__proto__"||po==="constructor"||po==="prototype")return Xe;if(ji!=eo){var Ho=oo[po];(jo=Si?Si(Ho,po,oo):c)===c&&(jo=Ds(Ho)?Ho:Pf(qr[ji+1])?[]:{})}kd(oo,po,jo),oo=oo[po]}return Xe}var yp=sp?function(Xe,qr){return sp.set(Xe,qr),Xe}:Fu,g3=rp?function(Xe,qr){return rp(Xe,"toString",{configurable:!0,enumerable:!1,value:Bl(qr),writable:!0})}:Fu;function D6(Xe){return Xh(gh(Xe))}function Hf(Xe,qr,hi){var Si=-1,ji=Xe.length;qr<0&&(qr=-qr>ji?0:ji+qr),(hi=hi>ji?ji:hi)<0&&(hi+=ji),ji=qr>hi?0:hi-qr>>>0,qr>>>=0;for(var Xi=pa(ji);++Si<ji;)Xi[Si]=Xe[Si+qr];return Xi}function U6(Xe,qr){var hi;return Xl(Xe,(function(Si,ji,Xi){return!(hi=qr(Si,ji,Xi))})),!!hi}function Ns(Xe,qr,hi){var Si=0,ji=Xe==null?Si:Xe.length;if(typeof qr=="number"&&qr==qr&&ji<=2147483647){for(;Si<ji;){var Xi=Si+ji>>>1,eo=Xe[Xi];eo!==null&&!hu(eo)&&(hi?eo<=qr:eo<qr)?Si=Xi+1:ji=Xi}return ji}return mp(Xe,qr,Fu,hi)}function mp(Xe,qr,hi,Si){var ji=0,Xi=Xe==null?0:Xe.length;if(Xi===0)return 0;for(var eo=(qr=hi(qr))!=qr,oo=qr===null,po=hu(qr),jo=qr===c;ji<Xi;){var Ho=ip((ji+Xi)/2),Xo=hi(Xe[Ho]),va=Xo!==c,xa=Xo===null,Oa=Xo==Xo,Mo=hu(Xo);if(eo)var Lo=Si||Oa;else Lo=jo?Oa&&(Si||va):oo?Oa&&va&&(Si||!xa):po?Oa&&va&&!xa&&(Si||!Mo):!xa&&!Mo&&(Si?Xo<=qr:Xo<qr);Lo?ji=Ho+1:Xi=Ho}return $s(Xi,4294967294)}function kh(Xe,qr){for(var hi=-1,Si=Xe.length,ji=0,Xi=[];++hi<Si;){var eo=Xe[hi],oo=qr?qr(eo):eo;if(!hi||!Gf(oo,po)){var po=oo;Xi[ji++]=eo===0?0:eo}}return Xi}function Nh(Xe){return typeof Xe=="number"?Xe:hu(Xe)?E:+Xe}function _u(Xe){if(typeof Xe=="string")return Xe;if(Ka(Xe))return ws(Xe,_u)+"";if(hu(Xe))return y3?y3.call(Xe):"";var qr=Xe+"";return qr=="0"&&1/Xe==-1/0?"-0":qr}function Ff(Xe,qr,hi){var Si=-1,ji=Ah,Xi=Xe.length,eo=!0,oo=[],po=oo;if(hi)eo=!1,ji=G0;else if(Xi>=200){var jo=qr?null:w3(Xe);if(jo)return ry(jo);eo=!1,ji=Q0,po=new Lf}else po=qr?[]:oo;e:for(;++Si<Xi;){var Ho=Xe[Si],Xo=qr?qr(Ho):Ho;if(Ho=hi||Ho!==0?Ho:0,eo&&Xo==Xo){for(var va=po.length;va--;)if(po[va]===Xo)continue e;qr&&po.push(Xo),oo.push(Ho)}else ji(po,Xo,hi)||(po!==oo&&po.push(Xo),oo.push(Ho))}return oo}function qd(Xe,qr){return(Xe=em(Xe,qr=yd(qr,Xe)))==null||delete Xe[Zf(Hu(qr))]}function b3(Xe,qr,hi,Si){return Hs(Xe,qr,hi(vu(Xe,qr)),Si)}function bp(Xe,qr,hi,Si){for(var ji=Xe.length,Xi=Si?ji:-1;(Si?Xi--:++Xi<ji)&&qr(Xe[Xi],Xi,Xe););return hi?Hf(Xe,Si?0:Xi,Si?Xi+1:ji):Hf(Xe,Si?Xi+1:0,Si?ji:Xi)}function v3(Xe,qr){var hi=Xe;return hi instanceof Ja&&(hi=hi.value()),Xp(qr,(function(Si,ji){return ji.func.apply(ji.thisArg,Tf([Si],ji.args))}),hi)}function Oy(Xe,qr,hi){var Si=Xe.length;if(Si<2)return Si?Ff(Xe[0]):[];for(var ji=-1,Xi=pa(Si);++ji<Si;)for(var eo=Xe[ji],oo=-1;++oo<Si;)oo!=ji&&(Xi[ji]=Ph(Xi[ji]||eo,Xe[oo],qr,hi));return Ff(Ws(Xi,1),qr,hi)}function zd(Xe,qr,hi){for(var Si=-1,ji=Xe.length,Xi=qr.length,eo={};++Si<ji;){var oo=Si<Xi?qr[Si]:c;hi(eo,Xe[Si],oo)}return eo}function vp(Xe){return js(Xe)?Xe:[]}function Dh(Xe){return typeof Xe=="function"?Xe:Fu}function yd(Xe,qr){return Ka(Xe)?Xe:Km(Xe,qr)?[Xe]:tm(ds(Xe))}var Uh=Va;function nd(Xe,qr,hi){var Si=Xe.length;return hi=hi===c?Si:hi,!qr&&hi>=Si?Xe:Hf(Xe,qr,hi)}var wp=Cm||function(Xe){return Yi.clearTimeout(Xe)};function xp(Xe,qr){if(qr)return Xe.slice();var hi=Xe.length,Si=a3?a3(hi):new Xe.constructor(hi);return Xe.copy(Si),Si}function Fy(Xe){var qr=new Xe.constructor(Xe.byteLength);return new ly(qr).set(new ly(Xe)),qr}function Lm(Xe,qr){var hi=qr?Fy(Xe.buffer):Xe.buffer;return new Xe.constructor(hi,Xe.byteOffset,Xe.length)}function Hd(Xe,qr){if(Xe!==qr){var hi=Xe!==c,Si=Xe===null,ji=Xe==Xe,Xi=hu(Xe),eo=qr!==c,oo=qr===null,po=qr==qr,jo=hu(qr);if(!oo&&!jo&&!Xi&&Xe>qr||Xi&&eo&&po&&!oo&&!jo||Si&&eo&&po||!hi&&po||!ji)return 1;if(!Si&&!Xi&&!jo&&Xe<qr||jo&&hi&&ji&&!Si&&!Xi||oo&&hi&&ji||!eo&&ji||!po)return-1}return 0}function Vd(Xe,qr,hi,Si){for(var ji=-1,Xi=Xe.length,eo=hi.length,oo=-1,po=qr.length,jo=ps(Xi-eo,0),Ho=pa(po+jo),Xo=!Si;++oo<po;)Ho[oo]=qr[oo];for(;++ji<eo;)(Xo||ji<Xi)&&(Ho[hi[ji]]=Xe[ji]);for(;jo--;)Ho[oo++]=Xe[ji++];return Ho}function qm(Xe,qr,hi,Si){for(var ji=-1,Xi=Xe.length,eo=-1,oo=hi.length,po=-1,jo=qr.length,Ho=ps(Xi-oo,0),Xo=pa(Ho+jo),va=!Si;++ji<Ho;)Xo[ji]=Xe[ji];for(var xa=ji;++po<jo;)Xo[xa+po]=qr[po];for(;++eo<oo;)(va||ji<Xi)&&(Xo[xa+hi[eo]]=Xe[ji++]);return Xo}function Tu(Xe,qr){var hi=-1,Si=Xe.length;for(qr||(qr=pa(Si));++hi<Si;)qr[hi]=Xe[hi];return qr}function Bu(Xe,qr,hi,Si){var ji=!hi;hi||(hi={});for(var Xi=-1,eo=qr.length;++Xi<eo;){var oo=qr[Xi],po=Si?Si(hi[oo],Xe[oo],oo,hi,Xe):c;po===c&&(po=Xe[oo]),ji?Yf(hi,oo,po):kd(hi,oo,po)}return hi}function Kd(Xe,qr){return function(hi,Si){var ji=Ka(hi)?Zs:N6,Xi=qr?qr():{};return ji(hi,Xe,ba(Si,2),Xi)}}function md(Xe){return Va((function(qr,hi){var Si=-1,ji=hi.length,Xi=ji>1?hi[ji-1]:c,eo=ji>2?hi[2]:c;for(Xi=Xe.length>3&&typeof Xi=="function"?(ji--,Xi):c,eo&&Qs(hi[0],hi[1],eo)&&(Xi=ji<3?c:Xi,ji=1),qr=Os(qr);++Si<ji;){var oo=hi[Si];oo&&Xe(qr,oo,Si,Xi)}return qr}))}function jh(Xe,qr){return function(hi,Si){if(hi==null)return hi;if(!Cu(hi))return Xe(hi,Si);for(var ji=hi.length,Xi=qr?ji:-1,eo=Os(hi);(qr?Xi--:++Xi<ji)&&Si(eo[Xi],Xi,eo)!==!1;);return hi}}function Ep(Xe){return function(qr,hi,Si){for(var ji=-1,Xi=Os(qr),eo=Si(qr),oo=eo.length;oo--;){var po=eo[Xe?oo:++ji];if(hi(Xi[po],po,Xi)===!1)break}return qr}}function zm(Xe){return function(qr){var hi=_h(qr=ds(qr))?Wf(qr):c,Si=hi?hi[0]:qr.charAt(0),ji=hi?nd(hi,1).join(""):qr.slice(1);return Si[Xe]()+ji}}function Vf(Xe){return function(qr){return Xp(ym(Fb(qr).replace(ha,"")),Xe,"")}}function qh(Xe){return function(){var qr=arguments;switch(qr.length){case 0:return new Xe;case 1:return new Xe(qr[0]);case 2:return new Xe(qr[0],qr[1]);case 3:return new Xe(qr[0],qr[1],qr[2]);case 4:return new Xe(qr[0],qr[1],qr[2],qr[3]);case 5:return new Xe(qr[0],qr[1],qr[2],qr[3],qr[4]);case 6:return new Xe(qr[0],qr[1],qr[2],qr[3],qr[4],qr[5]);case 7:return new Xe(qr[0],qr[1],qr[2],qr[3],qr[4],qr[5],qr[6])}var hi=Fh(Xe.prototype),Si=Xe.apply(hi,qr);return Ds(Si)?Si:hi}}function gd(Xe){return function(qr,hi,Si){var ji=Os(qr);if(!Cu(qr)){var Xi=ba(hi,3);qr=su(qr),hi=function(oo){return Xi(ji[oo],oo,ji)}}var eo=Xe(qr,hi,Si);return eo>-1?ji[Xi?qr[eo]:eo]:c}}function ky(Xe){return Ys((function(qr){var hi=qr.length,Si=hi,ji=Rf.prototype.thru;for(Xe&&qr.reverse();Si--;){var Xi=qr[Si];if(typeof Xi!="function")throw new Df(d);if(ji&&!eo&&tc(Xi)=="wrapper")var eo=new Rf([],!0)}for(Si=eo?Si:hi;++Si<hi;){var oo=tc(Xi=qr[Si]),po=oo=="wrapper"?$y(Xi):c;eo=po&&Ps(po[0])&&po[1]==424&&!po[4].length&&po[9]==1?eo[tc(po[0])].apply(eo,po[3]):Xi.length==1&&Ps(Xi)?eo[oo]():eo.thru(Xi)}return function(){var jo=arguments,Ho=jo[0];if(eo&&jo.length==1&&Ka(Ho))return eo.plant(Ho).value();for(var Xo=0,va=hi?qr[Xo].apply(this,jo):Ho;++Xo<hi;)va=qr[Xo].call(this,va);return va}}))}function Vh(Xe,qr,hi,Si,ji,Xi,eo,oo,po,jo){var Ho=qr&b,Xo=1&qr,va=2&qr,xa=24&qr,Oa=512&qr,Mo=va?c:qh(Xe);return function Lo(){for(var ua=arguments.length,Go=pa(ua),da=ua;da--;)Go[da]=arguments[da];if(xa)var Ta=cu(Lo),Ga=J0(Go,Ta);if(Si&&(Go=Vd(Go,Si,ji,xa)),Xi&&(Go=qm(Go,Xi,eo,xa)),ua-=Ga,xa&&ua<jo){var _a=Rd(Go,Ta);return Zh(Xe,qr,Vh,Lo.placeholder,hi,Go,_a,oo,po,jo-ua)}var Ca=Xo?hi:this,Es=va?Ca[Xe]:Xe;return ua=Go.length,oo?Go=Xm(Go,oo):Oa&&ua>1&&Go.reverse(),Ho&&po<ua&&(Go.length=po),this&&this!==Yi&&this instanceof Lo&&(Es=Mo||qh(Es)),Es.apply(Ca,Go)}}function bd(Xe,qr){return function(hi,Si){return(function(ji,Xi,eo,oo){return zs(ji,(function(po,jo,Ho){Xi(oo,eo(po),jo,Ho)})),oo})(hi,Xe,qr(Si),{})}}function Jf(Xe,qr){return function(hi,Si){var ji;if(hi===c&&Si===c)return qr;if(hi!==c&&(ji=hi),Si!==c){if(ji===c)return Si;typeof hi=="string"||typeof Si=="string"?(hi=_u(hi),Si=_u(Si)):(hi=Nh(hi),Si=Nh(Si)),ji=Xe(hi,Si)}return ji}}function sh(Xe){return Ys((function(qr){return qr=ws(qr,bu(ba())),Va((function(hi){var Si=this;return Xe(qr,(function(ji){return rs(ji,Si,hi)}))}))}))}function Kh(Xe,qr){var hi=(qr=qr===c?" ":_u(qr)).length;if(hi<2)return hi?pp(qr,Xe):qr;var Si=pp(qr,np(Xe/Th(qr)));return _h(qr)?nd(Wf(Si),0,Xe).join(""):Si.slice(0,Xe)}function Ny(Xe){return function(qr,hi,Si){return Si&&typeof Si!="number"&&Qs(qr,hi,Si)&&(hi=Si=c),qr=$f(qr),hi===c?(hi=qr,qr=0):hi=$f(hi),(function(ji,Xi,eo,oo){for(var po=-1,jo=ps(np((Xi-ji)/(eo||1)),0),Ho=pa(jo);jo--;)Ho[oo?jo:++po]=ji,ji+=eo;return Ho})(qr,hi,Si=Si===c?qr<hi?1:-1:$f(Si),Xe)}}function Zd(Xe){return function(qr,hi){return typeof qr=="string"&&typeof hi=="string"||(qr=kf(qr),hi=kf(hi)),Xe(qr,hi)}}function Zh(Xe,qr,hi,Si,ji,Xi,eo,oo,po,jo){var Ho=8&qr;qr|=Ho?y:64,4&(qr&=~(Ho?64:y))||(qr&=-4);var Xo=[Xe,qr,ji,Ho?Xi:c,Ho?eo:c,Ho?c:Xi,Ho?c:eo,oo,po,jo],va=hi.apply(c,Xo);return Ps(Xe)&&Eu(va,Xo),va.placeholder=Si,$h(va,Xe,qr)}function Uy(Xe){var qr=$l[Xe];return function(hi,Si){if(hi=kf(hi),(Si=Si==null?0:$s($a(Si),292))&&f3(hi)){var ji=(ds(hi)+"e").split("e");return+((ji=(ds(qr(ji[0]+"e"+(+ji[1]+Si)))+"e").split("e"))[0]+"e"+(+ji[1]-Si))}return qr(hi)}}var w3=Pd&&1/ry(new Pd([,-0]))[1]==w?function(Xe){return new Pd(Xe)}:_s;function uh(Xe){return function(qr){var hi=iu(qr);return hi==ce?Tm(qr):hi==ue?R6(qr):(function(Si,ji){return ws(ji,(function(Xi){return[Xi,Si[Xi]]}))})(qr,Xe(qr))}}function Kf(Xe,qr,hi,Si,ji,Xi,eo,oo){var po=2&qr;if(!po&&typeof Xe!="function")throw new Df(d);var jo=Si?Si.length:0;if(jo||(qr&=-97,Si=ji=c),eo=eo===c?eo:ps($a(eo),0),oo=oo===c?oo:$a(oo),jo-=ji?ji.length:0,64&qr){var Ho=Si,Xo=ji;Si=ji=c}var va=po?c:$y(Xe),xa=[Xe,qr,hi,Si,ji,Ho,Xo,Xi,eo,oo];if(va&&(function(Mo,Lo){var ua=Mo[1],Go=Lo[1],da=ua|Go,Ta=da<131,Ga=Go==b&&ua==8||Go==b&&ua==256&&Mo[7].length<=Lo[8]||Go==384&&Lo[7].length<=Lo[8]&&ua==8;if(!Ta&&!Ga)return Mo;1&Go&&(Mo[2]=Lo[2],da|=1&ua?0:4);var _a=Lo[3];if(_a){var Ca=Mo[3];Mo[3]=Ca?Vd(Ca,_a,Lo[4]):_a,Mo[4]=Ca?Rd(Mo[3],h):Lo[4]}(_a=Lo[5])&&(Ca=Mo[5],Mo[5]=Ca?qm(Ca,_a,Lo[6]):_a,Mo[6]=Ca?Rd(Mo[5],h):Lo[6]),(_a=Lo[7])&&(Mo[7]=_a),Go&b&&(Mo[8]=Mo[8]==null?Lo[8]:$s(Mo[8],Lo[8])),Mo[9]==null&&(Mo[9]=Lo[9]),Mo[0]=Lo[0],Mo[1]=da})(xa,va),Xe=xa[0],qr=xa[1],hi=xa[2],Si=xa[3],ji=xa[4],!(oo=xa[9]=xa[9]===c?po?0:Xe.length:ps(xa[9]-jo,0))&&24&qr&&(qr&=-25),qr&&qr!=1)Oa=qr==8||qr==16?(function(Mo,Lo,ua){var Go=qh(Mo);return function da(){for(var Ta=arguments.length,Ga=pa(Ta),_a=Ta,Ca=cu(da);_a--;)Ga[_a]=arguments[_a];var Es=Ta<3&&Ga[0]!==Ca&&Ga[Ta-1]!==Ca?[]:Rd(Ga,Ca);return(Ta-=Es.length)<ua?Zh(Mo,Lo,Vh,da.placeholder,c,Ga,Es,c,c,ua-Ta):rs(this&&this!==Yi&&this instanceof da?Go:Mo,this,Ga)}})(Xe,qr,oo):qr!=y&&qr!=33||ji.length?Vh.apply(c,xa):(function(Mo,Lo,ua,Go){var da=1&Lo,Ta=qh(Mo);return function Ga(){for(var _a=-1,Ca=arguments.length,Es=-1,is=Go.length,pu=pa(is+Ca),Fs=this&&this!==Yi&&this instanceof Ga?Ta:Mo;++Es<is;)pu[Es]=Go[Es];for(;Ca--;)pu[Es++]=arguments[++_a];return rs(Fs,da?ua:this,pu)}})(Xe,qr,hi,Si);else var Oa=(function(Mo,Lo,ua){var Go=1&Lo,da=qh(Mo);return function Ta(){return(this&&this!==Yi&&this instanceof Ta?da:Mo).apply(Go?ua:this,arguments)}})(Xe,qr,hi);return $h((va?yp:Eu)(Oa,xa),Xe,qr)}function Hm(Xe,qr,hi,Si){return Xe===c||Gf(Xe,Rh[hi])&&!fs.call(Si,hi)?qr:Xe}function qy(Xe,qr,hi,Si,ji,Xi){return Ds(Xe)&&Ds(qr)&&(Xi.set(qr,Xe),jd(Xe,qr,c,qy,Xi),Xi.delete(qr)),Xe}function Vm(Xe){return Jh(Xe)?c:Xe}function qu(Xe,qr,hi,Si,ji,Xi){var eo=1&hi,oo=Xe.length,po=qr.length;if(oo!=po&&!(eo&&po>oo))return!1;var jo=Xi.get(Xe),Ho=Xi.get(qr);if(jo&&Ho)return jo==qr&&Ho==Xe;var Xo=-1,va=!0,xa=2&hi?new Lf:c;for(Xi.set(Xe,qr),Xi.set(qr,Xe);++Xo<oo;){var Oa=Xe[Xo],Mo=qr[Xo];if(Si)var Lo=eo?Si(Mo,Oa,Xo,qr,Xe,Xi):Si(Oa,Mo,Xo,Xe,qr,Xi);if(Lo!==c){if(Lo)continue;va=!1;break}if(xa){if(!Wp(qr,(function(ua,Go){if(!Q0(xa,Go)&&(Oa===ua||ji(Oa,ua,hi,Si,Xi)))return xa.push(Go)}))){va=!1;break}}else if(Oa!==Mo&&!ji(Oa,Mo,hi,Si,Xi)){va=!1;break}}return Xi.delete(Xe),Xi.delete(qr),va}function Ys(Xe){return Gh(x3(Xe,c,Qm),Xe+"")}function id(Xe){return Jl(Xe,su,ms)}function Ap(Xe){return Jl(Xe,Ls,Vs)}var $y=sp?function(Xe){return sp.get(Xe)}:_s;function tc(Xe){for(var qr=Xe.name+"",hi=Uf[qr],Si=fs.call(Uf,qr)?hi.length:0;Si--;){var ji=hi[Si],Xi=ji.func;if(Xi==null||Xi==Xe)return ji.name}return qr}function cu(Xe){return(fs.call(Zi,"placeholder")?Zi:Xe).placeholder}function ba(){var Xe=Zi.iteratee||eu;return Xe=Xe===eu?pd:Xe,arguments.length?Xe(arguments[0],arguments[1]):Xe}function fh(Xe,qr){var hi,Si,ji=Xe.__data__;return((Si=typeof(hi=qr))=="string"||Si=="number"||Si=="symbol"||Si=="boolean"?hi!=="__proto__":hi===null)?ji[typeof qr=="string"?"string":"hash"]:ji.map}function rc(Xe){for(var qr=su(Xe),hi=qr.length;hi--;){var Si=qr[hi],ji=Xe[Si];qr[hi]=[Si,ji,Gm(ji)]}return qr}function ja(Xe,qr){var hi=(function(Si,ji){return Si==null?c:Si[ji]})(Xe,qr);return my(hi)?hi:c}var ms=Pm?function(Xe){return Xe==null?[]:(Xe=Os(Xe),mu(Pm(Xe),(function(qr){return Bh.call(Xe,qr)})))}:_0,Vs=Pm?function(Xe){for(var qr=[];Xe;)Tf(qr,ms(Xe)),Xe=tp(Xe);return qr}:_0,iu=xu;function ch(Xe,qr,hi){for(var Si=-1,ji=(qr=yd(qr,Xe)).length,Xi=!1;++Si<ji;){var eo=Zf(qr[Si]);if(!(Xi=Xe!=null&&hi(Xe,eo)))break;Xe=Xe[eo]}return Xi||++Si!=ji?Xi:!!(ji=Xe==null?0:Xe.length)&&Cp(ji)&&Pf(eo,ji)&&(Ka(Xe)||Yd(Xe))}function Gd(Xe){return typeof Xe.constructor!="function"||lh(Xe)?{}:Fh(tp(Xe))}function Yy(Xe){return Ka(Xe)||Yd(Xe)||!!(s3&&Xe&&Xe[s3])}function Pf(Xe,qr){var hi=typeof Xe;return!!(qr=qr??S)&&(hi=="number"||hi!="symbol"&&Io.test(Xe))&&Xe>-1&&Xe%1==0&&Xe<qr}function Qs(Xe,qr,hi){if(!Ds(hi))return!1;var Si=typeof qr;return!!(Si=="number"?Cu(hi)&&Pf(qr,hi.length):Si=="string"&&qr in hi)&&Gf(hi[qr],Xe)}function Km(Xe,qr){if(Ka(Xe))return!1;var hi=typeof Xe;return!(hi!="number"&&hi!="symbol"&&hi!="boolean"&&Xe!=null&&!hu(Xe))||qi.test(Xe)||!Bi.test(Xe)||qr!=null&&Xe in Os(qr)}function Ps(Xe){var qr=tc(Xe),hi=Zi[qr];if(typeof hi!="function"||!(qr in Ja.prototype))return!1;if(Xe===hi)return!0;var Si=$y(hi);return!!Si&&Xe===Si[0]}(op&&iu(new op(new ArrayBuffer(1)))!=k||ap&&iu(new ap)!=ce||Fd&&iu(Fd.resolve())!=vt||Pd&&iu(new Pd)!=ue||ld&&iu(new ld)!=_)&&(iu=function(Xe){var qr=xu(Xe),hi=qr==se?Xe.constructor:c,Si=hi?$d(hi):"";if(Si)switch(Si){case Oh:return k;case Nm:return ce;case h3:return vt;case th:return ue;case p3:return _}return qr});var Zm=fy?Ml:Su;function lh(Xe){var qr=Xe&&Xe.constructor;return Xe===(typeof qr=="function"&&qr.prototype||Rh)}function Gm(Xe){return Xe==Xe&&!Ds(Xe)}function $m(Xe,qr){return function(hi){return hi!=null&&hi[Xe]===qr&&(qr!==c||Xe in Os(hi))}}function x3(Xe,qr,hi){return qr=ps(qr===c?Xe.length-1:qr,0),function(){for(var Si=arguments,ji=-1,Xi=ps(Si.length-qr,0),eo=pa(Xi);++ji<Xi;)eo[ji]=Si[qr+ji];ji=-1;for(var oo=pa(qr+1);++ji<qr;)oo[ji]=Si[ji];return oo[qr]=hi(eo),rs(Xe,this,oo)}}function em(Xe,qr){return qr.length<2?Xe:vu(Xe,Hf(qr,0,-1))}function Xm(Xe,qr){for(var hi=Xe.length,Si=$s(qr.length,hi),ji=Tu(Xe);Si--;){var Xi=qr[Si];Xe[Si]=Pf(Xi,hi)?ji[Xi]:c}return Xe}function Sp(Xe,qr){if((qr!=="constructor"||typeof Xe[qr]!="function")&&qr!="__proto__")return Xe[qr]}var Eu=Ip(yp),Cs=u3||function(Xe,qr){return Yi.setTimeout(Xe,qr)},Gh=Ip(g3);function $h(Xe,qr,hi){var Si=qr+"";return Gh(Xe,(function(ji,Xi){var eo=Xi.length;if(!eo)return ji;var oo=eo-1;return Xi[oo]=(eo>1?"& ":"")+Xi[oo],Xi=Xi.join(eo>2?", ":" "),ji.replace(vi,`{
150
150
  /* [wrapped with `+Xi+`] */
@@ -193,7 +193,7 @@ js-sha256/src/sha256.js:
193
193
  * @copyright Chen, Yi-Cyuan 2014-2017
194
194
  * @license MIT
195
195
  *)
196
- */class MinaCrypto{constructor(){this.verifyAddress=t=>Check(TypeboxHelpers.Mina.Address,t),this.verifySignature=async(t,r,n)=>{try{const[o,i,u,...a]=n.split(";");if(!o||!i||!u||a.length>0)return!1;const s=new _1({network:u}),f={data:r,publicKey:t,signature:{field:o,scalar:i}};return s.verifyMessage(f)}catch(o){return console.error("[address-validator] error verifying mina signature:",o),!1}}}decodeAddress(t){return Decode(TypeboxHelpers.Mina.Address,t)}}class MidnightCrypto{constructor(){this.isMidnightSignature=t=>Check(TypeboxHelpers.Midnight.Signature,t),this.verifyAddress=t=>Check(TypeboxHelpers.Midnight.Address,t),this.verifySignature=async(t,r,n)=>{try{if(this.verifyAddress(t)&&this.isMidnightSignature(n))return console.log("TODO MIDNIGHT VERIFY SIGNATURE:",{signerAddress:t,message:r,signature:n}),!0}catch{}return!1}}decodeAddress(t){return Decode(TypeboxHelpers.Midnight.Address,t)}}class CryptoManager{static Algorand(){return CryptoManager.algorand==null&&(CryptoManager.algorand=new AlgorandCrypto),CryptoManager.algorand}static Cardano(){return CryptoManager.cardano==null&&(CryptoManager.cardano=new CardanoCrypto),CryptoManager.cardano}static Evm(){return CryptoManager.evm==null&&(CryptoManager.evm=new EvmCrypto),CryptoManager.evm}static Polkadot(){return CryptoManager.polkadot==null&&(CryptoManager.polkadot=new PolkadotCrypto),CryptoManager.polkadot}static Mina(){return CryptoManager.mina==null&&(CryptoManager.mina=new MinaCrypto),CryptoManager.mina}static Midnight(){return CryptoManager.midnight==null&&(CryptoManager.midnight=new MidnightCrypto),CryptoManager.midnight}static getCryptoManager(t){switch(t){case AddressType$1.EVM:return CryptoManager.Evm();case AddressType$1.CARDANO:return CryptoManager.Cardano();case AddressType$1.POLKADOT:return CryptoManager.Polkadot();case AddressType$1.ALGORAND:return CryptoManager.Algorand();case AddressType$1.MINA:return CryptoManager.Mina();case AddressType$1.MIDNIGHT:return CryptoManager.Midnight();default:throw new Error(`Unsupported address type: ${t}`)}}}requireCryptoBrowserify();function toKeyedJsonGrammar(e){return Object.fromEntries(Object.entries(e).map(([r,n])=>{const o=n.map(([u,a])=>a),i=Type.Tuple([Type.Literal(r),...o]);return[r,i]}))}function userAddress(e){return["userAddress",AddressValidator[e]]}const BatcherInnerCommon=[["userSignature",Type.String()],["conciseInput",Type.String()],["millisecondTimestamp",Type.String()]],BatcherInnerGrammar={[`${AddressType$1.NONE}`]:[userAddress(AddressType$1.NONE),...BatcherInnerCommon],[`${AddressType$1.EVM}`]:[userAddress(AddressType$1.EVM),...BatcherInnerCommon],[`${AddressType$1.CARDANO}`]:[userAddress(AddressType$1.CARDANO),...BatcherInnerCommon],[`${AddressType$1.SUBSTRATE}`]:[userAddress(AddressType$1.SUBSTRATE),...BatcherInnerCommon],[`${AddressType$1.AVAIL}`]:[userAddress(AddressType$1.AVAIL),...BatcherInnerCommon],[`${AddressType$1.ALGORAND}`]:[userAddress(AddressType$1.ALGORAND),...BatcherInnerCommon],[`${AddressType$1.MINA}`]:[userAddress(AddressType$1.MINA),...BatcherInnerCommon],[`${AddressType$1.MIDNIGHT}`]:[userAddress(AddressType$1.MIDNIGHT),...BatcherInnerCommon],[`${AddressType$1.POLKADOT}`]:[userAddress(AddressType$1.POLKADOT),...BatcherInnerCommon]};toKeyedJsonGrammar(BatcherInnerGrammar);const BatcherGrammarPrefix={batcherInput:"&B"},BatcherGrammar={[BatcherGrammarPrefix.batcherInput]:[["input",Type.Array(Type.String())]]};toKeyedJsonGrammar(BatcherGrammar);const BuiltinGrammarPrefix={createAccount:"&createAccount",linkAddress:"&linkAddress",unlinkAddress:"&unlinkAddress"},BuiltinGrammar={[BuiltinGrammarPrefix.createAccount]:[],[BuiltinGrammarPrefix.linkAddress]:[["account_id",Type.Number()],["signature_from_primary",Type.String()],["primary_address_type",Type.Number()],["new_address",Type.String()],["signature_from_new_address",Type.String()],["new_address_type",Type.Number()],["is_new_primary",Type.Boolean()]],[BuiltinGrammarPrefix.unlinkAddress]:[["account_id",Type.Number()],["signature_from_primary",Type.String()],["primary_address_type",Type.Number()],["target_address",Type.String()],["target_address_type",Type.Number()],["new_primary_address",Type.String()],["new_primary_address_type",Type.Number()]]};toKeyedJsonGrammar(BuiltinGrammar);var sha3$1={exports:{}},hasRequiredSha3;function requireSha3(){return hasRequiredSha3||(hasRequiredSha3=1,(function(e){(function(){var t="input is invalid type",r="finalize already called",n=typeof window=="object",o=n?window:{};o.JS_SHA3_NO_WINDOW&&(n=!1);var i=!n&&typeof self=="object",u=!o.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;u?o=commonjsGlobal:i&&(o=self);for(var a=!o.JS_SHA3_NO_COMMON_JS&&!0&&e.exports,s=!o.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),c=[31,7936,2031616,520093696],d=[4,1024,262144,67108864],p=[1,256,65536,16777216],h=[6,1536,393216,100663296],y=[0,8,16,24],b=[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],w=[224,256,384,512],S=[128,256],E=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136},ae=o.JS_SHA3_NO_NODE_JS||!Array.isArray?function(lr){return Object.prototype.toString.call(lr)==="[object Array]"}:Array.isArray,W=s&&(o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(lr){return typeof lr=="object"&&lr.buffer&&lr.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,J=function(lr){var ar=typeof lr;if(ar==="string")return[lr,!0];if(ar!=="object"||lr===null)throw new Error(t);if(s&&lr.constructor===ArrayBuffer)return[new Uint8Array(lr),!1];if(!ae(lr)&&!W(lr))throw new Error(t);return[lr,!1]},ve=function(lr){return J(lr)[0].length===0},Qe=function(lr){for(var ar=[],jr=0;jr<lr.length;++jr)ar[jr]=lr[jr];return ar},kt=function(lr,ar,jr){return function(ci){return new ni(lr,ar,lr).update(ci)[jr]()}},nr=function(lr,ar,jr){return function(ci,mi){return new ni(lr,ar,mi).update(ci)[jr]()}},sr=function(lr,ar,jr){return function(ci,mi,pi,ei){return L["cshake"+lr].update(ci,mi,pi,ei)[jr]()}},ce=function(lr,ar,jr){return function(ci,mi,pi,ei){return L["kmac"+lr].update(ci,mi,pi,ei)[jr]()}},Ze=function(lr,ar,jr,ci){for(var mi=0;mi<E.length;++mi){var pi=E[mi];lr[pi]=ar(jr,ci,pi)}return lr},se=function(lr,ar){var jr=kt(lr,ar,"hex");return jr.create=function(){return new ni(lr,ar,lr)},jr.update=function(ci){return jr.create().update(ci)},Ze(jr,kt,lr,ar)},vt=function(lr,ar){var jr=nr(lr,ar,"hex");return jr.create=function(ci){return new ni(lr,ar,ci)},jr.update=function(ci,mi){return jr.create(mi).update(ci)},Ze(jr,nr,lr,ar)},ur=function(lr,ar){var jr=B[lr],ci=sr(lr,ar,"hex");return ci.create=function(mi,pi,ei){return ve(pi)&&ve(ei)?L["shake"+lr].create(mi):new ni(lr,ar,mi).bytepad([pi,ei],jr)},ci.update=function(mi,pi,ei,Gr){return ci.create(pi,ei,Gr).update(mi)},Ze(ci,sr,lr,ar)},ue=function(lr,ar){var jr=B[lr],ci=ce(lr,ar,"hex");return ci.create=function(mi,pi,ei){return new ri(lr,ar,pi).bytepad(["KMAC",ei],jr).bytepad([mi],jr)},ci.update=function(mi,pi,ei,Gr){return ci.create(mi,ei,Gr).update(pi)},Ze(ci,ce,lr,ar)},bt=[{name:"keccak",padding:p,bits:w,createMethod:se},{name:"sha3",padding:h,bits:w,createMethod:se},{name:"shake",padding:c,bits:S,createMethod:vt},{name:"cshake",padding:d,bits:S,createMethod:ur},{name:"kmac",padding:d,bits:S,createMethod:ue}],L={},_=[],F=0;F<bt.length;++F)for(var k=bt[F],Ye=k.bits,rn=0;rn<Ye.length;++rn){var ii=k.name+"_"+Ye[rn];if(_.push(ii),L[ii]=k.createMethod(Ye[rn],k.padding),k.name!=="sha3"){var ai=k.name+Ye[rn];_.push(ai),L[ai]=L[ii]}}function ni(lr,ar,jr){this.blocks=[],this.s=[],this.padding=ar,this.outputBits=jr,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(lr<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=jr>>5,this.extraBytes=(jr&31)>>3;for(var ci=0;ci<50;++ci)this.s[ci]=0}ni.prototype.update=function(lr){if(this.finalized)throw new Error(r);var ar=J(lr);lr=ar[0];for(var jr=ar[1],ci=this.blocks,mi=this.byteCount,pi=lr.length,ei=this.blockCount,Gr=0,ti=this.s,fi,bi;Gr<pi;){if(this.reset)for(this.reset=!1,ci[0]=this.block,fi=1;fi<ei+1;++fi)ci[fi]=0;if(jr)for(fi=this.start;Gr<pi&&fi<mi;++Gr)bi=lr.charCodeAt(Gr),bi<128?ci[fi>>2]|=bi<<y[fi++&3]:bi<2048?(ci[fi>>2]|=(192|bi>>6)<<y[fi++&3],ci[fi>>2]|=(128|bi&63)<<y[fi++&3]):bi<55296||bi>=57344?(ci[fi>>2]|=(224|bi>>12)<<y[fi++&3],ci[fi>>2]|=(128|bi>>6&63)<<y[fi++&3],ci[fi>>2]|=(128|bi&63)<<y[fi++&3]):(bi=65536+((bi&1023)<<10|lr.charCodeAt(++Gr)&1023),ci[fi>>2]|=(240|bi>>18)<<y[fi++&3],ci[fi>>2]|=(128|bi>>12&63)<<y[fi++&3],ci[fi>>2]|=(128|bi>>6&63)<<y[fi++&3],ci[fi>>2]|=(128|bi&63)<<y[fi++&3]);else for(fi=this.start;Gr<pi&&fi<mi;++Gr)ci[fi>>2]|=lr[Gr]<<y[fi++&3];if(this.lastByteIndex=fi,fi>=mi){for(this.start=fi-mi,this.block=ci[ei],fi=0;fi<ei;++fi)ti[fi]^=ci[fi];ui(ti),this.reset=!0}else this.start=fi}return this},ni.prototype.encode=function(lr,ar){var jr=lr&255,ci=1,mi=[jr];for(lr=lr>>8,jr=lr&255;jr>0;)mi.unshift(jr),lr=lr>>8,jr=lr&255,++ci;return ar?mi.push(ci):mi.unshift(ci),this.update(mi),mi.length},ni.prototype.encodeString=function(lr){var ar=J(lr);lr=ar[0];var jr=ar[1],ci=0,mi=lr.length;if(jr)for(var pi=0;pi<lr.length;++pi){var ei=lr.charCodeAt(pi);ei<128?ci+=1:ei<2048?ci+=2:ei<55296||ei>=57344?ci+=3:(ei=65536+((ei&1023)<<10|lr.charCodeAt(++pi)&1023),ci+=4)}else ci=mi;return ci+=this.encode(ci*8),this.update(lr),ci},ni.prototype.bytepad=function(lr,ar){for(var jr=this.encode(ar),ci=0;ci<lr.length;++ci)jr+=this.encodeString(lr[ci]);var mi=(ar-jr%ar)%ar,pi=[];return pi.length=mi,this.update(pi),this},ni.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var lr=this.blocks,ar=this.lastByteIndex,jr=this.blockCount,ci=this.s;if(lr[ar>>2]|=this.padding[ar&3],this.lastByteIndex===this.byteCount)for(lr[0]=lr[jr],ar=1;ar<jr+1;++ar)lr[ar]=0;for(lr[jr-1]|=2147483648,ar=0;ar<jr;++ar)ci[ar]^=lr[ar];ui(ci)}},ni.prototype.toString=ni.prototype.hex=function(){this.finalize();for(var lr=this.blockCount,ar=this.s,jr=this.outputBlocks,ci=this.extraBytes,mi=0,pi=0,ei="",Gr;pi<jr;){for(mi=0;mi<lr&&pi<jr;++mi,++pi)Gr=ar[mi],ei+=f[Gr>>4&15]+f[Gr&15]+f[Gr>>12&15]+f[Gr>>8&15]+f[Gr>>20&15]+f[Gr>>16&15]+f[Gr>>28&15]+f[Gr>>24&15];pi%lr===0&&(ar=Qe(ar),ui(ar),mi=0)}return ci&&(Gr=ar[mi],ei+=f[Gr>>4&15]+f[Gr&15],ci>1&&(ei+=f[Gr>>12&15]+f[Gr>>8&15]),ci>2&&(ei+=f[Gr>>20&15]+f[Gr>>16&15])),ei},ni.prototype.arrayBuffer=function(){this.finalize();var lr=this.blockCount,ar=this.s,jr=this.outputBlocks,ci=this.extraBytes,mi=0,pi=0,ei=this.outputBits>>3,Gr;ci?Gr=new ArrayBuffer(jr+1<<2):Gr=new ArrayBuffer(ei);for(var ti=new Uint32Array(Gr);pi<jr;){for(mi=0;mi<lr&&pi<jr;++mi,++pi)ti[pi]=ar[mi];pi%lr===0&&(ar=Qe(ar),ui(ar))}return ci&&(ti[pi]=ar[mi],Gr=Gr.slice(0,ei)),Gr},ni.prototype.buffer=ni.prototype.arrayBuffer,ni.prototype.digest=ni.prototype.array=function(){this.finalize();for(var lr=this.blockCount,ar=this.s,jr=this.outputBlocks,ci=this.extraBytes,mi=0,pi=0,ei=[],Gr,ti;pi<jr;){for(mi=0;mi<lr&&pi<jr;++mi,++pi)Gr=pi<<2,ti=ar[mi],ei[Gr]=ti&255,ei[Gr+1]=ti>>8&255,ei[Gr+2]=ti>>16&255,ei[Gr+3]=ti>>24&255;pi%lr===0&&(ar=Qe(ar),ui(ar))}return ci&&(Gr=pi<<2,ti=ar[mi],ei[Gr]=ti&255,ci>1&&(ei[Gr+1]=ti>>8&255),ci>2&&(ei[Gr+2]=ti>>16&255)),ei};function ri(lr,ar,jr){ni.call(this,lr,ar,jr)}ri.prototype=new ni,ri.prototype.finalize=function(){return this.encode(this.outputBits,!0),ni.prototype.finalize.call(this)};var ui=function(lr){var ar,jr,ci,mi,pi,ei,Gr,ti,fi,bi,Ai,Bi,qi,vn,di,rr,on,si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi,Ji,no,co,Fo,Io,Ro,Oo,To,Po,ia,Jo,ea,zi,Gi,uo,wo,xi,Fi,Ui,gi,Li,Qi,Wi,io,lo,Ao,_o,ca,Co,$o,ta,sa,ga,ya,ma,fa,ra;for(ci=0;ci<48;ci+=2)mi=lr[0]^lr[10]^lr[20]^lr[30]^lr[40],pi=lr[1]^lr[11]^lr[21]^lr[31]^lr[41],ei=lr[2]^lr[12]^lr[22]^lr[32]^lr[42],Gr=lr[3]^lr[13]^lr[23]^lr[33]^lr[43],ti=lr[4]^lr[14]^lr[24]^lr[34]^lr[44],fi=lr[5]^lr[15]^lr[25]^lr[35]^lr[45],bi=lr[6]^lr[16]^lr[26]^lr[36]^lr[46],Ai=lr[7]^lr[17]^lr[27]^lr[37]^lr[47],Bi=lr[8]^lr[18]^lr[28]^lr[38]^lr[48],qi=lr[9]^lr[19]^lr[29]^lr[39]^lr[49],ar=Bi^(ei<<1|Gr>>>31),jr=qi^(Gr<<1|ei>>>31),lr[0]^=ar,lr[1]^=jr,lr[10]^=ar,lr[11]^=jr,lr[20]^=ar,lr[21]^=jr,lr[30]^=ar,lr[31]^=jr,lr[40]^=ar,lr[41]^=jr,ar=mi^(ti<<1|fi>>>31),jr=pi^(fi<<1|ti>>>31),lr[2]^=ar,lr[3]^=jr,lr[12]^=ar,lr[13]^=jr,lr[22]^=ar,lr[23]^=jr,lr[32]^=ar,lr[33]^=jr,lr[42]^=ar,lr[43]^=jr,ar=ei^(bi<<1|Ai>>>31),jr=Gr^(Ai<<1|bi>>>31),lr[4]^=ar,lr[5]^=jr,lr[14]^=ar,lr[15]^=jr,lr[24]^=ar,lr[25]^=jr,lr[34]^=ar,lr[35]^=jr,lr[44]^=ar,lr[45]^=jr,ar=ti^(Bi<<1|qi>>>31),jr=fi^(qi<<1|Bi>>>31),lr[6]^=ar,lr[7]^=jr,lr[16]^=ar,lr[17]^=jr,lr[26]^=ar,lr[27]^=jr,lr[36]^=ar,lr[37]^=jr,lr[46]^=ar,lr[47]^=jr,ar=bi^(mi<<1|pi>>>31),jr=Ai^(pi<<1|mi>>>31),lr[8]^=ar,lr[9]^=jr,lr[18]^=ar,lr[19]^=jr,lr[28]^=ar,lr[29]^=jr,lr[38]^=ar,lr[39]^=jr,lr[48]^=ar,lr[49]^=jr,vn=lr[0],di=lr[1],gi=lr[11]<<4|lr[10]>>>28,Li=lr[10]<<4|lr[11]>>>28,no=lr[20]<<3|lr[21]>>>29,co=lr[21]<<3|lr[20]>>>29,ya=lr[31]<<9|lr[30]>>>23,ma=lr[30]<<9|lr[31]>>>23,wo=lr[40]<<18|lr[41]>>>14,xi=lr[41]<<18|lr[40]>>>14,To=lr[2]<<1|lr[3]>>>31,Po=lr[3]<<1|lr[2]>>>31,rr=lr[13]<<12|lr[12]>>>20,on=lr[12]<<12|lr[13]>>>20,Qi=lr[22]<<10|lr[23]>>>22,Wi=lr[23]<<10|lr[22]>>>22,Fo=lr[33]<<13|lr[32]>>>19,Io=lr[32]<<13|lr[33]>>>19,fa=lr[42]<<2|lr[43]>>>30,ra=lr[43]<<2|lr[42]>>>30,ca=lr[5]<<30|lr[4]>>>2,Co=lr[4]<<30|lr[5]>>>2,ia=lr[14]<<6|lr[15]>>>26,Jo=lr[15]<<6|lr[14]>>>26,si=lr[25]<<11|lr[24]>>>21,vi=lr[24]<<11|lr[25]>>>21,io=lr[34]<<15|lr[35]>>>17,lo=lr[35]<<15|lr[34]>>>17,Ro=lr[45]<<29|lr[44]>>>3,Oo=lr[44]<<29|lr[45]>>>3,Ci=lr[6]<<28|lr[7]>>>4,Vi=lr[7]<<28|lr[6]>>>4,$o=lr[17]<<23|lr[16]>>>9,ta=lr[16]<<23|lr[17]>>>9,ea=lr[26]<<25|lr[27]>>>7,zi=lr[27]<<25|lr[26]>>>7,Ei=lr[36]<<21|lr[37]>>>11,Mi=lr[37]<<21|lr[36]>>>11,Ao=lr[47]<<24|lr[46]>>>8,_o=lr[46]<<24|lr[47]>>>8,Fi=lr[8]<<27|lr[9]>>>5,Ui=lr[9]<<27|lr[8]>>>5,Hi=lr[18]<<20|lr[19]>>>12,Ji=lr[19]<<20|lr[18]>>>12,sa=lr[29]<<7|lr[28]>>>25,ga=lr[28]<<7|lr[29]>>>25,Gi=lr[38]<<8|lr[39]>>>24,uo=lr[39]<<8|lr[38]>>>24,Di=lr[48]<<14|lr[49]>>>18,Ii=lr[49]<<14|lr[48]>>>18,lr[0]=vn^~rr&si,lr[1]=di^~on&vi,lr[10]=Ci^~Hi&no,lr[11]=Vi^~Ji&co,lr[20]=To^~ia&ea,lr[21]=Po^~Jo&zi,lr[30]=Fi^~gi&Qi,lr[31]=Ui^~Li&Wi,lr[40]=ca^~$o&sa,lr[41]=Co^~ta&ga,lr[2]=rr^~si&Ei,lr[3]=on^~vi&Mi,lr[12]=Hi^~no&Fo,lr[13]=Ji^~co&Io,lr[22]=ia^~ea&Gi,lr[23]=Jo^~zi&uo,lr[32]=gi^~Qi&io,lr[33]=Li^~Wi&lo,lr[42]=$o^~sa&ya,lr[43]=ta^~ga&ma,lr[4]=si^~Ei&Di,lr[5]=vi^~Mi&Ii,lr[14]=no^~Fo&Ro,lr[15]=co^~Io&Oo,lr[24]=ea^~Gi&wo,lr[25]=zi^~uo&xi,lr[34]=Qi^~io&Ao,lr[35]=Wi^~lo&_o,lr[44]=sa^~ya&fa,lr[45]=ga^~ma&ra,lr[6]=Ei^~Di&vn,lr[7]=Mi^~Ii&di,lr[16]=Fo^~Ro&Ci,lr[17]=Io^~Oo&Vi,lr[26]=Gi^~wo&To,lr[27]=uo^~xi&Po,lr[36]=io^~Ao&Fi,lr[37]=lo^~_o&Ui,lr[46]=ya^~fa&ca,lr[47]=ma^~ra&Co,lr[8]=Di^~vn&rr,lr[9]=Ii^~di&on,lr[18]=Ro^~Ci&Hi,lr[19]=Oo^~Vi&Ji,lr[28]=wo^~To&ia,lr[29]=xi^~Po&Jo,lr[38]=Ao^~Fi&gi,lr[39]=_o^~Ui&Li,lr[48]=fa^~ca&$o,lr[49]=ra^~Co&ta,lr[0]^=b[ci],lr[1]^=b[ci+1]};if(a)e.exports=L;else for(F=0;F<_.length;++F)o[_[F]]=L[_[F]]})()})(sha3$1)),sha3$1.exports}var sha3Exports=requireSha3();const sha3=getDefaultExportFromCjs(sha3Exports),{keccak_256:keccak_256$1}=sha3;function createMessageForBatcher(e,t,r,n,o,i=void 0){const a=CryptoManager.getCryptoManager(n).decodeAddress(r);return(""+(i??"")+t+a+o).replace(/[^a-zA-Z0-9]/g,"-").toLocaleLowerCase()}const AddressType={EVM:0};async function createSignedInput(e,t,r=void 0){const n=privateKeyToAccount(t.privateKey),o=createWalletClient({account:n,chain:hardhat,transport:http()}),i=Date.now().toString(),u=n.address,a=AddressType.EVM,s=createMessageForBatcher(null,i,u,a,e,r),f=await o.signMessage({account:n,message:s});return{addressType:a,address:u,signature:f,input:e,timestamp:i,target:r}}async function sendInputToBatcher(e){const t=await fetch(BATCHER_ENDPOINT,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e})});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}async function postToBatcher(e,t,r=void 0){console.log("🚀 Creating signed input for:",e);const n=await createSignedInput(e,t,r);console.log("✅ Signed input created:",{...n,signature:n.signature.slice(0,10)+"..."}),console.log("📤 Sending to batcher...");const o=await sendInputToBatcher(n);return console.log("🎉 Batcher response:",o),o}function AddressesTable(){const[e,t]=reactExports.useState([]),[r,n]=reactExports.useState(!0),[o,i]=reactExports.useState(null),[u,a]=reactExports.useState(10),[s,f]=reactExports.useState(0),[c,d]=reactExports.useState([void 0]),[p,h]=reactExports.useState(!1),[y,b]=reactExports.useState([]),[w,S]=reactExports.useState(null),[E,B]=reactExports.useState([]),[ae,W]=reactExports.useState(!1),[J,ve]=reactExports.useState(!1),[Qe,kt]=reactExports.useState(!1),[nr,sr]=reactExports.useState(""),[ce,Ze]=reactExports.useState(""),[se,vt]=reactExports.useState(""),[ur,ue]=reactExports.useState(null),[bt,L]=reactExports.useState(null),_=(pi,ei,Gr)=>{const ti=Date.now(),fi={id:ti,type:pi,title:ei,message:Gr};B(bi=>[...bi,fi]),setTimeout(()=>{B(bi=>bi.filter(Ai=>Ai.id!==ti))},5e3)},F=pi=>{B(ei=>ei.filter(Gr=>Gr.id!==pi))},k=()=>{const pi=generatePrivateKey(),ei=privateKeyToAccount(pi),Gr={id:Date.now().toString(),privateKey:pi,address:ei.address,name:`Wallet ${y.length+1}`};b(ti=>[...ti,Gr]),S(Gr),_("success","Wallet Generated",`New wallet created: ${ei.address.slice(0,6)}...${ei.address.slice(-4)}`)},Ye=pi=>{b(ei=>ei.filter(Gr=>Gr.id!==pi)),w?.id===pi&&S(null)},rn=async()=>{if(!w){_("error","No Wallet","Please select a wallet first");return}kt(!0);try{const ei=JSON.stringify(["&createAccount"]);await postToBatcher(ei,w),_("success","Account Created","Successfully created account! Use the refresh button to see updated addresses.")}catch(pi){_("error","Create Account Error",`Error creating account: ${pi instanceof Error?pi.message:"Unknown error"}`)}finally{kt(!1)}},ii=async()=>{if(!w){_("error","No Wallet","Please select a wallet first");return}if(!ur){_("error","No Account","Please select an account ID");return}kt(!0);try{const pi=["&unlinkAddress",ur.toString(),"","",""],ei=JSON.stringify(pi);await postToBatcher(ei,w),_("success","Self Unlinked","Successfully unlinked self from account! Use the refresh button to see updated addresses.")}catch(pi){_("error","Unlink Self Error",`Error unlinking self: ${pi instanceof Error?pi.message:"Unknown error"}`)}finally{kt(!1)}},ai=async()=>{if(!w){_("error","No Wallet","Please select a wallet first");return}if(!ur){_("error","No Account","Please select an account ID");return}if(!se.trim()){_("error","No Address","Please enter an address to unlink");return}const pi=createWalletClient({account:privateKeyToAccount(w.privateKey),chain:hardhat,transport:http()});kt(!0);const ei=`unlink:${String(ur)}:${se.toString().toLowerCase().trim()}:`,Gr=await pi.signMessage({account:privateKeyToAccount(w.privateKey),message:ei});try{const ti=["&unlinkAddress",ur.toString(),Gr,se.toString().toLowerCase().trim(),""],fi=JSON.stringify(ti);await postToBatcher(fi,w),_("success","Address Unlinked","Successfully unlinked address from account! Use the refresh button to see updated addresses."),vt("")}catch(ti){_("error","Unlink Other Error",`Error unlinking address: ${ti instanceof Error?ti.message:"Unknown error"}`)}finally{kt(!1)}},ni=async()=>{if(!w){_("error","No Wallet","Please select a wallet first");return}if(!ur){_("error","No Account","Please select an account ID");return}if(!bt){_("error","No Link Wallet","Please select a wallet to link");return}kt(!0);try{const pi=createWalletClient({account:privateKeyToAccount(w.privateKey),chain:hardhat,transport:http()}),ei=createWalletClient({account:privateKeyToAccount(bt.privateKey),chain:hardhat,transport:http()}),Gr=`link:${ur}:${bt.address.toString().toLowerCase().trim()}:false`,ti=await pi.signMessage({account:privateKeyToAccount(w.privateKey),message:Gr}),fi=`link:${ur}:${w.address.toString().toLowerCase().trim()}:false`,bi=await ei.signMessage({account:privateKeyToAccount(bt.privateKey),message:fi}),Ai=["&linkAddress",ur.toString(),ti,bt.address.toString().toLowerCase().trim(),bi,"false"],Bi=JSON.stringify(Ai);await postToBatcher(Bi,w),_("success","Address Linked","Successfully linked address to account! Use the refresh button to see updated addresses."),L(null)}catch(pi){_("error","Link Address Error",`Error linking address: ${pi instanceof Error?pi.message:"Unknown error"}`)}finally{kt(!1)}},ri=async()=>{try{n(!0),i(null);const pi=new URL(ADDRESSES_ENDPOINT);pi.searchParams.set("limit",String(u));const ei=c[s];ei&&pi.searchParams.set("after",ei);const Gr=await fetch(pi.toString());if(!Gr.ok)throw new Error(`HTTP error! status: ${Gr.status}`);const ti=await Gr.json(),fi=ti.data??[];t(fi),ti.pagination&&(h(ti.pagination.hasMore??!1),ti.pagination.nextCursor&&c.length===s+1&&d(bi=>[...bi,ti.pagination.nextCursor]))}catch(pi){console.error("Error fetching addresses:",pi),i(pi instanceof Error?pi.message:"Unknown error")}finally{n(!1)}};reactExports.useEffect(()=>{ri()},[u,s]);const ui=e.reduce((pi,ei)=>{const Gr=pi.find(ti=>ti.account_id===ei.account_id);return Gr?(Gr.addresses.includes(ei.address)||Gr.addresses.push(ei.address),ei.primary_address&&(Gr.hasPrimaryAddress=!0,Gr.primaryAddress=ei.primary_address)):pi.push({account_id:ei.account_id,addresses:[ei.address],hasPrimaryAddress:!!ei.primary_address,primaryAddress:ei.primary_address}),pi},[]),lr=[...new Set(ui.map(pi=>pi.account_id).filter(pi=>pi!==null))],ar=pi=>{a(Number(pi.target.value)),f(0),d([void 0])},jr=()=>{p&&f(pi=>pi+1)},ci=()=>{f(pi=>Math.max(0,pi-1))},mi=()=>{f(0)};return r?jsxRuntimeExports.jsx("div",{className:"addresses-loading",children:jsxRuntimeExports.jsx("div",{className:"loading-text",children:"Loading addresses..."})}):o?jsxRuntimeExports.jsx("div",{className:"addresses-error",children:jsxRuntimeExports.jsxs("div",{className:"error-text",children:["Error loading addresses: ",o]})}):jsxRuntimeExports.jsxs("div",{className:"addresses-table-container",children:[jsxRuntimeExports.jsx("div",{style:{position:"fixed",top:"20px",right:"20px",zIndex:1e3,display:"flex",flexDirection:"column",gap:"10px"},children:E.map(pi=>jsxRuntimeExports.jsxs("div",{style:{background:pi.type==="success"?"#10b981":pi.type==="error"?"#ef4444":"#3b82f6",color:"white",padding:"12px 16px",borderRadius:"8px",minWidth:"300px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",display:"flex",justifyContent:"space-between",alignItems:"flex-start",animation:"slideIn 0.3s ease-out"},children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:pi.title}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",opacity:.9},children:pi.message})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>F(pi.id),style:{background:"none",border:"none",color:"white",cursor:"pointer",fontSize:"18px",padding:"0",marginLeft:"12px",opacity:.7},children:"×"})]},pi.id))}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"20px",padding:"20px",border:"1px solid #ddd",borderRadius:"8px",background:"#f8fafc"},children:[jsxRuntimeExports.jsxs("div",{onClick:()=>W(!ae),style:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",marginBottom:ae?0:"20px"},children:[jsxRuntimeExports.jsx("h3",{style:{margin:0,color:"#333"},children:"Wallet Management"}),jsxRuntimeExports.jsx("span",{style:{fontSize:"18px",color:"#666",transform:ae?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.2s ease-in-out"},children:"▼"})]}),!ae&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{style:{marginBottom:"20px"},children:jsxRuntimeExports.jsx("button",{type:"button",onClick:k,style:{padding:"10px 16px",background:"linear-gradient(45deg, #19b17b, #022418)",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:"600",fontSize:"14px"},children:"Generate New EVM Wallet"})}),y.length>0&&jsxRuntimeExports.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 10px 0",color:"#333"},children:"Available Wallets:"}),jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:y.map(pi=>jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px",border:w?.id===pi.id?"2px solid #19b17b":"1px solid #ddd",borderRadius:"6px",background:w?.id===pi.id?"#f0fdf4":"white"},children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"selectedWallet",checked:w?.id===pi.id,onChange:()=>S(pi),style:{margin:0}}),jsxRuntimeExports.jsx("span",{style:{fontSize:"14px",fontFamily:"monospace",color:"#666",flex:"1"},children:pi.name}),jsxRuntimeExports.jsx("span",{style:{fontSize:"14px",fontFamily:"monospace",color:"#666",flex:"2"},children:pi.address}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>Ye(pi.id),style:{padding:"4px 8px",background:"#ef4444",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px"},children:"Remove"})]},pi.id))})]})]})]}),w&&jsxRuntimeExports.jsxs("div",{style:{marginBottom:"20px",padding:"20px",border:"1px solid #ddd",borderRadius:"8px",background:"#fef7ff"},children:[jsxRuntimeExports.jsxs("div",{onClick:()=>ve(!J),style:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",marginBottom:J?0:"20px"},children:[jsxRuntimeExports.jsx("h3",{style:{margin:0,color:"#333"},children:"Account Commands"}),jsxRuntimeExports.jsx("span",{style:{fontSize:"18px",color:"#666",transform:J?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.2s ease-in-out"},children:"▼"})]}),!J&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"10px",fontWeight:"600",fontSize:"16px"},children:"What would you like to do?"}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px",border:nr==="create"?"2px solid #19b17b":"1px solid #ddd",borderRadius:"6px",background:nr==="create"?"#f0fdf4":"white",cursor:"pointer"},onClick:()=>sr("create"),children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"action",checked:nr==="create",onChange:()=>sr("create"),style:{margin:0}}),jsxRuntimeExports.jsxs("div",{style:{flex:"1"},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:"1. Create new account"}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",color:"#666",fontStyle:"italic"},children:"Can only create if not linked to any account"})]})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px",border:nr==="link"?"2px solid #3b82f6":"1px solid #ddd",borderRadius:"6px",background:nr==="link"?"#eff6ff":"white",cursor:"pointer"},onClick:()=>sr("link"),children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"action",checked:nr==="link",onChange:()=>sr("link"),style:{margin:0}}),jsxRuntimeExports.jsxs("div",{style:{flex:"1"},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:"2. Link Account"}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",color:"#666",fontStyle:"italic"},children:"Only Account Primary can do this Action"})]})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px",border:nr==="unlink-other"?"2px solid #f59e0b":"1px solid #ddd",borderRadius:"6px",background:nr==="unlink-other"?"#fffbeb":"white",cursor:"pointer"},onClick:()=>sr("unlink-other"),children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"action",checked:nr==="unlink-other",onChange:()=>sr("unlink-other"),style:{margin:0}}),jsxRuntimeExports.jsxs("div",{style:{flex:"1"},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:"3. Unlink Account"}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",color:"#666",fontStyle:"italic"},children:"Only Account Primary can do this Action"})]})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px",border:nr==="unlink-self"?"2px solid #ef4444":"1px solid #ddd",borderRadius:"6px",background:nr==="unlink-self"?"#fef2f2":"white",cursor:"pointer"},onClick:()=>sr("unlink-self"),children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"action",checked:nr==="unlink-self",onChange:()=>sr("unlink-self"),style:{margin:0}}),jsxRuntimeExports.jsxs("div",{style:{flex:"1"},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:"4. Unlink Self"}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",color:"#666",fontStyle:"italic"},children:"Unlink self from account"})]})]})]})]}),nr&&jsxRuntimeExports.jsxs("div",{style:{marginTop:"20px",padding:"20px",background:"#f8fafc",borderRadius:"8px",border:"1px solid #e2e8f0"},children:[nr==="create"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 15px 0",color:"#333"},children:"Create New Account"}),jsxRuntimeExports.jsx("p",{style:{margin:"0 0 15px 0",color:"#666",fontSize:"14px"},children:"This will create a new account with your selected wallet as the primary address."}),jsxRuntimeExports.jsx("button",{type:"button",onClick:rn,disabled:Qe,style:{padding:"10px 20px",background:Qe?"#ccc":"linear-gradient(45deg, #19b17b, #022418)",color:"white",border:"none",borderRadius:"6px",cursor:Qe?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:Qe?"Creating...":"Create Account"})]}),nr==="link"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 15px 0",color:"#333"},children:"Link Account"}),jsxRuntimeExports.jsx("p",{style:{margin:"0 0 15px 0",color:"#666",fontSize:"14px"},children:"Link a wallet to an existing account. You must be the primary address of the account, and the wallet to link must have a private key."}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Account ID:"}),jsxRuntimeExports.jsxs("select",{value:ur||"",onChange:pi=>ue(pi.target.value?parseInt(pi.target.value):null),style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"200px"},children:[jsxRuntimeExports.jsx("option",{value:"",children:"-- Select Account ID --"}),lr.map(pi=>jsxRuntimeExports.jsxs("option",{value:pi,children:["Account ",pi]},pi))]})]}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Wallet to Link:"}),jsxRuntimeExports.jsxs("select",{value:bt?.id||"",onChange:pi=>{const ei=y.find(Gr=>Gr.id===pi.target.value);L(ei||null)},style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"300px"},children:[jsxRuntimeExports.jsx("option",{value:"",children:"-- Select a wallet to link --"}),y.filter(pi=>pi.id!==w?.id).map(pi=>jsxRuntimeExports.jsxs("option",{value:pi.id,children:[pi.name," (",pi.address,")"]},pi.id))]})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:ni,disabled:Qe||!ur||!bt,style:{padding:"10px 20px",background:Qe||!ur||!bt?"#ccc":"linear-gradient(45deg, #3b82f6, #1e3a8a)",color:"white",border:"none",borderRadius:"6px",cursor:Qe||!ur||!bt?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:Qe?"Linking...":"Link Wallet"})]}),nr==="unlink-other"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 15px 0",color:"#333"},children:"Unlink Account"}),jsxRuntimeExports.jsx("p",{style:{margin:"0 0 15px 0",color:"#666",fontSize:"14px"},children:"Unlink a specific address from an account. You must be the primary address of the account."}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Account ID:"}),jsxRuntimeExports.jsxs("select",{value:ur||"",onChange:pi=>ue(pi.target.value?parseInt(pi.target.value):null),style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"200px"},children:[jsxRuntimeExports.jsx("option",{value:"",children:"-- Select Account ID --"}),lr.map(pi=>jsxRuntimeExports.jsxs("option",{value:pi,children:["Account ",pi]},pi))]})]}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Address to Unlink:"}),jsxRuntimeExports.jsx("input",{type:"text",value:se,onChange:pi=>vt(pi.target.value),placeholder:"Enter address to unlink",style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"300px"}})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:ai,disabled:Qe||!ur||!se.trim(),style:{padding:"10px 20px",background:Qe||!ur||!se.trim()?"#ccc":"linear-gradient(45deg, #f59e0b, #92400e)",color:"white",border:"none",borderRadius:"6px",cursor:Qe||!ur||!se.trim()?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:Qe?"Unlinking...":"Unlink Address"})]}),nr==="unlink-self"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 15px 0",color:"#333"},children:"Unlink Self"}),jsxRuntimeExports.jsx("p",{style:{margin:"0 0 15px 0",color:"#666",fontSize:"14px"},children:"Unlink yourself from an account. This will remove your address from the account."}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Account ID:"}),jsxRuntimeExports.jsxs("select",{value:ur||"",onChange:pi=>ue(pi.target.value?parseInt(pi.target.value):null),style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"200px"},children:[jsxRuntimeExports.jsx("option",{value:"",children:"-- Select Account ID --"}),lr.map(pi=>jsxRuntimeExports.jsxs("option",{value:pi,children:["Account ",pi]},pi))]})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:ii,disabled:Qe||!ur,style:{padding:"10px 20px",background:Qe||!ur?"#ccc":"linear-gradient(45deg, #ef4444, #7f1d1d)",color:"white",border:"none",borderRadius:"6px",cursor:Qe||!ur?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:Qe?"Unlinking...":"Unlink Self"})]})]})]})]}),jsxRuntimeExports.jsxs("div",{className:"addresses-table-wrapper",children:[jsxRuntimeExports.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"15px"},children:[jsxRuntimeExports.jsx("h3",{style:{margin:0,color:"#333"},children:"Addresses"}),jsxRuntimeExports.jsx("div",{className:"table-controls",children:jsxRuntimeExports.jsxs("label",{children:["Rows per page:",jsxRuntimeExports.jsxs("select",{value:u,onChange:ar,children:[jsxRuntimeExports.jsx("option",{value:10,children:"10"}),jsxRuntimeExports.jsx("option",{value:20,children:"20"}),jsxRuntimeExports.jsx("option",{value:50,children:"50"})]})]})})]}),r&&jsxRuntimeExports.jsx("p",{children:"Loading..."}),o&&jsxRuntimeExports.jsx("p",{className:"error",children:o}),!r&&!o&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("table",{className:"addresses-table",children:[jsxRuntimeExports.jsx("thead",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("th",{children:"Account ID"}),jsxRuntimeExports.jsx("th",{children:"Addresses"})]})}),jsxRuntimeExports.jsx("tbody",{children:ui.map((pi,ei)=>jsxRuntimeExports.jsxs("tr",{className:pi.hasPrimaryAddress?"has-primary-address":"",children:[jsxRuntimeExports.jsx("td",{className:"account-id-cell",children:jsxRuntimeExports.jsx("div",{className:"account-id-content",children:pi.account_id??"No Account ID"})}),jsxRuntimeExports.jsx("td",{className:"addresses-cell",children:pi.addresses.map((Gr,ti)=>jsxRuntimeExports.jsxs("div",{className:`address-item ${Gr===pi.primaryAddress?"primary-address":""}`,title:Gr===pi.primaryAddress?`${Gr} (Primary)`:Gr,children:[Gr,Gr===pi.primaryAddress&&jsxRuntimeExports.jsx("span",{className:"primary-badge",children:"Primary"})]},Gr))})]},pi.account_id??`null-${ei}`))})]}),jsxRuntimeExports.jsxs("div",{className:"pagination-controls",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:mi,disabled:s===0,children:"First"}),jsxRuntimeExports.jsx("button",{type:"button",onClick:ci,disabled:s===0,children:"Previous"}),jsxRuntimeExports.jsx("button",{type:"button",onClick:jr,disabled:!p||e.length<u,children:"Next"})]})]})]}),ui.length===0&&jsxRuntimeExports.jsx("div",{className:"no-addresses",children:jsxRuntimeExports.jsx("div",{className:"no-data-text",children:"No addresses found"})}),jsxRuntimeExports.jsx("style",{children:`
196
+ */class MinaCrypto{constructor(){this.verifyAddress=t=>Check(TypeboxHelpers.Mina.Address,t),this.verifySignature=async(t,r,n)=>{try{const[o,i,u,...a]=n.split(";");if(!o||!i||!u||a.length>0)return!1;const s=new _1({network:u}),f={data:r,publicKey:t,signature:{field:o,scalar:i}};return s.verifyMessage(f)}catch(o){return console.error("[address-validator] error verifying mina signature:",o),!1}}}decodeAddress(t){return Decode(TypeboxHelpers.Mina.Address,t)}}class MidnightCrypto{constructor(){this.isMidnightSignature=t=>Check(TypeboxHelpers.Midnight.Signature,t),this.verifyAddress=t=>Check(TypeboxHelpers.Midnight.Address,t),this.verifySignature=async(t,r,n)=>{try{if(this.verifyAddress(t)&&this.isMidnightSignature(n))return console.log("TODO: MIDNIGHT SIGNATURE NYI:",{signerAddress:t,message:r,signature:n}),!1}catch{}return!1}}decodeAddress(t){return Decode(TypeboxHelpers.Midnight.Address,t)}}class CryptoManager{static Algorand(){return CryptoManager.algorand==null&&(CryptoManager.algorand=new AlgorandCrypto),CryptoManager.algorand}static Cardano(){return CryptoManager.cardano==null&&(CryptoManager.cardano=new CardanoCrypto),CryptoManager.cardano}static Evm(){return CryptoManager.evm==null&&(CryptoManager.evm=new EvmCrypto),CryptoManager.evm}static Polkadot(){return CryptoManager.polkadot==null&&(CryptoManager.polkadot=new PolkadotCrypto),CryptoManager.polkadot}static Mina(){return CryptoManager.mina==null&&(CryptoManager.mina=new MinaCrypto),CryptoManager.mina}static Midnight(){return CryptoManager.midnight==null&&(CryptoManager.midnight=new MidnightCrypto),CryptoManager.midnight}static getCryptoManager(t){switch(t){case AddressType$1.EVM:return CryptoManager.Evm();case AddressType$1.CARDANO:return CryptoManager.Cardano();case AddressType$1.POLKADOT:return CryptoManager.Polkadot();case AddressType$1.ALGORAND:return CryptoManager.Algorand();case AddressType$1.MINA:return CryptoManager.Mina();case AddressType$1.MIDNIGHT:return CryptoManager.Midnight();default:throw new Error(`Unsupported address type: ${t}`)}}}requireCryptoBrowserify();function toKeyedJsonGrammar(e){return Object.fromEntries(Object.entries(e).map(([r,n])=>{const o=n.map(([u,a])=>a),i=Type.Tuple([Type.Literal(r),...o]);return[r,i]}))}function userAddress(e){return["userAddress",AddressValidator[e]]}const BatcherInnerCommon=[["userSignature",Type.String()],["conciseInput",Type.String()],["millisecondTimestamp",Type.String()]],BatcherInnerGrammar={[`${AddressType$1.NONE}`]:[userAddress(AddressType$1.NONE),...BatcherInnerCommon],[`${AddressType$1.EVM}`]:[userAddress(AddressType$1.EVM),...BatcherInnerCommon],[`${AddressType$1.CARDANO}`]:[userAddress(AddressType$1.CARDANO),...BatcherInnerCommon],[`${AddressType$1.SUBSTRATE}`]:[userAddress(AddressType$1.SUBSTRATE),...BatcherInnerCommon],[`${AddressType$1.AVAIL}`]:[userAddress(AddressType$1.AVAIL),...BatcherInnerCommon],[`${AddressType$1.ALGORAND}`]:[userAddress(AddressType$1.ALGORAND),...BatcherInnerCommon],[`${AddressType$1.MINA}`]:[userAddress(AddressType$1.MINA),...BatcherInnerCommon],[`${AddressType$1.MIDNIGHT}`]:[userAddress(AddressType$1.MIDNIGHT),...BatcherInnerCommon],[`${AddressType$1.POLKADOT}`]:[userAddress(AddressType$1.POLKADOT),...BatcherInnerCommon]};toKeyedJsonGrammar(BatcherInnerGrammar);const BatcherGrammarPrefix={batcherInput:"&B"},BatcherGrammar={[BatcherGrammarPrefix.batcherInput]:[["input",Type.Array(Type.String())]]};toKeyedJsonGrammar(BatcherGrammar);const BuiltinGrammarPrefix={createAccount:"&createAccount",linkAddress:"&linkAddress",unlinkAddress:"&unlinkAddress"},BuiltinGrammar={[BuiltinGrammarPrefix.createAccount]:[],[BuiltinGrammarPrefix.linkAddress]:[["account_id",Type.Number()],["signature_from_primary",Type.String()],["primary_address_type",Type.Number()],["new_address",Type.String()],["signature_from_new_address",Type.String()],["new_address_type",Type.Number()],["is_new_primary",Type.Boolean()]],[BuiltinGrammarPrefix.unlinkAddress]:[["account_id",Type.Number()],["signature_from_primary",Type.String()],["primary_address_type",Type.Number()],["target_address",Type.String()],["target_address_type",Type.Number()],["new_primary_address",Type.String()],["new_primary_address_type",Type.Number()]]};toKeyedJsonGrammar(BuiltinGrammar);var sha3$1={exports:{}},hasRequiredSha3;function requireSha3(){return hasRequiredSha3||(hasRequiredSha3=1,(function(e){(function(){var t="input is invalid type",r="finalize already called",n=typeof window=="object",o=n?window:{};o.JS_SHA3_NO_WINDOW&&(n=!1);var i=!n&&typeof self=="object",u=!o.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;u?o=commonjsGlobal:i&&(o=self);for(var a=!o.JS_SHA3_NO_COMMON_JS&&!0&&e.exports,s=!o.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),c=[31,7936,2031616,520093696],d=[4,1024,262144,67108864],p=[1,256,65536,16777216],h=[6,1536,393216,100663296],y=[0,8,16,24],b=[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],w=[224,256,384,512],S=[128,256],E=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136},ae=o.JS_SHA3_NO_NODE_JS||!Array.isArray?function(lr){return Object.prototype.toString.call(lr)==="[object Array]"}:Array.isArray,W=s&&(o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(lr){return typeof lr=="object"&&lr.buffer&&lr.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,J=function(lr){var ar=typeof lr;if(ar==="string")return[lr,!0];if(ar!=="object"||lr===null)throw new Error(t);if(s&&lr.constructor===ArrayBuffer)return[new Uint8Array(lr),!1];if(!ae(lr)&&!W(lr))throw new Error(t);return[lr,!1]},ve=function(lr){return J(lr)[0].length===0},Qe=function(lr){for(var ar=[],jr=0;jr<lr.length;++jr)ar[jr]=lr[jr];return ar},kt=function(lr,ar,jr){return function(ci){return new ni(lr,ar,lr).update(ci)[jr]()}},nr=function(lr,ar,jr){return function(ci,mi){return new ni(lr,ar,mi).update(ci)[jr]()}},sr=function(lr,ar,jr){return function(ci,mi,pi,ei){return L["cshake"+lr].update(ci,mi,pi,ei)[jr]()}},ce=function(lr,ar,jr){return function(ci,mi,pi,ei){return L["kmac"+lr].update(ci,mi,pi,ei)[jr]()}},Ze=function(lr,ar,jr,ci){for(var mi=0;mi<E.length;++mi){var pi=E[mi];lr[pi]=ar(jr,ci,pi)}return lr},se=function(lr,ar){var jr=kt(lr,ar,"hex");return jr.create=function(){return new ni(lr,ar,lr)},jr.update=function(ci){return jr.create().update(ci)},Ze(jr,kt,lr,ar)},vt=function(lr,ar){var jr=nr(lr,ar,"hex");return jr.create=function(ci){return new ni(lr,ar,ci)},jr.update=function(ci,mi){return jr.create(mi).update(ci)},Ze(jr,nr,lr,ar)},ur=function(lr,ar){var jr=B[lr],ci=sr(lr,ar,"hex");return ci.create=function(mi,pi,ei){return ve(pi)&&ve(ei)?L["shake"+lr].create(mi):new ni(lr,ar,mi).bytepad([pi,ei],jr)},ci.update=function(mi,pi,ei,Gr){return ci.create(pi,ei,Gr).update(mi)},Ze(ci,sr,lr,ar)},ue=function(lr,ar){var jr=B[lr],ci=ce(lr,ar,"hex");return ci.create=function(mi,pi,ei){return new ri(lr,ar,pi).bytepad(["KMAC",ei],jr).bytepad([mi],jr)},ci.update=function(mi,pi,ei,Gr){return ci.create(mi,ei,Gr).update(pi)},Ze(ci,ce,lr,ar)},bt=[{name:"keccak",padding:p,bits:w,createMethod:se},{name:"sha3",padding:h,bits:w,createMethod:se},{name:"shake",padding:c,bits:S,createMethod:vt},{name:"cshake",padding:d,bits:S,createMethod:ur},{name:"kmac",padding:d,bits:S,createMethod:ue}],L={},_=[],F=0;F<bt.length;++F)for(var k=bt[F],Ye=k.bits,rn=0;rn<Ye.length;++rn){var ii=k.name+"_"+Ye[rn];if(_.push(ii),L[ii]=k.createMethod(Ye[rn],k.padding),k.name!=="sha3"){var ai=k.name+Ye[rn];_.push(ai),L[ai]=L[ii]}}function ni(lr,ar,jr){this.blocks=[],this.s=[],this.padding=ar,this.outputBits=jr,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(lr<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=jr>>5,this.extraBytes=(jr&31)>>3;for(var ci=0;ci<50;++ci)this.s[ci]=0}ni.prototype.update=function(lr){if(this.finalized)throw new Error(r);var ar=J(lr);lr=ar[0];for(var jr=ar[1],ci=this.blocks,mi=this.byteCount,pi=lr.length,ei=this.blockCount,Gr=0,ti=this.s,fi,bi;Gr<pi;){if(this.reset)for(this.reset=!1,ci[0]=this.block,fi=1;fi<ei+1;++fi)ci[fi]=0;if(jr)for(fi=this.start;Gr<pi&&fi<mi;++Gr)bi=lr.charCodeAt(Gr),bi<128?ci[fi>>2]|=bi<<y[fi++&3]:bi<2048?(ci[fi>>2]|=(192|bi>>6)<<y[fi++&3],ci[fi>>2]|=(128|bi&63)<<y[fi++&3]):bi<55296||bi>=57344?(ci[fi>>2]|=(224|bi>>12)<<y[fi++&3],ci[fi>>2]|=(128|bi>>6&63)<<y[fi++&3],ci[fi>>2]|=(128|bi&63)<<y[fi++&3]):(bi=65536+((bi&1023)<<10|lr.charCodeAt(++Gr)&1023),ci[fi>>2]|=(240|bi>>18)<<y[fi++&3],ci[fi>>2]|=(128|bi>>12&63)<<y[fi++&3],ci[fi>>2]|=(128|bi>>6&63)<<y[fi++&3],ci[fi>>2]|=(128|bi&63)<<y[fi++&3]);else for(fi=this.start;Gr<pi&&fi<mi;++Gr)ci[fi>>2]|=lr[Gr]<<y[fi++&3];if(this.lastByteIndex=fi,fi>=mi){for(this.start=fi-mi,this.block=ci[ei],fi=0;fi<ei;++fi)ti[fi]^=ci[fi];ui(ti),this.reset=!0}else this.start=fi}return this},ni.prototype.encode=function(lr,ar){var jr=lr&255,ci=1,mi=[jr];for(lr=lr>>8,jr=lr&255;jr>0;)mi.unshift(jr),lr=lr>>8,jr=lr&255,++ci;return ar?mi.push(ci):mi.unshift(ci),this.update(mi),mi.length},ni.prototype.encodeString=function(lr){var ar=J(lr);lr=ar[0];var jr=ar[1],ci=0,mi=lr.length;if(jr)for(var pi=0;pi<lr.length;++pi){var ei=lr.charCodeAt(pi);ei<128?ci+=1:ei<2048?ci+=2:ei<55296||ei>=57344?ci+=3:(ei=65536+((ei&1023)<<10|lr.charCodeAt(++pi)&1023),ci+=4)}else ci=mi;return ci+=this.encode(ci*8),this.update(lr),ci},ni.prototype.bytepad=function(lr,ar){for(var jr=this.encode(ar),ci=0;ci<lr.length;++ci)jr+=this.encodeString(lr[ci]);var mi=(ar-jr%ar)%ar,pi=[];return pi.length=mi,this.update(pi),this},ni.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var lr=this.blocks,ar=this.lastByteIndex,jr=this.blockCount,ci=this.s;if(lr[ar>>2]|=this.padding[ar&3],this.lastByteIndex===this.byteCount)for(lr[0]=lr[jr],ar=1;ar<jr+1;++ar)lr[ar]=0;for(lr[jr-1]|=2147483648,ar=0;ar<jr;++ar)ci[ar]^=lr[ar];ui(ci)}},ni.prototype.toString=ni.prototype.hex=function(){this.finalize();for(var lr=this.blockCount,ar=this.s,jr=this.outputBlocks,ci=this.extraBytes,mi=0,pi=0,ei="",Gr;pi<jr;){for(mi=0;mi<lr&&pi<jr;++mi,++pi)Gr=ar[mi],ei+=f[Gr>>4&15]+f[Gr&15]+f[Gr>>12&15]+f[Gr>>8&15]+f[Gr>>20&15]+f[Gr>>16&15]+f[Gr>>28&15]+f[Gr>>24&15];pi%lr===0&&(ar=Qe(ar),ui(ar),mi=0)}return ci&&(Gr=ar[mi],ei+=f[Gr>>4&15]+f[Gr&15],ci>1&&(ei+=f[Gr>>12&15]+f[Gr>>8&15]),ci>2&&(ei+=f[Gr>>20&15]+f[Gr>>16&15])),ei},ni.prototype.arrayBuffer=function(){this.finalize();var lr=this.blockCount,ar=this.s,jr=this.outputBlocks,ci=this.extraBytes,mi=0,pi=0,ei=this.outputBits>>3,Gr;ci?Gr=new ArrayBuffer(jr+1<<2):Gr=new ArrayBuffer(ei);for(var ti=new Uint32Array(Gr);pi<jr;){for(mi=0;mi<lr&&pi<jr;++mi,++pi)ti[pi]=ar[mi];pi%lr===0&&(ar=Qe(ar),ui(ar))}return ci&&(ti[pi]=ar[mi],Gr=Gr.slice(0,ei)),Gr},ni.prototype.buffer=ni.prototype.arrayBuffer,ni.prototype.digest=ni.prototype.array=function(){this.finalize();for(var lr=this.blockCount,ar=this.s,jr=this.outputBlocks,ci=this.extraBytes,mi=0,pi=0,ei=[],Gr,ti;pi<jr;){for(mi=0;mi<lr&&pi<jr;++mi,++pi)Gr=pi<<2,ti=ar[mi],ei[Gr]=ti&255,ei[Gr+1]=ti>>8&255,ei[Gr+2]=ti>>16&255,ei[Gr+3]=ti>>24&255;pi%lr===0&&(ar=Qe(ar),ui(ar))}return ci&&(Gr=pi<<2,ti=ar[mi],ei[Gr]=ti&255,ci>1&&(ei[Gr+1]=ti>>8&255),ci>2&&(ei[Gr+2]=ti>>16&255)),ei};function ri(lr,ar,jr){ni.call(this,lr,ar,jr)}ri.prototype=new ni,ri.prototype.finalize=function(){return this.encode(this.outputBits,!0),ni.prototype.finalize.call(this)};var ui=function(lr){var ar,jr,ci,mi,pi,ei,Gr,ti,fi,bi,Ai,Bi,qi,vn,di,rr,on,si,vi,Ei,Mi,Di,Ii,Ci,Vi,Hi,Ji,no,co,Fo,Io,Ro,Oo,To,Po,ia,Jo,ea,zi,Gi,uo,wo,xi,Fi,Ui,gi,Li,Qi,Wi,io,lo,Ao,_o,ca,Co,$o,ta,sa,ga,ya,ma,fa,ra;for(ci=0;ci<48;ci+=2)mi=lr[0]^lr[10]^lr[20]^lr[30]^lr[40],pi=lr[1]^lr[11]^lr[21]^lr[31]^lr[41],ei=lr[2]^lr[12]^lr[22]^lr[32]^lr[42],Gr=lr[3]^lr[13]^lr[23]^lr[33]^lr[43],ti=lr[4]^lr[14]^lr[24]^lr[34]^lr[44],fi=lr[5]^lr[15]^lr[25]^lr[35]^lr[45],bi=lr[6]^lr[16]^lr[26]^lr[36]^lr[46],Ai=lr[7]^lr[17]^lr[27]^lr[37]^lr[47],Bi=lr[8]^lr[18]^lr[28]^lr[38]^lr[48],qi=lr[9]^lr[19]^lr[29]^lr[39]^lr[49],ar=Bi^(ei<<1|Gr>>>31),jr=qi^(Gr<<1|ei>>>31),lr[0]^=ar,lr[1]^=jr,lr[10]^=ar,lr[11]^=jr,lr[20]^=ar,lr[21]^=jr,lr[30]^=ar,lr[31]^=jr,lr[40]^=ar,lr[41]^=jr,ar=mi^(ti<<1|fi>>>31),jr=pi^(fi<<1|ti>>>31),lr[2]^=ar,lr[3]^=jr,lr[12]^=ar,lr[13]^=jr,lr[22]^=ar,lr[23]^=jr,lr[32]^=ar,lr[33]^=jr,lr[42]^=ar,lr[43]^=jr,ar=ei^(bi<<1|Ai>>>31),jr=Gr^(Ai<<1|bi>>>31),lr[4]^=ar,lr[5]^=jr,lr[14]^=ar,lr[15]^=jr,lr[24]^=ar,lr[25]^=jr,lr[34]^=ar,lr[35]^=jr,lr[44]^=ar,lr[45]^=jr,ar=ti^(Bi<<1|qi>>>31),jr=fi^(qi<<1|Bi>>>31),lr[6]^=ar,lr[7]^=jr,lr[16]^=ar,lr[17]^=jr,lr[26]^=ar,lr[27]^=jr,lr[36]^=ar,lr[37]^=jr,lr[46]^=ar,lr[47]^=jr,ar=bi^(mi<<1|pi>>>31),jr=Ai^(pi<<1|mi>>>31),lr[8]^=ar,lr[9]^=jr,lr[18]^=ar,lr[19]^=jr,lr[28]^=ar,lr[29]^=jr,lr[38]^=ar,lr[39]^=jr,lr[48]^=ar,lr[49]^=jr,vn=lr[0],di=lr[1],gi=lr[11]<<4|lr[10]>>>28,Li=lr[10]<<4|lr[11]>>>28,no=lr[20]<<3|lr[21]>>>29,co=lr[21]<<3|lr[20]>>>29,ya=lr[31]<<9|lr[30]>>>23,ma=lr[30]<<9|lr[31]>>>23,wo=lr[40]<<18|lr[41]>>>14,xi=lr[41]<<18|lr[40]>>>14,To=lr[2]<<1|lr[3]>>>31,Po=lr[3]<<1|lr[2]>>>31,rr=lr[13]<<12|lr[12]>>>20,on=lr[12]<<12|lr[13]>>>20,Qi=lr[22]<<10|lr[23]>>>22,Wi=lr[23]<<10|lr[22]>>>22,Fo=lr[33]<<13|lr[32]>>>19,Io=lr[32]<<13|lr[33]>>>19,fa=lr[42]<<2|lr[43]>>>30,ra=lr[43]<<2|lr[42]>>>30,ca=lr[5]<<30|lr[4]>>>2,Co=lr[4]<<30|lr[5]>>>2,ia=lr[14]<<6|lr[15]>>>26,Jo=lr[15]<<6|lr[14]>>>26,si=lr[25]<<11|lr[24]>>>21,vi=lr[24]<<11|lr[25]>>>21,io=lr[34]<<15|lr[35]>>>17,lo=lr[35]<<15|lr[34]>>>17,Ro=lr[45]<<29|lr[44]>>>3,Oo=lr[44]<<29|lr[45]>>>3,Ci=lr[6]<<28|lr[7]>>>4,Vi=lr[7]<<28|lr[6]>>>4,$o=lr[17]<<23|lr[16]>>>9,ta=lr[16]<<23|lr[17]>>>9,ea=lr[26]<<25|lr[27]>>>7,zi=lr[27]<<25|lr[26]>>>7,Ei=lr[36]<<21|lr[37]>>>11,Mi=lr[37]<<21|lr[36]>>>11,Ao=lr[47]<<24|lr[46]>>>8,_o=lr[46]<<24|lr[47]>>>8,Fi=lr[8]<<27|lr[9]>>>5,Ui=lr[9]<<27|lr[8]>>>5,Hi=lr[18]<<20|lr[19]>>>12,Ji=lr[19]<<20|lr[18]>>>12,sa=lr[29]<<7|lr[28]>>>25,ga=lr[28]<<7|lr[29]>>>25,Gi=lr[38]<<8|lr[39]>>>24,uo=lr[39]<<8|lr[38]>>>24,Di=lr[48]<<14|lr[49]>>>18,Ii=lr[49]<<14|lr[48]>>>18,lr[0]=vn^~rr&si,lr[1]=di^~on&vi,lr[10]=Ci^~Hi&no,lr[11]=Vi^~Ji&co,lr[20]=To^~ia&ea,lr[21]=Po^~Jo&zi,lr[30]=Fi^~gi&Qi,lr[31]=Ui^~Li&Wi,lr[40]=ca^~$o&sa,lr[41]=Co^~ta&ga,lr[2]=rr^~si&Ei,lr[3]=on^~vi&Mi,lr[12]=Hi^~no&Fo,lr[13]=Ji^~co&Io,lr[22]=ia^~ea&Gi,lr[23]=Jo^~zi&uo,lr[32]=gi^~Qi&io,lr[33]=Li^~Wi&lo,lr[42]=$o^~sa&ya,lr[43]=ta^~ga&ma,lr[4]=si^~Ei&Di,lr[5]=vi^~Mi&Ii,lr[14]=no^~Fo&Ro,lr[15]=co^~Io&Oo,lr[24]=ea^~Gi&wo,lr[25]=zi^~uo&xi,lr[34]=Qi^~io&Ao,lr[35]=Wi^~lo&_o,lr[44]=sa^~ya&fa,lr[45]=ga^~ma&ra,lr[6]=Ei^~Di&vn,lr[7]=Mi^~Ii&di,lr[16]=Fo^~Ro&Ci,lr[17]=Io^~Oo&Vi,lr[26]=Gi^~wo&To,lr[27]=uo^~xi&Po,lr[36]=io^~Ao&Fi,lr[37]=lo^~_o&Ui,lr[46]=ya^~fa&ca,lr[47]=ma^~ra&Co,lr[8]=Di^~vn&rr,lr[9]=Ii^~di&on,lr[18]=Ro^~Ci&Hi,lr[19]=Oo^~Vi&Ji,lr[28]=wo^~To&ia,lr[29]=xi^~Po&Jo,lr[38]=Ao^~Fi&gi,lr[39]=_o^~Ui&Li,lr[48]=fa^~ca&$o,lr[49]=ra^~Co&ta,lr[0]^=b[ci],lr[1]^=b[ci+1]};if(a)e.exports=L;else for(F=0;F<_.length;++F)o[_[F]]=L[_[F]]})()})(sha3$1)),sha3$1.exports}var sha3Exports=requireSha3();const sha3=getDefaultExportFromCjs(sha3Exports),{keccak_256:keccak_256$1}=sha3;function createMessageForBatcher(e,t,r,n,o,i=void 0){const a=CryptoManager.getCryptoManager(n).decodeAddress(r);return(""+(i??"")+t+a+o).replace(/[^a-zA-Z0-9]/g,"-").toLocaleLowerCase()}const AddressType={EVM:0};async function createSignedInput(e,t,r=void 0){const n=privateKeyToAccount(t.privateKey),o=createWalletClient({account:n,chain:hardhat,transport:http()}),i=Date.now().toString(),u=n.address,a=AddressType.EVM,s=createMessageForBatcher(null,i,u,a,e,r),f=await o.signMessage({account:n,message:s});return{addressType:a,address:u,signature:f,input:e,timestamp:i,target:r}}async function sendInputToBatcher(e){const t=await fetch(BATCHER_ENDPOINT,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:e})});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}async function postToBatcher(e,t,r=void 0){console.log("🚀 Creating signed input for:",e);const n=await createSignedInput(e,t,r);console.log("✅ Signed input created:",{...n,signature:n.signature.slice(0,10)+"..."}),console.log("📤 Sending to batcher...");const o=await sendInputToBatcher(n);return console.log("🎉 Batcher response:",o),o}function AddressesTable(){const[e,t]=reactExports.useState([]),[r,n]=reactExports.useState(!0),[o,i]=reactExports.useState(null),[u,a]=reactExports.useState(10),[s,f]=reactExports.useState(0),[c,d]=reactExports.useState([void 0]),[p,h]=reactExports.useState(!1),[y,b]=reactExports.useState([]),[w,S]=reactExports.useState(null),[E,B]=reactExports.useState([]),[ae,W]=reactExports.useState(!1),[J,ve]=reactExports.useState(!1),[Qe,kt]=reactExports.useState(!1),[nr,sr]=reactExports.useState(""),[ce,Ze]=reactExports.useState(""),[se,vt]=reactExports.useState(""),[ur,ue]=reactExports.useState(null),[bt,L]=reactExports.useState(null),_=(pi,ei,Gr)=>{const ti=Date.now(),fi={id:ti,type:pi,title:ei,message:Gr};B(bi=>[...bi,fi]),setTimeout(()=>{B(bi=>bi.filter(Ai=>Ai.id!==ti))},5e3)},F=pi=>{B(ei=>ei.filter(Gr=>Gr.id!==pi))},k=()=>{const pi=generatePrivateKey(),ei=privateKeyToAccount(pi),Gr={id:Date.now().toString(),privateKey:pi,address:ei.address,name:`Wallet ${y.length+1}`};b(ti=>[...ti,Gr]),S(Gr),_("success","Wallet Generated",`New wallet created: ${ei.address.slice(0,6)}...${ei.address.slice(-4)}`)},Ye=pi=>{b(ei=>ei.filter(Gr=>Gr.id!==pi)),w?.id===pi&&S(null)},rn=async()=>{if(!w){_("error","No Wallet","Please select a wallet first");return}kt(!0);try{const ei=JSON.stringify(["&createAccount"]);await postToBatcher(ei,w),_("success","Account Created","Successfully created account! Use the refresh button to see updated addresses.")}catch(pi){_("error","Create Account Error",`Error creating account: ${pi instanceof Error?pi.message:"Unknown error"}`)}finally{kt(!1)}},ii=async()=>{if(!w){_("error","No Wallet","Please select a wallet first");return}if(!ur){_("error","No Account","Please select an account ID");return}kt(!0);try{const pi=["&unlinkAddress",ur.toString(),"","",""],ei=JSON.stringify(pi);await postToBatcher(ei,w),_("success","Self Unlinked","Successfully unlinked self from account! Use the refresh button to see updated addresses.")}catch(pi){_("error","Unlink Self Error",`Error unlinking self: ${pi instanceof Error?pi.message:"Unknown error"}`)}finally{kt(!1)}},ai=async()=>{if(!w){_("error","No Wallet","Please select a wallet first");return}if(!ur){_("error","No Account","Please select an account ID");return}if(!se.trim()){_("error","No Address","Please enter an address to unlink");return}const pi=createWalletClient({account:privateKeyToAccount(w.privateKey),chain:hardhat,transport:http()});kt(!0);const ei=`unlink:${String(ur)}:${se.toString().toLowerCase().trim()}:`,Gr=await pi.signMessage({account:privateKeyToAccount(w.privateKey),message:ei});try{const ti=["&unlinkAddress",ur.toString(),Gr,se.toString().toLowerCase().trim(),""],fi=JSON.stringify(ti);await postToBatcher(fi,w),_("success","Address Unlinked","Successfully unlinked address from account! Use the refresh button to see updated addresses."),vt("")}catch(ti){_("error","Unlink Other Error",`Error unlinking address: ${ti instanceof Error?ti.message:"Unknown error"}`)}finally{kt(!1)}},ni=async()=>{if(!w){_("error","No Wallet","Please select a wallet first");return}if(!ur){_("error","No Account","Please select an account ID");return}if(!bt){_("error","No Link Wallet","Please select a wallet to link");return}kt(!0);try{const pi=createWalletClient({account:privateKeyToAccount(w.privateKey),chain:hardhat,transport:http()}),ei=createWalletClient({account:privateKeyToAccount(bt.privateKey),chain:hardhat,transport:http()}),Gr=`link:${ur}:${bt.address.toString().toLowerCase().trim()}:false`,ti=await pi.signMessage({account:privateKeyToAccount(w.privateKey),message:Gr}),fi=`link:${ur}:${w.address.toString().toLowerCase().trim()}:false`,bi=await ei.signMessage({account:privateKeyToAccount(bt.privateKey),message:fi}),Ai=["&linkAddress",ur.toString(),ti,bt.address.toString().toLowerCase().trim(),bi,"false"],Bi=JSON.stringify(Ai);await postToBatcher(Bi,w),_("success","Address Linked","Successfully linked address to account! Use the refresh button to see updated addresses."),L(null)}catch(pi){_("error","Link Address Error",`Error linking address: ${pi instanceof Error?pi.message:"Unknown error"}`)}finally{kt(!1)}},ri=async()=>{try{n(!0),i(null);const pi=new URL(ADDRESSES_ENDPOINT);pi.searchParams.set("limit",String(u));const ei=c[s];ei&&pi.searchParams.set("after",ei);const Gr=await fetch(pi.toString());if(!Gr.ok)throw new Error(`HTTP error! status: ${Gr.status}`);const ti=await Gr.json(),fi=ti.data??[];t(fi),ti.pagination&&(h(ti.pagination.hasMore??!1),ti.pagination.nextCursor&&c.length===s+1&&d(bi=>[...bi,ti.pagination.nextCursor]))}catch(pi){console.error("Error fetching addresses:",pi),i(pi instanceof Error?pi.message:"Unknown error")}finally{n(!1)}};reactExports.useEffect(()=>{ri()},[u,s]);const ui=e.reduce((pi,ei)=>{const Gr=pi.find(ti=>ti.account_id===ei.account_id);return Gr?(Gr.addresses.includes(ei.address)||Gr.addresses.push(ei.address),ei.primary_address&&(Gr.hasPrimaryAddress=!0,Gr.primaryAddress=ei.primary_address)):pi.push({account_id:ei.account_id,addresses:[ei.address],hasPrimaryAddress:!!ei.primary_address,primaryAddress:ei.primary_address}),pi},[]),lr=[...new Set(ui.map(pi=>pi.account_id).filter(pi=>pi!==null))],ar=pi=>{a(Number(pi.target.value)),f(0),d([void 0])},jr=()=>{p&&f(pi=>pi+1)},ci=()=>{f(pi=>Math.max(0,pi-1))},mi=()=>{f(0)};return r?jsxRuntimeExports.jsx("div",{className:"addresses-loading",children:jsxRuntimeExports.jsx("div",{className:"loading-text",children:"Loading addresses..."})}):o?jsxRuntimeExports.jsx("div",{className:"addresses-error",children:jsxRuntimeExports.jsxs("div",{className:"error-text",children:["Error loading addresses: ",o]})}):jsxRuntimeExports.jsxs("div",{className:"addresses-table-container",children:[jsxRuntimeExports.jsx("div",{style:{position:"fixed",top:"20px",right:"20px",zIndex:1e3,display:"flex",flexDirection:"column",gap:"10px"},children:E.map(pi=>jsxRuntimeExports.jsxs("div",{style:{background:pi.type==="success"?"#10b981":pi.type==="error"?"#ef4444":"#3b82f6",color:"white",padding:"12px 16px",borderRadius:"8px",minWidth:"300px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",display:"flex",justifyContent:"space-between",alignItems:"flex-start",animation:"slideIn 0.3s ease-out"},children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:pi.title}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",opacity:.9},children:pi.message})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>F(pi.id),style:{background:"none",border:"none",color:"white",cursor:"pointer",fontSize:"18px",padding:"0",marginLeft:"12px",opacity:.7},children:"×"})]},pi.id))}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"20px",padding:"20px",border:"1px solid #ddd",borderRadius:"8px",background:"#f8fafc"},children:[jsxRuntimeExports.jsxs("div",{onClick:()=>W(!ae),style:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",marginBottom:ae?0:"20px"},children:[jsxRuntimeExports.jsx("h3",{style:{margin:0,color:"#333"},children:"Wallet Management"}),jsxRuntimeExports.jsx("span",{style:{fontSize:"18px",color:"#666",transform:ae?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.2s ease-in-out"},children:"▼"})]}),!ae&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{style:{marginBottom:"20px"},children:jsxRuntimeExports.jsx("button",{type:"button",onClick:k,style:{padding:"10px 16px",background:"linear-gradient(45deg, #19b17b, #022418)",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontWeight:"600",fontSize:"14px"},children:"Generate New EVM Wallet"})}),y.length>0&&jsxRuntimeExports.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 10px 0",color:"#333"},children:"Available Wallets:"}),jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:y.map(pi=>jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px",border:w?.id===pi.id?"2px solid #19b17b":"1px solid #ddd",borderRadius:"6px",background:w?.id===pi.id?"#f0fdf4":"white"},children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"selectedWallet",checked:w?.id===pi.id,onChange:()=>S(pi),style:{margin:0}}),jsxRuntimeExports.jsx("span",{style:{fontSize:"14px",fontFamily:"monospace",color:"#666",flex:"1"},children:pi.name}),jsxRuntimeExports.jsx("span",{style:{fontSize:"14px",fontFamily:"monospace",color:"#666",flex:"2"},children:pi.address}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>Ye(pi.id),style:{padding:"4px 8px",background:"#ef4444",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px"},children:"Remove"})]},pi.id))})]})]})]}),w&&jsxRuntimeExports.jsxs("div",{style:{marginBottom:"20px",padding:"20px",border:"1px solid #ddd",borderRadius:"8px",background:"#fef7ff"},children:[jsxRuntimeExports.jsxs("div",{onClick:()=>ve(!J),style:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",marginBottom:J?0:"20px"},children:[jsxRuntimeExports.jsx("h3",{style:{margin:0,color:"#333"},children:"Account Commands"}),jsxRuntimeExports.jsx("span",{style:{fontSize:"18px",color:"#666",transform:J?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.2s ease-in-out"},children:"▼"})]}),!J&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{style:{marginBottom:"20px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"10px",fontWeight:"600",fontSize:"16px"},children:"What would you like to do?"}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px",border:nr==="create"?"2px solid #19b17b":"1px solid #ddd",borderRadius:"6px",background:nr==="create"?"#f0fdf4":"white",cursor:"pointer"},onClick:()=>sr("create"),children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"action",checked:nr==="create",onChange:()=>sr("create"),style:{margin:0}}),jsxRuntimeExports.jsxs("div",{style:{flex:"1"},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:"1. Create new account"}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",color:"#666",fontStyle:"italic"},children:"Can only create if not linked to any account"})]})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px",border:nr==="link"?"2px solid #3b82f6":"1px solid #ddd",borderRadius:"6px",background:nr==="link"?"#eff6ff":"white",cursor:"pointer"},onClick:()=>sr("link"),children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"action",checked:nr==="link",onChange:()=>sr("link"),style:{margin:0}}),jsxRuntimeExports.jsxs("div",{style:{flex:"1"},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:"2. Link Account"}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",color:"#666",fontStyle:"italic"},children:"Only Account Primary can do this Action"})]})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px",border:nr==="unlink-other"?"2px solid #f59e0b":"1px solid #ddd",borderRadius:"6px",background:nr==="unlink-other"?"#fffbeb":"white",cursor:"pointer"},onClick:()=>sr("unlink-other"),children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"action",checked:nr==="unlink-other",onChange:()=>sr("unlink-other"),style:{margin:0}}),jsxRuntimeExports.jsxs("div",{style:{flex:"1"},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:"3. Unlink Account"}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",color:"#666",fontStyle:"italic"},children:"Only Account Primary can do this Action"})]})]}),jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px",border:nr==="unlink-self"?"2px solid #ef4444":"1px solid #ddd",borderRadius:"6px",background:nr==="unlink-self"?"#fef2f2":"white",cursor:"pointer"},onClick:()=>sr("unlink-self"),children:[jsxRuntimeExports.jsx("input",{type:"radio",name:"action",checked:nr==="unlink-self",onChange:()=>sr("unlink-self"),style:{margin:0}}),jsxRuntimeExports.jsxs("div",{style:{flex:"1"},children:[jsxRuntimeExports.jsx("div",{style:{fontWeight:"600",marginBottom:"4px"},children:"4. Unlink Self"}),jsxRuntimeExports.jsx("div",{style:{fontSize:"14px",color:"#666",fontStyle:"italic"},children:"Unlink self from account"})]})]})]})]}),nr&&jsxRuntimeExports.jsxs("div",{style:{marginTop:"20px",padding:"20px",background:"#f8fafc",borderRadius:"8px",border:"1px solid #e2e8f0"},children:[nr==="create"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 15px 0",color:"#333"},children:"Create New Account"}),jsxRuntimeExports.jsx("p",{style:{margin:"0 0 15px 0",color:"#666",fontSize:"14px"},children:"This will create a new account with your selected wallet as the primary address."}),jsxRuntimeExports.jsx("button",{type:"button",onClick:rn,disabled:Qe,style:{padding:"10px 20px",background:Qe?"#ccc":"linear-gradient(45deg, #19b17b, #022418)",color:"white",border:"none",borderRadius:"6px",cursor:Qe?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:Qe?"Creating...":"Create Account"})]}),nr==="link"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 15px 0",color:"#333"},children:"Link Account"}),jsxRuntimeExports.jsx("p",{style:{margin:"0 0 15px 0",color:"#666",fontSize:"14px"},children:"Link a wallet to an existing account. You must be the primary address of the account, and the wallet to link must have a private key."}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Account ID:"}),jsxRuntimeExports.jsxs("select",{value:ur||"",onChange:pi=>ue(pi.target.value?parseInt(pi.target.value):null),style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"200px"},children:[jsxRuntimeExports.jsx("option",{value:"",children:"-- Select Account ID --"}),lr.map(pi=>jsxRuntimeExports.jsxs("option",{value:pi,children:["Account ",pi]},pi))]})]}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Wallet to Link:"}),jsxRuntimeExports.jsxs("select",{value:bt?.id||"",onChange:pi=>{const ei=y.find(Gr=>Gr.id===pi.target.value);L(ei||null)},style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"300px"},children:[jsxRuntimeExports.jsx("option",{value:"",children:"-- Select a wallet to link --"}),y.filter(pi=>pi.id!==w?.id).map(pi=>jsxRuntimeExports.jsxs("option",{value:pi.id,children:[pi.name," (",pi.address,")"]},pi.id))]})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:ni,disabled:Qe||!ur||!bt,style:{padding:"10px 20px",background:Qe||!ur||!bt?"#ccc":"linear-gradient(45deg, #3b82f6, #1e3a8a)",color:"white",border:"none",borderRadius:"6px",cursor:Qe||!ur||!bt?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:Qe?"Linking...":"Link Wallet"})]}),nr==="unlink-other"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 15px 0",color:"#333"},children:"Unlink Account"}),jsxRuntimeExports.jsx("p",{style:{margin:"0 0 15px 0",color:"#666",fontSize:"14px"},children:"Unlink a specific address from an account. You must be the primary address of the account."}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Account ID:"}),jsxRuntimeExports.jsxs("select",{value:ur||"",onChange:pi=>ue(pi.target.value?parseInt(pi.target.value):null),style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"200px"},children:[jsxRuntimeExports.jsx("option",{value:"",children:"-- Select Account ID --"}),lr.map(pi=>jsxRuntimeExports.jsxs("option",{value:pi,children:["Account ",pi]},pi))]})]}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Address to Unlink:"}),jsxRuntimeExports.jsx("input",{type:"text",value:se,onChange:pi=>vt(pi.target.value),placeholder:"Enter address to unlink",style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"300px"}})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:ai,disabled:Qe||!ur||!se.trim(),style:{padding:"10px 20px",background:Qe||!ur||!se.trim()?"#ccc":"linear-gradient(45deg, #f59e0b, #92400e)",color:"white",border:"none",borderRadius:"6px",cursor:Qe||!ur||!se.trim()?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:Qe?"Unlinking...":"Unlink Address"})]}),nr==="unlink-self"&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("h4",{style:{margin:"0 0 15px 0",color:"#333"},children:"Unlink Self"}),jsxRuntimeExports.jsx("p",{style:{margin:"0 0 15px 0",color:"#666",fontSize:"14px"},children:"Unlink yourself from an account. This will remove your address from the account."}),jsxRuntimeExports.jsxs("div",{style:{marginBottom:"15px"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"5px",fontWeight:"600"},children:"Account ID:"}),jsxRuntimeExports.jsxs("select",{value:ur||"",onChange:pi=>ue(pi.target.value?parseInt(pi.target.value):null),style:{padding:"8px",border:"1px solid #ddd",borderRadius:"4px",width:"200px"},children:[jsxRuntimeExports.jsx("option",{value:"",children:"-- Select Account ID --"}),lr.map(pi=>jsxRuntimeExports.jsxs("option",{value:pi,children:["Account ",pi]},pi))]})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:ii,disabled:Qe||!ur,style:{padding:"10px 20px",background:Qe||!ur?"#ccc":"linear-gradient(45deg, #ef4444, #7f1d1d)",color:"white",border:"none",borderRadius:"6px",cursor:Qe||!ur?"not-allowed":"pointer",fontWeight:"600",fontSize:"14px"},children:Qe?"Unlinking...":"Unlink Self"})]})]})]})]}),jsxRuntimeExports.jsxs("div",{className:"addresses-table-wrapper",children:[jsxRuntimeExports.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"15px"},children:[jsxRuntimeExports.jsx("h3",{style:{margin:0,color:"#333"},children:"Addresses"}),jsxRuntimeExports.jsx("div",{className:"table-controls",children:jsxRuntimeExports.jsxs("label",{children:["Rows per page:",jsxRuntimeExports.jsxs("select",{value:u,onChange:ar,children:[jsxRuntimeExports.jsx("option",{value:10,children:"10"}),jsxRuntimeExports.jsx("option",{value:20,children:"20"}),jsxRuntimeExports.jsx("option",{value:50,children:"50"})]})]})})]}),r&&jsxRuntimeExports.jsx("p",{children:"Loading..."}),o&&jsxRuntimeExports.jsx("p",{className:"error",children:o}),!r&&!o&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("table",{className:"addresses-table",children:[jsxRuntimeExports.jsx("thead",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("th",{children:"Account ID"}),jsxRuntimeExports.jsx("th",{children:"Addresses"})]})}),jsxRuntimeExports.jsx("tbody",{children:ui.map((pi,ei)=>jsxRuntimeExports.jsxs("tr",{className:pi.hasPrimaryAddress?"has-primary-address":"",children:[jsxRuntimeExports.jsx("td",{className:"account-id-cell",children:jsxRuntimeExports.jsx("div",{className:"account-id-content",children:pi.account_id??"No Account ID"})}),jsxRuntimeExports.jsx("td",{className:"addresses-cell",children:pi.addresses.map((Gr,ti)=>jsxRuntimeExports.jsxs("div",{className:`address-item ${Gr===pi.primaryAddress?"primary-address":""}`,title:Gr===pi.primaryAddress?`${Gr} (Primary)`:Gr,children:[Gr,Gr===pi.primaryAddress&&jsxRuntimeExports.jsx("span",{className:"primary-badge",children:"Primary"})]},Gr))})]},pi.account_id??`null-${ei}`))})]}),jsxRuntimeExports.jsxs("div",{className:"pagination-controls",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:mi,disabled:s===0,children:"First"}),jsxRuntimeExports.jsx("button",{type:"button",onClick:ci,disabled:s===0,children:"Previous"}),jsxRuntimeExports.jsx("button",{type:"button",onClick:jr,disabled:!p||e.length<u,children:"Next"})]})]})]}),ui.length===0&&jsxRuntimeExports.jsx("div",{className:"no-addresses",children:jsxRuntimeExports.jsx("div",{className:"no-data-text",children:"No addresses found"})}),jsxRuntimeExports.jsx("style",{children:`
197
197
  @keyframes slideIn {
198
198
  from {
199
199
  transform: translateX(100%);