/*! OpenPGP.js v5.10.1 - 2023-08-29 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */ const e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};import t from"buffer";import r from"stream";import i from"crypto";import n from"zlib";import a from"os";import s from"util";import o from"asn1.js";const c=Symbol("doneWritingPromise"),u=Symbol("doneWritingResolve"),h=Symbol("doneWritingReject"),d=Symbol("readingIndex");class f extends Array{constructor(){super(),this[c]=new Promise(((e,t)=>{this[u]=e,this[h]=t})),this[c].catch((()=>{}))}}function l(e){return e&&e.getReader&&Array.isArray(e)}function p(e){if(!l(e)){const t=e.getWriter(),r=t.releaseLock;return t.releaseLock=()=>{t.closed.catch((function(){})),r.call(t)},t}this.stream=e}f.prototype.getReader=function(){return void 0===this[d]&&(this[d]=0),{read:async()=>(await this[c],this[d]===this.length?{value:void 0,done:!0}:{value:this[this[d]++],done:!1})}},f.prototype.readToEnd=async function(e){await this[c];const t=e(this.slice(this[d]));return this.length=0,t},f.prototype.clone=function(){const e=new f;return e[c]=this[c].then((()=>{e.push(...this)})),e},p.prototype.write=async function(e){this.stream.push(e)},p.prototype.close=async function(){this.stream[u]()},p.prototype.abort=async function(e){return this.stream[h](e),e},p.prototype.releaseLock=function(){};const y="object"==typeof e.process&&"object"==typeof e.process.versions,b=y&&r.Readable;function m(t){return l(t)?"array":e.ReadableStream&&e.ReadableStream.prototype.isPrototypeOf(t)?"web":K&&K.prototype.isPrototypeOf(t)?"ponyfill":b&&b.prototype.isPrototypeOf(t)?"node":!(!t||!t.getReader)&&"web-like"}function g(e){return Uint8Array.prototype.isPrototypeOf(e)}function w(e){if(1===e.length)return e[0];let t=0;for(let r=0;r{t||(v.isBuffer(i)&&(i=new Uint8Array(i.buffer,i.byteOffset,i.byteLength)),r.enqueue(i),e.pause())})),e.on("end",(()=>{t||r.close()})),e.on("error",(e=>r.error(e)))},pull(){e.resume()},cancel(r){t=!0,e.destroy(r)}})};class e extends _{constructor(e,t){super(t),this._reader=z(e)}async _read(e){try{for(;;){const{done:e,value:t}=await this._reader.read();if(e){this.push(null);break}if(!this.push(t)||this._cancelling){this._reading=!1;break}}}catch(e){this.emit("error",e)}}_destroy(e){this._reader.cancel(e)}}A=function(t,r){return new e(t,r)}}const S=new WeakSet,E=Symbol("externalBuffer");function P(e){if(this.stream=e,e[E]&&(this[E]=e[E].slice()),l(e)){const t=e.getReader();return this._read=t.read.bind(t),this._releaseLock=()=>{},void(this._cancel=()=>{})}let t=m(e);if("node"===t&&(e=k(e)),t){const t=e.getReader();return this._read=t.read.bind(t),this._releaseLock=()=>{t.closed.catch((function(){})),t.releaseLock()},void(this._cancel=t.cancel.bind(t))}let r=!1;this._read=async()=>r||S.has(e)?{value:void 0,done:!0}:(r=!0,{value:e,done:!1}),this._releaseLock=()=>{if(r)try{S.add(e)}catch(e){}}}P.prototype.read=async function(){if(this[E]&&this[E].length){return{done:!1,value:this[E].shift()}}return this._read()},P.prototype.releaseLock=function(){this[E]&&(this.stream[E]=this[E]),this._releaseLock()},P.prototype.cancel=function(e){return this._cancel(e)},P.prototype.readLine=async function(){let e,t=[];for(;!e;){let{done:r,value:i}=await this.read();if(i+="",r)return t.length?T(t):void 0;const n=i.indexOf("\n")+1;n&&(e=T(t.concat(i.substr(0,n))),t=[]),n!==i.length&&t.push(i.substr(n))}return this.unshift(...t),e},P.prototype.readByte=async function(){const{done:e,value:t}=await this.read();if(e)return;const r=t[0];return this.unshift($(t,1)),r},P.prototype.readBytes=async function(e){const t=[];let r=0;for(;;){const{done:i,value:n}=await this.read();if(i)return t.length?T(t):void 0;if(t.push(n),r+=n.length,r>=e){const r=T(t);return this.unshift($(r,e)),$(r,0,e)}}},P.prototype.peekBytes=async function(e){const t=await this.readBytes(e);return this.unshift(t),t},P.prototype.unshift=function(...e){this[E]||(this[E]=[]),1===e.length&&g(e[0])&&this[E].length&&e[0].length&&this[E][0].byteOffset>=e[0].length?this[E][0]=new Uint8Array(this[E][0].buffer,this[E][0].byteOffset-e[0].length,this[E][0].byteLength+e[0].length):this[E].unshift(...e.filter((e=>e&&e.length)))},P.prototype.readToEnd=async function(e=T){const t=[];for(;;){const{done:e,value:r}=await this.read();if(e)break;t.push(r)}return e(t)};let x,M,{ReadableStream:K,WritableStream:C,TransformStream:D}=e;async function U(){if(D)return;const[t,r]=await Promise.all([Promise.resolve().then((function(){return Wp})),Promise.resolve().then((function(){return dy}))]);({ReadableStream:K,WritableStream:C,TransformStream:D}=t);const{createReadableStreamWrapper:i}=r;e.ReadableStream&&K!==e.ReadableStream&&(x=i(K),M=i(e.ReadableStream))}const R=y&&t.Buffer;function I(e){let t=m(e);return"node"===t?k(e):"web"===t&&x?x(e):t?e:new K({start(t){t.enqueue(e),t.close()}})}function B(e){if(m(e))return e;const t=new f;return(async()=>{const r=q(t);await r.write(e),await r.close()})(),t}function T(e){return e.some((e=>m(e)&&!l(e)))?function(e){e=e.map(I);const t=L((async function(e){await Promise.all(i.map((t=>X(t,e))))}));let r=Promise.resolve();const i=e.map(((i,n)=>j(i,((i,a)=>(r=r.then((()=>F(i,t.writable,{preventClose:n!==e.length-1}))),r)))));return t.readable}(e):e.some((e=>l(e)))?function(e){const t=new f;let r=Promise.resolve();return e.forEach(((i,n)=>(r=r.then((()=>F(i,t,{preventClose:n!==e.length-1}))),r))),t}(e):"string"==typeof e[0]?e.join(""):R&&R.isBuffer(e[0])?R.concat(e):w(e)}function z(e){return new P(e)}function q(e){return new p(e)}async function F(e,t,{preventClose:r=!1,preventAbort:i=!1,preventCancel:n=!1}={}){if(m(e)&&!l(e)){e=I(e);try{if(e[E]){const r=q(t);for(let t=0;t{t=e})),t=null)},close:r.close.bind(r),abort:r.error.bind(r)})}}function N(e,t=(()=>{}),r=(()=>{})){if(l(e)){const i=new f;return(async()=>{const n=q(i);try{const i=await Z(e),a=t(i),s=r();let o;o=void 0!==a&&void 0!==s?T([a,s]):void 0!==a?a:s,await n.write(o),await n.close()}catch(e){await n.abort(e)}})(),i}if(m(e))return O(e,{async transform(e,r){try{const i=await t(e);void 0!==i&&r.enqueue(i)}catch(e){r.error(e)}},async flush(e){try{const t=await r();void 0!==t&&e.enqueue(t)}catch(t){e.error(t)}}});const i=t(e),n=r();return void 0!==i&&void 0!==n?T([i,n]):void 0!==i?i:n}function j(e,t){if(m(e)&&!l(e)){let r;const i=new D({start(e){r=e}}),n=F(e,i.writable),a=L((async function(e){r.error(e),await n,await new Promise(setTimeout)}));return t(i.readable,a.writable),a.readable}e=B(e);const r=new f;return t(e,r),r}function W(e,t){let r;const i=j(e,((e,n)=>{const a=z(e);a.remainder=()=>(a.releaseLock(),F(e,n),i),r=t(a)}));return r}function H(e){if(l(e))return e.clone();if(m(e)){const t=function(e){if(l(e))throw Error("ArrayStream cannot be tee()d, use clone() instead");if(m(e)){const t=I(e).tee();return t[0][E]=t[1][E]=e[E],t}return[$(e),$(e)]}(e);return V(e,t[0]),t[1]}return $(e)}function G(e){return l(e)?H(e):m(e)?new K({start(t){const r=j(e,(async(e,r)=>{const i=z(e),n=q(r);try{for(;;){await n.ready;const{done:e,value:r}=await i.read();if(e){try{t.close()}catch(e){}return void await n.close()}try{t.enqueue(r)}catch(e){}await n.write(r)}}catch(e){t.error(e),await n.abort(e)}}));V(e,r)}}):$(e)}function V(e,t){Object.entries(Object.getOwnPropertyDescriptors(e.constructor.prototype)).forEach((([r,i])=>{"constructor"!==r&&(i.value?i.value=i.value.bind(t):i.get=i.get.bind(t),Object.defineProperty(e,r,i))}))}function $(e,t=0,r=1/0){if(l(e))throw Error("Not implemented");if(m(e)){if(t>=0&&r>=0){let i=0;return O(e,{transform(e,n){i=t&&n.enqueue($(e,Math.max(t-i,0),r-i)),i+=e.length):n.terminate()}})}if(t<0&&(r<0||r===1/0)){let i=[];return N(e,(e=>{e.length>=-t?i=[e]:i.push(e)}),(()=>$(T(i),t,r)))}if(0===t&&r<0){let i;return N(e,(e=>{const n=i?T([i,e]):e;if(n.length>=-r)return i=$(n,r),$(n,t,r);i=n}))}return console.warn(`stream.slice(input, ${t}, ${r}) not implemented efficiently.`),Y((async()=>$(await Z(e),t,r)))}return e[E]&&(e=T(e[E].concat([e]))),!g(e)||R&&R.isBuffer(e)?e.slice(t,r):(r===1/0&&(r=e.length),e.subarray(t,r))}async function Z(e,t=T){return l(e)?e.readToEnd(t):m(e)?z(e).readToEnd(t):e}async function X(e,t){if(m(e)){if(e.cancel)return e.cancel(t);if(e.destroy)return e.destroy(t),await new Promise(setTimeout),t}}function Y(e){const t=new f;return(async()=>{const r=q(t);try{await r.write(await e()),await r.close()}catch(e){await r.abort(e)}})(),t}class Q{constructor(e){if(void 0===e)throw Error("Invalid BigInteger input");if(e instanceof Uint8Array){const t=e,r=Array(t.length);for(let e=0;eBigInt(0);){const e=r&BigInt(1);r>>=BigInt(1);const a=n*i%t.value;n=e?a:n,i=i*i%t.value}return new Q(n)}modInv(e){const{gcd:t,x:r}=this._egcd(e);if(!t.isOne())throw Error("Inverse does not exist");return r.add(e).mod(e)}_egcd(e){let t=BigInt(0),r=BigInt(1),i=BigInt(1),n=BigInt(0),a=this.value;for(e=e.value;e!==BigInt(0);){const s=a/e;let o=t;t=i-s*t,i=o,o=r,r=n-s*r,n=o,o=e,e=a%e,a=o}return{x:new Q(i),y:new Q(n),gcd:new Q(a)}}gcd(e){let t=this.value;for(e=e.value;e!==BigInt(0);){const r=e;e=t%e,t=r}return new Q(t)}ileftShift(e){return this.value<<=e.value,this}leftShift(e){return this.clone().ileftShift(e)}irightShift(e){return this.value>>=e.value,this}rightShift(e){return this.clone().irightShift(e)}equal(e){return this.value===e.value}lt(e){return this.valuee.value}gte(e){return this.value>=e.value}isZero(){return this.value===BigInt(0)}isOne(){return this.value===BigInt(1)}isNegative(){return this.valueNumber.MAX_SAFE_INTEGER)throw Error("Number can only safely store up to 53 bits");return e}getBit(e){return(this.value>>BigInt(e)&BigInt(1))===BigInt(0)?0:1}bitLength(){const e=new Q(0),t=new Q(1),r=new Q(-1),i=this.isNegative()?r:e;let n=1;const a=this.clone();for(;!a.irightShift(t).equal(i);)n++;return n}byteLength(){const e=new Q(0),t=new Q(-1),r=this.isNegative()?t:e,i=new Q(8);let n=1;const a=this.clone();for(;!a.irightShift(i).equal(r);)n++;return n}toUint8Array(e="be",t){let r=this.value.toString(16);r.length%2==1&&(r="0"+r);const i=r.length/2,n=new Uint8Array(t||i),a=t?t-i:0;let s=0;for(;s"undefined"!=typeof BigInt;const ee=Symbol("byValue");var te={curve:{p256:"p256","P-256":"p256",secp256r1:"p256",prime256v1:"p256","1.2.840.10045.3.1.7":"p256","2a8648ce3d030107":"p256","2A8648CE3D030107":"p256",p384:"p384","P-384":"p384",secp384r1:"p384","1.3.132.0.34":"p384","2b81040022":"p384","2B81040022":"p384",p521:"p521","P-521":"p521",secp521r1:"p521","1.3.132.0.35":"p521","2b81040023":"p521","2B81040023":"p521",secp256k1:"secp256k1","1.3.132.0.10":"secp256k1","2b8104000a":"secp256k1","2B8104000A":"secp256k1",ED25519:"ed25519",ed25519:"ed25519",Ed25519:"ed25519","1.3.6.1.4.1.11591.15.1":"ed25519","2b06010401da470f01":"ed25519","2B06010401DA470F01":"ed25519",X25519:"curve25519",cv25519:"curve25519",curve25519:"curve25519",Curve25519:"curve25519","1.3.6.1.4.1.3029.1.5.1":"curve25519","2b060104019755010501":"curve25519","2B060104019755010501":"curve25519",brainpoolP256r1:"brainpoolP256r1","1.3.36.3.3.2.8.1.1.7":"brainpoolP256r1","2b2403030208010107":"brainpoolP256r1","2B2403030208010107":"brainpoolP256r1",brainpoolP384r1:"brainpoolP384r1","1.3.36.3.3.2.8.1.1.11":"brainpoolP384r1","2b240303020801010b":"brainpoolP384r1","2B240303020801010B":"brainpoolP384r1",brainpoolP512r1:"brainpoolP512r1","1.3.36.3.3.2.8.1.1.13":"brainpoolP512r1","2b240303020801010d":"brainpoolP512r1","2B240303020801010D":"brainpoolP512r1"},s2k:{simple:0,salted:1,iterated:3,gnu:101},publicKey:{rsaEncryptSign:1,rsaEncrypt:2,rsaSign:3,elgamal:16,dsa:17,ecdh:18,ecdsa:19,ed25519Legacy:22,eddsa:22,aedh:23,aedsa:24,x25519:25,x448:26,ed25519:27,ed448:28},symmetric:{plaintext:0,idea:1,tripledes:2,cast5:3,blowfish:4,aes128:7,aes192:8,aes256:9,twofish:10},compression:{uncompressed:0,zip:1,zlib:2,bzip2:3},hash:{md5:1,sha1:2,ripemd:3,sha256:8,sha384:9,sha512:10,sha224:11},webHash:{"SHA-1":2,"SHA-256":8,"SHA-384":9,"SHA-512":10},aead:{eax:1,ocb:2,experimentalGCM:100},packet:{publicKeyEncryptedSessionKey:1,signature:2,symEncryptedSessionKey:3,onePassSignature:4,secretKey:5,publicKey:6,secretSubkey:7,compressedData:8,symmetricallyEncryptedData:9,marker:10,literalData:11,trust:12,userID:13,publicSubkey:14,userAttribute:17,symEncryptedIntegrityProtectedData:18,modificationDetectionCode:19,aeadEncryptedData:20},literal:{binary:98,text:116,utf8:117,mime:109},signature:{binary:0,text:1,standalone:2,certGeneric:16,certPersona:17,certCasual:18,certPositive:19,certRevocation:48,subkeyBinding:24,keyBinding:25,key:31,keyRevocation:32,subkeyRevocation:40,timestamp:64,thirdParty:80},signatureSubpacket:{signatureCreationTime:2,signatureExpirationTime:3,exportableCertification:4,trustSignature:5,regularExpression:6,revocable:7,keyExpirationTime:9,placeholderBackwardsCompatibility:10,preferredSymmetricAlgorithms:11,revocationKey:12,issuer:16,notationData:20,preferredHashAlgorithms:21,preferredCompressionAlgorithms:22,keyServerPreferences:23,preferredKeyServer:24,primaryUserID:25,policyURI:26,keyFlags:27,signersUserID:28,reasonForRevocation:29,features:30,signatureTarget:31,embeddedSignature:32,issuerFingerprint:33,preferredAEADAlgorithms:34},keyFlags:{certifyKeys:1,signData:2,encryptCommunication:4,encryptStorage:8,splitPrivateKey:16,authentication:32,sharedPrivateKey:128},armor:{multipartSection:0,multipartLast:1,signed:2,message:3,publicKey:4,privateKey:5,signature:6},reasonForRevocation:{noReason:0,keySuperseded:1,keyCompromised:2,keyRetired:3,userIDInvalid:32},features:{modificationDetection:1,aead:2,v5Keys:4},write:function(e,t){if("number"==typeof t&&(t=this.read(e,t)),void 0!==e[t])return e[t];throw Error("Invalid enum value.")},read:function(e,t){if(e[ee]||(e[ee]=[],Object.entries(e).forEach((([t,r])=>{e[ee][r]=t}))),void 0!==e[ee][t])return e[ee][t];throw Error("Invalid enum value.")}};const re=(()=>{try{return"development"===process.env.NODE_ENV}catch(e){}return!1})(),ie={isString:function(e){return"string"==typeof e||e instanceof String},isArray:function(e){return e instanceof Array},isUint8Array:g,isStream:m,readNumber:function(e){let t=0;for(let r=0;r>8*(t-i-1)&255;return r},readDate:function(e){const t=ie.readNumber(e);return new Date(1e3*t)},writeDate:function(e){const t=Math.floor(e.getTime()/1e3);return ie.writeNumber(t,4)},normalizeDate:function(e=Date.now()){return null===e||e===1/0?e:new Date(1e3*Math.floor(+e/1e3))},readMPI:function(e){const t=(e[0]<<8|e[1])+7>>>3;return e.subarray(2,2+t)},leftPad(e,t){const r=new Uint8Array(t),i=t-e.length;return r.set(e,i),r},uint8ArrayToMPI:function(e){const t=ie.uint8ArrayBitLength(e);if(0===t)throw Error("Zero MPI");const r=e.subarray(e.length-Math.ceil(t/8)),i=new Uint8Array([(65280&t)>>8,255&t]);return ie.concatUint8Array([i,r])},uint8ArrayBitLength:function(e){let t;for(t=0;t>1);for(let r=0;r>1;r++)t[r]=parseInt(e.substr(r<<1,2),16);return t},uint8ArrayToHex:function(e){const t=[],r=e.length;let i,n=0;for(;n{if(!ie.isString(e))throw Error("stringToUint8Array: Data must be in the form of a string");const t=new Uint8Array(e.length);for(let r=0;rr("",!0)))},decodeUTF8:function(e){const t=new TextDecoder("utf-8");function r(e,r=!1){return t.decode(e,{stream:!r})}return N(e,r,(()=>r(new Uint8Array,!0)))},concat:T,concatUint8Array:w,equalsUint8Array:function(e,t){if(!ie.isUint8Array(e)||!ie.isUint8Array(t))throw Error("Data must be in the form of a Uint8Array");if(e.length!==t.length)return!1;for(let r=0;r>>16;return 0!==r&&(e=r,t+=16),r=e>>8,0!==r&&(e=r,t+=8),r=e>>4,0!==r&&(e=r,t+=4),r=e>>2,0!==r&&(e=r,t+=2),r=e>>1,0!==r&&(e=r,t+=1),t},double:function(e){const t=new Uint8Array(e.length),r=e.length-1;for(let i=0;i>7;return t[r]=e[r]<<1^135*(e[0]>>7),t},shiftRight:function(e,t){if(t)for(let r=e.length-1;r>=0;r--)e[r]>>=t,r>0&&(e[r]|=e[r-1]<<8-t);return e},getWebCrypto:function(){return void 0!==e&&e.crypto&&e.crypto.subtle},getBigInteger:async function(){if(J())return Q;{const{default:e}=await Promise.resolve().then((function(){return by}));return e}},getNodeCrypto:function(){return i},getNodeZlib:function(){return n},getNodeBuffer:function(){return(t||{}).Buffer},getHardwareConcurrency:function(){if("undefined"!=typeof navigator)return navigator.hardwareConcurrency||1;return a.cpus().length},isEmailAddress:function(e){if(!ie.isString(e))return!1;return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,}[0-9]*|xn--[a-zA-Z\-0-9]+)))$/.test(e)},canonicalizeEOL:function(e){let t=!1;return N(e,(e=>{let r;t&&(e=ie.concatUint8Array([new Uint8Array([13]),e])),13===e[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;const i=[];for(let t=0;r=e.indexOf(10,t)+1,r;t=r)13!==e[r-2]&&i.push(r);if(!i.length)return e;const n=new Uint8Array(e.length+i.length);let a=0;for(let t=0;tt?new Uint8Array([13]):void 0))},nativeEOL:function(e){let t=!1;return N(e,(e=>{let r;13===(e=t&&10!==e[0]?ie.concatUint8Array([new Uint8Array([13]),e]):new Uint8Array(e))[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;let i=0;for(let t=0;t!==e.length;t=r){r=e.indexOf(13,t)+1,r||(r=e.length);const n=r-(10===e[r]?1:0);t&&e.copyWithin(i,t,n),i+=n-t}return e.subarray(0,i)}),(()=>t?new Uint8Array([13]):void 0))},removeTrailingSpaces:function(e){return e.split("\n").map((e=>{let t=e.length-1;for(;t>=0&&(" "===e[t]||"\t"===e[t]||"\r"===e[t]);t--);return e.substr(0,t+1)})).join("\n")},wrapError:function(e,t){if(!t)return Error(e);try{t.message=e+": "+t.message}catch(e){}return t},constructAllowedPackets:function(e){const t={};return e.forEach((e=>{if(!e.tag)throw Error("Invalid input: expected a packet class");t[e.tag]=e})),t},anyPromise:function(e){return new Promise((async(t,r)=>{let i;await Promise.all(e.map((async e=>{try{t(await e)}catch(e){i=e}}))),r(i)}))},selectUint8Array:function(e,t,r){const i=Math.max(t.length,r.length),n=new Uint8Array(i);let a=0;for(let i=0;i{t=ie.concatUint8Array([t,e]);const r=[],i=Math.floor(t.length/45),n=45*i,a=ae(t.subarray(0,n));for(let e=0;et.length?ae(t)+"\n":""))}function ce(e){let t="";return N(e,(e=>{t+=e;let r=0;const i=[" ","\t","\r","\n"];for(let e=0;e0&&(n-r)%4!=0;n--)i.includes(t[n])&&r--;const a=se(t.substr(0,n));return t=t.substr(n),a}),(()=>se(t)))}function ue(e){return ce(e.replace(/-/g,"+").replace(/_/g,"/"))}function he(e,t){let r=oe(e).replace(/[\r\n]/g,"");return t&&(r=r.replace(/[+]/g,"-").replace(/[/]/g,"_").replace(/[=]/g,"")),r}ne?(ae=e=>ne.from(e).toString("base64"),se=e=>{const t=ne.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}):(ae=e=>btoa(ie.uint8ArrayToString(e)),se=e=>ie.stringToUint8Array(atob(e)));var de={preferredHashAlgorithm:te.hash.sha256,preferredSymmetricAlgorithm:te.symmetric.aes256,preferredCompressionAlgorithm:te.compression.uncompressed,deflateLevel:6,aeadProtect:!1,preferredAEADAlgorithm:te.aead.eax,aeadChunkSizeByte:12,v5Keys:!1,s2kIterationCountByte:224,allowUnauthenticatedMessages:!1,allowUnauthenticatedStream:!1,checksumRequired:!1,minRSABits:2047,passwordCollisionCheck:!1,revocationsExpire:!1,allowInsecureDecryptionWithSigningKeys:!1,allowInsecureVerificationWithReformattedKeys:!1,constantTimePKCS1Decryption:!1,constantTimePKCS1DecryptionSupportedSymmetricAlgorithms:new Set([te.symmetric.aes128,te.symmetric.aes192,te.symmetric.aes256]),minBytesForWebCrypto:1e3,ignoreUnsupportedPackets:!0,ignoreMalformedPackets:!1,additionalAllowedPackets:[],showVersion:!1,showComment:!1,versionString:"OpenPGP.js 5.10.1",commentString:"https://openpgpjs.org",maxUserIDLength:5120,knownNotations:[],useIndutnyElliptic:!0,rejectHashAlgorithms:new Set([te.hash.md5,te.hash.ripemd]),rejectMessageHashAlgorithms:new Set([te.hash.md5,te.hash.ripemd,te.hash.sha1]),rejectPublicKeyAlgorithms:new Set([te.publicKey.elgamal,te.publicKey.dsa]),rejectCurves:new Set([te.curve.secp256k1])};function fe(e){const t=e.match(/^-----BEGIN PGP (MESSAGE, PART \d+\/\d+|MESSAGE, PART \d+|SIGNED MESSAGE|MESSAGE|PUBLIC KEY BLOCK|PRIVATE KEY BLOCK|SIGNATURE)-----$/m);if(!t)throw Error("Unknown ASCII armor type");return/MESSAGE, PART \d+\/\d+/.test(t[1])?te.armor.multipartSection:/MESSAGE, PART \d+/.test(t[1])?te.armor.multipartLast:/SIGNED MESSAGE/.test(t[1])?te.armor.signed:/MESSAGE/.test(t[1])?te.armor.message:/PUBLIC KEY BLOCK/.test(t[1])?te.armor.publicKey:/PRIVATE KEY BLOCK/.test(t[1])?te.armor.privateKey:/SIGNATURE/.test(t[1])?te.armor.signature:void 0}function le(e,t){let r="";return t.showVersion&&(r+="Version: "+t.versionString+"\n"),t.showComment&&(r+="Comment: "+t.commentString+"\n"),e&&(r+="Comment: "+e+"\n"),r+="\n",r}function pe(e){return oe(function(e){let t=13501623;return N(e,(e=>{const r=be?Math.floor(e.length/4):0,i=new Uint32Array(e.buffer,e.byteOffset,r);for(let e=0;e>24&255]^ye[1][t>>16&255]^ye[2][t>>8&255]^ye[3][t>>0&255];for(let i=4*r;i>8^ye[0][255&t^e[i]]}),(()=>new Uint8Array([t,t>>8,t>>16])))}(e))}const ye=[Array(255),Array(255),Array(255),Array(255)];for(let e=0;e<=255;e++){let t=e<<16;for(let e=0;e<8;e++)t=t<<1^(0!=(8388608&t)?8801531:0);ye[0][e]=(16711680&t)>>16|65280&t|(255&t)<<16}for(let e=0;e<=255;e++)ye[1][e]=ye[0][e]>>8^ye[0][255&ye[0][e]];for(let e=0;e<=255;e++)ye[2][e]=ye[1][e]>>8^ye[0][255&ye[1][e]];for(let e=0;e<=255;e++)ye[3][e]=ye[2][e]>>8^ye[0][255&ye[2][e]];const be=function(){const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,255,!0),255===new Int16Array(e)[0]}();function me(e){for(let t=0;t=0&&i!==e.length-1&&(t=e.slice(0,i),r=e.slice(i+1).substr(0,4)),{body:t,checksum:r}}function we(e,t=de){return new Promise((async(r,i)=>{try{const n=/^-----[^-]+-----$/m,a=/^[ \f\r\t\u00a0\u2000-\u200a\u202f\u205f\u3000]*$/;let s;const o=[];let c,u,h,d=o,f=[],l=ce(j(e,(async(e,t)=>{const p=z(e);try{for(;;){let e=await p.readLine();if(void 0===e)throw Error("Misformed armored text");if(e=ie.removeTrailingSpaces(e.replace(/[\r\n]/g,"")),s)if(c)u||2!==s||(n.test(e)?(f=f.join("\r\n"),u=!0,me(d),d=[],c=!1):f.push(e.replace(/^- /,"")));else if(n.test(e)&&i(Error("Mandatory blank line missing between armor headers and armor data")),a.test(e)){if(me(d),c=!0,u||2!==s){r({text:f,data:l,headers:o,type:s});break}}else d.push(e);else n.test(e)&&(s=fe(e))}}catch(e){return void i(e)}const y=q(t);try{for(;;){await y.ready;const{done:e,value:t}=await p.read();if(e)throw Error("Misformed armored text");const r=t+"";if(-1!==r.indexOf("=")||-1!==r.indexOf("-")){let e=await p.readToEnd();e.length||(e=""),e=r+e,e=ie.removeTrailingSpaces(e.replace(/\r/g,""));const t=e.split(n);if(1===t.length)throw Error("Misformed armored text");const i=ge(t[0].slice(0,-1));h=i.checksum,await y.write(i.body);break}await y.write(r)}await y.ready,await y.close()}catch(e){await y.abort(e)}})));l=j(l,(async(e,r)=>{const i=Z(pe(G(e)));i.catch((()=>{})),await F(e,r,{preventClose:!0});const n=q(r);try{const e=(await i).replace("\n","");if(h!==e&&(h||t.checksumRequired))throw Error("Ascii armor integrity check failed");await n.ready,await n.close()}catch(e){await n.abort(e)}}))}catch(e){i(e)}})).then((async e=>(l(e.data)&&(e.data=await Z(e.data)),e)))}function ve(e,t,r,i,n,a=de){let s,o;e===te.armor.signed&&(s=t.text,o=t.hash,t=t.data);const c=G(t),u=[];switch(e){case te.armor.multipartSection:u.push("-----BEGIN PGP MESSAGE, PART "+r+"/"+i+"-----\n"),u.push(le(n,a)),u.push(oe(t)),u.push("=",pe(c)),u.push("-----END PGP MESSAGE, PART "+r+"/"+i+"-----\n");break;case te.armor.multipartLast:u.push("-----BEGIN PGP MESSAGE, PART "+r+"-----\n"),u.push(le(n,a)),u.push(oe(t)),u.push("=",pe(c)),u.push("-----END PGP MESSAGE, PART "+r+"-----\n");break;case te.armor.signed:u.push("-----BEGIN PGP SIGNED MESSAGE-----\n"),u.push("Hash: "+o+"\n\n"),u.push(s.replace(/^-/gm,"- -")),u.push("\n-----BEGIN PGP SIGNATURE-----\n"),u.push(le(n,a)),u.push(oe(t)),u.push("=",pe(c)),u.push("-----END PGP SIGNATURE-----\n");break;case te.armor.message:u.push("-----BEGIN PGP MESSAGE-----\n"),u.push(le(n,a)),u.push(oe(t)),u.push("=",pe(c)),u.push("-----END PGP MESSAGE-----\n");break;case te.armor.publicKey:u.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),u.push(le(n,a)),u.push(oe(t)),u.push("=",pe(c)),u.push("-----END PGP PUBLIC KEY BLOCK-----\n");break;case te.armor.privateKey:u.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\n"),u.push(le(n,a)),u.push(oe(t)),u.push("=",pe(c)),u.push("-----END PGP PRIVATE KEY BLOCK-----\n");break;case te.armor.signature:u.push("-----BEGIN PGP SIGNATURE-----\n"),u.push(le(n,a)),u.push(oe(t)),u.push("=",pe(c)),u.push("-----END PGP SIGNATURE-----\n")}return ie.concat(u)}class _e{constructor(){this.bytes=""}read(e){return this.bytes=ie.uint8ArrayToString(e.subarray(0,8)),this.bytes.length}write(){return ie.stringToUint8Array(this.bytes)}toHex(){return ie.uint8ArrayToHex(ie.stringToUint8Array(this.bytes))}equals(e,t=!1){return t&&(e.isWildcard()||this.isWildcard())||this.bytes===e.bytes}isNull(){return""===this.bytes}isWildcard(){return/^0+$/.test(this.toHex())}static mapToHex(e){return e.toHex()}static fromID(e){const t=new _e;return t.read(ie.hexToUint8Array(e)),t}static wildcard(){const e=new _e;return e.read(new Uint8Array(8)),e}}var ke=function(){var e,t,r=!1;function i(r,i){var n=e[(t[r]+t[i])%255];return 0!==r&&0!==i||(n=0),n}var n,a,s,o,c=!1;function u(){function u(r){var i,n,a;for(n=a=function(r){var i=e[255-t[r]];return 0===r&&(i=0),i}(r),i=0;i<4;i++)a^=n=255&(n<<1|n>>>7);return a^=99}r||function(){e=[],t=[];var i,n,a=1;for(i=0;i<255;i++)e[i]=a,n=128&a,a<<=1,a&=255,128===n&&(a^=27),a^=e[i],t[e[i]]=i;e[255]=e[0],t[0]=0,r=!0}(),n=[],a=[],s=[[],[],[],[]],o=[[],[],[],[]];for(var h=0;h<256;h++){var d=u(h);n[h]=d,a[d]=h,s[0][h]=i(2,d)<<24|d<<16|d<<8|i(3,d),o[0][d]=i(14,h)<<24|i(9,h)<<16|i(13,h)<<8|i(11,h);for(var f=1;f<4;f++)s[f][h]=s[f-1][h]>>>8|s[f-1][h]<<24,o[f][d]=o[f-1][d]>>>8|o[f-1][d]<<24}c=!0}var h=function(e,t){c||u();var r=new Uint32Array(t);r.set(n,512),r.set(a,768);for(var i=0;i<4;i++)r.set(s[i],4096+1024*i>>2),r.set(o[i],8192+1024*i>>2);var h=function(e,t,r){"use asm";var i=0,n=0,a=0,s=0,o=0,c=0,u=0,h=0,d=0,f=0,l=0,p=0,y=0,b=0,m=0,g=0,w=0,v=0,_=0,k=0,A=0;var S=new e.Uint32Array(r),E=new e.Uint8Array(r);function P(e,t,r,o,c,u,h,d){e=e|0;t=t|0;r=r|0;o=o|0;c=c|0;u=u|0;h=h|0;d=d|0;var f=0,l=0,p=0,y=0,b=0,m=0,g=0,w=0;f=r|0x400,l=r|0x800,p=r|0xc00;c=c^S[(e|0)>>2],u=u^S[(e|4)>>2],h=h^S[(e|8)>>2],d=d^S[(e|12)>>2];for(w=16;(w|0)<=o<<4;w=w+16|0){y=S[(r|c>>22&1020)>>2]^S[(f|u>>14&1020)>>2]^S[(l|h>>6&1020)>>2]^S[(p|d<<2&1020)>>2]^S[(e|w|0)>>2],b=S[(r|u>>22&1020)>>2]^S[(f|h>>14&1020)>>2]^S[(l|d>>6&1020)>>2]^S[(p|c<<2&1020)>>2]^S[(e|w|4)>>2],m=S[(r|h>>22&1020)>>2]^S[(f|d>>14&1020)>>2]^S[(l|c>>6&1020)>>2]^S[(p|u<<2&1020)>>2]^S[(e|w|8)>>2],g=S[(r|d>>22&1020)>>2]^S[(f|c>>14&1020)>>2]^S[(l|u>>6&1020)>>2]^S[(p|h<<2&1020)>>2]^S[(e|w|12)>>2];c=y,u=b,h=m,d=g}i=S[(t|c>>22&1020)>>2]<<24^S[(t|u>>14&1020)>>2]<<16^S[(t|h>>6&1020)>>2]<<8^S[(t|d<<2&1020)>>2]^S[(e|w|0)>>2],n=S[(t|u>>22&1020)>>2]<<24^S[(t|h>>14&1020)>>2]<<16^S[(t|d>>6&1020)>>2]<<8^S[(t|c<<2&1020)>>2]^S[(e|w|4)>>2],a=S[(t|h>>22&1020)>>2]<<24^S[(t|d>>14&1020)>>2]<<16^S[(t|c>>6&1020)>>2]<<8^S[(t|u<<2&1020)>>2]^S[(e|w|8)>>2],s=S[(t|d>>22&1020)>>2]<<24^S[(t|c>>14&1020)>>2]<<16^S[(t|u>>6&1020)>>2]<<8^S[(t|h<<2&1020)>>2]^S[(e|w|12)>>2]}function x(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;P(0x0000,0x0800,0x1000,A,e,t,r,i)}function M(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var a=0;P(0x0400,0x0c00,0x2000,A,e,i,r,t);a=n,n=s,s=a}function K(e,t,r,d){e=e|0;t=t|0;r=r|0;d=d|0;P(0x0000,0x0800,0x1000,A,o^e,c^t,u^r,h^d);o=i,c=n,u=a,h=s}function C(e,t,r,d){e=e|0;t=t|0;r=r|0;d=d|0;var f=0;P(0x0400,0x0c00,0x2000,A,e,d,r,t);f=n,n=s,s=f;i=i^o,n=n^c,a=a^u,s=s^h;o=e,c=t,u=r,h=d}function D(e,t,r,d){e=e|0;t=t|0;r=r|0;d=d|0;P(0x0000,0x0800,0x1000,A,o,c,u,h);o=i=i^e,c=n=n^t,u=a=a^r,h=s=s^d}function U(e,t,r,d){e=e|0;t=t|0;r=r|0;d=d|0;P(0x0000,0x0800,0x1000,A,o,c,u,h);i=i^e,n=n^t,a=a^r,s=s^d;o=e,c=t,u=r,h=d}function R(e,t,r,d){e=e|0;t=t|0;r=r|0;d=d|0;P(0x0000,0x0800,0x1000,A,o,c,u,h);o=i,c=n,u=a,h=s;i=i^e,n=n^t,a=a^r,s=s^d}function I(e,t,r,o){e=e|0;t=t|0;r=r|0;o=o|0;P(0x0000,0x0800,0x1000,A,d,f,l,p);p=~g&p|g&p+1;l=~m&l|m&l+((p|0)==0);f=~b&f|b&f+((l|0)==0);d=~y&d|y&d+((f|0)==0);i=i^e;n=n^t;a=a^r;s=s^o}function B(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;var n=0,a=0,s=0,d=0,f=0,l=0,p=0,y=0,b=0,m=0;e=e^o,t=t^c,r=r^u,i=i^h;n=w|0,a=v|0,s=_|0,d=k|0;for(;(b|0)<128;b=b+1|0){if(n>>>31){f=f^e,l=l^t,p=p^r,y=y^i}n=n<<1|a>>>31,a=a<<1|s>>>31,s=s<<1|d>>>31,d=d<<1;m=i&1;i=i>>>1|r<<31,r=r>>>1|t<<31,t=t>>>1|e<<31,e=e>>>1;if(m)e=e^0xe1000000}o=f,c=l,u=p,h=y}function T(e){e=e|0;A=e}function z(e,t,r,o){e=e|0;t=t|0;r=r|0;o=o|0;i=e,n=t,a=r,s=o}function q(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;o=e,c=t,u=r,h=i}function F(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;d=e,f=t,l=r,p=i}function O(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;y=e,b=t,m=r,g=i}function L(e,t,r,i){e=e|0;t=t|0;r=r|0;i=i|0;p=~g&p|g&i,l=~m&l|m&r,f=~b&f|b&t,d=~y&d|y&e}function N(e){e=e|0;if(e&15)return-1;E[e|0]=i>>>24,E[e|1]=i>>>16&255,E[e|2]=i>>>8&255,E[e|3]=i&255,E[e|4]=n>>>24,E[e|5]=n>>>16&255,E[e|6]=n>>>8&255,E[e|7]=n&255,E[e|8]=a>>>24,E[e|9]=a>>>16&255,E[e|10]=a>>>8&255,E[e|11]=a&255,E[e|12]=s>>>24,E[e|13]=s>>>16&255,E[e|14]=s>>>8&255,E[e|15]=s&255;return 16}function j(e){e=e|0;if(e&15)return-1;E[e|0]=o>>>24,E[e|1]=o>>>16&255,E[e|2]=o>>>8&255,E[e|3]=o&255,E[e|4]=c>>>24,E[e|5]=c>>>16&255,E[e|6]=c>>>8&255,E[e|7]=c&255,E[e|8]=u>>>24,E[e|9]=u>>>16&255,E[e|10]=u>>>8&255,E[e|11]=u&255,E[e|12]=h>>>24,E[e|13]=h>>>16&255,E[e|14]=h>>>8&255,E[e|15]=h&255;return 16}function W(){x(0,0,0,0);w=i,v=n,_=a,k=s}function H(e,t,r){e=e|0;t=t|0;r=r|0;var o=0;if(t&15)return-1;while((r|0)>=16){V[e&7](E[t|0]<<24|E[t|1]<<16|E[t|2]<<8|E[t|3],E[t|4]<<24|E[t|5]<<16|E[t|6]<<8|E[t|7],E[t|8]<<24|E[t|9]<<16|E[t|10]<<8|E[t|11],E[t|12]<<24|E[t|13]<<16|E[t|14]<<8|E[t|15]);E[t|0]=i>>>24,E[t|1]=i>>>16&255,E[t|2]=i>>>8&255,E[t|3]=i&255,E[t|4]=n>>>24,E[t|5]=n>>>16&255,E[t|6]=n>>>8&255,E[t|7]=n&255,E[t|8]=a>>>24,E[t|9]=a>>>16&255,E[t|10]=a>>>8&255,E[t|11]=a&255,E[t|12]=s>>>24,E[t|13]=s>>>16&255,E[t|14]=s>>>8&255,E[t|15]=s&255;o=o+16|0,t=t+16|0,r=r-16|0}return o|0}function G(e,t,r){e=e|0;t=t|0;r=r|0;var i=0;if(t&15)return-1;while((r|0)>=16){$[e&1](E[t|0]<<24|E[t|1]<<16|E[t|2]<<8|E[t|3],E[t|4]<<24|E[t|5]<<16|E[t|6]<<8|E[t|7],E[t|8]<<24|E[t|9]<<16|E[t|10]<<8|E[t|11],E[t|12]<<24|E[t|13]<<16|E[t|14]<<8|E[t|15]);i=i+16|0,t=t+16|0,r=r-16|0}return i|0}var V=[x,M,K,C,D,U,R,I];var $=[K,B];return{set_rounds:T,set_state:z,set_iv:q,set_nonce:F,set_mask:O,set_counter:L,get_state:N,get_iv:j,gcm_init:W,cipher:H,mac:G}}({Uint8Array,Uint32Array},e,t);return h.set_key=function(e,t,i,a,s,c,u,d,f){var l=r.subarray(0,60),p=r.subarray(256,316);l.set([t,i,a,s,c,u,d,f]);for(var y=e,b=1;y<4*e+28;y++){var m=l[y-1];(y%e==0||8===e&&y%e==4)&&(m=n[m>>>24]<<24^n[m>>>16&255]<<16^n[m>>>8&255]<<8^n[255&m]),y%e==0&&(m=m<<8^m>>>24^b<<24,b=b<<1^(128&b?27:0)),l[y]=l[y-e]^m}for(var g=0;g=y-4?m:o[0][n[m>>>24]]^o[1][n[m>>>16&255]]^o[2][n[m>>>8&255]]^o[3][n[255&m]]}h.set_rounds(e+5)},h};return h.ENC={ECB:0,CBC:2,CFB:4,OFB:6,CTR:7},h.DEC={ECB:1,CBC:3,CFB:5,OFB:6,CTR:7},h.MAC={CBC:0,GCM:1},h.HEAP_DATA=16384,h}();function Ae(e){return e instanceof Uint8Array}function Se(e,t){const r=e?e.byteLength:t||65536;if(4095&r||r<=0)throw Error("heap size must be a positive integer and a multiple of 4096");return e=e||new Uint8Array(new ArrayBuffer(r))}function Ee(e,t,r,i,n){const a=e.length-t,s=ae+t.length),0),r=new Uint8Array(t);let i=0;for(let t=0;t>2,n.getUint32(0),n.getUint32(4),n.getUint32(8),n.getUint32(12),i>16?n.getUint32(16):0,i>16?n.getUint32(20):0,i>24?n.getUint32(24):0,i>24?n.getUint32(28):0),void 0!==t){if(16!==t.length)throw new Me("illegal iv size");let e=new DataView(t.buffer,t.byteOffset,t.byteLength);r.set_iv(e.getUint32(0),e.getUint32(4),e.getUint32(8),e.getUint32(12))}else r.set_iv(0,0,0,0)}AES_Encrypt_process(e){if(!Ae(e))throw new TypeError("data isn't of expected type");let{heap:t,asm:r}=this.acquire_asm(),i=ke.ENC[this.mode],n=ke.HEAP_DATA,a=this.pos,s=this.len,o=0,c=e.length||0,u=0,h=0,d=new Uint8Array(s+c&-16);for(;c>0;)h=Ee(t,a+s,e,o,c),s+=h,o+=h,c-=h,h=r.cipher(i,n+a,s),h&&d.set(t.subarray(a,a+h),u),u+=h,h0;)f=Ee(t,a+s,e,o,c),s+=f,o+=f,c-=f,f=r.cipher(i,n+a,s-(c?0:d)),f&&l.set(t.subarray(a,a+f),u),u+=f,f0){if(a%16){if(this.hasOwnProperty("padding"))throw new Me("data length must be a multiple of the block size");a+=16-a%16}if(t.cipher(r,i+n,a),this.hasOwnProperty("padding")&&this.padding){let t=e[n+s-1];if(t<1||t>16||t>s)throw new Ke("bad padding");let r=0;for(let i=t;i>1;i--)r|=t^e[n+s-i];if(r)throw new Ke("bad padding");s-=t}}const o=new Uint8Array(s);return s>0&&o.set(e.subarray(n,n+s)),this.pos=0,this.len=0,this.release_asm(),o}}class Re{static encrypt(e,t,r=!1){return new Re(t,r).encrypt(e)}static decrypt(e,t,r=!1){return new Re(t,r).decrypt(e)}constructor(e,t=!1,r){this.aes=r||new Ue(e,void 0,t,"ECB")}encrypt(e){return Pe(this.aes.AES_Encrypt_process(e),this.aes.AES_Encrypt_finish())}decrypt(e){return Pe(this.aes.AES_Decrypt_process(e),this.aes.AES_Decrypt_finish())}}function Ie(e){const t=function(e){const t=new Re(e);this.encrypt=function(e){return t.encrypt(e)},this.decrypt=function(e){return t.decrypt(e)}};return t.blockSize=t.prototype.blockSize=16,t.keySize=t.prototype.keySize=e/8,t}function Be(e,t,r,i,n,a){const s=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],o=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],c=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],u=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],h=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],d=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],f=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],l=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];let p,y,b,m,g,w,v,_,k,A,S,E,P,x,M=0,K=t.length;const C=32===e.length?3:9;_=3===C?r?[0,32,2]:[30,-2,-2]:r?[0,32,2,62,30,-2,64,96,2]:[94,62,-2,32,64,2,30,-2,-2],r&&(t=function(e,t){const r=8-e.length%8;let i;if(2===t&&r<8)i=32;else if(1===t)i=r;else{if(t||!(r<8)){if(8===r)return e;throw Error("des: invalid padding")}i=0}const n=new Uint8Array(e.length+r);for(let t=0;t>>4^v),v^=b,w^=b<<4,b=65535&(w>>>16^v),v^=b,w^=b<<16,b=858993459&(v>>>2^w),w^=b,v^=b<<2,b=16711935&(v>>>8^w),w^=b,v^=b<<8,b=1431655765&(w>>>1^v),v^=b,w^=b<<1,w=w<<1|w>>>31,v=v<<1|v>>>31,y=0;y>>4|v<<28)^e[p+1],b=w,w=v,v=b^(o[m>>>24&63]|u[m>>>16&63]|d[m>>>8&63]|l[63&m]|s[g>>>24&63]|c[g>>>16&63]|h[g>>>8&63]|f[63&g]);b=w,w=v,v=b}w=w>>>1|w<<31,v=v>>>1|v<<31,b=1431655765&(w>>>1^v),v^=b,w^=b<<1,b=16711935&(v>>>8^w),w^=b,v^=b<<8,b=858993459&(v>>>2^w),w^=b,v^=b<<2,b=65535&(w>>>16^v),v^=b,w^=b<<16,b=252645135&(w>>>4^v),v^=b,w^=b<<4,1===i&&(r?(k=w,S=v):(w^=A,v^=E)),D[U++]=w>>>24,D[U++]=w>>>16&255,D[U++]=w>>>8&255,D[U++]=255&w,D[U++]=v>>>24,D[U++]=v>>>16&255,D[U++]=v>>>8&255,D[U++]=255&v}return r||(D=function(e,t){let r,i=null;if(2===t)r=32;else if(1===t)i=e[e.length-1];else{if(t)throw Error("des: invalid padding");r=0}if(!i){for(i=1;e[e.length-i]===r;)i++;i--}return e.subarray(0,e.length-i)}(D,a)),D}function Te(e){const t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],r=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],n=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],a=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],s=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],o=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],u=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],f=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],l=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],p=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],y=e.length>8?3:1,b=Array(32*y),m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0];let g,w,v,_=0,k=0;for(let A=0;A>>4^A),A^=v,y^=v<<4,v=65535&(A>>>-16^y),y^=v,A^=v<<-16,v=858993459&(y>>>2^A),A^=v,y^=v<<2,v=65535&(A>>>-16^y),y^=v,A^=v<<-16,v=1431655765&(y>>>1^A),A^=v,y^=v<<1,v=16711935&(A>>>8^y),y^=v,A^=v<<8,v=1431655765&(y>>>1^A),A^=v,y^=v<<1,v=y<<8|A>>>20&240,y=A<<24|A<<8&16711680|A>>>8&65280|A>>>24&240,A=v;for(let e=0;e<16;e++)m[e]?(y=y<<2|y>>>26,A=A<<2|A>>>26):(y=y<<1|y>>>27,A=A<<1|A>>>27),y&=-15,A&=-15,g=t[y>>>28]|r[y>>>24&15]|i[y>>>20&15]|n[y>>>16&15]|a[y>>>12&15]|s[y>>>8&15]|o[y>>>4&15],w=c[A>>>28]|u[A>>>24&15]|h[A>>>20&15]|d[A>>>16&15]|f[A>>>12&15]|l[A>>>8&15]|p[A>>>4&15],v=65535&(w>>>16^g),b[k++]=g^v,b[k++]=w^v<<16}return b}function ze(e){this.key=[];for(let t=0;t<3;t++)this.key.push(new Uint8Array(e.subarray(8*t,8*t+8)));this.encrypt=function(e){return Be(Te(this.key[2]),Be(Te(this.key[1]),Be(Te(this.key[0]),e,!0,0,null,null),!1,0,null,null),!0,0,null,null)}}function qe(){this.BlockSize=8,this.KeySize=16,this.setKey=function(e){if(this.masking=Array(16),this.rotate=Array(16),this.reset(),e.length!==this.KeySize)throw Error("CAST-128: keys must be 16 bytes");return this.keySchedule(e),!0},this.reset=function(){for(let e=0;e<16;e++)this.masking[e]=0,this.rotate[e]=0},this.getBlockSize=function(){return this.BlockSize},this.encrypt=function(e){const t=Array(e.length);for(let a=0;a>>24&255,t[a+1]=c>>>16&255,t[a+2]=c>>>8&255,t[a+3]=255&c,t[a+4]=o>>>24&255,t[a+5]=o>>>16&255,t[a+6]=o>>>8&255,t[a+7]=255&o}return t},this.decrypt=function(e){const t=Array(e.length);for(let a=0;a>>24&255,t[a+1]=c>>>16&255,t[a+2]=c>>>8&255,t[a+3]=255&c,t[a+4]=o>>>24&255,t[a+5]=o>>16&255,t[a+6]=o>>8&255,t[a+7]=255&o}return t};const e=[,,,,];e[0]=[,,,,],e[0][0]=[4,0,13,15,12,14,8],e[0][1]=[5,2,16,18,17,19,10],e[0][2]=[6,3,23,22,21,20,9],e[0][3]=[7,1,26,25,27,24,11],e[1]=[,,,,],e[1][0]=[0,6,21,23,20,22,16],e[1][1]=[1,4,0,2,1,3,18],e[1][2]=[2,5,7,6,5,4,17],e[1][3]=[3,7,10,9,11,8,19],e[2]=[,,,,],e[2][0]=[4,0,13,15,12,14,8],e[2][1]=[5,2,16,18,17,19,10],e[2][2]=[6,3,23,22,21,20,9],e[2][3]=[7,1,26,25,27,24,11],e[3]=[,,,,],e[3][0]=[0,6,21,23,20,22,16],e[3][1]=[1,4,0,2,1,3,18],e[3][2]=[2,5,7,6,5,4,17],e[3][3]=[3,7,10,9,11,8,19];const t=[,,,,];function r(e,t,r){const i=t+e,n=i<>>32-r;return(a[0][n>>>24]^a[1][n>>>16&255])-a[2][n>>>8&255]+a[3][255&n]}function i(e,t,r){const i=t^e,n=i<>>32-r;return a[0][n>>>24]-a[1][n>>>16&255]+a[2][n>>>8&255]^a[3][255&n]}function n(e,t,r){const i=t-e,n=i<>>32-r;return(a[0][n>>>24]+a[1][n>>>16&255]^a[2][n>>>8&255])-a[3][255&n]}t[0]=[,,,,],t[0][0]=[24,25,23,22,18],t[0][1]=[26,27,21,20,22],t[0][2]=[28,29,19,18,25],t[0][3]=[30,31,17,16,28],t[1]=[,,,,],t[1][0]=[3,2,12,13,8],t[1][1]=[1,0,14,15,13],t[1][2]=[7,6,8,9,3],t[1][3]=[5,4,10,11,7],t[2]=[,,,,],t[2][0]=[19,18,28,29,25],t[2][1]=[17,16,30,31,28],t[2][2]=[23,22,24,25,18],t[2][3]=[21,20,26,27,22],t[3]=[,,,,],t[3][0]=[8,9,7,6,3],t[3][1]=[10,11,5,4,7],t[3][2]=[12,13,3,2,8],t[3][3]=[14,15,1,0,13],this.keySchedule=function(r){const i=[,,,,,,,,],n=Array(32);let s;for(let e=0;e<4;e++)s=4*e,i[e]=r[s]<<24|r[s+1]<<16|r[s+2]<<8|r[s+3];const o=[6,7,4,5];let c,u=0;for(let r=0;r<2;r++)for(let r=0;r<4;r++){for(s=0;s<4;s++){const t=e[r][s];c=i[t[1]],c^=a[4][i[t[2]>>>2]>>>24-8*(3&t[2])&255],c^=a[5][i[t[3]>>>2]>>>24-8*(3&t[3])&255],c^=a[6][i[t[4]>>>2]>>>24-8*(3&t[4])&255],c^=a[7][i[t[5]>>>2]>>>24-8*(3&t[5])&255],c^=a[o[s]][i[t[6]>>>2]>>>24-8*(3&t[6])&255],i[t[0]]=c}for(s=0;s<4;s++){const e=t[r][s];c=a[4][i[e[0]>>>2]>>>24-8*(3&e[0])&255],c^=a[5][i[e[1]>>>2]>>>24-8*(3&e[1])&255],c^=a[6][i[e[2]>>>2]>>>24-8*(3&e[2])&255],c^=a[7][i[e[3]>>>2]>>>24-8*(3&e[3])&255],c^=a[4+s][i[e[4]>>>2]>>>24-8*(3&e[4])&255],n[u]=c,u++}}for(let e=0;e<16;e++)this.masking[e]=n[e],this.rotate[e]=31&n[16+e]};const a=[,,,,,,,,];a[0]=[821772500,2678128395,1810681135,1059425402,505495343,2617265619,1610868032,3483355465,3218386727,2294005173,3791863952,2563806837,1852023008,365126098,3269944861,584384398,677919599,3229601881,4280515016,2002735330,1136869587,3744433750,2289869850,2731719981,2714362070,879511577,1639411079,575934255,717107937,2857637483,576097850,2731753936,1725645e3,2810460463,5111599,767152862,2543075244,1251459544,1383482551,3052681127,3089939183,3612463449,1878520045,1510570527,2189125840,2431448366,582008916,3163445557,1265446783,1354458274,3529918736,3202711853,3073581712,3912963487,3029263377,1275016285,4249207360,2905708351,3304509486,1442611557,3585198765,2712415662,2731849581,3248163920,2283946226,208555832,2766454743,1331405426,1447828783,3315356441,3108627284,2957404670,2981538698,3339933917,1669711173,286233437,1465092821,1782121619,3862771680,710211251,980974943,1651941557,430374111,2051154026,704238805,4128970897,3144820574,2857402727,948965521,3333752299,2227686284,718756367,2269778983,2731643755,718440111,2857816721,3616097120,1113355533,2478022182,410092745,1811985197,1944238868,2696854588,1415722873,1682284203,1060277122,1998114690,1503841958,82706478,2315155686,1068173648,845149890,2167947013,1768146376,1993038550,3566826697,3390574031,940016341,3355073782,2328040721,904371731,1205506512,4094660742,2816623006,825647681,85914773,2857843460,1249926541,1417871568,3287612,3211054559,3126306446,1975924523,1353700161,2814456437,2438597621,1800716203,722146342,2873936343,1151126914,4160483941,2877670899,458611604,2866078500,3483680063,770352098,2652916994,3367839148,3940505011,3585973912,3809620402,718646636,2504206814,2914927912,3631288169,2857486607,2860018678,575749918,2857478043,718488780,2069512688,3548183469,453416197,1106044049,3032691430,52586708,3378514636,3459808877,3211506028,1785789304,218356169,3571399134,3759170522,1194783844,1523787992,3007827094,1975193539,2555452411,1341901877,3045838698,3776907964,3217423946,2802510864,2889438986,1057244207,1636348243,3761863214,1462225785,2632663439,481089165,718503062,24497053,3332243209,3344655856,3655024856,3960371065,1195698900,2971415156,3710176158,2115785917,4027663609,3525578417,2524296189,2745972565,3564906415,1372086093,1452307862,2780501478,1476592880,3389271281,18495466,2378148571,901398090,891748256,3279637769,3157290713,2560960102,1447622437,4284372637,216884176,2086908623,1879786977,3588903153,2242455666,2938092967,3559082096,2810645491,758861177,1121993112,215018983,642190776,4169236812,1196255959,2081185372,3508738393,941322904,4124243163,2877523539,1848581667,2205260958,3180453958,2589345134,3694731276,550028657,2519456284,3789985535,2973870856,2093648313,443148163,46942275,2734146937,1117713533,1115362972,1523183689,3717140224,1551984063],a[1]=[522195092,4010518363,1776537470,960447360,4267822970,4005896314,1435016340,1929119313,2913464185,1310552629,3579470798,3724818106,2579771631,1594623892,417127293,2715217907,2696228731,1508390405,3994398868,3925858569,3695444102,4019471449,3129199795,3770928635,3520741761,990456497,4187484609,2783367035,21106139,3840405339,631373633,3783325702,532942976,396095098,3548038825,4267192484,2564721535,2011709262,2039648873,620404603,3776170075,2898526339,3612357925,4159332703,1645490516,223693667,1567101217,3362177881,1029951347,3470931136,3570957959,1550265121,119497089,972513919,907948164,3840628539,1613718692,3594177948,465323573,2659255085,654439692,2575596212,2699288441,3127702412,277098644,624404830,4100943870,2717858591,546110314,2403699828,3655377447,1321679412,4236791657,1045293279,4010672264,895050893,2319792268,494945126,1914543101,2777056443,3894764339,2219737618,311263384,4275257268,3458730721,669096869,3584475730,3835122877,3319158237,3949359204,2005142349,2713102337,2228954793,3769984788,569394103,3855636576,1425027204,108000370,2736431443,3671869269,3043122623,1750473702,2211081108,762237499,3972989403,2798899386,3061857628,2943854345,867476300,964413654,1591880597,1594774276,2179821409,552026980,3026064248,3726140315,2283577634,3110545105,2152310760,582474363,1582640421,1383256631,2043843868,3322775884,1217180674,463797851,2763038571,480777679,2718707717,2289164131,3118346187,214354409,200212307,3810608407,3025414197,2674075964,3997296425,1847405948,1342460550,510035443,4080271814,815934613,833030224,1620250387,1945732119,2703661145,3966000196,1388869545,3456054182,2687178561,2092620194,562037615,1356438536,3409922145,3261847397,1688467115,2150901366,631725691,3840332284,549916902,3455104640,394546491,837744717,2114462948,751520235,2221554606,2415360136,3999097078,2063029875,803036379,2702586305,821456707,3019566164,360699898,4018502092,3511869016,3677355358,2402471449,812317050,49299192,2570164949,3259169295,2816732080,3331213574,3101303564,2156015656,3705598920,3546263921,143268808,3200304480,1638124008,3165189453,3341807610,578956953,2193977524,3638120073,2333881532,807278310,658237817,2969561766,1641658566,11683945,3086995007,148645947,1138423386,4158756760,1981396783,2401016740,3699783584,380097457,2680394679,2803068651,3334260286,441530178,4016580796,1375954390,761952171,891809099,2183123478,157052462,3683840763,1592404427,341349109,2438483839,1417898363,644327628,2233032776,2353769706,2201510100,220455161,1815641738,182899273,2995019788,3627381533,3702638151,2890684138,1052606899,588164016,1681439879,4038439418,2405343923,4229449282,167996282,1336969661,1688053129,2739224926,1543734051,1046297529,1138201970,2121126012,115334942,1819067631,1902159161,1941945968,2206692869,1159982321],a[2]=[2381300288,637164959,3952098751,3893414151,1197506559,916448331,2350892612,2932787856,3199334847,4009478890,3905886544,1373570990,2450425862,4037870920,3778841987,2456817877,286293407,124026297,3001279700,1028597854,3115296800,4208886496,2691114635,2188540206,1430237888,1218109995,3572471700,308166588,570424558,2187009021,2455094765,307733056,1310360322,3135275007,1384269543,2388071438,863238079,2359263624,2801553128,3380786597,2831162807,1470087780,1728663345,4072488799,1090516929,532123132,2389430977,1132193179,2578464191,3051079243,1670234342,1434557849,2711078940,1241591150,3314043432,3435360113,3091448339,1812415473,2198440252,267246943,796911696,3619716990,38830015,1526438404,2806502096,374413614,2943401790,1489179520,1603809326,1920779204,168801282,260042626,2358705581,1563175598,2397674057,1356499128,2217211040,514611088,2037363785,2186468373,4022173083,2792511869,2913485016,1173701892,4200428547,3896427269,1334932762,2455136706,602925377,2835607854,1613172210,41346230,2499634548,2457437618,2188827595,41386358,4172255629,1313404830,2405527007,3801973774,2217704835,873260488,2528884354,2478092616,4012915883,2555359016,2006953883,2463913485,575479328,2218240648,2099895446,660001756,2341502190,3038761536,3888151779,3848713377,3286851934,1022894237,1620365795,3449594689,1551255054,15374395,3570825345,4249311020,4151111129,3181912732,310226346,1133119310,530038928,136043402,2476768958,3107506709,2544909567,1036173560,2367337196,1681395281,1758231547,3641649032,306774401,1575354324,3716085866,1990386196,3114533736,2455606671,1262092282,3124342505,2768229131,4210529083,1833535011,423410938,660763973,2187129978,1639812e3,3508421329,3467445492,310289298,272797111,2188552562,2456863912,310240523,677093832,1013118031,901835429,3892695601,1116285435,3036471170,1337354835,243122523,520626091,277223598,4244441197,4194248841,1766575121,594173102,316590669,742362309,3536858622,4176435350,3838792410,2501204839,1229605004,3115755532,1552908988,2312334149,979407927,3959474601,1148277331,176638793,3614686272,2083809052,40992502,1340822838,2731552767,3535757508,3560899520,1354035053,122129617,7215240,2732932949,3118912700,2718203926,2539075635,3609230695,3725561661,1928887091,2882293555,1988674909,2063640240,2491088897,1459647954,4189817080,2302804382,1113892351,2237858528,1927010603,4002880361,1856122846,1594404395,2944033133,3855189863,3474975698,1643104450,4054590833,3431086530,1730235576,2984608721,3084664418,2131803598,4178205752,267404349,1617849798,1616132681,1462223176,736725533,2327058232,551665188,2945899023,1749386277,2575514597,1611482493,674206544,2201269090,3642560800,728599968,1680547377,2620414464,1388111496,453204106,4156223445,1094905244,2754698257,2201108165,3757000246,2704524545,3922940700,3996465027],a[3]=[2645754912,532081118,2814278639,3530793624,1246723035,1689095255,2236679235,4194438865,2116582143,3859789411,157234593,2045505824,4245003587,1687664561,4083425123,605965023,672431967,1336064205,3376611392,214114848,4258466608,3232053071,489488601,605322005,3998028058,264917351,1912574028,756637694,436560991,202637054,135989450,85393697,2152923392,3896401662,2895836408,2145855233,3535335007,115294817,3147733898,1922296357,3464822751,4117858305,1037454084,2725193275,2127856640,1417604070,1148013728,1827919605,642362335,2929772533,909348033,1346338451,3547799649,297154785,1917849091,4161712827,2883604526,3968694238,1469521537,3780077382,3375584256,1763717519,136166297,4290970789,1295325189,2134727907,2798151366,1566297257,3672928234,2677174161,2672173615,965822077,2780786062,289653839,1133871874,3491843819,35685304,1068898316,418943774,672553190,642281022,2346158704,1954014401,3037126780,4079815205,2030668546,3840588673,672283427,1776201016,359975446,3750173538,555499703,2769985273,1324923,69110472,152125443,3176785106,3822147285,1340634837,798073664,1434183902,15393959,216384236,1303690150,3881221631,3711134124,3960975413,106373927,2578434224,1455997841,1801814300,1578393881,1854262133,3188178946,3258078583,2302670060,1539295533,3505142565,3078625975,2372746020,549938159,3278284284,2620926080,181285381,2865321098,3970029511,68876850,488006234,1728155692,2608167508,836007927,2435231793,919367643,3339422534,3655756360,1457871481,40520939,1380155135,797931188,234455205,2255801827,3990488299,397000196,739833055,3077865373,2871719860,4022553888,772369276,390177364,3853951029,557662966,740064294,1640166671,1699928825,3535942136,622006121,3625353122,68743880,1742502,219489963,1664179233,1577743084,1236991741,410585305,2366487942,823226535,1050371084,3426619607,3586839478,212779912,4147118561,1819446015,1911218849,530248558,3486241071,3252585495,2886188651,3410272728,2342195030,20547779,2982490058,3032363469,3631753222,312714466,1870521650,1493008054,3491686656,615382978,4103671749,2534517445,1932181,2196105170,278426614,6369430,3274544417,2913018367,697336853,2143000447,2946413531,701099306,1558357093,2805003052,3500818408,2321334417,3567135975,216290473,3591032198,23009561,1996984579,3735042806,2024298078,3739440863,569400510,2339758983,3016033873,3097871343,3639523026,3844324983,3256173865,795471839,2951117563,4101031090,4091603803,3603732598,971261452,534414648,428311343,3389027175,2844869880,694888862,1227866773,2456207019,3043454569,2614353370,3749578031,3676663836,459166190,4132644070,1794958188,51825668,2252611902,3084671440,2036672799,3436641603,1099053433,2469121526,3059204941,1323291266,2061838604,1018778475,2233344254,2553501054,334295216,3556750194,1065731521,183467730],a[4]=[2127105028,745436345,2601412319,2788391185,3093987327,500390133,1155374404,389092991,150729210,3891597772,3523549952,1935325696,716645080,946045387,2901812282,1774124410,3869435775,4039581901,3293136918,3438657920,948246080,363898952,3867875531,1286266623,1598556673,68334250,630723836,1104211938,1312863373,613332731,2377784574,1101634306,441780740,3129959883,1917973735,2510624549,3238456535,2544211978,3308894634,1299840618,4076074851,1756332096,3977027158,297047435,3790297736,2265573040,3621810518,1311375015,1667687725,47300608,3299642885,2474112369,201668394,1468347890,576830978,3594690761,3742605952,1958042578,1747032512,3558991340,1408974056,3366841779,682131401,1033214337,1545599232,4265137049,206503691,103024618,2855227313,1337551222,2428998917,2963842932,4015366655,3852247746,2796956967,3865723491,3747938335,247794022,3755824572,702416469,2434691994,397379957,851939612,2314769512,218229120,1380406772,62274761,214451378,3170103466,2276210409,3845813286,28563499,446592073,1693330814,3453727194,29968656,3093872512,220656637,2470637031,77972100,1667708854,1358280214,4064765667,2395616961,325977563,4277240721,4220025399,3605526484,3355147721,811859167,3069544926,3962126810,652502677,3075892249,4132761541,3498924215,1217549313,3250244479,3858715919,3053989961,1538642152,2279026266,2875879137,574252750,3324769229,2651358713,1758150215,141295887,2719868960,3515574750,4093007735,4194485238,1082055363,3417560400,395511885,2966884026,179534037,3646028556,3738688086,1092926436,2496269142,257381841,3772900718,1636087230,1477059743,2499234752,3811018894,2675660129,3285975680,90732309,1684827095,1150307763,1723134115,3237045386,1769919919,1240018934,815675215,750138730,2239792499,1234303040,1995484674,138143821,675421338,1145607174,1936608440,3238603024,2345230278,2105974004,323969391,779555213,3004902369,2861610098,1017501463,2098600890,2628620304,2940611490,2682542546,1171473753,3656571411,3687208071,4091869518,393037935,159126506,1662887367,1147106178,391545844,3452332695,1891500680,3016609650,1851642611,546529401,1167818917,3194020571,2848076033,3953471836,575554290,475796850,4134673196,450035699,2351251534,844027695,1080539133,86184846,1554234488,3692025454,1972511363,2018339607,1491841390,1141460869,1061690759,4244549243,2008416118,2351104703,2868147542,1598468138,722020353,1027143159,212344630,1387219594,1725294528,3745187956,2500153616,458938280,4129215917,1828119673,544571780,3503225445,2297937496,1241802790,267843827,2694610800,1397140384,1558801448,3782667683,1806446719,929573330,2234912681,400817706,616011623,4121520928,3603768725,1761550015,1968522284,4053731006,4192232858,4005120285,872482584,3140537016,3894607381,2287405443,1963876937,3663887957,1584857e3,2975024454,1833426440,4025083860],a[5]=[4143615901,749497569,1285769319,3795025788,2514159847,23610292,3974978748,844452780,3214870880,3751928557,2213566365,1676510905,448177848,3730751033,4086298418,2307502392,871450977,3222878141,4110862042,3831651966,2735270553,1310974780,2043402188,1218528103,2736035353,4274605013,2702448458,3936360550,2693061421,162023535,2827510090,687910808,23484817,3784910947,3371371616,779677500,3503626546,3473927188,4157212626,3500679282,4248902014,2466621104,3899384794,1958663117,925738300,1283408968,3669349440,1840910019,137959847,2679828185,1239142320,1315376211,1547541505,1690155329,739140458,3128809933,3933172616,3876308834,905091803,1548541325,4040461708,3095483362,144808038,451078856,676114313,2861728291,2469707347,993665471,373509091,2599041286,4025009006,4170239449,2149739950,3275793571,3749616649,2794760199,1534877388,572371878,2590613551,1753320020,3467782511,1405125690,4270405205,633333386,3026356924,3475123903,632057672,2846462855,1404951397,3882875879,3915906424,195638627,2385783745,3902872553,1233155085,3355999740,2380578713,2702246304,2144565621,3663341248,3894384975,2502479241,4248018925,3094885567,1594115437,572884632,3385116731,767645374,1331858858,1475698373,3793881790,3532746431,1321687957,619889600,1121017241,3440213920,2070816767,2833025776,1933951238,4095615791,890643334,3874130214,859025556,360630002,925594799,1764062180,3920222280,4078305929,979562269,2810700344,4087740022,1949714515,546639971,1165388173,3069891591,1495988560,922170659,1291546247,2107952832,1813327274,3406010024,3306028637,4241950635,153207855,2313154747,1608695416,1150242611,1967526857,721801357,1220138373,3691287617,3356069787,2112743302,3281662835,1111556101,1778980689,250857638,2298507990,673216130,2846488510,3207751581,3562756981,3008625920,3417367384,2198807050,529510932,3547516680,3426503187,2364944742,102533054,2294910856,1617093527,1204784762,3066581635,1019391227,1069574518,1317995090,1691889997,3661132003,510022745,3238594800,1362108837,1817929911,2184153760,805817662,1953603311,3699844737,120799444,2118332377,207536705,2282301548,4120041617,145305846,2508124933,3086745533,3261524335,1877257368,2977164480,3160454186,2503252186,4221677074,759945014,254147243,2767453419,3801518371,629083197,2471014217,907280572,3900796746,940896768,2751021123,2625262786,3161476951,3661752313,3260732218,1425318020,2977912069,1496677566,3988592072,2140652971,3126511541,3069632175,977771578,1392695845,1698528874,1411812681,1369733098,1343739227,3620887944,1142123638,67414216,3102056737,3088749194,1626167401,2546293654,3941374235,697522451,33404913,143560186,2595682037,994885535,1247667115,3859094837,2699155541,3547024625,4114935275,2968073508,3199963069,2732024527,1237921620,951448369,1898488916,1211705605,2790989240,2233243581,3598044975],a[6]=[2246066201,858518887,1714274303,3485882003,713916271,2879113490,3730835617,539548191,36158695,1298409750,419087104,1358007170,749914897,2989680476,1261868530,2995193822,2690628854,3443622377,3780124940,3796824509,2976433025,4259637129,1551479e3,512490819,1296650241,951993153,2436689437,2460458047,144139966,3136204276,310820559,3068840729,643875328,1969602020,1680088954,2185813161,3283332454,672358534,198762408,896343282,276269502,3014846926,84060815,197145886,376173866,3943890818,3813173521,3545068822,1316698879,1598252827,2633424951,1233235075,859989710,2358460855,3503838400,3409603720,1203513385,1193654839,2792018475,2060853022,207403770,1144516871,3068631394,1121114134,177607304,3785736302,326409831,1929119770,2983279095,4183308101,3474579288,3200513878,3228482096,119610148,1170376745,3378393471,3163473169,951863017,3337026068,3135789130,2907618374,1183797387,2015970143,4045674555,2182986399,2952138740,3928772205,384012900,2454997643,10178499,2879818989,2596892536,111523738,2995089006,451689641,3196290696,235406569,1441906262,3890558523,3013735005,4158569349,1644036924,376726067,1006849064,3664579700,2041234796,1021632941,1374734338,2566452058,371631263,4007144233,490221539,206551450,3140638584,1053219195,1853335209,3412429660,3562156231,735133835,1623211703,3104214392,2738312436,4096837757,3366392578,3110964274,3956598718,3196820781,2038037254,3877786376,2339753847,300912036,3766732888,2372630639,1516443558,4200396704,1574567987,4069441456,4122592016,2699739776,146372218,2748961456,2043888151,35287437,2596680554,655490400,1132482787,110692520,1031794116,2188192751,1324057718,1217253157,919197030,686247489,3261139658,1028237775,3135486431,3059715558,2460921700,986174950,2661811465,4062904701,2752986992,3709736643,367056889,1353824391,731860949,1650113154,1778481506,784341916,357075625,3608602432,1074092588,2480052770,3811426202,92751289,877911070,3600361838,1231880047,480201094,3756190983,3094495953,434011822,87971354,363687820,1717726236,1901380172,3926403882,2481662265,400339184,1490350766,2661455099,1389319756,2558787174,784598401,1983468483,30828846,3550527752,2716276238,3841122214,1765724805,1955612312,1277890269,1333098070,1564029816,2704417615,1026694237,3287671188,1260819201,3349086767,1016692350,1582273796,1073413053,1995943182,694588404,1025494639,3323872702,3551898420,4146854327,453260480,1316140391,1435673405,3038941953,3486689407,1622062951,403978347,817677117,950059133,4246079218,3278066075,1486738320,1417279718,481875527,2549965225,3933690356,760697757,1452955855,3897451437,1177426808,1702951038,4085348628,2447005172,1084371187,3516436277,3068336338,1073369276,1027665953,3284188590,1230553676,1368340146,2226246512,267243139,2274220762,4070734279,2497715176,2423353163,2504755875],a[7]=[3793104909,3151888380,2817252029,895778965,2005530807,3871412763,237245952,86829237,296341424,3851759377,3974600970,2475086196,709006108,1994621201,2972577594,937287164,3734691505,168608556,3189338153,2225080640,3139713551,3033610191,3025041904,77524477,185966941,1208824168,2344345178,1721625922,3354191921,1066374631,1927223579,1971335949,2483503697,1551748602,2881383779,2856329572,3003241482,48746954,1398218158,2050065058,313056748,4255789917,393167848,1912293076,940740642,3465845460,3091687853,2522601570,2197016661,1727764327,364383054,492521376,1291706479,3264136376,1474851438,1685747964,2575719748,1619776915,1814040067,970743798,1561002147,2925768690,2123093554,1880132620,3151188041,697884420,2550985770,2607674513,2659114323,110200136,1489731079,997519150,1378877361,3527870668,478029773,2766872923,1022481122,431258168,1112503832,897933369,2635587303,669726182,3383752315,918222264,163866573,3246985393,3776823163,114105080,1903216136,761148244,3571337562,1690750982,3166750252,1037045171,1888456500,2010454850,642736655,616092351,365016990,1185228132,4174898510,1043824992,2023083429,2241598885,3863320456,3279669087,3674716684,108438443,2132974366,830746235,606445527,4173263986,2204105912,1844756978,2532684181,4245352700,2969441100,3796921661,1335562986,4061524517,2720232303,2679424040,634407289,885462008,3294724487,3933892248,2094100220,339117932,4048830727,3202280980,1458155303,2689246273,1022871705,2464987878,3714515309,353796843,2822958815,4256850100,4052777845,551748367,618185374,3778635579,4020649912,1904685140,3069366075,2670879810,3407193292,2954511620,4058283405,2219449317,3135758300,1120655984,3447565834,1474845562,3577699062,550456716,3466908712,2043752612,881257467,869518812,2005220179,938474677,3305539448,3850417126,1315485940,3318264702,226533026,965733244,321539988,1136104718,804158748,573969341,3708209826,937399083,3290727049,2901666755,1461057207,4013193437,4066861423,3242773476,2421326174,1581322155,3028952165,786071460,3900391652,3918438532,1485433313,4023619836,3708277595,3678951060,953673138,1467089153,1930354364,1533292819,2492563023,1346121658,1685000834,1965281866,3765933717,4190206607,2052792609,3515332758,690371149,3125873887,2180283551,2903598061,3933952357,436236910,289419410,14314871,1242357089,2904507907,1616633776,2666382180,585885352,3471299210,2699507360,1432659641,277164553,3354103607,770115018,2303809295,3741942315,3177781868,2853364978,2269453327,3774259834,987383833,1290892879,225909803,1741533526,890078084,1496906255,1111072499,916028167,243534141,1252605537,2204162171,531204876,290011180,3916834213,102027703,237315147,209093447,1486785922,220223953,2758195998,4175039106,82940208,3127791296,2569425252,518464269,1353887104,3941492737,2377294467,3935040926]}function Fe(e){this.cast5=new qe,this.cast5.setKey(e),this.encrypt=function(e){return this.cast5.encrypt(e)}}ze.keySize=ze.prototype.keySize=24,ze.blockSize=ze.prototype.blockSize=8,Fe.blockSize=Fe.prototype.blockSize=8,Fe.keySize=Fe.prototype.keySize=16;const Oe=4294967295;function Le(e,t){return(e<>>32-t)&Oe}function Ne(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function je(e,t,r){e.splice(t,4,255&r,r>>>8&255,r>>>16&255,r>>>24&255)}function We(e,t){return e>>>8*t&255}function He(e){this.tf=function(){let e=null,t=null,r=-1,i=[],n=[[],[],[],[]];function a(e){return n[0][We(e,0)]^n[1][We(e,1)]^n[2][We(e,2)]^n[3][We(e,3)]}function s(e){return n[0][We(e,3)]^n[1][We(e,0)]^n[2][We(e,1)]^n[3][We(e,2)]}function o(e,t){let r=a(t[0]),n=s(t[1]);t[2]=Le(t[2]^r+n+i[4*e+8]&Oe,31),t[3]=Le(t[3],1)^r+2*n+i[4*e+9]&Oe,r=a(t[2]),n=s(t[3]),t[0]=Le(t[0]^r+n+i[4*e+10]&Oe,31),t[1]=Le(t[1],1)^r+2*n+i[4*e+11]&Oe}function c(e,t){let r=a(t[0]),n=s(t[1]);t[2]=Le(t[2],1)^r+n+i[4*e+10]&Oe,t[3]=Le(t[3]^r+2*n+i[4*e+11]&Oe,31),r=a(t[2]),n=s(t[3]),t[0]=Le(t[0],1)^r+n+i[4*e+8]&Oe,t[1]=Le(t[1]^r+2*n+i[4*e+9]&Oe,31)}return{name:"twofish",blocksize:16,open:function(t){let r,a,s,o,c;e=t;const u=[],h=[],d=[];let f;const l=[];let p,y,b;const m=[[8,1,7,13,6,15,3,2,0,11,5,9,14,12,10,4],[2,8,11,13,15,7,6,14,3,1,9,4,0,10,12,5]],g=[[14,12,11,8,1,2,3,5,15,4,10,6,7,0,9,13],[1,14,2,11,4,12,3,7,6,13,10,5,15,9,0,8]],w=[[11,10,5,14,6,13,9,0,12,8,15,3,2,4,7,1],[4,12,7,5,1,6,9,10,0,14,13,8,2,11,3,15]],v=[[13,7,15,4,1,2,6,14,9,11,3,0,8,5,12,10],[11,9,5,1,12,3,13,14,6,4,7,15,2,0,8,10]],_=[0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15],k=[0,9,2,11,4,13,6,15,8,1,10,3,12,5,14,7],A=[[],[]],S=[[],[],[],[]];function E(e){return e^e>>2^[0,90,180,238][3&e]}function P(e){return e^e>>1^e>>2^[0,238,180,90][3&e]}function x(e,t){let r,i,n;for(r=0;r<8;r++)i=t>>>24,t=t<<8&Oe|e>>>24,e=e<<8&Oe,n=i<<1,128&i&&(n^=333),t^=i^n<<16,n^=i>>>1,1&i&&(n^=166),t^=n<<24|n<<8;return t}function M(e,t){const r=t>>4,i=15&t,n=m[e][r^i],a=g[e][_[i]^k[r]];return v[e][_[a]^k[n]]<<4|w[e][n^a]}function K(e,t){let r=We(e,0),i=We(e,1),n=We(e,2),a=We(e,3);switch(f){case 4:r=A[1][r]^We(t[3],0),i=A[0][i]^We(t[3],1),n=A[0][n]^We(t[3],2),a=A[1][a]^We(t[3],3);case 3:r=A[1][r]^We(t[2],0),i=A[1][i]^We(t[2],1),n=A[0][n]^We(t[2],2),a=A[0][a]^We(t[2],3);case 2:r=A[0][A[0][r]^We(t[1],0)]^We(t[0],0),i=A[0][A[1][i]^We(t[1],1)]^We(t[0],1),n=A[1][A[0][n]^We(t[1],2)]^We(t[0],2),a=A[1][A[1][a]^We(t[1],3)]^We(t[0],3)}return S[0][r]^S[1][i]^S[2][n]^S[3][a]}for(e=e.slice(0,32),r=e.length;16!==r&&24!==r&&32!==r;)e[r++]=0;for(r=0;r>2]=Ne(e,r);for(r=0;r<256;r++)A[0][r]=M(0,r),A[1][r]=M(1,r);for(r=0;r<256;r++)p=A[1][r],y=E(p),b=P(p),S[0][r]=p+(y<<8)+(b<<16)+(b<<24),S[2][r]=y+(b<<8)+(p<<16)+(b<<24),p=A[0][r],y=E(p),b=P(p),S[1][r]=b+(b<<8)+(y<<16)+(p<<24),S[3][r]=y+(p<<8)+(b<<16)+(y<<24);for(f=d.length/2,r=0;r=0;e--)c(e,a);je(t,r,a[2]^i[0]),je(t,r+4,a[3]^i[1]),je(t,r+8,a[0]^i[2]),je(t,r+12,a[1]^i[3]),r+=16},finalize:function(){return t}}}(),this.tf.open(Array.from(e),0),this.encrypt=function(e){return this.tf.encrypt(Array.from(e),0)}}function Ge(){}function Ve(e){this.bf=new Ge,this.bf.init(e),this.encrypt=function(e){return this.bf.encryptBlock(e)}}He.keySize=He.prototype.keySize=32,He.blockSize=He.prototype.blockSize=16,Ge.prototype.BLOCKSIZE=8,Ge.prototype.SBOXES=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]],Ge.prototype.PARRAY=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],Ge.prototype.NN=16,Ge.prototype._clean=function(e){if(e<0){e=(2147483647&e)+2147483648}return e},Ge.prototype._F=function(e){let t;const r=255&e,i=255&(e>>>=8),n=255&(e>>>=8),a=255&(e>>>=8);return t=this.sboxes[0][a]+this.sboxes[1][n],t^=this.sboxes[2][i],t+=this.sboxes[3][r],t},Ge.prototype._encryptBlock=function(e){let t,r=e[0],i=e[1];for(t=0;t>>24-8*t&255,n[t+i]=r[1]>>>24-8*t&255;return n},Ge.prototype._decryptBlock=function(e){let t,r=e[0],i=e[1];for(t=this.NN+1;t>1;--t){r^=this.parray[t],i=this._F(r)^i;const e=r;r=i,i=e}r^=this.parray[1],i^=this.parray[0],e[0]=this._clean(i),e[1]=this._clean(r)},Ge.prototype.init=function(e){let t,r=0;for(this.parray=[],t=0;t=e.length&&(r=0);this.parray[t]=this.PARRAY[t]^i}for(this.sboxes=[],t=0;t<4;++t)for(this.sboxes[t]=[],r=0;r<256;++r)this.sboxes[t][r]=this.SBOXES[t][r];const i=[0,0];for(t=0;t>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=t+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=r+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=c+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=u+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=h+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=d+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=f+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=l+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=p+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=y+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=b+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=m+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=g+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=w+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;x=v+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=g^l^r^e;M=P<<1|P>>>31;x=M+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=w^p^c^t;K=P<<1|P>>>31;x=K+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=v^y^u^r;C=P<<1|P>>>31;x=C+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=M^b^h^c;D=P<<1|P>>>31;x=D+(_<<5|_>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=K^m^d^u;U=P<<1|P>>>31;x=U+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=C^g^f^h;R=P<<1|P>>>31;x=R+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=D^w^l^d;I=P<<1|P>>>31;x=I+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=U^v^p^f;B=P<<1|P>>>31;x=B+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=R^M^y^l;T=P<<1|P>>>31;x=T+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=I^K^b^p;z=P<<1|P>>>31;x=z+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=B^C^m^y;q=P<<1|P>>>31;x=q+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=T^D^g^b;F=P<<1|P>>>31;x=F+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=z^U^w^m;O=P<<1|P>>>31;x=O+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=q^R^v^g;L=P<<1|P>>>31;x=L+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=F^I^M^w;N=P<<1|P>>>31;x=N+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=O^B^K^v;j=P<<1|P>>>31;x=j+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=L^T^C^M;W=P<<1|P>>>31;x=W+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=N^z^D^K;H=P<<1|P>>>31;x=H+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=j^q^U^C;G=P<<1|P>>>31;x=G+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=W^F^R^D;V=P<<1|P>>>31;x=V+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=H^O^I^U;$=P<<1|P>>>31;x=$+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=G^L^B^R;Z=P<<1|P>>>31;x=Z+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=V^N^T^I;X=P<<1|P>>>31;x=X+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=$^j^z^B;Y=P<<1|P>>>31;x=Y+(_<<5|_>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Z^W^q^T;Q=P<<1|P>>>31;x=Q+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=X^H^F^z;J=P<<1|P>>>31;x=J+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Y^G^O^q;ee=P<<1|P>>>31;x=ee+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Q^V^L^F;te=P<<1|P>>>31;x=te+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=J^$^N^O;re=P<<1|P>>>31;x=re+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ee^Z^j^L;ie=P<<1|P>>>31;x=ie+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=te^X^W^N;ne=P<<1|P>>>31;x=ne+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=re^Y^H^j;ae=P<<1|P>>>31;x=ae+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ie^Q^G^W;se=P<<1|P>>>31;x=se+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ne^J^V^H;oe=P<<1|P>>>31;x=oe+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ae^ee^$^G;ce=P<<1|P>>>31;x=ce+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=se^te^Z^V;ue=P<<1|P>>>31;x=ue+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=oe^re^X^$;he=P<<1|P>>>31;x=he+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ce^ie^Y^Z;de=P<<1|P>>>31;x=de+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ue^ne^Q^X;fe=P<<1|P>>>31;x=fe+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=he^ae^J^Y;le=P<<1|P>>>31;x=le+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=de^se^ee^Q;pe=P<<1|P>>>31;x=pe+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=fe^oe^te^J;ye=P<<1|P>>>31;x=ye+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=le^ce^re^ee;be=P<<1|P>>>31;x=be+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=pe^ue^ie^te;me=P<<1|P>>>31;x=me+(_<<5|_>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ye^he^ne^re;ge=P<<1|P>>>31;x=ge+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=be^de^ae^ie;we=P<<1|P>>>31;x=we+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=me^fe^se^ne;ve=P<<1|P>>>31;x=ve+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ge^le^oe^ae;_e=P<<1|P>>>31;x=_e+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=we^pe^ce^se;ke=P<<1|P>>>31;x=ke+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ve^ye^ue^oe;Ae=P<<1|P>>>31;x=Ae+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=_e^be^he^ce;Se=P<<1|P>>>31;x=Se+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=ke^me^de^ue;Ee=P<<1|P>>>31;x=Ee+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Ae^ge^fe^he;Pe=P<<1|P>>>31;x=Pe+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Se^we^le^de;xe=P<<1|P>>>31;x=xe+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Ee^ve^pe^fe;Me=P<<1|P>>>31;x=Me+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Pe^_e^ye^le;Ke=P<<1|P>>>31;x=Ke+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=xe^ke^be^pe;Ce=P<<1|P>>>31;x=Ce+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Me^Ae^me^ye;De=P<<1|P>>>31;x=De+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Ke^Se^ge^be;Ue=P<<1|P>>>31;x=Ue+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Ce^Ee^we^me;Re=P<<1|P>>>31;x=Re+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=De^Pe^ve^ge;Ie=P<<1|P>>>31;x=Ie+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Ue^xe^_e^we;Be=P<<1|P>>>31;x=Be+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Re^Me^ke^ve;Te=P<<1|P>>>31;x=Te+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;P=Ie^Ke^Ae^_e;ze=P<<1|P>>>31;x=ze+(_<<5|_>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=_;_=x;i=i+_|0;n=n+k|0;a=a+A|0;s=s+S|0;o=o+E|0}function k(e){e=e|0;_(v[e|0]<<24|v[e|1]<<16|v[e|2]<<8|v[e|3],v[e|4]<<24|v[e|5]<<16|v[e|6]<<8|v[e|7],v[e|8]<<24|v[e|9]<<16|v[e|10]<<8|v[e|11],v[e|12]<<24|v[e|13]<<16|v[e|14]<<8|v[e|15],v[e|16]<<24|v[e|17]<<16|v[e|18]<<8|v[e|19],v[e|20]<<24|v[e|21]<<16|v[e|22]<<8|v[e|23],v[e|24]<<24|v[e|25]<<16|v[e|26]<<8|v[e|27],v[e|28]<<24|v[e|29]<<16|v[e|30]<<8|v[e|31],v[e|32]<<24|v[e|33]<<16|v[e|34]<<8|v[e|35],v[e|36]<<24|v[e|37]<<16|v[e|38]<<8|v[e|39],v[e|40]<<24|v[e|41]<<16|v[e|42]<<8|v[e|43],v[e|44]<<24|v[e|45]<<16|v[e|46]<<8|v[e|47],v[e|48]<<24|v[e|49]<<16|v[e|50]<<8|v[e|51],v[e|52]<<24|v[e|53]<<16|v[e|54]<<8|v[e|55],v[e|56]<<24|v[e|57]<<16|v[e|58]<<8|v[e|59],v[e|60]<<24|v[e|61]<<16|v[e|62]<<8|v[e|63])}function A(e){e=e|0;v[e|0]=i>>>24;v[e|1]=i>>>16&255;v[e|2]=i>>>8&255;v[e|3]=i&255;v[e|4]=n>>>24;v[e|5]=n>>>16&255;v[e|6]=n>>>8&255;v[e|7]=n&255;v[e|8]=a>>>24;v[e|9]=a>>>16&255;v[e|10]=a>>>8&255;v[e|11]=a&255;v[e|12]=s>>>24;v[e|13]=s>>>16&255;v[e|14]=s>>>8&255;v[e|15]=s&255;v[e|16]=o>>>24;v[e|17]=o>>>16&255;v[e|18]=o>>>8&255;v[e|19]=o&255}function S(){i=0x67452301;n=0xefcdab89;a=0x98badcfe;s=0x10325476;o=0xc3d2e1f0;c=u=0}function E(e,t,r,h,d,f,l){e=e|0;t=t|0;r=r|0;h=h|0;d=d|0;f=f|0;l=l|0;i=e;n=t;a=r;s=h;o=d;c=f;u=l}function P(e,t){e=e|0;t=t|0;var r=0;if(e&63)return-1;while((t|0)>=64){k(e);e=e+64|0;t=t-64|0;r=r+64|0}c=c+r|0;if(c>>>0>>0)u=u+1|0;return r|0}function x(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;if(e&63)return-1;if(~r)if(r&31)return-1;if((t|0)>=64){i=P(e,t)|0;if((i|0)==-1)return-1;e=e+i|0;t=t-i|0}i=i+t|0;c=c+t|0;if(c>>>0>>0)u=u+1|0;v[e|t]=0x80;if((t|0)>=56){for(n=t+1|0;(n|0)<64;n=n+1|0)v[e|n]=0x00;k(e);t=0;v[e|0]=0}for(n=t+1|0;(n|0)<59;n=n+1|0)v[e|n]=0;v[e|56]=u>>>21&255;v[e|57]=u>>>13&255;v[e|58]=u>>>5&255;v[e|59]=u<<3&255|c>>>29;v[e|60]=c>>>21&255;v[e|61]=c>>>13&255;v[e|62]=c>>>5&255;v[e|63]=c<<3&255;k(e);if(~r)A(r);return i|0}function M(){i=h;n=d;a=f;s=l;o=p;c=64;u=0}function K(){i=y;n=b;a=m;s=g;o=w;c=64;u=0}function C(e,t,r,v,k,A,E,P,x,M,K,C,D,U,R,I){e=e|0;t=t|0;r=r|0;v=v|0;k=k|0;A=A|0;E=E|0;P=P|0;x=x|0;M=M|0;K=K|0;C=C|0;D=D|0;U=U|0;R=R|0;I=I|0;S();_(e^0x5c5c5c5c,t^0x5c5c5c5c,r^0x5c5c5c5c,v^0x5c5c5c5c,k^0x5c5c5c5c,A^0x5c5c5c5c,E^0x5c5c5c5c,P^0x5c5c5c5c,x^0x5c5c5c5c,M^0x5c5c5c5c,K^0x5c5c5c5c,C^0x5c5c5c5c,D^0x5c5c5c5c,U^0x5c5c5c5c,R^0x5c5c5c5c,I^0x5c5c5c5c);y=i;b=n;m=a;g=s;w=o;S();_(e^0x36363636,t^0x36363636,r^0x36363636,v^0x36363636,k^0x36363636,A^0x36363636,E^0x36363636,P^0x36363636,x^0x36363636,M^0x36363636,K^0x36363636,C^0x36363636,D^0x36363636,U^0x36363636,R^0x36363636,I^0x36363636);h=i;d=n;f=a;l=s;p=o;c=64;u=0}function D(e,t,r){e=e|0;t=t|0;r=r|0;var c=0,u=0,h=0,d=0,f=0,l=0;if(e&63)return-1;if(~r)if(r&31)return-1;l=x(e,t,-1)|0;c=i,u=n,h=a,d=s,f=o;K();_(c,u,h,d,f,0x80000000,0,0,0,0,0,0,0,0,0,672);if(~r)A(r);return l|0}function U(e,t,r,c,u){e=e|0;t=t|0;r=r|0;c=c|0;u=u|0;var h=0,d=0,f=0,l=0,p=0,y=0,b=0,m=0,g=0,w=0;if(e&63)return-1;if(~u)if(u&31)return-1;v[e+t|0]=r>>>24;v[e+t+1|0]=r>>>16&255;v[e+t+2|0]=r>>>8&255;v[e+t+3|0]=r&255;D(e,t+4|0,-1)|0;h=y=i,d=b=n,f=m=a,l=g=s,p=w=o;c=c-1|0;while((c|0)>0){M();_(y,b,m,g,w,0x80000000,0,0,0,0,0,0,0,0,0,672);y=i,b=n,m=a,g=s,w=o;K();_(y,b,m,g,w,0x80000000,0,0,0,0,0,0,0,0,0,672);y=i,b=n,m=a,g=s,w=o;h=h^i;d=d^n;f=f^a;l=l^s;p=p^o;c=c-1|0}i=h;n=d;a=f;s=l;o=p;if(~u)A(u);return 0}return{reset:S,init:E,process:P,finish:x,hmac_reset:M,hmac_init:C,hmac_finish:D,pbkdf2_generate_block:U}};class et{constructor(){this.pos=0,this.len=0}reset(){const{asm:e}=this.acquire_asm();return this.result=null,this.pos=0,this.len=0,e.reset(),this}process(e){if(null!==this.result)throw new xe("state must be reset before processing new data");const{asm:t,heap:r}=this.acquire_asm();let i=this.pos,n=this.len,a=0,s=e.length,o=0;for(;s>0;)o=Ee(r,i+n,e,a,s),n+=o,a+=o,s-=o,o=t.process(i,n),i+=o,n-=o,n||(i=0);return this.pos=i,this.len=n,this}finish(){if(null!==this.result)throw new xe("state must be reset before processing new data");const{asm:e,heap:t}=this.acquire_asm();return e.finish(this.pos,this.len,0),this.result=new Uint8Array(this.HASH_SIZE),this.result.set(t.subarray(0,this.HASH_SIZE)),this.pos=0,this.len=0,this.release_asm(),this}}const tt=[],rt=[];class it extends et{constructor(){super(),this.NAME="sha1",this.BLOCK_SIZE=64,this.HASH_SIZE=20,this.acquire_asm()}acquire_asm(){return void 0!==this.heap&&void 0!==this.asm||(this.heap=tt.pop()||Se(),this.asm=rt.pop()||Je({Uint8Array},null,this.heap.buffer),this.reset()),{heap:this.heap,asm:this.asm}}release_asm(){void 0!==this.heap&&void 0!==this.asm&&(tt.push(this.heap),rt.push(this.asm)),this.heap=void 0,this.asm=void 0}static bytes(e){return(new it).process(e).finish().result}}it.NAME="sha1",it.heap_pool=[],it.asm_pool=[],it.asm_function=Je;const nt=[],at=[];class st extends et{constructor(){super(),this.NAME="sha256",this.BLOCK_SIZE=64,this.HASH_SIZE=32,this.acquire_asm()}acquire_asm(){return void 0!==this.heap&&void 0!==this.asm||(this.heap=nt.pop()||Se(),this.asm=at.pop()||function(e,t,r){"use asm";var i=0,n=0,a=0,s=0,o=0,c=0,u=0,h=0,d=0,f=0,l=0,p=0,y=0,b=0,m=0,g=0,w=0,v=0,_=0,k=0,A=0,S=0,E=0,P=0,x=0,M=0,K=new e.Uint8Array(r);function C(e,t,r,d,f,l,p,y,b,m,g,w,v,_,k,A){e=e|0;t=t|0;r=r|0;d=d|0;f=f|0;l=l|0;p=p|0;y=y|0;b=b|0;m=m|0;g=g|0;w=w|0;v=v|0;_=_|0;k=k|0;A=A|0;var S=0,E=0,P=0,x=0,M=0,K=0,C=0,D=0;S=i;E=n;P=a;x=s;M=o;K=c;C=u;D=h;D=e+D+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(C^M&(K^C))+0x428a2f98|0;x=x+D|0;D=D+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;C=t+C+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(K^x&(M^K))+0x71374491|0;P=P+C|0;C=C+(D&S^E&(D^S))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;K=r+K+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(M^P&(x^M))+0xb5c0fbcf|0;E=E+K|0;K=K+(C&D^S&(C^D))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;M=d+M+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0xe9b5dba5|0;S=S+M|0;M=M+(K&C^D&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;x=f+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x3956c25b|0;D=D+x|0;x=x+(M&K^C&(M^K))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;P=l+P+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(E^D&(S^E))+0x59f111f1|0;C=C+P|0;P=P+(x&M^K&(x^M))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;E=p+E+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(S^C&(D^S))+0x923f82a4|0;K=K+E|0;E=E+(P&x^M&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;S=y+S+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(D^K&(C^D))+0xab1c5ed5|0;M=M+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;D=b+D+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(C^M&(K^C))+0xd807aa98|0;x=x+D|0;D=D+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;C=m+C+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(K^x&(M^K))+0x12835b01|0;P=P+C|0;C=C+(D&S^E&(D^S))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;K=g+K+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(M^P&(x^M))+0x243185be|0;E=E+K|0;K=K+(C&D^S&(C^D))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;M=w+M+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x550c7dc3|0;S=S+M|0;M=M+(K&C^D&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;x=v+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x72be5d74|0;D=D+x|0;x=x+(M&K^C&(M^K))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;P=_+P+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(E^D&(S^E))+0x80deb1fe|0;C=C+P|0;P=P+(x&M^K&(x^M))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;E=k+E+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(S^C&(D^S))+0x9bdc06a7|0;K=K+E|0;E=E+(P&x^M&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;S=A+S+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(D^K&(C^D))+0xc19bf174|0;M=M+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;e=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(k>>>17^k>>>19^k>>>10^k<<15^k<<13)+e+m|0;D=e+D+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(C^M&(K^C))+0xe49b69c1|0;x=x+D|0;D=D+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;t=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+t+g|0;C=t+C+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(K^x&(M^K))+0xefbe4786|0;P=P+C|0;C=C+(D&S^E&(D^S))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;r=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+r+w|0;K=r+K+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(M^P&(x^M))+0x0fc19dc6|0;E=E+K|0;K=K+(C&D^S&(C^D))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;d=(f>>>7^f>>>18^f>>>3^f<<25^f<<14)+(t>>>17^t>>>19^t>>>10^t<<15^t<<13)+d+v|0;M=d+M+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x240ca1cc|0;S=S+M|0;M=M+(K&C^D&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;f=(l>>>7^l>>>18^l>>>3^l<<25^l<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+f+_|0;x=f+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x2de92c6f|0;D=D+x|0;x=x+(M&K^C&(M^K))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;l=(p>>>7^p>>>18^p>>>3^p<<25^p<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+l+k|0;P=l+P+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(E^D&(S^E))+0x4a7484aa|0;C=C+P|0;P=P+(x&M^K&(x^M))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;p=(y>>>7^y>>>18^y>>>3^y<<25^y<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+p+A|0;E=p+E+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(S^C&(D^S))+0x5cb0a9dc|0;K=K+E|0;E=E+(P&x^M&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;y=(b>>>7^b>>>18^b>>>3^b<<25^b<<14)+(l>>>17^l>>>19^l>>>10^l<<15^l<<13)+y+e|0;S=y+S+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(D^K&(C^D))+0x76f988da|0;M=M+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;b=(m>>>7^m>>>18^m>>>3^m<<25^m<<14)+(p>>>17^p>>>19^p>>>10^p<<15^p<<13)+b+t|0;D=b+D+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(C^M&(K^C))+0x983e5152|0;x=x+D|0;D=D+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;m=(g>>>7^g>>>18^g>>>3^g<<25^g<<14)+(y>>>17^y>>>19^y>>>10^y<<15^y<<13)+m+r|0;C=m+C+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(K^x&(M^K))+0xa831c66d|0;P=P+C|0;C=C+(D&S^E&(D^S))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;g=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(b>>>17^b>>>19^b>>>10^b<<15^b<<13)+g+d|0;K=g+K+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(M^P&(x^M))+0xb00327c8|0;E=E+K|0;K=K+(C&D^S&(C^D))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;w=(v>>>7^v>>>18^v>>>3^v<<25^v<<14)+(m>>>17^m>>>19^m>>>10^m<<15^m<<13)+w+f|0;M=w+M+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0xbf597fc7|0;S=S+M|0;M=M+(K&C^D&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;v=(_>>>7^_>>>18^_>>>3^_<<25^_<<14)+(g>>>17^g>>>19^g>>>10^g<<15^g<<13)+v+l|0;x=v+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0xc6e00bf3|0;D=D+x|0;x=x+(M&K^C&(M^K))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;_=(k>>>7^k>>>18^k>>>3^k<<25^k<<14)+(w>>>17^w>>>19^w>>>10^w<<15^w<<13)+_+p|0;P=_+P+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(E^D&(S^E))+0xd5a79147|0;C=C+P|0;P=P+(x&M^K&(x^M))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;k=(A>>>7^A>>>18^A>>>3^A<<25^A<<14)+(v>>>17^v>>>19^v>>>10^v<<15^v<<13)+k+y|0;E=k+E+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(S^C&(D^S))+0x06ca6351|0;K=K+E|0;E=E+(P&x^M&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;A=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(_>>>17^_>>>19^_>>>10^_<<15^_<<13)+A+b|0;S=A+S+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(D^K&(C^D))+0x14292967|0;M=M+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;e=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(k>>>17^k>>>19^k>>>10^k<<15^k<<13)+e+m|0;D=e+D+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(C^M&(K^C))+0x27b70a85|0;x=x+D|0;D=D+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;t=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+t+g|0;C=t+C+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(K^x&(M^K))+0x2e1b2138|0;P=P+C|0;C=C+(D&S^E&(D^S))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;r=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+r+w|0;K=r+K+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(M^P&(x^M))+0x4d2c6dfc|0;E=E+K|0;K=K+(C&D^S&(C^D))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;d=(f>>>7^f>>>18^f>>>3^f<<25^f<<14)+(t>>>17^t>>>19^t>>>10^t<<15^t<<13)+d+v|0;M=d+M+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x53380d13|0;S=S+M|0;M=M+(K&C^D&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;f=(l>>>7^l>>>18^l>>>3^l<<25^l<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+f+_|0;x=f+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x650a7354|0;D=D+x|0;x=x+(M&K^C&(M^K))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;l=(p>>>7^p>>>18^p>>>3^p<<25^p<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+l+k|0;P=l+P+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(E^D&(S^E))+0x766a0abb|0;C=C+P|0;P=P+(x&M^K&(x^M))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;p=(y>>>7^y>>>18^y>>>3^y<<25^y<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+p+A|0;E=p+E+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(S^C&(D^S))+0x81c2c92e|0;K=K+E|0;E=E+(P&x^M&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;y=(b>>>7^b>>>18^b>>>3^b<<25^b<<14)+(l>>>17^l>>>19^l>>>10^l<<15^l<<13)+y+e|0;S=y+S+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(D^K&(C^D))+0x92722c85|0;M=M+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;b=(m>>>7^m>>>18^m>>>3^m<<25^m<<14)+(p>>>17^p>>>19^p>>>10^p<<15^p<<13)+b+t|0;D=b+D+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(C^M&(K^C))+0xa2bfe8a1|0;x=x+D|0;D=D+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;m=(g>>>7^g>>>18^g>>>3^g<<25^g<<14)+(y>>>17^y>>>19^y>>>10^y<<15^y<<13)+m+r|0;C=m+C+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(K^x&(M^K))+0xa81a664b|0;P=P+C|0;C=C+(D&S^E&(D^S))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;g=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(b>>>17^b>>>19^b>>>10^b<<15^b<<13)+g+d|0;K=g+K+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(M^P&(x^M))+0xc24b8b70|0;E=E+K|0;K=K+(C&D^S&(C^D))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;w=(v>>>7^v>>>18^v>>>3^v<<25^v<<14)+(m>>>17^m>>>19^m>>>10^m<<15^m<<13)+w+f|0;M=w+M+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0xc76c51a3|0;S=S+M|0;M=M+(K&C^D&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;v=(_>>>7^_>>>18^_>>>3^_<<25^_<<14)+(g>>>17^g>>>19^g>>>10^g<<15^g<<13)+v+l|0;x=v+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0xd192e819|0;D=D+x|0;x=x+(M&K^C&(M^K))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;_=(k>>>7^k>>>18^k>>>3^k<<25^k<<14)+(w>>>17^w>>>19^w>>>10^w<<15^w<<13)+_+p|0;P=_+P+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(E^D&(S^E))+0xd6990624|0;C=C+P|0;P=P+(x&M^K&(x^M))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;k=(A>>>7^A>>>18^A>>>3^A<<25^A<<14)+(v>>>17^v>>>19^v>>>10^v<<15^v<<13)+k+y|0;E=k+E+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(S^C&(D^S))+0xf40e3585|0;K=K+E|0;E=E+(P&x^M&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;A=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(_>>>17^_>>>19^_>>>10^_<<15^_<<13)+A+b|0;S=A+S+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(D^K&(C^D))+0x106aa070|0;M=M+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;e=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(k>>>17^k>>>19^k>>>10^k<<15^k<<13)+e+m|0;D=e+D+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(C^M&(K^C))+0x19a4c116|0;x=x+D|0;D=D+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;t=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+t+g|0;C=t+C+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(K^x&(M^K))+0x1e376c08|0;P=P+C|0;C=C+(D&S^E&(D^S))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;r=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+r+w|0;K=r+K+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(M^P&(x^M))+0x2748774c|0;E=E+K|0;K=K+(C&D^S&(C^D))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;d=(f>>>7^f>>>18^f>>>3^f<<25^f<<14)+(t>>>17^t>>>19^t>>>10^t<<15^t<<13)+d+v|0;M=d+M+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x34b0bcb5|0;S=S+M|0;M=M+(K&C^D&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;f=(l>>>7^l>>>18^l>>>3^l<<25^l<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+f+_|0;x=f+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x391c0cb3|0;D=D+x|0;x=x+(M&K^C&(M^K))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;l=(p>>>7^p>>>18^p>>>3^p<<25^p<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+l+k|0;P=l+P+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(E^D&(S^E))+0x4ed8aa4a|0;C=C+P|0;P=P+(x&M^K&(x^M))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;p=(y>>>7^y>>>18^y>>>3^y<<25^y<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+p+A|0;E=p+E+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(S^C&(D^S))+0x5b9cca4f|0;K=K+E|0;E=E+(P&x^M&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;y=(b>>>7^b>>>18^b>>>3^b<<25^b<<14)+(l>>>17^l>>>19^l>>>10^l<<15^l<<13)+y+e|0;S=y+S+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(D^K&(C^D))+0x682e6ff3|0;M=M+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;b=(m>>>7^m>>>18^m>>>3^m<<25^m<<14)+(p>>>17^p>>>19^p>>>10^p<<15^p<<13)+b+t|0;D=b+D+(M>>>6^M>>>11^M>>>25^M<<26^M<<21^M<<7)+(C^M&(K^C))+0x748f82ee|0;x=x+D|0;D=D+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;m=(g>>>7^g>>>18^g>>>3^g<<25^g<<14)+(y>>>17^y>>>19^y>>>10^y<<15^y<<13)+m+r|0;C=m+C+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(K^x&(M^K))+0x78a5636f|0;P=P+C|0;C=C+(D&S^E&(D^S))+(D>>>2^D>>>13^D>>>22^D<<30^D<<19^D<<10)|0;g=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(b>>>17^b>>>19^b>>>10^b<<15^b<<13)+g+d|0;K=g+K+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(M^P&(x^M))+0x84c87814|0;E=E+K|0;K=K+(C&D^S&(C^D))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;w=(v>>>7^v>>>18^v>>>3^v<<25^v<<14)+(m>>>17^m>>>19^m>>>10^m<<15^m<<13)+w+f|0;M=w+M+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x8cc70208|0;S=S+M|0;M=M+(K&C^D&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;v=(_>>>7^_>>>18^_>>>3^_<<25^_<<14)+(g>>>17^g>>>19^g>>>10^g<<15^g<<13)+v+l|0;x=v+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x90befffa|0;D=D+x|0;x=x+(M&K^C&(M^K))+(M>>>2^M>>>13^M>>>22^M<<30^M<<19^M<<10)|0;_=(k>>>7^k>>>18^k>>>3^k<<25^k<<14)+(w>>>17^w>>>19^w>>>10^w<<15^w<<13)+_+p|0;P=_+P+(D>>>6^D>>>11^D>>>25^D<<26^D<<21^D<<7)+(E^D&(S^E))+0xa4506ceb|0;C=C+P|0;P=P+(x&M^K&(x^M))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;k=(A>>>7^A>>>18^A>>>3^A<<25^A<<14)+(v>>>17^v>>>19^v>>>10^v<<15^v<<13)+k+y|0;E=k+E+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(S^C&(D^S))+0xbef9a3f7|0;K=K+E|0;E=E+(P&x^M&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;A=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(_>>>17^_>>>19^_>>>10^_<<15^_<<13)+A+b|0;S=A+S+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(D^K&(C^D))+0xc67178f2|0;M=M+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;i=i+S|0;n=n+E|0;a=a+P|0;s=s+x|0;o=o+M|0;c=c+K|0;u=u+C|0;h=h+D|0}function D(e){e=e|0;C(K[e|0]<<24|K[e|1]<<16|K[e|2]<<8|K[e|3],K[e|4]<<24|K[e|5]<<16|K[e|6]<<8|K[e|7],K[e|8]<<24|K[e|9]<<16|K[e|10]<<8|K[e|11],K[e|12]<<24|K[e|13]<<16|K[e|14]<<8|K[e|15],K[e|16]<<24|K[e|17]<<16|K[e|18]<<8|K[e|19],K[e|20]<<24|K[e|21]<<16|K[e|22]<<8|K[e|23],K[e|24]<<24|K[e|25]<<16|K[e|26]<<8|K[e|27],K[e|28]<<24|K[e|29]<<16|K[e|30]<<8|K[e|31],K[e|32]<<24|K[e|33]<<16|K[e|34]<<8|K[e|35],K[e|36]<<24|K[e|37]<<16|K[e|38]<<8|K[e|39],K[e|40]<<24|K[e|41]<<16|K[e|42]<<8|K[e|43],K[e|44]<<24|K[e|45]<<16|K[e|46]<<8|K[e|47],K[e|48]<<24|K[e|49]<<16|K[e|50]<<8|K[e|51],K[e|52]<<24|K[e|53]<<16|K[e|54]<<8|K[e|55],K[e|56]<<24|K[e|57]<<16|K[e|58]<<8|K[e|59],K[e|60]<<24|K[e|61]<<16|K[e|62]<<8|K[e|63])}function U(e){e=e|0;K[e|0]=i>>>24;K[e|1]=i>>>16&255;K[e|2]=i>>>8&255;K[e|3]=i&255;K[e|4]=n>>>24;K[e|5]=n>>>16&255;K[e|6]=n>>>8&255;K[e|7]=n&255;K[e|8]=a>>>24;K[e|9]=a>>>16&255;K[e|10]=a>>>8&255;K[e|11]=a&255;K[e|12]=s>>>24;K[e|13]=s>>>16&255;K[e|14]=s>>>8&255;K[e|15]=s&255;K[e|16]=o>>>24;K[e|17]=o>>>16&255;K[e|18]=o>>>8&255;K[e|19]=o&255;K[e|20]=c>>>24;K[e|21]=c>>>16&255;K[e|22]=c>>>8&255;K[e|23]=c&255;K[e|24]=u>>>24;K[e|25]=u>>>16&255;K[e|26]=u>>>8&255;K[e|27]=u&255;K[e|28]=h>>>24;K[e|29]=h>>>16&255;K[e|30]=h>>>8&255;K[e|31]=h&255}function R(){i=0x6a09e667;n=0xbb67ae85;a=0x3c6ef372;s=0xa54ff53a;o=0x510e527f;c=0x9b05688c;u=0x1f83d9ab;h=0x5be0cd19;d=f=0}function I(e,t,r,l,p,y,b,m,g,w){e=e|0;t=t|0;r=r|0;l=l|0;p=p|0;y=y|0;b=b|0;m=m|0;g=g|0;w=w|0;i=e;n=t;a=r;s=l;o=p;c=y;u=b;h=m;d=g;f=w}function B(e,t){e=e|0;t=t|0;var r=0;if(e&63)return-1;while((t|0)>=64){D(e);e=e+64|0;t=t-64|0;r=r+64|0}d=d+r|0;if(d>>>0>>0)f=f+1|0;return r|0}function T(e,t,r){e=e|0;t=t|0;r=r|0;var i=0,n=0;if(e&63)return-1;if(~r)if(r&31)return-1;if((t|0)>=64){i=B(e,t)|0;if((i|0)==-1)return-1;e=e+i|0;t=t-i|0}i=i+t|0;d=d+t|0;if(d>>>0>>0)f=f+1|0;K[e|t]=0x80;if((t|0)>=56){for(n=t+1|0;(n|0)<64;n=n+1|0)K[e|n]=0x00;D(e);t=0;K[e|0]=0}for(n=t+1|0;(n|0)<59;n=n+1|0)K[e|n]=0;K[e|56]=f>>>21&255;K[e|57]=f>>>13&255;K[e|58]=f>>>5&255;K[e|59]=f<<3&255|d>>>29;K[e|60]=d>>>21&255;K[e|61]=d>>>13&255;K[e|62]=d>>>5&255;K[e|63]=d<<3&255;D(e);if(~r)U(r);return i|0}function z(){i=l;n=p;a=y;s=b;o=m;c=g;u=w;h=v;d=64;f=0}function q(){i=_;n=k;a=A;s=S;o=E;c=P;u=x;h=M;d=64;f=0}function F(e,t,r,K,D,U,I,B,T,z,q,F,O,L,N,j){e=e|0;t=t|0;r=r|0;K=K|0;D=D|0;U=U|0;I=I|0;B=B|0;T=T|0;z=z|0;q=q|0;F=F|0;O=O|0;L=L|0;N=N|0;j=j|0;R();C(e^0x5c5c5c5c,t^0x5c5c5c5c,r^0x5c5c5c5c,K^0x5c5c5c5c,D^0x5c5c5c5c,U^0x5c5c5c5c,I^0x5c5c5c5c,B^0x5c5c5c5c,T^0x5c5c5c5c,z^0x5c5c5c5c,q^0x5c5c5c5c,F^0x5c5c5c5c,O^0x5c5c5c5c,L^0x5c5c5c5c,N^0x5c5c5c5c,j^0x5c5c5c5c);_=i;k=n;A=a;S=s;E=o;P=c;x=u;M=h;R();C(e^0x36363636,t^0x36363636,r^0x36363636,K^0x36363636,D^0x36363636,U^0x36363636,I^0x36363636,B^0x36363636,T^0x36363636,z^0x36363636,q^0x36363636,F^0x36363636,O^0x36363636,L^0x36363636,N^0x36363636,j^0x36363636);l=i;p=n;y=a;b=s;m=o;g=c;w=u;v=h;d=64;f=0}function O(e,t,r){e=e|0;t=t|0;r=r|0;var d=0,f=0,l=0,p=0,y=0,b=0,m=0,g=0,w=0;if(e&63)return-1;if(~r)if(r&31)return-1;w=T(e,t,-1)|0;d=i,f=n,l=a,p=s,y=o,b=c,m=u,g=h;q();C(d,f,l,p,y,b,m,g,0x80000000,0,0,0,0,0,0,768);if(~r)U(r);return w|0}function L(e,t,r,d,f){e=e|0;t=t|0;r=r|0;d=d|0;f=f|0;var l=0,p=0,y=0,b=0,m=0,g=0,w=0,v=0,_=0,k=0,A=0,S=0,E=0,P=0,x=0,M=0;if(e&63)return-1;if(~f)if(f&31)return-1;K[e+t|0]=r>>>24;K[e+t+1|0]=r>>>16&255;K[e+t+2|0]=r>>>8&255;K[e+t+3|0]=r&255;O(e,t+4|0,-1)|0;l=_=i,p=k=n,y=A=a,b=S=s,m=E=o,g=P=c,w=x=u,v=M=h;d=d-1|0;while((d|0)>0){z();C(_,k,A,S,E,P,x,M,0x80000000,0,0,0,0,0,0,768);_=i,k=n,A=a,S=s,E=o,P=c,x=u,M=h;q();C(_,k,A,S,E,P,x,M,0x80000000,0,0,0,0,0,0,768);_=i,k=n,A=a,S=s,E=o,P=c,x=u,M=h;l=l^i;p=p^n;y=y^a;b=b^s;m=m^o;g=g^c;w=w^u;v=v^h;d=d-1|0}i=l;n=p;a=y;s=b;o=m;c=g;u=w;h=v;if(~f)U(f);return 0}return{reset:R,init:I,process:B,finish:T,hmac_reset:z,hmac_init:F,hmac_finish:O,pbkdf2_generate_block:L}}({Uint8Array},null,this.heap.buffer),this.reset()),{heap:this.heap,asm:this.asm}}release_asm(){void 0!==this.heap&&void 0!==this.asm&&(nt.push(this.heap),at.push(this.asm)),this.heap=void 0,this.asm=void 0}static bytes(e){return(new st).process(e).finish().result}}st.NAME="sha256";var ot=ct;function ct(e,t){if(!e)throw Error(t||"Assertion failed")}ct.equal=function(e,t,r){if(e!=t)throw Error(r||"Assertion failed: "+e+" != "+t)};var ut=void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ht(e,t){return e(t={exports:{}},t.exports),t.exports}function dt(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var ft=ht((function(e){e.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}})),lt=ht((function(e){try{var t=s;if("function"!=typeof t.inherits)throw"";e.exports=t.inherits}catch(t){e.exports=ft}}));var pt=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>8,s=255&n;a?r.push(a,s):r.push(s)}else for(i=0;i>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}var mt=function(e,t){for(var r="",i=0;i>>0}return a};var _t=function(e,t){for(var r=Array(4*e.length),i=0,n=0;i>>24,r[n+1]=a>>>16&255,r[n+2]=a>>>8&255,r[n+3]=255&a):(r[n+3]=a>>>24,r[n+2]=a>>>16&255,r[n+1]=a>>>8&255,r[n]=255&a)}return r};var kt={inherits:lt,toArray:pt,toHex:yt,htonl:bt,toHex32:mt,zero2:gt,zero8:wt,join32:vt,split32:_t,rotr32:function(e,t){return e>>>t|e<<32-t},rotl32:function(e,t){return e<>>32-t},sum32:function(e,t){return e+t>>>0},sum32_3:function(e,t,r){return e+t+r>>>0},sum32_4:function(e,t,r,i){return e+t+r+i>>>0},sum32_5:function(e,t,r,i,n){return e+t+r+i+n>>>0},sum64:function(e,t,r,i){var n=e[t],a=i+e[t+1]>>>0,s=(a>>0,e[t+1]=a},sum64_hi:function(e,t,r,i){return(t+i>>>0>>0},sum64_lo:function(e,t,r,i){return t+i>>>0},sum64_4_hi:function(e,t,r,i,n,a,s,o){var c=0,u=t;return c+=(u=u+i>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,t,r,i,n,a,s,o){return t+i+a+o>>>0},sum64_5_hi:function(e,t,r,i,n,a,s,o,c,u){var h=0,d=t;return h+=(d=d+i>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,t,r,i,n,a,s,o,c,u){return t+i+a+o+u>>>0},rotr64_hi:function(e,t,r){return(t<<32-r|e>>>r)>>>0},rotr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0},shr64_hi:function(e,t,r){return e>>>r},shr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0}};function At(){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}var St=At;At.prototype.update=function(e,t){if(e=kt.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=kt.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,i[n++]=e>>>16&255,i[n++]=e>>>8&255,i[n++]=255&e}else for(i[n++]=255&e,i[n++]=e>>>8&255,i[n++]=e>>>16&255,i[n++]=e>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,a=8;a>>3},g1_256:function(e){return Pt(e,17)^Pt(e,19)^e>>>10}},Ut=kt.sum32,Rt=kt.sum32_4,It=kt.sum32_5,Bt=Dt.ch32,Tt=Dt.maj32,zt=Dt.s0_256,qt=Dt.s1_256,Ft=Dt.g0_256,Ot=Dt.g1_256,Lt=Et.BlockHash,Nt=[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 jt(){if(!(this instanceof jt))return new jt;Lt.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Nt,this.W=Array(64)}kt.inherits(jt,Lt);var Wt=jt;function Ht(){if(!(this instanceof Ht))return new Ht;Wt.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}jt.blockSize=512,jt.outSize=256,jt.hmacStrength=192,jt.padLength=64,jt.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;i>>32-n,r)}function Fr(e,t,r,i,n,a,s){return qr(t&r|~t&i,e,t,n,a,s)}function Or(e,t,r,i,n,a,s){return qr(t&i|r&~i,e,t,n,a,s)}function Lr(e,t,r,i,n,a,s){return qr(t^r^i,e,t,n,a,s)}function Nr(e,t,r,i,n,a,s){return qr(r^(t|~i),e,t,n,a,s)}function jr(e){const t=[];let r;for(r=0;r<64;r+=4)t[r>>2]=e.charCodeAt(r)+(e.charCodeAt(r+1)<<8)+(e.charCodeAt(r+2)<<16)+(e.charCodeAt(r+3)<<24);return t}const Wr="0123456789abcdef".split("");function Hr(e){let t="",r=0;for(;r<4;r++)t+=Wr[e>>8*r+4&15]+Wr[e>>8*r&15];return t}function Gr(e,t){return e+t&4294967295}const Vr=ie.getWebCrypto(),$r=ie.getNodeCrypto(),Zr=$r&&$r.getHashes();function Xr(e){if($r&&Zr.includes(e))return async function(t){const r=$r.createHash(e);return N(t,(e=>{r.update(e)}),(()=>new Uint8Array(r.digest())))}}function Yr(e,t){return async function(r,i=de){if(l(r)&&(r=await Z(r)),!ie.isStream(r)&&Vr&&t&&r.length>=i.minBytesForWebCrypto)return new Uint8Array(await Vr.digest(t,r));const n=e();return N(r,(e=>{n.update(e)}),(()=>new Uint8Array(n.digest())))}}function Qr(e,t){return async function(r,i=de){if(l(r)&&(r=await Z(r)),ie.isStream(r)){const t=new e;return N(r,(e=>{t.process(e)}),(()=>t.finish().result))}return Vr&&t&&r.length>=i.minBytesForWebCrypto?new Uint8Array(await Vr.digest(t,r)):e.bytes(r)}}const Jr={md5:Xr("md5")||async function(e){const t=function(e){const t=e.length,r=[1732584193,-271733879,-1732584194,271733878];let i;for(i=64;i<=e.length;i+=64)zr(r,jr(e.substring(i-64,i)));e=e.substring(i-64);const n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i>2]|=e.charCodeAt(i)<<(i%4<<3);if(n[i>>2]|=128<<(i%4<<3),i>55)for(zr(r,n),i=0;i<16;i++)n[i]=0;return n[14]=8*t,zr(r,n),r}(ie.uint8ArrayToString(e));return ie.hexToUint8Array(function(e){for(let t=0;tnew Uint8Array(a.update(e))))}(e,t,r,i);if(ie.isAES(e))return function(e,t,r,i,n){if(ie.getWebCrypto()&&24!==t.length&&!ie.isStream(r)&&r.length>=3e3*n.minBytesForWebCrypto)return async function(e,t,r,i){const n="AES-CBC",a=await ii.importKey("raw",t,{name:n},!1,["encrypt"]),{blockSize:s}=ri(e),o=ie.concatUint8Array([new Uint8Array(s),r]),c=new Uint8Array(await ii.encrypt({name:n,iv:i},a,o)).subarray(0,r.length);return function(e,t){for(let r=0;ra.aes.AES_Encrypt_process(e)),(()=>a.aes.AES_Encrypt_finish()))}(e,t,r,i,n);const s=new(ri(e))(t),o=s.blockSize,c=i.slice();let u=new Uint8Array;const h=e=>{e&&(u=ie.concatUint8Array([u,e]));const t=new Uint8Array(u.length);let r,i=0;for(;e?u.length>=o:u.length;){const e=s.encrypt(c);for(r=0;rnew Uint8Array(a.update(e))))}(e,t,r,i);if(ie.isAES(e))return function(e,t,r,i){if(ie.isStream(r)){const e=new ti(t,i);return N(r,(t=>e.aes.AES_Decrypt_process(t)),(()=>e.aes.AES_Decrypt_finish()))}return ti.decrypt(r,t,i)}(0,t,r,i);const a=new(ri(e))(t),s=a.blockSize;let o=i,c=new Uint8Array;const u=e=>{e&&(c=ie.concatUint8Array([c,e]));const t=new Uint8Array(c.length);let r,i=0;for(;e?c.length>=s:c.length;){const e=a.encrypt(o);for(o=c,r=0;r48)throw new Me("illegal counter size");let e=Math.pow(2,r)-1;i.set_mask(0,0,e/4294967296|0,0|e)}else r=48,i.set_mask(0,0,65535,4294967295);if(void 0===e)throw Error("nonce is required");{let t=e.length;if(!t||t>16)throw new Me("illegal nonce size");let r=new DataView(new ArrayBuffer(16));new Uint8Array(r.buffer).set(e),i.set_nonce(r.getUint32(0),r.getUint32(4),r.getUint32(8),r.getUint32(12))}if(void 0!==t){if(t<0||t>=Math.pow(2,r))throw new Me("illegal counter value");i.set_counter(0,0,t/4294967296|0,0|t)}}}class ui{static encrypt(e,t,r=!0,i){return new ui(t,i,r).encrypt(e)}static decrypt(e,t,r=!0,i){return new ui(t,i,r).decrypt(e)}constructor(e,t,r=!0,i){this.aes=i||new Ue(e,t,r,"CBC")}encrypt(e){return Pe(this.aes.AES_Encrypt_process(e),this.aes.AES_Encrypt_finish())}decrypt(e){return Pe(this.aes.AES_Decrypt_process(e),this.aes.AES_Decrypt_finish())}}const hi=ie.getWebCrypto(),di=ie.getNodeCrypto(),fi=16;function li(e,t){const r=e.length-fi;for(let i=0;i>3),17+(u>>3)),8-(7&u)).subarray(1),l=new Uint8Array(Mi),p=new Uint8Array(t.length+Ci);let y,b=0;for(y=0;y16)throw new Me("illegal tagSize value");const o=t.length||0,c=new Uint8Array(16);12!==o?(this._gcm_mac_process(t),s[0]=0,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=0,s[11]=o>>>29,s[12]=o>>>21&255,s[13]=o>>>13&255,s[14]=o>>>5&255,s[15]=o<<3&255,a.mac(ke.MAC.GCM,ke.HEAP_DATA,16),a.get_iv(ke.HEAP_DATA),a.set_iv(0,0,0,0),c.set(s.subarray(0,16))):(c.set(t),c[15]=1);const u=new DataView(c.buffer);if(this.gamma0=u.getUint32(12),a.set_nonce(u.getUint32(0),u.getUint32(4),u.getUint32(8),0),a.set_mask(0,0,0,4294967295),void 0!==r){if(r.length>zi)throw new Me("illegal adata length");r.length?(this.adata=r,this._gcm_mac_process(r)):this.adata=void 0}else this.adata=void 0;if(this.counter<1||this.counter>4294967295)throw new RangeError("counter must be a positive 32-bit integer");a.set_counter(0,0,0,this.gamma0+this.counter|0)}static encrypt(e,t,r,i,n){return new qi(t,r,i,n).encrypt(e)}static decrypt(e,t,r,i,n){return new qi(t,r,i,n).decrypt(e)}encrypt(e){return this.AES_GCM_encrypt(e)}decrypt(e){return this.AES_GCM_decrypt(e)}AES_GCM_Encrypt_process(e){let t=0,r=e.length||0,{asm:i,heap:n}=this.aes.acquire_asm(),a=this.counter,s=this.aes.pos,o=this.aes.len,c=0,u=o+r&-16,h=0;if((a-1<<4)+o+r>zi)throw new RangeError("counter overflow");const d=new Uint8Array(u);for(;r>0;)h=Ee(n,s+o,e,t,r),o+=h,t+=h,r-=h,h=i.cipher(ke.ENC.CTR,ke.HEAP_DATA+s,o),h=i.mac(ke.MAC.GCM,ke.HEAP_DATA+s,h),h&&d.set(n.subarray(s,s+h),c),a+=h>>>4,c+=h,h>>29,t[4]=u>>>21,t[5]=u>>>13&255,t[6]=u>>>5&255,t[7]=u<<3&255,t[8]=t[9]=t[10]=0,t[11]=h>>>29,t[12]=h>>>21&255,t[13]=h>>>13&255,t[14]=h>>>5&255,t[15]=h<<3&255,e.mac(ke.MAC.GCM,ke.HEAP_DATA,16),e.get_iv(ke.HEAP_DATA),e.set_counter(0,0,0,this.gamma0),e.cipher(ke.ENC.CTR,ke.HEAP_DATA,16),o.set(t.subarray(0,i),s),this.counter=1,this.aes.pos=0,this.aes.len=0,o}AES_GCM_Decrypt_process(e){let t=0,r=e.length||0,{asm:i,heap:n}=this.aes.acquire_asm(),a=this.counter,s=this.tagSize,o=this.aes.pos,c=this.aes.len,u=0,h=c+r>s?c+r-s&-16:0,d=c+r-h,f=0;if((a-1<<4)+c+r>zi)throw new RangeError("counter overflow");const l=new Uint8Array(h);for(;r>d;)f=Ee(n,o+c,e,t,r-d),c+=f,t+=f,r-=f,f=i.mac(ke.MAC.GCM,ke.HEAP_DATA+o,f),f=i.cipher(ke.DEC.CTR,ke.HEAP_DATA+o,f),f&&l.set(n.subarray(o,o+f),u),a+=f>>>4,u+=f,o=0,c=0;return r>0&&(c+=Ee(n,0,e,t,r)),this.counter=a,this.aes.pos=o,this.aes.len=c,l}AES_GCM_Decrypt_finish(){let{asm:e,heap:t}=this.aes.acquire_asm(),r=this.tagSize,i=this.adata,n=this.counter,a=this.aes.pos,s=this.aes.len,o=s-r;if(s>>29,t[4]=d>>>21,t[5]=d>>>13&255,t[6]=d>>>5&255,t[7]=d<<3&255,t[8]=t[9]=t[10]=0,t[11]=f>>>29,t[12]=f>>>21&255,t[13]=f>>>13&255,t[14]=f>>>5&255,t[15]=f<<3&255,e.mac(ke.MAC.GCM,ke.HEAP_DATA,16),e.get_iv(ke.HEAP_DATA),e.set_counter(0,0,0,this.gamma0),e.cipher(ke.ENC.CTR,ke.HEAP_DATA,16);let l=0;for(let e=0;e0;){for(a=Ee(r,0,e,i,n),i+=a,n-=a;15&a;)r[a++]=0;t.mac(ke.MAC.GCM,ke.HEAP_DATA,a)}}}const Fi=ie.getWebCrypto(),Oi=ie.getNodeCrypto(),Li=ie.getNodeBuffer(),Ni=16,ji="AES-GCM";async function Wi(e,t){if(e!==te.symmetric.aes128&&e!==te.symmetric.aes192&&e!==te.symmetric.aes256)throw Error("GCM mode supports only AES cipher");if(ie.getWebCrypto()&&24!==t.length){const e=await Fi.importKey("raw",t,{name:ji},!1,["encrypt","decrypt"]);return{encrypt:async function(r,i,n=new Uint8Array){if(!r.length)return qi.encrypt(r,t,i,n);const a=await Fi.encrypt({name:ji,iv:i,additionalData:n,tagLength:8*Ni},e,r);return new Uint8Array(a)},decrypt:async function(r,i,n=new Uint8Array){if(r.length===Ni)return qi.decrypt(r,t,i,n);const a=await Fi.decrypt({name:ji,iv:i,additionalData:n,tagLength:8*Ni},e,r);return new Uint8Array(a)}}}return ie.getNodeCrypto()?{encrypt:async function(e,r,i=new Uint8Array){const n=new Oi.createCipheriv("aes-"+8*t.length+"-gcm",t,r);n.setAAD(i);const a=Li.concat([n.update(e),n.final(),n.getAuthTag()]);return new Uint8Array(a)},decrypt:async function(e,r,i=new Uint8Array){const n=new Oi.createDecipheriv("aes-"+8*t.length+"-gcm",t,r);n.setAAD(i),n.setAuthTag(e.slice(e.length-Ni,e.length));const a=Li.concat([n.update(e.slice(0,e.length-Ni)),n.final()]);return new Uint8Array(a)}}:{encrypt:async function(e,r,i){return qi.encrypt(e,t,r,i)},decrypt:async function(e,r,i){return qi.decrypt(e,t,r,i)}}}Wi.getNonce=function(e,t){const r=e.slice();for(let e=0;e>>8)-1}(e,t,r,i,32)}function p(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function y(e){var t,r,i=1;for(t=0;t<16;t++)r=e[t]+i+65535,i=Math.floor(r/65536),e[t]=r-65536*i;e[0]+=i-1+37*(i-1)}function b(e,t,r){for(var i,n=~(r-1),a=0;a<16;a++)i=n&(e[a]^t[a]),e[a]^=i,t[a]^=i}function m(e,r){var i,n,a,s=t(),o=t();for(i=0;i<16;i++)o[i]=r[i];for(y(o),y(o),y(o),n=0;n<2;n++){for(s[0]=o[0]-65517,i=1;i<15;i++)s[i]=o[i]-65535-(s[i-1]>>16&1),s[i-1]&=65535;s[15]=o[15]-32767-(s[14]>>16&1),a=s[15]>>16&1,s[14]&=65535,b(o,s,1-a)}for(i=0;i<16;i++)e[2*i]=255&o[i],e[2*i+1]=o[i]>>8}function g(e,t){var r=new Uint8Array(32),i=new Uint8Array(32);return m(r,e),m(i,t),l(r,0,i,0)}function w(e){var t=new Uint8Array(32);return m(t,e),1&t[0]}function v(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function _(e,t,r){for(var i=0;i<16;i++)e[i]=t[i]+r[i]}function k(e,t,r){for(var i=0;i<16;i++)e[i]=t[i]-r[i]}function A(e,t,r){var i,n,a=0,s=0,o=0,c=0,u=0,h=0,d=0,f=0,l=0,p=0,y=0,b=0,m=0,g=0,w=0,v=0,_=0,k=0,A=0,S=0,E=0,P=0,x=0,M=0,K=0,C=0,D=0,U=0,R=0,I=0,B=0,T=r[0],z=r[1],q=r[2],F=r[3],O=r[4],L=r[5],N=r[6],j=r[7],W=r[8],H=r[9],G=r[10],V=r[11],$=r[12],Z=r[13],X=r[14],Y=r[15];a+=(i=t[0])*T,s+=i*z,o+=i*q,c+=i*F,u+=i*O,h+=i*L,d+=i*N,f+=i*j,l+=i*W,p+=i*H,y+=i*G,b+=i*V,m+=i*$,g+=i*Z,w+=i*X,v+=i*Y,s+=(i=t[1])*T,o+=i*z,c+=i*q,u+=i*F,h+=i*O,d+=i*L,f+=i*N,l+=i*j,p+=i*W,y+=i*H,b+=i*G,m+=i*V,g+=i*$,w+=i*Z,v+=i*X,_+=i*Y,o+=(i=t[2])*T,c+=i*z,u+=i*q,h+=i*F,d+=i*O,f+=i*L,l+=i*N,p+=i*j,y+=i*W,b+=i*H,m+=i*G,g+=i*V,w+=i*$,v+=i*Z,_+=i*X,k+=i*Y,c+=(i=t[3])*T,u+=i*z,h+=i*q,d+=i*F,f+=i*O,l+=i*L,p+=i*N,y+=i*j,b+=i*W,m+=i*H,g+=i*G,w+=i*V,v+=i*$,_+=i*Z,k+=i*X,A+=i*Y,u+=(i=t[4])*T,h+=i*z,d+=i*q,f+=i*F,l+=i*O,p+=i*L,y+=i*N,b+=i*j,m+=i*W,g+=i*H,w+=i*G,v+=i*V,_+=i*$,k+=i*Z,A+=i*X,S+=i*Y,h+=(i=t[5])*T,d+=i*z,f+=i*q,l+=i*F,p+=i*O,y+=i*L,b+=i*N,m+=i*j,g+=i*W,w+=i*H,v+=i*G,_+=i*V,k+=i*$,A+=i*Z,S+=i*X,E+=i*Y,d+=(i=t[6])*T,f+=i*z,l+=i*q,p+=i*F,y+=i*O,b+=i*L,m+=i*N,g+=i*j,w+=i*W,v+=i*H,_+=i*G,k+=i*V,A+=i*$,S+=i*Z,E+=i*X,P+=i*Y,f+=(i=t[7])*T,l+=i*z,p+=i*q,y+=i*F,b+=i*O,m+=i*L,g+=i*N,w+=i*j,v+=i*W,_+=i*H,k+=i*G,A+=i*V,S+=i*$,E+=i*Z,P+=i*X,x+=i*Y,l+=(i=t[8])*T,p+=i*z,y+=i*q,b+=i*F,m+=i*O,g+=i*L,w+=i*N,v+=i*j,_+=i*W,k+=i*H,A+=i*G,S+=i*V,E+=i*$,P+=i*Z,x+=i*X,M+=i*Y,p+=(i=t[9])*T,y+=i*z,b+=i*q,m+=i*F,g+=i*O,w+=i*L,v+=i*N,_+=i*j,k+=i*W,A+=i*H,S+=i*G,E+=i*V,P+=i*$,x+=i*Z,M+=i*X,K+=i*Y,y+=(i=t[10])*T,b+=i*z,m+=i*q,g+=i*F,w+=i*O,v+=i*L,_+=i*N,k+=i*j,A+=i*W,S+=i*H,E+=i*G,P+=i*V,x+=i*$,M+=i*Z,K+=i*X,C+=i*Y,b+=(i=t[11])*T,m+=i*z,g+=i*q,w+=i*F,v+=i*O,_+=i*L,k+=i*N,A+=i*j,S+=i*W,E+=i*H,P+=i*G,x+=i*V,M+=i*$,K+=i*Z,C+=i*X,D+=i*Y,m+=(i=t[12])*T,g+=i*z,w+=i*q,v+=i*F,_+=i*O,k+=i*L,A+=i*N,S+=i*j,E+=i*W,P+=i*H,x+=i*G,M+=i*V,K+=i*$,C+=i*Z,D+=i*X,U+=i*Y,g+=(i=t[13])*T,w+=i*z,v+=i*q,_+=i*F,k+=i*O,A+=i*L,S+=i*N,E+=i*j,P+=i*W,x+=i*H,M+=i*G,K+=i*V,C+=i*$,D+=i*Z,U+=i*X,R+=i*Y,w+=(i=t[14])*T,v+=i*z,_+=i*q,k+=i*F,A+=i*O,S+=i*L,E+=i*N,P+=i*j,x+=i*W,M+=i*H,K+=i*G,C+=i*V,D+=i*$,U+=i*Z,R+=i*X,I+=i*Y,v+=(i=t[15])*T,s+=38*(k+=i*q),o+=38*(A+=i*F),c+=38*(S+=i*O),u+=38*(E+=i*L),h+=38*(P+=i*N),d+=38*(x+=i*j),f+=38*(M+=i*W),l+=38*(K+=i*H),p+=38*(C+=i*G),y+=38*(D+=i*V),b+=38*(U+=i*$),m+=38*(R+=i*Z),g+=38*(I+=i*X),w+=38*(B+=i*Y),a=(i=(a+=38*(_+=i*z))+(n=1)+65535)-65536*(n=Math.floor(i/65536)),s=(i=s+n+65535)-65536*(n=Math.floor(i/65536)),o=(i=o+n+65535)-65536*(n=Math.floor(i/65536)),c=(i=c+n+65535)-65536*(n=Math.floor(i/65536)),u=(i=u+n+65535)-65536*(n=Math.floor(i/65536)),h=(i=h+n+65535)-65536*(n=Math.floor(i/65536)),d=(i=d+n+65535)-65536*(n=Math.floor(i/65536)),f=(i=f+n+65535)-65536*(n=Math.floor(i/65536)),l=(i=l+n+65535)-65536*(n=Math.floor(i/65536)),p=(i=p+n+65535)-65536*(n=Math.floor(i/65536)),y=(i=y+n+65535)-65536*(n=Math.floor(i/65536)),b=(i=b+n+65535)-65536*(n=Math.floor(i/65536)),m=(i=m+n+65535)-65536*(n=Math.floor(i/65536)),g=(i=g+n+65535)-65536*(n=Math.floor(i/65536)),w=(i=w+n+65535)-65536*(n=Math.floor(i/65536)),v=(i=v+n+65535)-65536*(n=Math.floor(i/65536)),a=(i=(a+=n-1+37*(n-1))+(n=1)+65535)-65536*(n=Math.floor(i/65536)),s=(i=s+n+65535)-65536*(n=Math.floor(i/65536)),o=(i=o+n+65535)-65536*(n=Math.floor(i/65536)),c=(i=c+n+65535)-65536*(n=Math.floor(i/65536)),u=(i=u+n+65535)-65536*(n=Math.floor(i/65536)),h=(i=h+n+65535)-65536*(n=Math.floor(i/65536)),d=(i=d+n+65535)-65536*(n=Math.floor(i/65536)),f=(i=f+n+65535)-65536*(n=Math.floor(i/65536)),l=(i=l+n+65535)-65536*(n=Math.floor(i/65536)),p=(i=p+n+65535)-65536*(n=Math.floor(i/65536)),y=(i=y+n+65535)-65536*(n=Math.floor(i/65536)),b=(i=b+n+65535)-65536*(n=Math.floor(i/65536)),m=(i=m+n+65535)-65536*(n=Math.floor(i/65536)),g=(i=g+n+65535)-65536*(n=Math.floor(i/65536)),w=(i=w+n+65535)-65536*(n=Math.floor(i/65536)),v=(i=v+n+65535)-65536*(n=Math.floor(i/65536)),a+=n-1+37*(n-1),e[0]=a,e[1]=s,e[2]=o,e[3]=c,e[4]=u,e[5]=h,e[6]=d,e[7]=f,e[8]=l,e[9]=p,e[10]=y,e[11]=b,e[12]=m,e[13]=g,e[14]=w,e[15]=v}function S(e,t){A(e,t,t)}function E(e,r){var i,n=t();for(i=0;i<16;i++)n[i]=r[i];for(i=253;i>=0;i--)S(n,n),2!==i&&4!==i&&A(n,n,r);for(i=0;i<16;i++)e[i]=n[i]}function P(e,r,i){var n,a,s=new Uint8Array(32),c=new Float64Array(80),u=t(),h=t(),d=t(),f=t(),l=t(),p=t();for(a=0;a<31;a++)s[a]=r[a];for(s[31]=127&r[31]|64,s[0]&=248,v(c,i),a=0;a<16;a++)h[a]=c[a],f[a]=u[a]=d[a]=0;for(u[0]=f[0]=1,a=254;a>=0;--a)b(u,h,n=s[a>>>3]>>>(7&a)&1),b(d,f,n),_(l,u,d),k(u,u,d),_(d,h,f),k(h,h,f),S(f,l),S(p,u),A(u,d,u),A(d,h,l),_(l,u,d),k(u,u,d),S(h,u),k(d,f,p),A(u,d,o),_(u,u,f),A(d,d,u),A(u,f,p),A(f,h,c),S(h,l),b(u,h,n),b(d,f,n);for(a=0;a<16;a++)c[a+16]=u[a],c[a+32]=d[a],c[a+48]=h[a],c[a+64]=f[a];var y=c.subarray(32),g=c.subarray(16);return E(y,y),A(g,g,y),m(e,g),0}function x(e,t){return P(e,t,n)}function M(e,r){var i=t(),n=t(),a=t(),s=t(),o=t(),c=t(),h=t(),d=t(),f=t();k(i,e[1],e[0]),k(f,r[1],r[0]),A(i,i,f),_(n,e[0],e[1]),_(f,r[0],r[1]),A(n,n,f),A(a,e[3],r[3]),A(a,a,u),A(s,e[2],r[2]),_(s,s,s),k(o,n,i),k(c,s,a),_(h,s,a),_(d,n,i),A(e[0],o,c),A(e[1],d,h),A(e[2],h,c),A(e[3],o,d)}function K(e,t,r){var i;for(i=0;i<4;i++)b(e[i],t[i],r)}function C(e,r){var i=t(),n=t(),a=t();E(a,r[2]),A(i,r[0],a),A(n,r[1],a),m(e,n),e[31]^=w(i)<<7}function D(e,t,r){var i,n;for(p(e[0],a),p(e[1],s),p(e[2],s),p(e[3],a),n=255;n>=0;--n)K(e,t,i=r[n/8|0]>>(7&n)&1),M(t,e),M(e,e),K(e,t,i)}function U(e,r){var i=[t(),t(),t(),t()];p(i[0],h),p(i[1],d),p(i[2],s),A(i[3],h,d),D(e,i,r)}function R(i,n,a){var s,o,c=[t(),t(),t(),t()];for(a||r(n,32),(s=e.hash(n.subarray(0,32)))[0]&=248,s[31]&=127,s[31]|=64,U(c,s),C(i,c),o=0;o<32;o++)n[o+32]=i[o];return 0}var I=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function B(e,t){var r,i,n,a;for(i=63;i>=32;--i){for(r=0,n=i-32,a=i-12;n>4)*I[n],r=t[n]>>8,t[n]&=255;for(n=0;n<32;n++)t[n]-=r*I[n];for(i=0;i<32;i++)t[i+1]+=t[i]>>8,e[i]=255&t[i]}function T(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;B(e,r)}function z(e,r){var i=t(),n=t(),o=t(),u=t(),h=t(),d=t(),l=t();return p(e[2],s),v(e[1],r),S(o,e[1]),A(u,o,c),k(o,o,e[2]),_(u,e[2],u),S(h,u),S(d,h),A(l,d,h),A(i,l,o),A(i,i,u),function(e,r){var i,n=t();for(i=0;i<16;i++)n[i]=r[i];for(i=250;i>=0;i--)S(n,n),1!==i&&A(n,n,r);for(i=0;i<16;i++)e[i]=n[i]}(i,i),A(i,i,o),A(i,i,u),A(i,i,u),A(e[0],i,u),S(n,e[0]),A(n,n,u),g(n,o)&&A(e[0],e[0],f),S(n,e[0]),A(n,n,u),g(n,o)?-1:(w(e[0])===r[31]>>7&&k(e[0],a,e[0]),A(e[3],e[0],e[1]),0)}var q=64;function F(){for(var e=0;e=0},e.sign.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(64);return R(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(F(e),64!==e.length)throw Error("bad secret key size");for(var t=new Uint8Array(32),r=0;re&&(c.imod(a.leftShift(n)).iadd(a),u=c.mod(s).toNumber())}while(!await Qi(c,t,r));return c}async function Qi(e,t,r){return!(t&&!e.dec().gcd(t).isOne())&&(!!await async function(e){const t=await ie.getBigInteger();return Ji.every((r=>0!==e.mod(new t(r))))}(e)&&(!!await async function(e,t){const r=await ie.getBigInteger();return t=t||new r(2),t.modExp(e.dec(),e).isOne()}(e)&&!!await async function(e,t,r){const i=await ie.getBigInteger(),n=e.bitLength();t||(t=Math.max(1,n/48|0));const a=e.dec();let s=0;for(;!a.getBit(s);)s++;const o=e.rightShift(new i(s));for(;t>0;t--){let t,n=(r?r():await Zi(new i(2),a)).modExp(o,e);if(!n.isOne()&&!n.equal(a)){for(t=1;tt-11)throw Error("Message too long");const i=function(e){const t=new Uint8Array(e);let r=0;for(;r=8&!i;if(t)return ie.selectUint8Array(s,a,t);if(s)return a;throw Error("Decryption error")}async function nn(e,t,r){let i;if(t.length!==ei.getHashByteLength(e))throw Error("Invalid hash length");const n=new Uint8Array(en[e].length);for(i=0;i{on.generateKeyPair("rsa",r,((r,i,n)=>{r?t(r):e(un.decode(n,"der"))}))}));return{n:i.modulus.toArrayLike(Uint8Array),e:i.publicExponent.toArrayLike(Uint8Array),d:i.privateExponent.toArrayLike(Uint8Array),p:i.prime2.toArrayLike(Uint8Array),q:i.prime1.toArrayLike(Uint8Array),u:i.coefficient.toArrayLike(Uint8Array)}}let r,i,n;do{i=await Yi(e-(e>>1),t,40),r=await Yi(e>>1,t,40),n=r.mul(i)}while(n.bitLength()!==e);const a=r.dec().imul(i.dec());return i.lt(r)&&([r,i]=[i,r]),{n:n.toUint8Array(),e:t.toUint8Array(),d:t.modInv(a).toUint8Array(),p:r.toUint8Array(),q:i.toUint8Array(),u:r.modInv(i).toUint8Array()}},validateParams:async function(e,t,r,i,n,a){const s=await ie.getBigInteger();if(e=new s(e),i=new s(i),n=new s(n),!i.mul(n).equal(e))return!1;const o=new s(2);if(a=new s(a),!i.mul(a).mod(n).isOne())return!1;t=new s(t),r=new s(r);const c=new s(Math.floor(e.bitLength()/3)),u=await Zi(o,o.leftShift(c)),h=u.mul(r).mul(t);return!(!h.mod(i.dec()).equal(u)||!h.mod(n.dec()).equal(u))}});var fn=/*#__PURE__*/Object.freeze({__proto__:null,encrypt:async function(e,t,r,i){const n=await ie.getBigInteger();t=new n(t),r=new n(r),i=new n(i);const a=new n(tn(e,t.byteLength())),s=await Zi(new n(1),t.dec());return{c1:r.modExp(s,t).toUint8Array(),c2:i.modExp(s,t).imul(a).imod(t).toUint8Array()}},decrypt:async function(e,t,r,i,n){const a=await ie.getBigInteger();return e=new a(e),t=new a(t),r=new a(r),i=new a(i),rn(e.modExp(i,r).modInv(r).imul(t).imod(r).toUint8Array("be",r.byteLength()),n)},validateParams:async function(e,t,r,i){const n=await ie.getBigInteger();e=new n(e),t=new n(t),r=new n(r);const a=new n(1);if(t.lte(a)||t.gte(e))return!1;const s=new n(e.bitLength()),o=new n(1023);if(s.lt(o))return!1;if(!t.modExp(e.dec(),e).isOne())return!1;let c=t;const u=new n(1),h=new n(2).leftShift(new n(17));for(;u.lt(h);){if(c=c.mul(t).imod(e),c.isOne())return!1;u.iinc()}i=new n(i);const d=new n(2),f=await Zi(d.leftShift(s.dec()),d.leftShift(s)),l=e.dec().imul(f).iadd(i);return!!r.equal(t.modExp(l,e))}});class ln{constructor(e){if(e instanceof ln)this.oid=e.oid;else if(ie.isArray(e)||ie.isUint8Array(e)){if(6===(e=new Uint8Array(e))[0]){if(e[1]!==e.length-2)throw Error("Length mismatch in DER encoded oid");e=e.subarray(2)}this.oid=e}else this.oid=""}read(e){if(e.length>=1){const t=e[0];if(e.length>=1+t)return this.oid=e.subarray(1,1+t),1+this.oid.length}throw Error("Invalid oid")}write(){return ie.concatUint8Array([new Uint8Array([this.oid.length]),this.oid])}toHex(){return ie.uint8ArrayToHex(this.oid)}getName(){const e=this.toHex();if(te.curve[e])return te.write(te.curve,e);throw Error("Unknown curve object identifier.")}}function pn(e,t){return e.keyPair({priv:t})}function yn(e,t){const r=e.keyPair({pub:t});if(!0!==r.validate().result)throw Error("Invalid elliptic public key");return r}async function bn(e){if(!de.useIndutnyElliptic)throw Error("This curve is only supported in the full build of OpenPGP.js");const{default:t}=await Promise.resolve().then((function(){return Ub}));return new t.ec(e)}function mn(e){let t,r=0;const i=e[0];return i<192?([r]=e,t=1):i<255?(r=(e[0]-192<<8)+e[1]+192,t=2):255===i&&(r=ie.readNumber(e.subarray(1,5)),t=5),{len:r,offset:t}}function gn(e){return e<192?new Uint8Array([e]):e>191&&e<8384?new Uint8Array([192+(e-192>>8),e-192&255]):ie.concatUint8Array([new Uint8Array([255]),ie.writeNumber(e,4)])}function wn(e){if(e<0||e>30)throw Error("Partial Length power must be between 1 and 30");return new Uint8Array([224+e])}function vn(e){return new Uint8Array([192|e])}function _n(e,t){return ie.concatUint8Array([vn(e),gn(t)])}function kn(e){return[te.packet.literalData,te.packet.compressedData,te.packet.symmetricallyEncryptedData,te.packet.symEncryptedIntegrityProtectedData,te.packet.aeadEncryptedData].includes(e)}async function An(e,t){const r=z(e);let i,n;try{const a=await r.peekBytes(2);if(!a||a.length<2||0==(128&a[0]))throw Error("Error during parsing. This message / key probably does not conform to a valid OpenPGP format.");const s=await r.readByte();let o,c,u=-1,h=-1;h=0,0!=(64&s)&&(h=1),h?u=63&s:(u=(63&s)>>2,c=3&s);const d=kn(u);let l,p=null;if(d){if("array"===ie.isStream(e)){const e=new f;i=q(e),p=e}else{const e=new D;i=q(e.writable),p=e.readable}n=t({tag:u,packet:p})}else p=[];do{if(h){const e=await r.readByte();if(l=!1,e<192)o=e;else if(e>=192&&e<224)o=(e-192<<8)+await r.readByte()+192;else if(e>223&&e<255){if(o=1<<(31&e),l=!0,!d)throw new TypeError("This packet type does not support partial lengths.")}else o=await r.readByte()<<24|await r.readByte()<<16|await r.readByte()<<8|await r.readByte()}else switch(c){case 0:o=await r.readByte();break;case 1:o=await r.readByte()<<8|await r.readByte();break;case 2:o=await r.readByte()<<24|await r.readByte()<<16|await r.readByte()<<8|await r.readByte();break;default:o=1/0}if(o>0){let e=0;for(;;){i&&await i.ready;const{done:t,value:n}=await r.read();if(t){if(o===1/0)break;throw Error("Unexpected end of packet")}const a=o===1/0?n:n.subarray(0,o-e);if(i?await i.write(a):p.push(a),e+=n.length,e>=o){r.unshift(n.subarray(o-e+n.length));break}}}}while(l);const y=await r.peekBytes(d?1/0:2);return i?(await i.ready,await i.close()):(p=ie.concatUint8Array(p),await t({tag:u,packet:p})),!y||!y.length}catch(e){if(i)return await i.abort(e),!0;throw e}finally{i&&await n,r.releaseLock()}}class Sn extends Error{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,Sn),this.name="UnsupportedError"}}class En{constructor(e,t){this.tag=e,this.rawContent=t}write(){return this.rawContent}}const Pn=ie.getWebCrypto(),xn=ie.getNodeCrypto(),Mn={p256:"P-256",p384:"P-384",p521:"P-521"},Kn=xn?xn.getCurves():[],Cn=xn?{secp256k1:Kn.includes("secp256k1")?"secp256k1":void 0,p256:Kn.includes("prime256v1")?"prime256v1":void 0,p384:Kn.includes("secp384r1")?"secp384r1":void 0,p521:Kn.includes("secp521r1")?"secp521r1":void 0,ed25519:Kn.includes("ED25519")?"ED25519":void 0,curve25519:Kn.includes("X25519")?"X25519":void 0,brainpoolP256r1:Kn.includes("brainpoolP256r1")?"brainpoolP256r1":void 0,brainpoolP384r1:Kn.includes("brainpoolP384r1")?"brainpoolP384r1":void 0,brainpoolP512r1:Kn.includes("brainpoolP512r1")?"brainpoolP512r1":void 0}:{},Dn={p256:{oid:[6,8,42,134,72,206,61,3,1,7],keyType:te.publicKey.ecdsa,hash:te.hash.sha256,cipher:te.symmetric.aes128,node:Cn.p256,web:Mn.p256,payloadSize:32,sharedSize:256},p384:{oid:[6,5,43,129,4,0,34],keyType:te.publicKey.ecdsa,hash:te.hash.sha384,cipher:te.symmetric.aes192,node:Cn.p384,web:Mn.p384,payloadSize:48,sharedSize:384},p521:{oid:[6,5,43,129,4,0,35],keyType:te.publicKey.ecdsa,hash:te.hash.sha512,cipher:te.symmetric.aes256,node:Cn.p521,web:Mn.p521,payloadSize:66,sharedSize:528},secp256k1:{oid:[6,5,43,129,4,0,10],keyType:te.publicKey.ecdsa,hash:te.hash.sha256,cipher:te.symmetric.aes128,node:Cn.secp256k1,payloadSize:32},ed25519:{oid:[6,9,43,6,1,4,1,218,71,15,1],keyType:te.publicKey.eddsa,hash:te.hash.sha512,node:!1,payloadSize:32},curve25519:{oid:[6,10,43,6,1,4,1,151,85,1,5,1],keyType:te.publicKey.ecdh,hash:te.hash.sha256,cipher:te.symmetric.aes128,node:!1,payloadSize:32},brainpoolP256r1:{oid:[6,9,43,36,3,3,2,8,1,1,7],keyType:te.publicKey.ecdsa,hash:te.hash.sha256,cipher:te.symmetric.aes128,node:Cn.brainpoolP256r1,payloadSize:32},brainpoolP384r1:{oid:[6,9,43,36,3,3,2,8,1,1,11],keyType:te.publicKey.ecdsa,hash:te.hash.sha384,cipher:te.symmetric.aes192,node:Cn.brainpoolP384r1,payloadSize:48},brainpoolP512r1:{oid:[6,9,43,36,3,3,2,8,1,1,13],keyType:te.publicKey.ecdsa,hash:te.hash.sha512,cipher:te.symmetric.aes256,node:Cn.brainpoolP512r1,payloadSize:64}};class Un{constructor(e,t){try{(ie.isArray(e)||ie.isUint8Array(e))&&(e=new ln(e)),e instanceof ln&&(e=e.getName()),this.name=te.write(te.curve,e)}catch(e){throw new Sn("Unknown curve")}t=t||Dn[this.name],this.keyType=t.keyType,this.oid=t.oid,this.hash=t.hash,this.cipher=t.cipher,this.node=t.node&&Dn[this.name],this.web=t.web&&Dn[this.name],this.payloadSize=t.payloadSize,this.web&&ie.getWebCrypto()?this.type="web":this.node&&ie.getNodeCrypto()?this.type="node":"curve25519"===this.name?this.type="curve25519":"ed25519"===this.name&&(this.type="ed25519")}async genKeyPair(){let e;switch(this.type){case"web":try{return await async function(e){const t=await Pn.generateKey({name:"ECDSA",namedCurve:Mn[e]},!0,["sign","verify"]),r=await Pn.exportKey("jwk",t.privateKey),i=await Pn.exportKey("jwk",t.publicKey);return{publicKey:In(i),privateKey:ue(r.d)}}(this.name)}catch(e){ie.printDebugError("Browser did not support generating ec key "+e.message);break}case"node":return async function(e){const t=xn.createECDH(Cn[e]);return await t.generateKeys(),{publicKey:new Uint8Array(t.getPublicKey()),privateKey:new Uint8Array(t.getPrivateKey())}}(this.name);case"curve25519":{const t=$i(32);t[0]=127&t[0]|64,t[31]&=248;const r=t.slice().reverse();e=Gi.box.keyPair.fromSecretKey(r);return{publicKey:ie.concatUint8Array([new Uint8Array([64]),e.publicKey]),privateKey:t}}case"ed25519":{const e=$i(32),t=Gi.sign.keyPair.fromSeed(e);return{publicKey:ie.concatUint8Array([new Uint8Array([64]),t.publicKey]),privateKey:e}}}const t=await bn(this.name);return e=await t.genKeyPair({entropy:ie.uint8ArrayToString($i(32))}),{publicKey:new Uint8Array(e.getPublic("array",!1)),privateKey:e.getPrivate().toArrayLike(Uint8Array)}}}async function Rn(e,t,r,i){const n={p256:!0,p384:!0,p521:!0,secp256k1:!0,curve25519:e===te.publicKey.ecdh,brainpoolP256r1:!0,brainpoolP384r1:!0,brainpoolP512r1:!0},a=t.getName();if(!n[a])return!1;if("curve25519"===a){i=i.slice().reverse();const{publicKey:e}=Gi.box.keyPair.fromSecretKey(i);r=new Uint8Array(r);const t=new Uint8Array([64,...e]);return!!ie.equalsUint8Array(t,r)}const s=await bn(a);try{r=yn(s,r).getPublic()}catch(e){return!1}return!!pn(s,i).getPublic().eq(r)}function In(e){const t=ue(e.x),r=ue(e.y),i=new Uint8Array(t.length+r.length+1);return i[0]=4,i.set(t,1),i.set(r,t.length+1),i}function Bn(e,t,r){const i=e,n=r.slice(1,i+1),a=r.slice(i+1,2*i+1);return{kty:"EC",crv:t,x:he(n,!0),y:he(a,!0),ext:!0}}function Tn(e,t,r,i){const n=Bn(e,t,r);return n.d=he(i,!0),n}const zn=ie.getWebCrypto(),qn=ie.getNodeCrypto();async function Fn(e,t,r,i,n,a){const s=new Un(e);if(r&&!ie.isStream(r)){const e={publicKey:i,privateKey:n};switch(s.type){case"web":try{return await async function(e,t,r,i){const n=e.payloadSize,a=Tn(e.payloadSize,Mn[e.name],i.publicKey,i.privateKey),s=await zn.importKey("jwk",a,{name:"ECDSA",namedCurve:Mn[e.name],hash:{name:te.read(te.webHash,e.hash)}},!1,["sign"]),o=new Uint8Array(await zn.sign({name:"ECDSA",namedCurve:Mn[e.name],hash:{name:te.read(te.webHash,t)}},s,r));return{r:o.slice(0,n),s:o.slice(n,n<<1)}}(s,t,r,e)}catch(e){if("p521"!==s.name&&("DataError"===e.name||"OperationError"===e.name))throw e;ie.printDebugError("Browser did not support signing: "+e.message)}break;case"node":{const i=await async function(e,t,r,i){const n=qn.createSign(te.read(te.hash,t));n.write(r),n.end();const a=jn.encode({version:1,parameters:e.oid,privateKey:Array.from(i.privateKey),publicKey:{unused:0,data:Array.from(i.publicKey)}},"pem",{label:"EC PRIVATE KEY"});return Nn.decode(n.sign(a),"der")}(s,t,r,e);return{r:i.r.toArrayLike(Uint8Array),s:i.s.toArrayLike(Uint8Array)}}}}return async function(e,t,r){const i=await bn(e.name),n=pn(i,r),a=n.sign(t);return{r:a.r.toArrayLike(Uint8Array),s:a.s.toArrayLike(Uint8Array)}}(s,a,n)}async function On(e,t,r,i,n,a){const s=new Un(e);if(i&&!ie.isStream(i))switch(s.type){case"web":try{return await async function(e,t,{r,s:i},n,a){const s=Bn(e.payloadSize,Mn[e.name],a),o=await zn.importKey("jwk",s,{name:"ECDSA",namedCurve:Mn[e.name],hash:{name:te.read(te.webHash,e.hash)}},!1,["verify"]),c=ie.concatUint8Array([r,i]).buffer;return zn.verify({name:"ECDSA",namedCurve:Mn[e.name],hash:{name:te.read(te.webHash,t)}},o,c,n)}(s,t,r,i,n)}catch(e){if("p521"!==s.name&&("DataError"===e.name||"OperationError"===e.name))throw e;ie.printDebugError("Browser did not support verifying: "+e.message)}break;case"node":return async function(e,t,{r,s:i},n,a){const{default:s}=await Promise.resolve().then((function(){return ly})),o=qn.createVerify(te.read(te.hash,t));o.write(n),o.end();const c=Hn.encode({algorithm:{algorithm:[1,2,840,10045,2,1],parameters:e.oid},subjectPublicKey:{unused:0,data:Array.from(a)}},"pem",{label:"PUBLIC KEY"}),u=Nn.encode({r:new s(r),s:new s(i)},"der");try{return o.verify(c,u)}catch(e){return!1}}(s,t,r,i,n)}return async function(e,t,r,i){const n=await bn(e.name),a=yn(n,i);return a.verify(r,t)}(s,r,void 0===t?i:a,n)}const Ln=qn?o:void 0,Nn=qn?Ln.define("ECDSASignature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())})):void 0,jn=qn?Ln.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().any(),this.key("publicKey").explicit(1).optional().bitstr())})):void 0,Wn=qn?Ln.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})):void 0,Hn=qn?Ln.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(Wn),this.key("subjectPublicKey").bitstr())})):void 0;var Gn=/*#__PURE__*/Object.freeze({__proto__:null,sign:Fn,verify:On,validateParams:async function(e,t,r){const i=new Un(e);if(i.keyType!==te.publicKey.ecdsa)return!1;switch(i.type){case"web":case"node":{const i=$i(8),n=te.hash.sha256,a=await ei.digest(n,i);try{const s=await Fn(e,n,i,t,r,a);return await On(e,n,s,i,t,a)}catch(e){return!1}}default:return Rn(te.publicKey.ecdsa,e,t,r)}}});Gi.hash=e=>new Uint8Array(or().update(e).digest());var Vn=/*#__PURE__*/Object.freeze({__proto__:null,sign:async function(e,t,r,i,n,a){if(ei.getHashByteLength(t)new Uint8Array(or().update(e).digest());var $n=/*#__PURE__*/Object.freeze({__proto__:null,generate:async function(e){if(e===te.publicKey.ed25519){const e=$i(32),{publicKey:t}=Gi.sign.keyPair.fromSeed(e);return{A:t,seed:e}}throw Error("Unsupported EdDSA algorithm")},sign:async function(e,t,r,i,n,a){if(ei.getHashByteLength(t)=0;--e)for(let t=o-1;t>=0;--t)c[1]=o*e+(t+1),u[0]=a[0]^c[0],u[1]=a[1]^c[1],u[2]=s[2*t],u[3]=s[2*t+1],u=Yn(r.decrypt(Qn(u))),a=u.subarray(0,2),s[2*t]=u[2],s[2*t+1]=u[3];if(a[0]===i[0]&&a[1]===i[1])return Qn(s);throw Error("Key Data Integrity failed")}function Yn(e){const{length:t}=e,r=function(e){if(ie.isString(e)){const{length:t}=e,r=new ArrayBuffer(t),i=new Uint8Array(r);for(let r=0;r0){const r=e[t-1];if(r>=1){const i=e.subarray(t-r),n=new Uint8Array(r).fill(r);if(ie.equalsUint8Array(i,n))return e.subarray(0,t-r)}}throw Error("Invalid padding")}var ra=/*#__PURE__*/Object.freeze({__proto__:null,encode:ea,decode:ta});const ia=ie.getWebCrypto(),na=ie.getNodeCrypto();function aa(e,t,r,i){return ie.concatUint8Array([t.write(),new Uint8Array([e]),r.write(),ie.stringToUint8Array("Anonymous Sender "),i.subarray(0,20)])}async function sa(e,t,r,i,n=!1,a=!1){let s;if(n){for(s=0;s=0&&0===t[s];s--);t=t.subarray(0,s+1)}return(await ei.digest(e,ie.concatUint8Array([new Uint8Array([0,0,0,1]),t,i]))).subarray(0,r)}async function oa(e,t){switch(e.type){case"curve25519":{const r=$i(32),{secretKey:i,sharedKey:n}=await ca(e,t,null,r);let{publicKey:a}=Gi.box.keyPair.fromSecretKey(i);return a=ie.concatUint8Array([new Uint8Array([64]),a]),{publicKey:a,sharedKey:n}}case"web":if(e.web&&ie.getWebCrypto())try{return await async function(e,t){const r=Bn(e.payloadSize,e.web.web,t);let i=ia.generateKey({name:"ECDH",namedCurve:e.web.web},!0,["deriveKey","deriveBits"]),n=ia.importKey("jwk",r,{name:"ECDH",namedCurve:e.web.web},!1,[]);[i,n]=await Promise.all([i,n]);let a=ia.deriveBits({name:"ECDH",namedCurve:e.web.web,public:n},i.privateKey,e.web.sharedSize),s=ia.exportKey("jwk",i.publicKey);[a,s]=await Promise.all([a,s]);const o=new Uint8Array(a),c=new Uint8Array(In(s));return{publicKey:c,sharedKey:o}}(e,t)}catch(e){ie.printDebugError(e)}break;case"node":return async function(e,t){const r=na.createECDH(e.node.node);r.generateKeys();const i=new Uint8Array(r.computeSecret(t)),n=new Uint8Array(r.getPublicKey());return{publicKey:n,sharedKey:i}}(e,t)}return async function(e,t){const r=await bn(e.name),i=await e.genKeyPair();t=yn(r,t);const n=pn(r,i.privateKey),a=i.publicKey,s=n.derive(t.getPublic()),o=r.curve.p.byteLength(),c=s.toArrayLike(Uint8Array,"be",o);return{publicKey:a,sharedKey:c}}(e,t)}async function ca(e,t,r,i){if(i.length!==e.payloadSize){const t=new Uint8Array(e.payloadSize);t.set(i,e.payloadSize-i.length),i=t}switch(e.type){case"curve25519":{const e=i.slice().reverse();return{secretKey:e,sharedKey:Gi.scalarMult(e,t.subarray(1))}}case"web":if(e.web&&ie.getWebCrypto())try{return await async function(e,t,r,i){const n=Tn(e.payloadSize,e.web.web,r,i);let a=ia.importKey("jwk",n,{name:"ECDH",namedCurve:e.web.web},!0,["deriveKey","deriveBits"]);const s=Bn(e.payloadSize,e.web.web,t);let o=ia.importKey("jwk",s,{name:"ECDH",namedCurve:e.web.web},!0,[]);[a,o]=await Promise.all([a,o]);let c=ia.deriveBits({name:"ECDH",namedCurve:e.web.web,public:o},a,e.web.sharedSize),u=ia.exportKey("jwk",a);[c,u]=await Promise.all([c,u]);const h=new Uint8Array(c);return{secretKey:ue(u.d),sharedKey:h}}(e,t,r,i)}catch(e){ie.printDebugError(e)}break;case"node":return async function(e,t,r){const i=na.createECDH(e.node.node);i.setPrivateKey(r);const n=new Uint8Array(i.computeSecret(t));return{secretKey:new Uint8Array(i.getPrivateKey()),sharedKey:n}}(e,t,i)}return async function(e,t,r){const i=await bn(e.name);t=yn(i,t),r=pn(i,r);const n=new Uint8Array(r.getPrivate()),a=r.derive(t.getPublic()),s=i.curve.p.byteLength(),o=a.toArrayLike(Uint8Array,"be",s);return{secretKey:n,sharedKey:o}}(e,t,i)}var ua=/*#__PURE__*/Object.freeze({__proto__:null,validateParams:async function(e,t,r){return Rn(te.publicKey.ecdh,e,t,r)},encrypt:async function(e,t,r,i,n){const a=ea(r),s=new Un(e),{publicKey:o,sharedKey:c}=await oa(s,i),u=aa(te.publicKey.ecdh,e,t,n),{keySize:h}=ri(t.cipher);return{publicKey:o,wrappedKey:Zn(await sa(t.hash,c,h,u),a)}},decrypt:async function(e,t,r,i,n,a,s){const o=new Un(e),{sharedKey:c}=await ca(o,r,n,a),u=aa(te.publicKey.ecdh,e,t,s),{keySize:h}=ri(t.cipher);let d;for(let e=0;e<3;e++)try{return ta(Xn(await sa(t.hash,c,h,u,1===e,2===e),i))}catch(e){d=e}throw d}});const ha=ie.getWebCrypto(),da=ie.getNodeCrypto(),fa=da&&da.webcrypto&&da.webcrypto.subtle;async function la(e,t,r,i,n){const a=te.read(te.webHash,e);if(!a)throw Error("Hash algo not supported with HKDF");if(ha||fa){const e=ha||fa,s=await e.importKey("raw",t,"HKDF",!1,["deriveBits"]),o=await e.deriveBits({name:"HKDF",hash:a,salt:r,info:i},s,8*n);return new Uint8Array(o)}if(da){const a=te.read(te.hash,e),s=(e,t)=>da.createHmac(a,e).update(t).digest(),o=s(r,t),c=o.length,u=Math.ceil(n/c),h=new Uint8Array(u*c),d=new Uint8Array(c+i.length+1);d.set(i,c);for(let e=0;e0?d:d.subarray(c));d.set(t,0),h.set(t,e*c)}return h.subarray(0,n)}throw Error("No HKDF implementation available")}const pa={x25519:ie.encodeUTF8("OpenPGP X25519")};var ya=/*#__PURE__*/Object.freeze({__proto__:null,generate:async function(e){if(e===te.publicKey.x25519){const e=$i(32);e[0]&=248,e[31]=127&e[31]|64;const{publicKey:t}=Gi.box.keyPair.fromSecretKey(e);return{A:t,k:e}}throw Error("Unsupported ECDH algorithm")},validateParams:async function(e,t,r){if(e===te.publicKey.x25519){const{publicKey:e}=Gi.box.keyPair.fromSecretKey(r);return ie.equalsUint8Array(t,e)}return!1},encrypt:async function(e,t,r){if(e===te.publicKey.x25519){const e=$i(32),i=Gi.scalarMult(e,r),{publicKey:n}=Gi.box.keyPair.fromSecretKey(e),a=ie.concatUint8Array([n,r,i]),{keySize:s}=ri(te.symmetric.aes128);return{ephemeralPublicKey:n,wrappedKey:Zn(await la(te.hash.sha256,a,new Uint8Array,pa.x25519,s),t)}}throw Error("Unsupported ECDH algorithm")},decrypt:async function(e,t,r,i,n){if(e===te.publicKey.x25519){const e=Gi.scalarMult(n,t),a=ie.concatUint8Array([t,i,e]),{keySize:s}=ri(te.symmetric.aes128);return Xn(await la(te.hash.sha256,a,new Uint8Array,pa.x25519,s),r)}throw Error("Unsupported ECDH algorithm")}}),ba=/*#__PURE__*/Object.freeze({__proto__:null,CurveWithOID:Un,ecdh:ua,ecdhX:ya,ecdsa:Gn,eddsaLegacy:Vn,eddsa:$n,generate:async function(e){const t=await ie.getBigInteger();e=new Un(e);const r=await e.genKeyPair(),i=new t(r.publicKey).toUint8Array(),n=new t(r.privateKey).toUint8Array("be",e.payloadSize);return{oid:e.oid,Q:i,secret:n,hash:e.hash,cipher:e.cipher}},getPreferredHashAlgo:function(e){return Dn[te.write(te.curve,e.toHex())].hash}});var ma=/*#__PURE__*/Object.freeze({__proto__:null,sign:async function(e,t,r,i,n,a){const s=await ie.getBigInteger(),o=new s(1);let c,u,h,d;i=new s(i),n=new s(n),r=new s(r),a=new s(a),r=r.mod(i),a=a.mod(n);const f=new s(t.subarray(0,n.byteLength())).mod(n);for(;;){if(c=await Zi(o,n),u=r.modExp(c,i).imod(n),u.isZero())continue;const e=a.mul(u).imod(n);if(d=f.add(e).imod(n),h=c.modInv(n).imul(d).imod(n),!h.isZero())break}return{r:u.toUint8Array("be",n.byteLength()),s:h.toUint8Array("be",n.byteLength())}},verify:async function(e,t,r,i,n,a,s,o){const c=await ie.getBigInteger(),u=new c(0);if(t=new c(t),r=new c(r),a=new c(a),s=new c(s),n=new c(n),o=new c(o),t.lte(u)||t.gte(s)||r.lte(u)||r.gte(s))return ie.printDebug("invalid DSA Signature"),!1;const h=new c(i.subarray(0,s.byteLength())).imod(s),d=r.modInv(s);if(d.isZero())return ie.printDebug("invalid DSA Signature"),!1;n=n.mod(a),o=o.mod(a);const f=h.mul(d).imod(s),l=t.mul(d).imod(s),p=n.modExp(f,a),y=o.modExp(l,a);return p.mul(y).imod(a).imod(s).equal(t)},validateParams:async function(e,t,r,i,n){const a=await ie.getBigInteger();e=new a(e),t=new a(t),r=new a(r),i=new a(i);const s=new a(1);if(r.lte(s)||r.gte(e))return!1;if(!e.dec().mod(t).isZero())return!1;if(!r.modExp(t,e).isOne())return!1;const o=new a(t.bitLength()),c=new a(150);if(o.lt(c)||!await Qi(t,null,32))return!1;n=new a(n);const u=new a(2),h=await Zi(u.leftShift(o.dec()),u.leftShift(o)),d=t.mul(h).add(n);return!!i.equal(r.modExp(d,e))}}),ga={rsa:dn,elgamal:fn,elliptic:ba,dsa:ma,nacl:Gi};var wa=/*#__PURE__*/Object.freeze({__proto__:null,parseSignatureParams:function(e,t){let r=0;switch(e){case te.publicKey.rsaEncryptSign:case te.publicKey.rsaEncrypt:case te.publicKey.rsaSign:return{s:ie.readMPI(t.subarray(r))};case te.publicKey.dsa:case te.publicKey.ecdsa:{const e=ie.readMPI(t.subarray(r));r+=e.length+2;return{r:e,s:ie.readMPI(t.subarray(r))}}case te.publicKey.eddsa:case te.publicKey.ed25519Legacy:{let e=ie.readMPI(t.subarray(r));r+=e.length+2,e=ie.leftPad(e,32);let i=ie.readMPI(t.subarray(r));return i=ie.leftPad(i,32),{r:e,s:i}}case te.publicKey.ed25519:{const e=t.subarray(r,r+64);return r+=e.length,{RS:e}}default:throw new Sn("Unknown signature algorithm.")}},verify:async function(e,t,r,i,n,a){switch(e){case te.publicKey.rsaEncryptSign:case te.publicKey.rsaEncrypt:case te.publicKey.rsaSign:{const{n:e,e:s}=i,o=ie.leftPad(r.s,e.length);return ga.rsa.verify(t,n,o,e,s,a)}case te.publicKey.dsa:{const{g:e,p:n,q:s,y:o}=i,{r:c,s:u}=r;return ga.dsa.verify(t,c,u,a,e,n,s,o)}case te.publicKey.ecdsa:{const{oid:e,Q:s}=i,o=new ga.elliptic.CurveWithOID(e).payloadSize,c=ie.leftPad(r.r,o),u=ie.leftPad(r.s,o);return ga.elliptic.ecdsa.verify(e,t,{r:c,s:u},n,s,a)}case te.publicKey.eddsa:case te.publicKey.ed25519Legacy:{const{oid:e,Q:s}=i;return ga.elliptic.eddsaLegacy.verify(e,t,r,n,s,a)}case te.publicKey.ed25519:{const{A:s}=i;return ga.elliptic.eddsa.verify(e,t,r,n,s,a)}default:throw Error("Unknown signature algorithm.")}},sign:async function(e,t,r,i,n,a){if(!r||!i)throw Error("Missing key parameters");switch(e){case te.publicKey.rsaEncryptSign:case te.publicKey.rsaEncrypt:case te.publicKey.rsaSign:{const{n:e,e:s}=r,{d:o,p:c,q:u,u:h}=i;return{s:await ga.rsa.sign(t,n,e,s,o,c,u,h,a)}}case te.publicKey.dsa:{const{g:e,p:n,q:s}=r,{x:o}=i;return ga.dsa.sign(t,a,e,n,s,o)}case te.publicKey.elgamal:throw Error("Signing with Elgamal is not defined in the OpenPGP standard.");case te.publicKey.ecdsa:{const{oid:e,Q:s}=r,{d:o}=i;return ga.elliptic.ecdsa.sign(e,t,n,s,o,a)}case te.publicKey.eddsa:case te.publicKey.ed25519Legacy:{const{oid:e,Q:s}=r,{seed:o}=i;return ga.elliptic.eddsaLegacy.sign(e,t,n,s,o,a)}case te.publicKey.ed25519:{const{A:s}=r,{seed:o}=i;return ga.elliptic.eddsa.sign(e,t,n,s,o,a)}default:throw Error("Unknown signature algorithm.")}}});class va{constructor(e){e&&(this.data=e)}read(e){if(e.length>=1){const t=e[0];if(e.length>=1+t)return this.data=e.subarray(1,1+t),1+this.data.length}throw Error("Invalid symmetric key")}write(){return ie.concatUint8Array([new Uint8Array([this.data.length]),this.data])}}class _a{constructor(e){if(e){const{hash:t,cipher:r}=e;this.hash=t,this.cipher=r}else this.hash=null,this.cipher=null}read(e){if(e.length<4||3!==e[0]||1!==e[1])throw new Sn("Cannot read KDFParams");return this.hash=e[2],this.cipher=e[3],4}write(){return new Uint8Array([3,1,this.hash,this.cipher])}}class ka{static fromObject({wrappedKey:e,algorithm:t}){const r=new ka;return r.wrappedKey=e,r.algorithm=t,r}read(e){let t=0,r=e[t++];this.algorithm=r%2?e[t++]:null,r-=r%2,this.wrappedKey=e.subarray(t,t+r),t+=r}write(){return ie.concatUint8Array([this.algorithm?new Uint8Array([this.wrappedKey.length+1,this.algorithm]):new Uint8Array([this.wrappedKey.length]),this.wrappedKey])}}function Aa(e){try{e.getName()}catch(e){throw new Sn("Unknown curve OID")}}var Sa=/*#__PURE__*/Object.freeze({__proto__:null,publicKeyEncrypt:async function(e,t,r,i,n){switch(e){case te.publicKey.rsaEncrypt:case te.publicKey.rsaEncryptSign:{const{n:e,e:t}=r;return{c:await ga.rsa.encrypt(i,e,t)}}case te.publicKey.elgamal:{const{p:e,g:t,y:n}=r;return ga.elgamal.encrypt(i,e,t,n)}case te.publicKey.ecdh:{const{oid:e,Q:t,kdfParams:a}=r,{publicKey:s,wrappedKey:o}=await ga.elliptic.ecdh.encrypt(e,a,i,t,n);return{V:s,C:new va(o)}}case te.publicKey.x25519:{if(!ie.isAES(t))throw Error("X25519 keys can only encrypt AES session keys");const{A:n}=r,{ephemeralPublicKey:a,wrappedKey:s}=await ga.elliptic.ecdhX.encrypt(e,i,n);return{ephemeralPublicKey:a,C:ka.fromObject({algorithm:t,wrappedKey:s})}}default:return[]}},publicKeyDecrypt:async function(e,t,r,i,n,a){switch(e){case te.publicKey.rsaEncryptSign:case te.publicKey.rsaEncrypt:{const{c:e}=i,{n,e:s}=t,{d:o,p:c,q:u,u:h}=r;return ga.rsa.decrypt(e,n,s,o,c,u,h,a)}case te.publicKey.elgamal:{const{c1:e,c2:n}=i,s=t.p,o=r.x;return ga.elgamal.decrypt(e,n,s,o,a)}case te.publicKey.ecdh:{const{oid:e,Q:a,kdfParams:s}=t,{d:o}=r,{V:c,C:u}=i;return ga.elliptic.ecdh.decrypt(e,s,c,u.data,a,o,n)}case te.publicKey.x25519:{const{A:n}=t,{k:a}=r,{ephemeralPublicKey:s,C:o}=i;if(!ie.isAES(o.algorithm))throw Error("AES session key expected");return ga.elliptic.ecdhX.decrypt(e,s,o.wrappedKey,n,a)}default:throw Error("Unknown public key encryption algorithm.")}},parsePublicKeyParams:function(e,t){let r=0;switch(e){case te.publicKey.rsaEncrypt:case te.publicKey.rsaEncryptSign:case te.publicKey.rsaSign:{const e=ie.readMPI(t.subarray(r));r+=e.length+2;const i=ie.readMPI(t.subarray(r));return r+=i.length+2,{read:r,publicParams:{n:e,e:i}}}case te.publicKey.dsa:{const e=ie.readMPI(t.subarray(r));r+=e.length+2;const i=ie.readMPI(t.subarray(r));r+=i.length+2;const n=ie.readMPI(t.subarray(r));r+=n.length+2;const a=ie.readMPI(t.subarray(r));return r+=a.length+2,{read:r,publicParams:{p:e,q:i,g:n,y:a}}}case te.publicKey.elgamal:{const e=ie.readMPI(t.subarray(r));r+=e.length+2;const i=ie.readMPI(t.subarray(r));r+=i.length+2;const n=ie.readMPI(t.subarray(r));return r+=n.length+2,{read:r,publicParams:{p:e,g:i,y:n}}}case te.publicKey.ecdsa:{const e=new ln;r+=e.read(t),Aa(e);const i=ie.readMPI(t.subarray(r));return r+=i.length+2,{read:r,publicParams:{oid:e,Q:i}}}case te.publicKey.eddsa:case te.publicKey.ed25519Legacy:{const e=new ln;r+=e.read(t),Aa(e);let i=ie.readMPI(t.subarray(r));return r+=i.length+2,i=ie.leftPad(i,33),{read:r,publicParams:{oid:e,Q:i}}}case te.publicKey.ecdh:{const e=new ln;r+=e.read(t),Aa(e);const i=ie.readMPI(t.subarray(r));r+=i.length+2;const n=new _a;return r+=n.read(t.subarray(r)),{read:r,publicParams:{oid:e,Q:i,kdfParams:n}}}case te.publicKey.ed25519:case te.publicKey.x25519:{const e=t.subarray(r,r+32);return r+=e.length,{read:r,publicParams:{A:e}}}default:throw new Sn("Unknown public key encryption algorithm.")}},parsePrivateKeyParams:function(e,t,r){let i=0;switch(e){case te.publicKey.rsaEncrypt:case te.publicKey.rsaEncryptSign:case te.publicKey.rsaSign:{const e=ie.readMPI(t.subarray(i));i+=e.length+2;const r=ie.readMPI(t.subarray(i));i+=r.length+2;const n=ie.readMPI(t.subarray(i));i+=n.length+2;const a=ie.readMPI(t.subarray(i));return i+=a.length+2,{read:i,privateParams:{d:e,p:r,q:n,u:a}}}case te.publicKey.dsa:case te.publicKey.elgamal:{const e=ie.readMPI(t.subarray(i));return i+=e.length+2,{read:i,privateParams:{x:e}}}case te.publicKey.ecdsa:case te.publicKey.ecdh:{const e=new Un(r.oid);let n=ie.readMPI(t.subarray(i));return i+=n.length+2,n=ie.leftPad(n,e.payloadSize),{read:i,privateParams:{d:n}}}case te.publicKey.eddsa:case te.publicKey.ed25519Legacy:{const e=new Un(r.oid);let n=ie.readMPI(t.subarray(i));return i+=n.length+2,n=ie.leftPad(n,e.payloadSize),{read:i,privateParams:{seed:n}}}case te.publicKey.ed25519:{const e=t.subarray(i,i+32);return i+=e.length,{read:i,privateParams:{seed:e}}}case te.publicKey.x25519:{const e=t.subarray(i,i+32);return i+=e.length,{read:i,privateParams:{k:e}}}default:throw new Sn("Unknown public key encryption algorithm.")}},parseEncSessionKeyParams:function(e,t){let r=0;switch(e){case te.publicKey.rsaEncrypt:case te.publicKey.rsaEncryptSign:return{c:ie.readMPI(t.subarray(r))};case te.publicKey.elgamal:{const e=ie.readMPI(t.subarray(r));r+=e.length+2;return{c1:e,c2:ie.readMPI(t.subarray(r))}}case te.publicKey.ecdh:{const e=ie.readMPI(t.subarray(r));r+=e.length+2;const i=new va;return i.read(t.subarray(r)),{V:e,C:i}}case te.publicKey.x25519:{const e=t.subarray(r,r+32);r+=e.length;const i=new ka;return i.read(t.subarray(r)),{ephemeralPublicKey:e,C:i}}default:throw new Sn("Unknown public key encryption algorithm.")}},serializeParams:function(e,t){const r=new Set([te.publicKey.ed25519,te.publicKey.x25519]),i=Object.keys(t).map((i=>{const n=t[i];return ie.isUint8Array(n)?r.has(e)?n:ie.uint8ArrayToMPI(n):n.write()}));return ie.concatUint8Array(i)},generateParams:function(e,t,r){switch(e){case te.publicKey.rsaEncrypt:case te.publicKey.rsaEncryptSign:case te.publicKey.rsaSign:return ga.rsa.generate(t,65537).then((({n:e,e:t,d:r,p:i,q:n,u:a})=>({privateParams:{d:r,p:i,q:n,u:a},publicParams:{n:e,e:t}})));case te.publicKey.ecdsa:return ga.elliptic.generate(r).then((({oid:e,Q:t,secret:r})=>({privateParams:{d:r},publicParams:{oid:new ln(e),Q:t}})));case te.publicKey.eddsa:case te.publicKey.ed25519Legacy:return ga.elliptic.generate(r).then((({oid:e,Q:t,secret:r})=>({privateParams:{seed:r},publicParams:{oid:new ln(e),Q:t}})));case te.publicKey.ecdh:return ga.elliptic.generate(r).then((({oid:e,Q:t,secret:r,hash:i,cipher:n})=>({privateParams:{d:r},publicParams:{oid:new ln(e),Q:t,kdfParams:new _a({hash:i,cipher:n})}})));case te.publicKey.ed25519:return ga.elliptic.eddsa.generate(e).then((({A:e,seed:t})=>({privateParams:{seed:t},publicParams:{A:e}})));case te.publicKey.x25519:return ga.elliptic.ecdhX.generate(e).then((({A:e,k:t})=>({privateParams:{k:t},publicParams:{A:e}})));case te.publicKey.dsa:case te.publicKey.elgamal:throw Error("Unsupported algorithm for key generation.");default:throw Error("Unknown public key algorithm.")}},validateParams:async function(e,t,r){if(!t||!r)throw Error("Missing key parameters");switch(e){case te.publicKey.rsaEncrypt:case te.publicKey.rsaEncryptSign:case te.publicKey.rsaSign:{const{n:e,e:i}=t,{d:n,p:a,q:s,u:o}=r;return ga.rsa.validateParams(e,i,n,a,s,o)}case te.publicKey.dsa:{const{p:e,q:i,g:n,y:a}=t,{x:s}=r;return ga.dsa.validateParams(e,i,n,a,s)}case te.publicKey.elgamal:{const{p:e,g:i,y:n}=t,{x:a}=r;return ga.elgamal.validateParams(e,i,n,a)}case te.publicKey.ecdsa:case te.publicKey.ecdh:{const i=ga.elliptic[te.read(te.publicKey,e)],{oid:n,Q:a}=t,{d:s}=r;return i.validateParams(n,a,s)}case te.publicKey.eddsa:case te.publicKey.ed25519Legacy:{const{Q:e,oid:i}=t,{seed:n}=r;return ga.elliptic.eddsaLegacy.validateParams(i,e,n)}case te.publicKey.ed25519:{const{A:i}=t,{seed:n}=r;return ga.elliptic.eddsa.validateParams(e,i,n)}case te.publicKey.x25519:{const{A:i}=t,{k:n}=r;return ga.elliptic.ecdhX.validateParams(e,i,n)}default:throw Error("Unknown public key algorithm.")}},getPrefixRandom:async function(e){const{blockSize:t}=ri(e),r=await $i(t),i=new Uint8Array([r[r.length-2],r[r.length-1]]);return ie.concat([r,i])},generateSessionKey:function(e){const{keySize:t}=ri(e);return $i(t)},getAEADMode:function(e){const t=te.read(te.aead,e);return Hi[t]},getCipher:ri});const Ea={cipher:Qe,hash:ei,mode:Hi,publicKey:ga,signature:wa,random:Xi,pkcs1:an,pkcs5:ra,aesKW:Jn};Object.assign(Ea,Sa);var Pa="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function xa(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)}const Ma={arraySet:function(e,t,r,i,n){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+i),n);else for(let a=0;a=0;)e[t]=0}const ns=0,as=1,ss=2,os=29,cs=256,us=cs+1+os,hs=30,ds=19,fs=2*us+1,ls=15,ps=16,ys=7,bs=256,ms=16,gs=17,ws=18,vs=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],_s=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],ks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],As=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Ss=Array(2*(us+2));is(Ss);const Es=Array(2*hs);is(Es);const Ps=Array(512);is(Ps);const xs=Array(256);is(xs);const Ms=Array(os);is(Ms);const Ks=Array(hs);function Cs(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}let Ds,Us,Rs;function Is(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Bs(e){return e<256?Ps[e]:Ps[256+(e>>>7)]}function Ts(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function zs(e,t,r){e.bi_valid>ps-r?(e.bi_buf|=t<>ps-e.bi_valid,e.bi_valid+=r-ps):(e.bi_buf|=t<>>=1,r<<=1}while(--t>0);return r>>>1}function Os(e,t,r){const i=Array(ls+1);let n,a,s=0;for(n=1;n<=ls;n++)i[n]=s=s+r[n-1]<<1;for(a=0;a<=t;a++){const t=e[2*a+1];0!==t&&(e[2*a]=Fs(i[t]++,t))}}function Ls(e){let t;for(t=0;t8?Ts(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function js(e,t,r,i){const n=2*t,a=2*r;return e[n]>1;s>=1;s--)Ws(e,r,s);c=a;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ws(e,r,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,r[2*c]=r[2*s]+r[2*o],e.depth[c]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,r[2*s+1]=r[2*o+1]=c,e.heap[1]=c++,Ws(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){const r=t.dyn_tree,i=t.max_code,n=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,h,d,f,l,p,y=0;for(f=0;f<=ls;f++)e.bl_count[f]=0;for(r[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;uc&&(f=c,y++),r[2*h+1]=f,h>i||(e.bl_count[f]++,l=0,h>=o&&(l=s[h-o]),p=r[2*h],e.opt_len+=p*(f+l),a&&(e.static_len+=p*(n[2*h+1]+l)));if(0!==y){do{for(f=c-1;0===e.bl_count[f];)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,y-=2}while(y>0);for(f=c;0!==f;f--)for(h=e.bl_count[f];0!==h;)d=e.heap[--u],d>i||(r[2*d+1]!==f&&(e.opt_len+=(f-r[2*d+1])*r[2*d],r[2*d+1]=f),h--)}}(e,t),Os(r,u,e.bl_count)}function Vs(e,t,r){let i,n,a=-1,s=t[1],o=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=s,s=t[2*(i+1)+1],++o>=7;i=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}function Js(e,t,r,i){let n,a,s=0;e.level>0?(e.strm.data_type===ts&&(e.strm.data_type=function(e){let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return Ja;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return es;for(t=32;t=3&&0===e.bl_tree[2*As[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),n=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=n&&(n=a)):n=a=r+5,r+4<=n&&-1!==t?Ys(e,t,r,i):e.strategy===Qa||a===n?(zs(e,(as<<1)+(i?1:0),3),Hs(e,Ss,Es)):(zs(e,(ss<<1)+(i?1:0),3),function(e,t,r,i){let n;for(zs(e,t-257,5),zs(e,r-1,5),zs(e,i-4,4),n=0;n>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(xs[r]+cs+1)]++,e.dyn_dtree[2*Bs(t)]++),e.last_lit===e.lit_bufsize-1}function to(e,t,r,i){let n=65535&e|0,a=e>>>16&65535|0,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do{n=n+t[i++]|0,a=a+n|0}while(--s);n%=65521,a%=65521}return n|a<<16|0}const ro=function(){let e;const t=[];for(let r=0;r<256;r++){e=r;for(let t=0;t<8;t++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();function io(e,t,r,i){const n=ro,a=i+r;e^=-1;for(let r=i;r>>8^n[255&(e^t[r])];return-1^e}var no={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};const ao=9,so=3,oo=258,co=oo+so+1,uo=32,ho=42,fo=69,lo=73,po=91,yo=103,bo=113,mo=666,go=1,wo=2,vo=3,_o=4,ko=3;function Ao(e,t){return e.msg=no[t],t}function So(e){return(e<<1)-(e>4?9:0)}function Eo(e){let t=e.length;for(;--t>=0;)e[t]=0}function Po(e){const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(Ia(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function xo(e,t){Js(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Po(e.strm)}function Mo(e,t){e.pending_buf[e.pending++]=t}function Ko(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function Co(e,t,r,i){let n=e.avail_in;return n>i&&(n=i),0===n?0:(e.avail_in-=n,Ia(t,e.input,e.next_in,n,r),1===e.state.wrap?e.adler=to(e.adler,t,n,r):2===e.state.wrap&&(e.adler=io(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)}function Do(e,t){let r,i,n=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match;const c=e.strstart>e.w_size-co?e.strstart-(e.w_size-co):0,u=e.window,h=e.w_mask,d=e.prev,f=e.strstart+oo;let l=u[a+s-1],p=u[a+s];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do{if(r=t,u[r+s]===p&&u[r+s-1]===l&&u[r]===u[a]&&u[++r]===u[a+1]){a+=2,r++;do{}while(u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&as){if(e.match_start=t,s=i,i>=o)break;l=u[a+s-1],p=u[a+s]}}}while((t=d[t&h])>c&&0!=--n);return s<=e.lookahead?s:e.lookahead}function Uo(e){const t=e.w_size;let r,i,n,a,s;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-co)){Ia(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,i=e.hash_size,r=i;do{n=e.head[--r],e.head[r]=n>=t?n-t:0}while(--i);i=t,r=i;do{n=e.prev[--r],e.prev[r]=n>=t?n-t:0}while(--i);a+=t}if(0===e.strm.avail_in)break;if(i=Co(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=i,e.lookahead+e.insert>=so)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<=so&&(e.ins_h=(e.ins_h<=so)if(i=eo(e,e.strstart-e.match_start,e.match_length-so),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=so){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=so&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=so-1)),e.prev_length>=so&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-so,i=eo(e,e.strstart-1-e.prev_match,e.prev_length-so),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Uo(e),0===e.lookahead&&t===Ba)return go;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;const i=e.block_start+r;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,xo(e,!1),0===e.strm.avail_out))return go;if(e.strstart-e.block_start>=e.w_size-co&&(xo(e,!1),0===e.strm.avail_out))return go}return e.insert=0,t===Fa?(xo(e,!0),0===e.strm.avail_out?vo:_o):(e.strstart>e.block_start&&(xo(e,!1),e.strm.avail_out),go)})),new Bo(4,4,8,4,Ro),new Bo(4,5,16,8,Ro),new Bo(4,6,32,32,Ro),new Bo(4,4,16,16,Io),new Bo(8,16,32,32,Io),new Bo(8,16,128,128,Io),new Bo(8,32,128,256,Io),new Bo(32,128,258,1024,Io),new Bo(32,258,258,4096,Io)];class zo{constructor(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=rs,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Da(1146),this.dyn_dtree=new Da(122),this.bl_tree=new Da(78),Eo(this.dyn_ltree),Eo(this.dyn_dtree),Eo(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Da(16),this.heap=new Da(573),Eo(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Da(573),Eo(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}}function qo(e){const t=function(e){let t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=ts,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?ho:bo,e.adler=2===t.wrap?0:1,t.last_flush=Ba,Xs(t),Na):Ao(e,Ha)}(e);return t===Na&&function(e){e.window_size=2*e.w_size,Eo(e.head),e.max_lazy_match=To[e.level].max_lazy,e.good_match=To[e.level].good_length,e.nice_match=To[e.level].nice_length,e.max_chain_length=To[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=so-1,e.match_available=0,e.ins_h=0}(e.state),t}function Fo(e,t){let r,i,n,a;if(!e||!e.state||t>Oa||t<0)return e?Ao(e,Ha):Ha;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||i.status===mo&&t!==Fa)return Ao(e,0===e.avail_out?Va:Ha);if(i.strm=e,r=i.last_flush,i.last_flush=t,i.status===ho)if(2===i.wrap)e.adler=0,Mo(i,31),Mo(i,139),Mo(i,8),i.gzhead?(Mo(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),Mo(i,255&i.gzhead.time),Mo(i,i.gzhead.time>>8&255),Mo(i,i.gzhead.time>>16&255),Mo(i,i.gzhead.time>>24&255),Mo(i,9===i.level?2:i.strategy>=Xa||i.level<2?4:0),Mo(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(Mo(i,255&i.gzhead.extra.length),Mo(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=io(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=fo):(Mo(i,0),Mo(i,0),Mo(i,0),Mo(i,0),Mo(i,0),Mo(i,9===i.level?2:i.strategy>=Xa||i.level<2?4:0),Mo(i,ko),i.status=bo);else{let t=rs+(i.w_bits-8<<4)<<8,r=-1;r=i.strategy>=Xa||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=r<<6,0!==i.strstart&&(t|=uo),t+=31-t%31,i.status=bo,Ko(i,t),0!==i.strstart&&(Ko(i,e.adler>>>16),Ko(i,65535&e.adler)),e.adler=1}if(i.status===fo)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>n&&(e.adler=io(e.adler,i.pending_buf,i.pending-n,n)),Po(e),n=i.pending,i.pending!==i.pending_buf_size));)Mo(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(e.adler=io(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=lo)}else i.status=lo;if(i.status===lo)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=io(e.adler,i.pending_buf,i.pending-n,n)),Po(e),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}a=i.gzindexn&&(e.adler=io(e.adler,i.pending_buf,i.pending-n,n)),0===a&&(i.gzindex=0,i.status=po)}else i.status=po;if(i.status===po)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=io(e.adler,i.pending_buf,i.pending-n,n)),Po(e),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}a=i.gzindexn&&(e.adler=io(e.adler,i.pending_buf,i.pending-n,n)),0===a&&(i.status=yo)}else i.status=yo;if(i.status===yo&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&Po(e),i.pending+2<=i.pending_buf_size&&(Mo(i,255&e.adler),Mo(i,e.adler>>8&255),e.adler=0,i.status=bo)):i.status=bo),0!==i.pending){if(Po(e),0===e.avail_out)return i.last_flush=-1,Na}else if(0===e.avail_in&&So(t)<=So(r)&&t!==Fa)return Ao(e,Va);if(i.status===mo&&0!==e.avail_in)return Ao(e,Va);if(0!==e.avail_in||0!==i.lookahead||t!==Ba&&i.status!==mo){var s=i.strategy===Xa?function(e,t){let r;for(;;){if(0===e.lookahead&&(Uo(e),0===e.lookahead)){if(t===Ba)return go;break}if(e.match_length=0,r=eo(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(xo(e,!1),0===e.strm.avail_out))return go}return e.insert=0,t===Fa?(xo(e,!0),0===e.strm.avail_out?vo:_o):e.last_lit&&(xo(e,!1),0===e.strm.avail_out)?go:wo}(i,t):i.strategy===Ya?function(e,t){let r,i,n,a;const s=e.window;for(;;){if(e.lookahead<=oo){if(Uo(e),e.lookahead<=oo&&t===Ba)return go;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=so&&e.strstart>0&&(n=e.strstart-1,i=s[n],i===s[++n]&&i===s[++n]&&i===s[++n])){a=e.strstart+oo;do{}while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&ne.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=so?(r=eo(e,1,e.match_length-so),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=eo(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(xo(e,!1),0===e.strm.avail_out))return go}return e.insert=0,t===Fa?(xo(e,!0),0===e.strm.avail_out?vo:_o):e.last_lit&&(xo(e,!1),0===e.strm.avail_out)?go:wo}(i,t):To[i.level].func(i,t);if(s!==vo&&s!==_o||(i.status=mo),s===go||s===vo)return 0===e.avail_out&&(i.last_flush=-1),Na;if(s===wo&&(t===Ta?Qs(i):t!==Oa&&(Ys(i,0,0,!1),t===qa&&(Eo(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),Po(e),0===e.avail_out))return i.last_flush=-1,Na}return t!==Fa?Na:i.wrap<=0?ja:(2===i.wrap?(Mo(i,255&e.adler),Mo(i,e.adler>>8&255),Mo(i,e.adler>>16&255),Mo(i,e.adler>>24&255),Mo(i,255&e.total_in),Mo(i,e.total_in>>8&255),Mo(i,e.total_in>>16&255),Mo(i,e.total_in>>24&255)):(Ko(i,e.adler>>>16),Ko(i,65535&e.adler)),Po(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Na:ja)}try{String.fromCharCode.call(null,0)}catch(e){}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){}const Oo=new Ca(256);for(let e=0;e<256;e++)Oo[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;function Lo(e){let t,r,i,n,a=0;const s=e.length;for(i=0;i>>6,o[n++]=128|63&t):t<65536?(o[n++]=224|t>>>12,o[n++]=128|t>>>6&63,o[n++]=128|63&t):(o[n++]=240|t>>>18,o[n++]=128|t>>>12&63,o[n++]=128|t>>>6&63,o[n++]=128|63&t);return o}Oo[254]=Oo[254]=1;class No{constructor(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}}class jo{constructor(e){this.options={level:$a,method:rs,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,...e||{}};const t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new No,this.strm.avail_out=0;var r,i,n=function(e,t,r,i,n,a){if(!e)return Ha;let s=1;if(t===$a&&(t=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),n<1||n>ao||r!==rs||i<8||i>15||t<0||t>9||a<0||a>Qa)return Ao(e,Ha);8===i&&(i=9);const o=new zo;return e.state=o,o.strm=e,o.wrap=s,o.gzhead=null,o.w_bits=i,o.w_size=1<=r.w_size&&(0===a&&(Eo(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new Ca(r.w_size),Ia(u,t,h-r.w_size,r.w_size,0),t=u,h=r.w_size),s=e.avail_in,o=e.next_in,c=e.input,e.avail_in=h,e.next_in=0,e.input=t,Uo(r);r.lookahead>=so;){i=r.strstart,n=r.lookahead-(so-1);do{r.ins_h=(r.ins_h<0||0===r.avail_out)&&n!==ja);return a===Fa?(n=function(e){let t;return e&&e.state?(t=e.state.status,t!==ho&&t!==fo&&t!==lo&&t!==po&&t!==yo&&t!==bo&&t!==mo?Ao(e,Ha):(e.state=null,t===bo?Ao(e,Ga):Na)):Ha}(this.strm),this.onEnd(n),this.ended=!0,n===Na):a!==za||(this.onEnd(Na),r.avail_out=0,!0)}onData(e){this.chunks.push(e)}onEnd(e){e===Na&&(this.result=Ra(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg}}const Wo=30,Ho=12;function Go(e,t){let r,i,n,a,s,o,c,u,h,d;const f=e.state;r=e.next_in;const l=e.input,p=r+(e.avail_in-5);i=e.next_out;const y=e.output,b=i-(t-e.avail_out),m=i+(e.avail_out-257),g=f.dmax,w=f.wsize,v=f.whave,_=f.wnext,k=f.window;n=f.hold,a=f.bits;const A=f.lencode,S=f.distcode,E=(1<>>24,n>>>=o,a-=o,o=s>>>16&255,0===o)y[i++]=65535&s;else{if(!(16&o)){if(0==(64&o)){s=A[(65535&s)+(n&(1<>>=o,a-=o),a<15&&(n+=l[r++]<>>24,n>>>=o,a-=o,o=s>>>16&255,!(16&o)){if(0==(64&o)){s=S[(65535&s)+(n&(1<g){e.msg="invalid distance too far back",f.mode=Wo;break e}if(n>>>=o,a-=o,o=i-b,u>o){if(o=u-o,o>v&&f.sane){e.msg="invalid distance too far back",f.mode=Wo;break e}if(h=0,d=k,0===_){if(h+=w-o,o2;)y[i++]=d[h++],y[i++]=d[h++],y[i++]=d[h++],c-=3;c&&(y[i++]=d[h++],c>1&&(y[i++]=d[h++]))}else{h=i-u;do{y[i++]=y[h++],y[i++]=y[h++],y[i++]=y[h++],c-=3}while(c>2);c&&(y[i++]=y[h++],c>1&&(y[i++]=y[h++]))}break}}break}}while(r>3,r-=c,a-=c<<3,n&=(1<=1&&0===P[m];m--);if(g>m&&(g=m),0===m)return n[a++]=20971520,n[a++]=20971520,o.bits=1,0;for(b=1;b0&&(e===Xo||1!==m))return-1;for(x[1]=0,p=1;p$o||e===Qo&&k>Zo)return 1;for(;;){M=p-v,s[y]l?(K=D[U+s[y]],C=S[E+s[y]]):(K=96,C=0),u=1<>v)+h]=M<<24|K<<16|C|0}while(0!==h);for(u=1<>=1;if(0!==u?(A&=u-1,A+=u):A=0,y++,0==--P[p]){if(p===m)break;p=t[r+s[y]]}if(p>g&&(A&R)!==d){for(0===v&&(v=g),f+=b,w=p-v,_=1<$o||e===Qo&&k>Zo)return 1;d=A&R,n[d]=g<<24|w<<16|f-a|0}}return 0!==A&&(n[f+A]=p-v<<24|64<<16|0),o.bits=g,0}const nc=0,ac=1,sc=2,oc=1,cc=2,uc=3,hc=4,dc=5,fc=6,lc=7,pc=8,yc=9,bc=10,mc=11,gc=12,wc=13,vc=14,_c=15,kc=16,Ac=17,Sc=18,Ec=19,Pc=20,xc=21,Mc=22,Kc=23,Cc=24,Dc=25,Uc=26,Rc=27,Ic=28,Bc=29,Tc=30,zc=852,qc=592;function Fc(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}class Oc{constructor(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Da(320),this.work=new Da(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}}function Lc(e){let t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,function(e){let t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=oc,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Ua(zc),t.distcode=t.distdyn=new Ua(qc),t.sane=1,t.back=-1,Na):Ha}(e)):Ha}function Nc(e,t){let r,i;return e?(i=new Oc,e.state=i,i.window=null,r=function(e,t){let r,i;return e&&e.state?(i=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ha:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,Lc(e))):Ha}(e,t),r!==Na&&(e.state=null),r):Ha}let jc,Wc,Hc=!0;function Gc(e){if(Hc){let t;for(jc=new Ua(512),Wc=new Ua(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ic(ac,e.lens,0,288,jc,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ic(sc,e.lens,0,32,Wc,0,e.work,{bits:5}),Hc=!1}e.lencode=jc,e.lenbits=9,e.distcode=Wc,e.distbits=5}function Vc(e,t,r,i){let n;const a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(Ia(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>i&&(n=i),Ia(a.window,t,r-i,n,a.wnext),(i-=n)?(Ia(a.window,t,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,r.check=io(r.check,x,2,0),u=0,h=0,r.mode=cc;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Tc;break}if((15&u)!==rs){e.msg="unknown compression method",r.mode=Tc;break}if(u>>>=4,h-=4,k=8+(15&u),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=Tc;break}r.dmax=1<>8&1),512&r.flags&&(x[0]=255&u,x[1]=u>>>8&255,r.check=io(r.check,x,2,0)),u=0,h=0,r.mode=uc;case uc:for(;h<32;){if(0===o)break e;o--,u+=i[a++]<>>8&255,x[2]=u>>>16&255,x[3]=u>>>24&255,r.check=io(r.check,x,4,0)),u=0,h=0,r.mode=hc;case hc:for(;h<16;){if(0===o)break e;o--,u+=i[a++]<>8),512&r.flags&&(x[0]=255&u,x[1]=u>>>8&255,r.check=io(r.check,x,2,0)),u=0,h=0,r.mode=dc;case dc:if(1024&r.flags){for(;h<16;){if(0===o)break e;o--,u+=i[a++]<>>8&255,r.check=io(r.check,x,2,0)),u=0,h=0}else r.head&&(r.head.extra=null);r.mode=fc;case fc:if(1024&r.flags&&(l=r.length,l>o&&(l=o),l&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=Array(r.head.extra_len)),Ia(r.head.extra,i,a,l,k)),512&r.flags&&(r.check=io(r.check,i,l,a)),o-=l,a+=l,r.length-=l),r.length))break e;r.length=0,r.mode=lc;case lc:if(2048&r.flags){if(0===o)break e;l=0;do{k=i[a+l++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k))}while(k&&l>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=gc;break;case bc:for(;h<32;){if(0===o)break e;o--,u+=i[a++]<>>=7&h,h-=7&h,r.mode=Rc;break}for(;h<3;){if(0===o)break e;o--,u+=i[a++]<>>=1,h-=1,3&u){case 0:r.mode=vc;break;case 1:if(Gc(r),r.mode=Pc,t===La){u>>>=2,h-=2;break e}break;case 2:r.mode=Ac;break;case 3:e.msg="invalid block type",r.mode=Tc}u>>>=2,h-=2;break;case vc:for(u>>>=7&h,h-=7&h;h<32;){if(0===o)break e;o--,u+=i[a++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=Tc;break}if(r.length=65535&u,u=0,h=0,r.mode=_c,t===La)break e;case _c:r.mode=kc;case kc:if(l=r.length,l){if(l>o&&(l=o),l>c&&(l=c),0===l)break e;Ia(n,i,a,l,s),o-=l,a+=l,c-=l,s+=l,r.length-=l;break}r.mode=gc;break;case Ac:for(;h<14;){if(0===o)break e;o--,u+=i[a++]<>>=5,h-=5,r.ndist=1+(31&u),u>>>=5,h-=5,r.ncode=4+(15&u),u>>>=4,h-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Tc;break}r.have=0,r.mode=Sc;case Sc:for(;r.have>>=3,h-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},A=ic(nc,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,A){e.msg="invalid code lengths set",r.mode=Tc;break}r.have=0,r.mode=Ec;case Ec:for(;r.have>>24,m=P>>>16&255,g=65535&P,!(b<=h);){if(0===o)break e;o--,u+=i[a++]<>>=b,h-=b,r.lens[r.have++]=g;else{if(16===g){for(E=b+2;h>>=b,h-=b,0===r.have){e.msg="invalid bit length repeat",r.mode=Tc;break}k=r.lens[r.have-1],l=3+(3&u),u>>>=2,h-=2}else if(17===g){for(E=b+3;h>>=b,h-=b,k=0,l=3+(7&u),u>>>=3,h-=3}else{for(E=b+7;h>>=b,h-=b,k=0,l=11+(127&u),u>>>=7,h-=7}if(r.have+l>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Tc;break}for(;l--;)r.lens[r.have++]=k}}if(r.mode===Tc)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Tc;break}if(r.lenbits=9,S={bits:r.lenbits},A=ic(ac,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,A){e.msg="invalid literal/lengths set",r.mode=Tc;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},A=ic(sc,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,A){e.msg="invalid distances set",r.mode=Tc;break}if(r.mode=Pc,t===La)break e;case Pc:r.mode=xc;case xc:if(o>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,r.hold=u,r.bits=h,Go(e,f),s=e.next_out,n=e.output,c=e.avail_out,a=e.next_in,i=e.input,o=e.avail_in,u=r.hold,h=r.bits,r.mode===gc&&(r.back=-1);break}for(r.back=0;P=r.lencode[u&(1<>>24,m=P>>>16&255,g=65535&P,!(b<=h);){if(0===o)break e;o--,u+=i[a++]<>w)],b=P>>>24,m=P>>>16&255,g=65535&P,!(w+b<=h);){if(0===o)break e;o--,u+=i[a++]<>>=w,h-=w,r.back+=w}if(u>>>=b,h-=b,r.back+=b,r.length=g,0===m){r.mode=Uc;break}if(32&m){r.back=-1,r.mode=gc;break}if(64&m){e.msg="invalid literal/length code",r.mode=Tc;break}r.extra=15&m,r.mode=Mc;case Mc:if(r.extra){for(E=r.extra;h>>=r.extra,h-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=Kc;case Kc:for(;P=r.distcode[u&(1<>>24,m=P>>>16&255,g=65535&P,!(b<=h);){if(0===o)break e;o--,u+=i[a++]<>w)],b=P>>>24,m=P>>>16&255,g=65535&P,!(w+b<=h);){if(0===o)break e;o--,u+=i[a++]<>>=w,h-=w,r.back+=w}if(u>>>=b,h-=b,r.back+=b,64&m){e.msg="invalid distance code",r.mode=Tc;break}r.offset=g,r.extra=15&m,r.mode=Cc;case Cc:if(r.extra){for(E=r.extra;h>>=r.extra,h-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Tc;break}r.mode=Dc;case Dc:if(0===c)break e;if(l=f-c,r.offset>l){if(l=r.offset-l,l>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Tc;break}l>r.wnext?(l-=r.wnext,p=r.wsize-l):p=r.wnext-l,l>r.length&&(l=r.length),y=r.window}else y=n,p=s-r.offset,l=r.length;l>c&&(l=c),c-=l,r.length-=l;do{n[s++]=y[p++]}while(--l);0===r.length&&(r.mode=xc);break;case Uc:if(0===c)break e;n[s++]=r.length,c--,r.mode=xc;break;case Rc:if(r.wrap){for(;h<32;){if(0===o)break e;o--,u|=i[a++]<=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new No,this.strm.avail_out=0;let r=Nc(this.strm,t.windowBits);if(r!==Na)throw Error(no[r]);if(this.header=new Xc,function(e,t){let r;e&&e.state&&(r=e.state,0==(2&r.wrap)||(r.head=t,t.done=!1))}(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Lo(t.dictionary):t.dictionary instanceof ArrayBuffer&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Zc(this.strm,t.dictionary),r!==Na)))throw Error(no[r])}push(e,t){const{strm:r,options:{chunkSize:i,dictionary:n}}=this;let a,s,o=!1;if(this.ended)return!1;s=t===~~t?t:!0===t?Fa:Ba,"string"==typeof e?r.input=function(e){const t=new Ca(e.length);for(let r=0,i=t.length;r0||0===r.avail_out)&&a!==ja);return a===ja&&(s=Fa),s===Fa?(a=function(e){if(!e||!e.state)return Ha;const t=e.state;return t.window&&(t.window=null),e.state=null,Na}(this.strm),this.onEnd(a),this.ended=!0,a===Na):s!==za||(this.onEnd(Na),r.avail_out=0,!0)}onData(e){this.chunks.push(e)}onEnd(e){e===Na&&(this.result=Ra(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg}}var Qc=[0,1,3,7,15,31,63,127,255],Jc=function(e){this.stream=e,this.bitOffset=0,this.curByte=0,this.hasByte=!1};Jc.prototype._ensureByte=function(){this.hasByte||(this.curByte=this.stream.readByte(),this.hasByte=!0)},Jc.prototype.read=function(e){for(var t=0;e>0;){this._ensureByte();var r=8-this.bitOffset;if(e>=r)t<<=r,t|=Qc[r]&this.curByte,this.hasByte=!1,this.bitOffset=0,e-=r;else{t<<=e;var i=r-e;t|=(this.curByte&Qc[e]<>i,this.bitOffset+=e,e=0}}return t},Jc.prototype.seek=function(e){var t=e%8,r=(e-t)/8;this.bitOffset=t,this.stream.seek(r),this.hasByte=!1},Jc.prototype.pi=function(){var e,t=new Uint8Array(6);for(e=0;e("00"+e.toString(16)).slice(-2))).join("")}(t)};var eu=Jc,tu=function(){};tu.prototype.readByte=function(){throw Error("abstract method readByte() not implemented")},tu.prototype.read=function(e,t,r){for(var i=0;i>>0},this.updateCRC=function(t){e=e<<8^ru[255&(e>>>24^t)]},this.updateCRCRun=function(t,r){for(;r-- >0;)e=e<<8^ru[255&(e>>>24^t)]}}),au=function(e,t){var r,i=e[t];for(r=t;r>0;r--)e[r]=e[r-1];return e[0]=i,i},su={OK:0,LAST_BLOCK:-1,NOT_BZIP_DATA:-2,UNEXPECTED_INPUT_EOF:-3,UNEXPECTED_OUTPUT_EOF:-4,DATA_ERROR:-5,OUT_OF_MEMORY:-6,OBSOLETE_INPUT:-7,END_OF_BLOCK:-8},ou={};ou[su.LAST_BLOCK]="Bad file checksum",ou[su.NOT_BZIP_DATA]="Not bzip data",ou[su.UNEXPECTED_INPUT_EOF]="Unexpected input EOF",ou[su.UNEXPECTED_OUTPUT_EOF]="Unexpected output EOF",ou[su.DATA_ERROR]="Data error",ou[su.OUT_OF_MEMORY]="Out of memory",ou[su.OBSOLETE_INPUT]="Obsolete (pre 0.9.5) bzip format not supported.";var cu=function(e,t){var r=ou[e]||"unknown error";t&&(r+=": "+t);var i=new TypeError(r);throw i.errorCode=e,i},uu=function(e,t){this.writePos=this.writeCurrent=this.writeCount=0,this._start_bunzip(e,t)};uu.prototype._init_block=function(){return this._get_next_block()?(this.blockCRC=new nu,!0):(this.writeCount=-1,!1)},uu.prototype._start_bunzip=function(e,t){var r=new Uint8Array(4);4===e.read(r,0,4)&&"BZh"===String.fromCharCode(r[0],r[1],r[2])||cu(su.NOT_BZIP_DATA,"bad magic");var i=r[3]-48;(i<1||i>9)&&cu(su.NOT_BZIP_DATA,"level out of range"),this.reader=new eu(e),this.dbufSize=1e5*i,this.nextoutput=0,this.outputStream=t,this.streamCRC=0},uu.prototype._get_next_block=function(){var e,t,r,i=this.reader,n=i.pi();if("177245385090"===n)return!1;"314159265359"!==n&&cu(su.NOT_BZIP_DATA),this.targetBlockCRC=i.read(32)>>>0,this.streamCRC=(this.targetBlockCRC^(this.streamCRC<<1|this.streamCRC>>>31))>>>0,i.read(1)&&cu(su.OBSOLETE_INPUT);var a=i.read(24);a>this.dbufSize&&cu(su.DATA_ERROR,"initial position out of bounds");var s=i.read(16),o=new Uint8Array(256),c=0;for(e=0;e<16;e++)if(s&1<<15-e){var u=16*e;for(r=i.read(16),t=0;t<16;t++)r&1<<15-t&&(o[c++]=u+t)}var h=i.read(3);(h<2||h>6)&&cu(su.DATA_ERROR);var d=i.read(15);0===d&&cu(su.DATA_ERROR);var f=new Uint8Array(256);for(e=0;e=h&&cu(su.DATA_ERROR);l[e]=au(f,t)}var p,y=c+2,b=[];for(t=0;t20)&&cu(su.DATA_ERROR),i.read(1);)i.read(1)?s--:s++;w[e]=s}for(m=g=w[0],e=1;eg?g=w[e]:w[e]=d&&cu(su.DATA_ERROR),p=b[l[P++]]),e=p.minLen,t=i.read(e);e>p.maxLen&&cu(su.DATA_ERROR),!(t<=p.limit[e]);e++)t=t<<1|i.read(1);((t-=p.base[e])<0||t>=258)&&cu(su.DATA_ERROR);var M=p.permute[t];if(0!==M&&1!==M){if(S)for(S=0,E+s>this.dbufSize&&cu(su.DATA_ERROR),k[A=o[f[0]]]+=s;s--;)x[E++]=A;if(M>c)break;E>=this.dbufSize&&cu(su.DATA_ERROR),k[A=o[A=au(f,e=M-1)]]++,x[E++]=A}else S||(S=1,s=0),s+=0===M?S:2*S,S<<=1}for((a<0||a>=E)&&cu(su.DATA_ERROR),t=0,e=0;e<256;e++)r=t+k[e],k[e]=t,t=r;for(e=0;e>=8,D=-1),this.writePos=K,this.writeCurrent=C,this.writeCount=E,this.writeRun=D,!0},uu.prototype._read_bunzip=function(e,t){var r,i,n;if(this.writeCount<0)return 0;var a=this.dbuf,s=this.writePos,o=this.writeCurrent,c=this.writeCount;this.outputsize;for(var u=this.writeRun;c;){for(c--,i=o,o=255&(s=a[s]),s>>=8,3==u++?(r=o,n=i,o=-1):(r=1,n=o),this.blockCRC.updateCRCRun(n,r);r--;)this.outputStream.writeByte(n),this.nextoutput++;o!=i&&(u=0)}return this.writeCount=c,this.blockCRC.getCRC()!==this.targetBlockCRC&&cu(su.DATA_ERROR,"Bad block CRC (got "+this.blockCRC.getCRC().toString(16)+" expected "+this.targetBlockCRC.toString(16)+")"),this.nextoutput};var hu=function(e){if("readByte"in e)return e;var t=new iu;return t.pos=0,t.readByte=function(){return e[this.pos++]},t.seek=function(e){this.pos=e},t.eof=function(){return this.pos>=e.length},t},du=function(e){var t=new iu,r=!0;if(e)if("number"==typeof e)t.buffer=new Uint8Array(e),r=!1;else{if("writeByte"in e)return e;t.buffer=e,r=!1}else t.buffer=new Uint8Array(16384);return t.pos=0,t.writeByte=function(e){if(r&&this.pos>=this.buffer.length){var t=new Uint8Array(2*this.buffer.length);t.set(this.buffer),this.buffer=t}this.buffer[this.pos++]=e},t.getBuffer=function(){if(this.pos!==this.buffer.length){if(!r)throw new TypeError("outputsize does not match decoded input");var e=new Uint8Array(this.pos);e.set(this.buffer.subarray(0,this.pos)),this.buffer=e}return this.buffer},t._coerced=!0,t};var fu=function(e,t,r){for(var i=hu(e),n=du(t),a=new uu(i,n);!("eof"in i)||!i.eof();)if(a._init_block())a._read_bunzip();else{var s=a.reader.read(32)>>>0;if(s!==a.streamCRC&&cu(su.DATA_ERROR,"Bad stream CRC (got "+a.streamCRC.toString(16)+" expected "+s.toString(16)+")"),!r||!("eof"in i)||i.eof())break;a._start_bunzip(i,n)}if("getBuffer"in n)return n.getBuffer()};class lu{static get tag(){return te.packet.literalData}constructor(e=new Date){this.format=te.literal.utf8,this.date=ie.normalizeDate(e),this.text=null,this.data=null,this.filename=""}setText(e,t=te.literal.utf8){this.format=t,this.text=e,this.data=null}getText(e=!1){return(null===this.text||ie.isStream(this.text))&&(this.text=ie.decodeUTF8(ie.nativeEOL(this.getBytes(e)))),this.text}setBytes(e,t){this.format=t,this.data=e,this.text=null}getBytes(e=!1){return null===this.data&&(this.data=ie.canonicalizeEOL(ie.encodeUTF8(this.text))),e?G(this.data):this.data}setFilename(e){this.filename=e}getFilename(){return this.filename}async read(e){await W(e,(async e=>{const t=await e.readByte(),r=await e.readByte();this.filename=ie.decodeUTF8(await e.readBytes(r)),this.date=ie.readDate(await e.readBytes(4));let i=e.remainder();l(i)&&(i=await Z(i)),this.setBytes(i,t)}))}writeHeader(){const e=ie.encodeUTF8(this.filename),t=new Uint8Array([e.length]),r=new Uint8Array([this.format]),i=ie.writeDate(this.date);return ie.concatUint8Array([r,t,e,i])}write(){const e=this.writeHeader(),t=this.getBytes();return ie.concat([e,t])}}const pu=Symbol("verified"),yu=new Set([te.signatureSubpacket.issuer,te.signatureSubpacket.issuerFingerprint,te.signatureSubpacket.embeddedSignature]);class bu{static get tag(){return te.packet.signature}constructor(){this.version=null,this.signatureType=null,this.hashAlgorithm=null,this.publicKeyAlgorithm=null,this.signatureData=null,this.unhashedSubpackets=[],this.signedHashValue=null,this.created=null,this.signatureExpirationTime=null,this.signatureNeverExpires=!0,this.exportable=null,this.trustLevel=null,this.trustAmount=null,this.regularExpression=null,this.revocable=null,this.keyExpirationTime=null,this.keyNeverExpires=null,this.preferredSymmetricAlgorithms=null,this.revocationKeyClass=null,this.revocationKeyAlgorithm=null,this.revocationKeyFingerprint=null,this.issuerKeyID=new _e,this.rawNotations=[],this.notations={},this.preferredHashAlgorithms=null,this.preferredCompressionAlgorithms=null,this.keyServerPreferences=null,this.preferredKeyServer=null,this.isPrimaryUserID=null,this.policyURI=null,this.keyFlags=null,this.signersUserID=null,this.reasonForRevocationFlag=null,this.reasonForRevocationString=null,this.features=null,this.signatureTargetPublicKeyAlgorithm=null,this.signatureTargetHashAlgorithm=null,this.signatureTargetHash=null,this.embeddedSignature=null,this.issuerKeyVersion=null,this.issuerFingerprint=null,this.preferredAEADAlgorithms=null,this.revoked=null,this[pu]=null}read(e){let t=0;if(this.version=e[t++],4!==this.version&&5!==this.version)throw new Sn(`Version ${this.version} of the signature packet is unsupported.`);if(this.signatureType=e[t++],this.publicKeyAlgorithm=e[t++],this.hashAlgorithm=e[t++],t+=this.readSubPackets(e.subarray(t,e.length),!0),!this.created)throw Error("Missing signature creation time subpacket.");this.signatureData=e.subarray(0,t),t+=this.readSubPackets(e.subarray(t,e.length),!1),this.signedHashValue=e.subarray(t,t+2),t+=2,this.params=Ea.signature.parseSignatureParams(this.publicKeyAlgorithm,e.subarray(t,e.length))}writeParams(){return this.params instanceof Promise?Y((async()=>Ea.serializeParams(this.publicKeyAlgorithm,await this.params))):Ea.serializeParams(this.publicKeyAlgorithm,this.params)}write(){const e=[];return e.push(this.signatureData),e.push(this.writeUnhashedSubPackets()),e.push(this.signedHashValue),e.push(this.writeParams()),ie.concat(e)}async sign(e,t,r=new Date,i=!1){5===e.version?this.version=5:this.version=4;const n=[new Uint8Array([this.version,this.signatureType,this.publicKeyAlgorithm,this.hashAlgorithm])];this.created=ie.normalizeDate(r),this.issuerKeyVersion=e.version,this.issuerFingerprint=e.getFingerprintBytes(),this.issuerKeyID=e.getKeyID(),n.push(this.writeHashedSubPackets()),this.unhashedSubpackets=[],this.signatureData=ie.concat(n);const a=this.toHash(this.signatureType,t,i),s=await this.hash(this.signatureType,t,a,i);this.signedHashValue=$(H(s),0,2);const o=async()=>Ea.signature.sign(this.publicKeyAlgorithm,this.hashAlgorithm,e.publicParams,e.privateParams,a,await Z(s));ie.isStream(s)?this.params=o():(this.params=await o(),this[pu]=!0)}writeHashedSubPackets(){const e=te.signatureSubpacket,t=[];let r;if(null===this.created)throw Error("Missing signature creation time");t.push(mu(e.signatureCreationTime,!0,ie.writeDate(this.created))),null!==this.signatureExpirationTime&&t.push(mu(e.signatureExpirationTime,!0,ie.writeNumber(this.signatureExpirationTime,4))),null!==this.exportable&&t.push(mu(e.exportableCertification,!0,new Uint8Array([this.exportable?1:0]))),null!==this.trustLevel&&(r=new Uint8Array([this.trustLevel,this.trustAmount]),t.push(mu(e.trustSignature,!0,r))),null!==this.regularExpression&&t.push(mu(e.regularExpression,!0,this.regularExpression)),null!==this.revocable&&t.push(mu(e.revocable,!0,new Uint8Array([this.revocable?1:0]))),null!==this.keyExpirationTime&&t.push(mu(e.keyExpirationTime,!0,ie.writeNumber(this.keyExpirationTime,4))),null!==this.preferredSymmetricAlgorithms&&(r=ie.stringToUint8Array(ie.uint8ArrayToString(this.preferredSymmetricAlgorithms)),t.push(mu(e.preferredSymmetricAlgorithms,!1,r))),null!==this.revocationKeyClass&&(r=new Uint8Array([this.revocationKeyClass,this.revocationKeyAlgorithm]),r=ie.concat([r,this.revocationKeyFingerprint]),t.push(mu(e.revocationKey,!1,r))),this.issuerKeyID.isNull()||5===this.issuerKeyVersion||t.push(mu(e.issuer,!0,this.issuerKeyID.write())),this.rawNotations.forEach((({name:i,value:n,humanReadable:a,critical:s})=>{r=[new Uint8Array([a?128:0,0,0,0])];const o=ie.encodeUTF8(i);r.push(ie.writeNumber(o.length,2)),r.push(ie.writeNumber(n.length,2)),r.push(o),r.push(n),r=ie.concat(r),t.push(mu(e.notationData,s,r))})),null!==this.preferredHashAlgorithms&&(r=ie.stringToUint8Array(ie.uint8ArrayToString(this.preferredHashAlgorithms)),t.push(mu(e.preferredHashAlgorithms,!1,r))),null!==this.preferredCompressionAlgorithms&&(r=ie.stringToUint8Array(ie.uint8ArrayToString(this.preferredCompressionAlgorithms)),t.push(mu(e.preferredCompressionAlgorithms,!1,r))),null!==this.keyServerPreferences&&(r=ie.stringToUint8Array(ie.uint8ArrayToString(this.keyServerPreferences)),t.push(mu(e.keyServerPreferences,!1,r))),null!==this.preferredKeyServer&&t.push(mu(e.preferredKeyServer,!1,ie.encodeUTF8(this.preferredKeyServer))),null!==this.isPrimaryUserID&&t.push(mu(e.primaryUserID,!1,new Uint8Array([this.isPrimaryUserID?1:0]))),null!==this.policyURI&&t.push(mu(e.policyURI,!1,ie.encodeUTF8(this.policyURI))),null!==this.keyFlags&&(r=ie.stringToUint8Array(ie.uint8ArrayToString(this.keyFlags)),t.push(mu(e.keyFlags,!0,r))),null!==this.signersUserID&&t.push(mu(e.signersUserID,!1,ie.encodeUTF8(this.signersUserID))),null!==this.reasonForRevocationFlag&&(r=ie.stringToUint8Array(String.fromCharCode(this.reasonForRevocationFlag)+this.reasonForRevocationString),t.push(mu(e.reasonForRevocation,!0,r))),null!==this.features&&(r=ie.stringToUint8Array(ie.uint8ArrayToString(this.features)),t.push(mu(e.features,!1,r))),null!==this.signatureTargetPublicKeyAlgorithm&&(r=[new Uint8Array([this.signatureTargetPublicKeyAlgorithm,this.signatureTargetHashAlgorithm])],r.push(ie.stringToUint8Array(this.signatureTargetHash)),r=ie.concat(r),t.push(mu(e.signatureTarget,!0,r))),null!==this.embeddedSignature&&t.push(mu(e.embeddedSignature,!0,this.embeddedSignature.write())),null!==this.issuerFingerprint&&(r=[new Uint8Array([this.issuerKeyVersion]),this.issuerFingerprint],r=ie.concat(r),t.push(mu(e.issuerFingerprint,5===this.version,r))),null!==this.preferredAEADAlgorithms&&(r=ie.stringToUint8Array(ie.uint8ArrayToString(this.preferredAEADAlgorithms)),t.push(mu(e.preferredAEADAlgorithms,!1,r)));const i=ie.concat(t),n=ie.writeNumber(i.length,2);return ie.concat([n,i])}writeUnhashedSubPackets(){const e=[];this.unhashedSubpackets.forEach((t=>{e.push(gn(t.length)),e.push(t)}));const t=ie.concat(e),r=ie.writeNumber(t.length,2);return ie.concat([r,t])}readSubPacket(e,t=!0){let r=0;const i=!!(128&e[r]),n=127&e[r];if(t||(this.unhashedSubpackets.push(e.subarray(r,e.length)),yu.has(n)))switch(r++,n){case te.signatureSubpacket.signatureCreationTime:this.created=ie.readDate(e.subarray(r,e.length));break;case te.signatureSubpacket.signatureExpirationTime:{const t=ie.readNumber(e.subarray(r,e.length));this.signatureNeverExpires=0===t,this.signatureExpirationTime=t;break}case te.signatureSubpacket.exportableCertification:this.exportable=1===e[r++];break;case te.signatureSubpacket.trustSignature:this.trustLevel=e[r++],this.trustAmount=e[r++];break;case te.signatureSubpacket.regularExpression:this.regularExpression=e[r];break;case te.signatureSubpacket.revocable:this.revocable=1===e[r++];break;case te.signatureSubpacket.keyExpirationTime:{const t=ie.readNumber(e.subarray(r,e.length));this.keyExpirationTime=t,this.keyNeverExpires=0===t;break}case te.signatureSubpacket.preferredSymmetricAlgorithms:this.preferredSymmetricAlgorithms=[...e.subarray(r,e.length)];break;case te.signatureSubpacket.revocationKey:this.revocationKeyClass=e[r++],this.revocationKeyAlgorithm=e[r++],this.revocationKeyFingerprint=e.subarray(r,r+20);break;case te.signatureSubpacket.issuer:this.issuerKeyID.read(e.subarray(r,e.length));break;case te.signatureSubpacket.notationData:{const t=!!(128&e[r]);r+=4;const n=ie.readNumber(e.subarray(r,r+2));r+=2;const a=ie.readNumber(e.subarray(r,r+2));r+=2;const s=ie.decodeUTF8(e.subarray(r,r+n)),o=e.subarray(r+n,r+n+a);this.rawNotations.push({name:s,humanReadable:t,value:o,critical:i}),t&&(this.notations[s]=ie.decodeUTF8(o));break}case te.signatureSubpacket.preferredHashAlgorithms:this.preferredHashAlgorithms=[...e.subarray(r,e.length)];break;case te.signatureSubpacket.preferredCompressionAlgorithms:this.preferredCompressionAlgorithms=[...e.subarray(r,e.length)];break;case te.signatureSubpacket.keyServerPreferences:this.keyServerPreferences=[...e.subarray(r,e.length)];break;case te.signatureSubpacket.preferredKeyServer:this.preferredKeyServer=ie.decodeUTF8(e.subarray(r,e.length));break;case te.signatureSubpacket.primaryUserID:this.isPrimaryUserID=0!==e[r++];break;case te.signatureSubpacket.policyURI:this.policyURI=ie.decodeUTF8(e.subarray(r,e.length));break;case te.signatureSubpacket.keyFlags:this.keyFlags=[...e.subarray(r,e.length)];break;case te.signatureSubpacket.signersUserID:this.signersUserID=ie.decodeUTF8(e.subarray(r,e.length));break;case te.signatureSubpacket.reasonForRevocation:this.reasonForRevocationFlag=e[r++],this.reasonForRevocationString=ie.decodeUTF8(e.subarray(r,e.length));break;case te.signatureSubpacket.features:this.features=[...e.subarray(r,e.length)];break;case te.signatureSubpacket.signatureTarget:{this.signatureTargetPublicKeyAlgorithm=e[r++],this.signatureTargetHashAlgorithm=e[r++];const t=Ea.getHashByteLength(this.signatureTargetHashAlgorithm);this.signatureTargetHash=ie.uint8ArrayToString(e.subarray(r,r+t));break}case te.signatureSubpacket.embeddedSignature:this.embeddedSignature=new bu,this.embeddedSignature.read(e.subarray(r,e.length));break;case te.signatureSubpacket.issuerFingerprint:this.issuerKeyVersion=e[r++],this.issuerFingerprint=e.subarray(r,e.length),5===this.issuerKeyVersion?this.issuerKeyID.read(this.issuerFingerprint):this.issuerKeyID.read(this.issuerFingerprint.subarray(-8));break;case te.signatureSubpacket.preferredAEADAlgorithms:this.preferredAEADAlgorithms=[...e.subarray(r,e.length)];break;default:{const e=Error("Unknown signature subpacket type "+n);if(i)throw e;ie.printDebug(e)}}}readSubPackets(e,t=!0,r){const i=ie.readNumber(e.subarray(0,2));let n=2;for(;n<2+i;){const i=mn(e.subarray(n,e.length));n+=i.offset,this.readSubPacket(e.subarray(n,n+i.len),t,r),n+=i.len}return n}toSign(e,t){const r=te.signature;switch(e){case r.binary:return null!==t.text?ie.encodeUTF8(t.getText(!0)):t.getBytes(!0);case r.text:{const e=t.getBytes(!0);return ie.canonicalizeEOL(e)}case r.standalone:return new Uint8Array(0);case r.certGeneric:case r.certPersona:case r.certCasual:case r.certPositive:case r.certRevocation:{let e,i;if(t.userID)i=180,e=t.userID;else{if(!t.userAttribute)throw Error("Either a userID or userAttribute packet needs to be supplied for certification.");i=209,e=t.userAttribute}const n=e.write();return ie.concat([this.toSign(r.key,t),new Uint8Array([i]),ie.writeNumber(n.length,4),n])}case r.subkeyBinding:case r.subkeyRevocation:case r.keyBinding:return ie.concat([this.toSign(r.key,t),this.toSign(r.key,{key:t.bind})]);case r.key:if(void 0===t.key)throw Error("Key packet is required for this signature.");return t.key.writeForHash(this.version);case r.keyRevocation:return this.toSign(r.key,t);case r.timestamp:return new Uint8Array(0);case r.thirdParty:throw Error("Not implemented");default:throw Error("Unknown signature type.")}}calculateTrailer(e,t){let r=0;return N(H(this.signatureData),(e=>{r+=e.length}),(()=>{const i=[];return 5!==this.version||this.signatureType!==te.signature.binary&&this.signatureType!==te.signature.text||(t?i.push(new Uint8Array(6)):i.push(e.writeHeader())),i.push(new Uint8Array([this.version,255])),5===this.version&&i.push(new Uint8Array(4)),i.push(ie.writeNumber(r,4)),ie.concat(i)}))}toHash(e,t,r=!1){const i=this.toSign(e,t);return ie.concat([i,this.signatureData,this.calculateTrailer(t,r)])}async hash(e,t,r,i=!1){return r||(r=this.toHash(e,t,i)),Ea.hash.digest(this.hashAlgorithm,r)}async verify(e,t,r,i=new Date,n=!1,a=de){if(!this.issuerKeyID.equals(e.getKeyID()))throw Error("Signature was not issued by the given public key");if(this.publicKeyAlgorithm!==e.algorithm)throw Error("Public key algorithm used to sign signature does not match issuer key algorithm.");const s=t===te.signature.binary||t===te.signature.text;if(!(this[pu]&&!s)){let i,a;if(this.hashed?a=await this.hashed:(i=this.toHash(t,r,n),a=await this.hash(t,r,i)),a=await Z(a),this.signedHashValue[0]!==a[0]||this.signedHashValue[1]!==a[1])throw Error("Signed digest did not match");if(this.params=await this.params,this[pu]=await Ea.signature.verify(this.publicKeyAlgorithm,this.hashAlgorithm,this.params,e.publicParams,i,a),!this[pu])throw Error("Signature verification failed")}const o=ie.normalizeDate(i);if(o&&this.created>o)throw Error("Signature creation time is in the future");if(o&&o>=this.getExpirationTime())throw Error("Signature is expired");if(a.rejectHashAlgorithms.has(this.hashAlgorithm))throw Error("Insecure hash algorithm: "+te.read(te.hash,this.hashAlgorithm).toUpperCase());if(a.rejectMessageHashAlgorithms.has(this.hashAlgorithm)&&[te.signature.binary,te.signature.text].includes(this.signatureType))throw Error("Insecure message hash algorithm: "+te.read(te.hash,this.hashAlgorithm).toUpperCase());if(this.rawNotations.forEach((({name:e,critical:t})=>{if(t&&a.knownNotations.indexOf(e)<0)throw Error("Unknown critical notation: "+e)})),null!==this.revocationKeyClass)throw Error("This key is intended to be revoked with an authorized key, which OpenPGP.js does not support.")}isExpired(e=new Date){const t=ie.normalizeDate(e);return null!==t&&!(this.created<=t&&tbu.prototype.calculateTrailer.apply(await this.correspondingSig,e)))}async verify(){const e=await this.correspondingSig;if(!e||e.constructor.tag!==te.packet.signature)throw Error("Corresponding signature packet missing");if(e.signatureType!==this.signatureType||e.hashAlgorithm!==this.hashAlgorithm||e.publicKeyAlgorithm!==this.publicKeyAlgorithm||!e.issuerKeyID.equals(this.issuerKeyID))throw Error("Corresponding signature packet does not match one-pass signature packet");return e.hashed=this.hashed,e.verify.apply(e,arguments)}}function wu(e,t){if(!t[e]){let t;try{t=te.read(te.packet,e)}catch(t){throw new Sn("Unknown packet type with tag: "+e)}throw Error("Packet not allowed in this context: "+t)}return new t[e]}gu.prototype.hash=bu.prototype.hash,gu.prototype.toHash=bu.prototype.toHash,gu.prototype.toSign=bu.prototype.toSign;class vu extends Array{static async fromBinary(e,t,r=de){const i=new vu;return await i.read(e,t,r),i}async read(e,t,r=de){r.additionalAllowedPackets.length&&(t={...t,...ie.constructAllowedPackets(r.additionalAllowedPackets)}),this.stream=j(e,(async(e,i)=>{const n=q(i);try{for(;;){await n.ready;if(await An(e,(async e=>{try{if(e.tag===te.packet.marker||e.tag===te.packet.trust)return;const i=wu(e.tag,t);i.packets=new vu,i.fromStream=ie.isStream(e.packet),await i.read(e.packet,r),await n.write(i)}catch(t){const i=!r.ignoreUnsupportedPackets&&t instanceof Sn,a=!(r.ignoreMalformedPackets||t instanceof Sn);if(i||a||kn(e.tag))await n.abort(t);else{const t=new En(e.tag,e.packet);await n.write(t)}ie.printDebugError(t)}})))return await n.ready,void await n.close()}}catch(e){await n.abort(e)}}));const i=z(this.stream);for(;;){const{done:e,value:t}=await i.read();if(e?this.stream=null:this.push(t),e||kn(t.constructor.tag))break}i.releaseLock()}write(){const e=[];for(let t=0;t{if(t.push(e),n+=e.length,n>=a){const e=Math.min(Math.log(n)/Math.LN2|0,30),r=2**e,i=ie.concat([wn(e)].concat(t));return t=[i.subarray(1+r)],n=t[0].length,i.subarray(0,1+r)}}),(()=>ie.concat([gn(n)].concat(t)))))}else{if(ie.isStream(i)){let t=0;e.push(N(H(i),(e=>{t+=e.length}),(()=>_n(r,t))))}else e.push(_n(r,i.length));e.push(i)}}return ie.concat(e)}filterByTag(...e){const t=new vu,r=e=>t=>e===t;for(let i=0;it.constructor.tag===e))}indexOfTag(...e){const t=[],r=this,i=e=>t=>e===t;for(let n=0;n{this.algorithm=await e.readByte(),this.compressed=e.remainder(),await this.decompress(t)}))}write(){return null===this.compressed&&this.compress(),ie.concat([new Uint8Array([this.algorithm]),this.compressed])}async decompress(e=de){const t=te.read(te.compression,this.algorithm),r=Ku[t];if(!r)throw Error(t+" decompression not supported");this.packets=await vu.fromBinary(r(this.compressed),_u,e)}compress(){const e=te.read(te.compression,this.algorithm),t=Mu[e];if(!t)throw Error(e+" compression not supported");this.compressed=t(this.packets.write(),this.deflateLevel)}}const Au=ie.getNodeZlib();function Su(e){return e}function Eu(e,t,r={}){return function(i){return!ie.isStream(i)||l(i)?Y((()=>Z(i).then((t=>new Promise(((i,n)=>{e(t,r,((e,t)=>{if(e)return n(e);i(t)}))})))))):k(A(i).pipe(t(r)))}}function Pu(e,t={}){return function(r){const i=new e(t);return N(r,(e=>{if(e.length)return i.push(e,za),i.result}),(()=>{if(e===jo)return i.push([],Fa),i.result}))}}function xu(e){return function(t){return Y((async()=>e(await Z(t))))}}const Mu=Au?{zip:/*#__PURE__*/(e,t)=>Eu(Au.deflateRaw,Au.createDeflateRaw,{level:t})(e),zlib:/*#__PURE__*/(e,t)=>Eu(Au.deflate,Au.createDeflate,{level:t})(e)}:{zip:/*#__PURE__*/(e,t)=>Pu(jo,{raw:!0,level:t})(e),zlib:/*#__PURE__*/(e,t)=>Pu(jo,{level:t})(e)},Ku=Au?{uncompressed:Su,zip:/*#__PURE__*/Eu(Au.inflateRaw,Au.createInflateRaw),zlib:/*#__PURE__*/Eu(Au.inflate,Au.createInflate),bzip2:/*#__PURE__*/xu(fu)}:{uncompressed:Su,zip:/*#__PURE__*/Pu(Yc,{raw:!0}),zlib:/*#__PURE__*/Pu(Yc),bzip2:/*#__PURE__*/xu(fu)},Cu=/*#__PURE__*/ie.constructAllowedPackets([lu,ku,gu,bu]);class Du{static get tag(){return te.packet.symEncryptedIntegrityProtectedData}constructor(){this.version=1,this.encrypted=null,this.packets=null}async read(e){await W(e,(async e=>{const t=await e.readByte();if(1!==t)throw new Sn(`Version ${t} of the SEIP packet is unsupported.`);this.encrypted=e.remainder()}))}write(){return ie.concat([new Uint8Array([1]),this.encrypted])}async encrypt(e,t,r=de){const{blockSize:i}=Ea.getCipher(e);let n=this.packets.write();l(n)&&(n=await Z(n));const a=await Ea.getPrefixRandom(e),s=new Uint8Array([211,20]),o=ie.concat([a,n,s]),c=await Ea.hash.sha1(G(o)),u=ie.concat([o,c]);return this.encrypted=await Ea.mode.cfb.encrypt(e,t,u,new Uint8Array(i),r),!0}async decrypt(e,t,r=de){const{blockSize:i}=Ea.getCipher(e);let n=H(this.encrypted);l(n)&&(n=await Z(n));const a=await Ea.mode.cfb.decrypt(e,t,n,new Uint8Array(i)),s=$(G(a),-20),o=$(a,0,-20),c=Promise.all([Z(await Ea.hash.sha1(G(o))),Z(s)]).then((([e,t])=>{if(!ie.equalsUint8Array(e,t))throw Error("Modification detected.");return new Uint8Array})),u=$(o,i+2);let h=$(u,0,-2);return h=T([h,Y((()=>c))]),ie.isStream(n)&&r.allowUnauthenticatedStream||(h=await Z(h)),this.packets=await vu.fromBinary(h,Cu,r),!0}}const Uu=/*#__PURE__*/ie.constructAllowedPackets([lu,ku,gu,bu]);class Ru{static get tag(){return te.packet.aeadEncryptedData}constructor(){this.version=1,this.cipherAlgorithm=null,this.aeadAlgorithm=te.aead.eax,this.chunkSizeByte=null,this.iv=null,this.encrypted=null,this.packets=null}async read(e){await W(e,(async e=>{const t=await e.readByte();if(1!==t)throw new Sn(`Version ${t} of the AEAD-encrypted data packet is not supported.`);this.cipherAlgorithm=await e.readByte(),this.aeadAlgorithm=await e.readByte(),this.chunkSizeByte=await e.readByte();const r=Ea.getAEADMode(this.aeadAlgorithm);this.iv=await e.readBytes(r.ivLength),this.encrypted=e.remainder()}))}write(){return ie.concat([new Uint8Array([this.version,this.cipherAlgorithm,this.aeadAlgorithm,this.chunkSizeByte]),this.iv,this.encrypted])}async decrypt(e,t,r=de){this.packets=await vu.fromBinary(await this.crypt("decrypt",t,H(this.encrypted)),Uu,r)}async encrypt(e,t,r=de){this.cipherAlgorithm=e;const{ivLength:i}=Ea.getAEADMode(this.aeadAlgorithm);this.iv=Ea.random.getRandomBytes(i),this.chunkSizeByte=r.aeadChunkSizeByte;const n=this.packets.write();this.encrypted=await this.crypt("encrypt",t,n)}async crypt(e,t,r){const i=Ea.getAEADMode(this.aeadAlgorithm),n=await i(this.cipherAlgorithm,t),a="decrypt"===e?i.tagLength:0,s="encrypt"===e?i.tagLength:0,o=2**(this.chunkSizeByte+6)+a,c=new ArrayBuffer(21),u=new Uint8Array(c,0,13),h=new Uint8Array(c),d=new DataView(c),f=new Uint8Array(c,5,8);u.set([192|Ru.tag,this.version,this.cipherAlgorithm,this.aeadAlgorithm,this.chunkSizeByte],0);let l=0,p=Promise.resolve(),y=0,b=0;const m=this.iv;return j(r,(async(t,r)=>{if("array"!==ie.isStream(t)){const e=new D({},{highWaterMark:ie.getHardwareConcurrency()*2**(this.chunkSizeByte+6),size:e=>e.length});F(e.readable,r),r=e.writable}const c=z(t),g=q(r);try{for(;;){let t=await c.readBytes(o+a)||new Uint8Array;const r=t.subarray(t.length-a);let w,v;if(t=t.subarray(0,t.length-a),!l||t.length?(c.unshift(r),w=n[e](t,i.getNonce(m,f),u),b+=t.length-a+s):(d.setInt32(17,y),w=n[e](r,i.getNonce(m,f),h),b+=s,v=!0),y+=t.length-a,p=p.then((()=>w)).then((async e=>{await g.ready,await g.write(e),b-=e.length})).catch((e=>g.abort(e))),(v||b>g.desiredSize)&&await p,v){await g.close();break}d.setInt32(9,++l)}}catch(e){await g.abort(e)}}))}}class Iu{static get tag(){return te.packet.publicKeyEncryptedSessionKey}constructor(){this.version=3,this.publicKeyID=new _e,this.publicKeyAlgorithm=null,this.sessionKey=null,this.sessionKeyAlgorithm=null,this.encrypted={}}read(e){let t=0;if(this.version=e[t++],3!==this.version)throw new Sn(`Version ${this.version} of the PKESK packet is unsupported.`);t+=this.publicKeyID.read(e.subarray(t)),this.publicKeyAlgorithm=e[t++],this.encrypted=Ea.parseEncSessionKeyParams(this.publicKeyAlgorithm,e.subarray(t),this.version),this.publicKeyAlgorithm===te.publicKey.x25519&&(this.sessionKeyAlgorithm=te.write(te.symmetric,this.encrypted.C.algorithm))}write(){const e=[new Uint8Array([this.version]),this.publicKeyID.write(),new Uint8Array([this.publicKeyAlgorithm]),Ea.serializeParams(this.publicKeyAlgorithm,this.encrypted)];return ie.concatUint8Array(e)}async encrypt(e){const t=te.write(te.publicKey,this.publicKeyAlgorithm),r=Bu(this.version,t,this.sessionKeyAlgorithm,this.sessionKey);this.encrypted=await Ea.publicKeyEncrypt(t,this.sessionKeyAlgorithm,e.publicParams,r,e.getFingerprintBytes())}async decrypt(e,t){if(this.publicKeyAlgorithm!==e.algorithm)throw Error("Decryption error");const r=t?Bu(this.version,this.publicKeyAlgorithm,t.sessionKeyAlgorithm,t.sessionKey):null,i=await Ea.publicKeyDecrypt(this.publicKeyAlgorithm,e.publicParams,e.privateParams,this.encrypted,e.getFingerprintBytes(),r),{sessionKey:n,sessionKeyAlgorithm:a}=function(e,t,r,i){switch(t){case te.publicKey.rsaEncrypt:case te.publicKey.rsaEncryptSign:case te.publicKey.elgamal:case te.publicKey.ecdh:{const e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=ie.writeChecksum(e.subarray(e.length%8)),a=n[0]===t[0]&n[1]===t[1],s={sessionKeyAlgorithm:e[0],sessionKey:e.subarray(1)};if(i){const e=a&s.sessionKeyAlgorithm===i.sessionKeyAlgorithm&s.sessionKey.length===i.sessionKey.length;return{sessionKey:ie.selectUint8Array(e,s.sessionKey,i.sessionKey),sessionKeyAlgorithm:ie.selectUint8(e,s.sessionKeyAlgorithm,i.sessionKeyAlgorithm)}}if(a&&te.read(te.symmetric,s.sessionKeyAlgorithm))return s;throw Error("Decryption error")}case te.publicKey.x25519:return{sessionKey:r};default:throw Error("Unsupported public key algorithm")}}(this.version,this.publicKeyAlgorithm,i,t);this.publicKeyAlgorithm!==te.publicKey.x25519&&(this.sessionKeyAlgorithm=a),this.sessionKey=n}}function Bu(e,t,r,i){switch(t){case te.publicKey.rsaEncrypt:case te.publicKey.rsaEncryptSign:case te.publicKey.elgamal:case te.publicKey.ecdh:return ie.concatUint8Array([new Uint8Array([r]),i,ie.writeChecksum(i.subarray(i.length%8))]);case te.publicKey.x25519:return i;default:throw Error("Unsupported public key algorithm")}}class Tu{constructor(e=de){this.algorithm=te.hash.sha256,this.type="iterated",this.c=e.s2kIterationCountByte,this.salt=null}getCount(){return 16+(15&this.c)<<6+(this.c>>4)}read(e){let t=0;try{this.type=te.read(te.s2k,e[t++])}catch(e){throw new Sn("Unknown S2K type.")}switch(this.algorithm=e[t++],this.type){case"simple":break;case"salted":this.salt=e.subarray(t,t+8),t+=8;break;case"iterated":this.salt=e.subarray(t,t+8),t+=8,this.c=e[t++];break;case"gnu":if("GNU"!==ie.uint8ArrayToString(e.subarray(t,t+3)))throw new Sn("Unknown s2k type.");t+=3;if(1001!==1e3+e[t++])throw new Sn("Unknown s2k gnu protection mode.");this.type="gnu-dummy";break;default:throw new Sn("Unknown s2k type.")}return t}write(){if("gnu-dummy"===this.type)return new Uint8Array([101,0,...ie.stringToUint8Array("GNU"),1]);const e=[new Uint8Array([te.write(te.s2k,this.type),this.algorithm])];switch(this.type){case"simple":break;case"salted":e.push(this.salt);break;case"iterated":e.push(this.salt),e.push(new Uint8Array([this.c]));break;case"gnu":throw Error("GNU s2k type not supported.");default:throw Error("Unknown s2k type.")}return ie.concatUint8Array(e)}async produceKey(e,t){e=ie.encodeUTF8(e);const r=[];let i=0,n=0;for(;i{this.privateParams[e].fill(0),delete this.privateParams[e]})),this.privateParams=null,this.isEncrypted=!0)}}async function Hu(e,t,r){const{keySize:i}=Ea.getCipher(r);return e.produceKey(t,i)}var Gu=ht((function(e){!function(t){function r(e){function t(){return Ae0&&(t.semantic=" "),t}}function b(e,t){return function(){var i,a,o,u,h;for(u=r(),i=s("star"),o=0,h=void 0===t?0:t;null!==(a=e());)o+=1,c(i,a);return o>=h?i:(n(u),null)}}function m(e){return e.charCodeAt(0)>=128}function g(){return o("cr",h("\r")())}function w(){return o("crlf",d(g,k)())}function v(){return o("dquote",h('"')())}function _(){return o("htab",h("\t")())}function k(){return o("lf",h("\n")())}function A(){return o("sp",h(" ")())}function S(){return o("vchar",u((function(t){var r=t.charCodeAt(0),i=33<=r&&r<=126;return e.rfc6532&&(i=i||m(t)),i})))}function E(){return o("wsp",f(A,_)())}function P(){var e=o("quoted-pair",f(d(h("\\"),f(S,E)),ie)());return null===e?null:(e.semantic=e.semantic[1],e)}function x(){return o("fws",f(ae,d(l(d(b(E),p(w))),b(E,1)))())}function M(){return o("ctext",f((function(){return u((function(t){var r=t.charCodeAt(0),i=33<=r&&r<=39||42<=r&&r<=91||93<=r&&r<=126;return e.rfc6532&&(i=i||m(t)),i}))}),te)())}function K(){return o("ccontent",f(M,P,C)())}function C(){return o("comment",d(h("("),b(d(l(x),K)),l(x),h(")"))())}function D(){return o("cfws",f(d(b(d(l(x),C),1),l(x)),x)())}function U(){return o("atext",u((function(t){var r="a"<=t&&t<="z"||"A"<=t&&t<="Z"||"0"<=t&&t<="9"||["!","#","$","%","&","'","*","+","-","/","=","?","^","_","`","{","|","}","~"].indexOf(t)>=0;return e.rfc6532&&(r=r||m(t)),r})))}function R(){return o("atom",d(y(l(D)),b(U,1),y(l(D)))())}function I(){var e,t;return null===(e=o("dot-atom-text",b(U,1)()))||null!==(t=b(d(h("."),b(U,1)))())&&c(e,t),e}function B(){return o("dot-atom",d(p(l(D)),I,p(l(D)))())}function T(){return o("qtext",f((function(){return u((function(t){var r=t.charCodeAt(0),i=33===r||35<=r&&r<=91||93<=r&&r<=126;return e.rfc6532&&(i=i||m(t)),i}))}),re)())}function z(){return o("qcontent",f(T,P)())}function q(){return o("quoted-string",d(p(l(D)),p(v),b(d(l(y(x)),z)),l(p(x)),p(v),p(l(D)))())}function F(){return o("word",f(R,q)())}function O(){return o("address",f(L,W)())}function L(){return o("mailbox",f(N,J)())}function N(){return o("name-addr",d(l(H),j)())}function j(){return o("angle-addr",f(d(p(l(D)),h("<"),J,h(">"),p(l(D))),se)())}function W(){return o("group",d(H,h(":"),l($),h(";"),p(l(D)))())}function H(){return o("display-name",(null!==(e=o("phrase",f(ne,b(F,1))()))&&(e.semantic=function(e){return e.replace(/([ \t]|\r\n)+/g," ").replace(/^\s*/,"").replace(/\s*$/,"")}(e.semantic)),e));var e}function G(){return o("mailbox-list",f(d(L,b(d(h(","),L))),ue)())}function V(){return o("address-list",f(d(O,b(d(h(","),O))),he)())}function $(){return o("group-list",f(G,p(D),de)())}function Z(){return o("local-part",f(fe,B,q)())}function X(){return o("dtext",f((function(){return u((function(t){var r=t.charCodeAt(0),i=33<=r&&r<=90||94<=r&&r<=126;return e.rfc6532&&(i=i||m(t)),i}))}),pe)())}function Y(){return o("domain-literal",d(p(l(D)),h("["),b(d(l(x),X)),l(x),h("]"),p(l(D)))())}function Q(){return o("domain",(t=f(le,B,Y)(),e.rejectTLD&&t&&t.semantic&&t.semantic.indexOf(".")<0?null:(t&&(t.semantic=t.semantic.replace(/\s+/g,"")),t)));var t}function J(){return o("addr-spec",d(Z,h("@"),Q)())}function ee(){return e.strict?null:o("obs-NO-WS-CTL",u((function(e){var t=e.charCodeAt(0);return 1<=t&&t<=8||11===t||12===t||14<=t&&t<=31||127===t})))}function te(){return e.strict?null:o("obs-ctext",ee())}function re(){return e.strict?null:o("obs-qtext",ee())}function ie(){return e.strict?null:o("obs-qp",d(h("\\"),f(h("\0"),ee,k,g))())}function ne(){return e.strict?null:e.atInDisplayName?o("obs-phrase",d(F,b(f(F,h("."),h("@"),y(D))))()):o("obs-phrase",d(F,b(f(F,h("."),y(D))))())}function ae(){return e.strict?null:o("obs-FWS",b(d(p(l(w)),E),1)())}function se(){return e.strict?null:o("obs-angle-addr",d(p(l(D)),h("<"),oe,J,h(">"),p(l(D)))())}function oe(){return e.strict?null:o("obs-route",d(ce,h(":"))())}function ce(){return e.strict?null:o("obs-domain-list",d(b(f(p(D),h(","))),h("@"),Q,b(d(h(","),p(l(D)),l(d(h("@"),Q)))))())}function ue(){return e.strict?null:o("obs-mbox-list",d(b(d(p(l(D)),h(","))),L,b(d(h(","),l(d(L,p(D))))))())}function he(){return e.strict?null:o("obs-addr-list",d(b(d(p(l(D)),h(","))),O,b(d(h(","),l(d(O,p(D))))))())}function de(){return e.strict?null:o("obs-group-list",d(b(d(p(l(D)),h(",")),1),p(l(D)))())}function fe(){return e.strict?null:o("obs-local-part",d(F,b(d(h("."),F)))())}function le(){return e.strict?null:o("obs-domain",d(R,b(d(h("."),R)))())}function pe(){return e.strict?null:o("obs-dtext",f(ee,P)())}function ye(e,t){var r,i,n;if(null==t)return null;for(i=[t];i.length>0;){if((n=i.pop()).name===e)return n;for(r=n.children.length-1;r>=0;r-=1)i.push(n.children[r])}return null}function be(e,t){var r,i,n,a,s;if(null==t)return null;for(i=[t],a=[],s={},r=0;r0;)if((n=i.pop()).name in s)a.push(n);else for(r=n.children.length-1;r>=0;r-=1)i.push(n.children[r]);return a}function me(t){var r,i,n,a,s;if(null===t)return null;for(r=[],i=be(["group","mailbox"],t),n=0;n1)return null;return t.addresses&&t.addresses[0]}(s):e.simple?s&&s.addresses:s}function ge(e){var t,r=ye("display-name",e),i=[],n=be(["mailbox"],e);for(t=0;t0;)for((n=i.pop()).name===e&&a.push(n),r=n.children.length-1;r>=0;r-=1)i.push(n.children[r]);return a}("cfws",e),n=be(["comment"],e),a=ye("local-part",r),s=ye("domain",r);return{node:e,parts:{name:t,address:r,local:a,domain:s,comments:i},type:e.name,name:ve(t),address:ve(r),local:ve(a),domain:ve(s),comments:_e(n),groupName:ve(e.groupName)}}function ve(e){return null!=e?e.semantic:null}function _e(e){var t="";if(e)for(var r=0;r`),t.userID=r.join(" "),t}read(e,t=de){const r=ie.decodeUTF8(e);if(r.length>t.maxUserIDLength)throw Error("User ID string is too long");try{const{name:e,address:t,comments:i}=Gu.parseOneAddress({input:r,atInDisplayName:!0});this.comment=i.replace(/^\(|\)$/g,""),this.name=e,this.email=t}catch(e){}this.userID=r}write(){return ie.encodeUTF8(this.userID)}equals(e){return e&&e.userID===this.userID}}class $u extends Wu{static get tag(){return te.packet.secretSubkey}constructor(e=new Date,t=de){super(e,t)}}class Zu{static get tag(){return te.packet.trust}read(){throw new Sn("Trust packets are not supported")}write(){throw new Sn("Trust packets are not supported")}}const Xu=/*#__PURE__*/ie.constructAllowedPackets([bu]);class Yu{constructor(e){this.packets=e||new vu}write(){return this.packets.write()}armor(e=de){return ve(te.armor.signature,this.write(),void 0,void 0,void 0,e)}getSigningKeyIDs(){return this.packets.map((e=>e.issuerKeyID))}}async function Qu({armoredSignature:e,binarySignature:t,config:r,...i}){r={...de,...r};let n=e||t;if(!n)throw Error("readSignature: must pass options object containing `armoredSignature` or `binarySignature`");if(e&&!ie.isString(e))throw Error("readSignature: options.armoredSignature must be a string");if(t&&!ie.isUint8Array(t))throw Error("readSignature: options.binarySignature must be a Uint8Array");const a=Object.keys(i);if(a.length>0)throw Error("Unknown option: "+a.join(", "));if(e){const{type:e,data:t}=await we(n,r);if(e!==te.armor.signature)throw Error("Armored text not of type signature");n=t}const s=await vu.fromBinary(n,Xu,r);return new Yu(s)}async function Ju(e,t){const r=new $u(e.date,t);return r.packets=null,r.algorithm=te.write(te.publicKey,e.algorithm),await r.generate(e.rsaBits,e.curve),await r.computeFingerprintAndKeyID(),r}async function eh(e,t){const r=new Wu(e.date,t);return r.packets=null,r.algorithm=te.write(te.publicKey,e.algorithm),await r.generate(e.rsaBits,e.curve,e.config),await r.computeFingerprintAndKeyID(),r}async function th(e,t,r,i,n=new Date,a){let s,o;for(let c=e.length-1;c>=0;c--)try{(!s||e[c].created>=s.created)&&(await e[c].verify(t,r,i,n,void 0,a),s=e[c])}catch(e){o=e}if(!s)throw ie.wrapError(`Could not find valid ${te.read(te.signature,r)} signature in key ${t.getKeyID().toHex()}`.replace("certGeneric ","self-").replace(/([a-z])([A-Z])/g,((e,t,r)=>t+" "+r.toLowerCase())),o);return s}function rh(e,t,r=new Date){const i=ie.normalizeDate(r);if(null!==i){const r=uh(e,t);return!(e.created<=i&&i0&&(a.keyExpirationTime=r.keyExpirationTime,a.keyNeverExpires=!1),await a.sign(t,n,r.date),a}async function nh(e,t,r=new Date,i={},n){let a=n.preferredHashAlgorithm,s=a;if(e){const t=await e.getPrimaryUser(r,i,n);t.selfCertification.preferredHashAlgorithms&&([s]=t.selfCertification.preferredHashAlgorithms,a=Ea.hash.getHashByteLength(a)<=Ea.hash.getHashByteLength(s)?s:a)}switch(Object.getPrototypeOf(t)){case Wu.prototype:case qu.prototype:case $u.prototype:case Nu.prototype:switch(t.algorithm){case te.publicKey.ecdh:case te.publicKey.ecdsa:case te.publicKey.eddsa:s=Ea.publicKey.elliptic.getPreferredHashAlgo(t.publicParams.oid)}}return Ea.hash.getHashByteLength(a)<=Ea.hash.getHashByteLength(s)?s:a}async function ah(e,t=[],r=new Date,i=[],n=de){const a={symmetric:te.symmetric.aes128,aead:te.aead.eax,compression:te.compression.uncompressed}[e],s={symmetric:n.preferredSymmetricAlgorithm,aead:n.preferredAEADAlgorithm,compression:n.preferredCompressionAlgorithm}[e],o={symmetric:"preferredSymmetricAlgorithms",aead:"preferredAEADAlgorithms",compression:"preferredCompressionAlgorithms"}[e],c=await Promise.all(t.map((async function(e,t){const a=(await e.getPrimaryUser(r,i[t],n)).selfCertification[o];return!!a&&a.indexOf(s)>=0})));return c.every(Boolean)?s:a}async function sh(e,t,r,i,n,a,s=[],o=!1,c){if(r.isDummy())throw Error("Cannot sign with a gnu-dummy key.");if(!r.isDecrypted())throw Error("Signing key is not decrypted.");const u=new bu;return Object.assign(u,i),u.publicKeyAlgorithm=r.algorithm,u.hashAlgorithm=await nh(t,r,n,a,c),u.rawNotations=s,await u.sign(r,e,n,o),u}async function oh(e,t,r,i=new Date,n){(e=e[r])&&(t[r].length?await Promise.all(e.map((async function(e){e.isExpired(i)||n&&!await n(e)||t[r].some((function(t){return ie.equalsUint8Array(t.writeParams(),e.writeParams())}))||t[r].push(e)}))):t[r]=e)}async function ch(e,t,r,i,n,a,s=new Date,o){a=a||e;const c=[];return await Promise.all(i.map((async function(e){try{n&&!e.issuerKeyID.equals(n.issuerKeyID)||(await e.verify(a,t,r,o.revocationsExpire?s:null,!1,o),c.push(e.issuerKeyID))}catch(e){}}))),n?(n.revoked=!!c.some((e=>e.equals(n.issuerKeyID)))||(n.revoked||!1),n.revoked):c.length>0}function uh(e,t){let r;return!1===t.keyNeverExpires&&(r=e.created.getTime()+1e3*t.keyExpirationTime),r?new Date(r):1/0}function hh(e,t={}){switch(e.type=e.type||t.type,e.curve=e.curve||t.curve,e.rsaBits=e.rsaBits||t.rsaBits,e.keyExpirationTime=void 0!==e.keyExpirationTime?e.keyExpirationTime:t.keyExpirationTime,e.passphrase=ie.isString(e.passphrase)?e.passphrase:t.passphrase,e.date=e.date||t.date,e.sign=e.sign||!1,e.type){case"ecc":try{e.curve=te.write(te.curve,e.curve)}catch(e){throw Error("Unknown curve")}e.curve!==te.curve.ed25519&&e.curve!==te.curve.curve25519||(e.curve=e.sign?te.curve.ed25519:te.curve.curve25519),e.sign?e.algorithm=e.curve===te.curve.ed25519?te.publicKey.eddsa:te.publicKey.ecdsa:e.algorithm=te.publicKey.ecdh;break;case"rsa":e.algorithm=te.publicKey.rsaEncryptSign;break;default:throw Error("Unsupported key type "+e.type)}return e}function dh(e,t){const r=e.algorithm;return r!==te.publicKey.rsaEncrypt&&r!==te.publicKey.elgamal&&r!==te.publicKey.ecdh&&(!t.keyFlags||0!=(t.keyFlags[0]&te.keyFlags.signData))}function fh(e,t){const r=e.algorithm;return r!==te.publicKey.dsa&&r!==te.publicKey.rsaSign&&r!==te.publicKey.ecdsa&&r!==te.publicKey.eddsa&&(!t.keyFlags||0!=(t.keyFlags[0]&te.keyFlags.encryptCommunication)||0!=(t.keyFlags[0]&te.keyFlags.encryptStorage))}function lh(e,t){return!!t.allowInsecureDecryptionWithSigningKeys||(!e.keyFlags||0!=(e.keyFlags[0]&te.keyFlags.encryptCommunication)||0!=(e.keyFlags[0]&te.keyFlags.encryptStorage))}function ph(e,t){const r=te.write(te.publicKey,e.algorithm),i=e.getAlgorithmInfo();if(t.rejectPublicKeyAlgorithms.has(r))throw Error(i.algorithm+" keys are considered too weak.");switch(r){case te.publicKey.rsaEncryptSign:case te.publicKey.rsaSign:case te.publicKey.rsaEncrypt:if(i.bitse.getKeys(o).length>0));return 0===c.length?null:(await Promise.all(c.map((async t=>{const a=await t.getSigningKey(o,e.created,void 0,i);if(e.revoked||await n.isRevoked(e,a.keyPacket,r,i))throw Error("User certificate is revoked");try{await e.verify(a.keyPacket,te.signature.certGeneric,s,r,void 0,i)}catch(e){throw ie.wrapError("User certificate is invalid",e)}}))),!0)}async verifyAllCertifications(e,t=new Date,r){const i=this,n=this.selfCertifications.concat(this.otherCertifications);return Promise.all(n.map((async n=>({keyID:n.issuerKeyID,valid:await i.verifyCertificate(n,e,t,r).catch((()=>!1))}))))}async verify(e=new Date,t){if(!this.selfCertifications.length)throw Error("No self-certifications found");const r=this,i=this.mainKey.keyPacket,n={userID:this.userID,userAttribute:this.userAttribute,key:i};let a;for(let s=this.selfCertifications.length-1;s>=0;s--)try{const a=this.selfCertifications[s];if(a.revoked||await r.isRevoked(a,void 0,e,t))throw Error("Self-certification is revoked");try{await a.verify(i,te.signature.certGeneric,n,e,void 0,t)}catch(e){throw ie.wrapError("Self-certification is invalid",e)}return!0}catch(e){a=e}throw a}async update(e,t,r){const i=this.mainKey.keyPacket,n={userID:this.userID,userAttribute:this.userAttribute,key:i};await oh(e,this,"selfCertifications",t,(async function(e){try{return await e.verify(i,te.signature.certGeneric,n,t,!1,r),!0}catch(e){return!1}})),await oh(e,this,"otherCertifications",t),await oh(e,this,"revocationSignatures",t,(function(e){return ch(i,te.signature.certRevocation,n,[e],void 0,void 0,t,r)}))}async revoke(e,{flag:t=te.reasonForRevocation.noReason,string:r=""}={},i=new Date,n=de){const a={userID:this.userID,userAttribute:this.userAttribute,key:e},s=new yh(a.userID||a.userAttribute,this.mainKey);return s.revocationSignatures.push(await sh(a,null,e,{signatureType:te.signature.certRevocation,reasonForRevocationFlag:te.write(te.reasonForRevocation,t),reasonForRevocationString:r},i,void 0,void 0,!1,n)),await s.update(this),s}}class bh{constructor(e,t){this.keyPacket=e,this.bindingSignatures=[],this.revocationSignatures=[],this.mainKey=t}toPacketList(){const e=new vu;return e.push(this.keyPacket),e.push(...this.revocationSignatures),e.push(...this.bindingSignatures),e}clone(){const e=new bh(this.keyPacket,this.mainKey);return e.bindingSignatures=[...this.bindingSignatures],e.revocationSignatures=[...this.revocationSignatures],e}async isRevoked(e,t,r=new Date,i=de){const n=this.mainKey.keyPacket;return ch(n,te.signature.subkeyRevocation,{key:n,bind:this.keyPacket},this.revocationSignatures,e,t,r,i)}async verify(e=new Date,t=de){const r=this.mainKey.keyPacket,i={key:r,bind:this.keyPacket},n=await th(this.bindingSignatures,r,te.signature.subkeyBinding,i,e,t);if(n.revoked||await this.isRevoked(n,null,e,t))throw Error("Subkey is revoked");if(rh(this.keyPacket,n,e))throw Error("Subkey is expired");return n}async getExpirationTime(e=new Date,t=de){const r=this.mainKey.keyPacket,i={key:r,bind:this.keyPacket};let n;try{n=await th(this.bindingSignatures,r,te.signature.subkeyBinding,i,e,t)}catch(e){return null}const a=uh(this.keyPacket,n),s=n.getExpirationTime();return an.bindingSignatures[t].created&&(n.bindingSignatures[t]=e),!1;try{return await e.verify(i,te.signature.subkeyBinding,a,t,void 0,r),!0}catch(e){return!1}})),await oh(e,this,"revocationSignatures",t,(function(e){return ch(i,te.signature.subkeyRevocation,a,[e],void 0,void 0,t,r)}))}async revoke(e,{flag:t=te.reasonForRevocation.noReason,string:r=""}={},i=new Date,n=de){const a={key:e,bind:this.keyPacket},s=new bh(this.keyPacket,this.mainKey);return s.revocationSignatures.push(await sh(a,null,e,{signatureType:te.signature.subkeyRevocation,reasonForRevocationFlag:te.write(te.reasonForRevocation,t),reasonForRevocationString:r},i,void 0,void 0,!1,n)),await s.update(this),s}hasSameFingerprintAs(e){return this.keyPacket.hasSameFingerprintAs(e.keyPacket||e)}}["getKeyID","getFingerprint","getAlgorithmInfo","getCreationTime","isDecrypted"].forEach((e=>{bh.prototype[e]=function(){return this.keyPacket[e]()}}));const mh=/*#__PURE__*/ie.constructAllowedPackets([bu]),gh=new Set([te.packet.publicKey,te.packet.privateKey]),wh=new Set([te.packet.publicKey,te.packet.privateKey,te.packet.publicSubkey,te.packet.privateSubkey]);class vh{packetListToStructure(e,t=new Set){let r,i,n,a;for(const s of e){if(s instanceof En){wh.has(s.tag)&&!a&&(a=gh.has(s.tag)?gh:wh);continue}const e=s.constructor.tag;if(a){if(!a.has(e))continue;a=null}if(t.has(e))throw Error("Unexpected packet type: "+e);switch(e){case te.packet.publicKey:case te.packet.secretKey:if(this.keyPacket)throw Error("Key block contains multiple keys");if(this.keyPacket=s,i=this.getKeyID(),!i)throw Error("Missing Key ID");break;case te.packet.userID:case te.packet.userAttribute:r=new yh(s,this),this.users.push(r);break;case te.packet.publicSubkey:case te.packet.secretSubkey:r=null,n=new bh(s,this),this.subkeys.push(n);break;case te.packet.signature:switch(s.signatureType){case te.signature.certGeneric:case te.signature.certPersona:case te.signature.certCasual:case te.signature.certPositive:if(!r){ie.printDebug("Dropping certification signatures without preceding user packet");continue}s.issuerKeyID.equals(i)?r.selfCertifications.push(s):r.otherCertifications.push(s);break;case te.signature.certRevocation:r?r.revocationSignatures.push(s):this.directSignatures.push(s);break;case te.signature.key:this.directSignatures.push(s);break;case te.signature.subkeyBinding:if(!n){ie.printDebug("Dropping subkey binding signature without preceding subkey packet");continue}n.bindingSignatures.push(s);break;case te.signature.keyRevocation:this.revocationSignatures.push(s);break;case te.signature.subkeyRevocation:if(!n){ie.printDebug("Dropping subkey revocation signature without preceding subkey packet");continue}n.revocationSignatures.push(s)}}}}toPacketList(){const e=new vu;return e.push(this.keyPacket),e.push(...this.revocationSignatures),e.push(...this.directSignatures),this.users.map((t=>e.push(...t.toPacketList()))),this.subkeys.map((t=>e.push(...t.toPacketList()))),e}clone(e=!1){const t=new this.constructor(this.toPacketList());return e&&t.getKeys().forEach((e=>{if(e.keyPacket=Object.create(Object.getPrototypeOf(e.keyPacket),Object.getOwnPropertyDescriptors(e.keyPacket)),!e.keyPacket.isDecrypted())return;const t={};Object.keys(e.keyPacket.privateParams).forEach((r=>{t[r]=new Uint8Array(e.keyPacket.privateParams[r])})),e.keyPacket.privateParams=t})),t}getSubkeys(e=null){return this.subkeys.filter((t=>!e||t.getKeyID().equals(e,!0)))}getKeys(e=null){const t=[];return e&&!this.getKeyID().equals(e,!0)||t.push(this),t.concat(this.getSubkeys(e))}getKeyIDs(){return this.getKeys().map((e=>e.getKeyID()))}getUserIDs(){return this.users.map((e=>e.userID?e.userID.userID:null)).filter((e=>null!==e))}write(){return this.toPacketList().write()}async getSigningKey(e=null,t=new Date,r={},i=de){await this.verifyPrimaryKey(t,r,i);const n=this.keyPacket,a=this.subkeys.slice().sort(((e,t)=>t.keyPacket.created-e.keyPacket.created));let s;for(const r of a)if(!e||r.getKeyID().equals(e))try{await r.verify(t,i);const e={key:n,bind:r.keyPacket},a=await th(r.bindingSignatures,n,te.signature.subkeyBinding,e,t,i);if(!dh(r.keyPacket,a))continue;if(!a.embeddedSignature)throw Error("Missing embedded signature");return await th([a.embeddedSignature],r.keyPacket,te.signature.keyBinding,e,t,i),ph(r.keyPacket,i),r}catch(e){s=e}try{const a=await this.getPrimaryUser(t,r,i);if((!e||n.getKeyID().equals(e))&&dh(n,a.selfCertification))return ph(n,i),this}catch(e){s=e}throw ie.wrapError("Could not find valid signing key packet in key "+this.getKeyID().toHex(),s)}async getEncryptionKey(e,t=new Date,r={},i=de){await this.verifyPrimaryKey(t,r,i);const n=this.keyPacket,a=this.subkeys.slice().sort(((e,t)=>t.keyPacket.created-e.keyPacket.created));let s;for(const r of a)if(!e||r.getKeyID().equals(e))try{await r.verify(t,i);const e={key:n,bind:r.keyPacket},a=await th(r.bindingSignatures,n,te.signature.subkeyBinding,e,t,i);if(fh(r.keyPacket,a))return ph(r.keyPacket,i),r}catch(e){s=e}try{const a=await this.getPrimaryUser(t,r,i);if((!e||n.getKeyID().equals(e))&&fh(n,a.selfCertification))return ph(n,i),this}catch(e){s=e}throw ie.wrapError("Could not find valid encryption key packet in key "+this.getKeyID().toHex(),s)}async isRevoked(e,t,r=new Date,i=de){return ch(this.keyPacket,te.signature.keyRevocation,{key:this.keyPacket},this.revocationSignatures,e,t,r,i)}async verifyPrimaryKey(e=new Date,t={},r=de){const i=this.keyPacket;if(await this.isRevoked(null,null,e,r))throw Error("Primary key is revoked");const{selfCertification:n}=await this.getPrimaryUser(e,t,r);if(rh(i,n,e))throw Error("Primary key is expired");const a=await th(this.directSignatures,i,te.signature.key,{key:i},e,r).catch((()=>{}));if(a&&rh(i,a,e))throw Error("Primary key is expired")}async getExpirationTime(e,t=de){let r;try{const{selfCertification:i}=await this.getPrimaryUser(null,e,t),n=uh(this.keyPacket,i),a=i.getExpirationTime(),s=await th(this.directSignatures,this.keyPacket,te.signature.key,{key:this.keyPacket},null,t).catch((()=>{}));if(s){const e=uh(this.keyPacket,s);r=Math.min(n,a,e)}else r=ne.subkeys.some((e=>t.hasSameFingerprintAs(e)))))))throw Error("Cannot update public key with private key if subkeys mismatch");return e.update(this,r)}const i=this.clone();return await oh(e,i,"revocationSignatures",t,(n=>ch(i.keyPacket,te.signature.keyRevocation,i,[n],null,e.keyPacket,t,r))),await oh(e,i,"directSignatures",t),await Promise.all(e.users.map((async e=>{const n=i.users.filter((t=>e.userID&&e.userID.equals(t.userID)||e.userAttribute&&e.userAttribute.equals(t.userAttribute)));if(n.length>0)await Promise.all(n.map((i=>i.update(e,t,r))));else{const t=e.clone();t.mainKey=i,i.users.push(t)}}))),await Promise.all(e.subkeys.map((async e=>{const n=i.subkeys.filter((t=>t.hasSameFingerprintAs(e)));if(n.length>0)await Promise.all(n.map((i=>i.update(e,t,r))));else{const t=e.clone();t.mainKey=i,i.subkeys.push(t)}}))),i}async getRevocationCertificate(e=new Date,t=de){const r={key:this.keyPacket},i=await th(this.revocationSignatures,this.keyPacket,te.signature.keyRevocation,r,e,t),n=new vu;return n.push(i),ve(te.armor.publicKey,n.write(),null,null,"This is a revocation certificate")}async applyRevocationCertificate(e,t=new Date,r=de){const i=await we(e,r),n=(await vu.fromBinary(i.data,mh,r)).findPacket(te.packet.signature);if(!n||n.signatureType!==te.signature.keyRevocation)throw Error("Could not find revocation signature packet");if(!n.issuerKeyID.equals(this.getKeyID()))throw Error("Revocation signature does not match key");try{await n.verify(this.keyPacket,te.signature.keyRevocation,{key:this.keyPacket},t,void 0,r)}catch(e){throw ie.wrapError("Could not verify revocation signature",e)}const a=this.clone();return a.revocationSignatures.push(n),a}async signPrimaryUser(e,t,r,i=de){const{index:n,user:a}=await this.getPrimaryUser(t,r,i),s=await a.certify(e,t,i),o=this.clone();return o.users[n]=s,o}async signAllUsers(e,t=new Date,r=de){const i=this.clone();return i.users=await Promise.all(this.users.map((function(i){return i.certify(e,t,r)}))),i}async verifyPrimaryUser(e,t=new Date,r,i=de){const n=this.keyPacket,{user:a}=await this.getPrimaryUser(t,r,i);return e?await a.verifyAllCertifications(e,t,i):[{keyID:n.getKeyID(),valid:await a.verify(t,i).catch((()=>!1))}]}async verifyAllUsers(e,t=new Date,r=de){const i=this.keyPacket,n=[];return await Promise.all(this.users.map((async a=>{const s=e?await a.verifyAllCertifications(e,t,r):[{keyID:i.getKeyID(),valid:await a.verify(t,r).catch((()=>!1))}];n.push(...s.map((e=>({userID:a.userID?a.userID.userID:null,userAttribute:a.userAttribute,keyID:e.keyID,valid:e.valid}))))}))),n}}["getKeyID","getFingerprint","getAlgorithmInfo","getCreationTime","hasSameFingerprintAs"].forEach((e=>{vh.prototype[e]=bh.prototype[e]}));class _h extends vh{constructor(e){if(super(),this.keyPacket=null,this.revocationSignatures=[],this.directSignatures=[],this.users=[],this.subkeys=[],e&&(this.packetListToStructure(e,new Set([te.packet.secretKey,te.packet.secretSubkey])),!this.keyPacket))throw Error("Invalid key: missing public-key packet")}isPrivate(){return!1}toPublic(){return this}armor(e=de){return ve(te.armor.publicKey,this.toPacketList().write(),void 0,void 0,void 0,e)}}class kh extends _h{constructor(e){if(super(),this.packetListToStructure(e,new Set([te.packet.publicKey,te.packet.publicSubkey])),!this.keyPacket)throw Error("Invalid key: missing private-key packet")}isPrivate(){return!0}toPublic(){const e=new vu,t=this.toPacketList();for(const r of t)switch(r.constructor.tag){case te.packet.secretKey:{const t=qu.fromSecretKeyPacket(r);e.push(t);break}case te.packet.secretSubkey:{const t=Nu.fromSecretSubkeyPacket(r);e.push(t);break}default:e.push(r)}return new _h(e)}armor(e=de){return ve(te.armor.privateKey,this.toPacketList().write(),void 0,void 0,void 0,e)}async getDecryptionKeys(e,t=new Date,r={},i=de){const n=this.keyPacket,a=[];for(let r=0;re.isDecrypted()))}async validate(e=de){if(!this.isPrivate())throw Error("Cannot validate a public key");let t;if(this.keyPacket.isDummy()){const r=await this.getSigningKey(null,null,void 0,{...e,rejectPublicKeyAlgorithms:new Set,minRSABits:0});r&&!r.keyPacket.isDummy()&&(t=r.keyPacket)}else t=this.keyPacket;if(t)return t.validate();{const e=this.getKeys(),t=e.map((e=>e.keyPacket.isDummy())).every(Boolean);if(t)throw Error("Cannot validate an all-gnu-dummy key");return Promise.all(e.map((async e=>e.keyPacket.validate())))}}clearPrivateParams(){this.getKeys().forEach((({keyPacket:e})=>{e.isDecrypted()&&e.clearPrivateParams()}))}async revoke({flag:e=te.reasonForRevocation.noReason,string:t=""}={},r=new Date,i=de){if(!this.isPrivate())throw Error("Need private key for revoking");const n={key:this.keyPacket},a=this.clone();return a.revocationSignatures.push(await sh(n,null,this.keyPacket,{signatureType:te.signature.keyRevocation,reasonForRevocationFlag:te.write(te.reasonForRevocation,e),reasonForRevocationString:t},r,void 0,void 0,void 0,i)),a}async addSubkey(e={}){const t={...de,...e.config};if(e.passphrase)throw Error("Subkey could not be encrypted here, please encrypt whole key");if(e.rsaBitse!==t))]}const s=Vu.fromObject(t),o={};o.userID=s,o.key=e;const c=new bu;return c.signatureType=te.signature.certGeneric,c.publicKeyAlgorithm=e.algorithm,c.hashAlgorithm=await nh(null,e,void 0,void 0,i),c.keyFlags=[te.keyFlags.certifyKeys|te.keyFlags.signData],c.preferredSymmetricAlgorithms=a([te.symmetric.aes256,te.symmetric.aes128,te.symmetric.aes192],i.preferredSymmetricAlgorithm),i.aeadProtect&&(c.preferredAEADAlgorithms=a([te.aead.eax,te.aead.ocb],i.preferredAEADAlgorithm)),c.preferredHashAlgorithms=a([te.hash.sha256,te.hash.sha512],i.preferredHashAlgorithm),c.preferredCompressionAlgorithms=a([te.compression.zlib,te.compression.zip,te.compression.uncompressed],i.preferredCompressionAlgorithm),0===n&&(c.isPrimaryUserID=!0),c.features=[0],c.features[0]|=te.features.modificationDetection,i.aeadProtect&&(c.features[0]|=te.features.aead),i.v5Keys&&(c.features[0]|=te.features.v5Keys),r.keyExpirationTime>0&&(c.keyExpirationTime=r.keyExpirationTime,c.keyNeverExpires=!1),await c.sign(e,o,r.date),{userIDPacket:s,signaturePacket:c}}))).then((e=>{e.forEach((({userIDPacket:e,signaturePacket:t})=>{n.push(e),n.push(t)}))})),await Promise.all(t.map((async function(t,n){const a=r.subkeys[n];return{secretSubkeyPacket:t,subkeySignaturePacket:await ih(t,e,a,i)}}))).then((e=>{e.forEach((({secretSubkeyPacket:e,subkeySignaturePacket:t})=>{n.push(e),n.push(t)}))}));const a={key:e};return n.push(await sh(a,null,e,{signatureType:te.signature.keyRevocation,reasonForRevocationFlag:te.reasonForRevocation.noReason,reasonForRevocationString:""},r.date,void 0,void 0,void 0,i)),r.passphrase&&e.clearPrivateParams(),await Promise.all(t.map((async function(e,t){r.subkeys[t].passphrase&&e.clearPrivateParams()}))),new kh(n)}async function Ph({armoredKey:e,binaryKey:t,config:r,...i}){if(r={...de,...r},!e&&!t)throw Error("readKey: must pass options object containing `armoredKey` or `binaryKey`");if(e&&!ie.isString(e))throw Error("readKey: options.armoredKey must be a string");if(t&&!ie.isUint8Array(t))throw Error("readKey: options.binaryKey must be a Uint8Array");const n=Object.keys(i);if(n.length>0)throw Error("Unknown option: "+n.join(", "));let a;if(e){const{type:t,data:i}=await we(e,r);if(t!==te.armor.publicKey&&t!==te.armor.privateKey)throw Error("Armored text not of type key");a=i}else a=t;return Sh(await vu.fromBinary(a,Ah,r))}async function xh({armoredKey:e,binaryKey:t,config:r,...i}){if(r={...de,...r},!e&&!t)throw Error("readPrivateKey: must pass options object containing `armoredKey` or `binaryKey`");if(e&&!ie.isString(e))throw Error("readPrivateKey: options.armoredKey must be a string");if(t&&!ie.isUint8Array(t))throw Error("readPrivateKey: options.binaryKey must be a Uint8Array");const n=Object.keys(i);if(n.length>0)throw Error("Unknown option: "+n.join(", "));let a;if(e){const{type:t,data:i}=await we(e,r);if(t!==te.armor.privateKey)throw Error("Armored text not of type private key");a=i}else a=t;const s=await vu.fromBinary(a,Ah,r);return new kh(s)}async function Mh({armoredKeys:e,binaryKeys:t,config:r,...i}){r={...de,...r};let n=e||t;if(!n)throw Error("readKeys: must pass options object containing `armoredKeys` or `binaryKeys`");if(e&&!ie.isString(e))throw Error("readKeys: options.armoredKeys must be a string");if(t&&!ie.isUint8Array(t))throw Error("readKeys: options.binaryKeys must be a Uint8Array");const a=Object.keys(i);if(a.length>0)throw Error("Unknown option: "+a.join(", "));if(e){const{type:t,data:i}=await we(e,r);if(t!==te.armor.publicKey&&t!==te.armor.privateKey)throw Error("Armored text not of type key");n=i}const s=[],o=await vu.fromBinary(n,Ah,r),c=o.indexOfTag(te.packet.publicKey,te.packet.secretKey);if(0===c.length)throw Error("No key packet found");for(let e=0;e0)return t.map((e=>e.issuerKeyID));return e.packets.filterByTag(te.packet.signature).map((e=>e.issuerKeyID))}async decrypt(e,t,r,i=new Date,n=de){const a=r||await this.decryptSessionKeys(e,t,i,n),s=this.packets.filterByTag(te.packet.symmetricallyEncryptedData,te.packet.symEncryptedIntegrityProtectedData,te.packet.aeadEncryptedData);if(0===s.length)throw Error("No encrypted data found");const o=s[0];let c=null;const u=Promise.all(a.map((async({algorithm:e,data:t})=>{if(!ie.isUint8Array(t)||!ie.isString(e))throw Error("Invalid session key for decryption.");try{const r=te.write(te.symmetric,e);await o.decrypt(r,t,n)}catch(e){ie.printDebugError(e),c=e}})));if(X(o.encrypted),o.encrypted=null,await u,!o.packets||!o.packets.length)throw c||Error("Decryption failed.");const h=new Rh(o.packets);return o.packets=new vu,h}async decryptSessionKeys(e,t,r=new Date,i=de){let n,a=[];if(t){const e=this.packets.filterByTag(te.packet.symEncryptedSessionKey);if(0===e.length)throw Error("No symmetrically encrypted session key packet found.");await Promise.all(t.map((async function(t,r){let n;n=r?await vu.fromBinary(e.write(),Dh,i):e,await Promise.all(n.map((async function(e){try{await e.decrypt(t),a.push(e)}catch(e){ie.printDebugError(e)}})))})))}else{if(!e)throw Error("No key or password specified.");{const t=this.packets.filterByTag(te.packet.publicKeyEncryptedSessionKey);if(0===t.length)throw Error("No public key encrypted session key packet found.");await Promise.all(t.map((async function(t){await Promise.all(e.map((async function(e){let s=[te.symmetric.aes256,te.symmetric.aes128,te.symmetric.tripledes,te.symmetric.cast5];try{const t=await e.getPrimaryUser(r,void 0,i);t.selfCertification.preferredSymmetricAlgorithms&&(s=s.concat(t.selfCertification.preferredSymmetricAlgorithms))}catch(e){}const o=(await e.getDecryptionKeys(t.publicKeyID,null,void 0,i)).map((e=>e.keyPacket));await Promise.all(o.map((async function(e){if(!e||e.isDummy())return;if(!e.isDecrypted())throw Error("Decryption key is not decrypted.");if(i.constantTimePKCS1Decryption&&(t.publicKeyAlgorithm===te.publicKey.rsaEncrypt||t.publicKeyAlgorithm===te.publicKey.rsaEncryptSign||t.publicKeyAlgorithm===te.publicKey.rsaSign||t.publicKeyAlgorithm===te.publicKey.elgamal)){const r=t.write();await Promise.all(Array.from(i.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms).map((async t=>{const i=new Iu;i.read(r);const s={sessionKeyAlgorithm:t,sessionKey:Ea.generateSessionKey(t)};try{await i.decrypt(e,s),a.push(i)}catch(e){ie.printDebugError(e),n=e}})))}else try{if(await t.decrypt(e),!s.includes(te.write(te.symmetric,t.sessionKeyAlgorithm)))throw Error("A non-preferred symmetric algorithm was used.");a.push(t)}catch(e){ie.printDebugError(e),n=e}})))}))),X(t.encrypted),t.encrypted=null})))}}if(a.length>0){if(a.length>1){const e=new Set;a=a.filter((t=>{const r=t.sessionKeyAlgorithm+ie.uint8ArrayToString(t.sessionKey);return!e.has(r)&&(e.add(r),!0)}))}return a.map((e=>({data:e.sessionKey,algorithm:te.read(te.symmetric,e.sessionKeyAlgorithm)})))}throw n||Error("Session key decryption failed.")}getLiteralData(){const e=this.unwrapCompressed().packets.findPacket(te.packet.literalData);return e&&e.getBytes()||null}getFilename(){const e=this.unwrapCompressed().packets.findPacket(te.packet.literalData);return e&&e.getFilename()||null}getText(){const e=this.unwrapCompressed().packets.findPacket(te.packet.literalData);return e?e.getText():null}static async generateSessionKey(e=[],t=new Date,r=[],i=de){const n=await ah("symmetric",e,t,r,i),a=te.read(te.symmetric,n),s=i.aeadProtect&&await async function(e,t=new Date,r=[],i=de){let n=!0;return await Promise.all(e.map((async function(e,a){const s=await e.getPrimaryUser(t,r[a],i);s.selfCertification.features&&s.selfCertification.features[0]&te.features.aead||(n=!1)}))),n}(e,t,r,i)?te.read(te.aead,await ah("aead",e,t,r,i)):void 0;await Promise.all(e.map((e=>e.getEncryptionKey().catch((()=>null)).then((e=>{if(e&&e.keyPacket.algorithm===te.publicKey.x25519&&!ie.isAES(n))throw Error("Could not generate a session key compatible with the given `encryptionKeys`: X22519 keys can only be used to encrypt AES session keys; change `config.preferredSymmetricAlgorithm` accordingly.")})))));return{data:Ea.generateSessionKey(n),algorithm:a,aeadAlgorithm:s}}async encrypt(e,t,r,i=!1,n=[],a=new Date,s=[],o=de){if(r){if(!ie.isUint8Array(r.data)||!ie.isString(r.algorithm))throw Error("Invalid session key for encryption.")}else if(e&&e.length)r=await Rh.generateSessionKey(e,a,s,o);else{if(!t||!t.length)throw Error("No keys, passwords, or session key provided.");r=await Rh.generateSessionKey(void 0,void 0,void 0,o)}const{data:c,algorithm:u,aeadAlgorithm:h}=r,d=await Rh.encryptSessionKey(c,u,h,e,t,i,n,a,s,o);let f;h?(f=new Ru,f.aeadAlgorithm=te.write(te.aead,h)):f=new Du,f.packets=this.packets;const l=te.write(te.symmetric,u);return await f.encrypt(l,c,o),d.packets.push(f),f.packets=new vu,d}static async encryptSessionKey(e,t,r,i,n,a=!1,s=[],o=new Date,c=[],u=de){const h=new vu,d=te.write(te.symmetric,t),f=r&&te.write(te.aead,r);if(i){const t=await Promise.all(i.map((async function(t,r){const i=await t.getEncryptionKey(s[r],o,c,u),n=new Iu;return n.publicKeyID=a?_e.wildcard():i.getKeyID(),n.publicKeyAlgorithm=i.keyPacket.algorithm,n.sessionKey=e,n.sessionKeyAlgorithm=d,await n.encrypt(i.keyPacket),delete n.sessionKey,n})));h.push(...t)}if(n){const t=async function(e,t){try{return await e.decrypt(t),1}catch(e){return 0}},r=(e,t)=>e+t,i=async function(e,a,s,o){const c=new zu(u);if(c.sessionKey=e,c.sessionKeyAlgorithm=a,s&&(c.aeadAlgorithm=s),await c.encrypt(o,u),u.passwordCollisionCheck){if(1!==(await Promise.all(n.map((e=>t(c,e))))).reduce(r))return i(e,a,o)}return delete c.sessionKey,c},a=await Promise.all(n.map((t=>i(e,d,f,t))));h.push(...a)}return new Rh(h)}async sign(e=[],t=null,r=[],i=new Date,n=[],a=[],s=de){const o=new vu,c=this.packets.findPacket(te.packet.literalData);if(!c)throw Error("No literal data packet to sign.");let u,h;const d=null===c.text?te.signature.binary:te.signature.text;if(t)for(h=t.packets.filterByTag(te.packet.signature),u=h.length-1;u>=0;u--){const t=h[u],r=new gu;r.signatureType=t.signatureType,r.hashAlgorithm=t.hashAlgorithm,r.publicKeyAlgorithm=t.publicKeyAlgorithm,r.issuerKeyID=t.issuerKeyID,e.length||0!==u||(r.flags=1),o.push(r)}return await Promise.all(Array.from(e).reverse().map((async function(t,a){if(!t.isPrivate())throw Error("Need private key for signing");const o=r[e.length-1-a],c=await t.getSigningKey(o,i,n,s),u=new gu;return u.signatureType=d,u.hashAlgorithm=await nh(t,c.keyPacket,i,n,s),u.publicKeyAlgorithm=c.keyPacket.algorithm,u.issuerKeyID=c.getKeyID(),a===e.length-1&&(u.flags=1),u}))).then((e=>{e.forEach((e=>o.push(e)))})),o.push(c),o.push(...await Ih(c,e,t,r,i,n,a,!1,s)),new Rh(o)}compress(e,t=de){if(e===te.compression.uncompressed)return this;const r=new ku(t);r.algorithm=e,r.packets=this.packets;const i=new vu;return i.push(r),new Rh(i)}async signDetached(e=[],t=null,r=[],i=new Date,n=[],a=[],s=de){const o=this.packets.findPacket(te.packet.literalData);if(!o)throw Error("No literal data packet to sign.");return new Yu(await Ih(o,e,t,r,i,n,a,!0,s))}async verify(e,t=new Date,r=de){const i=this.unwrapCompressed(),n=i.packets.filterByTag(te.packet.literalData);if(1!==n.length)throw Error("Can only verify message with one literal data packet.");l(i.packets.stream)&&i.packets.push(...await Z(i.packets.stream,(e=>e||[])));const a=i.packets.filterByTag(te.packet.onePassSignature).reverse(),s=i.packets.filterByTag(te.packet.signature);return a.length&&!s.length&&ie.isStream(i.packets.stream)&&!l(i.packets.stream)?(await Promise.all(a.map((async e=>{e.correspondingSig=new Promise(((t,r)=>{e.correspondingSigResolve=t,e.correspondingSigReject=r})),e.signatureData=Y((async()=>(await e.correspondingSig).signatureData)),e.hashed=Z(await e.hash(e.signatureType,n[0],void 0,!1)),e.hashed.catch((()=>{}))}))),i.packets.stream=j(i.packets.stream,(async(e,t)=>{const r=z(e),i=q(t);try{for(let e=0;e{t.correspondingSigReject(e)})),await i.abort(e)}})),Bh(a,n,e,t,!1,r)):Bh(s,n,e,t,!1,r)}verifyDetached(e,t,r=new Date,i=de){const n=this.unwrapCompressed().packets.filterByTag(te.packet.literalData);if(1!==n.length)throw Error("Can only verify message with one literal data packet.");return Bh(e.packets.filterByTag(te.packet.signature),n,t,r,!0,i)}unwrapCompressed(){const e=this.packets.filterByTag(te.packet.compressedData);return e.length?new Rh(e[0].packets):this}async appendSignature(e,t=de){await this.packets.read(ie.isUint8Array(e)?e:(await we(e)).data,Uh,t)}write(){return this.packets.write()}armor(e=de){return ve(te.armor.message,this.write(),null,null,null,e)}}async function Ih(e,t,r=null,i=[],n=new Date,a=[],s=[],o=!1,c=de){const u=new vu,h=null===e.text?te.signature.binary:te.signature.text;if(await Promise.all(t.map((async(t,r)=>{const u=a[r];if(!t.isPrivate())throw Error("Need private key for signing");const d=await t.getSigningKey(i[r],n,u,c);return sh(e,t,d.keyPacket,{signatureType:h},n,u,s,o,c)}))).then((e=>{u.push(...e)})),r){const e=r.packets.filterByTag(te.packet.signature);u.push(...e)}return u}async function Bh(e,t,r,i=new Date,n=!1,a=de){return Promise.all(e.filter((function(e){return["text","binary"].includes(te.read(te.signature,e.signatureType))})).map((async function(e){return async function(e,t,r,i=new Date,n=!1,a=de){let s,o;for(const t of r){const r=t.getKeys(e.issuerKeyID);if(r.length>0){s=t,o=r[0];break}}const c=e instanceof gu?e.correspondingSig:e,u={keyID:e.issuerKeyID,verified:(async()=>{if(!o)throw Error("Could not find signing key with key ID "+e.issuerKeyID.toHex());await e.verify(o.keyPacket,e.signatureType,t[0],i,n,a);const r=await c;if(o.getCreationTime()>r.created)throw Error("Key is newer than the signature");try{await s.getSigningKey(o.getKeyID(),r.created,void 0,a)}catch(e){if(!a.allowInsecureVerificationWithReformattedKeys||!e.message.match(/Signature creation time is in the future/))throw e;await s.getSigningKey(o.getKeyID(),i,void 0,a)}return!0})(),signature:(async()=>{const e=await c,t=new vu;return e&&t.push(e),new Yu(t)})()};return u.signature.catch((()=>{})),u.verified.catch((()=>{})),u}(e,t,r,i,n,a)})))}async function Th({armoredMessage:e,binaryMessage:t,config:r,...i}){r={...de,...r};let n=e||t;if(!n)throw Error("readMessage: must pass options object containing `armoredMessage` or `binaryMessage`");if(e&&!ie.isString(e)&&!ie.isStream(e))throw Error("readMessage: options.armoredMessage must be a string or stream");if(t&&!ie.isUint8Array(t)&&!ie.isStream(t))throw Error("readMessage: options.binaryMessage must be a Uint8Array or stream");const a=Object.keys(i);if(a.length>0)throw Error("Unknown option: "+a.join(", "));const s=ie.isStream(n);if(s&&(await U(),n=I(n)),e){const{type:e,data:t}=await we(n,r);if(e!==te.armor.message)throw Error("Armored text not of type message");n=t}const o=await vu.fromBinary(n,Ch,r),c=new Rh(o);return c.fromStream=s,c}async function zh({text:e,binary:t,filename:r,date:i=new Date,format:n=(void 0!==e?"utf8":"binary"),...a}){let s=void 0!==e?e:t;if(void 0===s)throw Error("createMessage: must pass options object containing `text` or `binary`");if(e&&!ie.isString(e)&&!ie.isStream(e))throw Error("createMessage: options.text must be a string or stream");if(t&&!ie.isUint8Array(t)&&!ie.isStream(t))throw Error("createMessage: options.binary must be a Uint8Array or stream");const o=Object.keys(a);if(o.length>0)throw Error("Unknown option: "+o.join(", "));const c=ie.isStream(s);c&&(await U(),s=I(s));const u=new lu(i);void 0!==e?u.setText(s,te.write(te.literal,n)):u.setBytes(s,te.write(te.literal,n)),void 0!==r&&u.setFilename(r);const h=new vu;h.push(u);const d=new Rh(h);return d.fromStream=c,d}const qh=/*#__PURE__*/ie.constructAllowedPackets([bu]);class Fh{constructor(e,t){if(this.text=ie.removeTrailingSpaces(e).replace(/\r?\n/g,"\r\n"),t&&!(t instanceof Yu))throw Error("Invalid signature input");this.signature=t||new Yu(new vu)}getSigningKeyIDs(){const e=[];return this.signature.packets.forEach((function(t){e.push(t.issuerKeyID)})),e}async sign(e,t=null,r=[],i=new Date,n=[],a=[],s=de){const o=new lu;o.setText(this.text);const c=new Yu(await Ih(o,e,t,r,i,n,a,!0,s));return new Fh(this.text,c)}verify(e,t=new Date,r=de){const i=this.signature.packets.filterByTag(te.packet.signature),n=new lu;return n.setText(this.text),Bh(i,[n],e,t,!0,r)}getText(){return this.text.replace(/\r\n/g,"\n")}armor(e=de){let t=this.signature.packets.map((function(e){return te.read(te.hash,e.hashAlgorithm).toUpperCase()}));t=t.filter((function(e,t,r){return r.indexOf(e)===t}));const r={hash:t.join(),text:this.text,data:this.signature.packets.write()};return ve(te.armor.signed,r,void 0,void 0,void 0,e)}}async function Oh({cleartextMessage:e,config:t,...r}){if(t={...de,...t},!e)throw Error("readCleartextMessage: must pass options object containing `cleartextMessage`");if(!ie.isString(e))throw Error("readCleartextMessage: options.cleartextMessage must be a string");const i=Object.keys(r);if(i.length>0)throw Error("Unknown option: "+i.join(", "));const n=await we(e);if(n.type!==te.armor.signed)throw Error("No cleartext signed message.");const a=await vu.fromBinary(n.data,qh,t);!function(e,t){const r=function(e){const r=e=>t=>e.hashAlgorithm===t;for(let i=0;i0)throw Error("Unknown option: "+r.join(", "));return new Fh(e)}async function Nh({userIDs:e=[],passphrase:t,type:r="ecc",rsaBits:i=4096,curve:n="curve25519",keyExpirationTime:a=0,date:s=new Date,subkeys:o=[{}],format:c="armored",config:u,...h}){nd(u={...de,...u}),e=ad(e);const d=Object.keys(h);if(d.length>0)throw Error("Unknown option: "+d.join(", "));if(0===e.length)throw Error("UserIDs are required for key generation");if("rsa"===r&&ihh(e.subkeys[r],e)));let r=[eh(e,t)];r=r.concat(e.subkeys.map((e=>Ju(e,t))));const i=await Promise.all(r),n=await Eh(i[0],i.slice(1),e,t),a=await n.getRevocationCertificate(e.date,t);return n.revocationSignatures=[],{key:n,revocationCertificate:a}}(f,u);return e.getKeys().forEach((({keyPacket:e})=>ph(e,u))),{privateKey:cd(e,c,u),publicKey:cd(e.toPublic(),c,u),revocationCertificate:t}}catch(e){throw ie.wrapError("Error generating keypair",e)}}async function jh({privateKey:e,userIDs:t=[],passphrase:r,keyExpirationTime:i=0,date:n,format:a="armored",config:s,...o}){nd(s={...de,...s}),t=ad(t);const c=Object.keys(o);if(c.length>0)throw Error("Unknown option: "+c.join(", "));if(0===t.length)throw Error("UserIDs are required for key reformat");const u={privateKey:e,userIDs:t,passphrase:r,keyExpirationTime:i,date:n};try{const{key:e,revocationCertificate:t}=await async function(e,t){e=o(e);const{privateKey:r}=e;if(!r.isPrivate())throw Error("Cannot reformat a public key");if(r.keyPacket.isDummy())throw Error("Cannot reformat a gnu-dummy primary key");if(!r.getKeys().every((({keyPacket:e})=>e.isDecrypted())))throw Error("Key is not decrypted");const i=r.keyPacket;e.subkeys||(e.subkeys=await Promise.all(r.subkeys.map((async e=>{const r=e.keyPacket,n={key:i,bind:r},a=await th(e.bindingSignatures,i,te.signature.subkeyBinding,n,null,t).catch((()=>({})));return{sign:a.keyFlags&&a.keyFlags[0]&te.keyFlags.signData}}))));const n=r.subkeys.map((e=>e.keyPacket));if(e.subkeys.length!==n.length)throw Error("Number of subkey options does not match number of subkeys");e.subkeys=e.subkeys.map((t=>o(t,e)));const a=await Eh(i,n,e,t),s=await a.getRevocationCertificate(e.date,t);return a.revocationSignatures=[],{key:a,revocationCertificate:s};function o(e,t={}){return e.keyExpirationTime=e.keyExpirationTime||t.keyExpirationTime,e.passphrase=ie.isString(e.passphrase)?e.passphrase:t.passphrase,e.date=e.date||t.date,e}}(u,s);return{privateKey:cd(e,a,s),publicKey:cd(e.toPublic(),a,s),revocationCertificate:t}}catch(e){throw ie.wrapError("Error reformatting keypair",e)}}async function Wh({key:e,revocationCertificate:t,reasonForRevocation:r,date:i=new Date,format:n="armored",config:a,...s}){nd(a={...de,...a});const o=Object.keys(s);if(o.length>0)throw Error("Unknown option: "+o.join(", "));try{const s=t?await e.applyRevocationCertificate(t,i,a):await e.revoke(r,i,a);return s.isPrivate()?{privateKey:cd(s,n,a),publicKey:cd(s.toPublic(),n,a)}:{privateKey:null,publicKey:cd(s,n,a)}}catch(e){throw ie.wrapError("Error revoking key",e)}}async function Hh({privateKey:e,passphrase:t,config:r,...i}){nd(r={...de,...r});const n=Object.keys(i);if(n.length>0)throw Error("Unknown option: "+n.join(", "));if(!e.isPrivate())throw Error("Cannot decrypt a public key");const a=e.clone(!0),s=ie.isArray(t)?t:[t];try{return await Promise.all(a.getKeys().map((e=>ie.anyPromise(s.map((t=>e.keyPacket.decrypt(t))))))),await a.validate(r),a}catch(e){throw a.clearPrivateParams(),ie.wrapError("Error decrypting private key",e)}}async function Gh({privateKey:e,passphrase:t,config:r,...i}){nd(r={...de,...r});const n=Object.keys(i);if(n.length>0)throw Error("Unknown option: "+n.join(", "));if(!e.isPrivate())throw Error("Cannot encrypt a public key");const a=e.clone(!0),s=a.getKeys(),o=ie.isArray(t)?t:Array(s.length).fill(t);if(o.length!==s.length)throw Error("Invalid number of passphrases given for key encryption");try{return await Promise.all(s.map((async(e,t)=>{const{keyPacket:i}=e;await i.encrypt(o[t],r),i.clearPrivateParams()}))),a}catch(e){throw a.clearPrivateParams(),ie.wrapError("Error encrypting private key",e)}}async function Vh({message:e,encryptionKeys:t,signingKeys:r,passwords:i,sessionKey:n,format:a="armored",signature:s=null,wildcard:o=!1,signingKeyIDs:c=[],encryptionKeyIDs:u=[],date:h=new Date,signingUserIDs:d=[],encryptionUserIDs:f=[],signatureNotations:l=[],config:p,...y}){if(nd(p={...de,...p}),ed(e),rd(a),t=ad(t),r=ad(r),i=ad(i),c=ad(c),u=ad(u),d=ad(d),f=ad(f),l=ad(l),y.detached)throw Error("The `detached` option has been removed from openpgp.encrypt, separately call openpgp.sign instead. Don't forget to remove the `privateKeys` option as well.");if(y.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.encrypt, pass `encryptionKeys` instead");if(y.privateKeys)throw Error("The `privateKeys` option has been removed from openpgp.encrypt, pass `signingKeys` instead");if(void 0!==y.armor)throw Error("The `armor` option has been removed from openpgp.encrypt, pass `format` instead.");const b=Object.keys(y);if(b.length>0)throw Error("Unknown option: "+b.join(", "));r||(r=[]);const m=e.fromStream;try{if((r.length||s)&&(e=await e.sign(r,s,c,h,d,l,p)),e=e.compress(await ah("compression",t,h,f,p),p),e=await e.encrypt(t,i,n,o,u,h,f,p),"object"===a)return e;const y="armored"===a;return sd(y?e.armor(p):e.write(),m,y?"utf8":"binary")}catch(e){throw ie.wrapError("Error encrypting message",e)}}async function $h({message:e,decryptionKeys:t,passwords:r,sessionKeys:i,verificationKeys:n,expectSigned:a=!1,format:s="utf8",signature:o=null,date:c=new Date,config:u,...h}){if(nd(u={...de,...u}),ed(e),n=ad(n),t=ad(t),r=ad(r),i=ad(i),h.privateKeys)throw Error("The `privateKeys` option has been removed from openpgp.decrypt, pass `decryptionKeys` instead");if(h.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.decrypt, pass `verificationKeys` instead");const d=Object.keys(h);if(d.length>0)throw Error("Unknown option: "+d.join(", "));try{const h=await e.decrypt(t,r,i,c,u);n||(n=[]);const d={};if(d.signatures=o?await h.verifyDetached(o,n,c,u):await h.verify(n,c,u),d.data="binary"===s?h.getLiteralData():h.getText(),d.filename=h.getFilename(),od(d,e),a){if(0===n.length)throw Error("Verification keys are required to verify message signatures");if(0===d.signatures.length)throw Error("Message is not signed");d.data=T([d.data,Y((async()=>{await ie.anyPromise(d.signatures.map((e=>e.verified)))}))])}return d.data=await sd(d.data,e.fromStream,s),d}catch(e){throw ie.wrapError("Error decrypting message",e)}}async function Zh({message:e,signingKeys:t,format:r="armored",detached:i=!1,signingKeyIDs:n=[],date:a=new Date,signingUserIDs:s=[],signatureNotations:o=[],config:c,...u}){if(nd(c={...de,...c}),td(e),rd(r),t=ad(t),n=ad(n),s=ad(s),o=ad(o),u.privateKeys)throw Error("The `privateKeys` option has been removed from openpgp.sign, pass `signingKeys` instead");if(void 0!==u.armor)throw Error("The `armor` option has been removed from openpgp.sign, pass `format` instead.");const h=Object.keys(u);if(h.length>0)throw Error("Unknown option: "+h.join(", "));if(e instanceof Fh&&"binary"===r)throw Error("Cannot return signed cleartext message in binary format");if(e instanceof Fh&&i)throw Error("Cannot detach-sign a cleartext message");if(!t||0===t.length)throw Error("No signing keys provided");try{let u;if(u=i?await e.signDetached(t,void 0,n,a,s,o,c):await e.sign(t,void 0,n,a,s,o,c),"object"===r)return u;const h="armored"===r;return u=h?u.armor(c):u.write(),i&&(u=j(e.packets.write(),(async(e,t)=>{await Promise.all([F(u,t),Z(e).catch((()=>{}))])}))),sd(u,e.fromStream,h?"utf8":"binary")}catch(e){throw ie.wrapError("Error signing message",e)}}async function Xh({message:e,verificationKeys:t,expectSigned:r=!1,format:i="utf8",signature:n=null,date:a=new Date,config:s,...o}){if(nd(s={...de,...s}),td(e),t=ad(t),o.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.verify, pass `verificationKeys` instead");const c=Object.keys(o);if(c.length>0)throw Error("Unknown option: "+c.join(", "));if(e instanceof Fh&&"binary"===i)throw Error("Can't return cleartext message data as binary");if(e instanceof Fh&&n)throw Error("Can't verify detached cleartext signature");try{const o={};if(o.signatures=n?await e.verifyDetached(n,t,a,s):await e.verify(t,a,s),o.data="binary"===i?e.getLiteralData():e.getText(),e.fromStream&&od(o,e),r){if(0===o.signatures.length)throw Error("Message is not signed");o.data=T([o.data,Y((async()=>{await ie.anyPromise(o.signatures.map((e=>e.verified)))}))])}return o.data=await sd(o.data,e.fromStream,i),o}catch(e){throw ie.wrapError("Error verifying signed message",e)}}async function Yh({encryptionKeys:e,date:t=new Date,encryptionUserIDs:r=[],config:i,...n}){if(nd(i={...de,...i}),e=ad(e),r=ad(r),n.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.generateSessionKey, pass `encryptionKeys` instead");const a=Object.keys(n);if(a.length>0)throw Error("Unknown option: "+a.join(", "));try{return await Rh.generateSessionKey(e,t,r,i)}catch(e){throw ie.wrapError("Error generating session key",e)}}async function Qh({data:e,algorithm:t,aeadAlgorithm:r,encryptionKeys:i,passwords:n,format:a="armored",wildcard:s=!1,encryptionKeyIDs:o=[],date:c=new Date,encryptionUserIDs:u=[],config:h,...d}){if(nd(h={...de,...h}),function(e,t){if(!ie.isUint8Array(e))throw Error("Parameter ["+(t||"data")+"] must be of type Uint8Array")}(e),function(e,t){if(!ie.isString(e))throw Error("Parameter ["+(t||"data")+"] must be of type String")}(t,"algorithm"),rd(a),i=ad(i),n=ad(n),o=ad(o),u=ad(u),d.publicKeys)throw Error("The `publicKeys` option has been removed from openpgp.encryptSessionKey, pass `encryptionKeys` instead");const f=Object.keys(d);if(f.length>0)throw Error("Unknown option: "+f.join(", "));if(!(i&&0!==i.length||n&&0!==n.length))throw Error("No encryption keys or passwords provided.");try{return cd(await Rh.encryptSessionKey(e,t,r,i,n,s,o,c,u,h),a,h)}catch(e){throw ie.wrapError("Error encrypting session key",e)}}async function Jh({message:e,decryptionKeys:t,passwords:r,date:i=new Date,config:n,...a}){if(nd(n={...de,...n}),ed(e),t=ad(t),r=ad(r),a.privateKeys)throw Error("The `privateKeys` option has been removed from openpgp.decryptSessionKeys, pass `decryptionKeys` instead");const s=Object.keys(a);if(s.length>0)throw Error("Unknown option: "+s.join(", "));try{return await e.decryptSessionKeys(t,r,i,n)}catch(e){throw ie.wrapError("Error decrypting session keys",e)}}function ed(e){if(!(e instanceof Rh))throw Error("Parameter [message] needs to be of type Message")}function td(e){if(!(e instanceof Fh||e instanceof Rh))throw Error("Parameter [message] needs to be of type Message or CleartextMessage")}function rd(e){if("armored"!==e&&"binary"!==e&&"object"!==e)throw Error("Unsupported format "+e)}const id=Object.keys(de).length;function nd(e){const t=Object.keys(e);if(t.length!==id)for(const e of t)if(void 0===de[e])throw Error("Unknown config property: "+e)}function ad(e){return e&&!ie.isArray(e)&&(e=[e]),e}async function sd(e,t,r="utf8"){const i=ie.isStream(e);return"array"===i?Z(e):"node"===t?(e=A(e),"binary"!==r&&e.setEncoding(r),e):"web"===t&&"ponyfill"===i?M(e):e}function od(e,t){e.data=j(t.packets.stream,(async(t,r)=>{await F(e.data,r,{preventClose:!0});const i=q(r);try{await Z(t,(e=>e)),await i.close()}catch(e){await i.abort(e)}}))}function cd(e,t,r){switch(t){case"object":return e;case"armored":return e.armor(r);case"binary":return e.write();default:throw Error("Unsupported format "+t)}}const ud="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:e=>`Symbol(${e})`;function hd(){}const dd="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;function fd(e){return"object"==typeof e&&null!==e||"function"==typeof e}const ld=hd,pd=Promise,yd=Promise.prototype.then,bd=Promise.resolve.bind(pd),md=Promise.reject.bind(pd);function gd(e){return new pd(e)}function wd(e){return bd(e)}function vd(e){return md(e)}function _d(e,t,r){return yd.call(e,t,r)}function kd(e,t,r){_d(_d(e,t,r),void 0,ld)}function Ad(e,t){kd(e,t)}function Sd(e,t){kd(e,void 0,t)}function Ed(e,t,r){return _d(e,t,r)}function Pd(e){_d(e,void 0,ld)}const xd=(()=>{const e=dd&&dd.queueMicrotask;if("function"==typeof e)return e;const t=wd(void 0);return e=>_d(t,e)})();function Md(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function Kd(e,t,r){try{return wd(Md(e,t,r))}catch(e){return vd(e)}}class Cd{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(e){const t=this._back;let r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let i=r+1;const n=e._elements,a=n[r];return 16384===i&&(t=e._next,i=0),--this._size,this._cursor=i,e!==t&&(this._front=t),n[r]=void 0,a}forEach(e){let t=this._cursor,r=this._front,i=r._elements;for(;!(t===i.length&&void 0===r._next||t===i.length&&(r=r._next,i=r._elements,t=0,0===i.length));)e(i[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}function Dd(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?Bd(e):"closed"===t._state?function(e){Bd(e),qd(e)}(e):Td(e,t._storedError)}function Ud(e,t){return bp(e._ownerReadableStream,t)}function Rd(e){"readable"===e._ownerReadableStream._state?zd(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,t){Td(e,t)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function Id(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function Bd(e){e._closedPromise=gd(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function Td(e,t){Bd(e),zd(e,t)}function zd(e,t){void 0!==e._closedPromise_reject&&(Pd(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function qd(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const Fd=ud("[[AbortSteps]]"),Od=ud("[[ErrorSteps]]"),Ld=ud("[[CancelSteps]]"),Nd=ud("[[PullSteps]]"),jd=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},Wd=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function Hd(e,t){if(void 0!==e&&("object"!=typeof(r=e)&&"function"!=typeof r))throw new TypeError(t+" is not an object.");var r}function Gd(e,t){if("function"!=typeof e)throw new TypeError(t+" is not a function.")}function Vd(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(t+" is not an object.")}function $d(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function Zd(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function Xd(e){return Number(e)}function Yd(e){return 0===e?0:e}function Qd(e,t){const r=Number.MAX_SAFE_INTEGER;let i=Number(e);if(i=Yd(i),!jd(i))throw new TypeError(t+" is not a finite number");if(i=function(e){return Yd(Wd(e))}(i),i<0||i>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return jd(i)&&0!==i?i:0}function Jd(e,t){if(!pp(e))throw new TypeError(t+" is not a ReadableStream.")}function ef(e){return new sf(e)}function tf(e,t){e._reader._readRequests.push(t)}function rf(e,t,r){const i=e._reader._readRequests.shift();r?i._closeSteps():i._chunkSteps(t)}function nf(e){return e._reader._readRequests.length}function af(e){const t=e._reader;return void 0!==t&&!!of(t)}class sf{constructor(e){if($d(e,1,"ReadableStreamDefaultReader"),Jd(e,"First parameter"),yp(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Dd(this,e),this._readRequests=new Cd}get closed(){return of(this)?this._closedPromise:vd(uf("closed"))}cancel(e=undefined){return of(this)?void 0===this._ownerReadableStream?vd(Id("cancel")):Ud(this,e):vd(uf("cancel"))}read(){if(!of(this))return vd(uf("read"));if(void 0===this._ownerReadableStream)return vd(Id("read from"));let e,t;const r=gd(((r,i)=>{e=r,t=i}));return cf(this,{_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)}),r}releaseLock(){if(!of(this))throw uf("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");Rd(this)}}}function of(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function cf(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[Nd](t)}function uf(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}let hf;Object.defineProperties(sf.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(sf.prototype,ud.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0}),"symbol"==typeof ud.asyncIterator&&(hf={[ud.asyncIterator](){return this}},Object.defineProperty(hf,ud.asyncIterator,{enumerable:!1}));class df{constructor(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}next(){const e=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?Ed(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?Ed(this._ongoingPromise,t,t):t()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader;if(void 0===e._ownerReadableStream)return vd(Id("iterate"));let t,r;const i=gd(((e,i)=>{t=e,r=i}));return cf(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,xd((()=>t({value:e,done:!1})))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,Rd(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,Rd(e),r(t)}}),i}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(void 0===t._ownerReadableStream)return vd(Id("finish iterating"));if(!this._preventCancel){const r=Ud(t,e);return Rd(t),Ed(r,(()=>({value:e,done:!0})))}return Rd(t),wd({value:e,done:!0})}}const ff={next(){return lf(this)?this._asyncIteratorImpl.next():vd(pf("next"))},return(e){return lf(this)?this._asyncIteratorImpl.return(e):vd(pf("return"))}};function lf(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl")}function pf(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}void 0!==hf&&Object.setPrototypeOf(ff,hf);const yf=Number.isNaN||function(e){return e!=e};function bf(e){return!!function(e){if("number"!=typeof e)return!1;if(yf(e))return!1;if(e<0)return!1;return!0}(e)&&e!==1/0}function mf(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function gf(e,t,r){if(!bf(r=Number(r)))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function wf(e){e._queue=new Cd,e._queueTotalSize=0}function vf(e){return e.slice()}class _f{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!Sf(this))throw Of("view");return this._view}respond(e){if(!Sf(this))throw Of("respond");if($d(e,1,"respond"),e=Qd(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,function(e,t){if(t=Number(t),!bf(t))throw new RangeError("bytesWritten must be a finite");If(e,t)}(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!Sf(this))throw Of("respondWithNewView");if($d(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");!function(e,t){const r=e._pendingPullIntos.peek();if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.byteLength!==t.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");r.buffer=t.buffer,If(e,t.byteLength)}(this._associatedReadableByteStreamController,e)}}Object.defineProperties(_f.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(_f.prototype,ud.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class kf{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!Af(this))throw Lf("byobRequest");if(null===this._byobRequest&&this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek(),t=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),r=Object.create(_f.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(r,this,t),this._byobRequest=r}return this._byobRequest}get desiredSize(){if(!Af(this))throw Lf("desiredSize");return qf(this)}close(){if(!Af(this))throw Lf("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);!function(e){const t=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==t._state)return;if(e._queueTotalSize>0)return void(e._closeRequested=!0);if(e._pendingPullIntos.length>0){if(e._pendingPullIntos.peek().bytesFilled>0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw zf(e,t),t}}Tf(e),mp(t)}(this)}enqueue(e){if(!Af(this))throw Lf("enqueue");if($d(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);!function(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const i=t.buffer,n=t.byteOffset,a=t.byteLength,s=i;if(af(r))if(0===nf(r))Mf(e,s,n,a);else{rf(r,new Uint8Array(s,n,a),!1)}else Wf(r)?(Mf(e,s,n,a),Rf(e)):Mf(e,s,n,a);Ef(e)}(this,e)}error(e=undefined){if(!Af(this))throw Lf("error");zf(this,e)}[Ld](e){if(this._pendingPullIntos.length>0){this._pendingPullIntos.peek().bytesFilled=0}wf(this);const t=this._cancelAlgorithm(e);return Tf(this),t}[Nd](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0){const t=this._queue.shift();this._queueTotalSize-=t.byteLength,Df(this);const r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return void e._chunkSteps(r)}const r=this._autoAllocateChunkSize;if(void 0!==r){let t;try{t=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}const i={buffer:t,byteOffset:0,byteLength:r,bytesFilled:0,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(i)}tf(t,e),Ef(this)}}function Af(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function Sf(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function Ef(e){const t=function(e){const t=e._controlledReadableByteStream;if("readable"!==t._state)return!1;if(e._closeRequested)return!1;if(!e._started)return!1;if(af(t)&&nf(t)>0)return!0;if(Wf(t)&&jf(t)>0)return!0;const r=qf(e);if(r>0)return!0;return!1}(e);if(!t)return;if(e._pulling)return void(e._pullAgain=!0);e._pulling=!0;kd(e._pullAlgorithm(),(()=>{e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,Ef(e))}),(t=>{zf(e,t)}))}function Pf(e,t){let r=!1;"closed"===e._state&&(r=!0);const i=xf(t);"default"===t.readerType?rf(e,i,r):function(e,t,r){const i=e._reader,n=i._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,i,r)}function xf(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function Mf(e,t,r,i){e._queue.push({buffer:t,byteOffset:r,byteLength:i}),e._queueTotalSize+=i}function Kf(e,t){const r=t.elementSize,i=t.bytesFilled-t.bytesFilled%r,n=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),a=t.bytesFilled+n,s=a-a%r;let o=n,c=!1;s>i&&(o=s-t.bytesFilled,c=!0);const u=e._queue;for(;o>0;){const r=u.peek(),i=Math.min(o,r.byteLength),n=t.byteOffset+t.bytesFilled;h=t.buffer,d=n,f=r.buffer,l=r.byteOffset,p=i,new Uint8Array(h).set(new Uint8Array(f,l,p),d),r.byteLength===i?u.shift():(r.byteOffset+=i,r.byteLength-=i),e._queueTotalSize-=i,Cf(e,i,t),o-=i}var h,d,f,l,p;return c}function Cf(e,t,r){Uf(e),r.bytesFilled+=t}function Df(e){0===e._queueTotalSize&&e._closeRequested?(Tf(e),mp(e._controlledReadableByteStream)):Ef(e)}function Uf(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Rf(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();Kf(e,t)&&(Bf(e),Pf(e._controlledReadableByteStream,t))}}function If(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");!function(e,t){t.buffer=t.buffer;const r=e._controlledReadableByteStream;if(Wf(r))for(;jf(r)>0;)Pf(r,Bf(e))}(e,r)}else!function(e,t,r){if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range");if(Cf(e,t,r),r.bytesFilled0){const t=r.byteOffset+r.bytesFilled,n=r.buffer.slice(t-i,t);Mf(e,n,0,n.byteLength)}r.buffer=r.buffer,r.bytesFilled-=i,Pf(e._controlledReadableByteStream,r),Rf(e)}(e,t,r);Ef(e)}function Bf(e){const t=e._pendingPullIntos.shift();return Uf(e),t}function Tf(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function zf(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(!function(e){Uf(e),e._pendingPullIntos=new Cd}(e),wf(e),Tf(e),gp(r,t))}function qf(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Ff(e,t,r){const i=Object.create(kf.prototype);let n=()=>{},a=()=>wd(void 0),s=()=>wd(void 0);void 0!==t.start&&(n=()=>t.start(i)),void 0!==t.pull&&(a=()=>t.pull(i)),void 0!==t.cancel&&(s=e=>t.cancel(e));const o=t.autoAllocateChunkSize;if(0===o)throw new TypeError("autoAllocateChunkSize must be greater than 0");!function(e,t,r,i,n,a,s){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,wf(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=a,t._pullAlgorithm=i,t._cancelAlgorithm=n,t._autoAllocateChunkSize=s,t._pendingPullIntos=new Cd,e._readableStreamController=t,kd(wd(r()),(()=>{t._started=!0,Ef(t)}),(e=>{zf(t,e)}))}(e,i,n,a,s,r,o)}function Of(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Lf(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function Nf(e,t){e._reader._readIntoRequests.push(t)}function jf(e){return e._reader._readIntoRequests.length}function Wf(e){const t=e._reader;return void 0!==t&&!!Gf(t)}Object.defineProperties(kf.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(kf.prototype,ud.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class Hf{constructor(e){if($d(e,1,"ReadableStreamBYOBReader"),Jd(e,"First parameter"),yp(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!Af(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");Dd(this,e),this._readIntoRequests=new Cd}get closed(){return Gf(this)?this._closedPromise:vd(Vf("closed"))}cancel(e=undefined){return Gf(this)?void 0===this._ownerReadableStream?vd(Id("cancel")):Ud(this,e):vd(Vf("cancel"))}read(e){if(!Gf(this))return vd(Vf("read"));if(!ArrayBuffer.isView(e))return vd(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return vd(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return vd(new TypeError("view's buffer must have non-zero byteLength"));if(void 0===this._ownerReadableStream)return vd(Id("read from"));let t,r;const i=gd(((e,i)=>{t=e,r=i}));return function(e,t,r){const i=e._ownerReadableStream;i._disturbed=!0,"errored"===i._state?r._errorSteps(i._storedError):function(e,t,r){const i=e._controlledReadableByteStream;let n=1;t.constructor!==DataView&&(n=t.constructor.BYTES_PER_ELEMENT);const a=t.constructor,s={buffer:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:n,viewConstructor:a,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(s),void Nf(i,r);if("closed"!==i._state){if(e._queueTotalSize>0){if(Kf(e,s)){const t=xf(s);return Df(e),void r._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return zf(e,t),void r._errorSteps(t)}}e._pendingPullIntos.push(s),Nf(i,r),Ef(e)}else{const e=new a(s.buffer,s.byteOffset,0);r._closeSteps(e)}}(i._readableStreamController,t,r)}(this,e,{_chunkSteps:e=>t({value:e,done:!1}),_closeSteps:e=>t({value:e,done:!0}),_errorSteps:e=>r(e)}),i}releaseLock(){if(!Gf(this))throw Vf("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");Rd(this)}}}function Gf(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Vf(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function $f(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(yf(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function Zf(e){const{size:t}=e;return t||(()=>1)}function Xf(e,t){Hd(e,t);const r=null==e?void 0:e.highWaterMark,i=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:Xd(r),size:void 0===i?void 0:Yf(i,t+" has member 'size' that")}}function Yf(e,t){return Gd(e,t),t=>Xd(e(t))}function Qf(e,t,r){return Gd(e,r),r=>Kd(e,t,[r])}function Jf(e,t,r){return Gd(e,r),()=>Kd(e,t,[])}function el(e,t,r){return Gd(e,r),r=>Md(e,t,[r])}function tl(e,t,r){return Gd(e,r),(r,i)=>Kd(e,t,[r,i])}function rl(e,t){if(!sl(e))throw new TypeError(t+" is not a WritableStream.")}Object.defineProperties(Hf.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(Hf.prototype,ud.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});class il{constructor(e={},t={}){void 0===e?e=null:Vd(e,"First parameter");const r=Xf(t,"Second parameter"),i=function(e,t){Hd(e,t);const r=null==e?void 0:e.abort,i=null==e?void 0:e.close,n=null==e?void 0:e.start,a=null==e?void 0:e.type,s=null==e?void 0:e.write;return{abort:void 0===r?void 0:Qf(r,e,t+" has member 'abort' that"),close:void 0===i?void 0:Jf(i,e,t+" has member 'close' that"),start:void 0===n?void 0:el(n,e,t+" has member 'start' that"),write:void 0===s?void 0:tl(s,e,t+" has member 'write' that"),type:a}}(e,"First parameter");al(this);if(void 0!==i.type)throw new RangeError("Invalid type is specified");const n=Zf(r);!function(e,t,r,i){const n=Object.create(Sl.prototype);let a=()=>{},s=()=>wd(void 0),o=()=>wd(void 0),c=()=>wd(void 0);void 0!==t.start&&(a=()=>t.start(n));void 0!==t.write&&(s=e=>t.write(e,n));void 0!==t.close&&(o=()=>t.close());void 0!==t.abort&&(c=e=>t.abort(e));El(e,n,a,s,o,c,r,i)}(this,i,$f(r,1),n)}get locked(){if(!sl(this))throw Ul("locked");return ol(this)}abort(e=undefined){return sl(this)?ol(this)?vd(new TypeError("Cannot abort a stream that already has a writer")):cl(this,e):vd(Ul("abort"))}close(){return sl(this)?ol(this)?vd(new TypeError("Cannot close a stream that already has a writer")):ll(this)?vd(new TypeError("Cannot close an already-closing stream")):ul(this):vd(Ul("close"))}getWriter(){if(!sl(this))throw Ul("getWriter");return nl(this)}}function nl(e){return new bl(e)}function al(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new Cd,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function sl(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function ol(e){return void 0!==e._writer}function cl(e,t){const r=e._state;if("closed"===r||"errored"===r)return wd(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let i=!1;"erroring"===r&&(i=!0,t=void 0);const n=gd(((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:i}}));return e._pendingAbortRequest._promise=n,i||dl(e,t),n}function ul(e){const t=e._state;if("closed"===t||"errored"===t)return vd(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=gd(((t,r)=>{const i={_resolve:t,_reject:r};e._closeRequest=i})),i=e._writer;var n;return void 0!==i&&e._backpressure&&"writable"===t&&jl(i),gf(n=e._writableStreamController,Al,0),Ml(n),r}function hl(e,t){"writable"!==e._state?fl(e):dl(e,t)}function dl(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const i=e._writer;void 0!==i&&vl(i,t),!function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&r._started&&fl(e)}function fl(e){e._state="errored",e._writableStreamController[Od]();const t=e._storedError;if(e._writeRequests.forEach((e=>{e._reject(t)})),e._writeRequests=new Cd,void 0===e._pendingAbortRequest)return void pl(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void pl(e);kd(e._writableStreamController[Fd](r._reason),(()=>{r._resolve(),pl(e)}),(t=>{r._reject(t),pl(e)}))}function ll(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function pl(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&zl(t,e._storedError)}function yl(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){Fl(e)}(r):jl(r)),e._backpressure=t}Object.defineProperties(il.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(il.prototype,ud.toStringTag,{value:"WritableStream",configurable:!0});class bl{constructor(e){if($d(e,1,"WritableStreamDefaultWriter"),rl(e,"First parameter"),ol(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!ll(e)&&e._backpressure?Fl(this):Ll(this),Bl(this);else if("erroring"===t)Ol(this,e._storedError),Bl(this);else if("closed"===t)Ll(this),Bl(r=this),ql(r);else{const t=e._storedError;Ol(this,t),Tl(this,t)}var r}get closed(){return ml(this)?this._closedPromise:vd(Rl("closed"))}get desiredSize(){if(!ml(this))throw Rl("desiredSize");if(void 0===this._ownerWritableStream)throw Il("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;if("errored"===r||"erroring"===r)return null;if("closed"===r)return 0;return xl(t._writableStreamController)}(this)}get ready(){return ml(this)?this._readyPromise:vd(Rl("ready"))}abort(e=undefined){return ml(this)?void 0===this._ownerWritableStream?vd(Il("abort")):function(e,t){const r=e._ownerWritableStream;return cl(r,t)}(this,e):vd(Rl("abort"))}close(){if(!ml(this))return vd(Rl("close"));const e=this._ownerWritableStream;return void 0===e?vd(Il("close")):ll(e)?vd(new TypeError("Cannot close an already-closing stream")):gl(this)}releaseLock(){if(!ml(this))throw Rl("releaseLock");void 0!==this._ownerWritableStream&&_l(this)}write(e=undefined){return ml(this)?void 0===this._ownerWritableStream?vd(Il("write to")):kl(this,e):vd(Rl("write"))}}function ml(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function gl(e){return ul(e._ownerWritableStream)}function wl(e,t){"pending"===e._closedPromiseState?zl(e,t):function(e,t){Tl(e,t)}(e,t)}function vl(e,t){"pending"===e._readyPromiseState?Nl(e,t):function(e,t){Ol(e,t)}(e,t)}function _l(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");vl(e,r),wl(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function kl(e,t){const r=e._ownerWritableStream,i=r._writableStreamController,n=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Kl(e,t),1}}(i,t);if(r!==e._ownerWritableStream)return vd(Il("write to"));const a=r._state;if("errored"===a)return vd(r._storedError);if(ll(r)||"closed"===a)return vd(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===a)return vd(r._storedError);const s=function(e){return gd(((t,r)=>{const i={_resolve:t,_reject:r};e._writeRequests.push(i)}))}(r);return function(e,t,r){try{gf(e,t,r)}catch(t){return void Kl(e,t)}const i=e._controlledWritableStream;if(!ll(i)&&"writable"===i._state){yl(i,Cl(e))}Ml(e)}(i,t,n),s}Object.defineProperties(bl.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(bl.prototype,ud.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Al={};class Sl{constructor(){throw new TypeError("Illegal constructor")}error(e=undefined){if(!function(e){if(!fd(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream"))return!1;return!0}(this))throw new TypeError("WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController");"writable"===this._controlledWritableStream._state&&Dl(this,e)}[Fd](e){const t=this._abortAlgorithm(e);return Pl(this),t}[Od](){wf(this)}}function El(e,t,r,i,n,a,s,o){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,wf(t),t._started=!1,t._strategySizeAlgorithm=o,t._strategyHWM=s,t._writeAlgorithm=i,t._closeAlgorithm=n,t._abortAlgorithm=a;const c=Cl(t);yl(e,c);kd(wd(r()),(()=>{t._started=!0,Ml(t)}),(r=>{t._started=!0,hl(e,r)}))}function Pl(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function xl(e){return e._strategyHWM-e._queueTotalSize}function Ml(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void fl(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Al?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),mf(e);const r=e._closeAlgorithm();Pl(e),kd(r,(()=>{!function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&ql(t)}(t)}),(e=>{!function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),hl(e,t)}(t,e)}))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r);const i=e._writeAlgorithm(t);kd(i,(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(mf(e),!ll(r)&&"writable"===t){const t=Cl(e);yl(r,t)}Ml(e)}),(t=>{"writable"===r._state&&Pl(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,hl(e,t)}(r,t)}))}(e,r)}function Kl(e,t){"writable"===e._controlledWritableStream._state&&Dl(e,t)}function Cl(e){return xl(e)<=0}function Dl(e,t){const r=e._controlledWritableStream;Pl(e),dl(r,t)}function Ul(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function Rl(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function Il(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Bl(e){e._closedPromise=gd(((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"}))}function Tl(e,t){Bl(e),zl(e,t)}function zl(e,t){void 0!==e._closedPromise_reject&&(Pd(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function ql(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function Fl(e){e._readyPromise=gd(((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r})),e._readyPromiseState="pending"}function Ol(e,t){Fl(e),Nl(e,t)}function Ll(e){Fl(e),jl(e)}function Nl(e,t){void 0!==e._readyPromise_reject&&(Pd(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function jl(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(Sl.prototype,{error:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(Sl.prototype,ud.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const Wl="undefined"!=typeof DOMException?DOMException:void 0;const Hl=function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;try{return new e,!0}catch(e){return!1}}(Wl)?Wl:function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return Object.defineProperty(e.prototype=Object.create(Error.prototype),"constructor",{value:e,writable:!0,configurable:!0}),e}();function Gl(e,t,r,i,n,a){const s=ef(e),o=nl(t);e._disturbed=!0;let c=!1,u=wd(void 0);return gd(((h,d)=>{let f;if(void 0!==a){if(f=()=>{const r=new Hl("Aborted","AbortError"),a=[];i||a.push((()=>"writable"===t._state?cl(t,r):wd(void 0))),n||a.push((()=>"readable"===e._state?bp(e,r):wd(void 0))),y((()=>Promise.all(a.map((e=>e())))),!0,r)},a.aborted)return void f();a.addEventListener("abort",f)}if(p(e,s._closedPromise,(e=>{i?b(!0,e):y((()=>cl(t,e)),!0,e)})),p(t,o._closedPromise,(t=>{n?b(!0,t):y((()=>bp(e,t)),!0,t)})),function(e,t,r){"closed"===e._state?r():Ad(t,r)}(e,s._closedPromise,(()=>{r?b():y((()=>function(e){const t=e._ownerWritableStream,r=t._state;return ll(t)||"closed"===r?wd(void 0):"errored"===r?vd(t._storedError):gl(e)}(o)))})),ll(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");n?b(!0,t):y((()=>bp(e,t)),!0,t)}function l(){const e=u;return _d(u,(()=>e!==u?l():void 0))}function p(e,t,r){"errored"===e._state?r(e._storedError):Sd(t,r)}function y(e,r,i){function n(){kd(e(),(()=>m(r,i)),(e=>m(!0,e)))}c||(c=!0,"writable"!==t._state||ll(t)?n():Ad(l(),n))}function b(e,r){c||(c=!0,"writable"!==t._state||ll(t)?m(e,r):Ad(l(),(()=>m(e,r))))}function m(e,t){_l(o),Rd(s),void 0!==a&&a.removeEventListener("abort",f),e?d(t):h(void 0)}Pd(gd(((e,t)=>{!function r(i){i?e():_d(c?wd(!0):_d(o._readyPromise,(()=>gd(((e,t)=>{cf(s,{_chunkSteps:t=>{u=_d(kl(o,t),void 0,hd),e(!1)},_closeSteps:()=>e(!0),_errorSteps:t})})))),r,t)}(!1)})))}))}class Vl{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!$l(this))throw np("desiredSize");return tp(this)}close(){if(!$l(this))throw np("close");if(!rp(this))throw new TypeError("The stream is not in a state that permits close");Ql(this)}enqueue(e=undefined){if(!$l(this))throw np("enqueue");if(!rp(this))throw new TypeError("The stream is not in a state that permits enqueue");return Jl(this,e)}error(e=undefined){if(!$l(this))throw np("error");ep(this,e)}[Ld](e){wf(this);const t=this._cancelAlgorithm(e);return Yl(this),t}[Nd](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=mf(this);this._closeRequested&&0===this._queue.length?(Yl(this),mp(t)):Zl(this),e._chunkSteps(r)}else tf(t,e),Zl(this)}}function $l(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function Zl(e){if(!Xl(e))return;if(e._pulling)return void(e._pullAgain=!0);e._pulling=!0;kd(e._pullAlgorithm(),(()=>{e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,Zl(e))}),(t=>{ep(e,t)}))}function Xl(e){const t=e._controlledReadableStream;if(!rp(e))return!1;if(!e._started)return!1;if(yp(t)&&nf(t)>0)return!0;return tp(e)>0}function Yl(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Ql(e){if(!rp(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Yl(e),mp(t))}function Jl(e,t){if(!rp(e))return;const r=e._controlledReadableStream;if(yp(r)&&nf(r)>0)rf(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw ep(e,t),t}try{gf(e,t,r)}catch(t){throw ep(e,t),t}}Zl(e)}function ep(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(wf(e),Yl(e),gp(r,t))}function tp(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function rp(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function ip(e,t,r,i,n,a,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,wf(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=s,t._strategyHWM=a,t._pullAlgorithm=i,t._cancelAlgorithm=n,e._readableStreamController=t;kd(wd(r()),(()=>{t._started=!0,Zl(t)}),(e=>{ep(t,e)}))}function np(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function ap(e,t,r){return Gd(e,r),r=>Kd(e,t,[r])}function sp(e,t,r){return Gd(e,r),r=>Kd(e,t,[r])}function op(e,t,r){return Gd(e,r),r=>Md(e,t,[r])}function cp(e,t){if("bytes"!==(e=""+e))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function up(e,t){if("byob"!==(e=""+e))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function hp(e,t){Hd(e,t);const r=null==e?void 0:e.preventAbort,i=null==e?void 0:e.preventCancel,n=null==e?void 0:e.preventClose,a=null==e?void 0:e.signal;return void 0!==a&&function(e,t){if(!function(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}(e))throw new TypeError(t+" is not an AbortSignal.")}(a,t+" has member 'signal' that"),{preventAbort:!!r,preventCancel:!!i,preventClose:!!n,signal:a}}Object.defineProperties(Vl.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(Vl.prototype,ud.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class dp{constructor(e={},t={}){void 0===e?e=null:Vd(e,"First parameter");const r=Xf(t,"Second parameter"),i=function(e,t){Hd(e,t);const r=e,i=null==r?void 0:r.autoAllocateChunkSize,n=null==r?void 0:r.cancel,a=null==r?void 0:r.pull,s=null==r?void 0:r.start,o=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===i?void 0:Qd(i,t+" has member 'autoAllocateChunkSize' that"),cancel:void 0===n?void 0:ap(n,r,t+" has member 'cancel' that"),pull:void 0===a?void 0:sp(a,r,t+" has member 'pull' that"),start:void 0===s?void 0:op(s,r,t+" has member 'start' that"),type:void 0===o?void 0:cp(o,t+" has member 'type' that")}}(e,"First parameter");if(lp(this),"bytes"===i.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");Ff(this,i,$f(r,0))}else{const e=Zf(r);!function(e,t,r,i){const n=Object.create(Vl.prototype);let a=()=>{},s=()=>wd(void 0),o=()=>wd(void 0);void 0!==t.start&&(a=()=>t.start(n)),void 0!==t.pull&&(s=()=>t.pull(n)),void 0!==t.cancel&&(o=e=>t.cancel(e)),ip(e,n,a,s,o,r,i)}(this,i,$f(r,1),e)}}get locked(){if(!pp(this))throw wp("locked");return yp(this)}cancel(e=undefined){return pp(this)?yp(this)?vd(new TypeError("Cannot cancel a stream that already has a reader")):bp(this,e):vd(wp("cancel"))}getReader(e=undefined){if(!pp(this))throw wp("getReader");const t=function(e,t){Hd(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:up(r,t+" has member 'mode' that")}}(e,"First parameter");return void 0===t.mode?ef(this):function(e){return new Hf(e)}(this)}pipeThrough(e,t={}){if(!pp(this))throw wp("pipeThrough");$d(e,1,"pipeThrough");const r=function(e,t){Hd(e,t);const r=null==e?void 0:e.readable;Zd(r,"readable","ReadableWritablePair"),Jd(r,t+" has member 'readable' that");const i=null==e?void 0:e.writable;return Zd(i,"writable","ReadableWritablePair"),rl(i,t+" has member 'writable' that"),{readable:r,writable:i}}(e,"First parameter"),i=hp(t,"Second parameter");if(yp(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(ol(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return Pd(Gl(this,r.writable,i.preventClose,i.preventAbort,i.preventCancel,i.signal)),r.readable}pipeTo(e,t={}){if(!pp(this))return vd(wp("pipeTo"));if(void 0===e)return vd("Parameter 1 is required in 'pipeTo'.");if(!sl(e))return vd(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=hp(t,"Second parameter")}catch(e){return vd(e)}return yp(this)?vd(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):ol(e)?vd(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Gl(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!pp(this))throw wp("tee");const e=function(e,t){const r=ef(e);let i,n,a,s,o,c=!1,u=!1,h=!1;const d=gd((e=>{o=e}));function f(){return c||(c=!0,cf(r,{_chunkSteps:e=>{xd((()=>{c=!1;const t=e,r=e;u||Jl(a._readableStreamController,t),h||Jl(s._readableStreamController,r)}))},_closeSteps:()=>{c=!1,u||Ql(a._readableStreamController),h||Ql(s._readableStreamController),u&&h||o(void 0)},_errorSteps:()=>{c=!1}})),wd(void 0)}function l(){}return a=fp(l,f,(function(t){if(u=!0,i=t,h){const t=vf([i,n]),r=bp(e,t);o(r)}return d})),s=fp(l,f,(function(t){if(h=!0,n=t,u){const t=vf([i,n]),r=bp(e,t);o(r)}return d})),Sd(r._closedPromise,(e=>{ep(a._readableStreamController,e),ep(s._readableStreamController,e),u&&h||o(void 0)})),[a,s]}(this);return vf(e)}values(e=undefined){if(!pp(this))throw wp("values");return function(e,t){const r=ef(e),i=new df(r,t),n=Object.create(ff);return n._asyncIteratorImpl=i,n}(this,function(e,t){return Hd(e,t),{preventCancel:!!(null==e?void 0:e.preventCancel)}}(e,"First parameter").preventCancel)}}function fp(e,t,r,i=1,n=(()=>1)){const a=Object.create(dp.prototype);lp(a);return ip(a,Object.create(Vl.prototype),e,t,r,i,n),a}function lp(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function pp(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function yp(e){return void 0!==e._reader}function bp(e,t){if(e._disturbed=!0,"closed"===e._state)return wd(void 0);if("errored"===e._state)return vd(e._storedError);mp(e);return Ed(e._readableStreamController[Ld](t),hd)}function mp(e){e._state="closed";const t=e._reader;void 0!==t&&(qd(t),of(t)&&(t._readRequests.forEach((e=>{e._closeSteps()})),t._readRequests=new Cd))}function gp(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(zd(r,t),of(r)?(r._readRequests.forEach((e=>{e._errorSteps(t)})),r._readRequests=new Cd):(r._readIntoRequests.forEach((e=>{e._errorSteps(t)})),r._readIntoRequests=new Cd))}function wp(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function vp(e,t){Hd(e,t);const r=null==e?void 0:e.highWaterMark;return Zd(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:Xd(r)}}Object.defineProperties(dp.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(dp.prototype,ud.toStringTag,{value:"ReadableStream",configurable:!0}),"symbol"==typeof ud.asyncIterator&&Object.defineProperty(dp.prototype,ud.asyncIterator,{value:dp.prototype.values,writable:!0,configurable:!0});const _p=function(e){return e.byteLength};class kp{constructor(e){$d(e,1,"ByteLengthQueuingStrategy"),e=vp(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!Sp(this))throw Ap("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!Sp(this))throw Ap("size");return _p}}function Ap(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function Sp(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")}Object.defineProperties(kp.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(kp.prototype,ud.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const Ep=function(){return 1};class Pp{constructor(e){$d(e,1,"CountQueuingStrategy"),e=vp(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!Mp(this))throw xp("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!Mp(this))throw xp("size");return Ep}}function xp(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function Mp(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")}function Kp(e,t,r){return Gd(e,r),r=>Kd(e,t,[r])}function Cp(e,t,r){return Gd(e,r),r=>Md(e,t,[r])}function Dp(e,t,r){return Gd(e,r),(r,i)=>Kd(e,t,[r,i])}Object.defineProperties(Pp.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(Pp.prototype,ud.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class Up{constructor(e={},t={},r={}){void 0===e&&(e=null);const i=Xf(t,"Second parameter"),n=Xf(r,"Third parameter"),a=function(e,t){Hd(e,t);const r=null==e?void 0:e.flush,i=null==e?void 0:e.readableType,n=null==e?void 0:e.start,a=null==e?void 0:e.transform,s=null==e?void 0:e.writableType;return{flush:void 0===r?void 0:Kp(r,e,t+" has member 'flush' that"),readableType:i,start:void 0===n?void 0:Cp(n,e,t+" has member 'start' that"),transform:void 0===a?void 0:Dp(a,e,t+" has member 'transform' that"),writableType:s}}(e,"First parameter");if(void 0!==a.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==a.writableType)throw new RangeError("Invalid writableType specified");const s=$f(n,0),o=Zf(n),c=$f(i,1),u=Zf(i);let h;!function(e,t,r,i,n,a){function s(){return t}function o(t){return function(e,t){const r=e._transformStreamController;if(e._backpressure){return Ed(e._backpressureChangePromise,(()=>{const i=e._writable;if("erroring"===i._state)throw i._storedError;return Lp(r,t)}))}return Lp(r,t)}(e,t)}function c(t){return function(e,t){return Ip(e,t),wd(void 0)}(e,t)}function u(){return function(e){const t=e._readable,r=e._transformStreamController,i=r._flushAlgorithm();return Fp(r),Ed(i,(()=>{if("errored"===t._state)throw t._storedError;Ql(t._readableStreamController)}),(r=>{throw Ip(e,r),t._storedError}))}(e)}function h(){return function(e){return Tp(e,!1),e._backpressureChangePromise}(e)}function d(t){return Bp(e,t),wd(void 0)}e._writable=function(e,t,r,i,n=1,a=(()=>1)){const s=Object.create(il.prototype);return al(s),El(s,Object.create(Sl.prototype),e,t,r,i,n,a),s}(s,o,u,c,r,i),e._readable=fp(s,h,d,n,a),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Tp(e,!0),e._transformStreamController=void 0}(this,gd((e=>{h=e})),c,u,s,o),function(e,t){const r=Object.create(zp.prototype);let i=e=>{try{return Op(r,e),wd(void 0)}catch(e){return vd(e)}},n=()=>wd(void 0);void 0!==t.transform&&(i=e=>t.transform(e,r));void 0!==t.flush&&(n=()=>t.flush(r));!function(e,t,r,i){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=i}(e,r,i,n)}(this,a),void 0!==a.start?h(a.start(this._transformStreamController)):h(void 0)}get readable(){if(!Rp(this))throw jp("readable");return this._readable}get writable(){if(!Rp(this))throw jp("writable");return this._writable}}function Rp(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function Ip(e,t){ep(e._readable._readableStreamController,t),Bp(e,t)}function Bp(e,t){Fp(e._transformStreamController),Kl(e._writable._writableStreamController,t),e._backpressure&&Tp(e,!1)}function Tp(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=gd((t=>{e._backpressureChangePromise_resolve=t})),e._backpressure=t}Object.defineProperties(Up.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(Up.prototype,ud.toStringTag,{value:"TransformStream",configurable:!0});class zp{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!qp(this))throw Np("desiredSize");return tp(this._controlledTransformStream._readable._readableStreamController)}enqueue(e=undefined){if(!qp(this))throw Np("enqueue");Op(this,e)}error(e=undefined){if(!qp(this))throw Np("error");var t;t=e,Ip(this._controlledTransformStream,t)}terminate(){if(!qp(this))throw Np("terminate");!function(e){const t=e._controlledTransformStream,r=t._readable._readableStreamController;Ql(r);Bp(t,new TypeError("TransformStream terminated"))}(this)}}function qp(e){return!!fd(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function Fp(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Op(e,t){const r=e._controlledTransformStream,i=r._readable._readableStreamController;if(!rp(i))throw new TypeError("Readable side is not in a state that permits enqueue");try{Jl(i,t)}catch(e){throw Bp(r,e),r._readable._storedError}const n=function(e){return!Xl(e)}(i);n!==r._backpressure&&Tp(r,!0)}function Lp(e,t){return Ed(e._transformAlgorithm(t),void 0,(t=>{throw Ip(e._controlledTransformStream,t),t}))}function Np(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function jp(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}Object.defineProperties(zp.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof ud.toStringTag&&Object.defineProperty(zp.prototype,ud.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});var Wp=/*#__PURE__*/Object.freeze({__proto__:null,ByteLengthQueuingStrategy:kp,CountQueuingStrategy:Pp,ReadableByteStreamController:kf,ReadableStream:dp,ReadableStreamBYOBReader:Hf,ReadableStreamBYOBRequest:_f,ReadableStreamDefaultController:Vl,ReadableStreamDefaultReader:sf,TransformStream:Up,TransformStreamDefaultController:zp,WritableStream:il,WritableStreamDefaultController:Sl,WritableStreamDefaultWriter:bl}),Hp=function(e,t){return Hp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Hp(e,t)}; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function Gp(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function r(){this.constructor=e}Hp(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Vp(e){if(!e)throw new TypeError("Assertion failed")}function $p(){}function Zp(e){return"object"==typeof e&&null!==e||"function"==typeof e}function Xp(e){if("function"!=typeof e)return!1;var t=!1;try{new e({start:function(){t=!0}})}catch(e){}return t}function Yp(e){return!!Zp(e)&&"function"==typeof e.getReader}function Qp(e){return!!Zp(e)&&"function"==typeof e.getWriter}function Jp(e){return!!Zp(e)&&(!!Yp(e.readable)&&!!Qp(e.writable))}function ey(e){try{return e.getReader({mode:"byob"}).releaseLock(),!0}catch(e){return!1}}function ty(e,t){var r=(void 0===t?{}:t).type;return Vp(Yp(e)),Vp(!1===e.locked),"bytes"===(r=ry(r))?new sy(e):new ny(e)}function ry(e){var t=e+"";if("bytes"===t)return t;if(void 0===e)return e;throw new RangeError("Invalid type is specified")}var iy=function(){function e(e){this._underlyingReader=void 0,this._readerMode=void 0,this._readableStreamController=void 0,this._pendingRead=void 0,this._underlyingStream=e,this._attachDefaultReader()}return e.prototype.start=function(e){this._readableStreamController=e},e.prototype.cancel=function(e){return Vp(void 0!==this._underlyingReader),this._underlyingReader.cancel(e)},e.prototype._attachDefaultReader=function(){if("default"!==this._readerMode){this._detachReader();var e=this._underlyingStream.getReader();this._readerMode="default",this._attachReader(e)}},e.prototype._attachReader=function(e){var t=this;Vp(void 0===this._underlyingReader),this._underlyingReader=e;var r=this._underlyingReader.closed;r&&r.then((function(){return t._finishPendingRead()})).then((function(){e===t._underlyingReader&&t._readableStreamController.close()}),(function(r){e===t._underlyingReader&&t._readableStreamController.error(r)})).catch($p)},e.prototype._detachReader=function(){void 0!==this._underlyingReader&&(this._underlyingReader.releaseLock(),this._underlyingReader=void 0,this._readerMode=void 0)},e.prototype._pullWithDefaultReader=function(){var e=this;this._attachDefaultReader();var t=this._underlyingReader.read().then((function(t){var r=e._readableStreamController;t.done?e._tryClose():r.enqueue(t.value)}));return this._setPendingRead(t),t},e.prototype._tryClose=function(){try{this._readableStreamController.close()}catch(e){}},e.prototype._setPendingRead=function(e){var t,r=this,i=function(){r._pendingRead===t&&(r._pendingRead=void 0)};this._pendingRead=t=e.then(i,i)},e.prototype._finishPendingRead=function(){var e=this;if(this._pendingRead){var t=function(){return e._finishPendingRead()};return this._pendingRead.then(t,t)}},e}(),ny=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Gp(t,e),t.prototype.pull=function(){return this._pullWithDefaultReader()},t}(iy);function ay(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var sy=function(e){function t(t){var r=this,i=ey(t);return(r=e.call(this,t)||this)._supportsByob=i,r}return Gp(t,e),Object.defineProperty(t.prototype,"type",{get:function(){return"bytes"},enumerable:!1,configurable:!0}),t.prototype._attachByobReader=function(){if("byob"!==this._readerMode){Vp(this._supportsByob),this._detachReader();var e=this._underlyingStream.getReader({mode:"byob"});this._readerMode="byob",this._attachReader(e)}},t.prototype.pull=function(){if(this._supportsByob){var e=this._readableStreamController.byobRequest;if(e)return this._pullWithByobRequest(e)}return this._pullWithDefaultReader()},t.prototype._pullWithByobRequest=function(e){var t=this;this._attachByobReader();var r=new Uint8Array(e.view.byteLength),i=this._underlyingReader.read(r).then((function(r){var i,n,a;t._readableStreamController,r.done?(t._tryClose(),e.respond(0)):(i=r.value,n=e.view,a=ay(i),ay(n).set(a,0),e.respond(r.value.byteLength))}));return this._setPendingRead(i),i},t}(iy);function oy(e){Vp(Qp(e)),Vp(!1===e.locked);var t=e.getWriter();return new cy(t)}var cy=function(){function e(e){var t=this;this._writableStreamController=void 0,this._pendingWrite=void 0,this._state="writable",this._storedError=void 0,this._underlyingWriter=e,this._errorPromise=new Promise((function(e,r){t._errorPromiseReject=r})),this._errorPromise.catch($p)}return e.prototype.start=function(e){var t=this;this._writableStreamController=e,this._underlyingWriter.closed.then((function(){t._state="closed"})).catch((function(e){return t._finishErroring(e)}))},e.prototype.write=function(e){var t=this,r=this._underlyingWriter;if(null===r.desiredSize)return r.ready;var i=r.write(e);i.catch((function(e){return t._finishErroring(e)})),r.ready.catch((function(e){return t._startErroring(e)}));var n=Promise.race([i,this._errorPromise]);return this._setPendingWrite(n),n},e.prototype.close=function(){var e=this;return void 0===this._pendingWrite?this._underlyingWriter.close():this._finishPendingWrite().then((function(){return e.close()}))},e.prototype.abort=function(e){if("errored"!==this._state)return this._underlyingWriter.abort(e)},e.prototype._setPendingWrite=function(e){var t,r=this,i=function(){r._pendingWrite===t&&(r._pendingWrite=void 0)};this._pendingWrite=t=e.then(i,i)},e.prototype._finishPendingWrite=function(){var e=this;if(void 0===this._pendingWrite)return Promise.resolve();var t=function(){return e._finishPendingWrite()};return this._pendingWrite.then(t,t)},e.prototype._startErroring=function(e){var t=this;if("writable"===this._state){this._state="erroring",this._storedError=e;var r=function(){return t._finishErroring(e)};void 0===this._pendingWrite?r():this._finishPendingWrite().then(r,r),this._writableStreamController.error(e)}},e.prototype._finishErroring=function(e){"writable"===this._state&&this._startErroring(e),"erroring"===this._state&&(this._state="errored",this._errorPromiseReject(this._storedError))},e}();function uy(e){Vp(Jp(e));var t=e.readable,r=e.writable;Vp(!1===t.locked),Vp(!1===r.locked);var i,n=t.getReader();try{i=r.getWriter()}catch(e){throw n.releaseLock(),e}return new hy(n,i)}var hy=function(){function e(e,t){var r=this;this._transformStreamController=void 0,this._onRead=function(e){if(!e.done)return r._transformStreamController.enqueue(e.value),r._reader.read().then(r._onRead)},this._onError=function(e){r._flushReject(e),r._transformStreamController.error(e),r._reader.cancel(e).catch($p),r._writer.abort(e).catch($p)},this._onTerminate=function(){r._flushResolve(),r._transformStreamController.terminate();var e=new TypeError("TransformStream terminated");r._writer.abort(e).catch($p)},this._reader=e,this._writer=t,this._flushPromise=new Promise((function(e,t){r._flushResolve=e,r._flushReject=t}))}return e.prototype.start=function(e){this._transformStreamController=e,this._reader.read().then(this._onRead).then(this._onTerminate,this._onError);var t=this._reader.closed;t&&t.then(this._onTerminate,this._onError)},e.prototype.transform=function(e){return this._writer.write(e)},e.prototype.flush=function(){var e=this;return this._writer.close().then((function(){return e._flushPromise}))},e}(),dy=/*#__PURE__*/Object.freeze({__proto__:null,createReadableStreamWrapper:function(e){Vp(function(e){return!!Xp(e)&&!!Yp(new e)}(e));var t=function(e){try{return new e({type:"bytes"}),!0}catch(e){return!1}}(e);return function(r,i){var n=(void 0===i?{}:i).type;if("bytes"!==(n=ry(n))||t||(n=void 0),r.constructor===e&&("bytes"!==n||ey(r)))return r;if("bytes"===n){var a=ty(r,{type:n});return new e(a)}a=ty(r);return new e(a)}},createTransformStreamWrapper:function(e){return Vp(function(e){return!!Xp(e)&&!!Jp(new e)}(e)),function(t){if(t.constructor===e)return t;var r=uy(t);return new e(r)}},createWrappingReadableSource:ty,createWrappingTransformer:uy,createWrappingWritableSink:oy,createWritableStreamWrapper:function(e){return Vp(function(e){return!!Xp(e)&&!!Qp(new e)}(e)),function(t){if(t.constructor===e)return t;var r=oy(t);return new e(r)}}}),fy=ht((function(e){!function(e,r){function i(e,t){if(!e)throw Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function a(e,t,r){if(a.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var s;"object"==typeof e?e.exports=a:r.BN=a,a.BN=a,a.wordSize=26;try{s=t.Buffer}catch(e){}function o(e,t,r){for(var i=0,n=Math.min(e.length,r),a=t;a=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return i}function c(e,t,r,i){for(var n=0,a=Math.min(e.length,r),s=t;s=49?o-49+10:o>=17?o-17+10:o}return n}a.isBN=function(e){return e instanceof a||null!==e&&"object"==typeof e&&e.constructor.wordSize===a.wordSize&&Array.isArray(e.words)},a.max=function(e,t){return e.cmp(t)>0?e:t},a.min=function(e,t){return e.cmp(t)<0?e:t},a.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&n++,16===t?this._parseHex(e,n):this._parseBase(e,t,n),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},a.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(i(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},a.prototype._initArray=function(e,t,r){if(i("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=Array(this.length);for(var n=0;n=0;n-=3)s=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[a]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,a++);else if("le"===r)for(n=0,a=0;n>>26-o&67108863,(o+=24)>=26&&(o-=26,a++);return this.strip()},a.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=Array(this.length);for(var r=0;r=t;r-=6)n=o(e,r,r+6),this.words[i]|=n<>>26-a&4194303,(a+=24)>=26&&(a-=26,i++);r+6!==t&&(n=o(e,t,r+6),this.words[i]|=n<>>26-a&4194303),this.strip()},a.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var a=e.length-r,s=a%i,o=Math.min(a,a-s)+r,u=0,h=r;h1&&0===this.words[this.length-1];)this.length--;return this._normSign()},a.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},a.prototype.inspect=function(){return(this.red?""};var u=["","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"],h=[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],d=[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 f(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;r.length=i,i=i-1|0;var n=0|e.words[0],a=0|t.words[0],s=n*a,o=67108863&s,c=s/67108864|0;r.words[0]=o;for(var u=1;u>>26,d=67108863&c,f=Math.min(u,t.length-1),l=Math.max(0,u-e.length+1);l<=f;l++){var p=u-l|0;h+=(s=(n=0|e.words[p])*(a=0|t.words[l])+d)/67108864|0,d=67108863&s}r.words[u]=0|d,c=0|h}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}a.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var n=0,a=0,s=0;s>>24-n&16777215)||s!==this.length-1?u[6-c.length]+c+r:c+r,(n+=2)>=26&&(n-=26,s--)}for(0!==a&&(r=a.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var f=h[e],l=d[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modn(l).toString(e);r=(p=p.idivn(l)).isZero()?y+r:u[f-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},a.prototype.toJSON=function(){return this.toString(16)},a.prototype.toBuffer=function(e,t){return i(void 0!==s),this.toArrayLike(s,e,t)},a.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},a.prototype.toArrayLike=function(e,t,r){var n=this.byteLength(),a=r||Math.max(1,n);i(n<=a,"byte array longer than desired length"),i(a>0,"Requested array length <= 0"),this.strip();var s,o,c="le"===t,u=new e(a),h=this.clone();if(c){for(o=0;!h.isZero();o++)s=h.andln(255),h.iushrn(8),u[o]=s;for(;o=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},a.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},a.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},a.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},a.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},a.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},a.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},a.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},a.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},a.prototype.notn=function(e){return this.clone().inotn(e)},a.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var r=e/26|0,n=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,i=e):(r=e,i=this);for(var n=0,a=0;a>>26;for(;0!==n&&a>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;ae.length?this.clone().iadd(e):e.clone().iadd(this)},a.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=e):(r=e,i=this);for(var a=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==a&&s>26,this.words[s]=67108863&t;if(0===a&&s>>13,l=0|s[1],p=8191&l,y=l>>>13,b=0|s[2],m=8191&b,g=b>>>13,w=0|s[3],v=8191&w,_=w>>>13,k=0|s[4],A=8191&k,S=k>>>13,E=0|s[5],P=8191&E,x=E>>>13,M=0|s[6],K=8191&M,C=M>>>13,D=0|s[7],U=8191&D,R=D>>>13,I=0|s[8],B=8191&I,T=I>>>13,z=0|s[9],q=8191&z,F=z>>>13,O=0|o[0],L=8191&O,N=O>>>13,j=0|o[1],W=8191&j,H=j>>>13,G=0|o[2],V=8191&G,$=G>>>13,Z=0|o[3],X=8191&Z,Y=Z>>>13,Q=0|o[4],J=8191&Q,ee=Q>>>13,te=0|o[5],re=8191&te,ie=te>>>13,ne=0|o[6],ae=8191&ne,se=ne>>>13,oe=0|o[7],ce=8191&oe,ue=oe>>>13,he=0|o[8],de=8191&he,fe=he>>>13,le=0|o[9],pe=8191&le,ye=le>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(u+(i=Math.imul(d,L))|0)+((8191&(n=(n=Math.imul(d,N))+Math.imul(f,L)|0))<<13)|0;u=((a=Math.imul(f,N))+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(p,L),n=(n=Math.imul(p,N))+Math.imul(y,L)|0,a=Math.imul(y,N);var me=(u+(i=i+Math.imul(d,W)|0)|0)+((8191&(n=(n=n+Math.imul(d,H)|0)+Math.imul(f,W)|0))<<13)|0;u=((a=a+Math.imul(f,H)|0)+(n>>>13)|0)+(me>>>26)|0,me&=67108863,i=Math.imul(m,L),n=(n=Math.imul(m,N))+Math.imul(g,L)|0,a=Math.imul(g,N),i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,H)|0)+Math.imul(y,W)|0,a=a+Math.imul(y,H)|0;var ge=(u+(i=i+Math.imul(d,V)|0)|0)+((8191&(n=(n=n+Math.imul(d,$)|0)+Math.imul(f,V)|0))<<13)|0;u=((a=a+Math.imul(f,$)|0)+(n>>>13)|0)+(ge>>>26)|0,ge&=67108863,i=Math.imul(v,L),n=(n=Math.imul(v,N))+Math.imul(_,L)|0,a=Math.imul(_,N),i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(g,W)|0,a=a+Math.imul(g,H)|0,i=i+Math.imul(p,V)|0,n=(n=n+Math.imul(p,$)|0)+Math.imul(y,V)|0,a=a+Math.imul(y,$)|0;var we=(u+(i=i+Math.imul(d,X)|0)|0)+((8191&(n=(n=n+Math.imul(d,Y)|0)+Math.imul(f,X)|0))<<13)|0;u=((a=a+Math.imul(f,Y)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(A,L),n=(n=Math.imul(A,N))+Math.imul(S,L)|0,a=Math.imul(S,N),i=i+Math.imul(v,W)|0,n=(n=n+Math.imul(v,H)|0)+Math.imul(_,W)|0,a=a+Math.imul(_,H)|0,i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,$)|0)+Math.imul(g,V)|0,a=a+Math.imul(g,$)|0,i=i+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(y,X)|0,a=a+Math.imul(y,Y)|0;var ve=(u+(i=i+Math.imul(d,J)|0)|0)+((8191&(n=(n=n+Math.imul(d,ee)|0)+Math.imul(f,J)|0))<<13)|0;u=((a=a+Math.imul(f,ee)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(P,L),n=(n=Math.imul(P,N))+Math.imul(x,L)|0,a=Math.imul(x,N),i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,H)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,H)|0,i=i+Math.imul(v,V)|0,n=(n=n+Math.imul(v,$)|0)+Math.imul(_,V)|0,a=a+Math.imul(_,$)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(g,X)|0,a=a+Math.imul(g,Y)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(y,J)|0,a=a+Math.imul(y,ee)|0;var _e=(u+(i=i+Math.imul(d,re)|0)|0)+((8191&(n=(n=n+Math.imul(d,ie)|0)+Math.imul(f,re)|0))<<13)|0;u=((a=a+Math.imul(f,ie)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(K,L),n=(n=Math.imul(K,N))+Math.imul(C,L)|0,a=Math.imul(C,N),i=i+Math.imul(P,W)|0,n=(n=n+Math.imul(P,H)|0)+Math.imul(x,W)|0,a=a+Math.imul(x,H)|0,i=i+Math.imul(A,V)|0,n=(n=n+Math.imul(A,$)|0)+Math.imul(S,V)|0,a=a+Math.imul(S,$)|0,i=i+Math.imul(v,X)|0,n=(n=n+Math.imul(v,Y)|0)+Math.imul(_,X)|0,a=a+Math.imul(_,Y)|0,i=i+Math.imul(m,J)|0,n=(n=n+Math.imul(m,ee)|0)+Math.imul(g,J)|0,a=a+Math.imul(g,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(y,re)|0,a=a+Math.imul(y,ie)|0;var ke=(u+(i=i+Math.imul(d,ae)|0)|0)+((8191&(n=(n=n+Math.imul(d,se)|0)+Math.imul(f,ae)|0))<<13)|0;u=((a=a+Math.imul(f,se)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(U,L),n=(n=Math.imul(U,N))+Math.imul(R,L)|0,a=Math.imul(R,N),i=i+Math.imul(K,W)|0,n=(n=n+Math.imul(K,H)|0)+Math.imul(C,W)|0,a=a+Math.imul(C,H)|0,i=i+Math.imul(P,V)|0,n=(n=n+Math.imul(P,$)|0)+Math.imul(x,V)|0,a=a+Math.imul(x,$)|0,i=i+Math.imul(A,X)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(S,X)|0,a=a+Math.imul(S,Y)|0,i=i+Math.imul(v,J)|0,n=(n=n+Math.imul(v,ee)|0)+Math.imul(_,J)|0,a=a+Math.imul(_,ee)|0,i=i+Math.imul(m,re)|0,n=(n=n+Math.imul(m,ie)|0)+Math.imul(g,re)|0,a=a+Math.imul(g,ie)|0,i=i+Math.imul(p,ae)|0,n=(n=n+Math.imul(p,se)|0)+Math.imul(y,ae)|0,a=a+Math.imul(y,se)|0;var Ae=(u+(i=i+Math.imul(d,ce)|0)|0)+((8191&(n=(n=n+Math.imul(d,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((a=a+Math.imul(f,ue)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(B,L),n=(n=Math.imul(B,N))+Math.imul(T,L)|0,a=Math.imul(T,N),i=i+Math.imul(U,W)|0,n=(n=n+Math.imul(U,H)|0)+Math.imul(R,W)|0,a=a+Math.imul(R,H)|0,i=i+Math.imul(K,V)|0,n=(n=n+Math.imul(K,$)|0)+Math.imul(C,V)|0,a=a+Math.imul(C,$)|0,i=i+Math.imul(P,X)|0,n=(n=n+Math.imul(P,Y)|0)+Math.imul(x,X)|0,a=a+Math.imul(x,Y)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,ee)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,ee)|0,i=i+Math.imul(v,re)|0,n=(n=n+Math.imul(v,ie)|0)+Math.imul(_,re)|0,a=a+Math.imul(_,ie)|0,i=i+Math.imul(m,ae)|0,n=(n=n+Math.imul(m,se)|0)+Math.imul(g,ae)|0,a=a+Math.imul(g,se)|0,i=i+Math.imul(p,ce)|0,n=(n=n+Math.imul(p,ue)|0)+Math.imul(y,ce)|0,a=a+Math.imul(y,ue)|0;var Se=(u+(i=i+Math.imul(d,de)|0)|0)+((8191&(n=(n=n+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;u=((a=a+Math.imul(f,fe)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(q,L),n=(n=Math.imul(q,N))+Math.imul(F,L)|0,a=Math.imul(F,N),i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,H)|0)+Math.imul(T,W)|0,a=a+Math.imul(T,H)|0,i=i+Math.imul(U,V)|0,n=(n=n+Math.imul(U,$)|0)+Math.imul(R,V)|0,a=a+Math.imul(R,$)|0,i=i+Math.imul(K,X)|0,n=(n=n+Math.imul(K,Y)|0)+Math.imul(C,X)|0,a=a+Math.imul(C,Y)|0,i=i+Math.imul(P,J)|0,n=(n=n+Math.imul(P,ee)|0)+Math.imul(x,J)|0,a=a+Math.imul(x,ee)|0,i=i+Math.imul(A,re)|0,n=(n=n+Math.imul(A,ie)|0)+Math.imul(S,re)|0,a=a+Math.imul(S,ie)|0,i=i+Math.imul(v,ae)|0,n=(n=n+Math.imul(v,se)|0)+Math.imul(_,ae)|0,a=a+Math.imul(_,se)|0,i=i+Math.imul(m,ce)|0,n=(n=n+Math.imul(m,ue)|0)+Math.imul(g,ce)|0,a=a+Math.imul(g,ue)|0,i=i+Math.imul(p,de)|0,n=(n=n+Math.imul(p,fe)|0)+Math.imul(y,de)|0,a=a+Math.imul(y,fe)|0;var Ee=(u+(i=i+Math.imul(d,pe)|0)|0)+((8191&(n=(n=n+Math.imul(d,ye)|0)+Math.imul(f,pe)|0))<<13)|0;u=((a=a+Math.imul(f,ye)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(q,W),n=(n=Math.imul(q,H))+Math.imul(F,W)|0,a=Math.imul(F,H),i=i+Math.imul(B,V)|0,n=(n=n+Math.imul(B,$)|0)+Math.imul(T,V)|0,a=a+Math.imul(T,$)|0,i=i+Math.imul(U,X)|0,n=(n=n+Math.imul(U,Y)|0)+Math.imul(R,X)|0,a=a+Math.imul(R,Y)|0,i=i+Math.imul(K,J)|0,n=(n=n+Math.imul(K,ee)|0)+Math.imul(C,J)|0,a=a+Math.imul(C,ee)|0,i=i+Math.imul(P,re)|0,n=(n=n+Math.imul(P,ie)|0)+Math.imul(x,re)|0,a=a+Math.imul(x,ie)|0,i=i+Math.imul(A,ae)|0,n=(n=n+Math.imul(A,se)|0)+Math.imul(S,ae)|0,a=a+Math.imul(S,se)|0,i=i+Math.imul(v,ce)|0,n=(n=n+Math.imul(v,ue)|0)+Math.imul(_,ce)|0,a=a+Math.imul(_,ue)|0,i=i+Math.imul(m,de)|0,n=(n=n+Math.imul(m,fe)|0)+Math.imul(g,de)|0,a=a+Math.imul(g,fe)|0;var Pe=(u+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;u=((a=a+Math.imul(y,ye)|0)+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i=Math.imul(q,V),n=(n=Math.imul(q,$))+Math.imul(F,V)|0,a=Math.imul(F,$),i=i+Math.imul(B,X)|0,n=(n=n+Math.imul(B,Y)|0)+Math.imul(T,X)|0,a=a+Math.imul(T,Y)|0,i=i+Math.imul(U,J)|0,n=(n=n+Math.imul(U,ee)|0)+Math.imul(R,J)|0,a=a+Math.imul(R,ee)|0,i=i+Math.imul(K,re)|0,n=(n=n+Math.imul(K,ie)|0)+Math.imul(C,re)|0,a=a+Math.imul(C,ie)|0,i=i+Math.imul(P,ae)|0,n=(n=n+Math.imul(P,se)|0)+Math.imul(x,ae)|0,a=a+Math.imul(x,se)|0,i=i+Math.imul(A,ce)|0,n=(n=n+Math.imul(A,ue)|0)+Math.imul(S,ce)|0,a=a+Math.imul(S,ue)|0,i=i+Math.imul(v,de)|0,n=(n=n+Math.imul(v,fe)|0)+Math.imul(_,de)|0,a=a+Math.imul(_,fe)|0;var xe=(u+(i=i+Math.imul(m,pe)|0)|0)+((8191&(n=(n=n+Math.imul(m,ye)|0)+Math.imul(g,pe)|0))<<13)|0;u=((a=a+Math.imul(g,ye)|0)+(n>>>13)|0)+(xe>>>26)|0,xe&=67108863,i=Math.imul(q,X),n=(n=Math.imul(q,Y))+Math.imul(F,X)|0,a=Math.imul(F,Y),i=i+Math.imul(B,J)|0,n=(n=n+Math.imul(B,ee)|0)+Math.imul(T,J)|0,a=a+Math.imul(T,ee)|0,i=i+Math.imul(U,re)|0,n=(n=n+Math.imul(U,ie)|0)+Math.imul(R,re)|0,a=a+Math.imul(R,ie)|0,i=i+Math.imul(K,ae)|0,n=(n=n+Math.imul(K,se)|0)+Math.imul(C,ae)|0,a=a+Math.imul(C,se)|0,i=i+Math.imul(P,ce)|0,n=(n=n+Math.imul(P,ue)|0)+Math.imul(x,ce)|0,a=a+Math.imul(x,ue)|0,i=i+Math.imul(A,de)|0,n=(n=n+Math.imul(A,fe)|0)+Math.imul(S,de)|0,a=a+Math.imul(S,fe)|0;var Me=(u+(i=i+Math.imul(v,pe)|0)|0)+((8191&(n=(n=n+Math.imul(v,ye)|0)+Math.imul(_,pe)|0))<<13)|0;u=((a=a+Math.imul(_,ye)|0)+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,i=Math.imul(q,J),n=(n=Math.imul(q,ee))+Math.imul(F,J)|0,a=Math.imul(F,ee),i=i+Math.imul(B,re)|0,n=(n=n+Math.imul(B,ie)|0)+Math.imul(T,re)|0,a=a+Math.imul(T,ie)|0,i=i+Math.imul(U,ae)|0,n=(n=n+Math.imul(U,se)|0)+Math.imul(R,ae)|0,a=a+Math.imul(R,se)|0,i=i+Math.imul(K,ce)|0,n=(n=n+Math.imul(K,ue)|0)+Math.imul(C,ce)|0,a=a+Math.imul(C,ue)|0,i=i+Math.imul(P,de)|0,n=(n=n+Math.imul(P,fe)|0)+Math.imul(x,de)|0,a=a+Math.imul(x,fe)|0;var Ke=(u+(i=i+Math.imul(A,pe)|0)|0)+((8191&(n=(n=n+Math.imul(A,ye)|0)+Math.imul(S,pe)|0))<<13)|0;u=((a=a+Math.imul(S,ye)|0)+(n>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,i=Math.imul(q,re),n=(n=Math.imul(q,ie))+Math.imul(F,re)|0,a=Math.imul(F,ie),i=i+Math.imul(B,ae)|0,n=(n=n+Math.imul(B,se)|0)+Math.imul(T,ae)|0,a=a+Math.imul(T,se)|0,i=i+Math.imul(U,ce)|0,n=(n=n+Math.imul(U,ue)|0)+Math.imul(R,ce)|0,a=a+Math.imul(R,ue)|0,i=i+Math.imul(K,de)|0,n=(n=n+Math.imul(K,fe)|0)+Math.imul(C,de)|0,a=a+Math.imul(C,fe)|0;var Ce=(u+(i=i+Math.imul(P,pe)|0)|0)+((8191&(n=(n=n+Math.imul(P,ye)|0)+Math.imul(x,pe)|0))<<13)|0;u=((a=a+Math.imul(x,ye)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(q,ae),n=(n=Math.imul(q,se))+Math.imul(F,ae)|0,a=Math.imul(F,se),i=i+Math.imul(B,ce)|0,n=(n=n+Math.imul(B,ue)|0)+Math.imul(T,ce)|0,a=a+Math.imul(T,ue)|0,i=i+Math.imul(U,de)|0,n=(n=n+Math.imul(U,fe)|0)+Math.imul(R,de)|0,a=a+Math.imul(R,fe)|0;var De=(u+(i=i+Math.imul(K,pe)|0)|0)+((8191&(n=(n=n+Math.imul(K,ye)|0)+Math.imul(C,pe)|0))<<13)|0;u=((a=a+Math.imul(C,ye)|0)+(n>>>13)|0)+(De>>>26)|0,De&=67108863,i=Math.imul(q,ce),n=(n=Math.imul(q,ue))+Math.imul(F,ce)|0,a=Math.imul(F,ue),i=i+Math.imul(B,de)|0,n=(n=n+Math.imul(B,fe)|0)+Math.imul(T,de)|0,a=a+Math.imul(T,fe)|0;var Ue=(u+(i=i+Math.imul(U,pe)|0)|0)+((8191&(n=(n=n+Math.imul(U,ye)|0)+Math.imul(R,pe)|0))<<13)|0;u=((a=a+Math.imul(R,ye)|0)+(n>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,i=Math.imul(q,de),n=(n=Math.imul(q,fe))+Math.imul(F,de)|0,a=Math.imul(F,fe);var Re=(u+(i=i+Math.imul(B,pe)|0)|0)+((8191&(n=(n=n+Math.imul(B,ye)|0)+Math.imul(T,pe)|0))<<13)|0;u=((a=a+Math.imul(T,ye)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Ie=(u+(i=Math.imul(q,pe))|0)+((8191&(n=(n=Math.imul(q,ye))+Math.imul(F,pe)|0))<<13)|0;return u=((a=Math.imul(F,ye))+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,c[0]=be,c[1]=me,c[2]=ge,c[3]=we,c[4]=ve,c[5]=_e,c[6]=ke,c[7]=Ae,c[8]=Se,c[9]=Ee,c[10]=Pe,c[11]=xe,c[12]=Me,c[13]=Ke,c[14]=Ce,c[15]=De,c[16]=Ue,c[17]=Re,c[18]=Ie,0!==u&&(c[19]=u,r.length++),r};function p(e,t,r){return(new y).mulp(e,t,r)}function y(e,t){this.x=e,this.y=t}Math.imul||(l=f),a.prototype.mulTo=function(e,t){var r,i=this.length+e.length;return r=10===this.length&&10===e.length?l(this,e,t):i<63?f(this,e,t):i<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var i=0,n=0,a=0;a>>26)|0)>>>26,s&=67108863}r.words[a]=o,i=s,s=n}return 0!==i?r.words[a]=i:r.length--,r.strip()}(this,e,t):p(this,e,t),r},y.prototype.makeRBT=function(e){for(var t=Array(e),r=a.prototype._countBits(e)-1,i=0;i>=1;return i},y.prototype.permute=function(e,t,r,i,n,a){for(var s=0;s>>=1)n++;return 1<>>=13,r[2*s+1]=8191&a,a>>>=13;for(s=2*t;s>=26,t+=n/67108864|0,t+=a>>>26,this.words[r]=67108863&a}return 0!==t&&(this.words[r]=t,this.length++),this},a.prototype.muln=function(e){return this.clone().imuln(e)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(e){var t=function(e){for(var t=Array(e.bitLength()),r=0;r>>n}return t}(e);if(0===t.length)return new a(1);for(var r=this,i=0;i=0);var t,r=e%26,n=(e-r)/26,a=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==n){for(t=this.length-1;t>=0;t--)this.words[t+n]=this.words[t];for(t=0;t=0),n=t?(t-t%26)/26:0;var a=e%26,s=Math.min((e-a)/26,this.length),o=67108863^67108863>>>a<s)for(this.length-=s,u=0;u=0&&(0!==h||u>=n);u--){var d=0|this.words[u];this.words[u]=h<<26-a|d>>>a,h=d&o}return c&&0!==h&&(c.words[c.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},a.prototype.ishrn=function(e,t,r){return i(0===this.negative),this.iushrn(e,t,r)},a.prototype.shln=function(e){return this.clone().ishln(e)},a.prototype.ushln=function(e){return this.clone().iushln(e)},a.prototype.shrn=function(e){return this.clone().ishrn(e)},a.prototype.ushrn=function(e){return this.clone().iushrn(e)},a.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,n=1<=0);var t=e%26,r=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var n=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},a.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(c/67108864|0),this.words[n+r]=67108863&a}for(;n>26,this.words[n+r]=67108863&a;if(0===o)return this.strip();for(i(-1===o),o=0,n=0;n>26,this.words[n]=67108863&a;return this.negative=1,this.strip()},a.prototype._wordDiv=function(e,t){var r=(this.length,e.length),i=this.clone(),n=e,s=0|n.words[n.length-1];0!==(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var o,c=i.length-n.length;if("mod"!==t){(o=new a(null)).length=c+1,o.words=Array(o.length);for(var u=0;u=0;d--){var f=67108864*(0|i.words[n.length+d])+(0|i.words[n.length+d-1]);for(f=Math.min(f/s|0,67108863),i._ishlnsubmul(n,f,d);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,d),i.isZero()||(i.negative^=1);o&&(o.words[d]=f)}return o&&o.strip(),i.strip(),"div"!==t&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},a.prototype.divmod=function(e,t,r){return i(!e.isZero()),this.isZero()?{div:new a(0),mod:new a(0)}:0!==this.negative&&0===e.negative?(o=this.neg().divmod(e,t),"mod"!==t&&(n=o.div.neg()),"div"!==t&&(s=o.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:n,mod:s}):0===this.negative&&0!==e.negative?(o=this.divmod(e.neg(),t),"mod"!==t&&(n=o.div.neg()),{div:n,mod:o.mod}):0!=(this.negative&e.negative)?(o=this.neg().divmod(e.neg(),t),"div"!==t&&(s=o.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:o.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new a(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new a(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new a(this.modn(e.words[0]))}:this._wordDiv(e,t);var n,s,o},a.prototype.div=function(e){return this.divmod(e,"div",!1).div},a.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},a.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},a.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},a.prototype.modn=function(e){i(e<=67108863);for(var t=(1<<26)%e,r=0,n=this.length-1;n>=0;n--)r=(t*r+(0|this.words[n]))%e;return r},a.prototype.idivn=function(e){i(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*t;this.words[r]=n/e|0,t=n%e}return this.strip()},a.prototype.divn=function(e){return this.clone().idivn(e)},a.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n=new a(1),s=new a(0),o=new a(0),c=new a(1),u=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++u;for(var h=r.clone(),d=t.clone();!t.isZero();){for(var f=0,l=1;0==(t.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(h),s.isub(d)),n.iushrn(1),s.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(o.isOdd()||c.isOdd())&&(o.iadd(h),c.isub(d)),o.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),n.isub(o),s.isub(c)):(r.isub(t),o.isub(n),c.isub(s))}return{a:o,b:c,gcd:r.iushln(u)}},a.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n,s=new a(1),o=new a(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,h=1;0==(t.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(t.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var d=0,f=1;0==(r.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(r.iushrn(d);d-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(o)):(r.isub(t),o.isub(s))}return(n=0===t.cmpn(1)?s:o).cmpn(0)<0&&n.iadd(e),n},a.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var i=0;t.isEven()&&r.isEven();i++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=t.cmp(r);if(n<0){var a=t;t=r,r=a}else if(0===n||0===r.cmpn(1))break;t.isub(r)}return r.iushln(i)},a.prototype.invm=function(e){return this.egcd(e).a.umod(e)},a.prototype.isEven=function(){return 0==(1&this.words[0])},a.prototype.isOdd=function(){return 1==(1&this.words[0])},a.prototype.andln=function(e){return this.words[0]&e},a.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,r=(e-t)/26,n=1<>>26,o&=67108863,this.words[s]=o}return 0!==a&&(this.words[s]=a,this.length++),this},a.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},a.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),i(e<=67108863,"Number is too big");var n=0|this.words[0];t=n===e?0:ne.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|e.words[r];if(i!==n){in&&(t=1);break}}return t},a.prototype.gtn=function(e){return 1===this.cmpn(e)},a.prototype.gt=function(e){return 1===this.cmp(e)},a.prototype.gten=function(e){return this.cmpn(e)>=0},a.prototype.gte=function(e){return this.cmp(e)>=0},a.prototype.ltn=function(e){return-1===this.cmpn(e)},a.prototype.lt=function(e){return-1===this.cmp(e)},a.prototype.lten=function(e){return this.cmpn(e)<=0},a.prototype.lte=function(e){return this.cmp(e)<=0},a.prototype.eqn=function(e){return 0===this.cmpn(e)},a.prototype.eq=function(e){return 0===this.cmp(e)},a.red=function(e){return new k(e)},a.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},a.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(e){return this.red=e,this},a.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},a.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},a.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},a.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},a.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},a.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},a.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},a.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},a.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new a(t,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function k(e){if("string"==typeof e){var t=a._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function A(e){k.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new a(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)}m.prototype._tmp=function(){var e=new a(null);return e.words=Array(Math.ceil(this.n/13)),e},m.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var i=t0?r.isub(this.p):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},n(g,m),g.prototype.split=function(e,t){for(var r=4194303,i=Math.min(e.length,9),n=0;n>>22,a=s}a>>>=22,e.words[n-10]=a,0===a&&e.length>10?e.length-=10:e.length-=9},g.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},a._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new g;else if("p224"===e)t=new w;else if("p192"===e)t=new v;else{if("p25519"!==e)throw Error("Unknown prime "+e);t=new _}return b[e]=t,t},k.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},k.prototype._verify2=function(e,t){i(0==(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},k.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},k.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},k.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},k.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},k.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},k.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},k.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},k.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},k.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},k.prototype.isqr=function(e){return this.imul(e,e.clone())},k.prototype.sqr=function(e){return this.mul(e,e)},k.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2==1),3===t){var r=this.m.add(new a(1)).iushrn(2);return this.pow(e,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var o=new a(1).toRed(this),c=o.redNeg(),u=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new a(2*h*h).toRed(this);0!==this.pow(h,u).cmp(c);)h.redIAdd(c);for(var d=this.pow(h,n),f=this.pow(e,n.addn(1).iushrn(1)),l=this.pow(e,n),p=s;0!==l.cmp(o);){for(var y=l,b=0;0!==y.cmp(o);b++)y=y.redSqr();i(b=0;i--){for(var u=t.words[i],h=c-1;h>=0;h--){var d=u>>h&1;n!==r[0]&&(n=this.sqr(n)),0!==d||0!==s?(s<<=1,s|=d,(4===++o||0===i&&0===h)&&(n=this.mul(n,r[s]),o=0,s=0)):o=0}c=26}return n},k.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},k.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},a.mont=function(e){return new A(e)},n(A,k),A.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},A.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},A.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),a=n;return n.cmp(this.m)>=0?a=n.isub(this.m):n.cmpn(0)<0&&(a=n.iadd(this.m)),a._forceRed(this)},A.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new a(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},A.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,ut)})),ly=/*#__PURE__*/Object.freeze({__proto__:null,default:fy,__moduleExports:fy});class py{constructor(e){if(void 0===e)throw Error("Invalid BigInteger input");this.value=new fy(e)}clone(){const e=new py(null);return this.value.copy(e.value),e}iinc(){return this.value.iadd(new fy(1)),this}inc(){return this.clone().iinc()}idec(){return this.value.isub(new fy(1)),this}dec(){return this.clone().idec()}iadd(e){return this.value.iadd(e.value),this}add(e){return this.clone().iadd(e)}isub(e){return this.value.isub(e.value),this}sub(e){return this.clone().isub(e)}imul(e){return this.value.imul(e.value),this}mul(e){return this.clone().imul(e)}imod(e){return this.value=this.value.umod(e.value),this}mod(e){return this.clone().imod(e)}modExp(e,t){const r=t.isEven()?fy.red(t.value):fy.mont(t.value),i=this.clone();return i.value=i.value.toRed(r).redPow(e.value).fromRed(),i}modInv(e){if(!this.gcd(e).isOne())throw Error("Inverse does not exist");return new py(this.value.invm(e.value))}gcd(e){return new py(this.value.gcd(e.value))}ileftShift(e){return this.value.ishln(e.value.toNumber()),this}leftShift(e){return this.clone().ileftShift(e)}irightShift(e){return this.value.ishrn(e.value.toNumber()),this}rightShift(e){return this.clone().irightShift(e)}equal(e){return this.value.eq(e.value)}lt(e){return this.value.lt(e.value)}lte(e){return this.value.lte(e.value)}gt(e){return this.value.gt(e.value)}gte(e){return this.value.gte(e.value)}isZero(){return this.value.isZero()}isOne(){return this.value.eq(new fy(1))}isNegative(){return this.value.isNeg()}isEven(){return this.value.isEven()}abs(){const e=this.clone();return e.value=e.value.abs(),e}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}getBit(e){return this.value.testn(e)?1:0}bitLength(){return this.value.bitLength()}byteLength(){return this.value.byteLength()}toUint8Array(e="be",t){return this.value.toArrayLike(Uint8Array,e,t)}}var yy,by=/*#__PURE__*/Object.freeze({__proto__:null,default:py}),my=ht((function(e,t){var r=t;function i(e){return 1===e.length?"0"+e:e}function n(e){for(var t="",r=0;r>8,s=255&n;a?r.push(a,s):r.push(s)}return r},r.zero2=i,r.toHex=n,r.encode=function(e,t){return"hex"===t?n(e):e}})),gy=ht((function(e,t){var r=t;r.assert=ot,r.toArray=my.toArray,r.zero2=my.zero2,r.toHex=my.toHex,r.encode=my.encode,r.getNAF=function(e,t){for(var r=[],i=1<=0;){var a;if(n.isOdd()){var s=n.andln(i-1);a=s>(i>>1)-1?(i>>1)-s:s,n.isubn(a)}else a=0;r.push(a);for(var o=0!==n.cmpn(0)&&0===n.andln(i-1)?t+1:1,c=1;c0||t.cmpn(-n)>0;){var a,s,o,c=e.andln(3)+i&3,u=t.andln(3)+n&3;if(3===c&&(c=-1),3===u&&(u=-1),0==(1&c))a=0;else a=3!==(o=e.andln(7)+i&7)&&5!==o||2!==u?c:-c;if(r[0].push(a),0==(1&u))s=0;else s=3!==(o=t.andln(7)+n&7)&&5!==o||2!==c?u:-u;r[1].push(s),2*i===a+1&&(i=1-i),2*n===s+1&&(n=1-n),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var i="_"+t;e.prototype[t]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new fy(e,"hex","le")}})),wy=function(e){return yy||(yy=new vy(null)),yy.generate(e)};function vy(e){this.rand=e}var _y=vy;if(vy.prototype.generate=function(e){return this._rand(e)},vy.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var xy=Py;function My(e,t){this.curve=e,this.type=t,this.precomputed=null}Py.prototype.point=function(){throw Error("Not implemented")},Py.prototype.validate=function(){throw Error("Not implemented")},Py.prototype._fixedNafMul=function(e,t){Ey(e.precomputed);var r=e._getDoubles(),i=Ay(t,1),n=(1<=s;t--)o=(o<<1)+i[t];a.push(o)}for(var c=this.jpoint(null,null,null),u=this.jpoint(null,null,null),h=n;h>0;h--){for(s=0;s=0;o--){for(t=0;o>=0&&0===a[o];o--)t++;if(o>=0&&t++,s=s.dblp(t),o<0)break;var c=a[o];Ey(0!==c),s="affine"===e.type?c>0?s.mixedAdd(n[c-1>>1]):s.mixedAdd(n[-c-1>>1].neg()):c>0?s.add(n[c-1>>1]):s.add(n[-c-1>>1].neg())}return"affine"===e.type?s.toP():s},Py.prototype._wnafMulAdd=function(e,t,r,i,n){for(var a=this._wnafT1,s=this._wnafT2,o=this._wnafT3,c=0,u=0;u=1;u-=2){var d=u-1,f=u;if(1===a[d]&&1===a[f]){var l=[t[d],null,null,t[f]];0===t[d].y.cmp(t[f].y)?(l[1]=t[d].add(t[f]),l[2]=t[d].toJ().mixedAdd(t[f].neg())):0===t[d].y.cmp(t[f].y.redNeg())?(l[1]=t[d].toJ().mixedAdd(t[f]),l[2]=t[d].add(t[f].neg())):(l[1]=t[d].toJ().mixedAdd(t[f]),l[2]=t[d].toJ().mixedAdd(t[f].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],y=Sy(r[d],r[f]);c=Math.max(y[0].length,c),o[d]=Array(c),o[f]=Array(c);for(var b=0;b=0;u--){for(var _=0;u>=0;){var k=!0;for(b=0;b=0&&_++,w=w.dblp(_),u<0)break;for(b=0;b0?A=s[b][S-1>>1]:S<0&&(A=s[b][-S-1>>1].neg()),w="affine"===A.type?w.mixedAdd(A):w.add(A))}}for(u=0;u=Math.ceil((e.bitLength()+1)/t.step)},My.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n=0&&(a=t,s=r),i.negative&&(i=i.neg(),n=n.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:i,b:n},{a,b:s}]},Cy.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],n=i.b.mul(e).divRound(this.n),a=r.b.neg().mul(e).divRound(this.n),s=n.mul(r.a),o=a.mul(i.a),c=n.mul(r.b),u=a.mul(i.b);return{k1:e.sub(s).sub(o),k2:c.add(u).neg()}},Cy.prototype.pointFromX=function(e,t){(e=new fy(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw Error("invalid point");var n=i.fromRed().isOdd();return(t&&!n||!t&&n)&&(i=i.redNeg()),this.point(e,i)},Cy.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},Cy.prototype._endoWnafMulAdd=function(e,t,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,a=0;a":""},Uy.prototype.isInfinity=function(){return this.inf},Uy.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},Uy.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),a=n.redSqr().redISub(this.x.redAdd(this.x)),s=n.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,s)},Uy.prototype.getX=function(){return this.x.fromRed()},Uy.prototype.getY=function(){return this.y.fromRed()},Uy.prototype.mul=function(e){return e=new fy(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Uy.prototype.mulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},Uy.prototype.jmulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},Uy.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Uy.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t},Uy.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},lt(Ry,xy.BasePoint),Cy.prototype.jpoint=function(e,t,r){return new Ry(this,e,t,r)},Ry.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)},Ry.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Ry.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),n=e.x.redMul(r),a=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),o=i.redSub(n),c=a.redSub(s);if(0===o.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=o.redSqr(),h=u.redMul(o),d=i.redMul(u),f=c.redSqr().redIAdd(h).redISub(d).redISub(d),l=c.redMul(d.redISub(f)).redISub(a.redMul(h)),p=this.z.redMul(e.z).redMul(o);return this.curve.jpoint(f,l,p)},Ry.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),n=this.y,a=e.y.redMul(t).redMul(this.z),s=r.redSub(i),o=n.redSub(a);if(0===s.cmpn(0))return 0!==o.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),u=c.redMul(s),h=r.redMul(c),d=o.redSqr().redIAdd(u).redISub(h).redISub(h),f=o.redMul(h.redISub(d)).redISub(n.redMul(u)),l=this.z.redMul(s);return this.curve.jpoint(d,f,l)},Ry.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},Ry.prototype.inspect=function(){return this.isInfinity()?"":""},Ry.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},lt(Iy,xy);var By=Iy;function Ty(e,t,r){xy.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new fy(t,16),this.z=new fy(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Iy.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),i=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===i.redSqrt().redSqr().cmp(i)},lt(Ty,xy.BasePoint),Iy.prototype.decodePoint=function(e,t){if(33===(e=gy.toArray(e,t)).length&&64===e[0]&&(e=e.slice(1,33).reverse()),32!==e.length)throw Error("Unknown point compression format");return this.point(e,1)},Iy.prototype.point=function(e,t){return new Ty(this,e,t)},Iy.prototype.pointFromJSON=function(e){return Ty.fromJSON(this,e)},Ty.prototype.precompute=function(){},Ty.prototype._encode=function(e){var t=this.curve.p.byteLength();return e?[64].concat(this.getX().toArray("le",t)):this.getX().toArray("be",t)},Ty.fromJSON=function(e,t){return new Ty(e,t[0],t[1]||e.one)},Ty.prototype.inspect=function(){return this.isInfinity()?"":""},Ty.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Ty.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),i=e.redMul(t),n=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},Ty.prototype.add=function(){throw Error("Not supported on Montgomery curve")},Ty.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=e.x.redAdd(e.z),a=e.x.redSub(e.z).redMul(r),s=n.redMul(i),o=t.z.redMul(a.redAdd(s).redSqr()),c=t.x.redMul(a.redISub(s).redSqr());return this.curve.point(o,c)},Ty.prototype.mul=function(e){for(var t=(e=new fy(e,16)).clone(),r=this,i=this.curve.point(null,null),n=[];0!==t.cmpn(0);t.iushrn(1))n.push(t.andln(1));for(var a=n.length-1;a>=0;a--)0===n[a]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},Ty.prototype.mulAdd=function(){throw Error("Not supported on Montgomery curve")},Ty.prototype.jumlAdd=function(){throw Error("Not supported on Montgomery curve")},Ty.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},Ty.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Ty.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var zy=gy.assert;function qy(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,xy.call(this,"edwards",e),this.a=new fy(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new fy(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new fy(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),zy(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}lt(qy,xy);var Fy=qy;function Oy(e,t,r,i,n){xy.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===i?(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 fy(t,16),this.y=new fy(r,16),this.z=i?new fy(i,16):this.curve.one,this.t=n&&new fy(n,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()))))}qy.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},qy.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},qy.prototype.jpoint=function(e,t,r,i){return this.point(e,t,r,i)},qy.prototype.pointFromX=function(e,t){(e=new fy(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),i=this.c2.redSub(this.a.redMul(r)),n=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=i.redMul(n.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw Error("invalid point");var o=s.fromRed().isOdd();return(t&&!o||!t&&o)&&(s=s.redNeg()),this.point(e,s)},qy.prototype.pointFromY=function(e,t){(e=new fy(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),i=r.redSub(this.c2),n=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=i.redMul(n.redInvm());if(0===a.cmp(this.zero)){if(t)throw Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},qy.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),i=t.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===i.cmp(n)},lt(Oy,xy.BasePoint),qy.prototype.pointFromJSON=function(e){return Oy.fromJSON(this,e)},qy.prototype.point=function(e,t,r,i){return new Oy(this,e,t,r,i)},Oy.fromJSON=function(e,t){return new Oy(e,t[0],t[1],t[2])},Oy.prototype.inspect=function(){return this.isInfinity()?"":""},Oy.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Oy.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(e),n=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),a=i.redAdd(t),s=a.redSub(r),o=i.redSub(t),c=n.redMul(s),u=a.redMul(o),h=n.redMul(o),d=s.redMul(a);return this.curve.point(c,u,d,h)},Oy.prototype._projDbl=function(){var e,t,r,i=this.x.redAdd(this.y).redSqr(),n=this.x.redSqr(),a=this.y.redSqr();if(this.curve.twisted){var s=(u=this.curve._mulA(n)).redAdd(a);if(this.zOne)e=i.redSub(n).redSub(a).redMul(s.redSub(this.curve.two)),t=s.redMul(u.redSub(a)),r=s.redSqr().redSub(s).redSub(s);else{var o=this.z.redSqr(),c=s.redSub(o).redISub(o);e=i.redSub(n).redISub(a).redMul(c),t=s.redMul(u.redSub(a)),r=s.redMul(c)}}else{var u=n.redAdd(a);o=this.curve._mulC(this.z).redSqr(),c=u.redSub(o).redSub(o);e=this.curve._mulC(i.redISub(u)).redMul(c),t=this.curve._mulC(u).redMul(n.redISub(a)),r=u.redMul(c)}return this.curve.point(e,t,r)},Oy.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Oy.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),n=this.z.redMul(e.z.redAdd(e.z)),a=r.redSub(t),s=n.redSub(i),o=n.redAdd(i),c=r.redAdd(t),u=a.redMul(s),h=o.redMul(c),d=a.redMul(c),f=s.redMul(o);return this.curve.point(u,h,f,d)},Oy.prototype._projAdd=function(e){var t,r,i=this.z.redMul(e.z),n=i.redSqr(),a=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(a).redMul(s),c=n.redSub(o),u=n.redAdd(o),h=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(a).redISub(s),d=i.redMul(c).redMul(h);return this.curve.twisted?(t=i.redMul(u).redMul(s.redSub(this.curve._mulA(a))),r=c.redMul(u)):(t=i.redMul(u).redMul(s.redSub(a)),r=this.curve._mulC(c).redMul(u)),this.curve.point(d,t,r)},Oy.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Oy.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Oy.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},Oy.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},Oy.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},Oy.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Oy.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Oy.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Oy.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},Oy.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}},Oy.prototype.toP=Oy.prototype.normalize,Oy.prototype.mixedAdd=Oy.prototype.add;var Ly=ht((function(e,t){var r=t;r.base=xy,r.short=Dy,r.mont=By,r.edwards=Fy})),Ny=kt.rotl32,jy=kt.sum32,Wy=kt.sum32_5,Hy=Dt.ft_1,Gy=Et.BlockHash,Vy=[1518500249,1859775393,2400959708,3395469782];function $y(){if(!(this instanceof $y))return new $y;Gy.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=Array(80)}kt.inherits($y,Gy);var Zy=$y;$y.blockSize=512,$y.outSize=160,$y.hmacStrength=80,$y.padLength=64,$y.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;ithis.blockSize&&(e=(new this.Hash).update(e).digest()),ot(e.length<=this.blockSize);for(var t=e.length;t=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,i)}var ib=rb;rb.prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=Array(this.outLen/8),this.V=Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},rb.prototype.generate=function(e,t,r,i){if(this._reseed>this.reseedInterval)throw Error("Reseed is required");"string"!=typeof t&&(i=r,r=t,t=null),r&&(r=my.toArray(r,i||"hex"),this._update(r));for(var n=[];n.length"};var ob=gy.assert;function cb(e,t){if(e instanceof cb)return e;this._importDER(e,t)||(ob(e.r&&e.s,"Signature without r or s"),this.r=new fy(e.r,16),this.s=new fy(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var ub=cb;function hb(){this.place=0}function db(e,t){var r=e[t.place++];if(!(128&r))return r;for(var i=15&r,n=0,a=0,s=t.place;a>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}cb.prototype._importDER=function(e,t){e=gy.toArray(e,t);var r=new hb;if(48!==e[r.place++])return!1;if(db(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var i=db(e,r),n=e.slice(r.place,i+r.place);if(r.place+=i,2!==e[r.place++])return!1;var a=db(e,r);if(e.length!==a+r.place)return!1;var s=e.slice(r.place,a+r.place);return 0===n[0]&&128&n[1]&&(n=n.slice(1)),0===s[0]&&128&s[1]&&(s=s.slice(1)),this.r=new fy(n),this.s=new fy(s),this.recoveryParam=null,!0},cb.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=fb(t),r=fb(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];lb(i,t.length),(i=i.concat(t)).push(2),lb(i,r.length);var n=i.concat(r),a=[48];return lb(a,n.length),a=a.concat(n),gy.encode(a,e)};var pb=gy.assert;function yb(e){if(!(this instanceof yb))return new yb(e);"string"==typeof e&&(pb(tb.hasOwnProperty(e),"Unknown curve "+e),e=tb[e]),e instanceof tb.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}var bb=yb;yb.prototype.keyPair=function(e){return new sb(this,e)},yb.prototype.keyFromPrivate=function(e,t){return sb.fromPrivate(this,e,t)},yb.prototype.keyFromPublic=function(e,t){return sb.fromPublic(this,e,t)},yb.prototype.genKeyPair=function(e){e||(e={});var t=new ib({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||wy(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()});if("mont"===this.curve.type){var r=new fy(t.generate(32));return this.keyFromPrivate(r)}for(var i=this.n.byteLength(),n=this.n.sub(new fy(2));;){if(!((r=new fy(t.generate(i))).cmp(n)>0))return r.iaddn(1),this.keyFromPrivate(r)}},yb.prototype._truncateToN=function(e,t,r){var i=(r=r||8*e.byteLength())-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},yb.prototype.truncateMsg=function(e){var t;return e instanceof Uint8Array?(t=8*e.byteLength,e=this._truncateToN(new fy(e,16),!1,t)):"string"==typeof e?(t=4*e.length,e=this._truncateToN(new fy(e,16),!1,t)):e=this._truncateToN(new fy(e,16)),e},yb.prototype.sign=function(e,t,r,i){"object"==typeof r&&(i=r,r=null),i||(i={}),t=this.keyFromPrivate(t,r),e=this.truncateMsg(e);for(var n=this.n.byteLength(),a=t.getPrivate().toArray("be",n),s=e.toArray("be",n),o=new ib({hash:this.hash,entropy:a,nonce:s,pers:i.pers,persEnc:i.persEnc||"utf8"}),c=this.n.sub(new fy(1)),u=0;;u++){var h=i.k?i.k(u):new fy(o.generate(this.n.byteLength()));if(!((h=this._truncateToN(h,!0)).cmpn(1)<=0||h.cmp(c)>=0)){var d=this.g.mul(h);if(!d.isInfinity()){var f=d.getX(),l=f.umod(this.n);if(0!==l.cmpn(0)){var p=h.invm(this.n).mul(l.mul(t.getPrivate()).iadd(e));if(0!==(p=p.umod(this.n)).cmpn(0)){var y=(d.getY().isOdd()?1:0)|(0!==f.cmp(l)?2:0);return i.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),y^=1),new ub({r:l,s:p,recoveryParam:y})}}}}}},yb.prototype.verify=function(e,t,r,i){return r=this.keyFromPublic(r,i),t=new ub(t,"hex"),this._verify(this.truncateMsg(e),t,r)||this._verify(this._truncateToN(new fy(e,16)),t,r)},yb.prototype._verify=function(e,t,r){var i=t.r,n=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;var a,s=n.invm(this.n),o=s.mul(e).umod(this.n),c=s.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(o,r.getPublic(),c)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(o,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},yb.prototype.recoverPubKey=function(e,t,r,i){pb((3&r)===r,"The recovery param is more than two bits"),t=new ub(t,i);var n=this.n,a=new fy(e),s=t.r,o=t.s,c=1&r,u=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw Error("Unable to find sencond key candinate");s=u?this.curve.pointFromX(s.add(this.curve.n),c):this.curve.pointFromX(s,c);var h=t.r.invm(n),d=n.sub(a).mul(h).umod(n),f=o.mul(h).umod(n);return this.g.mulAdd(d,s,f)},yb.prototype.getKeyRecoveryParam=function(e,t,r,i){if(null!==(t=new ub(t,i)).recoveryParam)return t.recoveryParam;for(var n=0;n<4;n++){var a;try{a=this.recoverPubKey(e,t,n)}catch(e){continue}if(a.eq(r))return n}throw Error("Unable to find valid recovery factor")};var mb=gy.assert,gb=gy.parseBytes,wb=gy.cachedProperty;function vb(e,t){if(this.eddsa=e,t.hasOwnProperty("secret")&&(this._secret=gb(t.secret)),e.isPoint(t.pub))this._pub=t.pub;else if(this._pubBytes=gb(t.pub),this._pubBytes&&33===this._pubBytes.length&&64===this._pubBytes[0]&&(this._pubBytes=this._pubBytes.slice(1,33)),this._pubBytes&&32!==this._pubBytes.length)throw Error("Unknown point compression format")}vb.fromPublic=function(e,t){return t instanceof vb?t:new vb(e,{pub:t})},vb.fromSecret=function(e,t){return t instanceof vb?t:new vb(e,{secret:t})},vb.prototype.secret=function(){return this._secret},wb(vb,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),wb(vb,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),wb(vb,"privBytes",(function(){var e=this.eddsa,t=this.hash(),r=e.encodingLength-1,i=t.slice(0,e.encodingLength);return i[0]&=248,i[r]&=127,i[r]|=64,i})),wb(vb,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),wb(vb,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),wb(vb,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),vb.prototype.sign=function(e){return mb(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},vb.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},vb.prototype.getSecret=function(e){return mb(this._secret,"KeyPair is public only"),gy.encode(this.secret(),e)},vb.prototype.getPublic=function(e,t){return gy.encode((t?[64]:[]).concat(this.pubBytes()),e)};var _b=vb,kb=gy.assert,Ab=gy.cachedProperty,Sb=gy.parseBytes;function Eb(e,t){this.eddsa=e,"object"!=typeof t&&(t=Sb(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),kb(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof fy&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}Ab(Eb,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),Ab(Eb,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),Ab(Eb,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),Ab(Eb,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),Eb.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Eb.prototype.toHex=function(){return gy.encode(this.toBytes(),"hex").toUpperCase()};var Pb=Eb,xb=gy.assert,Mb=gy.parseBytes;function Kb(e){if(xb("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof Kb))return new Kb(e);e=tb[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=Jy.sha512}var Cb=Kb;Kb.prototype.sign=function(e,t){e=Mb(e);var r=this.keyFromSecret(t),i=this.hashInt(r.messagePrefix(),e),n=this.g.mul(i),a=this.encodePoint(n),s=this.hashInt(a,r.pubBytes(),e).mul(r.priv()),o=i.add(s).umod(this.curve.n);return this.makeSignature({R:n,S:o,Rencoded:a})},Kb.prototype.verify=function(e,t,r){e=Mb(e),t=this.makeSignature(t);var i=this.keyFromPublic(r),n=this.hashInt(t.Rencoded(),i.pubBytes(),e),a=this.g.mul(t.S());return t.R().add(i.pub().mul(n)).eq(a)},Kb.prototype.hashInt=function(){for(var e=this.hash(),t=0;t