diff --git a/LoginThread.js b/LoginThread.js index e3bcadf1..2c45c79b 100644 --- a/LoginThread.js +++ b/LoginThread.js @@ -1,2 +1 @@ -/*! For license information please see LoginThread.js.LICENSE.txt */ -var t,e,r,i,n,a,o,s,h,u,l,f,c,d,p,m,g,y,v,b,w,M,_,E,S,C,A,I,T,B,k,R,N,L,x,D,U,P,O,j,V,q,K,F,H,z,G,W,Z,Y,$,Q,X,J,tt,et,rt,it,nt,at,ot,st,ht,ut,lt,ft,ct,dt,pt,mt,gt,yt,vt,bt,wt,Mt,_t,Et,St,Ct,At,It,Tt,Bt,kt,Rt,Nt,Lt,xt,Dt,Ut,Pt,Ot,jt,Vt,qt,Kt,Ft,Ht,zt,Gt,Wt,Zt,Yt,$t,Qt,Xt,Jt,te,ee,re,ie,ne,ae,oe,se,he,ue,le,fe,ce,de,pe,me,ge,ye,ve,be,we,Me,_e,Ee,Se,Ce,Ae,Ie,Te,Be,ke,Re,Ne,Le,xe,De,Ue,Pe,Oe,je,Ve,qe,Ke,Fe,He,ze,Ge,We,Ze,Ye,$e,Qe,Xe,Je,tr,er,rr,ir,nr,ar,or,sr,hr,ur,lr,fr,cr,dr,pr,mr,gr,yr,vr,br,wr,Mr,_r,Er,Sr,Cr,Ar,Ir,Tr,Br,kr,Rr,Nr,Lr,xr,Dr,Ur,Pr,Or,jr,Vr,qr,Kr,Fr,Hr,zr,Gr,Wr,Zr,Yr,$r,Qr,Xr,Jr,ti,ei,ri,ii,ni,ai,oi,si,hi,ui,li,fi,ci,di,pi,mi,gi=Object.create,yi=Object.defineProperty,vi=Object.getPrototypeOf,bi=Object.getOwnPropertyNames,wi=Object.getOwnPropertyDescriptor,Mi=Object.prototype.hasOwnProperty,_i=(t,e,r)=>{r=null!=t?gi(vi(t)):{};const i=!e&&t&&t.__esModule?r:yi(r,'default',{value:t,enumerable:!0});for(let e of bi(t))Mi.call(i,e)||yi(i,e,{get:()=>t[e],enumerable:!0});return i},Ei=t=>{const e=Ei.moduleCache??=new WeakMap;var r=e.get(t);if(r)return r;var i=yi({},'__esModule',{value:!0}),n={enumerable:!1};if(t&&'object'==typeof t||'function'==typeof t)for(let e of bi(t))Mi.call(i,e)||yi(i,e,{get:()=>t[e],enumerable:!(n=wi(t,e))||n.enumerable});return e.set(t,i),i},Si=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ci=Si(((t,e)=>{e.exports={options:{usePureJavaScript:!1}}})),Ai=Si(((t,e)=>{var r={};e.exports=r;var i={};r.encode=function(t,e,r){if('string'!=typeof e)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&'number'!=typeof r)throw new TypeError('"maxline" must be a number.');var i='';if(t instanceof Uint8Array){var n=0,a=e.length,o=e.charAt(0),s=[0];for(n=0;n0;)s.push(u%a),u=u/a|0}for(n=0;0===t[n]&&n=0;--n)i+=e[s[n]]}else i=function(t,e){var r=0,i=e.length,n=e.charAt(0),a=[0];for(r=0;r0;)a.push(s%i),s=s/i|0}var h='';for(r=0;0===t.at(r)&&r=0;--r)h+=e[a[r]];return h}(t,e);if(r){var l=new RegExp('.{1,'+r+'}','g');i=i.match(l).join('\r\n')}return i},r.decode=function(t,e){if('string'!=typeof t)throw new TypeError('"input" must be a string.');if('string'!=typeof e)throw new TypeError('"alphabet" must be a string.');var r=i[e];if(!r){r=i[e]=[];for(var n=0;n>=8;for(;l>0;)s.push(255&l),l>>=8}for(var f=0;t[f]===o&&f{var r=function(t){if(8!==t&&16!==t&&24!==t&&32!==t)throw new Error('Only 8, 16, 24, or 32 bits supported: '+t)},i=function(t){if(this.data='',this.read=0,'string'==typeof t)this.data=t;else if(o.isArrayBuffer(t)||o.isArrayBufferView(t))if('undefined'!=typeof Buffer&&t instanceof Buffer)this.data=t.toString('binary');else{var e=new Uint8Array(t);try{this.data=String.fromCharCode.apply(null,e)}catch(t){for(var r=0;r15?(r=Date.now(),a(t)):(e.push(t),1===e.length&&n.setAttribute('a',i=!i))}}o.nextTick=o.setImmediate}(),o.isNodejs='undefined'!=typeof process&&process.versions&&process.versions.node,o.globalScope=o.isNodejs?global:'undefined'==typeof self?window:self,o.isArray=Array.isArray||function(t){return'[object Array]'===Object.prototype.toString.call(t)},o.isArrayBuffer=function(t){return'undefined'!=typeof ArrayBuffer&&t instanceof ArrayBuffer},o.isArrayBufferView=function(t){return t&&o.isArrayBuffer(t.buffer)&&void 0!==t.byteLength},o.ByteBuffer=i,o.ByteStringBuffer=i;o.ByteStringBuffer.prototype._optimizeConstructedString=function(t){this._constructedStringLength+=t,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},o.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},o.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},o.ByteStringBuffer.prototype.putByte=function(t){return this.putBytes(String.fromCharCode(t))},o.ByteStringBuffer.prototype.fillWithByte=function(t,e){t=String.fromCharCode(t);for(var r=this.data;e>0;)1&e&&(r+=t),(e>>>=1)>0&&(t+=t);return this.data=r,this._optimizeConstructedString(e),this},o.ByteStringBuffer.prototype.putBytes=function(t){return this.data+=t,this._optimizeConstructedString(t.length),this},o.ByteStringBuffer.prototype.putString=function(t){return this.putBytes(o.encodeUtf8(t))},o.ByteStringBuffer.prototype.putInt16=function(t){return this.putBytes(String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},o.ByteStringBuffer.prototype.putInt24=function(t){return this.putBytes(String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},o.ByteStringBuffer.prototype.putInt32=function(t){return this.putBytes(String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},o.ByteStringBuffer.prototype.putInt16Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255))},o.ByteStringBuffer.prototype.putInt24Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255))},o.ByteStringBuffer.prototype.putInt32Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>24&255))},o.ByteStringBuffer.prototype.putInt=function(t,e){r(e);var i='';do{e-=8,i+=String.fromCharCode(t>>e&255)}while(e>0);return this.putBytes(i)},o.ByteStringBuffer.prototype.putSignedInt=function(t,e){return t<0&&(t+=2<0);return e},o.ByteStringBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<=r&&(e-=r<<1),e},o.ByteStringBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):0===t?e='':(e=0===this.read?this.data:this.data.slice(this.read),this.clear()),e},o.ByteStringBuffer.prototype.bytes=function(t){return void 0===t?this.data.slice(this.read):this.data.slice(this.read,this.read+t)},o.ByteStringBuffer.prototype.at=function(t){return this.data.charCodeAt(this.read+t)},o.ByteStringBuffer.prototype.setAt=function(t,e){return this.data=this.data.substr(0,this.read+t)+String.fromCharCode(e)+this.data.substr(this.read+t+1),this},o.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},o.ByteStringBuffer.prototype.copy=function(){var t=o.createBuffer(this.data);return t.read=this.read,t},o.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},o.ByteStringBuffer.prototype.clear=function(){return this.data='',this.read=0,this},o.ByteStringBuffer.prototype.truncate=function(t){var e=Math.max(0,this.length()-t);return this.data=this.data.substr(this.read,e),this.read=0,this},o.ByteStringBuffer.prototype.toHex=function(){for(var t='',e=this.read;e=t)return this;e=Math.max(e||this.growSize,t);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),i=new Uint8Array(this.length()+e);return i.set(r),this.data=new DataView(i.buffer),this},o.DataBuffer.prototype.putByte=function(t){return this.accommodate(1),this.data.setUint8(this.write++,t),this},o.DataBuffer.prototype.fillWithByte=function(t,e){this.accommodate(e);for(var r=0;r>8&65535),this.data.setInt8(this.write,t>>16&255),this.write+=3,this},o.DataBuffer.prototype.putInt32=function(t){return this.accommodate(4),this.data.setInt32(this.write,t),this.write+=4,this},o.DataBuffer.prototype.putInt16Le=function(t){return this.accommodate(2),this.data.setInt16(this.write,t,!0),this.write+=2,this},o.DataBuffer.prototype.putInt24Le=function(t){return this.accommodate(3),this.data.setInt8(this.write,t>>16&255),this.data.setInt16(this.write,t>>8&65535,!0),this.write+=3,this},o.DataBuffer.prototype.putInt32Le=function(t){return this.accommodate(4),this.data.setInt32(this.write,t,!0),this.write+=4,this},o.DataBuffer.prototype.putInt=function(t,e){r(e),this.accommodate(e/8);do{e-=8,this.data.setInt8(this.write++,t>>e&255)}while(e>0);return this},o.DataBuffer.prototype.putSignedInt=function(t,e){return r(e),this.accommodate(e/8),t<0&&(t+=2<0);return e},o.DataBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<=r&&(e-=r<<1),e},o.DataBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):0===t?e='':(e=0===this.read?this.data:this.data.slice(this.read),this.clear()),e},o.DataBuffer.prototype.bytes=function(t){return void 0===t?this.data.slice(this.read):this.data.slice(this.read,this.read+t)},o.DataBuffer.prototype.at=function(t){return this.data.getUint8(this.read+t)},o.DataBuffer.prototype.setAt=function(t,e){return this.data.setUint8(t,e),this},o.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},o.DataBuffer.prototype.copy=function(){return new o.DataBuffer(this)},o.DataBuffer.prototype.compact=function(){if(this.read>0){var t=new Uint8Array(this.data.buffer,this.read),e=new Uint8Array(t.byteLength);e.set(t),this.data=new DataView(e),this.write-=this.read,this.read=0}return this},o.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},o.DataBuffer.prototype.truncate=function(t){return this.write=Math.max(0,this.length()-t),this.read=Math.min(this.read,this.write),this},o.DataBuffer.prototype.toHex=function(){for(var t='',e=this.read;e0;)1&e&&(r+=t),(e>>>=1)>0&&(t+=t);return r},o.xorBytes=function(t,e,r){for(var i='',n='',a='',o=0,s=0;r>0;--r,++o)n=t.charCodeAt(o)^e.charCodeAt(o),s>=10&&(i+=a,a='',s=0),a+=String.fromCharCode(n),++s;return i+=a},o.hexToBytes=function(t){var e='',r=0;for(!0&t.length&&(r=1,e+=String.fromCharCode(parseInt(t[0],16)));r>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t)};var s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',h=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],u='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';o.encode64=function(t,e){for(var r,i,n,a='',o='',h=0;h>2),a+=s.charAt((3&r)<<4|i>>4),isNaN(i)?a+='==':(a+=s.charAt((15&i)<<2|n>>6),a+=isNaN(n)?'=':s.charAt(63&n)),e&&a.length>e&&(o+=a.substr(0,e)+'\r\n',a=a.substr(e));return o+=a},o.decode64=function(t){t=t.replace(/[^A-Za-z0-9\+\/\=]/g,'');for(var e,r,i,n,a='',o=0;o>4),64!==i&&(a+=String.fromCharCode((15&r)<<4|i>>2),64!==n&&(a+=String.fromCharCode((3&i)<<6|n)));return a},o.encodeUtf8=function(t){return unescape(encodeURIComponent(t))},o.decodeUtf8=function(t){return decodeURIComponent(escape(t))},o.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:a.encode,decode:a.decode}},o.binary.raw.encode=function(t){return String.fromCharCode.apply(null,t)},o.binary.raw.decode=function(t,e,r){var i=e;i||(i=new Uint8Array(t.length));for(var n=r=r||0,a=0;a>2),a+=s.charAt((3&r)<<4|i>>4),isNaN(i)?a+='==':(a+=s.charAt((15&i)<<2|n>>6),a+=isNaN(n)?'=':s.charAt(63&n)),e&&a.length>e&&(o+=a.substr(0,e)+'\r\n',a=a.substr(e));return o+=a},o.binary.base64.decode=function(t,e,r){var i,n,a,o,s=e;s||(s=new Uint8Array(3*Math.ceil(t.length/4))),t=t.replace(/[^A-Za-z0-9\+\/\=]/g,'');for(var u=0,l=r=r||0;u>4,64!==a&&(s[l++]=(15&n)<<4|a>>2,64!==o&&(s[l++]=(3&a)<<6|o));return e?l-r:s.subarray(0,l)},o.binary.base58.encode=function(t,e){return o.binary.baseN.encode(t,u,e)},o.binary.base58.decode=function(t,e){return o.binary.baseN.decode(t,u,e)},o.text={utf8:{},utf16:{}},o.text.utf8.encode=function(t,e,r){t=o.encodeUtf8(t);var i=e;i||(i=new Uint8Array(t.length));for(var n=r=r||0,a=0;a0&&a.push(r),o=i.lastIndex;var s=e[0][1];switch(s){case's':case'o':n');break;case'%':a.push('%');break;default:a.push('<%'+s+'?>')}}return a.push(t.substring(o)),a.join('')},o.formatNumber=function(t,e,r,i){var n=t,a=isNaN(e=Math.abs(e))?2:e,o=void 0===r?',':r,s=void 0===i?'.':i,h=n<0?'-':'',u=parseInt(n=Math.abs(+n||0).toFixed(a),10)+'',l=u.length>3?u.length%3:0;return h+(l?u.substr(0,l)+s:'')+u.substr(l).replace(/(\d{3})(?=\d)/g,'$1'+s)+(a?o+Math.abs(n-u).toFixed(a).slice(2):'')},o.formatSize=function(t){return t=t>=1073741824?o.formatNumber(t/1073741824,2,'.','')+' GiB':t>=1048576?o.formatNumber(t/1048576,2,'.','')+' MiB':t>=1024?o.formatNumber(t/1024,0)+' KiB':o.formatNumber(t,0)+' bytes'},o.bytesFromIP=function(t){return-1!==t.indexOf('.')?o.bytesFromIPv4(t):-1!==t.indexOf(':')?o.bytesFromIPv6(t):null},o.bytesFromIPv4=function(t){if(4!==(t=t.split('.')).length)return null;for(var e=o.createBuffer(),r=0;rr[i].end-r[i].start&&(i=r.length-1)):r.push({start:h,end:h})}e.push(a)}if(r.length>0){var u=r[i];u.end-u.start>0&&(e.splice(u.start,u.end-u.start+1,''),0===u.start&&e.unshift(''),7===u.end&&e.push(''))}return e.join(':')},o.estimateCores=function(t,e){if('function'==typeof t&&(e=t,t={}),t=t||{},'cores'in o&&!t.update)return e(null,o.cores);if('undefined'!=typeof navigator&&'hardwareConcurrency'in navigator&&navigator.hardwareConcurrency>0)return o.cores=navigator.hardwareConcurrency,e(null,o.cores);if('undefined'==typeof Worker)return o.cores=1,e(null,o.cores);if('undefined'==typeof Blob)return o.cores=2,e(null,o.cores);var r=URL.createObjectURL(new Blob(['(',function(){self.addEventListener('message',(function(t){for(var e=Date.now(),r=e+4;Date.now()s.st&&n.stn.st&&s.st{var r=Ci();Ii(),e.exports=r.cipher=r.cipher||{},r.cipher.algorithms=r.cipher.algorithms||{},r.cipher.createCipher=function(t,e){var i=t;if('string'==typeof i&&(i=r.cipher.getAlgorithm(i))&&(i=i()),!i)throw new Error('Unsupported algorithm: '+t);return new r.cipher.BlockCipher({algorithm:i,key:e,decrypt:!1})},r.cipher.createDecipher=function(t,e){var i=t;if('string'==typeof i&&(i=r.cipher.getAlgorithm(i))&&(i=i()),!i)throw new Error('Unsupported algorithm: '+t);return new r.cipher.BlockCipher({algorithm:i,key:e,decrypt:!0})},r.cipher.registerAlgorithm=function(t,e){t=t.toUpperCase(),r.cipher.algorithms[t]=e},r.cipher.getAlgorithm=function(t){return(t=t.toUpperCase())in r.cipher.algorithms?r.cipher.algorithms[t]:null};var i=r.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};i.prototype.start=function(t){t=t||{};var e={};for(var i in t)e[i]=t[i];e.decrypt=this._decrypt,this._finish=!1,this._input=r.util.createBuffer(),this.output=t.output||r.util.createBuffer(),this.mode.start(e)},i.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(t){!t||'ECB'!==this.mode.name&&'CBC'!==this.mode.name||(this.mode.pad=function(e){return t(this.blockSize,e,!1)},this.mode.unpad=function(e){return t(this.blockSize,e,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,e)))}})),Bi=Si(((t,e)=>{var r=function(t,e){if('string'==typeof t&&(t=a.util.createBuffer(t)),a.util.isArray(t)&&t.length>4){var r=t;t=a.util.createBuffer();for(var i=0;i0))return!0;for(var i=0;i0))return!0;for(var i=0;i0)return!1;var r=t.length(),i=t.at(r-1);return!(i>this.blockSize<<2)&&(t.truncate(i),!0)},o.cbc=function(t){t=t||{},this.name='CBC',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},o.cbc.prototype.start=function(t){if(null===t.iv){if(!this._prev)throw new Error('Invalid IV parameter.');this._iv=this._prev.slice(0)}else{if(!('iv'in t))throw new Error('Invalid IV parameter.');this._iv=r(t.iv,this.blockSize),this._prev=this._iv.slice(0)}},o.cbc.prototype.encrypt=function(t,e,r){if(t.length()0))return!0;for(var i=0;i0))return!0;for(var i=0;i0)return!1;var r=t.length(),i=t.at(r-1);return!(i>this.blockSize<<2)&&(t.truncate(i),!0)},o.cfb=function(t){t=t||{},this.name='CFB',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=a.util.createBuffer(),this._partialBytes=0},o.cfb.prototype.start=function(t){if(!('iv'in t))throw new Error('Invalid IV parameter.');this._iv=r(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},o.cfb.prototype.encrypt=function(t,e,r){var i=t.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(a=this.blockSize-a),this._partialOutput.clear();for(n=0;n0)t.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}},o.cfb.prototype.decrypt=function(t,e,r){var i=t.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(a=this.blockSize-a),this._partialOutput.clear();for(n=0;n0)t.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}},o.ofb=function(t){t=t||{},this.name='OFB',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=a.util.createBuffer(),this._partialBytes=0},o.ofb.prototype.start=function(t){if(!('iv'in t))throw new Error('Invalid IV parameter.');this._iv=r(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},o.ofb.prototype.encrypt=function(t,e,r){var i=t.length();if(0===t.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(a=this.blockSize-a),this._partialOutput.clear();for(n=0;n0)t.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}},o.ofb.prototype.decrypt=o.ofb.prototype.encrypt,o.ctr=function(t){t=t||{},this.name='CTR',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=a.util.createBuffer(),this._partialBytes=0},o.ctr.prototype.start=function(t){if(!('iv'in t))throw new Error('Invalid IV parameter.');this._iv=r(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},o.ctr.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var a=0;a0&&(o=this.blockSize-o),this._partialOutput.clear();for(a=0;a0&&(t.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}i(this._inBlock)},o.ctr.prototype.decrypt=o.ctr.prototype.encrypt,o.gcm=function(t){t=t||{},this.name='GCM',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=a.util.createBuffer(),this._partialBytes=0,this._R=3774873600},o.gcm.prototype.start=function(t){if(!('iv'in t))throw new Error('Invalid IV parameter.');var e,r=a.util.createBuffer(t.iv);if(this._cipherLength=0,e='additionalData'in t?a.util.createBuffer(t.additionalData):a.util.createBuffer(),this._tagLength='tagLength'in t?t.tagLength:128,this._tag=null,t.decrypt&&(this._tag=a.util.createBuffer(t.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error('Authentication tag does not match tag length.');this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var o=r.length();if(12===o)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(n(8*o)))}this._inBlock=this._j0.slice(0),i(this._inBlock),this._partialBytes=0,e=a.util.createBuffer(e),this._aDataLength=n(8*e.length());var s=e.length()%this.blockSize;for(s&&e.fillWithByte(0,this.blockSize-s),this._s=[0,0,0,0];e.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[e.getInt32(),e.getInt32(),e.getInt32(),e.getInt32()])},o.gcm.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var a=0;a0&&(o=this.blockSize-o),this._partialOutput.clear();for(a=0;a0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.read-=this.blockSize,e.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),i(this._inBlock)},o.gcm.prototype.decrypt=function(t,e,r){var n=t.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),i(this._inBlock),this._hashBlock[0]=t.getInt32(),this._hashBlock[1]=t.getInt32(),this._hashBlock[2]=t.getInt32(),this._hashBlock[3]=t.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var a=0;a0;--i)e[i]=t[i]>>>1|(1&t[i-1])<<31;e[0]=t[0]>>>1,r&&(e[0]^=this._R)},o.gcm.prototype.tableMultiply=function(t){for(var e=[0,0,0,0],r=0;r<32;++r){var i=t[r/8|0]>>>4*(7-r%8)&15,n=this._m[r][i];e[0]^=n[0],e[1]^=n[1],e[2]^=n[2],e[3]^=n[3]}return e},o.gcm.prototype.ghash=function(t,e,r){return e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3],this.tableMultiply(e)},o.gcm.prototype.generateHashTable=function(t,e){for(var r=8/e,i=4*r,n=16*r,a=new Array(n),o=0;o>>1,n=new Array(r);n[i]=t.slice(0);for(var a=i>>>1;a>0;)this.pow(n[2*a],n[a]=[]),a>>=1;for(a=2;a{var r=function(t,e){s.cipher.registerAlgorithm(t,(function(){return new s.aes.Algorithm(t,e)}))},i=function(){d=!0,l=[0,1,2,4,8,16,32,64,128,27,54];for(var t=new Array(256),e=0;e<128;++e)t[e]=e<<1,t[e+128]=e+128<<1^283;h=new Array(256),u=new Array(256),f=new Array(4),c=new Array(4);for(e=0;e<4;++e)f[e]=new Array(256),c[e]=new Array(256);var r,i,n,a,o,s,p,m=0,g=0;for(e=0;e<256;++e){a=(a=g^g<<1^g<<2^g<<3^g<<4)>>8^255&a^99,h[m]=a,u[a]=m,s=(o=t[a])<<24^a<<16^a<<8^a^o,p=((r=t[m])^(i=t[r])^(n=t[i]))<<24^(m^n)<<16^(m^i^n)<<8^m^r^n;for(var y=0;y<4;++y)f[y][m]=s,c[y][a]=p,s=s<<24|s>>>8,p=p<<24|p>>>8;0===m?m=g=1:(m=r^t[t[t[r^n]]],g^=t[t[g]])}},n=function(t,e){for(var r,i=t.slice(0),n=1,a=i.length,o=p*(a+6+1),s=a;s>>16&255]<<24^h[r>>>8&255]<<16^h[255&r]<<8^h[r>>>24]^l[n]<<24,n++):a>6&&s%a==4&&(r=h[r>>>24]<<24^h[r>>>16&255]<<16^h[r>>>8&255]<<8^h[255&r]),i[s]=i[s-a]^r;if(e){for(var u,f=c[0],d=c[1],m=c[2],g=c[3],y=i.slice(0),v=(s=0,(o=i.length)-p);s>>24]]^d[h[u>>>16&255]]^m[h[u>>>8&255]]^g[h[255&u]];i=y}return i},a=function(t,e,r,i){var n,a,o,s,l,d,p,m,g,y,v,b,w=t.length/4-1;i?(n=c[0],a=c[1],o=c[2],s=c[3],l=u):(n=f[0],a=f[1],o=f[2],s=f[3],l=h),d=e[0]^t[0],p=e[i?3:1]^t[1],m=e[2]^t[2],g=e[i?1:3]^t[3];for(var M=3,_=1;_>>24]^a[p>>>16&255]^o[m>>>8&255]^s[255&g]^t[++M],v=n[p>>>24]^a[m>>>16&255]^o[g>>>8&255]^s[255&d]^t[++M],b=n[m>>>24]^a[g>>>16&255]^o[d>>>8&255]^s[255&p]^t[++M],g=n[g>>>24]^a[d>>>16&255]^o[p>>>8&255]^s[255&m]^t[++M],d=y,p=v,m=b;r[0]=l[d>>>24]<<24^l[p>>>16&255]<<16^l[m>>>8&255]<<8^l[255&g]^t[++M],r[i?3:1]=l[p>>>24]<<24^l[m>>>16&255]<<16^l[g>>>8&255]<<8^l[255&d]^t[++M],r[2]=l[m>>>24]<<24^l[g>>>16&255]<<16^l[d>>>8&255]<<8^l[255&p]^t[++M],r[i?1:3]=l[g>>>24]<<24^l[d>>>16&255]<<16^l[p>>>8&255]<<8^l[255&m]^t[++M]},o=function(t){var e,r='AES-'+((t=t||{}).mode||'CBC').toUpperCase(),i=(e=t.decrypt?s.cipher.createDecipher(r,t.key):s.cipher.createCipher(r,t.key)).start;return e.start=function(t,r){var n=null;r instanceof s.util.ByteBuffer&&(n=r,r={}),(r=r||{}).output=n,r.iv=t,i.call(e,r)},e},s=Ci();Ti(),Bi(),Ii(),e.exports=s.aes=s.aes||{},s.aes.startEncrypting=function(t,e,r,i){var n=o({key:t,output:r,decrypt:!1,mode:i});return n.start(e),n},s.aes.createEncryptionCipher=function(t,e){return o({key:t,output:null,decrypt:!1,mode:e})},s.aes.startDecrypting=function(t,e,r,i){var n=o({key:t,output:r,decrypt:!0,mode:i});return n.start(e),n},s.aes.createDecryptionCipher=function(t,e){return o({key:t,output:null,decrypt:!0,mode:e})},s.aes.Algorithm=function(t,e){d||i();var r=this;r.name=t,r.mode=new e({blockSize:16,cipher:{encrypt:function(t,e){return a(r._w,t,e,!1)},decrypt:function(t,e){return a(r._w,t,e,!0)}}}),r._init=!1},s.aes.Algorithm.prototype.initialize=function(t){if(!this._init){var e,r=t.key;if('string'!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(s.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){e=r,r=s.util.createBuffer();for(var i=0;i>>=2;for(i=0;i{var r=function(t,e){a[t]=e,a[e]=t},i=function(t,e){a[t]=e},n=Ci();n.pki=n.pki||{};var a=e.exports=n.pki.oids=n.oids=n.oids||{};r('1.2.840.113549.1.1.1','rsaEncryption'),r('1.2.840.113549.1.1.4','md5WithRSAEncryption'),r('1.2.840.113549.1.1.5','sha1WithRSAEncryption'),r('1.2.840.113549.1.1.7','RSAES-OAEP'),r('1.2.840.113549.1.1.8','mgf1'),r('1.2.840.113549.1.1.9','pSpecified'),r('1.2.840.113549.1.1.10','RSASSA-PSS'),r('1.2.840.113549.1.1.11','sha256WithRSAEncryption'),r('1.2.840.113549.1.1.12','sha384WithRSAEncryption'),r('1.2.840.113549.1.1.13','sha512WithRSAEncryption'),r('1.3.101.112','EdDSA25519'),r('1.2.840.10040.4.3','dsa-with-sha1'),r('1.3.14.3.2.7','desCBC'),r('1.3.14.3.2.26','sha1'),r('1.3.14.3.2.29','sha1WithRSASignature'),r('2.16.840.1.101.3.4.2.1','sha256'),r('2.16.840.1.101.3.4.2.2','sha384'),r('2.16.840.1.101.3.4.2.3','sha512'),r('2.16.840.1.101.3.4.2.4','sha224'),r('2.16.840.1.101.3.4.2.5','sha512-224'),r('2.16.840.1.101.3.4.2.6','sha512-256'),r('1.2.840.113549.2.2','md2'),r('1.2.840.113549.2.5','md5'),r('1.2.840.113549.1.7.1','data'),r('1.2.840.113549.1.7.2','signedData'),r('1.2.840.113549.1.7.3','envelopedData'),r('1.2.840.113549.1.7.4','signedAndEnvelopedData'),r('1.2.840.113549.1.7.5','digestedData'),r('1.2.840.113549.1.7.6','encryptedData'),r('1.2.840.113549.1.9.1','emailAddress'),r('1.2.840.113549.1.9.2','unstructuredName'),r('1.2.840.113549.1.9.3','contentType'),r('1.2.840.113549.1.9.4','messageDigest'),r('1.2.840.113549.1.9.5','signingTime'),r('1.2.840.113549.1.9.6','counterSignature'),r('1.2.840.113549.1.9.7','challengePassword'),r('1.2.840.113549.1.9.8','unstructuredAddress'),r('1.2.840.113549.1.9.14','extensionRequest'),r('1.2.840.113549.1.9.20','friendlyName'),r('1.2.840.113549.1.9.21','localKeyId'),r('1.2.840.113549.1.9.22.1','x509Certificate'),r('1.2.840.113549.1.12.10.1.1','keyBag'),r('1.2.840.113549.1.12.10.1.2','pkcs8ShroudedKeyBag'),r('1.2.840.113549.1.12.10.1.3','certBag'),r('1.2.840.113549.1.12.10.1.4','crlBag'),r('1.2.840.113549.1.12.10.1.5','secretBag'),r('1.2.840.113549.1.12.10.1.6','safeContentsBag'),r('1.2.840.113549.1.5.13','pkcs5PBES2'),r('1.2.840.113549.1.5.12','pkcs5PBKDF2'),r('1.2.840.113549.1.12.1.1','pbeWithSHAAnd128BitRC4'),r('1.2.840.113549.1.12.1.2','pbeWithSHAAnd40BitRC4'),r('1.2.840.113549.1.12.1.3','pbeWithSHAAnd3-KeyTripleDES-CBC'),r('1.2.840.113549.1.12.1.4','pbeWithSHAAnd2-KeyTripleDES-CBC'),r('1.2.840.113549.1.12.1.5','pbeWithSHAAnd128BitRC2-CBC'),r('1.2.840.113549.1.12.1.6','pbewithSHAAnd40BitRC2-CBC'),r('1.2.840.113549.2.7','hmacWithSHA1'),r('1.2.840.113549.2.8','hmacWithSHA224'),r('1.2.840.113549.2.9','hmacWithSHA256'),r('1.2.840.113549.2.10','hmacWithSHA384'),r('1.2.840.113549.2.11','hmacWithSHA512'),r('1.2.840.113549.3.7','des-EDE3-CBC'),r('2.16.840.1.101.3.4.1.2','aes128-CBC'),r('2.16.840.1.101.3.4.1.22','aes192-CBC'),r('2.16.840.1.101.3.4.1.42','aes256-CBC'),r('2.5.4.3','commonName'),r('2.5.4.4','surname'),r('2.5.4.5','serialNumber'),r('2.5.4.6','countryName'),r('2.5.4.7','localityName'),r('2.5.4.8','stateOrProvinceName'),r('2.5.4.9','streetAddress'),r('2.5.4.10','organizationName'),r('2.5.4.11','organizationalUnitName'),r('2.5.4.12','title'),r('2.5.4.13','description'),r('2.5.4.15','businessCategory'),r('2.5.4.17','postalCode'),r('2.5.4.42','givenName'),r('1.3.6.1.4.1.311.60.2.1.2','jurisdictionOfIncorporationStateOrProvinceName'),r('1.3.6.1.4.1.311.60.2.1.3','jurisdictionOfIncorporationCountryName'),r('2.16.840.1.113730.1.1','nsCertType'),r('2.16.840.1.113730.1.13','nsComment'),i('2.5.29.1','authorityKeyIdentifier'),i('2.5.29.2','keyAttributes'),i('2.5.29.3','certificatePolicies'),i('2.5.29.4','keyUsageRestriction'),i('2.5.29.5','policyMapping'),i('2.5.29.6','subtreesConstraint'),i('2.5.29.7','subjectAltName'),i('2.5.29.8','issuerAltName'),i('2.5.29.9','subjectDirectoryAttributes'),i('2.5.29.10','basicConstraints'),i('2.5.29.11','nameConstraints'),i('2.5.29.12','policyConstraints'),i('2.5.29.13','basicConstraints'),r('2.5.29.14','subjectKeyIdentifier'),r('2.5.29.15','keyUsage'),i('2.5.29.16','privateKeyUsagePeriod'),r('2.5.29.17','subjectAltName'),r('2.5.29.18','issuerAltName'),r('2.5.29.19','basicConstraints'),i('2.5.29.20','cRLNumber'),i('2.5.29.21','cRLReason'),i('2.5.29.22','expirationDate'),i('2.5.29.23','instructionCode'),i('2.5.29.24','invalidityDate'),i('2.5.29.25','cRLDistributionPoints'),i('2.5.29.26','issuingDistributionPoint'),i('2.5.29.27','deltaCRLIndicator'),i('2.5.29.28','issuingDistributionPoint'),i('2.5.29.29','certificateIssuer'),i('2.5.29.30','nameConstraints'),r('2.5.29.31','cRLDistributionPoints'),r('2.5.29.32','certificatePolicies'),i('2.5.29.33','policyMappings'),i('2.5.29.34','policyConstraints'),r('2.5.29.35','authorityKeyIdentifier'),i('2.5.29.36','policyConstraints'),r('2.5.29.37','extKeyUsage'),i('2.5.29.46','freshestCRL'),i('2.5.29.54','inhibitAnyPolicy'),r('1.3.6.1.4.1.11129.2.4.2','timestampList'),r('1.3.6.1.5.5.7.1.1','authorityInfoAccess'),r('1.3.6.1.5.5.7.3.1','serverAuth'),r('1.3.6.1.5.5.7.3.2','clientAuth'),r('1.3.6.1.5.5.7.3.3','codeSigning'),r('1.3.6.1.5.5.7.3.4','emailProtection'),r('1.3.6.1.5.5.7.3.8','timeStamping')})),Ni=Si(((t,e)=>{var r=function(t,e,r){if(r>e){var i=new Error('Too few bytes to parse DER.');throw i.available=t.length(),i.remaining=e,i.requested=r,i}},i=function(t,e,n,s){var h;r(t,e,2);var u=t.getByte();e--;var l=192&u,f=31&u;h=t.length();var c,d,p=o(t,e);if(e-=h-t.length(),void 0!==p&&p>e){if(s.strict){var m=new Error('Too few bytes to read ASN.1 value.');throw m.available=t.length(),m.remaining=e,m.requested=p,m}p=e}var g=!(32&~u);if(g)if(c=[],void 0===p)for(;;){if(r(t,e,2),t.bytes(2)===String.fromCharCode(0,0)){t.getBytes(2),e-=2;break}h=t.length(),c.push(i(t,e,n+1,s)),e-=h-t.length()}else for(;p>0;)h=t.length(),c.push(i(t,p,n+1,s)),e-=h-t.length(),p-=h-t.length();if(void 0===c&&l===a.Class.UNIVERSAL&&f===a.Type.BITSTRING&&(d=t.bytes(p)),void 0===c&&s.decodeBitStrings&&l===a.Class.UNIVERSAL&&f===a.Type.BITSTRING&&p>1){var y=t.read,v=e,b=0;if(f===a.Type.BITSTRING&&(r(t,e,1),b=t.getByte(),e--),0===b)try{h=t.length();var w=i(t,e,n+1,{strict:!0,decodeBitStrings:!0}),M=h-t.length();e-=M,f==a.Type.BITSTRING&&M++;var _=w.tagClass;M!==p||_!==a.Class.UNIVERSAL&&_!==a.Class.CONTEXT_SPECIFIC||(c=[w])}catch(t){}void 0===c&&(t.read=y,e=v)}if(void 0===c){if(void 0===p){if(s.strict)throw new Error('Non-constructed ASN.1 object of indefinite length.');p=e}if(f===a.Type.BMPSTRING)for(c='';p>0;p-=2)r(t,e,2),c+=String.fromCharCode(t.getInt16()),e-=2;else c=t.getBytes(p),e-=p}var E=void 0===d?null:{bitStringContents:d};return a.create(l,f,g,c,E)},n=Ci();Ii(),Ri();var a=e.exports=n.asn1=n.asn1||{};a.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},a.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},a.create=function(t,e,r,i,o){if(n.util.isArray(i)){for(var s=[],h=0;h1)||(0!==t.value.charCodeAt(0)||128&t.value.charCodeAt(1))&&(255!==t.value.charCodeAt(0)||128&~t.value.charCodeAt(1))?i.putBytes(t.value):i.putBytes(t.value.substr(1));if(e.putByte(r),i.length()<=127)e.putByte(127&i.length());else{var h=i.length(),u='';do{u+=String.fromCharCode(255&h),h>>>=8}while(h>0);e.putByte(128|u.length);for(s=u.length-1;s>=0;--s)e.putByte(u.charCodeAt(s))}return e.putBuffer(i),e},a.oidToDer=function(t){var e,r,i,a,o=t.split('.'),s=n.util.createBuffer();s.putByte(40*parseInt(o[0],10)+parseInt(o[1],10));for(var h=2;h>>=7,e||(a|=128),r.push(a),e=!1}while(i>0);for(var u=r.length-1;u>=0;--u)s.putByte(r[u])}return s},a.derToOid=function(t){var e;'string'==typeof t&&(t=n.util.createBuffer(t));var r=t.getByte();e=Math.floor(r/40)+'.'+r%40;for(var i=0;t.length()>0;)i<<=7,128&(r=t.getByte())?i+=127&r:(e+='.'+(i+r),i=0);return e},a.utcTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,2),10);r=r>=50?1900+r:2e3+r;var i=parseInt(t.substr(2,2),10)-1,n=parseInt(t.substr(4,2),10),a=parseInt(t.substr(6,2),10),o=parseInt(t.substr(8,2),10),s=0;if(t.length>11){var h=t.charAt(10),u=10;'+'!==h&&'-'!==h&&(s=parseInt(t.substr(10,2),10),u+=2)}if(e.setUTCFullYear(r,i,n),e.setUTCHours(a,o,s,0),u&&('+'===(h=t.charAt(u))||'-'===h)){var l=60*parseInt(t.substr(u+1,2),10)+parseInt(t.substr(u+4,2),10);l*=6e4,'+'===h?e.setTime(+e-l):e.setTime(+e+l)}return e},a.generalizedTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,4),10),i=parseInt(t.substr(4,2),10)-1,n=parseInt(t.substr(6,2),10),a=parseInt(t.substr(8,2),10),o=parseInt(t.substr(10,2),10),s=parseInt(t.substr(12,2),10),h=0,u=0,l=!1;'Z'===t.charAt(t.length-1)&&(l=!0);var f=t.length-5,c=t.charAt(f);'+'!==c&&'-'!==c||(u=60*parseInt(t.substr(f+1,2),10)+parseInt(t.substr(f+4,2),10),u*=6e4,'+'===c&&(u*=-1),l=!0);return'.'===t.charAt(14)&&(h=1e3*parseFloat(t.substr(14),10)),l?(e.setUTCFullYear(r,i,n),e.setUTCHours(a,o,s,h),e.setTime(+e+u)):(e.setFullYear(r,i,n),e.setHours(a,o,s,h)),e},a.dateToUtcTime=function(t){if('string'==typeof t)return t;var e='',r=[];r.push((''+t.getUTCFullYear()).substr(2)),r.push(''+(t.getUTCMonth()+1)),r.push(''+t.getUTCDate()),r.push(''+t.getUTCHours()),r.push(''+t.getUTCMinutes()),r.push(''+t.getUTCSeconds());for(var i=0;i=-128&&t<128)return e.putSignedInt(t,8);if(t>=-32768&&t<32768)return e.putSignedInt(t,16);if(t>=-8388608&&t<8388608)return e.putSignedInt(t,24);if(t>=-2147483648&&t<2147483648)return e.putSignedInt(t,32);var r=new Error('Integer too large; max is 32-bits.');throw r.integer=t,r},a.derToInteger=function(t){'string'==typeof t&&(t=n.util.createBuffer(t));var e=8*t.length();if(e>32)throw new Error('Integer too large; max is 32-bits.');return t.getSignedInt(e)},a.validate=function(t,e,r,i){var o=!1;if(t.tagClass!==e.tagClass&&void 0!==e.tagClass||t.type!==e.type&&void 0!==e.type)i&&(t.tagClass!==e.tagClass&&i.push('['+e.name+"] Expected tag class \""+e.tagClass+'", got "'+t.tagClass+'"'),t.type!==e.type&&i.push('['+e.name+"] Expected type \""+e.type+'", got "'+t.type+'"'));else if(t.constructed===e.constructed||void 0===e.constructed){if(o=!0,e.value&&n.util.isArray(e.value))for(var s=0,h=0;o&&h0&&(i+='\n');for(var o='',h=0;h1?i+='0x'+n.util.bytesToHex(t.value.slice(1)):i+='(none)',t.value.length>0){var c=t.value.charCodeAt(0);1==c?i+=' (1 unused bit shown)':c>1&&(i+=' ('+c+' unused bits shown)')}}else if(t.type===a.Type.OCTETSTRING)s.test(t.value)||(i+='('+t.value+') '),i+='0x'+n.util.bytesToHex(t.value);else if(t.type===a.Type.UTF8)try{i+=n.util.decodeUtf8(t.value)}catch(e){if('URI malformed'!==e.message)throw e;i+='0x'+n.util.bytesToHex(t.value)+' (malformed UTF8)'}else t.type===a.Type.PRINTABLESTRING||t.type===a.Type.IA5String?i+=t.value:s.test(t.value)?i+='0x'+n.util.bytesToHex(t.value):0===t.value.length?i+='[null]':i+=t.value}return i}})),Li=Si(((t,e)=>{var r=Ci();e.exports=r.md=r.md||{},r.md.algorithms=r.md.algorithms||{}})),xi=Si(((t,e)=>{var r=Ci();Li(),Ii(),(e.exports=r.hmac=r.hmac||{}).create=function(){var t=null,e=null,i=null,n=null,a={start:function(a,o){if(null!==a)if('string'==typeof a){if(!((a=a.toLowerCase())in r.md.algorithms))throw new Error('Unknown hash algorithm "'+a+'"');e=r.md.algorithms[a].create()}else e=a;if(null===o)o=t;else{if('string'==typeof o)o=r.util.createBuffer(o);else if(r.util.isArray(o)){var s=o;o=r.util.createBuffer();for(var h=0;he.blockLength&&(e.start(),e.update(o.bytes()),o=e.digest()),i=r.util.createBuffer(),n=r.util.createBuffer(),u=o.length();for(h=0;h{var r=function(t,e,r){for(var i,n,a,u,l,f,c,d=r.length();d>=64;){for(n=t.h0,a=t.h1,u=t.h2,l=t.h3,c=0;c<16;++c)e[c]=r.getInt32Le(),i=n+(l^a&(u^l))+h[c]+e[c],n=l,l=u,u=a,a+=i<<(f=s[c])|i>>>32-f;for(;c<32;++c)i=n+(u^l&(a^u))+h[c]+e[o[c]],n=l,l=u,u=a,a+=i<<(f=s[c])|i>>>32-f;for(;c<48;++c)i=n+(a^u^l)+h[c]+e[o[c]],n=l,l=u,u=a,a+=i<<(f=s[c])|i>>>32-f;for(;c<64;++c)i=n+(u^(a|~l))+h[c]+e[o[c]],n=l,l=u,u=a,a+=i<<(f=s[c])|i>>>32-f;t.h0=t.h0+n|0,t.h1=t.h1+a|0,t.h2=t.h2+u|0,t.h3=t.h3+l|0,d-=64}},i=Ci();Li(),Ii();var n=e.exports=i.md5=i.md5||{};i.md.md5=i.md.algorithms.md5=n,n.create=function(){u||function(){a=String.fromCharCode(128),a+=i.util.fillString(String.fromCharCode(0),64),o=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],s=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],h=new Array(64);for(var t=0;t<64;++t)h[t]=Math.floor(4294967296*Math.abs(Math.sin(t+1)));u=!0}();var t=null,e=i.util.createBuffer(),n=new Array(16),l={algorithm:'md5',blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){l.messageLength=0,l.fullMessageLength=l.messageLength64=[];for(var r=l.messageLengthSize/4,n=0;n>>0,s>>>0];for(var h=l.fullMessageLength.length-1;h>=0;--h)l.fullMessageLength[h]+=s[1],s[1]=s[0]+(l.fullMessageLength[h]/4294967296>>>0),l.fullMessageLength[h]=l.fullMessageLength[h]>>>0,s[0]=s[1]/4294967296>>>0;return e.putBytes(a),r(t,n,e),(e.read>2048||0===e.length())&&e.compact(),l},l.digest=function(){var o=i.util.createBuffer();o.putBytes(e.bytes());var s=l.fullMessageLength[l.fullMessageLength.length-1]+l.messageLengthSize&l.blockLength-1;o.putBytes(a.substr(0,l.blockLength-s));for(var h,u=0,f=l.fullMessageLength.length-1;f>=0;--f)u=(h=8*l.fullMessageLength[f]+u)/4294967296>>>0,o.putInt32Le(h>>>0);var c={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3};r(c,n,o);var d=i.util.createBuffer();return d.putInt32Le(c.h0),d.putInt32Le(c.h1),d.putInt32Le(c.h2),d.putInt32Le(c.h3),d},l};var a=null,o=null,s=null,h=null,u=!1})),Ui=Si(((t,e)=>{var r=function(t){for(var e=t.name+': ',r=[],i=function(t,e){return' '+e},n=0;n65&&-1!==o){var s=e[o];','===s?(++o,e=e.substr(0,o)+'\r\n '+e.substr(o)):e=e.substr(0,o)+'\r\n'+s+e.substr(o+1),a=n-o-1,o=-1,++n}else' '!==e[n]&&'\t'!==e[n]&&','!==e[n]||(o=n);return e},i=function(t){return t.replace(/^\s+/,'')},n=Ci();Ii();var a=e.exports=n.pem=n.pem||{};a.encode=function(t,e){e=e||{};var i,a='-----BEGIN '+t.type+'-----\r\n';if(t.procType&&(i={name:'Proc-Type',values:[String(t.procType.version),t.procType.type]},a+=r(i)),t.contentDomain&&(i={name:'Content-Domain',values:[t.contentDomain]},a+=r(i)),t.dekInfo&&(i={name:'DEK-Info',values:[t.dekInfo.algorithm]},t.dekInfo.parameters&&i.values.push(t.dekInfo.parameters),a+=r(i)),t.headers)for(var o=0;o{var r=function(t,e){a.cipher.registerAlgorithm(t,(function(){return new a.des.Algorithm(t,e)}))},i=function(t,e,r,i){var n,a,p=32===t.length?3:9;n=3===p?i?[30,-2,-2]:[0,32,2]:i?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var m=e[0],g=e[1];m^=(a=252645135&(m>>>4^g))<<4,m^=(a=65535&(m>>>16^(g^=a)))<<16,m^=a=858993459&((g^=a)>>>2^m),m^=a=16711935&((g^=a<<2)>>>8^m),m=(m^=(a=1431655765&(m>>>1^(g^=a<<8)))<<1)<<1|m>>>31,g=(g^=a)<<1|g>>>31;for(var y=0;y>>4|g<<28)^t[w+1];a=m,m=g,g=a^(s[M>>>24&63]|u[M>>>16&63]|f[M>>>8&63]|d[63&M]|o[_>>>24&63]|h[_>>>16&63]|l[_>>>8&63]|c[63&_])}a=m,m=g,g=a}g=g>>>1|g<<31,g^=a=1431655765&((m=m>>>1|m<<31)>>>1^g),g^=(a=16711935&(g>>>8^(m^=a<<1)))<<8,g^=(a=858993459&(g>>>2^(m^=a)))<<2,g^=a=65535&((m^=a)>>>16^g),g^=a=252645135&((m^=a<<16)>>>4^g),m^=a<<4,r[0]=m,r[1]=g},n=function(t){var e,r='DES-'+((t=t||{}).mode||'CBC').toUpperCase(),i=(e=t.decrypt?a.cipher.createDecipher(r,t.key):a.cipher.createCipher(r,t.key)).start;return e.start=function(t,r){var n=null;r instanceof a.util.ByteBuffer&&(n=r,r={}),(r=r||{}).output=n,r.iv=t,i.call(e,r)},e},a=Ci();Ti(),Bi(),Ii(),e.exports=a.des=a.des||{},a.des.startEncrypting=function(t,e,r,i){var a=n({key:t,output:r,decrypt:!1,mode:i||(null===e?'ECB':'CBC')});return a.start(e),a},a.des.createEncryptionCipher=function(t,e){return n({key:t,output:null,decrypt:!1,mode:e})},a.des.startDecrypting=function(t,e,r,i){var a=n({key:t,output:r,decrypt:!0,mode:i||(null===e?'ECB':'CBC')});return a.start(e),a},a.des.createDecryptionCipher=function(t,e){return n({key:t,output:null,decrypt:!0,mode:e})},a.des.Algorithm=function(t,e){var r=this;r.name=t,r.mode=new e({blockSize:8,cipher:{encrypt:function(t,e){return i(r._keys,t,e,!1)},decrypt:function(t,e){return i(r._keys,t,e,!0)}}}),r._init=!1},a.des.Algorithm.prototype.initialize=function(t){if(!this._init){var e=a.util.createBuffer(t.key);if(0===this.name.indexOf('3DES')&&24!==e.length())throw new Error('Invalid Triple-DES key size: '+8*e.length());this._keys=function(t){for(var e,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],i=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],a=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[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],h=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],f=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],c=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],d=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],m=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=t.length()>8?3:1,y=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,w=0;w>>4^_))<<4,M^=e=65535&((_^=e)>>>-16^M),M^=(e=858993459&(M>>>2^(_^=e<<-16)))<<2,M^=e=65535&((_^=e)>>>-16^M),M^=(e=1431655765&(M>>>1^(_^=e<<-16)))<<1,M^=e=16711935&((_^=e)>>>8^M),e=(M^=(e=1431655765&(M>>>1^(_^=e<<8)))<<1)<<8|(_^=e)>>>20&240,M=_<<24|_<<8&16711680|_>>>8&65280|_>>>24&240,_=e;for(var E=0;E>>26,_=_<<2|_>>>26):(M=M<<1|M>>>27,_=_<<1|_>>>27);var S=r[(M&=-15)>>>28]|i[M>>>24&15]|n[M>>>20&15]|a[M>>>16&15]|o[M>>>12&15]|s[M>>>8&15]|h[M>>>4&15],C=u[(_&=-15)>>>28]|l[_>>>24&15]|f[_>>>20&15]|c[_>>>16&15]|d[_>>>12&15]|p[_>>>8&15]|m[_>>>4&15];e=65535&(C>>>16^S),y[b++]=S^e,y[b++]=C^e<<16}}return y}(e),this._init=!0}},r('DES-ECB',a.cipher.modes.ecb),r('DES-CBC',a.cipher.modes.cbc),r('DES-CFB',a.cipher.modes.cfb),r('DES-OFB',a.cipher.modes.ofb),r('DES-CTR',a.cipher.modes.ctr),r('3DES-ECB',a.cipher.modes.ecb),r('3DES-CBC',a.cipher.modes.cbc),r('3DES-CFB',a.cipher.modes.cfb),r('3DES-OFB',a.cipher.modes.ofb),r('3DES-CTR',a.cipher.modes.ctr);var o=[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],s=[-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],h=[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],l=[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],f=[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],c=[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],d=[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]})),Oi={};((t,e)=>{for(var r in e)yi(t,r,{get:e[r],enumerable:!0,configurable:!0,set:t=>e[r]=()=>t})})(Oi,{webcrypto:()=>pi,timingSafeEqual:()=>fi,scryptSync:()=>ci,scrypt:()=>di,randomUUID:()=>ui,getRandomValues:()=>hi,getCurves:()=>t,default:()=>mi,DEFAULT_ENCODING:()=>si});var ji,Vi,qi,Ki,Fi=(ji=()=>{t=function(){return li},e=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(t,e)=>()=>(t&&(e=t(t=0)),e),h=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),u=(t,e)=>{for(var i in e)r(t,i,{get:e[i],enumerable:!0})},l=(t,e,a,s)=>{if(e&&'object'==typeof e||'function'==typeof e)for(let h of n(e))!o.call(t,h)&&h!==a&&r(t,h,{get:()=>e[h],enumerable:!(s=i(e,h))||s.enumerable});return t},f=(t,e,r)=>(l(t,e,'default'),r&&l(r,e,'default')),c=(t,i,n)=>(n=null!=t?e(a(t)):{},l(!i&&t&&t.__esModule?n:r(n,'default',{value:t,enumerable:!0}),t)),d=t=>l(r({},'__esModule',{value:!0}),t),p=h((t=>{t.byteLength=function(t){var e=o(t),r=e[0],i=e[1];return 3*(r+i)/4-i},t.toByteArray=function(t){var e,r,a=o(t),s=a[0],h=a[1],u=new n(function(t,e,r){return 3*(e+r)/4-r}(0,s,h)),l=0,f=h>0?s-4:s;for(r=0;r>16&255,u[l++]=e>>8&255,u[l++]=255&e;return 2===h&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[l++]=255&e),1===h&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e),u},t.fromByteArray=function(t){for(var e,i=t.length,n=i%3,a=[],o=16383,s=0,u=i-n;su?u:s+o));return 1===n?(e=t[i-1],a.push(r[e>>2]+r[e<<4&63]+'==')):2===n&&(e=(t[i-2]<<8)+t[i-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+'=')),a.join('')};var e,r=[],i=[],n=typeof Uint8Array<'u'?Uint8Array:Array,a='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';for(e=0;e<64;++e)r[e]=a[e],i[a.charCodeAt(e)]=e;function o(t){var e=t.length;if(e%4>0)throw new Error('Invalid string. Length must be a multiple of 4');var r=t.indexOf('=');return-1===r&&(r=e),[r,r===e?0:4-r%4]}function s(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function h(t,e,r){for(var i,n=[],a=e;a{t.read=function(t,e,r,i,n){var a,o,s=8*n-i-1,h=(1<>1,l=-7,f=r?n-1:0,c=r?-1:1,d=t[e+f];for(f+=c,a=d&(1<<-l)-1,d>>=-l,l+=s;l>0;a=256*a+t[e+f],f+=c,l-=8);for(o=a&(1<<-l)-1,a>>=-l,l+=i;l>0;o=256*o+t[e+f],f+=c,l-=8);if(0===a)a=1-u;else{if(a===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),a-=u}return(d?-1:1)*o*Math.pow(2,a-i)},t.write=function(t,e,r,i,n,a){var o,s,h,u=8*a-n-1,l=(1<>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:a-1,p=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+f>=1?c/h:c*Math.pow(2,1-f))*h>=2&&(o++,h/=2),o+f>=l?(s=0,o=l):o+f>=1?(s=(e*h-1)*Math.pow(2,n),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,n),o=0));n>=8;t[r+d]=255&s,d+=p,s/=256,n-=8);for(o=o<0;t[r+d]=255&o,d+=p,o/=256,u-=8);t[r+d-p]|=128*m}})),g=h((t=>{var e=p(),r=m(),i='function'==typeof Symbol&&'function'==typeof Symbol.for?Symbol.for('nodejs.util.inspect.custom'):null;t.Buffer=o,t.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},t.INSPECT_MAX_BYTES=50;var n=2147483647;function a(t){if(t>n)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,r){if('number'==typeof t){if('string'==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){if('string'==typeof t)return function(t,e){if(('string'!=typeof e||''===e)&&(e='utf8'),!o.isEncoding(e))throw new TypeError('Unknown encoding: '+e);let r=0|d(t,e),i=a(r),n=i.write(t,e);return n!==r&&(i=i.slice(0,n)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(t,Uint8Array)){let e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type '+typeof t);if(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<'u'&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return f(t,e,r);if('number'==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');let i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return o.from(i,e,r);let n=function(t){if(o.isBuffer(t)){let e=0|c(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?'number'!=typeof t.length||$(t.length)?a(0):l(t):'Buffer'===t.type&&Array.isArray(t.data)?l(t.data):void 0}(t);if(n)return n;if(typeof Symbol<'u'&&null!=Symbol.toPrimitive&&'function'==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]('string'),e,r);throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type '+typeof t)}function h(t){if('number'!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return h(t),a(t<0?0:0|c(t))}function l(t){let e=t.length<0?0:0|c(t.length),r=a(e);for(let i=0;i=n)throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x'+n.toString(16)+' bytes');return 0|t}function d(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(t,ArrayBuffer))return t.byteLength;if('string'!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let n=!1;for(;;)switch(e){case'ascii':case'latin1':case'binary':return r;case'utf8':case'utf-8':return G(t).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*r;case'hex':return r>>>1;case'base64':return W(t).length;default:if(n)return i?-1:G(t).length;e=(''+e).toLowerCase(),n=!0}}function g(t,e,r){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0)||(r>>>=0)<=(e>>>=0))return'';for(t||(t='utf8');;)switch(t){case'hex':return k(this,e,r);case'utf8':case'utf-8':return A(this,e,r);case'ascii':return T(this,e,r);case'latin1':case'binary':return B(this,e,r);case'base64':return C(this,e,r);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return R(this,e,r);default:if(i)throw new TypeError('Unknown encoding: '+t);t=(t+'').toLowerCase(),i=!0}}function y(t,e,r){let i=t[e];t[e]=t[r],t[r]=i}function v(t,e,r,i,n){if(0===t.length)return-1;if('string'==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),$(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if('string'==typeof e&&(e=o.from(e,i)),o.isBuffer(e))return 0===e.length?-1:b(t,e,r,i,n);if('number'==typeof e)return e&=255,'function'==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,i,n);throw new TypeError('val must be string, number or Buffer')}function b(t,e,r,i,n){let a,o=1,s=t.length,h=e.length;if(void 0!==i&&('ucs2'===(i=String(i).toLowerCase())||'ucs-2'===i||'utf16le'===i||'utf-16le'===i)){if(t.length<2||e.length<2)return-1;o=2,s/=2,h/=2,r/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(n){let i=-1;for(a=r;as&&(r=s-h),a=r;a>=0;a--){let r=!0;for(let i=0;in&&(i=n):i=n;let a,o=e.length;for(i>o/2&&(i=o/2),a=0;a>8,n=r%256,a.push(n),a.push(i);return a}(e,t.length-r),t,r,i)}function C(t,r,i){return 0===r&&i===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,i))}function A(t,e,r){r=Math.min(t.length,r);let i=[],n=e;for(;n239?4:e>223?3:e>191?2:1;if(n+o<=r){let r,i,s,h;switch(o){case 1:e<128&&(a=e);break;case 2:r=t[n+1],128==(192&r)&&(h=(31&e)<<6|63&r,h>127&&(a=h));break;case 3:r=t[n+1],i=t[n+2],128==(192&r)&&128==(192&i)&&(h=(15&e)<<12|(63&r)<<6|63&i,h>2047&&(h<55296||h>57343)&&(a=h));break;case 4:r=t[n+1],i=t[n+2],s=t[n+3],128==(192&r)&&128==(192&i)&&128==(192&s)&&(h=(15&e)<<18|(63&r)<<12|(63&i)<<6|63&s,h>65535&&h<1114112&&(a=h))}}null===a?(a=65533,o=1):a>65535&&(a-=65536,i.push(a>>>10&1023|55296),a=56320|1023&a),i.push(a),n+=o}return function(t){let e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r='',i=0;for(;ii.length?(o.isBuffer(e)||(e=o.from(e)),e.copy(i,n)):Uint8Array.prototype.set.call(i,e,n);else{if(!o.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,n)}n+=e.length}return i},o.byteLength=d,o.prototype._isBuffer=!0,o.prototype.swap16=function(){let t=this.length;if(t%2!=0)throw new RangeError('Buffer size must be a multiple of 16-bits');for(let e=0;er&&(e+=' ... '),''},i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=function(t,e,r,i,n){if(Y(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError('out of range index');if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let a=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(e>>>=0),h=Math.min(a,s),u=this.slice(i,n),l=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i='utf8')):(i=r,r=void 0)}let n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError('Attempt to write outside buffer bounds');i||(i='utf8');let a=!1;for(;;)switch(i){case'hex':return w(this,t,e,r);case'utf8':case'utf-8':return M(this,t,e,r);case'ascii':case'latin1':case'binary':return _(this,t,e,r);case'base64':return E(this,t,e,r);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return S(this,t,e,r);default:if(a)throw new TypeError('Unknown encoding: '+i);i=(''+i).toLowerCase(),a=!0}},o.prototype.toJSON=function(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function T(t,e,r){let i='';r=Math.min(t.length,r);for(let n=e;ni)&&(r=i);let n='';for(let i=e;ir)throw new RangeError('Trying to access beyond buffer length')}function L(t,e,r,i,n,a){if(!o.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||et.length)throw new RangeError('Index out of range')}function x(t,e,r,i,n){K(e,i,n,t,r,7);let a=Number(e&BigInt(4294967295));t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,r}function D(t,e,r,i,n){K(e,i,n,t,r,7);let a=Number(e&BigInt(4294967295));t[r+7]=a,a>>=8,t[r+6]=a,a>>=8,t[r+5]=a,a>>=8,t[r+4]=a;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o>>=8,t[r+2]=o,o>>=8,t[r+1]=o,o>>=8,t[r]=o,r+8}function U(t,e,r,i,n,a){if(r+i>t.length)throw new RangeError('Index out of range');if(r<0)throw new RangeError('Index out of range')}function P(t,e,i,n,a){return e=+e,i>>>=0,a||U(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function O(t,e,i,n,a){return e=+e,i>>>=0,a||U(t,0,i,8),r.write(t,e,i,n,52,8),i+8}o.prototype.slice=function(t,e){let r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let i=this[t],n=1,a=0;for(;++a>>=0,e>>>=0,r||N(t,e,this.length);let i=this[t+--e],n=1;for(;e>0&&(n*=256);)i+=this[t+--e]*n;return i},o.prototype.readUint8=o.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readBigUInt64LE=X((function(t){F(t>>>=0,'offset');let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&H(t,this.length-8);let i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(i)+(BigInt(n)<>>=0,'offset');let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&H(t,this.length-8);let i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(i)<>>=0,e>>>=0,r||N(t,e,this.length);let i=this[t],n=1,a=0;for(;++a=n&&(i-=Math.pow(2,8*e)),i},o.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let i=e,n=1,a=this[t+--i];for(;i>0&&(n*=256);)a+=this[t+--i]*n;return n*=128,a>=n&&(a-=Math.pow(2,8*e)),a},o.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);let r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);let r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readBigInt64LE=X((function(t){F(t>>>=0,'offset');let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&H(t,this.length-8);let i=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(i)<>>=0,'offset');let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&H(t,this.length-8);let i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<>>=0,e||N(t,4,this.length),r.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),r.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),r.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),r.read(this,t,!1,52,8)},o.prototype.writeUintLE=o.prototype.writeUIntLE=function(t,e,r,i){t=+t,e>>>=0,r>>>=0,i||L(this,t,e,r,Math.pow(2,8*r)-1,0);let n=1,a=0;for(this[e]=255&t;++a>>=0,r>>>=0,i||L(this,t,e,r,Math.pow(2,8*r)-1,0);let n=r-1,a=1;for(this[e+n]=255&t;--n>=0&&(a*=256);)this[e+n]=t/a&255;return e+r},o.prototype.writeUint8=o.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigUInt64LE=X((function(t,e=0){return x(this,t,e,BigInt(0),BigInt('0xffffffffffffffff'))})),o.prototype.writeBigUInt64BE=X((function(t,e=0){return D(this,t,e,BigInt(0),BigInt('0xffffffffffffffff'))})),o.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e>>>=0,!i){let i=Math.pow(2,8*r-1);L(this,t,e,r,i-1,-i)}let n=0,a=1,o=0;for(this[e]=255&t;++n>>=0,!i){let i=Math.pow(2,8*r-1);L(this,t,e,r,i-1,-i)}let n=r-1,a=1,o=0;for(this[e+n]=255&t;--n>=0&&(a*=256);)t<0&&0===o&&0!==this[e+n+1]&&(o=1),this[e+n]=(t/a|0)-o&255;return e+r},o.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeBigInt64LE=X((function(t,e=0){return x(this,t,e,-BigInt('0x8000000000000000'),BigInt('0x7fffffffffffffff'))})),o.prototype.writeBigInt64BE=X((function(t,e=0){return D(this,t,e,-BigInt('0x8000000000000000'),BigInt('0x7fffffffffffffff'))})),o.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},o.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},o.prototype.writeDoubleLE=function(t,e,r){return O(this,t,e,!0,r)},o.prototype.writeDoubleBE=function(t,e,r){return O(this,t,e,!1,r)},o.prototype.copy=function(t,e,r,i){if(!o.isBuffer(t))throw new TypeError('argument should be a Buffer');if(r||(r=0),!i&&0!==i&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError('Index out of range');if(i<0)throw new RangeError('sourceEnd out of bounds');i>this.length&&(i=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),'number'==typeof t)for(n=e;n=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,i,n,a){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(a+1)}${n}`:`>= -(2${n} ** ${8*(a+1)-1}${n}) and < 2 ** ${8*(a+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new j.ERR_OUT_OF_RANGE('value',i,t)}!function(t,e,r){F(e,'offset'),(void 0===t[e]||void 0===t[e+r])&&H(e,t.length-(r+1))}(i,n,a)}function F(t,e){if('number'!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,'number',t)}function H(t,e,r){throw Math.floor(t)!==t?(F(t,r),new j.ERR_OUT_OF_RANGE(r||'offset','an integer',t)):e<0?new j.ERR_BUFFER_OUT_OF_BOUNDS:new j.ERR_OUT_OF_RANGE(r||'offset',`>= ${r?1:0} and <= ${e}`,t)}V('ERR_BUFFER_OUT_OF_BOUNDS',(function(t){return t?`${t} is outside of buffer bounds`:'Attempt to access memory outside buffer bounds'}),RangeError),V('ERR_INVALID_ARG_TYPE',(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),V('ERR_OUT_OF_RANGE',(function(t,e,r){let i=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=q(String(r)):'bigint'==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=q(n)),n+='n'),i+=` It must be ${e}. Received ${n}`,i}),RangeError);var z=/[^+/0-9A-Za-z-_]/g;function G(t,e){e=e||1/0;let r,i=t.length,n=null,a=[];for(let o=0;o55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&a.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&a.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&a.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;a.push(r)}else if(r<2048){if((e-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error('Invalid code point');if((e-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function W(t){return e.toByteArray(function(t){if((t=(t=t.split('=')[0]).trim().replace(z,'')).length<2)return'';for(;t.length%4!=0;)t+='=';return t}(t))}function Z(t,e,r,i){let n;for(n=0;n=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function $(t){return t!=t}var Q=function(){let t='0123456789abcdef',e=new Array(256);for(let r=0;r<16;++r){let i=16*r;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function X(t){return typeof BigInt>'u'?J:t}function J(){throw new Error('BigInt not supported')}})),y=h(((t,e)=>{var r=g(),i=r.Buffer;function n(t,e){for(var r in t)e[r]=t[r]}function a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(n(r,t),t.Buffer=a),a.prototype=Object.create(i.prototype),n(i,a),a.from=function(t,e,r){if('number'==typeof t)throw new TypeError('Argument must not be a number');return i(t,e,r)},a.alloc=function(t,e,r){if('number'!=typeof t)throw new TypeError('Argument must be a number');var n=i(t);return void 0!==e?'string'==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},a.allocUnsafe=function(t){if('number'!=typeof t)throw new TypeError('Argument must be a number');return i(t)},a.allocUnsafeSlow=function(t){if('number'!=typeof t)throw new TypeError('Argument must be a number');return r.SlowBuffer(t)}})),v=h(((t,e)=>{var r=65536,i=y().Buffer,n=global.crypto||global.msCrypto;n&&n.getRandomValues?e.exports=function(t,e){if(t>4294967295)throw new RangeError('requested too many random bytes');var a=i.allocUnsafe(t);if(t>0)if(t>r)for(var o=0;o{'function'==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),w=h(((t,e)=>{var r,i='object'==typeof Reflect?Reflect:null,n=i&&'function'==typeof i.apply?i.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};r=i&&'function'==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var a=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(t,e){return new Promise((function(r,i){function n(r){t.removeListener(e,a),i(r)}function a(){'function'==typeof t.removeListener&&t.removeListener('error',n),r([].slice.call(arguments))}g(t,e,a,{once:!0}),'error'!==e&&function(t,e,r){'function'==typeof t.on&&g(t,'error',e,r)}(t,n,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function h(t){if('function'!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function l(t,e,r,i){var n,a,o;if(h(r),void 0===(a=t._events)?(a=t._events=Object.create(null),t._eventsCount=0):(void 0!==a.newListener&&(t.emit('newListener',e,r.listener?r.listener:r),a=t._events),o=a[e]),void 0===o)o=a[e]=r,++t._eventsCount;else if('function'==typeof o?o=a[e]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=u(t))>0&&o.length>n&&!o.warned){o.warned=!0;var s=new Error('Possible EventEmitter memory leak detected. '+o.length+' '+String(e)+' listeners added. Use emitter.setMaxListeners() to increase limit');s.name='MaxListenersExceededWarning',s.emitter=t,s.type=e,s.count=o.length,function(t){console&&console.warn&&console.warn(t)}(s)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=f.bind(i);return n.listener=r,i.wrapFn=n,n}function d(t,e,r){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:'function'==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(o=e[0]),o instanceof Error)throw o;var s=new Error('Unhandled error.'+(o?' ('+o.message+')':''));throw s.context=o,s}var h=a[t];if(void 0===h)return!1;if('function'==typeof h)n(h,this,e);else{var u=h.length,l=m(h,u);for(r=0;r=0;a--)if(r[a]===e||r[a].listener===e){o=r[a].listener,n=a;break}if(n<0)return this;0===n?r.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return'function'==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}})),M=h(((t,e)=>{e.exports=w().EventEmitter})),_=h((()=>{})),E=h(((t,e)=>{function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:'unshift',value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:'shift',value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:'clear',value:function(){this.head=this.tail=null,this.length=0}},{key:'join',value:function(t){if(0===this.length)return'';for(var e=this.head,r=''+e.data;e=e.next;)r+=t+e.data;return r}},{key:'concat',value:function(t){if(0===this.length)return a.alloc(0);for(var e=a.allocUnsafe(t>>>0),r=this.head,i=0;r;)h(r.data,e,i),i+=r.data.length,r=r.next;return e}},{key:'consume',value:function(t,e){var r;return tn.length?n.length:t;if(a===n.length?i+=n:i+=n.slice(0,t),0==(t-=a)){a===n.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(a));break}++r}return this.length-=r,i}},{key:'_getBuffer',value:function(t){var e=a.allocUnsafe(t),r=this.head,i=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var n=r.data,o=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,o),0==(t-=o)){o===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(o));break}++i}return this.length-=i,e}},{key:s,value:function(t,e){return o(this,function(t){for(var e=1;e{function r(t,e){n(t,e),i(t)}function i(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit('close')}function n(t,e){t.emit('error',e)}e.exports={destroy:function(t,e){var a=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?a._writableState?a._writableState.errorEmitted?process.nextTick(i,a):(a._writableState.errorEmitted=!0,process.nextTick(r,a,t)):process.nextTick(r,a,t):e?(process.nextTick(i,a),e(t)):process.nextTick(i,a)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var{_readableState:r,_writableState:i}=t;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit('error',e)}}})),C=h(((t,e)=>{var r={};function i(t,e,i){i||(i=Error);var n=function(t){function r(r,i,n){return t.call(this,function(t,r,i){return'string'==typeof e?e:e(t,r,i)}(r,i,n))||this}return function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(r,t),r}(i);n.prototype.name=i.name,n.prototype.code=t,r[t]=n}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?'one of '.concat(e,' ').concat(t.slice(0,r-1).join(', '),', or ')+t[r-1]:2===r?'one of '.concat(e,' ').concat(t[0],' or ').concat(t[1]):'of '.concat(e,' ').concat(t[0])}return'of '.concat(e,' ').concat(String(t))}i('ERR_INVALID_OPT_VALUE',(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),i('ERR_INVALID_ARG_TYPE',(function(t,e,r){var i,a;if('string'==typeof e&&function(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}(e,'not ')?(i='must not be',e=e.replace(/^not /,'')):i='must be',function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t,' argument'))a='The '.concat(t,' ').concat(i,' ').concat(n(e,'type'));else{var o=function(t,e,r){return'number'!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,'.')?'property':'argument';a='The "'.concat(t,'" ').concat(o,' ').concat(i,' ').concat(n(e,'type'))}return a+='. Received type '.concat(typeof r)}),TypeError),i('ERR_STREAM_PUSH_AFTER_EOF','stream.push() after EOF'),i('ERR_METHOD_NOT_IMPLEMENTED',(function(t){return'The '+t+' method is not implemented'})),i('ERR_STREAM_PREMATURE_CLOSE','Premature close'),i('ERR_STREAM_DESTROYED',(function(t){return'Cannot call '+t+' after a stream was destroyed'})),i('ERR_MULTIPLE_CALLBACK','Callback called multiple times'),i('ERR_STREAM_CANNOT_PIPE','Cannot pipe, not readable'),i('ERR_STREAM_WRITE_AFTER_END','write after end'),i('ERR_STREAM_NULL_VALUES','May not write null values to stream',TypeError),i('ERR_UNKNOWN_ENCODING',(function(t){return'Unknown encoding: '+t}),TypeError),i('ERR_STREAM_UNSHIFT_AFTER_END_EVENT','stream.unshift() after end event'),e.exports.codes=r})),A=h(((t,e)=>{var r=C().codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,i,n){var a=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,n,i);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(n?i:'highWaterMark',a);return Math.floor(a)}return t.objectMode?16:16384}}})),I=h(((t,e)=>{function r(t){try{if(!global.localStorage)return!1}catch{return!1}var e=global.localStorage[t];return null!=e&&'true'===String(e).toLowerCase()}e.exports=function(t,e){if(r('noDeprecation'))return t;var i=!1;return function(){if(!i){if(r('throwDeprecation'))throw new Error(e);r('traceDeprecation')?console.trace(e):console.warn(e),i=!0}return t.apply(this,arguments)}}})),T=h(((t,e)=>{function r(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}var i;e.exports=R,R.WritableState=k;var n,a={deprecate:I()},o=M(),s=g().Buffer,h=global.Uint8Array||function(){},u=S(),l=A().getHighWaterMark,f=C().codes,c=f.ERR_INVALID_ARG_TYPE,d=f.ERR_METHOD_NOT_IMPLEMENTED,p=f.ERR_MULTIPLE_CALLBACK,m=f.ERR_STREAM_CANNOT_PIPE,y=f.ERR_STREAM_DESTROYED,v=f.ERR_STREAM_NULL_VALUES,w=f.ERR_STREAM_WRITE_AFTER_END,_=f.ERR_UNKNOWN_ENCODING,E=u.errorOrDestroy;function T(){}function k(t,e,n){i=i||B(),t=t||{},'boolean'!=typeof n&&(n=e instanceof i),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=l(this,t,'writableHighWaterMark',n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||'utf8',this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if('function'!=typeof n)throw new p;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,n){--e.pendingcb,r?(process.nextTick(n,i),process.nextTick(P,t,e),t._writableState.errorEmitted=!0,E(t,i)):(n(i),t._writableState.errorEmitted=!0,E(t,i),P(t,e))}(t,r,i,e,n);else{var a=D(r)||t.destroyed;!a&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&x(t,r),i?process.nextTick(L,t,r,a,n):L(t,r,a,n)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}function R(t){var e=this instanceof(i=i||B());if(!e&&!n.call(R,this))return new R(t);this._writableState=new k(t,this,e),this.writable=!0,t&&('function'==typeof t.write&&(this._write=t.write),'function'==typeof t.writev&&(this._writev=t.writev),'function'==typeof t.destroy&&(this._destroy=t.destroy),'function'==typeof t.final&&(this._final=t.final)),o.call(this)}function N(t,e,r,i,n,a,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new y('write')):r?t._writev(n,e.onwrite):t._write(n,a,e.onwrite),e.sync=!1}function L(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit('drain'))}(t,e),e.pendingcb--,i(),P(t,e)}function x(t,e){e.bufferProcessing=!0;var i=e.bufferedRequest;if(t._writev&&i&&i.next){var n=e.bufferedRequestCount,a=new Array(n),o=e.corkedRequestsFree;o.entry=i;for(var s=0,h=!0;i;)a[s]=i,i.isBuf||(h=!1),i=i.next,s+=1;a.allBuffers=h,N(t,e,!0,e.length,a,'',o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new r(e),e.bufferedRequestCount=0}else{for(;i;){var{chunk:u,encoding:l,callback:f}=i;if(N(t,e,!1,e.objectMode?1:u.length,u,l,f),i=i.next,e.bufferedRequestCount--,e.writing)break}null===i&&(e.lastBufferedRequest=null)}e.bufferedRequest=i,e.bufferProcessing=!1}function D(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function U(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit('prefinish'),P(t,e)}))}function P(t,e){var r=D(e);if(r&&(function(t,e){!e.prefinished&&!e.finalCalled&&('function'!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit('prefinish')):(e.pendingcb++,e.finalCalled=!0,process.nextTick(U,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit('finish'),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return r}b()(R,o),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,'buffer',{get:a.deprecate((function(){return this.getBuffer()}),'_writableState.buffer is deprecated. Use _writableState.getBuffer instead.','DEP0003')})}catch{}}(),'function'==typeof Symbol&&Symbol.hasInstance&&'function'==typeof Function.prototype[Symbol.hasInstance]?(n=Function.prototype[Symbol.hasInstance],Object.defineProperty(R,Symbol.hasInstance,{value:function(t){return!!n.call(this,t)||this===R&&t&&t._writableState instanceof k}})):n=function(t){return t instanceof this},R.prototype.pipe=function(){E(this,new m)},R.prototype.write=function(t,e,r){var i=this._writableState,n=!1,a=!i.objectMode&&function(t){return s.isBuffer(t)||t instanceof h}(t);return a&&!s.isBuffer(t)&&(t=function(t){return s.from(t)}(t)),'function'==typeof e&&(r=e,e=null),a?e='buffer':e||(e=i.defaultEncoding),'function'!=typeof r&&(r=T),i.ending?function(t,e){var r=new w;E(t,r),process.nextTick(e,r)}(this,r):(a||function(t,e,r,i){var n;return null===r?n=new v:'string'!=typeof r&&!e.objectMode&&(n=new c('chunk',['string','Buffer'],r)),!n||(E(t,n),process.nextTick(i,n),!1)}(this,i,t,r))&&(i.pendingcb++,n=function(t,e,r,i,n,a){if(!r){var o=function(t,e,r){return!t.objectMode&&!1!==t.decodeStrings&&'string'==typeof e&&(e=s.from(e,r)),e}(e,i,n);i!==o&&(r=!0,n='buffer',i=o)}var h=e.objectMode?1:i.length;e.length+=h;var u=e.length-1))throw new _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(R.prototype,'writableBuffer',{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(R.prototype,'writableHighWaterMark',{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),R.prototype._write=function(t,e,r){r(new d('_write()'))},R.prototype._writev=null,R.prototype.end=function(t,e,r){var i=this._writableState;return'function'==typeof t?(r=t,t=null,e=null):'function'==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,P(t,e),r&&(e.finished?process.nextTick(r):t.once('finish',r)),e.ended=!0,t.writable=!1}(this,i,r),this},Object.defineProperty(R.prototype,'writableLength',{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(R.prototype,'destroyed',{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){!this._writableState||(this._writableState.destroyed=t)}}),R.prototype.destroy=u.destroy,R.prototype._undestroy=u.undestroy,R.prototype._destroy=function(t,e){e(t)}})),B=h(((t,e)=>{var r=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var i,n,a,o=P(),s=T();for(b()(h,o),i=r(s.prototype),a=0;a{var e=y().Buffer,r=e.isEncoding||function(t){switch((t=''+t)&&t.toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':case'raw':return!0;default:return!1}};function i(t){var i;switch(this.encoding=function(t){var i=function(t){if(!t)return'utf8';for(var e;;)switch(t){case'utf8':case'utf-8':return'utf8';case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return'utf16le';case'latin1':case'binary':return'latin1';case'base64':case'ascii':case'hex':return t;default:if(e)return;t=(''+t).toLowerCase(),e=!0}}(t);if('string'!=typeof i&&(e.isEncoding===r||!r(t)))throw new Error('Unknown encoding: '+t);return i||t}(t),this.encoding){case'utf16le':this.text=o,this.end=s,i=4;break;case'utf8':this.fillLast=a,i=4;break;case'base64':this.text=h,this.end=u,i=3;break;default:return this.write=l,void(this.end=f)}this.lastNeed=0,this.lastTotal=0,this.lastChar=e.allocUnsafe(i)}function n(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,'�';if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,'�';if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,'�'}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function o(t,e){if((t.length-e)%2==0){var r=t.toString('utf16le',e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString('utf16le',e,t.length-1)}function s(t){var e=t&&t.length?this.write(t):'';if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString('utf16le',0,r)}return e}function h(t,e){var r=(t.length-e)%3;return 0===r?t.toString('base64',e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString('base64',e,t.length-r))}function u(t){var e=t&&t.length?this.write(t):'';return this.lastNeed?e+this.lastChar.toString('base64',0,3-this.lastNeed):e}function l(t){return t.toString(this.encoding)}function f(t){return t&&t.length?this.write(t):''}t.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return'';var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return'';r=this.lastNeed,this.lastNeed=0}else r=0;return r=0?(a>0&&(t.lastNeed=a-1),a):--i=0?(a>0&&(t.lastNeed=a-2),a):--i=0?(a>0&&(2===a?a=0:t.lastNeed=a-3),a):0}(this,t,e);if(!this.lastNeed)return t.toString('utf8',e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString('utf8',e,i)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}})),u(R={},{StringDecoder:()=>N.StringDecoder,default:()=>N.StringDecoder}),L=s((()=>{N=c(k())})),x=h(((t,e)=>{var r=C().codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function t(e,n,a){if('function'==typeof n)return t(e,null,n);n||(n={}),a=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,i=new Array(r),n=0;n{var r;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var n=x(),a=Symbol('lastResolve'),o=Symbol('lastReject'),s=Symbol('error'),h=Symbol('ended'),u=Symbol('lastPromise'),l=Symbol('handlePromise'),f=Symbol('stream');function c(t,e){return{value:t,done:e}}function d(t){var e=t[a];if(null!==e){var r=t[f].read();null!==r&&(t[u]=null,t[a]=null,t[o]=null,e(c(r,!1)))}}function p(t){process.nextTick(d,t)}var m=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((r={get stream(){return this[f]},next:function(){var t=this,e=this[s];if(null!==e)return Promise.reject(e);if(this[h])return Promise.resolve(c(void 0,!0));if(this[f].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[s]?r(t[s]):e(c(void 0,!0))}))}));var r,i=this[u];if(i)r=new Promise(function(t,e){return function(r,i){t.then((function(){e[h]?r(c(void 0,!0)):e[l](r,i)}),i)}}(i,this));else{var n=this[f].read();if(null!==n)return Promise.resolve(c(n,!1));r=new Promise(this[l])}return this[u]=r,r}},i(r,Symbol.asyncIterator,(function(){return this})),i(r,'return',(function(){var t=this;return new Promise((function(e,r){t[f].destroy(null,(function(t){t?r(t):e(c(void 0,!0))}))}))})),r),m);e.exports=function(t){var e,r=Object.create(g,(i(e={},f,{value:t,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,o,{value:null,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,h,{value:t._readableState.endEmitted,writable:!0}),i(e,l,{value:function(t,e){var i=r[f].read();i?(r[u]=null,r[a]=null,r[o]=null,t(c(i,!1))):(r[a]=t,r[o]=e)},writable:!0}),e));return r[u]=null,n(t,(function(t){if(t&&'ERR_STREAM_PREMATURE_CLOSE'!==t.code){var e=r[o];return null!==e&&(r[u]=null,r[a]=null,r[o]=null,e(t)),void(r[s]=t)}var i=r[a];null!==i&&(r[u]=null,r[a]=null,r[o]=null,i(c(void 0,!0))),r[h]=!0})),t.on('readable',p.bind(null,r)),r}})),U=h(((t,e)=>{e.exports=function(){throw new Error('Readable.from is not available in the browser')}})),P=h(((t,e)=>{var r;e.exports=O,O.ReadableState=P,w().EventEmitter;var i,n=function(t,e){return t.listeners(e).length},a=M(),o=g().Buffer,s=global.Uint8Array||function(){},h=_();i=h&&h.debuglog?h.debuglog('stream'):function(){};var u,l,f,c=E(),p=S(),m=A().getHighWaterMark,y=C().codes,v=y.ERR_INVALID_ARG_TYPE,I=y.ERR_STREAM_PUSH_AFTER_EOF,T=y.ERR_METHOD_NOT_IMPLEMENTED,k=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;b()(O,a);var N=p.errorOrDestroy,x=['error','close','destroy','pause','resume'];function P(t,e,i){r=r||B(),t=t||{},'boolean'!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=m(this,t,'readableHighWaterMark',i),this.buffer=new c,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||'utf8',this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(u||(u=(L(),d(R)).StringDecoder),this.decoder=new u(t.encoding),this.encoding=t.encoding)}function O(t){if(r=r||B(),!(this instanceof O))return new O(t);var e=this instanceof r;this._readableState=new P(t,this,e),this.readable=!0,t&&('function'==typeof t.read&&(this._read=t.read),'function'==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function j(t,e,r,n,a){i('readableAddChunk',e);var h,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(i('onEofChunk'),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?F(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,H(t)))}}(t,u);else if(a||(h=function(t,e){var r;return!function(t){return o.isBuffer(t)||t instanceof s}(e)&&'string'!=typeof e&&void 0!==e&&!t.objectMode&&(r=new v('chunk',['string','Buffer','Uint8Array'],e)),r}(u,e)),h)N(t,h);else if(u.objectMode||e&&e.length>0)if('string'!=typeof e&&!u.objectMode&&Object.getPrototypeOf(e)!==o.prototype&&(e=function(t){return o.from(t)}(e)),n)u.endEmitted?N(t,new k):V(t,u,e,!0);else if(u.ended)N(t,new I);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!r?(e=u.decoder.write(e),u.objectMode||0!==e.length?V(t,u,e,!1):z(t,u)):V(t,u,e,!1)}else n||(u.reading=!1,z(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=q?t=q:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function F(t){var e=t._readableState;i('emitReadable',e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(i('emitReadable',e.flowing),e.emittedReadable=!0,process.nextTick(H,t))}function H(t){var e=t._readableState;i('emitReadable_',e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit('readable'),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,$(t)}function z(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(G,t,e))}function G(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount('data')>0&&t.resume()}function Z(t){i('readable nexttick read 0'),t.read(0)}function Y(t,e){i('resume',e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit('resume'),$(t),e.flowing&&!e.reading&&t.read(0)}function $(t){var e=t._readableState;for(i('flow',e.flowing);e.flowing&&null!==t.read(););}function Q(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(''):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function X(t){var e=t._readableState;i('endReadable',e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(J,e,t))}function J(t,e){if(i('endReadableNT',t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit('end'),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function tt(t,e){for(var r=0,i=t.length;r=e.highWaterMark:e.length>0)||e.ended))return i('read: emitReadable',e.length,e.ended),0===e.length&&e.ended?X(this):F(this),null;if(0===(t=K(t,e))&&e.ended)return 0===e.length&&X(this),null;var n,a=e.needReadable;return i('need readable',a),(0===e.length||e.length-t0?Q(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&X(this)),null!==n&&this.emit('data',n),n},O.prototype._read=function(t){N(this,new T('_read()'))},O.prototype.pipe=function(t,e){var r=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,i('pipe count=%d opts=%j',a.pipesCount,e);var o=e&&!1===e.end||t===process.stdout||t===process.stderr?m:h;function s(e,n){i('onunpipe'),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,i('cleanup'),t.removeListener('close',d),t.removeListener('finish',p),t.removeListener('drain',u),t.removeListener('error',c),t.removeListener('unpipe',s),r.removeListener('end',h),r.removeListener('end',m),r.removeListener('data',f),l=!0,a.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&u())}function h(){i('onend'),t.end()}a.endEmitted?process.nextTick(o):r.once('end',o),t.on('unpipe',s);var u=function(t){return function(){var e=t._readableState;i('pipeOnDrain',e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&n(t,'data')&&(e.flowing=!0,$(t))}}(r);t.on('drain',u);var l=!1;function f(e){i('ondata');var n=t.write(e);i('dest.write',n),!1===n&&((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==tt(a.pipes,t))&&!l&&(i('false write response, pause',a.awaitDrain),a.awaitDrain++),r.pause())}function c(e){i('onerror',e),m(),t.removeListener('error',c),0===n(t,'error')&&N(t,e)}function d(){t.removeListener('finish',p),m()}function p(){i('onfinish'),t.removeListener('close',d),m()}function m(){i('unpipe'),r.unpipe(t)}return r.on('data',f),function(t,e,r){if('function'==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,'error',c),t.once('close',d),t.once('finish',p),t.emit('pipe',r),a.flowing||(i('pipe resume'),r.resume()),t},O.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit('unpipe',this,r)),this;if(!t){var{pipes:i,pipesCount:n}=e;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a0,!1!==n.flowing&&this.resume()):'readable'===t&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,i('on readable',n.length,n.reading),n.length?F(this):n.reading||process.nextTick(Z,this)),r},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(t,e){var r=a.prototype.removeListener.call(this,t,e);return'readable'===t&&process.nextTick(W,this),r},O.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return('readable'===t||void 0===t)&&process.nextTick(W,this),e},O.prototype.resume=function(){var t=this._readableState;return t.flowing||(i('resume'),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(Y,t,e))}(this,t)),t.paused=!1,this},O.prototype.pause=function(){return i('call pause flowing=%j',this._readableState.flowing),!1!==this._readableState.flowing&&(i('pause'),this._readableState.flowing=!1,this.emit('pause')),this._readableState.paused=!0,this},O.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var a in t.on('end',(function(){if(i('wrapped end'),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on('data',(function(a){i('wrapped data'),r.decoder&&(a=r.decoder.write(a)),r.objectMode&&null==a||!(r.objectMode||a&&a.length)||e.push(a)||(n=!0,t.pause())})),t)void 0===this[a]&&'function'==typeof t[a]&&(this[a]=function(e){return function(){return t[e].apply(t,arguments)}}(a));for(var o=0;o{e.exports=u;var r=C().codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,n=r.ERR_MULTIPLE_CALLBACK,a=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,o=r.ERR_TRANSFORM_WITH_LENGTH_0,s=B();function h(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit('error',new n);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var a=this._readableState;a.reading=!1,(a.needReadable||a.length{e.exports=i;var r=O();function i(t){if(!(this instanceof i))return new i(t);r.call(this,t)}b()(i,r),i.prototype._transform=function(t,e,r){r(null,t)}})),V=h(((t,e)=>{var r,i=C().codes,n=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function o(t){if(t)throw t}function s(t){t()}function h(t,e){return t.pipe(e)}e.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){l||(l=t),t&&f.forEach(s),!n&&(f.forEach(s),u(l))}))}));return e.reduce(h)}})),q=h(((t,e)=>{(t=e.exports=P()).Stream=t,t.Readable=t,t.Writable=T(),t.Duplex=B(),t.Transform=O(),t.PassThrough=j(),t.finished=x(),t.pipeline=V()})),K=h(((t,e)=>{var r=y().Buffer,i=q().Transform;function n(t){i.call(this),this._block=r.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}b()(n,i),n.prototype._transform=function(t,e,r){var i=null;try{this.update(t,e)}catch(t){i=t}r(i)},n.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},n.prototype.update=function(t,e){if(function(t,e){if(!r.isBuffer(t)&&'string'!=typeof t)throw new TypeError(e+' must be a string or a buffer')}(t,'Data'),this._finalized)throw new Error('Digest already called');r.isBuffer(t)||(t=r.from(t,e));for(var i=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var a=this._blockOffset;a0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},n.prototype._update=function(){throw new Error('_update is not implemented')},n.prototype.digest=function(t){if(this._finalized)throw new Error('Digest already called');this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},n.prototype._digest=function(){throw new Error('_digest is not implemented')},e.exports=n})),F=h(((t,e)=>{var r=b(),i=K(),n=y().Buffer,a=new Array(16);function o(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function s(t,e){return t<>>32-e}function h(t,e,r,i,n,a,o){return s(t+(e&r|~e&i)+n+a|0,o)+e|0}function u(t,e,r,i,n,a,o){return s(t+(e&i|r&~i)+n+a|0,o)+e|0}function l(t,e,r,i,n,a,o){return s(t+(e^r^i)+n+a|0,o)+e|0}function f(t,e,r,i,n,a,o){return s(t+(r^(e|~i))+n+a|0,o)+e|0}r(o,i),o.prototype._update=function(){for(var t=a,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,i=this._b,n=this._c,o=this._d;r=h(r,i,n,o,t[0],3614090360,7),o=h(o,r,i,n,t[1],3905402710,12),n=h(n,o,r,i,t[2],606105819,17),i=h(i,n,o,r,t[3],3250441966,22),r=h(r,i,n,o,t[4],4118548399,7),o=h(o,r,i,n,t[5],1200080426,12),n=h(n,o,r,i,t[6],2821735955,17),i=h(i,n,o,r,t[7],4249261313,22),r=h(r,i,n,o,t[8],1770035416,7),o=h(o,r,i,n,t[9],2336552879,12),n=h(n,o,r,i,t[10],4294925233,17),i=h(i,n,o,r,t[11],2304563134,22),r=h(r,i,n,o,t[12],1804603682,7),o=h(o,r,i,n,t[13],4254626195,12),n=h(n,o,r,i,t[14],2792965006,17),r=u(r,i=h(i,n,o,r,t[15],1236535329,22),n,o,t[1],4129170786,5),o=u(o,r,i,n,t[6],3225465664,9),n=u(n,o,r,i,t[11],643717713,14),i=u(i,n,o,r,t[0],3921069994,20),r=u(r,i,n,o,t[5],3593408605,5),o=u(o,r,i,n,t[10],38016083,9),n=u(n,o,r,i,t[15],3634488961,14),i=u(i,n,o,r,t[4],3889429448,20),r=u(r,i,n,o,t[9],568446438,5),o=u(o,r,i,n,t[14],3275163606,9),n=u(n,o,r,i,t[3],4107603335,14),i=u(i,n,o,r,t[8],1163531501,20),r=u(r,i,n,o,t[13],2850285829,5),o=u(o,r,i,n,t[2],4243563512,9),n=u(n,o,r,i,t[7],1735328473,14),r=l(r,i=u(i,n,o,r,t[12],2368359562,20),n,o,t[5],4294588738,4),o=l(o,r,i,n,t[8],2272392833,11),n=l(n,o,r,i,t[11],1839030562,16),i=l(i,n,o,r,t[14],4259657740,23),r=l(r,i,n,o,t[1],2763975236,4),o=l(o,r,i,n,t[4],1272893353,11),n=l(n,o,r,i,t[7],4139469664,16),i=l(i,n,o,r,t[10],3200236656,23),r=l(r,i,n,o,t[13],681279174,4),o=l(o,r,i,n,t[0],3936430074,11),n=l(n,o,r,i,t[3],3572445317,16),i=l(i,n,o,r,t[6],76029189,23),r=l(r,i,n,o,t[9],3654602809,4),o=l(o,r,i,n,t[12],3873151461,11),n=l(n,o,r,i,t[15],530742520,16),r=f(r,i=l(i,n,o,r,t[2],3299628645,23),n,o,t[0],4096336452,6),o=f(o,r,i,n,t[7],1126891415,10),n=f(n,o,r,i,t[14],2878612391,15),i=f(i,n,o,r,t[5],4237533241,21),r=f(r,i,n,o,t[12],1700485571,6),o=f(o,r,i,n,t[3],2399980690,10),n=f(n,o,r,i,t[10],4293915773,15),i=f(i,n,o,r,t[1],2240044497,21),r=f(r,i,n,o,t[8],1873313359,6),o=f(o,r,i,n,t[15],4264355552,10),n=f(n,o,r,i,t[6],2734768916,15),i=f(i,n,o,r,t[13],1309151649,21),r=f(r,i,n,o,t[4],4149444226,6),o=f(o,r,i,n,t[11],3174756917,10),n=f(n,o,r,i,t[2],718787259,15),i=f(i,n,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+n|0,this._d=this._d+o|0},o.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=o})),H=h(((t,e)=>{var r=g().Buffer,i=b(),n=K(),a=new Array(16),o=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],s=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],h=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],u=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],f=[1352829926,1548603684,1836072691,2053994217,0];function c(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,i,n,a,o,s){return d(t+(e^r^i)+a+o|0,s)+n|0}function m(t,e,r,i,n,a,o,s){return d(t+(e&r|~e&i)+a+o|0,s)+n|0}function y(t,e,r,i,n,a,o,s){return d(t+((e|~r)^i)+a+o|0,s)+n|0}function v(t,e,r,i,n,a,o,s){return d(t+(e&i|r&~i)+a+o|0,s)+n|0}function w(t,e,r,i,n,a,o,s){return d(t+(e^(r|~i))+a+o|0,s)+n|0}i(c,n),c.prototype._update=function(){for(var t=a,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,i=0|this._b,n=0|this._c,c=0|this._d,g=0|this._e,b=0|this._a,M=0|this._b,_=0|this._c,E=0|this._d,S=0|this._e,C=0;C<80;C+=1){var A,I;C<16?(A=p(r,i,n,c,g,t[o[C]],l[0],h[C]),I=w(b,M,_,E,S,t[s[C]],f[0],u[C])):C<32?(A=m(r,i,n,c,g,t[o[C]],l[1],h[C]),I=v(b,M,_,E,S,t[s[C]],f[1],u[C])):C<48?(A=y(r,i,n,c,g,t[o[C]],l[2],h[C]),I=y(b,M,_,E,S,t[s[C]],f[2],u[C])):C<64?(A=v(r,i,n,c,g,t[o[C]],l[3],h[C]),I=m(b,M,_,E,S,t[s[C]],f[3],u[C])):(A=w(r,i,n,c,g,t[o[C]],l[4],h[C]),I=p(b,M,_,E,S,t[s[C]],f[4],u[C])),r=g,g=c,c=d(n,10),n=i,i=A,b=S,S=E,E=d(_,10),_=M,M=I}var T=this._b+n+E|0;this._b=this._c+c+S|0,this._c=this._d+g+b|0,this._d=this._e+r+M|0,this._e=this._a+i+_|0,this._a=T},c.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=r.alloc?r.alloc(20):new r(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=c})),z=h(((t,e)=>{var r=y().Buffer;function i(t,e){this._block=r.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){'string'==typeof t&&(e=e||'utf8',t=r.from(t,e));for(var i=this._block,n=this._blockSize,a=t.length,o=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(4294967295&r)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var a=this._hash();return t?a.toString(t):a},i.prototype._update=function(){throw new Error('_update must be implemented by subclass')},e.exports=i})),G=h(((t,e)=>{var r=b(),i=z(),n=y().Buffer,a=[1518500249,1859775393,-1894007588,-899497514],o=new Array(80);function s(){this.init(),this._w=o,i.call(this,64,56)}function h(t){return t<<5|t>>>27}function u(t){return t<<30|t>>>2}function l(t,e,r,i){return 0===t?e&r|~e&i:2===t?e&r|e&i|r&i:e^r^i}r(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(t){for(var e=this._w,r=0|this._a,i=0|this._b,n=0|this._c,o=0|this._d,s=0|this._e,f=0;f<16;++f)e[f]=t.readInt32BE(4*f);for(;f<80;++f)e[f]=e[f-3]^e[f-8]^e[f-14]^e[f-16];for(var c=0;c<80;++c){var d=~~(c/20),p=h(r)+l(d,i,n,o)+s+e[c]+a[d]|0;s=o,o=n,n=u(i),i=r,r=p}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0},s.prototype._hash=function(){var t=n.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=s})),W=h(((t,e)=>{var r=b(),i=z(),n=y().Buffer,a=[1518500249,1859775393,-1894007588,-899497514],o=new Array(80);function s(){this.init(),this._w=o,i.call(this,64,56)}function h(t){return t<<1|t>>>31}function u(t){return t<<5|t>>>27}function l(t){return t<<30|t>>>2}function f(t,e,r,i){return 0===t?e&r|~e&i:2===t?e&r|e&i|r&i:e^r^i}r(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(t){for(var e=this._w,r=0|this._a,i=0|this._b,n=0|this._c,o=0|this._d,s=0|this._e,c=0;c<16;++c)e[c]=t.readInt32BE(4*c);for(;c<80;++c)e[c]=h(e[c-3]^e[c-8]^e[c-14]^e[c-16]);for(var d=0;d<80;++d){var p=~~(d/20),m=u(r)+f(p,i,n,o)+s+e[d]+a[p]|0;s=o,o=n,n=l(i),i=r,r=m}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0},s.prototype._hash=function(){var t=n.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=s})),Z=h(((t,e)=>{var r=b(),i=z(),n=y().Buffer,a=[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],o=new Array(64);function s(){this.init(),this._w=o,i.call(this,64,56)}function h(t,e,r){return r^t&(e^r)}function u(t,e,r){return t&e|r&(t|e)}function l(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function f(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function c(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function d(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}r(s,i),s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},s.prototype._update=function(t){for(var e=this._w,r=0|this._a,i=0|this._b,n=0|this._c,o=0|this._d,s=0|this._e,p=0|this._f,m=0|this._g,g=0|this._h,y=0;y<16;++y)e[y]=t.readInt32BE(4*y);for(;y<64;++y)e[y]=d(e[y-2])+e[y-7]+c(e[y-15])+e[y-16]|0;for(var v=0;v<64;++v){var b=g+f(s)+h(s,p,m)+a[v]+e[v]|0,w=l(r)+u(r,i,n)|0;g=m,m=p,p=s,s=o+b|0,o=n,n=i,i=r,r=b+w|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=p+this._f|0,this._g=m+this._g|0,this._h=g+this._h|0},s.prototype._hash=function(){var t=n.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=s})),Y=h(((t,e)=>{var r=b(),i=Z(),n=z(),a=y().Buffer,o=new Array(64);function s(){this.init(),this._w=o,n.call(this,64,56)}r(s,i),s.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},s.prototype._hash=function(){var t=a.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=s})),$=h(((t,e)=>{var r=b(),i=z(),n=y().Buffer,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],o=new Array(160);function s(){this.init(),this._w=o,i.call(this,128,112)}function h(t,e,r){return r^t&(e^r)}function u(t,e,r){return t&e|r&(t|e)}function l(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function f(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function c(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function m(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(t,e){return t>>>0>>0?1:0}r(s,i),s.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},s.prototype._update=function(t){for(var e=this._w,r=0|this._ah,i=0|this._bh,n=0|this._ch,o=0|this._dh,s=0|this._eh,y=0|this._fh,v=0|this._gh,b=0|this._hh,w=0|this._al,M=0|this._bl,_=0|this._cl,E=0|this._dl,S=0|this._el,C=0|this._fl,A=0|this._gl,I=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var B=e[T-30],k=e[T-30+1],R=c(B,k),N=d(k,B),L=p(B=e[T-4],k=e[T-4+1]),x=m(k,B),D=e[T-14],U=e[T-14+1],P=e[T-32],O=e[T-32+1],j=N+U|0,V=R+D+g(j,N)|0;V=(V=V+L+g(j=j+x|0,x)|0)+P+g(j=j+O|0,O)|0,e[T]=V,e[T+1]=j}for(var q=0;q<160;q+=2){V=e[q],j=e[q+1];var K=u(r,i,n),F=u(w,M,_),H=l(r,w),z=l(w,r),G=f(s,S),W=f(S,s),Z=a[q],Y=a[q+1],$=h(s,y,v),Q=h(S,C,A),X=I+W|0,J=b+G+g(X,I)|0;J=(J=(J=J+$+g(X=X+Q|0,Q)|0)+Z+g(X=X+Y|0,Y)|0)+V+g(X=X+j|0,j)|0;var tt=z+F|0,et=H+K+g(tt,z)|0;b=v,I=A,v=y,A=C,y=s,C=S,s=o+J+g(S=E+X|0,E)|0,o=n,E=_,n=i,_=M,i=r,M=w,r=J+et+g(w=X+tt|0,X)|0}this._al=this._al+w|0,this._bl=this._bl+M|0,this._cl=this._cl+_|0,this._dl=this._dl+E|0,this._el=this._el+S|0,this._fl=this._fl+C|0,this._gl=this._gl+A|0,this._hl=this._hl+I|0,this._ah=this._ah+r+g(this._al,w)|0,this._bh=this._bh+i+g(this._bl,M)|0,this._ch=this._ch+n+g(this._cl,_)|0,this._dh=this._dh+o+g(this._dl,E)|0,this._eh=this._eh+s+g(this._el,S)|0,this._fh=this._fh+y+g(this._fl,C)|0,this._gh=this._gh+v+g(this._gl,A)|0,this._hh=this._hh+b+g(this._hl,I)|0},s.prototype._hash=function(){var t=n.allocUnsafe(64);function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=s})),Q=h(((t,e)=>{var r=b(),i=$(),n=z(),a=y().Buffer,o=new Array(160);function s(){this.init(),this._w=o,n.call(this,128,112)}r(s,i),s.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},s.prototype._hash=function(){var t=a.allocUnsafe(48);function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=s})),X=h(((t,e)=>{t=e.exports=function(e){e=e.toLowerCase();var r=t[e];if(!r)throw new Error(e+' is not supported (we accept pull requests)');return new r},t.sha=G(),t.sha1=W(),t.sha224=Y(),t.sha256=Z(),t.sha384=Q(),t.sha512=$()})),J=h(((t,e)=>{e.exports={ArrayIsArray:t=>Array.isArray(t),ArrayPrototypeIncludes:(t,e)=>t.includes(e),ArrayPrototypeIndexOf:(t,e)=>t.indexOf(e),ArrayPrototypeJoin:(t,e)=>t.join(e),ArrayPrototypeMap:(t,e)=>t.map(e),ArrayPrototypePop:(t,e)=>t.pop(e),ArrayPrototypePush:(t,e)=>t.push(e),ArrayPrototypeSlice:(t,e,r)=>t.slice(e,r),Error,FunctionPrototypeCall:(t,e,...r)=>t.call(e,...r),FunctionPrototypeSymbolHasInstance:(t,e)=>Function.prototype[Symbol.hasInstance].call(t,e),MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties:(t,e)=>Object.defineProperties(t,e),ObjectDefineProperty:(t,e,r)=>Object.defineProperty(t,e,r),ObjectGetOwnPropertyDescriptor:(t,e)=>Object.getOwnPropertyDescriptor(t,e),ObjectKeys:t=>Object.keys(t),ObjectSetPrototypeOf:(t,e)=>Object.setPrototypeOf(t,e),Promise,PromisePrototypeCatch:(t,e)=>t.catch(e),PromisePrototypeThen:(t,e,r)=>t.then(e,r),PromiseReject:t=>Promise.reject(t),ReflectApply:Reflect.apply,RegExpPrototypeTest:(t,e)=>t.test(e),SafeSet:Set,String,StringPrototypeSlice:(t,e,r)=>t.slice(e,r),StringPrototypeToLowerCase:t=>t.toLowerCase(),StringPrototypeToUpperCase:t=>t.toUpperCase(),StringPrototypeTrim:t=>t.trim(),Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet:(t,e,r)=>t.set(e,r),Uint8Array}})),tt=h(((t,e)=>{var r=g(),i=Object.getPrototypeOf((async function(){})).constructor,n=globalThis.Blob||r.Blob,a=typeof n<'u'?function(t){return t instanceof n}:function(t){return!1},o=class extends Error{constructor(t){if(!Array.isArray(t))throw new TypeError("Expected input to be an Array, got "+typeof t);let e='';for(let r=0;r{t=r,e=i})),resolve:t,reject:e}},promisify:t=>new Promise(((e,r)=>{t(((t,...i)=>t?r(t):e(...i)))})),debuglog:()=>function(){},format:(t,...e)=>t.replace(/%([sdifj])/g,(function(...[t,r]){let i=e.shift();return'f'===r?i.toFixed(6):'j'===r?JSON.stringify(i):'s'===r&&'object'==typeof i?`${i.constructor!==Object?i.constructor.name:''} {}`.trim():i.toString()})),inspect(t){switch(typeof t){case'string':if(t.includes("'")){if(!t.includes('"'))return`"${t}"`;if(!t.includes('`')&&!t.includes('${'))return`\`${t}\``}return`'${t}'`;case'number':return isNaN(t)?'NaN':Object.is(t,-0)?String(t):t;case'bigint':return`${String(t)}n`;case'boolean':case'undefined':return String(t);case'object':return'{}'}},types:{isAsyncFunction:t=>t instanceof i,isArrayBufferView:t=>ArrayBuffer.isView(t)},isBlob:a},e.exports.promisify.custom=Symbol.for('nodejs.util.promisify.custom')})),et=h(((t,e)=>{var{AbortController:r,AbortSignal:i}=typeof self<'u'?self:typeof window<'u'?window:void 0;e.exports=r,e.exports.AbortSignal=i,e.exports.default=r})),rt=h(((t,e)=>{var{format:r,inspect:i,AggregateError:n}=tt(),a=globalThis.AggregateError||n,o=Symbol('kIsNodeError'),s=['string','function','number','object','Function','Object','boolean','bigint','symbol'],h=/^([A-Z][a-z0-9]*)+$/,u={};function l(t,e){if(!t)throw new u.ERR_INTERNAL_ASSERTION(e)}function f(t){let e='',r=t.length,i='-'===t[0]?1:0;for(;r>=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function c(t,e,i){i||(i=Error);class n extends i{constructor(...i){super(function(t,e,i){if('function'==typeof e)return l(e.length<=i.length,`Code: ${t}; The provided arguments length (${i.length}) does not match the required ones (${e.length}).`),e(...i);let n=(e.match(/%[dfijoOs]/g)||[]).length;return l(n===i.length,`Code: ${t}; The provided arguments length (${i.length}) does not match the required ones (${n}).`),0===i.length?e:r(e,...i)}(t,e,i))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(n.prototype,{name:{value:i.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),n.prototype.code=t,n.prototype[o]=!0,u[t]=n}function d(t){let e="__node_internal_"+t.name;return Object.defineProperty(t,'name',{value:e}),t}var p=class extends Error{constructor(t="The operation was aborted",e=void 0){if(void 0!==e&&'object'!=typeof e)throw new u.ERR_INVALID_ARG_TYPE('options','Object',e);super(t,e),this.code='ABORT_ERR',this.name='AbortError'}};c('ERR_ASSERTION','%s',Error),c('ERR_INVALID_ARG_TYPE',((t,e,r)=>{l('string'==typeof t,"'name' must be a string"),Array.isArray(e)||(e=[e]);let n='The ';t.endsWith(' argument')?n+=`${t} `:n+=`"${t}" ${t.includes('.')?'property':'argument'} `,n+='must be ';let a=[],o=[],u=[];for(let t of e)l('string'==typeof t,'All expected entries have to be of type string'),s.includes(t)?a.push(t.toLowerCase()):h.test(t)?o.push(t):(l('object'!==t,'The value "object" should be written as "Object"'),u.push(t));if(o.length>0){let t=a.indexOf('object');-1!==t&&(a.splice(a,t,1),o.push('Object'))}if(a.length>0){switch(a.length){case 1:n+=`of type ${a[0]}`;break;case 2:n+=`one of type ${a[0]} or ${a[1]}`;break;default:{let t=a.pop();n+=`one of type ${a.join(', ')}, or ${t}`}}(o.length>0||u.length>0)&&(n+=' or ')}if(o.length>0){switch(o.length){case 1:n+=`an instance of ${o[0]}`;break;case 2:n+=`an instance of ${o[0]} or ${o[1]}`;break;default:{let t=o.pop();n+=`an instance of ${o.join(', ')}, or ${t}`}}u.length>0&&(n+=' or ')}switch(u.length){case 0:break;case 1:u[0].toLowerCase()!==u[0]&&(n+='an '),n+=`${u[0]}`;break;case 2:n+=`one of ${u[0]} or ${u[1]}`;break;default:{let t=u.pop();n+=`one of ${u.join(', ')}, or ${t}`}}if(null==r)n+=`. Received ${r}`;else if('function'==typeof r&&r.name)n+=`. Received function ${r.name}`;else if('object'==typeof r){var f;null!==(f=r.constructor)&&void 0!==f&&f.name?n+=`. Received an instance of ${r.constructor.name}`:n+=`. Received ${i(r,{depth:-1})}`}else{let t=i(r,{colors:!1});t.length>25&&(t=`${t.slice(0,25)}...`),n+=`. Received type ${typeof r} (${t})`}return n}),TypeError),c('ERR_INVALID_ARG_VALUE',((t,e,r="is invalid")=>{let n=i(e);return n.length>128&&(n=n.slice(0,128)+'...'),`The ${t.includes('.')?'property':'argument'} '${t}' ${r}. Received ${n}`}),TypeError),c('ERR_INVALID_RETURN_VALUE',((t,e,r)=>{var i;return`Expected ${t} to be returned from the "${e}" function but got ${null!=r&&null!==(i=r.constructor)&&void 0!==i&&i.name?`instance of ${r.constructor.name}`:"type "+typeof r}.`}),TypeError),c('ERR_MISSING_ARGS',((...t)=>{l(t.length>0,'At least one arg needs to be specified');let e,r=t.length;switch(t=(Array.isArray(t)?t:[t]).map((t=>`"${t}"`)).join(' or '),r){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{let r=t.pop();e+=`The ${t.join(', ')}, and ${r} arguments`}}return`${e} must be specified`}),TypeError),c('ERR_OUT_OF_RANGE',((t,e,r)=>{let n;return l(e,'Missing "range" argument'),Number.isInteger(r)&&Math.abs(r)>2**32?n=f(String(r)):'bigint'==typeof r?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=f(n)),n+='n'):n=i(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`}),RangeError),c('ERR_MULTIPLE_CALLBACK','Callback called multiple times',Error),c('ERR_METHOD_NOT_IMPLEMENTED','The %s method is not implemented',Error),c('ERR_STREAM_ALREADY_FINISHED','Cannot call %s after a stream was finished',Error),c('ERR_STREAM_CANNOT_PIPE','Cannot pipe, not readable',Error),c('ERR_STREAM_DESTROYED','Cannot call %s after a stream was destroyed',Error),c('ERR_STREAM_NULL_VALUES','May not write null values to stream',TypeError),c('ERR_STREAM_PREMATURE_CLOSE','Premature close',Error),c('ERR_STREAM_PUSH_AFTER_EOF','stream.push() after EOF',Error),c('ERR_STREAM_UNSHIFT_AFTER_END_EVENT','stream.unshift() after end event',Error),c('ERR_STREAM_WRITE_AFTER_END','write after end',Error),c('ERR_UNKNOWN_ENCODING','Unknown encoding: %s',TypeError),e.exports={AbortError:p,aggregateTwoErrors:d((function(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new a([e,t],e.message);return r.code=e.code,r}return t||e})),hideStackFrames:d,codes:u}})),it=h(((t,e)=>{var{ArrayIsArray:r,ArrayPrototypeIncludes:i,ArrayPrototypeJoin:n,ArrayPrototypeMap:a,NumberIsInteger:o,NumberIsNaN:s,NumberMAX_SAFE_INTEGER:h,NumberMIN_SAFE_INTEGER:u,NumberParseInt:l,ObjectPrototypeHasOwnProperty:f,RegExpPrototypeExec:c,String:d,StringPrototypeToUpperCase:p,StringPrototypeTrim:m}=J(),{hideStackFrames:g,codes:{ERR_SOCKET_BAD_PORT:y,ERR_INVALID_ARG_TYPE:v,ERR_INVALID_ARG_VALUE:b,ERR_OUT_OF_RANGE:w,ERR_UNKNOWN_SIGNAL:M}}=rt(),{normalizeEncoding:_}=tt(),{isAsyncFunction:E,isArrayBufferView:S}=tt().types,C={},A=/^[0-7]+$/,I=g(((t,e,r=u,i=h)=>{if('number'!=typeof t)throw new v(e,'number',t);if(!o(t))throw new w(e,'an integer',t);if(ti)throw new w(e,`>= ${r} && <= ${i}`,t)})),T=g(((t,e,r=-2147483648,i=2147483647)=>{if('number'!=typeof t)throw new v(e,'number',t);if(!o(t))throw new w(e,'an integer',t);if(ti)throw new w(e,`>= ${r} && <= ${i}`,t)})),B=g(((t,e,r=!1)=>{if('number'!=typeof t)throw new v(e,'number',t);if(!o(t))throw new w(e,'an integer',t);let i=r?1:0,n=4294967295;if(tn)throw new w(e,`>= ${i} && <= ${n}`,t)}));function k(t,e){if('string'!=typeof t)throw new v(e,'string',t)}var R=g(((t,e,r)=>{if(!i(r,t)){let i=n(a(r,(t=>'string'==typeof t?`'${t}'`:d(t))),', ');throw new b(e,t,'must be one of: '+i)}}));function N(t,e,r){return null!=t&&f(t,e)?t[e]:r}var L=g(((t,e,i=null)=>{let n=N(i,'allowArray',!1),a=N(i,'allowFunction',!1);if(!N(i,'nullable',!1)&&null===t||!n&&r(t)||'object'!=typeof t&&(!a||'function'!=typeof t))throw new v(e,'Object',t)})),x=g(((t,e,i=0)=>{if(!r(t))throw new v(e,'Array',t);if(t.length{if(!S(t))throw new v(e,['Buffer','TypedArray','DataView'],t)})),U=g(((t,e)=>{if(void 0!==t&&(null===t||'object'!=typeof t||!('aborted'in t)))throw new v(e,'AbortSignal',t)})),P=g(((t,e)=>{if('function'!=typeof t)throw new v(e,'Function',t)})),O=g(((t,e)=>{if('function'!=typeof t||E(t))throw new v(e,'Function',t)})),j=g(((t,e)=>{if(void 0!==t)throw new v(e,'undefined',t)}));e.exports={isInt32:function(t){return t===(0|t)},isUint32:function(t){return t===t>>>0},parseFileMode:function(t,e,r){if(typeof t>'u'&&(t=r),'string'==typeof t){if(null===c(A,t))throw new b(e,t,"must be a 32-bit unsigned integer or an octal string");t=l(t,8)}return B(t,e),t},validateArray:x,validateBoolean:function(t,e){if('boolean'!=typeof t)throw new v(e,'boolean',t)},validateBuffer:D,validateEncoding:function(t,e){let r=_(e),i=t.length;if('hex'===r&&i%2!=0)throw new b('encoding',e,`is invalid for data of length ${i}`)},validateFunction:P,validateInt32:T,validateInteger:I,validateNumber:function(t,e,r=void 0,i){if('number'!=typeof t)throw new v(e,'number',t);if(null!=r&&ti||(null!=r||null!=i)&&s(t))throw new w(e,`${null!=r?`>= ${r}`:''}${null!=r&&null!=i?' && ':''}${null!=i?`<= ${i}`:''}`,t)},validateObject:L,validateOneOf:R,validatePlainFunction:O,validatePort:function(t,e="Port",r=!0){if('number'!=typeof t&&'string'!=typeof t||'string'==typeof t&&0===m(t).length||+t!=+t>>>0||t>65535||0===t&&!r)throw new y(e,t,r);return 0|t},validateSignalName:function(t,e="signal"){if(k(t,e),void 0===C[t])throw void 0!==C[p(t)]?new M(t+' (signals must use all capital letters)'):new M(t)},validateString:k,validateUint32:B,validateUndefined:j,validateUnion:function(t,e,r){if(!i(r,t))throw new v(e,`('${n(r,'|')}')`,t)},validateAbortSignal:U}})),nt=h(((t,e)=>{var r,i,n=e.exports={};function a(){throw new Error('setTimeout has not been defined')}function o(){throw new Error('clearTimeout has not been defined')}function s(t){if(r===setTimeout)return setTimeout(t,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch{try{return r.call(null,t,0)}catch{return r.call(this,t,0)}}}!function(){try{r='function'==typeof setTimeout?setTimeout:a}catch{r=a}try{i='function'==typeof clearTimeout?clearTimeout:o}catch{i=o}}();var h,u=[],l=!1,f=-1;function c(){!l||!h||(l=!1,h.length?u=h.concat(u):f=-1,u.length&&d())}function d(){if(!l){var t=s(c);l=!0;for(var e=u.length;e;){for(h=u,u=[];++f1)for(var r=1;rot}),st=s((()=>{f(at,c(nt())),ot=c(nt())})),ht=h(((t,e)=>{var{Symbol:r,SymbolAsyncIterator:i,SymbolIterator:n}=J(),a=r('kDestroyed'),o=r('kIsErrored'),s=r('kIsReadable'),h=r('kIsDisturbed');function u(t,e=!1){var r;return!(!t||'function'!=typeof t.pipe||'function'!=typeof t.on||e&&('function'!=typeof t.pause||'function'!=typeof t.resume)||t._writableState&&!1===(null===(r=t._readableState)||void 0===r?void 0:r.readable)||t._writableState&&!t._readableState)}function l(t){var e;return!(!t||'function'!=typeof t.write||'function'!=typeof t.on||t._readableState&&!1===(null===(e=t._writableState)||void 0===e?void 0:e.writable))}function f(t){return t&&(t._readableState||t._writableState||'function'==typeof t.write&&'function'==typeof t.on||'function'==typeof t.pipe&&'function'==typeof t.on)}function c(t){if(!f(t))return null;let{_writableState:e,_readableState:r}=t,i=e||r;return!!(t.destroyed||t[a]||null!=i&&i.destroyed)}function d(t){if(!l(t))return null;if(!0===t.writableEnded)return!0;let e=t._writableState;return(null==e||!e.errored)&&('boolean'!=typeof e?.ended?null:e.ended)}function p(t,e){if(!u(t))return null;let r=t._readableState;return(null==r||!r.errored)&&('boolean'!=typeof r?.endEmitted?null:!!(r.endEmitted||!1===e&&!0===r.ended&&0===r.length))}function m(t){return t&&null!=t[s]?t[s]:'boolean'!=typeof t?.readable?null:!c(t)&&u(t)&&t.readable&&!p(t)}function g(t){return'boolean'!=typeof t?.writable?null:!c(t)&&l(t)&&t.writable&&!d(t)}function y(t){return'boolean'==typeof t._closed&&'boolean'==typeof t._defaultKeepAlive&&'boolean'==typeof t._removedConnection&&'boolean'==typeof t._removedContLen}function v(t){return'boolean'==typeof t._sent100&&y(t)}e.exports={kDestroyed:a,isDisturbed:function(t){var e;return!(!t||!(null!==(e=t[h])&&void 0!==e?e:t.readableDidRead||t.readableAborted))},kIsDisturbed:h,isErrored:function(t){var e,r,i,n,a,s,h,u,l,f;return!(!t||!(null!==(e=null!==(r=null!==(i=null!==(n=null!==(a=null!==(s=t[o])&&void 0!==s?s:t.readableErrored)&&void 0!==a?a:t.writableErrored)&&void 0!==n?n:null===(h=t._readableState)||void 0===h?void 0:h.errorEmitted)&&void 0!==i?i:null===(u=t._writableState)||void 0===u?void 0:u.errorEmitted)&&void 0!==r?r:null===(l=t._readableState)||void 0===l?void 0:l.errored)&&void 0!==e?e:null===(f=t._writableState)||void 0===f?void 0:f.errored))},kIsErrored:o,isReadable:m,kIsReadable:s,isClosed:function(t){if(!f(t))return null;if('boolean'==typeof t.closed)return t.closed;let{_writableState:e,_readableState:r}=t;return'boolean'==typeof e?.closed||'boolean'==typeof r?.closed?e?.closed||r?.closed:'boolean'==typeof t._closed&&y(t)?t._closed:null},isDestroyed:c,isDuplexNodeStream:function(t){return!(!t||'function'!=typeof t.pipe||!t._readableState||'function'!=typeof t.on||'function'!=typeof t.write)},isFinished:function(t,e){return f(t)?!!c(t)||!(!1!==e?.readable&&m(t)||!1!==e?.writable&&g(t)):null},isIterable:function(t,e){return null!=t&&(!0===e?'function'==typeof t[i]:!1===e?'function'==typeof t[n]:'function'==typeof t[i]||'function'==typeof t[n])},isReadableNodeStream:u,isReadableEnded:function(t){if(!u(t))return null;if(!0===t.readableEnded)return!0;let e=t._readableState;return!(!e||e.errored)&&('boolean'!=typeof e?.ended?null:e.ended)},isReadableFinished:p,isReadableErrored:function(t){var e,r;return f(t)?t.readableErrored?t.readableErrored:null!==(e=null===(r=t._readableState)||void 0===r?void 0:r.errored)&&void 0!==e?e:null:null},isNodeStream:f,isWritable:g,isWritableNodeStream:l,isWritableEnded:d,isWritableFinished:function(t,e){if(!l(t))return null;if(!0===t.writableFinished)return!0;let r=t._writableState;return(null==r||!r.errored)&&('boolean'!=typeof r?.finished?null:!!(r.finished||!1===e&&!0===r.ended&&0===r.length))},isWritableErrored:function(t){var e,r;return f(t)?t.writableErrored?t.writableErrored:null!==(e=null===(r=t._writableState)||void 0===r?void 0:r.errored)&&void 0!==e?e:null:null},isServerRequest:function(t){var e;return'boolean'==typeof t._consuming&&'boolean'==typeof t._dumped&&void 0===(null===(e=t.req)||void 0===e?void 0:e.upgradeOrConnect)},isServerResponse:v,willEmitClose:function(t){if(!f(t))return null;let{_writableState:e,_readableState:r}=t,i=e||r;return!i&&v(t)||!!(i&&i.autoDestroy&&i.emitClose&&!1===i.closed)}}})),ut=h(((t,e)=>{var r=(st(),d(at)),{AbortError:i,codes:n}=rt(),{ERR_INVALID_ARG_TYPE:a,ERR_STREAM_PREMATURE_CLOSE:o}=n,{kEmptyObject:s,once:h}=tt(),{validateAbortSignal:u,validateFunction:l,validateObject:f}=it(),{Promise:c}=J(),{isClosed:p,isReadable:m,isReadableNodeStream:g,isReadableFinished:y,isReadableErrored:v,isWritable:b,isWritableNodeStream:w,isWritableFinished:M,isWritableErrored:_,isNodeStream:E,willEmitClose:S}=ht(),C=()=>{};function A(t,e,n){var c,d;2===arguments.length?(n=e,e=s):null==e?e=s:f(e,'options'),l(n,'callback'),u(e.signal,'options.signal'),n=h(n);let A=null!==(c=e.readable)&&void 0!==c?c:g(t),I=null!==(d=e.writable)&&void 0!==d?d:w(t);if(!E(t))throw new a('stream','Stream',t);let{_writableState:T,_readableState:B}=t,k=()=>{t.writable||L()},R=S(t)&&g(t)===A&&w(t)===I,N=M(t,!1),L=()=>{N=!0,t.destroyed&&(R=!1),(!R||t.readable&&!A)&&(!A||x)&&n.call(t)},x=y(t,!1),D=()=>{x=!0,t.destroyed&&(R=!1),(!R||t.writable&&!I)&&(!I||N)&&n.call(t)},U=e=>{n.call(t,e)},P=p(t),O=()=>{P=!0;let e=_(t)||v(t);return e&&'boolean'!=typeof e?n.call(t,e):A&&!x&&g(t,!0)&&!y(t,!1)?n.call(t,new o):!I||N||M(t,!1)?void n.call(t):n.call(t,new o)},j=()=>{t.req.on('finish',L)};!function(t){return t.setHeader&&'function'==typeof t.abort}(t)?I&&!T&&(t.on('end',k),t.on('close',k)):(t.on('complete',L),R||t.on('abort',O),t.req?j():t.on('request',j)),!R&&'boolean'==typeof t.aborted&&t.on('aborted',O),t.on('end',D),t.on('finish',L),!1!==e.error&&t.on('error',U),t.on('close',O),P?r.nextTick(O):null!=T&&T.errorEmitted||null!=B&&B.errorEmitted?R||r.nextTick(O):(!A&&(!R||m(t))&&(N||!1===b(t))||!I&&(!R||b(t))&&(x||!1===m(t))||B&&t.req&&t.aborted)&&r.nextTick(O);let V=()=>{n=C,t.removeListener('aborted',O),t.removeListener('complete',L),t.removeListener('abort',O),t.removeListener('request',j),t.req&&t.req.removeListener('finish',L),t.removeListener('end',k),t.removeListener('close',k),t.removeListener('finish',L),t.removeListener('end',D),t.removeListener('error',U),t.removeListener('close',O)};if(e.signal&&!P){let a=()=>{let r=n;V(),r.call(t,new i(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)r.nextTick(a);else{let r=n;n=h(((...i)=>{e.signal.removeEventListener('abort',a),r.apply(t,i)})),e.signal.addEventListener('abort',a)}}return V}e.exports=A,e.exports.finished=function(t,e){return new c(((r,i)=>{A(t,e,(t=>{t?i(t):r()}))}))}})),lt=h(((t,e)=>{var r=globalThis.AbortController||et().AbortController,{codes:{ERR_INVALID_ARG_TYPE:i,ERR_MISSING_ARGS:n,ERR_OUT_OF_RANGE:a},AbortError:o}=rt(),{validateAbortSignal:s,validateInteger:h,validateObject:u}=it(),l=J().Symbol('kWeak'),{finished:f}=ut(),{ArrayPrototypePush:c,MathFloor:d,Number:p,NumberIsNaN:m,Promise:g,PromiseReject:y,PromisePrototypeThen:v,Symbol:b}=J(),w=b('kEmpty'),M=b('kEof');function _(t,e){if('function'!=typeof t)throw new i('fn',['Function','AsyncFunction'],t);null!=e&&u(e,'options'),null!=e?.signal&&s(e.signal,'options.signal');let n=1;return null!=e?.concurrency&&(n=d(e.concurrency)),h(n,'concurrency',1),async function*(){var i,a;let s=new r,h=this,u=[],l=s.signal,f={signal:l},c=()=>s.abort();null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted&&c(),null==e||null===(a=e.signal)||void 0===a||a.addEventListener('abort',c);let d,p,m=!1;function b(){m=!0}!async function(){try{for await(let e of h){var r;if(m)return;if(l.aborted)throw new o;try{e=t(e,f)}catch(t){e=y(t)}e!==w&&('function'==typeof(null===(r=e)||void 0===r?void 0:r.catch)&&e.catch(b),u.push(e),d&&(d(),d=null),!m&&u.length&&u.length>=n&&await new g((t=>{p=t})))}u.push(M)}catch(t){let e=y(t);v(e,void 0,b),u.push(e)}finally{var i;m=!0,d&&(d(),d=null),null==e||null===(i=e.signal)||void 0===i||i.removeEventListener('abort',c)}}();try{for(;;){for(;u.length>0;){let t=await u[0];if(t===M)return;if(l.aborted)throw new o;t!==w&&(yield t),u.shift(),p&&(p(),p=null)}await new g((t=>{d=t}))}}finally{s.abort(),m=!0,p&&(p(),p=null)}}.call(this)}async function E(t,e=void 0){for await(let r of S.call(this,t,e))return!0;return!1}function S(t,e){if('function'!=typeof t)throw new i('fn',['Function','AsyncFunction'],t);return _.call(this,(async function(e,r){return await t(e,r)?e:w}),e)}var C=class extends n{constructor(){super('reduce'),this.message='Reduce of an empty stream requires an initial value'}};function A(t){if(t=p(t),m(t))return 0;if(t<0)throw new a('number','>= 0',t);return t}e.exports.streamReturningOperators={asIndexedPairs:function(t=void 0){return null!=t&&u(t,'options'),null!=t?.signal&&s(t.signal,'options.signal'),async function*(){let e=0;for await(let i of this){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new o({cause:t.signal.reason});yield[e++,i]}}.call(this)},drop:function(t,e=void 0){return null!=e&&u(e,'options'),null!=e?.signal&&s(e.signal,'options.signal'),t=A(t),async function*(){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new o;for await(let r of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new o;t--<=0&&(yield r)}}.call(this)},filter:S,flatMap:function(t,e){let r=_.call(this,t,e);return async function*(){for await(let t of r)yield*t}.call(this)},map:_,take:function(t,e=void 0){return null!=e&&u(e,'options'),null!=e?.signal&&s(e.signal,'options.signal'),t=A(t),async function*(){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new o;for await(let r of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new o;if(!(t-- >0))return;yield r}}.call(this)}},e.exports.promiseReturningOperators={every:async function(t,e=void 0){if('function'!=typeof t)throw new i('fn',['Function','AsyncFunction'],t);return!await E.call(this,(async(...e)=>!await t(...e)),e)},forEach:async function(t,e){if('function'!=typeof t)throw new i('fn',['Function','AsyncFunction'],t);for await(let r of _.call(this,(async function(e,r){return await t(e,r),w}),e));},reduce:async function(t,e,n){var a;if('function'!=typeof t)throw new i('reducer',['Function','AsyncFunction'],t);null!=n&&u(n,'options'),null!=n?.signal&&s(n.signal,'options.signal');let h=arguments.length>1;if(null!=n&&null!==(a=n.signal)&&void 0!==a&&a.aborted){let t=new o(void 0,{cause:n.signal.reason});throw this.once('error',(()=>{})),await f(this.destroy(t)),t}let c=new r,d=c.signal;if(null!=n&&n.signal){let t={once:!0,[l]:this};n.signal.addEventListener('abort',(()=>c.abort()),t)}let p=!1;try{for await(let r of this){var m;if(p=!0,null!=n&&null!==(m=n.signal)&&void 0!==m&&m.aborted)throw new o;h?e=await t(e,r,{signal:d}):(e=r,h=!0)}if(!p&&!h)throw new C}finally{c.abort()}return e},toArray:async function(t){null!=t&&u(t,'options'),null!=t?.signal&&s(t.signal,'options.signal');let e=[];for await(let i of this){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new o(void 0,{cause:t.signal.reason});c(e,i)}return e},some:E,find:async function(t,e){for await(let r of S.call(this,t,e))return r}}})),ft=h(((t,e)=>{var r=(st(),d(at)),{aggregateTwoErrors:i,codes:{ERR_MULTIPLE_CALLBACK:n},AbortError:a}=rt(),{Symbol:o}=J(),{kDestroyed:s,isDestroyed:h,isFinished:u,isServerRequest:l}=ht(),f=o('kDestroy'),c=o('kConstruct');function p(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function m(t,e,i){let n=!1;function a(e){if(n)return;n=!0;let{_readableState:a,_writableState:o}=t;p(e,o,a),o&&(o.closed=!0),a&&(a.closed=!0),'function'==typeof i&&i(e),e?r.nextTick(g,t,e):r.nextTick(y,t)}try{t._destroy(e||null,a)}catch(t){a(t)}}function g(t,e){v(t,e),y(t)}function y(t){let{_readableState:e,_writableState:r}=t;r&&(r.closeEmitted=!0),e&&(e.closeEmitted=!0),(r&&r.emitClose||e&&e.emitClose)&&t.emit('close')}function v(t,e){let{_readableState:r,_writableState:i}=t;i&&i.errorEmitted||r&&r.errorEmitted||(i&&(i.errorEmitted=!0),r&&(r.errorEmitted=!0),t.emit('error',e))}function b(t,e,i){let{_readableState:n,_writableState:a}=t;if(a&&a.destroyed||n&&n.destroyed)return this;n&&n.autoDestroy||a&&a.autoDestroy?t.destroy(e):e&&(e.stack,a&&!a.errored&&(a.errored=e),n&&!n.errored&&(n.errored=e),i?r.nextTick(v,t,e):v(t,e))}function w(t){let e=!1;function i(i){if(e)return void b(t,i??new n);e=!0;let{_readableState:a,_writableState:o}=t,s=o||a;a&&(a.constructed=!0),o&&(o.constructed=!0),s.destroyed?t.emit(f,i):i?b(t,i,!0):r.nextTick(M,t)}try{t._construct(i)}catch(t){i(t)}}function M(t){t.emit(c)}function _(t){return t&&t.setHeader&&'function'==typeof t.abort}function E(t){t.emit('close')}function S(t,e){t.emit('error',e),r.nextTick(E,t)}e.exports={construct:function(t,e){if('function'!=typeof t._construct)return;let{_readableState:i,_writableState:n}=t;i&&(i.constructed=!1),n&&(n.constructed=!1),t.once(c,e),!(t.listenerCount(c)>1)&&r.nextTick(w,t)},destroyer:function(t,e){!t||h(t)||(!e&&!u(t)&&(e=new a),l(t)?(t.socket=null,t.destroy(e)):_(t)?t.abort():_(t.req)?t.req.abort():'function'==typeof t.destroy?t.destroy(e):'function'==typeof t.close?t.close():e?r.nextTick(S,t,e):r.nextTick(E,t),t.destroyed||(t[s]=!0))},destroy:function(t,e){let r=this._readableState,n=this._writableState,a=n||r;return n&&n.destroyed||r&&r.destroyed?('function'==typeof e&&e(),this):(p(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),a.constructed?m(this,t,e):this.once(f,(function(r){m(this,i(r,t),e)})),this)},undestroy:function(){let t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=!1===t.readable,t.endEmitted=!1===t.readable),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=!1===e.writable,e.ending=!1===e.writable,e.finished=!1===e.writable)},errorOrDestroy:b}})),ct=h(((t,e)=>{var{ArrayIsArray:r,ObjectSetPrototypeOf:i}=J(),{EventEmitter:n}=w();function a(t){n.call(this,t)}function o(t,e,i){if('function'==typeof t.prependListener)return t.prependListener(e,i);t._events&&t._events[e]?r(t._events[e])?t._events[e].unshift(i):t._events[e]=[i,t._events[e]]:t.on(e,i)}i(a.prototype,n.prototype),i(a,n),a.prototype.pipe=function(t,e){let r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function a(){r.readable&&r.resume&&r.resume()}r.on('data',i),t.on('drain',a),!t._isStdio&&(!e||!1!==e.end)&&(r.on('end',h),r.on('close',u));let s=!1;function h(){s||(s=!0,t.end())}function u(){s||(s=!0,'function'==typeof t.destroy&&t.destroy())}function l(t){f(),0===n.listenerCount(this,'error')&&this.emit('error',t)}function f(){r.removeListener('data',i),t.removeListener('drain',a),r.removeListener('end',h),r.removeListener('close',u),r.removeListener('error',l),t.removeListener('error',l),r.removeListener('end',f),r.removeListener('close',f),t.removeListener('close',f)}return o(r,'error',l),o(t,'error',l),r.on('end',f),r.on('close',f),t.on('close',f),t.emit('pipe',r),t},e.exports={Stream:a,prependListener:o}})),dt=h(((t,e)=>{var{AbortError:r,codes:i}=rt(),n=ut(),{ERR_INVALID_ARG_TYPE:a}=i;e.exports.addAbortSignal=function(t,r){if(((t,e)=>{if('object'!=typeof t||!('aborted'in t))throw new a(e,'AbortSignal',t)})(t,'signal'),!function(t){return!(!t||'function'!=typeof t.pipe)}(r))throw new a('stream','stream.Stream',r);return e.exports.addAbortSignalNoValidate(t,r)},e.exports.addAbortSignalNoValidate=function(t,e){if('object'!=typeof t||!('aborted'in t))return e;let i=()=>{e.destroy(new r(void 0,{cause:t.reason}))};return t.aborted?i():(t.addEventListener('abort',i),n(e,(()=>t.removeEventListener('abort',i)))),e}})),pt=h(((t,e)=>{var{StringPrototypeSlice:r,SymbolIterator:i,TypedArrayPrototypeSet:n,Uint8Array:a}=J(),{Buffer:o}=g(),{inspect:s}=tt();e.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(t){let e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}unshift(t){let e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}shift(){if(0===this.length)return;let t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}clear(){this.head=this.tail=null,this.length=0}join(t){if(0===this.length)return'';let e=this.head,r=''+e.data;for(;null!==(e=e.next);)r+=t+e.data;return r}concat(t){if(0===this.length)return o.alloc(0);let e=o.allocUnsafe(t>>>0),r=this.head,i=0;for(;r;)n(e,r.data,i),i+=r.data.length,r=r.next;return e}consume(t,e){let r=this.head.data;if(ta.length)){t===a.length?(e+=a,++n,i.next?this.head=i.next:this.head=this.tail=null):(e+=r(a,0,t),this.head=i,i.data=r(a,t));break}e+=a,t-=a.length,++n}while(null!==(i=i.next));return this.length-=n,e}_getBuffer(t){let e=o.allocUnsafe(t),r=t,i=this.head,s=0;do{let o=i.data;if(!(t>o.length)){t===o.length?(n(e,o,r-t),++s,i.next?this.head=i.next:this.head=this.tail=null):(n(e,new a(o.buffer,o.byteOffset,t),r-t),this.head=i,i.data=o.slice(t));break}n(e,o,r-t),t-=o.length,++s}while(null!==(i=i.next));return this.length-=s,e}[Symbol.for('nodejs.util.inspect.custom')](t,e){return s(this,{...e,depth:0,customInspect:!1})}}})),mt=h(((t,e)=>{var{MathFloor:r,NumberIsInteger:i}=J(),{ERR_INVALID_ARG_VALUE:n}=rt().codes;function a(t){return t?16:16384}e.exports={getHighWaterMark:function(t,e,o,s){let h=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,s,o);if(null!=h){if(!i(h)||h<0)throw new n(s?`options.${o}`:'options.highWaterMark',h);return r(h)}return a(t.objectMode)},getDefaultHighWaterMark:a}})),gt=h(((t,e)=>{var r=(st(),d(at)),{PromisePrototypeThen:i,SymbolAsyncIterator:n,SymbolIterator:a}=J(),{Buffer:o}=g(),{ERR_INVALID_ARG_TYPE:s,ERR_STREAM_NULL_VALUES:h}=rt().codes;e.exports=function(t,e,u){let l,f;if('string'==typeof e||e instanceof o)return new t({objectMode:!0,...u,read(){this.push(e),this.push(null)}});if(e&&e[n])f=!0,l=e[n]();else{if(!e||!e[a])throw new s('iterable',['Iterable'],e);f=!1,l=e[a]()}let c=new t({objectMode:!0,highWaterMark:1,...u}),d=!1;return c._read=function(){d||(d=!0,async function(){for(;;){try{let{value:t,done:e}=f?await l.next():l.next();if(e)c.push(null);else{let e=t&&'function'==typeof t.then?await t:t;if(null===e)throw d=!1,new h;if(c.push(e))continue;d=!1}}catch(t){c.destroy(t)}break}}())},c._destroy=function(t,e){i(async function(t){let e=null!=t,r='function'==typeof l.throw;if(e&&r){let{value:e,done:r}=await l.throw(t);if(await e,r)return}if('function'==typeof l.return){let{value:t}=await l.return();await t}}(t),(()=>r.nextTick(e,t)),(i=>r.nextTick(e,i||t)))},c}})),yt=h(((t,e)=>{var r=(st(),d(at)),{ArrayPrototypeIndexOf:i,NumberIsInteger:n,NumberIsNaN:a,NumberParseInt:o,ObjectDefineProperties:s,ObjectKeys:h,ObjectSetPrototypeOf:u,Promise:l,SafeSet:f,SymbolAsyncIterator:c,Symbol:p}=J();e.exports=F,F.ReadableState=K;var{EventEmitter:m}=w(),{Stream:y,prependListener:v}=ct(),{Buffer:b}=g(),{addAbortSignal:M}=dt(),_=ut(),E=tt().debuglog('stream',(t=>{E=t})),S=pt(),C=ft(),{getHighWaterMark:A,getDefaultHighWaterMark:I}=mt(),{aggregateTwoErrors:T,codes:{ERR_INVALID_ARG_TYPE:B,ERR_METHOD_NOT_IMPLEMENTED:R,ERR_OUT_OF_RANGE:N,ERR_STREAM_PUSH_AFTER_EOF:L,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:x}}=rt(),{validateObject:D}=it(),U=p('kPaused'),{StringDecoder:P}=k(),O=gt();u(F.prototype,y.prototype),u(F,y);var j,V=()=>{},{errorOrDestroy:q}=C;function K(t,e,r){'boolean'!=typeof r&&(r=e instanceof wt()),this.objectMode=!(!t||!t.objectMode),r&&(this.objectMode=this.objectMode||!(!t||!t.readableObjectMode)),this.highWaterMark=t?A(this,t,'readableHighWaterMark',r):I(!1),this.buffer=new S,this.length=0,this.pipes=[],this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.constructed=!0,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this[U]=null,this.errorEmitted=!1,this.emitClose=!t||!1!==t.emitClose,this.autoDestroy=!t||!1!==t.autoDestroy,this.destroyed=!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this.defaultEncoding=t&&t.defaultEncoding||'utf8',this.awaitDrainWriters=null,this.multiAwaitDrain=!1,this.readingMore=!1,this.dataEmitted=!1,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new P(t.encoding),this.encoding=t.encoding)}function F(t){if(!(this instanceof F))return new F(t);let e=this instanceof wt();this._readableState=new K(t,this,e),t&&('function'==typeof t.read&&(this._read=t.read),'function'==typeof t.destroy&&(this._destroy=t.destroy),'function'==typeof t.construct&&(this._construct=t.construct),t.signal&&!e&&M(t.signal,this)),y.call(this,t),C.construct(this,(()=>{this._readableState.needReadable&&Y(this,this._readableState)}))}function H(t,e,r,i){E('readableAddChunk',e);let n,a=t._readableState;if(a.objectMode||('string'==typeof e?(r=r||a.defaultEncoding,a.encoding!==r&&(i&&a.encoding?e=b.from(e,r).toString(a.encoding):(e=b.from(e,r),r=''))):e instanceof b?r='':y._isUint8Array(e)?(e=y._uint8ArrayToBuffer(e),r=''):null!=e&&(n=new B('chunk',['string','Buffer','Uint8Array'],e))),n)q(t,n);else if(null===e)a.reading=!1,function(t,e){if(E('onEofChunk'),!e.ended){if(e.decoder){let t=e.decoder.end();t&&t.length&&(e.buffer.push(t),e.length+=e.objectMode?1:t.length)}e.ended=!0,e.sync?W(t):(e.needReadable=!1,e.emittedReadable=!0,Z(t))}}(t,a);else if(a.objectMode||e&&e.length>0)if(i)if(a.endEmitted)q(t,new x);else{if(a.destroyed||a.errored)return!1;z(t,a,e,!0)}else if(a.ended)q(t,new L);else{if(a.destroyed||a.errored)return!1;a.reading=!1,a.decoder&&!r?(e=a.decoder.write(e),a.objectMode||0!==e.length?z(t,a,e,!1):Y(t,a)):z(t,a,e,!1)}else i||(a.reading=!1,Y(t,a));return!a.ended&&(a.length0?(e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null,e.dataEmitted=!0,t.emit('data',r)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&W(t)),Y(t,e)}function G(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:a(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}function W(t){let e=t._readableState;E('emitReadable',e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(E('emitReadable',e.flowing),e.emittedReadable=!0,r.nextTick(Z,t))}function Z(t){let e=t._readableState;E('emitReadable_',e.destroyed,e.length,e.ended),!e.destroyed&&!e.errored&&(e.length||e.ended)&&(t.emit('readable'),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,nt(t)}function Y(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,r.nextTick($,t,e))}function $(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!1===e[U]?e.flowing=!0:t.listenerCount('data')>0?t.resume():e.readableListening||(e.flowing=null)}function X(t){E('readable nexttick read 0'),t.read(0)}function et(t,e){E('resume',e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit('resume'),nt(t),e.flowing&&!e.reading&&t.read(0)}function nt(t){let e=t._readableState;for(E('flow',e.flowing);e.flowing&&null!==t.read(););}function ot(t,e){'function'!=typeof t.read&&(t=F.wrap(t,{objectMode:!0}));let r=async function*(t,e){let r=V;function i(e){this===t?(r(),r=V):r=e}t.on('readable',i);let n,a=_(t,{writable:!1},(t=>{n=t?T(n,t):null,r(),r=V}));try{for(;;){let e=t.destroyed?null:t.read();if(null!==e)yield e;else{if(n)throw n;if(null===n)return;await new l(i)}}}catch(t){throw n=T(n,t),n}finally{!n&&!1===e?.destroyOnReturn||void 0!==n&&!t._readableState.autoDestroy?(t.off('readable',i),a()):C.destroyer(t,null)}}(t,e);return r.stream=t,r}function ht(t,e){if(0===e.length)return null;let r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(''):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function lt(t){let e=t._readableState;E('endReadable',e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(yt,e,t))}function yt(t,e){if(E('endReadableNT',t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&0===t.length)if(t.endEmitted=!0,e.emit('end'),e.writable&&!1===e.allowHalfOpen)r.nextTick(vt,e);else if(t.autoDestroy){let t=e._writableState;(!t||t.autoDestroy&&(t.finished||!1===t.writable))&&e.destroy()}}function vt(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}function bt(){return void 0===j&&(j={}),j}F.prototype.destroy=C.destroy,F.prototype._undestroy=C.undestroy,F.prototype._destroy=function(t,e){e(t)},F.prototype[m.captureRejectionSymbol]=function(t){this.destroy(t)},F.prototype.push=function(t,e){return H(this,t,e,!1)},F.prototype.unshift=function(t,e){return H(this,t,e,!0)},F.prototype.isPaused=function(){let t=this._readableState;return!0===t[U]||!1===t.flowing},F.prototype.setEncoding=function(t){let e=new P(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;let r=this._readableState.buffer,i='';for(let t of r)i+=e.write(t);return r.clear(),''!==i&&r.push(i),this._readableState.length=i.length,this},F.prototype.read=function(t){E('read',t),void 0===t?t=NaN:n(t)||(t=o(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=function(t){if(t>1073741824)throw new N('size','<= 1GiB',t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,++t}(t)),0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return E('read: emitReadable',e.length,e.ended),0===e.length&&e.ended?lt(this):W(this),null;if(0===(t=G(t,e))&&e.ended)return 0===e.length&<(this),null;let i,a=e.needReadable;if(E('need readable',a),(0===e.length||e.length-t0?ht(t,e):null,null===i?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&<(this)),null!==i&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit('data',i)),i},F.prototype._read=function(t){throw new R('_read()')},F.prototype.pipe=function(t,e){let i=this,n=this._readableState;1===n.pipes.length&&(n.multiAwaitDrain||(n.multiAwaitDrain=!0,n.awaitDrainWriters=new f(n.awaitDrainWriters?[n.awaitDrainWriters]:[]))),n.pipes.push(t),E('pipe count=%d opts=%j',n.pipes.length,e);let a=e&&!1===e.end||t===r.stdout||t===r.stderr?g:s;function o(e,r){E('onunpipe'),e===i&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,E('cleanup'),t.removeListener('close',p),t.removeListener('finish',m),h&&t.removeListener('drain',h),t.removeListener('error',d),t.removeListener('unpipe',o),i.removeListener('end',s),i.removeListener('end',g),i.removeListener('data',c),u=!0,h&&n.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&h())}function s(){E('onend'),t.end()}n.endEmitted?r.nextTick(a):i.once('end',a),t.on('unpipe',o);let h,u=!1;function l(){u||(1===n.pipes.length&&n.pipes[0]===t?(E('false write response, pause',0),n.awaitDrainWriters=t,n.multiAwaitDrain=!1):n.pipes.length>1&&n.pipes.includes(t)&&(E('false write response, pause',n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),i.pause()),h||(h=function(t,e){return function(){let r=t._readableState;r.awaitDrainWriters===e?(E('pipeOnDrain',1),r.awaitDrainWriters=null):r.multiAwaitDrain&&(E('pipeOnDrain',r.awaitDrainWriters.size),r.awaitDrainWriters.delete(e)),(!r.awaitDrainWriters||0===r.awaitDrainWriters.size)&&t.listenerCount('data')&&t.resume()}}(i,t),t.on('drain',h))}function c(e){E('ondata');let r=t.write(e);E('dest.write',r),!1===r&&l()}function d(e){if(E('onerror',e),g(),t.removeListener('error',d),0===t.listenerCount('error')){let r=t._writableState||t._readableState;r&&!r.errorEmitted?q(t,e):t.emit('error',e)}}function p(){t.removeListener('finish',m),g()}function m(){E('onfinish'),t.removeListener('close',p),g()}function g(){E('unpipe'),i.unpipe(t)}return i.on('data',c),v(t,'error',d),t.once('close',p),t.once('finish',m),t.emit('pipe',i),!0===t.writableNeedDrain?n.flowing&&l():n.flowing||(E('pipe resume'),i.resume()),t},F.prototype.unpipe=function(t){let e=this._readableState;if(0===e.pipes.length)return this;if(!t){let t=e.pipes;e.pipes=[],this.pause();for(let e=0;e0,!1!==n.flowing&&this.resume()):'readable'===t&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,E('on readable',n.length,n.reading),n.length?W(this):n.reading||r.nextTick(X,this)),i},F.prototype.addListener=F.prototype.on,F.prototype.removeListener=function(t,e){let i=y.prototype.removeListener.call(this,t,e);return'readable'===t&&r.nextTick(Q,this),i},F.prototype.off=F.prototype.removeListener,F.prototype.removeAllListeners=function(t){let e=y.prototype.removeAllListeners.apply(this,arguments);return('readable'===t||void 0===t)&&r.nextTick(Q,this),e},F.prototype.resume=function(){let t=this._readableState;return t.flowing||(E('resume'),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(et,t,e))}(this,t)),t[U]=!1,this},F.prototype.pause=function(){return E('call pause flowing=%j',this._readableState.flowing),!1!==this._readableState.flowing&&(E('pause'),this._readableState.flowing=!1,this.emit('pause')),this._readableState[U]=!0,this},F.prototype.wrap=function(t){let e=!1;t.on('data',(r=>{!this.push(r)&&t.pause&&(e=!0,t.pause())})),t.on('end',(()=>{this.push(null)})),t.on('error',(t=>{q(this,t)})),t.on('close',(()=>{this.destroy()})),t.on('destroy',(()=>{this.destroy()})),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=h(t);for(let e=1;e{var r=(st(),d(at)),{ArrayPrototypeSlice:i,Error:n,FunctionPrototypeSymbolHasInstance:a,ObjectDefineProperty:o,ObjectDefineProperties:s,ObjectSetPrototypeOf:h,StringPrototypeToLowerCase:u,Symbol:l,SymbolHasInstance:f}=J();e.exports=U,U.WritableState=x;var{EventEmitter:c}=w(),p=ct().Stream,{Buffer:m}=g(),y=ft(),{addAbortSignal:v}=dt(),{getHighWaterMark:b,getDefaultHighWaterMark:M}=mt(),{ERR_INVALID_ARG_TYPE:_,ERR_METHOD_NOT_IMPLEMENTED:E,ERR_MULTIPLE_CALLBACK:S,ERR_STREAM_CANNOT_PIPE:C,ERR_STREAM_DESTROYED:A,ERR_STREAM_ALREADY_FINISHED:I,ERR_STREAM_NULL_VALUES:T,ERR_STREAM_WRITE_AFTER_END:B,ERR_UNKNOWN_ENCODING:k}=rt().codes,{errorOrDestroy:R}=y;function N(){}h(U.prototype,p.prototype),h(U,p);var L=l('kOnFinished');function x(t,e,r){'boolean'!=typeof r&&(r=e instanceof wt()),this.objectMode=!(!t||!t.objectMode),r&&(this.objectMode=this.objectMode||!(!t||!t.writableObjectMode)),this.highWaterMark=t?b(this,t,'writableHighWaterMark',r):M(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let i=!(!t||!1!==t.decodeStrings);this.decodeStrings=!i,this.defaultEncoding=t&&t.defaultEncoding||'utf8',this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=V.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,D(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||!1!==t.emitClose,this.autoDestroy=!t||!1!==t.autoDestroy,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[L]=[]}function D(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}function U(t){let e=this instanceof wt();if(!e&&!a(U,this))return new U(t);this._writableState=new x(t,this,e),t&&('function'==typeof t.write&&(this._write=t.write),'function'==typeof t.writev&&(this._writev=t.writev),'function'==typeof t.destroy&&(this._destroy=t.destroy),'function'==typeof t.final&&(this._final=t.final),'function'==typeof t.construct&&(this._construct=t.construct),t.signal&&v(t.signal,this)),p.call(this,t),y.construct(this,(()=>{let t=this._writableState;t.writing||H(this,t),W(this,t)}))}function P(t,e,i,n){let a,o=t._writableState;if('function'==typeof i)n=i,i=o.defaultEncoding;else{if(i){if('buffer'!==i&&!m.isEncoding(i))throw new k(i)}else i=o.defaultEncoding;'function'!=typeof n&&(n=N)}if(null===e)throw new T;if(!o.objectMode)if('string'==typeof e)!1!==o.decodeStrings&&(e=m.from(e,i),i='buffer');else if(e instanceof m)i='buffer';else{if(!p._isUint8Array(e))throw new _('chunk',['string','Buffer','Uint8Array'],e);e=p._uint8ArrayToBuffer(e),i='buffer'}return o.ending?a=new B:o.destroyed&&(a=new A('write')),a?(r.nextTick(n,a),R(t,a,!0),a):(o.pendingcb++,function(t,e,r,i,n){let a=e.objectMode?1:r.length;e.length+=a;let o=e.lengthi.bufferedIndex&&H(t,i),n?null!==i.afterWriteTickInfo&&i.afterWriteTickInfo.cb===a?i.afterWriteTickInfo.count++:(i.afterWriteTickInfo={count:1,cb:a,stream:t,state:i},r.nextTick(q,i.afterWriteTickInfo)):K(t,i,1,a))):R(t,new S)}function q({stream:t,state:e,count:r,cb:i}){return e.afterWriteTickInfo=null,K(t,e,r,i)}function K(t,e,r,i){for(!e.ending&&!t.destroyed&&0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit('drain'));r-- >0;)e.pendingcb--,i();e.destroyed&&F(e),W(t,e)}function F(t){if(t.writing)return;for(let r=t.bufferedIndex;r1&&t._writev){e.pendingcb-=o-1;let n=e.allNoop?N:t=>{for(let e=s;e256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}function z(t){return t.ending&&!t.destroyed&&t.constructed&&0===t.length&&!t.errored&&0===t.buffered.length&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function G(t,e){!e.prefinished&&!e.finalCalled&&('function'!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit('prefinish')):(e.finalCalled=!0,function(t,e){let i=!1;function n(n){if(i)R(t,n??S());else if(i=!0,e.pendingcb--,n){let r=e[L].splice(0);for(let t=0;t{z(e)?Z(t,e):e.pendingcb--}),t,e)):z(e)&&(e.pendingcb++,Z(t,e))))}function Z(t,e){e.pendingcb--,e.finished=!0;let r=e[L].splice(0);for(let t=0;t{var r=(st(),d(at)),i=g(),{isReadable:n,isWritable:a,isIterable:o,isNodeStream:s,isReadableNodeStream:h,isWritableNodeStream:u,isDuplexNodeStream:l}=ht(),f=ut(),{AbortError:c,codes:{ERR_INVALID_ARG_TYPE:p,ERR_INVALID_RETURN_VALUE:m}}=rt(),{destroyer:y}=ft(),v=wt(),b=yt(),{createDeferredPromise:w}=tt(),M=gt(),_=globalThis.Blob||i.Blob,E=typeof _<'u'?function(t){return t instanceof _}:function(t){return!1},S=globalThis.AbortController||et().AbortController,{FunctionPrototypeCall:C}=J(),A=class extends v{constructor(t){super(t),!1===t?.readable&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===t?.writable&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};function I(t){let e,r,i,o,s,h=t.readable&&'function'!=typeof t.readable.read?b.wrap(t.readable):t.readable,u=t.writable,l=!!n(h),d=!!a(u);function p(t){let e=o;o=null,e?e(t):t?s.destroy(t):!l&&!d&&s.destroy()}return s=new A({readableObjectMode:!(null==h||!h.readableObjectMode),writableObjectMode:!(null==u||!u.writableObjectMode),readable:l,writable:d}),d&&(f(u,(t=>{d=!1,t&&y(h,t),p(t)})),s._write=function(t,r,i){u.write(t,r)?i():e=i},s._final=function(t){u.end(),r=t},u.on('drain',(function(){if(e){let t=e;e=null,t()}})),u.on('finish',(function(){if(r){let t=r;r=null,t()}}))),l&&(f(h,(t=>{l=!1,t&&y(h,t),p(t)})),h.on('readable',(function(){if(i){let t=i;i=null,t()}})),h.on('end',(function(){s.push(null)})),s._read=function(){for(;;){let t=h.read();if(null===t)return void(i=s._read);if(!s.push(t))return}}),s._destroy=function(t,n){!t&&null!==o&&(t=new c),i=null,e=null,r=null,null===o?n(t):(o=n,y(u,t),y(h,t))},s}e.exports=function t(e,i){if(l(e))return e;if(h(e))return I({readable:e});if(u(e))return I({writable:e});if(s(e))return I({writable:!1,readable:!1});if('function'==typeof e){let{value:t,write:n,final:a,destroy:s}=function(t){let{promise:e,resolve:i}=w(),n=new S,a=n.signal;return{value:t(async function*(){for(;;){let t=e;e=null;let{chunk:n,done:o,cb:s}=await t;if(r.nextTick(s),o)return;if(a.aborted)throw new c(void 0,{cause:a.reason});({promise:e,resolve:i}=w()),yield n}}(),{signal:a}),write(t,e,r){let n=i;i=null,n({chunk:t,done:!1,cb:r})},final(t){let e=i;i=null,e({done:!0,cb:t})},destroy(t,e){n.abort(),e(t)}}}(e);if(o(t))return M(A,t,{objectMode:!0,write:n,final:a,destroy:s});let h=t?.then;if('function'==typeof h){let e,i=C(h,t,(t=>{if(null!=t)throw new m('nully','body',t)}),(t=>{y(e,t)}));return e=new A({objectMode:!0,readable:!1,write:n,final(t){a((async()=>{try{await i,r.nextTick(t,null)}catch(e){r.nextTick(t,e)}}))},destroy:s})}throw new m('Iterable, AsyncIterable or AsyncFunction',i,t)}if(E(e))return t(e.arrayBuffer());if(o(e))return M(A,e,{objectMode:!0,writable:!1});if('object'==typeof e?.writable||'object'==typeof e?.readable)return I({readable:null!=e&&e.readable?h(e?.readable)?e?.readable:t(e.readable):void 0,writable:null!=e&&e.writable?u(e?.writable)?e?.writable:t(e.writable):void 0});let n=e?.then;if('function'==typeof n){let t;return C(n,e,(e=>{null!=e&&t.push(e),t.push(null)}),(e=>{y(t,e)})),t=new A({objectMode:!0,writable:!1,read(){}})}throw new p(i,['Blob','ReadableStream','WritableStream','Stream','Iterable','AsyncIterable','Function','{ readable, writable } pair','Promise'],e)}})),wt=h(((t,e)=>{var{ObjectDefineProperties:r,ObjectGetOwnPropertyDescriptor:i,ObjectKeys:n,ObjectSetPrototypeOf:a}=J();e.exports=l;var o,s,h=yt(),u=vt();a(l.prototype,h.prototype),a(l,h);{let t=n(u.prototype);for(let e=0;e{var{ObjectSetPrototypeOf:r,Symbol:i}=J();e.exports=h;var{ERR_METHOD_NOT_IMPLEMENTED:n}=rt().codes,a=wt(),{getHighWaterMark:o}=mt();r(h.prototype,a.prototype),r(h,a);var s=i('kCallback');function h(t){if(!(this instanceof h))return new h(t);let e=t?o(this,t,'readableHighWaterMark',!0):null;0===e&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),a.call(this,t),this._readableState.sync=!1,this[s]=null,t&&('function'==typeof t.transform&&(this._transform=t.transform),'function'==typeof t.flush&&(this._flush=t.flush)),this.on('prefinish',l)}function u(t){'function'!=typeof this._flush||this.destroyed?(this.push(null),t&&t()):this._flush(((e,r)=>{e?t?t(e):this.destroy(e):(null!=r&&this.push(r),this.push(null),t&&t())}))}function l(){this._final!==u&&u.call(this)}h.prototype._final=u,h.prototype._transform=function(t,e,r){throw new n('_transform()')},h.prototype._write=function(t,e,r){let i=this._readableState,n=this._writableState,a=i.length;this._transform(t,e,((t,e)=>{t?r(t):(null!=e&&this.push(e),n.ended||a===i.length||i.length{var{ObjectSetPrototypeOf:r}=J();e.exports=n;var i=Mt();function n(t){if(!(this instanceof n))return new n(t);i.call(this,t)}r(n.prototype,i.prototype),r(n,i),n.prototype._transform=function(t,e,r){r(null,t)}})),Et=h(((t,e)=>{var r,i,n=(st(),d(at)),{ArrayIsArray:a,Promise:o,SymbolAsyncIterator:s}=J(),h=ut(),{once:u}=tt(),l=ft(),f=wt(),{aggregateTwoErrors:c,codes:{ERR_INVALID_ARG_TYPE:p,ERR_INVALID_RETURN_VALUE:m,ERR_MISSING_ARGS:g,ERR_STREAM_DESTROYED:y,ERR_STREAM_PREMATURE_CLOSE:v},AbortError:b}=rt(),{validateFunction:w,validateAbortSignal:M}=it(),{isIterable:_,isReadable:E,isReadableNodeStream:S,isNodeStream:C}=ht(),A=globalThis.AbortController||et().AbortController;function I(t,e,r){let i=!1;return t.on('close',(()=>{i=!0})),{destroy:e=>{i||(i=!0,l.destroyer(t,e||new y('pipe')))},cleanup:h(t,{readable:e,writable:r},(t=>{i=!t}))}}function T(t){if(_(t))return t;if(S(t))return async function*(t){i||(i=yt()),yield*i.prototype[s].call(t)}(t);throw new p('val',['Readable','Iterable','AsyncIterable'],t)}async function B(t,e,r,{end:i}){let n,a=null,s=t=>{if(t&&(n=t),a){let t=a;a=null,t()}},u=()=>new o(((t,e)=>{n?e(n):a=()=>{n?e(n):t()}}));e.on('drain',s);let l=h(e,{readable:!1},s);try{e.writableNeedDrain&&await u();for await(let r of t)e.write(r)||await u();i&&e.end(),await u(),r()}catch(t){r(n!==t?c(n,t):t)}finally{l(),e.off('drain',s)}}function k(t,e,i){if(1===t.length&&a(t[0])&&(t=t[0]),t.length<2)throw new g('streams');let o=new A,s=o.signal,h=i?.signal,u=[];function l(){N(new b)}M(h,'options.signal'),h?.addEventListener('abort',l);let c,d,y,v=[],w=0;function k(t){N(t,0==--w)}function N(t,r){if(t&&(!c||'ERR_STREAM_PREMATURE_CLOSE'===c.code)&&(c=t),c||r){for(;v.length;)v.shift()(c);h?.removeEventListener('abort',l),o.abort(),r&&(c||u.forEach((t=>t())),n.nextTick(e,c,d))}}for(let e=0;e0,l=o||!1!==i?.end,c=e===t.length-1;if(C(a)){let t=function(t){t&&'AbortError'!==t.name&&'ERR_STREAM_PREMATURE_CLOSE'!==t.code&&k(t)};if(l){let{destroy:t,cleanup:e}=I(a,o,h);v.push(t),E(a)&&c&&u.push(e)}a.on('error',t),E(a)&&c&&u.push((()=>{a.removeListener('error',t)}))}if(0===e)if('function'==typeof a){if(y=a({signal:s}),!_(y))throw new m('Iterable, AsyncIterable or Stream','source',y)}else y=_(a)||S(a)?a:f.from(a);else if('function'==typeof a)if(y=T(y),y=a(y,{signal:s}),o){if(!_(y,!0))throw new m('AsyncIterable',`transform[${e-1}]`,y)}else{var L;r||(r=_t());let t=new r({objectMode:!0}),e=null===(L=y)||void 0===L?void 0:L.then;if('function'==typeof e)w++,e.call(y,(e=>{d=e,null!=e&&t.write(e),l&&t.end(),n.nextTick(k)}),(e=>{t.destroy(e),n.nextTick(k,e)}));else{if(!_(y,!0))throw new m('AsyncIterable or Promise','destination',y);w++,B(y,t,k,{end:l})}y=t;let{destroy:i,cleanup:a}=I(y,!1,!0);v.push(i),c&&u.push(a)}else if(C(a)){if(S(y)){w+=2;let t=R(y,a,k,{end:l});E(a)&&c&&u.push(t)}else{if(!_(y))throw new p('val',['Readable','Iterable','AsyncIterable'],y);w++,B(y,a,k,{end:l})}y=a}else y=f.from(a)}return(null!=s&&s.aborted||null!=h&&h.aborted)&&n.nextTick(l),y}function R(t,e,r,{end:i}){let n=!1;return e.on('close',(()=>{n||r(new v)})),t.pipe(e,{end:i}),i?t.once('end',(()=>{n=!0,e.end()})):r(),h(t,{readable:!0,writable:!1},(e=>{let i=t._readableState;e&&'ERR_STREAM_PREMATURE_CLOSE'===e.code&&i&&i.ended&&!i.errored&&!i.errorEmitted?t.once('end',r).once('error',r):r(e)})),h(e,{readable:!1,writable:!0},r)}e.exports={pipelineImpl:k,pipeline:function(...t){return k(t,u(function(t){return w(t[t.length-1],'streams[stream.length - 1]'),t.pop()}(t)))}}})),St=h(((t,e)=>{var{pipeline:r}=Et(),i=wt(),{destroyer:n}=ft(),{isNodeStream:a,isReadable:o,isWritable:s}=ht(),{AbortError:h,codes:{ERR_INVALID_ARG_VALUE:u,ERR_MISSING_ARGS:l}}=rt();e.exports=function(...t){if(0===t.length)throw new l('streams');if(1===t.length)return i.from(t[0]);let e,f,c,d,p,m=[...t];if('function'==typeof t[0]&&(t[0]=i.from(t[0])),'function'==typeof t[t.length-1]){let e=t.length-1;t[e]=i.from(t[e])}for(let e=0;e0&&!s(t[e]))throw new u(`streams[${e}]`,m[e],'must be writable')}let g=t[0],y=r(t,(function(t){let e=d;d=null,e?e(t):t?p.destroy(t):!b&&!v&&p.destroy()})),v=!!s(g),b=!!o(y);return p=new i({writableObjectMode:!(null==g||!g.writableObjectMode),readableObjectMode:!(null==y||!y.writableObjectMode),writable:v,readable:b}),v&&(p._write=function(t,r,i){g.write(t,r)?i():e=i},p._final=function(t){g.end(),f=t},g.on('drain',(function(){if(e){let t=e;e=null,t()}})),y.on('finish',(function(){if(f){let t=f;f=null,t()}}))),b&&(y.on('readable',(function(){if(c){let t=c;c=null,t()}})),y.on('end',(function(){p.push(null)})),p._read=function(){for(;;){let t=y.read();if(null===t)return void(c=p._read);if(!p.push(t))return}}),p._destroy=function(t,r){!t&&null!==d&&(t=new h),c=null,e=null,f=null,null===d?r(t):(d=r,n(y,t))},p}})),Ct=h(((t,e)=>{var{ArrayPrototypePop:r,Promise:i}=J(),{isIterable:n,isNodeStream:a}=ht(),{pipelineImpl:o}=Et(),{finished:s}=ut();e.exports={finished:s,pipeline:function(...t){return new i(((e,i)=>{let s,h,u=t[t.length-1];if(u&&'object'==typeof u&&!a(u)&&!n(u)){let e=r(t);s=e.signal,h=e.end}o(t,((t,r)=>{t?i(t):e(r)}),{signal:s,end:h})}))}}})),At=h(((t,e)=>{var{Buffer:r}=g(),{ObjectDefineProperty:i,ObjectKeys:n,ReflectApply:a}=J(),{promisify:{custom:o}}=tt(),{streamReturningOperators:s,promiseReturningOperators:h}=lt(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:u}}=rt(),l=St(),{pipeline:f}=Et(),{destroyer:c}=ft(),d=ut(),p=Ct(),m=ht(),y=e.exports=ct().Stream;y.isDisturbed=m.isDisturbed,y.isErrored=m.isErrored,y.isReadable=m.isReadable,y.Readable=yt();for(let t of n(s)){let e=function(...t){if(new.target)throw u();return y.Readable.from(a(r,this,t))},r=s[t];i(e,'name',{__proto__:null,value:r.name}),i(e,'length',{__proto__:null,value:r.length}),i(y.Readable.prototype,t,{__proto__:null,value:e,enumerable:!1,configurable:!0,writable:!0})}for(let t of n(h)){let e=function(...t){if(new.target)throw u();return a(r,this,t)},r=h[t];i(e,'name',{__proto__:null,value:r.name}),i(e,'length',{__proto__:null,value:r.length}),i(y.Readable.prototype,t,{__proto__:null,value:e,enumerable:!1,configurable:!0,writable:!0})}y.Writable=vt(),y.Duplex=wt(),y.Transform=Mt(),y.PassThrough=_t(),y.pipeline=f;var{addAbortSignal:v}=dt();y.addAbortSignal=v,y.finished=d,y.destroy=c,y.compose=l,i(y,'promises',{__proto__:null,configurable:!0,enumerable:!0,get:()=>p}),i(f,o,{__proto__:null,enumerable:!0,get:()=>p.pipeline}),i(d,o,{__proto__:null,enumerable:!0,get:()=>p.finished}),y.Stream=y,y._isUint8Array=function(t){return t instanceof Uint8Array},y._uint8ArrayToBuffer=function(t){return r.from(t.buffer,t.byteOffset,t.byteLength)}})),It=h(((t,e)=>{var r=At(),i=Ct(),n=r.Readable.destroy;e.exports=r.Readable,e.exports._uint8ArrayToBuffer=r._uint8ArrayToBuffer,e.exports._isUint8Array=r._isUint8Array,e.exports.isDisturbed=r.isDisturbed,e.exports.isErrored=r.isErrored,e.exports.isReadable=r.isReadable,e.exports.Readable=r.Readable,e.exports.Writable=r.Writable,e.exports.Duplex=r.Duplex,e.exports.Transform=r.Transform,e.exports.PassThrough=r.PassThrough,e.exports.addAbortSignal=r.addAbortSignal,e.exports.finished=r.finished,e.exports.destroy=r.destroy,e.exports.destroy=n,e.exports.pipeline=r.pipeline,e.exports.compose=r.compose,Object.defineProperty(r,'promises',{configurable:!0,enumerable:!0,get:()=>i}),e.exports.Stream=r.Stream,e.exports.default=e.exports})),u(Tt={},{default:()=>Bt}),kt=s((()=>{f(Tt,c(It())),Bt=c(It())})),Rt=h(((t,e)=>{var r=y().Buffer,i=(kt(),d(Tt)).Transform,n=k().StringDecoder;function a(t){i.call(this),this.hashMode='string'==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}b()(a,i),a.prototype.update=function(t,e,i){'string'==typeof t&&(t=r.from(t,e));var n=this._update(t);return this.hashMode?this:(i&&(n=this._toString(n,i)),n)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error('trying to get auth tag in unsupported state')},a.prototype.setAuthTag=function(){throw new Error('trying to set auth tag in unsupported state')},a.prototype.setAAD=function(){throw new Error('trying to set aad in unsupported state')},a.prototype._transform=function(t,e,r){var i;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){i=t}finally{r(i)}},a.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},a.prototype._finalOrDigest=function(t){var e=this.__final()||r.alloc(0);return t&&(e=this._toString(e,t,!0)),e},a.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new n(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var i=this._decoder.write(t);return r&&(i+=this._decoder.end()),i},e.exports=a})),Nt=h(((t,e)=>{var r=b(),i=F(),n=H(),a=X(),o=Rt();function s(t){o.call(this,'digest'),this._hash=t}r(s,o),s.prototype._update=function(t){this._hash.update(t)},s.prototype._final=function(){return this._hash.digest()},e.exports=function(t){return'md5'===(t=t.toLowerCase())?new i:'rmd160'===t||'ripemd160'===t?new n:new s(a(t))}})),Lt=h(((t,e)=>{var r=b(),i=y().Buffer,n=Rt(),a=i.alloc(128),o=64;function s(t,e){n.call(this,'digest'),'string'==typeof e&&(e=i.from(e)),this._alg=t,this._key=e,e.length>o?e=t(e):e.length{var r=F();e.exports=function(t){return(new r).update(t).digest()}})),Dt=h(((t,e)=>{var r=b(),i=Lt(),n=Rt(),a=y().Buffer,o=xt(),s=H(),h=X(),u=a.alloc(128);function l(t,e){n.call(this,'digest'),'string'==typeof e&&(e=a.from(e));var r='sha512'===t||'sha384'===t?128:64;this._alg=t,this._key=e,e.length>r?e=('rmd160'===t?new s:h(t)).update(e).digest():e.length{e.exports={sha224WithRSAEncryption:{sign:'rsa',hash:'sha224',id:'302d300d06096086480165030402040500041c'},'RSA-SHA224':{sign:'ecdsa/rsa',hash:'sha224',id:'302d300d06096086480165030402040500041c'},sha256WithRSAEncryption:{sign:'rsa',hash:'sha256',id:'3031300d060960864801650304020105000420'},'RSA-SHA256':{sign:'ecdsa/rsa',hash:'sha256',id:'3031300d060960864801650304020105000420'},sha384WithRSAEncryption:{sign:'rsa',hash:'sha384',id:'3041300d060960864801650304020205000430'},'RSA-SHA384':{sign:'ecdsa/rsa',hash:'sha384',id:'3041300d060960864801650304020205000430'},sha512WithRSAEncryption:{sign:'rsa',hash:'sha512',id:'3051300d060960864801650304020305000440'},'RSA-SHA512':{sign:'ecdsa/rsa',hash:'sha512',id:'3051300d060960864801650304020305000440'},'RSA-SHA1':{sign:'rsa',hash:'sha1',id:'3021300906052b0e03021a05000414'},'ecdsa-with-SHA1':{sign:'ecdsa',hash:'sha1',id:''},sha256:{sign:'ecdsa',hash:'sha256',id:''},sha224:{sign:'ecdsa',hash:'sha224',id:''},sha384:{sign:'ecdsa',hash:'sha384',id:''},sha512:{sign:'ecdsa',hash:'sha512',id:''},'DSA-SHA':{sign:'dsa',hash:'sha1',id:''},'DSA-SHA1':{sign:'dsa',hash:'sha1',id:''},DSA:{sign:'dsa',hash:'sha1',id:''},'DSA-WITH-SHA224':{sign:'dsa',hash:'sha224',id:''},'DSA-SHA224':{sign:'dsa',hash:'sha224',id:''},'DSA-WITH-SHA256':{sign:'dsa',hash:'sha256',id:''},'DSA-SHA256':{sign:'dsa',hash:'sha256',id:''},'DSA-WITH-SHA384':{sign:'dsa',hash:'sha384',id:''},'DSA-SHA384':{sign:'dsa',hash:'sha384',id:''},'DSA-WITH-SHA512':{sign:'dsa',hash:'sha512',id:''},'DSA-SHA512':{sign:'dsa',hash:'sha512',id:''},'DSA-RIPEMD160':{sign:'dsa',hash:'rmd160',id:''},ripemd160WithRSA:{sign:'rsa',hash:'rmd160',id:'3021300906052b2403020105000414'},'RSA-RIPEMD160':{sign:'rsa',hash:'rmd160',id:'3021300906052b2403020105000414'},md5WithRSAEncryption:{sign:'rsa',hash:'md5',id:'3020300c06082a864886f70d020505000410'},'RSA-MD5':{sign:'rsa',hash:'md5',id:'3020300c06082a864886f70d020505000410'}}})),Pt=h(((t,e)=>{e.exports=Ut()})),Ot=h(((t,e)=>{var r=Math.pow(2,30)-1;e.exports=function(t,e){if('number'!=typeof t)throw new TypeError('Iterations not a number');if(t<0)throw new TypeError('Bad iterations');if('number'!=typeof e)throw new TypeError('Key length not a number');if(e<0||e>r||e!=e)throw new TypeError('Bad key length')}})),jt=h(((t,e)=>{var r;r=global.process&&global.process.browser?'utf-8':global.process&&global.process.version?parseInt(process.version.split('.')[0].slice(1),10)>=6?'utf-8':'binary':'utf-8',e.exports=r})),Vt=h(((t,e)=>{var r=y().Buffer;e.exports=function(t,e,i){if(r.isBuffer(t))return t;if('string'==typeof t)return r.from(t,e);if(ArrayBuffer.isView(t))return r.from(t.buffer);throw new TypeError(i+' must be a string, a Buffer, a typed array or a DataView')}})),qt=h(((t,e)=>{var r=xt(),i=H(),n=X(),a=y().Buffer,o=Ot(),s=jt(),h=Vt(),u=a.alloc(128),l={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function f(t,e,o){var s=function(t){function e(e){return n(t).update(e).digest()}function a(t){return(new i).update(t).digest()}return'rmd160'===t||'ripemd160'===t?a:'md5'===t?r:e}(t),h='sha512'===t||'sha384'===t?128:64;e.length>h?e=s(e):e.length{var r,i,n=y().Buffer,a=Ot(),o=jt(),s=qt(),h=Vt(),u=global.crypto&&global.crypto.subtle,l={sha:'SHA-1','sha-1':'SHA-1',sha1:'SHA-1',sha256:'SHA-256','sha-256':'SHA-256',sha384:'SHA-384','sha-384':'SHA-384','sha-512':'SHA-512',sha512:'SHA-512'},f=[];function c(){return i||(i=global.process&&global.process.nextTick?global.process.nextTick:global.queueMicrotask?global.queueMicrotask:global.setImmediate?global.setImmediate:global.setTimeout)}function d(t,e,r,i,a){return u.importKey('raw',t,{name:'PBKDF2'},!1,['deriveBits']).then((function(t){return u.deriveBits({name:'PBKDF2',salt:e,iterations:r,hash:{name:a}},t,i<<3)})).then((function(t){return n.from(t)}))}e.exports=function(t,e,i,p,m,g){'function'==typeof m&&(g=m,m=void 0);var y=l[(m=m||'sha1').toLowerCase()];if(y&&'function'==typeof global.Promise){if(a(i,p),t=h(t,o,'Password'),e=h(e,o,'Salt'),'function'!=typeof g)throw new Error('No callback provided to pbkdf2');!function(t,e){t.then((function(t){c()((function(){e(null,t)}))}),(function(t){c()((function(){e(t)}))}))}(function(t){if(global.process&&!global.process.browser||!u||!u.importKey||!u.deriveBits)return Promise.resolve(!1);if(void 0!==f[t])return f[t];var e=d(r=r||n.alloc(8),r,10,128,t).then((function(){return!0})).catch((function(){return!1}));return f[t]=e,e}(y).then((function(r){return r?d(t,e,i,p,y):s(t,e,i,p,m)})),g)}else c()((function(){var r;try{r=s(t,e,i,p,m)}catch(t){return g(t)}g(null,r)}))}})),Ft=h((t=>{t.pbkdf2=Kt(),t.pbkdf2Sync=qt()})),Ht=h((t=>{t.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},t.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},t.ip=function(t,e,r,i){for(var n=0,a=0,o=6;o>=0;o-=2){for(var s=0;s<=24;s+=8)n<<=1,n|=e>>>s+o&1;for(s=0;s<=24;s+=8)n<<=1,n|=t>>>s+o&1}for(o=6;o>=0;o-=2){for(s=1;s<=25;s+=8)a<<=1,a|=e>>>s+o&1;for(s=1;s<=25;s+=8)a<<=1,a|=t>>>s+o&1}r[i+0]=n>>>0,r[i+1]=a>>>0},t.rip=function(t,e,r,i){for(var n=0,a=0,o=0;o<4;o++)for(var s=24;s>=0;s-=8)n<<=1,n|=e>>>s+o&1,n<<=1,n|=t>>>s+o&1;for(o=4;o<8;o++)for(s=24;s>=0;s-=8)a<<=1,a|=e>>>s+o&1,a<<=1,a|=t>>>s+o&1;r[i+0]=n>>>0,r[i+1]=a>>>0},t.pc1=function(t,e,r,i){for(var n=0,a=0,o=7;o>=5;o--){for(var s=0;s<=24;s+=8)n<<=1,n|=e>>s+o&1;for(s=0;s<=24;s+=8)n<<=1,n|=t>>s+o&1}for(s=0;s<=24;s+=8)n<<=1,n|=e>>s+o&1;for(o=1;o<=3;o++){for(s=0;s<=24;s+=8)a<<=1,a|=e>>s+o&1;for(s=0;s<=24;s+=8)a<<=1,a|=t>>s+o&1}for(s=0;s<=24;s+=8)a<<=1,a|=t>>s+o&1;r[i+0]=n>>>0,r[i+1]=a>>>0},t.r28shl=function(t,e){return t<>>28-e};var e=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];t.pc2=function(t,r,i,n){for(var a=0,o=0,s=e.length>>>1,h=0;h>>e[h]&1;for(h=s;h>>e[h]&1;i[n+0]=a>>>0,i[n+1]=o>>>0},t.expand=function(t,e,r){var i=0,n=0;i=(1&t)<<5|t>>>27;for(var a=23;a>=15;a-=4)i<<=6,i|=t>>>a&63;for(a=11;a>=3;a-=4)n|=t>>>a&63,n<<=6;n|=(31&t)<<1|t>>>31,e[r+0]=i>>>0,e[r+1]=n>>>0};var r=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];t.substitute=function(t,e){for(var i=0,n=0;n<4;n++)i<<=4,i|=r[64*n+(t>>>18-6*n&63)];for(n=0;n<4;n++)i<<=4,i|=r[256+64*n+(e>>>18-6*n&63)];return i>>>0};var i=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];t.permute=function(t){for(var e=0,r=0;r>>i[r]&1;return e>>>0},t.padSplit=function(t,e,r){for(var i=t.toString(2);i.length{function r(t,e){if(!t)throw new Error(e||'Assertion failed')}e.exports=r,r.equal=function(t,e,r){if(t!=e)throw new Error(r||'Assertion failed: '+t+' != '+e)}})),Gt=h(((t,e)=>{var r=zt();function i(t){this.options=t,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}e.exports=i,i.prototype._init=function(){},i.prototype.update=function(t){return 0===t.length?[]:'decrypt'===this.type?this._updateDecrypt(t):this._updateEncrypt(t)},i.prototype._buffer=function(t,e){for(var r=Math.min(this.buffer.length-this.bufferOff,t.length-e),i=0;i0;i--)e+=this._buffer(t,e),r+=this._flushBuffer(n,r);return e+=this._buffer(t,e),n},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r='encrypt'===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e{var r=zt(),i=b(),n=Ht(),a=Gt();function o(){this.tmp=new Array(2),this.keys=null}function s(t){a.call(this,t);var e=new o;this._desState=e,this.deriveKeys(e,t.key)}i(s,a),e.exports=s,s.create=function(t){return new s(t)};var h=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];s.prototype.deriveKeys=function(t,e){t.keys=new Array(32),r.equal(e.length,this.blockSize,'Invalid key length');var i=n.readUInt32BE(e,0),a=n.readUInt32BE(e,4);n.pc1(i,a,t.tmp,0),i=t.tmp[0],a=t.tmp[1];for(var o=0;o>>1];i=n.r28shl(i,s),a=n.r28shl(a,s),n.pc2(i,a,t.keys,o)}},s.prototype._update=function(t,e,r,i){var a=this._desState,o=n.readUInt32BE(t,e),s=n.readUInt32BE(t,e+4);n.ip(o,s,a.tmp,0),o=a.tmp[0],s=a.tmp[1],'encrypt'===this.type?this._encrypt(a,o,s,a.tmp,0):this._decrypt(a,o,s,a.tmp,0),o=a.tmp[0],s=a.tmp[1],n.writeUInt32BE(r,o,i),n.writeUInt32BE(r,s,i+4)},s.prototype._pad=function(t,e){for(var r=t.length-e,i=e;i>>0,o=c}n.rip(s,o,i,a)},s.prototype._decrypt=function(t,e,r,i,a){for(var o=r,s=e,h=t.keys.length-2;h>=0;h-=2){var u=t.keys[h],l=t.keys[h+1];n.expand(o,t.tmp,0),u^=t.tmp[0],l^=t.tmp[1];var f=n.substitute(u,l),c=o;o=(s^n.permute(f))>>>0,s=c}n.rip(o,s,i,a)}})),Zt=h((t=>{var e=zt(),r=b(),i={};function n(t){e.equal(t.length,8,'Invalid IV length'),this.iv=new Array(8);for(var r=0;r{var r=zt(),i=b(),n=Gt(),a=Wt();function o(t,e){r.equal(e.length,24,'Invalid key length');var i=e.slice(0,8),n=e.slice(8,16),o=e.slice(16,24);this.ciphers='encrypt'===t?[a.create({type:'encrypt',key:i}),a.create({type:'decrypt',key:n}),a.create({type:'encrypt',key:o})]:[a.create({type:'decrypt',key:o}),a.create({type:'encrypt',key:n}),a.create({type:'decrypt',key:i})]}function s(t){n.call(this,t);var e=new o(this.type,this.options.key);this._edeState=e}i(s,n),e.exports=s,s.create=function(t){return new s(t)},s.prototype._update=function(t,e,r,i){var n=this._edeState;n.ciphers[0]._update(t,e,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},s.prototype._pad=a.prototype._pad,s.prototype._unpad=a.prototype._unpad})),$t=h((t=>{t.utils=Ht(),t.Cipher=Gt(),t.DES=Wt(),t.CBC=Zt(),t.EDE=Yt()})),Qt=h(((t,e)=>{var r=Rt(),i=$t(),n=b(),a=y().Buffer,o={'des-ede3-cbc':i.CBC.instantiate(i.EDE),'des-ede3':i.EDE,'des-ede-cbc':i.CBC.instantiate(i.EDE),'des-ede':i.EDE,'des-cbc':i.CBC.instantiate(i.DES),'des-ecb':i.DES};function s(t){r.call(this);var e,i=t.mode.toLowerCase(),n=o[i];e=t.decrypt?'decrypt':'encrypt';var s=t.key;a.isBuffer(s)||(s=a.from(s)),('des-ede'===i||'des-ede-cbc'===i)&&(s=a.concat([s,s.slice(0,8)]));var h=t.iv;a.isBuffer(h)||(h=a.from(h)),this._des=n.create({key:s,iv:h,type:e})}o.des=o['des-cbc'],o.des3=o['des-ede3-cbc'],e.exports=s,n(s,r),s.prototype._update=function(t){return a.from(this._des.update(t))},s.prototype._final=function(){return a.from(this._des.final())}})),Xt=h((t=>{t.encrypt=function(t,e){return t._cipher.encryptBlock(e)},t.decrypt=function(t,e){return t._cipher.decryptBlock(e)}})),Jt=h(((t,e)=>{e.exports=function(t,e){for(var r=Math.min(t.length,e.length),i=new Buffer(r),n=0;n{var e=Jt();t.encrypt=function(t,r){var i=e(r,t._prev);return t._prev=t._cipher.encryptBlock(i),t._prev},t.decrypt=function(t,r){var i=t._prev;t._prev=r;var n=t._cipher.decryptBlock(r);return e(n,i)}})),ee=h((t=>{var e=y().Buffer,r=Jt();function i(t,i,n){var a=i.length,o=r(i,t._cache);return t._cache=t._cache.slice(a),t._prev=e.concat([t._prev,n?i:o]),o}t.encrypt=function(t,r,n){for(var a,o=e.allocUnsafe(0);r.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=e.allocUnsafe(0)),!(t._cache.length<=r.length)){o=e.concat([o,i(t,r,n)]);break}a=t._cache.length,o=e.concat([o,i(t,r.slice(0,a),n)]),r=r.slice(a)}return o}})),re=h((t=>{var e=y().Buffer;function r(t,r,i){var n=t._cipher.encryptBlock(t._prev)[0]^r;return t._prev=e.concat([t._prev.slice(1),e.from([i?r:n])]),n}t.encrypt=function(t,i,n){for(var a=i.length,o=e.allocUnsafe(a),s=-1;++s{var e=y().Buffer;function r(t,e,r){for(var n,a,o=-1,s=0;++o<8;)n=e&1<<7-o?128:0,s+=(128&(a=t._cipher.encryptBlock(t._prev)[0]^n))>>o%8,t._prev=i(t._prev,r?n:a);return s}function i(t,r){var i=t.length,n=-1,a=e.allocUnsafe(t.length);for(t=e.concat([t,e.from([r])]);++n>7;return a}t.encrypt=function(t,i,n){for(var a=i.length,o=e.allocUnsafe(a),s=-1;++s{var e=Jt();function r(t){return t._prev=t._cipher.encryptBlock(t._prev),t._prev}t.encrypt=function(t,i){for(;t._cache.length{e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}})),oe=h((t=>{var e=Jt(),r=y().Buffer,i=ae();function n(t){var e=t._cipher.encryptBlockRaw(t._prev);return i(t._prev),e}t.encrypt=function(t,i){var a=Math.ceil(i.length/16),o=t._cache.length;t._cache=r.concat([t._cache,r.allocUnsafe(16*a)]);for(var s=0;s{e.exports={'aes-128-ecb':{cipher:'AES',key:128,iv:0,mode:'ECB',type:'block'},'aes-192-ecb':{cipher:'AES',key:192,iv:0,mode:'ECB',type:'block'},'aes-256-ecb':{cipher:'AES',key:256,iv:0,mode:'ECB',type:'block'},'aes-128-cbc':{cipher:'AES',key:128,iv:16,mode:'CBC',type:'block'},'aes-192-cbc':{cipher:'AES',key:192,iv:16,mode:'CBC',type:'block'},'aes-256-cbc':{cipher:'AES',key:256,iv:16,mode:'CBC',type:'block'},aes128:{cipher:'AES',key:128,iv:16,mode:'CBC',type:'block'},aes192:{cipher:'AES',key:192,iv:16,mode:'CBC',type:'block'},aes256:{cipher:'AES',key:256,iv:16,mode:'CBC',type:'block'},'aes-128-cfb':{cipher:'AES',key:128,iv:16,mode:'CFB',type:'stream'},'aes-192-cfb':{cipher:'AES',key:192,iv:16,mode:'CFB',type:'stream'},'aes-256-cfb':{cipher:'AES',key:256,iv:16,mode:'CFB',type:'stream'},'aes-128-cfb8':{cipher:'AES',key:128,iv:16,mode:'CFB8',type:'stream'},'aes-192-cfb8':{cipher:'AES',key:192,iv:16,mode:'CFB8',type:'stream'},'aes-256-cfb8':{cipher:'AES',key:256,iv:16,mode:'CFB8',type:'stream'},'aes-128-cfb1':{cipher:'AES',key:128,iv:16,mode:'CFB1',type:'stream'},'aes-192-cfb1':{cipher:'AES',key:192,iv:16,mode:'CFB1',type:'stream'},'aes-256-cfb1':{cipher:'AES',key:256,iv:16,mode:'CFB1',type:'stream'},'aes-128-ofb':{cipher:'AES',key:128,iv:16,mode:'OFB',type:'stream'},'aes-192-ofb':{cipher:'AES',key:192,iv:16,mode:'OFB',type:'stream'},'aes-256-ofb':{cipher:'AES',key:256,iv:16,mode:'OFB',type:'stream'},'aes-128-ctr':{cipher:'AES',key:128,iv:16,mode:'CTR',type:'stream'},'aes-192-ctr':{cipher:'AES',key:192,iv:16,mode:'CTR',type:'stream'},'aes-256-ctr':{cipher:'AES',key:256,iv:16,mode:'CTR',type:'stream'},'aes-128-gcm':{cipher:'AES',key:128,iv:12,mode:'GCM',type:'auth'},'aes-192-gcm':{cipher:'AES',key:192,iv:12,mode:'GCM',type:'auth'},'aes-256-gcm':{cipher:'AES',key:256,iv:12,mode:'GCM',type:'auth'}}})),he=h(((t,e)=>{var r,i={ECB:Xt(),CBC:te(),CFB:ee(),CFB8:re(),CFB1:ie(),OFB:ne(),CTR:oe(),GCM:oe()},n=se();for(r in n)n[r].module=i[n[r].mode];e.exports=n})),ue=h(((t,e)=>{var r=y().Buffer;function i(t){r.isBuffer(t)||(t=r.from(t));for(var e=t.length/4|0,i=new Array(e),n=0;n>>24]^l[p>>>16&255]^f[m>>>8&255]^c[255&g]^e[y++],o=u[p>>>24]^l[m>>>16&255]^f[g>>>8&255]^c[255&d]^e[y++],s=u[m>>>24]^l[g>>>16&255]^f[d>>>8&255]^c[255&p]^e[y++],h=u[g>>>24]^l[d>>>16&255]^f[p>>>8&255]^c[255&m]^e[y++],d=a,p=o,m=s,g=h;return a=(i[d>>>24]<<24|i[p>>>16&255]<<16|i[m>>>8&255]<<8|i[255&g])^e[y++],o=(i[p>>>24]<<24|i[m>>>16&255]<<16|i[g>>>8&255]<<8|i[255&d])^e[y++],s=(i[m>>>24]<<24|i[g>>>16&255]<<16|i[d>>>8&255]<<8|i[255&p])^e[y++],h=(i[g>>>24]<<24|i[d>>>16&255]<<16|i[p>>>8&255]<<8|i[255&m])^e[y++],[a>>>=0,o>>>=0,s>>>=0,h>>>=0]}var o=[0,1,2,4,8,16,32,64,128,27,54],s=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],i=[],n=[[],[],[],[]],a=[[],[],[],[]],o=0,s=0,h=0;h<256;++h){var u=s^s<<1^s<<2^s<<3^s<<4;u=u>>>8^255&u^99,r[o]=u,i[u]=o;var l=t[o],f=t[l],c=t[f],d=257*t[u]^16843008*u;n[0][o]=d<<24|d>>>8,n[1][o]=d<<16|d>>>16,n[2][o]=d<<8|d>>>24,n[3][o]=d,d=16843009*c^65537*f^257*l^16843008*o,a[0][u]=d<<24|d>>>8,a[1][u]=d<<16|d>>>16,a[2][u]=d<<8|d>>>24,a[3][u]=d,0===o?o=s=1:(o=l^t[t[t[c^l]]],s^=t[t[s]])}return{SBOX:r,INV_SBOX:i,SUB_MIX:n,INV_SUB_MIX:a}}();function h(t){this._key=i(t),this._reset()}h.blockSize=16,h.keySize=32,h.prototype.blockSize=h.blockSize,h.prototype.keySize=h.keySize,h.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,i=4*(r+1),n=[],a=0;a>>24,h=s.SBOX[h>>>24]<<24|s.SBOX[h>>>16&255]<<16|s.SBOX[h>>>8&255]<<8|s.SBOX[255&h],h^=o[a/e|0]<<24):e>6&&a%e==4&&(h=s.SBOX[h>>>24]<<24|s.SBOX[h>>>16&255]<<16|s.SBOX[h>>>8&255]<<8|s.SBOX[255&h]),n[a]=n[a-e]^h}for(var u=[],l=0;l>>24]]^s.INV_SUB_MIX[1][s.SBOX[c>>>16&255]]^s.INV_SUB_MIX[2][s.SBOX[c>>>8&255]]^s.INV_SUB_MIX[3][s.SBOX[255&c]]}this._nRounds=r,this._keySchedule=n,this._invKeySchedule=u},h.prototype.encryptBlockRaw=function(t){return a(t=i(t),this._keySchedule,s.SUB_MIX,s.SBOX,this._nRounds)},h.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),i=r.allocUnsafe(16);return i.writeUInt32BE(e[0],0),i.writeUInt32BE(e[1],4),i.writeUInt32BE(e[2],8),i.writeUInt32BE(e[3],12),i},h.prototype.decryptBlock=function(t){var e=(t=i(t))[1];t[1]=t[3],t[3]=e;var n=a(t,this._invKeySchedule,s.INV_SUB_MIX,s.INV_SBOX,this._nRounds),o=r.allocUnsafe(16);return o.writeUInt32BE(n[0],0),o.writeUInt32BE(n[3],4),o.writeUInt32BE(n[2],8),o.writeUInt32BE(n[1],12),o},h.prototype.scrub=function(){n(this._keySchedule),n(this._invKeySchedule),n(this._key)},e.exports.AES=h})),le=h(((t,e)=>{var r=y().Buffer,i=r.alloc(16,0);function n(t){var e=r.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function a(t){this.h=t,this.state=r.alloc(16,0),this.cache=r.allocUnsafe(0)}a.prototype.ghash=function(t){for(var e=-1;++e0;t--)r[t]=r[t]>>>1|(1&r[t-1])<<31;r[0]=r[0]>>>1,e&&(r[0]=r[0]^225<<24)}this.state=n(i)},a.prototype.update=function(t){this.cache=r.concat([this.cache,t]);for(var e;this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},a.prototype.final=function(t,e){return this.cache.length&&this.ghash(r.concat([this.cache,i],16)),this.ghash(n([0,t,0,e])),this.state},e.exports=a})),fe=h(((t,e)=>{var r=ue(),i=y().Buffer,n=Rt(),a=b(),o=le(),s=Jt(),h=ae();function u(t,e,a,s){n.call(this);var u=i.alloc(4,0);this._cipher=new r.AES(e);var l=this._cipher.encryptBlock(u);this._ghash=new o(l),a=function(t,e,r){if(12===e.length)return t._finID=i.concat([e,i.from([0,0,0,1])]),i.concat([e,i.from([0,0,0,2])]);var n=new o(r),a=e.length,s=a%16;n.update(e),s&&(s=16-s,n.update(i.alloc(s,0))),n.update(i.alloc(8,0));var u=8*a,l=i.alloc(8);l.writeUIntBE(u,0,8),n.update(l),t._finID=n.state;var f=i.from(t._finID);return h(f),f}(this,a,l),this._prev=i.from(a),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=s,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}a(u,n),u.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=i.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},u.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error('Unsupported state or unable to authenticate data');var t=s(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var i=Math.min(t.length,e.length),n=0;n{var r=ue(),i=y().Buffer,n=Rt();function a(t,e,a,o){n.call(this),this._cipher=new r.AES(e),this._prev=i.from(a),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._mode=t}b()(a,n),a.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)},a.prototype._final=function(){this._cipher.scrub()},e.exports=a})),de=h(((t,e)=>{var r=y().Buffer,i=F();e.exports=function(t,e,n,a){if(r.isBuffer(t)||(t=r.from(t,'binary')),e&&(r.isBuffer(e)||(e=r.from(e,'binary')),8!==e.length))throw new RangeError('salt should be Buffer with 8 byte length');for(var o=n/8,s=r.alloc(o),h=r.alloc(a||0),u=r.alloc(0);o>0||a>0;){var l=new i;l.update(u),l.update(t),e&&l.update(e),u=l.digest();var f=0;if(o>0){var c=s.length-o;f=Math.min(o,u.length),u.copy(s,c,0,f),o-=f}if(f0){var d=h.length-a,p=Math.min(a,u.length-f);u.copy(h,d,f,f+p),a-=p}}return u.fill(0),{key:s,iv:h}}})),pe=h((t=>{var e=he(),r=fe(),i=y().Buffer,n=ce(),a=Rt(),o=ue(),s=de();function h(t,e,r){a.call(this),this._cache=new l,this._cipher=new o.AES(e),this._prev=i.from(r),this._mode=t,this._autopadding=!0}b()(h,a),h.prototype._update=function(t){this._cache.add(t);for(var e,r,n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return i.concat(n)};var u=i.alloc(16,16);function l(){this.cache=i.allocUnsafe(0)}function f(t,a,o){var s=e[t.toLowerCase()];if(!s)throw new TypeError('invalid suite type');if('string'==typeof a&&(a=i.from(a)),a.length!==s.key/8)throw new TypeError('invalid key length '+a.length);if('string'==typeof o&&(o=i.from(o)),'GCM'!==s.mode&&o.length!==s.iv)throw new TypeError('invalid iv length '+o.length);return'stream'===s.type?new n(s.module,a,o):'auth'===s.type?new r(s.module,a,o):new h(s.module,a,o)}h.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(u))throw this._cipher.scrub(),new Error('data not multiple of block length')},h.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},l.prototype.add=function(t){this.cache=i.concat([this.cache,t])},l.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},l.prototype.flush=function(){for(var t=16-this.cache.length,e=i.allocUnsafe(t),r=-1;++r{var e=fe(),r=y().Buffer,i=he(),n=ce(),a=Rt(),o=ue(),s=de();function h(t,e,i){a.call(this),this._cache=new u,this._last=void 0,this._cipher=new o.AES(e),this._prev=r.from(i),this._mode=t,this._autopadding=!0}function u(){this.cache=r.allocUnsafe(0)}function l(t,a,o){var s=i[t.toLowerCase()];if(!s)throw new TypeError('invalid suite type');if('string'==typeof o&&(o=r.from(o)),'GCM'!==s.mode&&o.length!==s.iv)throw new TypeError('invalid iv length '+o.length);if('string'==typeof a&&(a=r.from(a)),a.length!==s.key/8)throw new TypeError('invalid key length '+a.length);return'stream'===s.type?new n(s.module,a,o,!0):'auth'===s.type?new e(s.module,a,o,!0):new h(s.module,a,o)}b()(h,a),h.prototype._update=function(t){this._cache.add(t);for(var e,i,n=[];e=this._cache.get(this._autopadding);)i=this._mode.decrypt(this,e),n.push(i);return r.concat(n)},h.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return function(t){var e=t[15];if(e<1||e>16)throw new Error('unable to decrypt data');for(var r=-1;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},u.prototype.flush=function(){if(this.cache.length)return this.cache},t.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError('invalid suite type');var n=s(e,!1,r.key,r.iv);return l(t,n.key,n.iv)},t.createDecipheriv=l})),ge=h((t=>{var e=pe(),r=me(),i=se();t.createCipher=t.Cipher=e.createCipher,t.createCipheriv=t.Cipheriv=e.createCipheriv,t.createDecipher=t.Decipher=r.createDecipher,t.createDecipheriv=t.Decipheriv=r.createDecipheriv,t.listCiphers=t.getCiphers=function(){return Object.keys(i)}})),ye=h((t=>{t['des-ecb']={key:8,iv:0},t['des-cbc']=t.des={key:8,iv:8},t['des-ede3-cbc']=t.des3={key:24,iv:8},t['des-ede3']={key:24,iv:0},t['des-ede-cbc']={key:16,iv:8},t['des-ede']={key:16,iv:0}})),ve=h((t=>{var e=Qt(),r=ge(),i=he(),n=ye(),a=de();function o(t,a,o){if(t=t.toLowerCase(),i[t])return r.createCipheriv(t,a,o);if(n[t])return new e({key:a,iv:o,mode:t});throw new TypeError('invalid suite type')}function s(t,a,o){if(t=t.toLowerCase(),i[t])return r.createDecipheriv(t,a,o);if(n[t])return new e({key:a,iv:o,mode:t,decrypt:!0});throw new TypeError('invalid suite type')}t.createCipher=t.Cipher=function(t,e){var r,s;if(t=t.toLowerCase(),i[t])r=i[t].key,s=i[t].iv;else{if(!n[t])throw new TypeError('invalid suite type');r=8*n[t].key,s=n[t].iv}var h=a(e,!1,r,s);return o(t,h.key,h.iv)},t.createCipheriv=t.Cipheriv=o,t.createDecipher=t.Decipher=function(t,e){var r,o;if(t=t.toLowerCase(),i[t])r=i[t].key,o=i[t].iv;else{if(!n[t])throw new TypeError('invalid suite type');r=8*n[t].key,o=n[t].iv}var h=a(e,!1,r,o);return s(t,h.key,h.iv)},t.createDecipheriv=t.Decipheriv=s,t.listCiphers=t.getCiphers=function(){return Object.keys(n).concat(r.getCiphers())}})),be=h((()=>{})),we=h(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var a;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{a=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:be().Buffer}catch{}function o(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if('le'===i)for(n=0,a=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=s(t,e,i)<=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var a=t.length-r,o=a%i,s=Math.min(a,a-o)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.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'],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],a=0|e.words[0],o=n*a,s=67108863&o,h=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(a=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,a=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,o--)}for(0!==a&&(i=a.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);i=(p=p.idivn(d)).isZero()?m+i:u[c-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof a<'u'),this.toArrayLike(a,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),a=i||Math.max(1,n);r(n<=a,'byte array longer than desired length'),r(a>0,'Requested array length <= 0'),this.strip();var o,s,h='le'===e,u=new t(a),l=this.clone();if(h){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,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(;at.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,M=b>>>13,_=0|o[4],E=8191&_,S=_>>>13,C=0|o[5],A=8191&C,I=C>>>13,T=0|o[6],B=8191&T,k=T>>>13,R=0|o[7],N=8191&R,L=R>>>13,x=0|o[8],D=8191&x,U=x>>>13,P=0|o[9],O=8191&P,j=P>>>13,V=0|s[0],q=8191&V,K=V>>>13,F=0|s[1],H=8191&F,z=F>>>13,G=0|s[2],W=8191&G,Z=G>>>13,Y=0|s[3],$=8191&Y,Q=Y>>>13,X=0|s[4],J=8191&X,tt=X>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],at=8191&nt,ot=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ft=8191<,ct=lt>>>13,dt=0|s[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(f,q))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(c,q)|0))<<13)|0;u=((a=Math.imul(c,K))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,q),n=(n=Math.imul(p,K))+Math.imul(m,q)|0,a=Math.imul(m,K);var yt=(u+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,z)|0)+Math.imul(c,H)|0))<<13)|0;u=((a=a+Math.imul(c,z)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,q),n=(n=Math.imul(y,K))+Math.imul(v,q)|0,a=Math.imul(v,K),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,H)|0,a=a+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(f,W)|0)|0)+((8191&(n=(n=n+Math.imul(f,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((a=a+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(w,q),n=(n=Math.imul(w,K))+Math.imul(M,q)|0,a=Math.imul(M,K),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(v,H)|0,a=a+Math.imul(v,z)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,a=a+Math.imul(m,Z)|0;var bt=(u+(i=i+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,Q)|0)+Math.imul(c,$)|0))<<13)|0;u=((a=a+Math.imul(c,Q)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(E,q),n=(n=Math.imul(E,K))+Math.imul(S,q)|0,a=Math.imul(S,K),i=i+Math.imul(w,H)|0,n=(n=n+Math.imul(w,z)|0)+Math.imul(M,H)|0,a=a+Math.imul(M,z)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(v,W)|0,a=a+Math.imul(v,Z)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(m,$)|0,a=a+Math.imul(m,Q)|0;var wt=(u+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(c,J)|0))<<13)|0;u=((a=a+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,q),n=(n=Math.imul(A,K))+Math.imul(I,q)|0,a=Math.imul(I,K),i=i+Math.imul(E,H)|0,n=(n=n+Math.imul(E,z)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,z)|0,i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(M,W)|0,a=a+Math.imul(M,Z)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(v,$)|0,a=a+Math.imul(v,Q)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,a=a+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((a=a+Math.imul(c,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(B,q),n=(n=Math.imul(B,K))+Math.imul(k,q)|0,a=Math.imul(k,K),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,z)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,z)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,Z)|0,i=i+Math.imul(w,$)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(M,$)|0,a=a+Math.imul(M,Q)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,a=a+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,a=a+Math.imul(m,it)|0;var _t=(u+(i=i+Math.imul(f,at)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(c,at)|0))<<13)|0;u=((a=a+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,K))+Math.imul(L,q)|0,a=Math.imul(L,K),i=i+Math.imul(B,H)|0,n=(n=n+Math.imul(B,z)|0)+Math.imul(k,H)|0,a=a+Math.imul(k,z)|0,i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,Z)|0)+Math.imul(I,W)|0,a=a+Math.imul(I,Z)|0,i=i+Math.imul(E,$)|0,n=(n=n+Math.imul(E,Q)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,Q)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,J)|0,a=a+Math.imul(M,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,a=a+Math.imul(v,it)|0,i=i+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,at)|0,a=a+Math.imul(m,ot)|0;var Et=(u+(i=i+Math.imul(f,ht)|0)|0)+((8191&(n=(n=n+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((a=a+Math.imul(c,ut)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,q),n=(n=Math.imul(D,K))+Math.imul(U,q)|0,a=Math.imul(U,K),i=i+Math.imul(N,H)|0,n=(n=n+Math.imul(N,z)|0)+Math.imul(L,H)|0,a=a+Math.imul(L,z)|0,i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(k,W)|0,a=a+Math.imul(k,Z)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,Q)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,Q)|0,i=i+Math.imul(E,J)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,it)|0,i=i+Math.imul(y,at)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(v,at)|0,a=a+Math.imul(v,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,a=a+Math.imul(m,ut)|0;var St=(u+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((a=a+Math.imul(c,ct)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(O,q),n=(n=Math.imul(O,K))+Math.imul(j,q)|0,a=Math.imul(j,K),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(U,H)|0,a=a+Math.imul(U,z)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Z)|0)+Math.imul(L,W)|0,a=a+Math.imul(L,Z)|0,i=i+Math.imul(B,$)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(k,$)|0,a=a+Math.imul(k,Q)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,J)|0,a=a+Math.imul(I,tt)|0,i=i+Math.imul(E,rt)|0,n=(n=n+Math.imul(E,it)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,it)|0,i=i+Math.imul(w,at)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,a=a+Math.imul(v,ut)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,a=a+Math.imul(m,ct)|0;var Ct=(u+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((a=a+Math.imul(c,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(O,H),n=(n=Math.imul(O,z))+Math.imul(j,H)|0,a=Math.imul(j,z),i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,Z)|0)+Math.imul(U,W)|0,a=a+Math.imul(U,Z)|0,i=i+Math.imul(N,$)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(L,$)|0,a=a+Math.imul(L,Q)|0,i=i+Math.imul(B,J)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(k,J)|0,a=a+Math.imul(k,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,it)|0,i=i+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,a=a+Math.imul(M,ut)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,a=a+Math.imul(v,ct)|0;var At=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((a=a+Math.imul(m,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,W),n=(n=Math.imul(O,Z))+Math.imul(j,W)|0,a=Math.imul(j,Z),i=i+Math.imul(D,$)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(U,$)|0,a=a+Math.imul(U,Q)|0,i=i+Math.imul(N,J)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(L,J)|0,a=a+Math.imul(L,tt)|0,i=i+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,it)|0)+Math.imul(k,rt)|0,a=a+Math.imul(k,it)|0,i=i+Math.imul(A,at)|0,n=(n=n+Math.imul(A,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,i=i+Math.imul(E,ht)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(S,ht)|0,a=a+Math.imul(S,ut)|0,i=i+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ct)|0;var It=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((a=a+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,Q))+Math.imul(j,$)|0,a=Math.imul(j,Q),i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(U,J)|0,a=a+Math.imul(U,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(L,rt)|0,a=a+Math.imul(L,it)|0,i=i+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(k,at)|0,a=a+Math.imul(k,ot)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(I,ht)|0,a=a+Math.imul(I,ut)|0,i=i+Math.imul(E,ft)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(S,ft)|0,a=a+Math.imul(S,ct)|0;var Tt=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((a=a+Math.imul(M,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(O,J),n=(n=Math.imul(O,tt))+Math.imul(j,J)|0,a=Math.imul(j,tt),i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(U,rt)|0,a=a+Math.imul(U,it)|0,i=i+Math.imul(N,at)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(L,at)|0,a=a+Math.imul(L,ot)|0,i=i+Math.imul(B,ht)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(k,ht)|0,a=a+Math.imul(k,ut)|0,i=i+Math.imul(A,ft)|0,n=(n=n+Math.imul(A,ct)|0)+Math.imul(I,ft)|0,a=a+Math.imul(I,ct)|0;var Bt=(u+(i=i+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((a=a+Math.imul(S,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(O,rt),n=(n=Math.imul(O,it))+Math.imul(j,rt)|0,a=Math.imul(j,it),i=i+Math.imul(D,at)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(U,at)|0,a=a+Math.imul(U,ot)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(L,ht)|0,a=a+Math.imul(L,ut)|0,i=i+Math.imul(B,ft)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(k,ft)|0,a=a+Math.imul(k,ct)|0;var kt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((a=a+Math.imul(I,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(O,at),n=(n=Math.imul(O,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(U,ht)|0,a=a+Math.imul(U,ut)|0,i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(L,ft)|0,a=a+Math.imul(L,ct)|0;var Rt=(u+(i=i+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((a=a+Math.imul(k,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(O,ht),n=(n=Math.imul(O,ut))+Math.imul(j,ht)|0,a=Math.imul(j,ut),i=i+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,ct)|0)+Math.imul(U,ft)|0,a=a+Math.imul(U,ct)|0;var Nt=(u+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,mt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((a=a+Math.imul(L,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(O,ft),n=(n=Math.imul(O,ct))+Math.imul(j,ft)|0,a=Math.imul(j,ct);var Lt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((a=a+Math.imul(U,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var xt=(u+(i=Math.imul(O,pt))|0)+((8191&(n=(n=Math.imul(O,mt))+Math.imul(j,pt)|0))<<13)|0;return u=((a=Math.imul(j,mt))+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=Et,h[8]=St,h[9]=Ct,h[10]=At,h[11]=It,h[12]=Tt,h[13]=Bt,h[14]=kt,h[15]=Rt,h[16]=Nt,h[17]=Lt,h[18]=xt,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?c(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,i=o,o=n}return 0!==i?r.words[a]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,a){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=n/67108864|0,e+=a>>>26,this.words[i]=67108863&a}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,a=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(e=0;e>>26-i}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=n);u--){var f=0|this.words[u];this.words[u]=l<<26-a|f>>>a,l=f&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n>26,this.words[n+i]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),a=t,o=0|a.words[a.length-1];0!=(r=26-this._countBits(o))&&(a=a.ushln(r),i.iushln(r),o=0|a.words[a.length-1]);var s,h=i.length-a.length;if('mod'!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var c=67108864*(0|i.words[a.length+f])+(0|i.words[a.length+f-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(a,c,f);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(a,1,f),i.isZero()||(i.negative^=1);s&&(s.words[f]=c)}return s&&s.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),'mod'!==e&&(a=s.div.neg()),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.iadd(t)),{div:a,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),'mod'!==e&&(a=s.div.neg()),{div:a,mod:s.mod}):this.negative&t.negative?(s=this.neg().divmod(t.neg(),e),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var a,o,s},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a=new n(1),o=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;!(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(l),o.isub(f)),a.iushrn(1),o.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(f)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s),o.isub(h)):(i.isub(e),s.isub(a),h.isub(o))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,a=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var o=new n(1),s=new n(0),h=a.clone();i.cmpn(1)>0&&a.cmpn(1)>0;){for(var u=0,l=1;!(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;!(a.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(a.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);i.cmp(a)>=0?(i.isub(a),o.isub(s)):(a.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var a=e;e=r,r=a}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new _(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function w(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function M(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function _(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function E(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,a=o}a>>>=22,t.words[n-10]=a,0===a&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new w;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new M}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},_.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),o=0;!a.isZero()&&0===a.andln(1);)o++,a.iushrn(1);r(!a.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,a),c=this.pow(t,a.addn(1).iushrn(1)),d=this.pow(t,a),p=o;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var f=u>>l&1;a!==r[0]&&(a=this.sqr(a)),0!==f||0!==o?(o<<=1,o|=f,(4==++s||0===i&&0===l)&&(a=this.mul(a,r[o]),s=0,o=0)):s=0}h=26}return a},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new E(t)},i(E,_),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(i).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),Me=h(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var a;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{a=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:be().Buffer}catch{}function o(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if('le'===i)for(n=0,a=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=s(t,e,i)<=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var a=t.length-r,o=a%i,s=Math.min(a,a-o)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.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'],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],a=0|e.words[0],o=n*a,s=67108863&o,h=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(a=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,a=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,o--)}for(0!==a&&(i=a.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);i=(p=p.idivn(d)).isZero()?m+i:u[c-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof a<'u'),this.toArrayLike(a,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),a=i||Math.max(1,n);r(n<=a,'byte array longer than desired length'),r(a>0,'Requested array length <= 0'),this.strip();var o,s,h='le'===e,u=new t(a),l=this.clone();if(h){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,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(;at.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,M=b>>>13,_=0|o[4],E=8191&_,S=_>>>13,C=0|o[5],A=8191&C,I=C>>>13,T=0|o[6],B=8191&T,k=T>>>13,R=0|o[7],N=8191&R,L=R>>>13,x=0|o[8],D=8191&x,U=x>>>13,P=0|o[9],O=8191&P,j=P>>>13,V=0|s[0],q=8191&V,K=V>>>13,F=0|s[1],H=8191&F,z=F>>>13,G=0|s[2],W=8191&G,Z=G>>>13,Y=0|s[3],$=8191&Y,Q=Y>>>13,X=0|s[4],J=8191&X,tt=X>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],at=8191&nt,ot=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ft=8191<,ct=lt>>>13,dt=0|s[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(f,q))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(c,q)|0))<<13)|0;u=((a=Math.imul(c,K))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,q),n=(n=Math.imul(p,K))+Math.imul(m,q)|0,a=Math.imul(m,K);var yt=(u+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,z)|0)+Math.imul(c,H)|0))<<13)|0;u=((a=a+Math.imul(c,z)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,q),n=(n=Math.imul(y,K))+Math.imul(v,q)|0,a=Math.imul(v,K),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,H)|0,a=a+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(f,W)|0)|0)+((8191&(n=(n=n+Math.imul(f,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((a=a+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(w,q),n=(n=Math.imul(w,K))+Math.imul(M,q)|0,a=Math.imul(M,K),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(v,H)|0,a=a+Math.imul(v,z)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,a=a+Math.imul(m,Z)|0;var bt=(u+(i=i+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,Q)|0)+Math.imul(c,$)|0))<<13)|0;u=((a=a+Math.imul(c,Q)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(E,q),n=(n=Math.imul(E,K))+Math.imul(S,q)|0,a=Math.imul(S,K),i=i+Math.imul(w,H)|0,n=(n=n+Math.imul(w,z)|0)+Math.imul(M,H)|0,a=a+Math.imul(M,z)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(v,W)|0,a=a+Math.imul(v,Z)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(m,$)|0,a=a+Math.imul(m,Q)|0;var wt=(u+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(c,J)|0))<<13)|0;u=((a=a+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,q),n=(n=Math.imul(A,K))+Math.imul(I,q)|0,a=Math.imul(I,K),i=i+Math.imul(E,H)|0,n=(n=n+Math.imul(E,z)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,z)|0,i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(M,W)|0,a=a+Math.imul(M,Z)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(v,$)|0,a=a+Math.imul(v,Q)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,a=a+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((a=a+Math.imul(c,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(B,q),n=(n=Math.imul(B,K))+Math.imul(k,q)|0,a=Math.imul(k,K),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,z)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,z)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,Z)|0,i=i+Math.imul(w,$)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(M,$)|0,a=a+Math.imul(M,Q)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,a=a+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,a=a+Math.imul(m,it)|0;var _t=(u+(i=i+Math.imul(f,at)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(c,at)|0))<<13)|0;u=((a=a+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,K))+Math.imul(L,q)|0,a=Math.imul(L,K),i=i+Math.imul(B,H)|0,n=(n=n+Math.imul(B,z)|0)+Math.imul(k,H)|0,a=a+Math.imul(k,z)|0,i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,Z)|0)+Math.imul(I,W)|0,a=a+Math.imul(I,Z)|0,i=i+Math.imul(E,$)|0,n=(n=n+Math.imul(E,Q)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,Q)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,J)|0,a=a+Math.imul(M,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,a=a+Math.imul(v,it)|0,i=i+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,at)|0,a=a+Math.imul(m,ot)|0;var Et=(u+(i=i+Math.imul(f,ht)|0)|0)+((8191&(n=(n=n+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((a=a+Math.imul(c,ut)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,q),n=(n=Math.imul(D,K))+Math.imul(U,q)|0,a=Math.imul(U,K),i=i+Math.imul(N,H)|0,n=(n=n+Math.imul(N,z)|0)+Math.imul(L,H)|0,a=a+Math.imul(L,z)|0,i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(k,W)|0,a=a+Math.imul(k,Z)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,Q)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,Q)|0,i=i+Math.imul(E,J)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,it)|0,i=i+Math.imul(y,at)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(v,at)|0,a=a+Math.imul(v,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,a=a+Math.imul(m,ut)|0;var St=(u+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((a=a+Math.imul(c,ct)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(O,q),n=(n=Math.imul(O,K))+Math.imul(j,q)|0,a=Math.imul(j,K),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(U,H)|0,a=a+Math.imul(U,z)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Z)|0)+Math.imul(L,W)|0,a=a+Math.imul(L,Z)|0,i=i+Math.imul(B,$)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(k,$)|0,a=a+Math.imul(k,Q)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,J)|0,a=a+Math.imul(I,tt)|0,i=i+Math.imul(E,rt)|0,n=(n=n+Math.imul(E,it)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,it)|0,i=i+Math.imul(w,at)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,a=a+Math.imul(v,ut)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,a=a+Math.imul(m,ct)|0;var Ct=(u+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((a=a+Math.imul(c,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(O,H),n=(n=Math.imul(O,z))+Math.imul(j,H)|0,a=Math.imul(j,z),i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,Z)|0)+Math.imul(U,W)|0,a=a+Math.imul(U,Z)|0,i=i+Math.imul(N,$)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(L,$)|0,a=a+Math.imul(L,Q)|0,i=i+Math.imul(B,J)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(k,J)|0,a=a+Math.imul(k,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,it)|0,i=i+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,a=a+Math.imul(M,ut)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,a=a+Math.imul(v,ct)|0;var At=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((a=a+Math.imul(m,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,W),n=(n=Math.imul(O,Z))+Math.imul(j,W)|0,a=Math.imul(j,Z),i=i+Math.imul(D,$)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(U,$)|0,a=a+Math.imul(U,Q)|0,i=i+Math.imul(N,J)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(L,J)|0,a=a+Math.imul(L,tt)|0,i=i+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,it)|0)+Math.imul(k,rt)|0,a=a+Math.imul(k,it)|0,i=i+Math.imul(A,at)|0,n=(n=n+Math.imul(A,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,i=i+Math.imul(E,ht)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(S,ht)|0,a=a+Math.imul(S,ut)|0,i=i+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ct)|0;var It=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((a=a+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,Q))+Math.imul(j,$)|0,a=Math.imul(j,Q),i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(U,J)|0,a=a+Math.imul(U,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(L,rt)|0,a=a+Math.imul(L,it)|0,i=i+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(k,at)|0,a=a+Math.imul(k,ot)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(I,ht)|0,a=a+Math.imul(I,ut)|0,i=i+Math.imul(E,ft)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(S,ft)|0,a=a+Math.imul(S,ct)|0;var Tt=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((a=a+Math.imul(M,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(O,J),n=(n=Math.imul(O,tt))+Math.imul(j,J)|0,a=Math.imul(j,tt),i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(U,rt)|0,a=a+Math.imul(U,it)|0,i=i+Math.imul(N,at)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(L,at)|0,a=a+Math.imul(L,ot)|0,i=i+Math.imul(B,ht)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(k,ht)|0,a=a+Math.imul(k,ut)|0,i=i+Math.imul(A,ft)|0,n=(n=n+Math.imul(A,ct)|0)+Math.imul(I,ft)|0,a=a+Math.imul(I,ct)|0;var Bt=(u+(i=i+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((a=a+Math.imul(S,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(O,rt),n=(n=Math.imul(O,it))+Math.imul(j,rt)|0,a=Math.imul(j,it),i=i+Math.imul(D,at)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(U,at)|0,a=a+Math.imul(U,ot)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(L,ht)|0,a=a+Math.imul(L,ut)|0,i=i+Math.imul(B,ft)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(k,ft)|0,a=a+Math.imul(k,ct)|0;var kt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((a=a+Math.imul(I,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(O,at),n=(n=Math.imul(O,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(U,ht)|0,a=a+Math.imul(U,ut)|0,i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(L,ft)|0,a=a+Math.imul(L,ct)|0;var Rt=(u+(i=i+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((a=a+Math.imul(k,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(O,ht),n=(n=Math.imul(O,ut))+Math.imul(j,ht)|0,a=Math.imul(j,ut),i=i+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,ct)|0)+Math.imul(U,ft)|0,a=a+Math.imul(U,ct)|0;var Nt=(u+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,mt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((a=a+Math.imul(L,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(O,ft),n=(n=Math.imul(O,ct))+Math.imul(j,ft)|0,a=Math.imul(j,ct);var Lt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((a=a+Math.imul(U,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var xt=(u+(i=Math.imul(O,pt))|0)+((8191&(n=(n=Math.imul(O,mt))+Math.imul(j,pt)|0))<<13)|0;return u=((a=Math.imul(j,mt))+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=Et,h[8]=St,h[9]=Ct,h[10]=At,h[11]=It,h[12]=Tt,h[13]=Bt,h[14]=kt,h[15]=Rt,h[16]=Nt,h[17]=Lt,h[18]=xt,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?c(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,i=o,o=n}return 0!==i?r.words[a]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,a){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=n/67108864|0,e+=a>>>26,this.words[i]=67108863&a}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,a=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(e=0;e>>26-i}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=n);u--){var f=0|this.words[u];this.words[u]=l<<26-a|f>>>a,l=f&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n>26,this.words[n+i]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),a=t,o=0|a.words[a.length-1];0!=(r=26-this._countBits(o))&&(a=a.ushln(r),i.iushln(r),o=0|a.words[a.length-1]);var s,h=i.length-a.length;if('mod'!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var c=67108864*(0|i.words[a.length+f])+(0|i.words[a.length+f-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(a,c,f);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(a,1,f),i.isZero()||(i.negative^=1);s&&(s.words[f]=c)}return s&&s.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),'mod'!==e&&(a=s.div.neg()),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.iadd(t)),{div:a,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),'mod'!==e&&(a=s.div.neg()),{div:a,mod:s.mod}):this.negative&t.negative?(s=this.neg().divmod(t.neg(),e),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var a,o,s},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a=new n(1),o=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;!(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(l),o.isub(f)),a.iushrn(1),o.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(f)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s),o.isub(h)):(i.isub(e),s.isub(a),h.isub(o))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,a=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var o=new n(1),s=new n(0),h=a.clone();i.cmpn(1)>0&&a.cmpn(1)>0;){for(var u=0,l=1;!(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;!(a.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(a.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);i.cmp(a)>=0?(i.isub(a),o.isub(s)):(a.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var a=e;e=r,r=a}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new _(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function w(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function M(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function _(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function E(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,a=o}a>>>=22,t.words[n-10]=a,0===a&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new w;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new M}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},_.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),o=0;!a.isZero()&&0===a.andln(1);)o++,a.iushrn(1);r(!a.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,a),c=this.pow(t,a.addn(1).iushrn(1)),d=this.pow(t,a),p=o;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var f=u>>l&1;a!==r[0]&&(a=this.sqr(a)),0!==f||0!==o?(o<<=1,o|=f,(4==++s||0===i&&0===l)&&(a=this.mul(a,r[o]),s=0,o=0)):s=0}h=26}return a},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new E(t)},i(E,_),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(i).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),_e=h((()=>{})),Ee=h(((t,e)=>{var r,i;function n(t){this.rand=t}if(e.exports=function(t){return r||(r=new n(null)),r.generate(t)},e.exports.Rand=n,n.prototype.generate=function(t){return this._rand(t)},n.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r{var r=Me(),i=Ee();function n(t){this.rand=t||new i.Rand}e.exports=n,n.create=function(t){return new n(t)},n.prototype._randbelow=function(t){var e=t.bitLength(),i=Math.ceil(e/8);do{var n=new r(this.rand.generate(i))}while(n.cmp(t)>=0);return n},n.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},n.prototype.test=function(t,e,i){var n=t.bitLength(),a=r.mont(t),o=new r(1).toRed(a);e||(e=Math.max(1,n/48|0));for(var s=t.subn(1),h=0;!s.testn(h);h++);for(var u=t.shrn(h),l=s.toRed(a);e>0;e--){var f=this._randrange(new r(2),s);i&&i(f);var c=f.toRed(a).redPow(u);if(0!==c.cmp(o)&&0!==c.cmp(l)){for(var d=1;d0;e--){var l=this._randrange(new r(2),o),f=t.gcd(l);if(0!==f.cmpn(1))return f;var c=l.toRed(n).redPow(h);if(0!==c.cmp(a)&&0!==c.cmp(u)){for(var d=1;d{var r=v();e.exports=g,g.simpleSieve=p,g.fermatTest=m;var i=we(),n=new i(24),a=new(Se()),o=new i(1),s=new i(2),h=new i(5),u=(new i(16),new i(8),new i(10)),l=new i(3),f=(new i(7),new i(11)),c=new i(4),d=(new i(12),null);function p(t){for(var e=function(){if(null!==d)return d;var t=[];t[0]=2;for(var e=1,r=3;r<1048576;r+=2){for(var i=Math.ceil(Math.sqrt(r)),n=0;nt;)d.ishrn(1);if(d.isEven()&&d.iadd(o),d.testn(1)||d.iadd(s),e.cmp(s)){if(!e.cmp(h))for(;d.mod(u).cmp(l);)d.iadd(c)}else for(;d.mod(n).cmp(f);)d.iadd(c);if(p(g=d.shrn(1))&&p(d)&&m(g)&&m(d)&&a.test(g)&&a.test(d))return d}}})),Ae=h(((t,e)=>{e.exports={modp1:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff'},modp2:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff'},modp5:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff'},modp14:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff'},modp15:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff'},modp16:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff'},modp17:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff'},modp18:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff'}}})),Ie=h(((t,e)=>{var r=we(),i=new(Se()),n=new r(24),a=new r(11),o=new r(10),s=new r(3),h=new r(7),u=Ce(),l=v();function f(t,e){return e=e||'utf8',Buffer.isBuffer(t)||(t=new Buffer(t,e)),this._pub=new r(t),this}function c(t,e){return e=e||'utf8',Buffer.isBuffer(t)||(t=new Buffer(t,e)),this._priv=new r(t),this}e.exports=p;var d={};function p(t,e,i){this.setGenerator(e),this.__prime=new r(t),this._prime=r.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,i?(this.setPublicKey=f,this.setPrivateKey=c):this._primeCode=8}function m(t,e){var r=new Buffer(t.toArray());return e?r.toString(e):r}Object.defineProperty(p.prototype,'verifyError',{enumerable:!0,get:function(){return'number'!=typeof this._primeCode&&(this._primeCode=function(t,e){var r=e.toString('hex'),l=[r,t.toString(16)].join('_');if(l in d)return d[l];var f,c=0;if(t.isEven()||!u.simpleSieve||!u.fermatTest(t)||!i.test(t))return c+=1,c+='02'===r||'05'===r?8:4,d[l]=c,c;switch(i.test(t.shrn(1))||(c+=2),r){case'02':t.mod(n).cmp(a)&&(c+=8);break;case'05':(f=t.mod(o)).cmp(s)&&f.cmp(h)&&(c+=8);break;default:c+=4}return d[l]=c,c}(this.__prime,this.__gen)),this._primeCode}}),p.prototype.generateKeys=function(){return this._priv||(this._priv=new r(l(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},p.prototype.computeSecret=function(t){var e=(t=(t=new r(t)).toRed(this._prime)).redPow(this._priv).fromRed(),i=new Buffer(e.toArray()),n=this.getPrime();if(i.length{var e=Ce(),r=Ae(),i=Ie(),n={binary:!0,hex:!0,base64:!0};t.DiffieHellmanGroup=t.createDiffieHellmanGroup=t.getDiffieHellman=function(t){var e=new Buffer(r[t].prime,'hex'),n=new Buffer(r[t].gen,'hex');return new i(e,n)},t.createDiffieHellman=t.DiffieHellman=function t(r,a,o,s){return Buffer.isBuffer(a)||void 0===n[a]?t(r,'binary',a,o):(a=a||'binary',s=s||'binary',o=o||new Buffer([2]),Buffer.isBuffer(o)||(o=new Buffer(o,s)),'number'==typeof r?new i(e(r,o),o,!0):(Buffer.isBuffer(r)||(r=new Buffer(r,a)),new i(r,o,!0)))}})),Be=h(((t,e)=>{e.exports=w().EventEmitter})),ke=h(((t,e)=>{function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:'unshift',value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:'shift',value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:'clear',value:function(){this.head=this.tail=null,this.length=0}},{key:'join',value:function(t){if(0===this.length)return'';for(var e=this.head,r=''+e.data;e=e.next;)r+=t+e.data;return r}},{key:'concat',value:function(t){if(0===this.length)return a.alloc(0);for(var e=a.allocUnsafe(t>>>0),r=this.head,i=0;r;)h(r.data,e,i),i+=r.data.length,r=r.next;return e}},{key:'consume',value:function(t,e){var r;return tn.length?n.length:t;if(a===n.length?i+=n:i+=n.slice(0,t),0==(t-=a)){a===n.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(a));break}++r}return this.length-=r,i}},{key:'_getBuffer',value:function(t){var e=a.allocUnsafe(t),r=this.head,i=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var n=r.data,o=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,o),0==(t-=o)){o===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(o));break}++i}return this.length-=i,e}},{key:s,value:function(t,e){return o(this,function(t){for(var e=1;e{function r(t,e){n(t,e),i(t)}function i(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit('close')}function n(t,e){t.emit('error',e)}e.exports={destroy:function(t,e){var a=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?a._writableState?a._writableState.errorEmitted?process.nextTick(i,a):(a._writableState.errorEmitted=!0,process.nextTick(r,a,t)):process.nextTick(r,a,t):e?(process.nextTick(i,a),e(t)):process.nextTick(i,a)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var{_readableState:r,_writableState:i}=t;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit('error',e)}}})),Ne=h(((t,e)=>{var r={};function i(t,e,i){i||(i=Error);var n=function(t){function r(r,i,n){return t.call(this,function(t,r,i){return'string'==typeof e?e:e(t,r,i)}(r,i,n))||this}return function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(r,t),r}(i);n.prototype.name=i.name,n.prototype.code=t,r[t]=n}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?'one of '.concat(e,' ').concat(t.slice(0,r-1).join(', '),', or ')+t[r-1]:2===r?'one of '.concat(e,' ').concat(t[0],' or ').concat(t[1]):'of '.concat(e,' ').concat(t[0])}return'of '.concat(e,' ').concat(String(t))}i('ERR_INVALID_OPT_VALUE',(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),i('ERR_INVALID_ARG_TYPE',(function(t,e,r){var i,a;if('string'==typeof e&&function(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}(e,'not ')?(i='must not be',e=e.replace(/^not /,'')):i='must be',function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t,' argument'))a='The '.concat(t,' ').concat(i,' ').concat(n(e,'type'));else{var o=function(t,e,r){return'number'!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,'.')?'property':'argument';a='The "'.concat(t,'" ').concat(o,' ').concat(i,' ').concat(n(e,'type'))}return a+='. Received type '.concat(typeof r)}),TypeError),i('ERR_STREAM_PUSH_AFTER_EOF','stream.push() after EOF'),i('ERR_METHOD_NOT_IMPLEMENTED',(function(t){return'The '+t+' method is not implemented'})),i('ERR_STREAM_PREMATURE_CLOSE','Premature close'),i('ERR_STREAM_DESTROYED',(function(t){return'Cannot call '+t+' after a stream was destroyed'})),i('ERR_MULTIPLE_CALLBACK','Callback called multiple times'),i('ERR_STREAM_CANNOT_PIPE','Cannot pipe, not readable'),i('ERR_STREAM_WRITE_AFTER_END','write after end'),i('ERR_STREAM_NULL_VALUES','May not write null values to stream',TypeError),i('ERR_UNKNOWN_ENCODING',(function(t){return'Unknown encoding: '+t}),TypeError),i('ERR_STREAM_UNSHIFT_AFTER_END_EVENT','stream.unshift() after end event'),e.exports.codes=r})),Le=h(((t,e)=>{var r=Ne().codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,i,n){var a=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,n,i);if(null!=a){if(!isFinite(a)||Math.floor(a)!==a||a<0)throw new r(n?i:'highWaterMark',a);return Math.floor(a)}return t.objectMode?16:16384}}})),xe=h(((t,e)=>{function r(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}var i;e.exports=C,C.WritableState=S;var n,a={deprecate:I()},o=Be(),s=g().Buffer,h=global.Uint8Array||function(){},u=Re(),l=Le().getHighWaterMark,f=Ne().codes,c=f.ERR_INVALID_ARG_TYPE,d=f.ERR_METHOD_NOT_IMPLEMENTED,p=f.ERR_MULTIPLE_CALLBACK,m=f.ERR_STREAM_CANNOT_PIPE,y=f.ERR_STREAM_DESTROYED,v=f.ERR_STREAM_NULL_VALUES,w=f.ERR_STREAM_WRITE_AFTER_END,M=f.ERR_UNKNOWN_ENCODING,_=u.errorOrDestroy;function E(){}function S(t,e,n){i=i||De(),t=t||{},'boolean'!=typeof n&&(n=e instanceof i),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=l(this,t,'writableHighWaterMark',n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||'utf8',this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if('function'!=typeof n)throw new p;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,n){--e.pendingcb,r?(process.nextTick(n,i),process.nextTick(N,t,e),t._writableState.errorEmitted=!0,_(t,i)):(n(i),t._writableState.errorEmitted=!0,_(t,i),N(t,e))}(t,r,i,e,n);else{var a=k(r)||t.destroyed;!a&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&B(t,r),i?process.nextTick(T,t,r,a,n):T(t,r,a,n)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}function C(t){var e=this instanceof(i=i||De());if(!e&&!n.call(C,this))return new C(t);this._writableState=new S(t,this,e),this.writable=!0,t&&('function'==typeof t.write&&(this._write=t.write),'function'==typeof t.writev&&(this._writev=t.writev),'function'==typeof t.destroy&&(this._destroy=t.destroy),'function'==typeof t.final&&(this._final=t.final)),o.call(this)}function A(t,e,r,i,n,a,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new y('write')):r?t._writev(n,e.onwrite):t._write(n,a,e.onwrite),e.sync=!1}function T(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit('drain'))}(t,e),e.pendingcb--,i(),N(t,e)}function B(t,e){e.bufferProcessing=!0;var i=e.bufferedRequest;if(t._writev&&i&&i.next){var n=e.bufferedRequestCount,a=new Array(n),o=e.corkedRequestsFree;o.entry=i;for(var s=0,h=!0;i;)a[s]=i,i.isBuf||(h=!1),i=i.next,s+=1;a.allBuffers=h,A(t,e,!0,e.length,a,'',o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new r(e),e.bufferedRequestCount=0}else{for(;i;){var{chunk:u,encoding:l,callback:f}=i;if(A(t,e,!1,e.objectMode?1:u.length,u,l,f),i=i.next,e.bufferedRequestCount--,e.writing)break}null===i&&(e.lastBufferedRequest=null)}e.bufferedRequest=i,e.bufferProcessing=!1}function k(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function R(t,e){t._final((function(r){e.pendingcb--,r&&_(t,r),e.prefinished=!0,t.emit('prefinish'),N(t,e)}))}function N(t,e){var r=k(e);if(r&&(function(t,e){!e.prefinished&&!e.finalCalled&&('function'!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit('prefinish')):(e.pendingcb++,e.finalCalled=!0,process.nextTick(R,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit('finish'),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return r}b()(C,o),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,'buffer',{get:a.deprecate((function(){return this.getBuffer()}),'_writableState.buffer is deprecated. Use _writableState.getBuffer instead.','DEP0003')})}catch{}}(),'function'==typeof Symbol&&Symbol.hasInstance&&'function'==typeof Function.prototype[Symbol.hasInstance]?(n=Function.prototype[Symbol.hasInstance],Object.defineProperty(C,Symbol.hasInstance,{value:function(t){return!!n.call(this,t)||this===C&&t&&t._writableState instanceof S}})):n=function(t){return t instanceof this},C.prototype.pipe=function(){_(this,new m)},C.prototype.write=function(t,e,r){var i=this._writableState,n=!1,a=!i.objectMode&&function(t){return s.isBuffer(t)||t instanceof h}(t);return a&&!s.isBuffer(t)&&(t=function(t){return s.from(t)}(t)),'function'==typeof e&&(r=e,e=null),a?e='buffer':e||(e=i.defaultEncoding),'function'!=typeof r&&(r=E),i.ending?function(t,e){var r=new w;_(t,r),process.nextTick(e,r)}(this,r):(a||function(t,e,r,i){var n;return null===r?n=new v:'string'!=typeof r&&!e.objectMode&&(n=new c('chunk',['string','Buffer'],r)),!n||(_(t,n),process.nextTick(i,n),!1)}(this,i,t,r))&&(i.pendingcb++,n=function(t,e,r,i,n,a){if(!r){var o=function(t,e,r){return!t.objectMode&&!1!==t.decodeStrings&&'string'==typeof e&&(e=s.from(e,r)),e}(e,i,n);i!==o&&(r=!0,n='buffer',i=o)}var h=e.objectMode?1:i.length;e.length+=h;var u=e.length-1))throw new M(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(C.prototype,'writableBuffer',{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(C.prototype,'writableHighWaterMark',{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),C.prototype._write=function(t,e,r){r(new d('_write()'))},C.prototype._writev=null,C.prototype.end=function(t,e,r){var i=this._writableState;return'function'==typeof t?(r=t,t=null,e=null):'function'==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,N(t,e),r&&(e.finished?process.nextTick(r):t.once('finish',r)),e.ended=!0,t.writable=!1}(this,i,r),this},Object.defineProperty(C.prototype,'writableLength',{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(C.prototype,'destroyed',{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){!this._writableState||(this._writableState.destroyed=t)}}),C.prototype.destroy=u.destroy,C.prototype._undestroy=u.undestroy,C.prototype._destroy=function(t,e){e(t)}})),De=h(((t,e)=>{var r=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var i,n,a,o=je(),s=xe();for(b()(h,o),i=r(s.prototype),a=0;a{var r=Ne().codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function t(e,n,a){if('function'==typeof n)return t(e,null,n);n||(n={}),a=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,i=new Array(r),n=0;n{var r;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var n=Ue(),a=Symbol('lastResolve'),o=Symbol('lastReject'),s=Symbol('error'),h=Symbol('ended'),u=Symbol('lastPromise'),l=Symbol('handlePromise'),f=Symbol('stream');function c(t,e){return{value:t,done:e}}function d(t){var e=t[a];if(null!==e){var r=t[f].read();null!==r&&(t[u]=null,t[a]=null,t[o]=null,e(c(r,!1)))}}function p(t){process.nextTick(d,t)}var m=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((r={get stream(){return this[f]},next:function(){var t=this,e=this[s];if(null!==e)return Promise.reject(e);if(this[h])return Promise.resolve(c(void 0,!0));if(this[f].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[s]?r(t[s]):e(c(void 0,!0))}))}));var r,i=this[u];if(i)r=new Promise(function(t,e){return function(r,i){t.then((function(){e[h]?r(c(void 0,!0)):e[l](r,i)}),i)}}(i,this));else{var n=this[f].read();if(null!==n)return Promise.resolve(c(n,!1));r=new Promise(this[l])}return this[u]=r,r}},i(r,Symbol.asyncIterator,(function(){return this})),i(r,'return',(function(){var t=this;return new Promise((function(e,r){t[f].destroy(null,(function(t){t?r(t):e(c(void 0,!0))}))}))})),r),m);e.exports=function(t){var e,r=Object.create(g,(i(e={},f,{value:t,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,o,{value:null,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,h,{value:t._readableState.endEmitted,writable:!0}),i(e,l,{value:function(t,e){var i=r[f].read();i?(r[u]=null,r[a]=null,r[o]=null,t(c(i,!1))):(r[a]=t,r[o]=e)},writable:!0}),e));return r[u]=null,n(t,(function(t){if(t&&'ERR_STREAM_PREMATURE_CLOSE'!==t.code){var e=r[o];return null!==e&&(r[u]=null,r[a]=null,r[o]=null,e(t)),void(r[s]=t)}var i=r[a];null!==i&&(r[u]=null,r[a]=null,r[o]=null,i(c(void 0,!0))),r[h]=!0})),t.on('readable',p.bind(null,r)),r}})),Oe=h(((t,e)=>{e.exports=function(){throw new Error('Readable.from is not available in the browser')}})),je=h(((t,e)=>{var r;e.exports=T,T.ReadableState=I,w().EventEmitter;var i,n=function(t,e){return t.listeners(e).length},a=Be(),o=g().Buffer,s=global.Uint8Array||function(){},h=_();i=h&&h.debuglog?h.debuglog('stream'):function(){};var u,l,f,c=ke(),p=Re(),m=Le().getHighWaterMark,y=Ne().codes,v=y.ERR_INVALID_ARG_TYPE,M=y.ERR_STREAM_PUSH_AFTER_EOF,E=y.ERR_METHOD_NOT_IMPLEMENTED,S=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;b()(T,a);var C=p.errorOrDestroy,A=['error','close','destroy','pause','resume'];function I(t,e,i){r=r||De(),t=t||{},'boolean'!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=m(this,t,'readableHighWaterMark',i),this.buffer=new c,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||'utf8',this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(u||(u=(L(),d(R)).StringDecoder),this.decoder=new u(t.encoding),this.encoding=t.encoding)}function T(t){if(r=r||De(),!(this instanceof T))return new T(t);var e=this instanceof r;this._readableState=new I(t,this,e),this.readable=!0,t&&('function'==typeof t.read&&(this._read=t.read),'function'==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function B(t,e,r,n,a){i('readableAddChunk',e);var h,u=t._readableState;if(null===e)u.reading=!1,function(t,e){if(i('onEofChunk'),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?D(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,U(t)))}}(t,u);else if(a||(h=function(t,e){var r;return!function(t){return o.isBuffer(t)||t instanceof s}(e)&&'string'!=typeof e&&void 0!==e&&!t.objectMode&&(r=new v('chunk',['string','Buffer','Uint8Array'],e)),r}(u,e)),h)C(t,h);else if(u.objectMode||e&&e.length>0)if('string'!=typeof e&&!u.objectMode&&Object.getPrototypeOf(e)!==o.prototype&&(e=function(t){return o.from(t)}(e)),n)u.endEmitted?C(t,new S):k(t,u,e,!0);else if(u.ended)C(t,new M);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!r?(e=u.decoder.write(e),u.objectMode||0!==e.length?k(t,u,e,!1):P(t,u)):k(t,u,e,!1)}else n||(u.reading=!1,P(t,u));return!u.ended&&(u.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=N?t=N:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function D(t){var e=t._readableState;i('emitReadable',e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(i('emitReadable',e.flowing),e.emittedReadable=!0,process.nextTick(U,t))}function U(t){var e=t._readableState;i('emitReadable_',e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit('readable'),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,K(t)}function P(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(O,t,e))}function O(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount('data')>0&&t.resume()}function V(t){i('readable nexttick read 0'),t.read(0)}function q(t,e){i('resume',e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit('resume'),K(t),e.flowing&&!e.reading&&t.read(0)}function K(t){var e=t._readableState;for(i('flow',e.flowing);e.flowing&&null!==t.read(););}function F(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(''):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function H(t){var e=t._readableState;i('endReadable',e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(z,e,t))}function z(t,e){if(i('endReadableNT',t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit('end'),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function G(t,e){for(var r=0,i=t.length;r=e.highWaterMark:e.length>0)||e.ended))return i('read: emitReadable',e.length,e.ended),0===e.length&&e.ended?H(this):D(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&H(this),null;var n,a=e.needReadable;return i('need readable',a),(0===e.length||e.length-t0?F(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&H(this)),null!==n&&this.emit('data',n),n},T.prototype._read=function(t){C(this,new E('_read()'))},T.prototype.pipe=function(t,e){var r=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,i('pipe count=%d opts=%j',a.pipesCount,e);var o=e&&!1===e.end||t===process.stdout||t===process.stderr?m:h;function s(e,n){i('onunpipe'),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,i('cleanup'),t.removeListener('close',d),t.removeListener('finish',p),t.removeListener('drain',u),t.removeListener('error',c),t.removeListener('unpipe',s),r.removeListener('end',h),r.removeListener('end',m),r.removeListener('data',f),l=!0,a.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&u())}function h(){i('onend'),t.end()}a.endEmitted?process.nextTick(o):r.once('end',o),t.on('unpipe',s);var u=function(t){return function(){var e=t._readableState;i('pipeOnDrain',e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&n(t,'data')&&(e.flowing=!0,K(t))}}(r);t.on('drain',u);var l=!1;function f(e){i('ondata');var n=t.write(e);i('dest.write',n),!1===n&&((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==G(a.pipes,t))&&!l&&(i('false write response, pause',a.awaitDrain),a.awaitDrain++),r.pause())}function c(e){i('onerror',e),m(),t.removeListener('error',c),0===n(t,'error')&&C(t,e)}function d(){t.removeListener('finish',p),m()}function p(){i('onfinish'),t.removeListener('close',d),m()}function m(){i('unpipe'),r.unpipe(t)}return r.on('data',f),function(t,e,r){if('function'==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,'error',c),t.once('close',d),t.once('finish',p),t.emit('pipe',r),a.flowing||(i('pipe resume'),r.resume()),t},T.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit('unpipe',this,r)),this;if(!t){var{pipes:i,pipesCount:n}=e;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a0,!1!==n.flowing&&this.resume()):'readable'===t&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,i('on readable',n.length,n.reading),n.length?D(this):n.reading||process.nextTick(V,this)),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var r=a.prototype.removeListener.call(this,t,e);return'readable'===t&&process.nextTick(j,this),r},T.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return('readable'===t||void 0===t)&&process.nextTick(j,this),e},T.prototype.resume=function(){var t=this._readableState;return t.flowing||(i('resume'),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(q,t,e))}(this,t)),t.paused=!1,this},T.prototype.pause=function(){return i('call pause flowing=%j',this._readableState.flowing),!1!==this._readableState.flowing&&(i('pause'),this._readableState.flowing=!1,this.emit('pause')),this._readableState.paused=!0,this},T.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var a in t.on('end',(function(){if(i('wrapped end'),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on('data',(function(a){i('wrapped data'),r.decoder&&(a=r.decoder.write(a)),r.objectMode&&null==a||!(r.objectMode||a&&a.length)||e.push(a)||(n=!0,t.pause())})),t)void 0===this[a]&&'function'==typeof t[a]&&(this[a]=function(e){return function(){return t[e].apply(t,arguments)}}(a));for(var o=0;o{e.exports=u;var r=Ne().codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,n=r.ERR_MULTIPLE_CALLBACK,a=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,o=r.ERR_TRANSFORM_WITH_LENGTH_0,s=De();function h(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit('error',new n);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var a=this._readableState;a.reading=!1,(a.needReadable||a.length{e.exports=i;var r=Ve();function i(t){if(!(this instanceof i))return new i(t);r.call(this,t)}b()(i,r),i.prototype._transform=function(t,e,r){r(null,t)}})),Ke=h(((t,e)=>{var r,i=Ne().codes,n=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function o(t){if(t)throw t}function s(t){t()}function h(t,e){return t.pipe(e)}e.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){l||(l=t),t&&f.forEach(s),!n&&(f.forEach(s),u(l))}))}));return e.reduce(h)}})),Fe=h(((t,e)=>{(t=e.exports=je()).Stream=t,t.Readable=t,t.Writable=xe(),t.Duplex=De(),t.Transform=Ve(),t.PassThrough=qe(),t.finished=Ue(),t.pipeline=Ke()})),He=h(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var a;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{a=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:be().Buffer}catch{}function o(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,'Invalid character in '+t)}function s(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function h(t,e,i,n){for(var a=0,o=0,s=Math.min(t.length,i),h=e;h=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&o0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if('le'===i)for(n=0,a=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=s(t,e,i)<=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var a=t.length-r,o=a%i,s=Math.min(a,a-o)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},typeof Symbol<'u'&&'function'==typeof Symbol.for)try{n.prototype[Symbol.for('nodejs.util.inspect.custom')]=l}catch{n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?''}var f=['','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'],c=[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 p(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],a=0|e.words[0],o=n*a,s=67108863&o,h=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(a=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,a=0,o=0;o>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),i=0!==a||o!==this.length-1?f[6-h.length]+h+i:h+i}for(0!==a&&(i=a.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=c[t],l=d[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modrn(l).toString(t);i=(p=p.idivn(l)).isZero()?m+i:f[u-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},a&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(a,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),a=i||Math.max(1,n);r(n<=a,'byte array longer than desired length'),r(a>0,'Requested array length <= 0');var o=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,a);return this['_toArrayLike'+('le'===e?'LE':'BE')](o,n),o},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,a=0;n>8&255),r>16&255),6===a?(r>24&255),i=0,a=0):(i=o>>>24,a+=2)}if(r=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===a?(r>=0&&(t[r--]=o>>24&255),i=0,a=0):(i=o>>>24,a+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,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(;at.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,M=b>>>13,_=0|o[4],E=8191&_,S=_>>>13,C=0|o[5],A=8191&C,I=C>>>13,T=0|o[6],B=8191&T,k=T>>>13,R=0|o[7],N=8191&R,L=R>>>13,x=0|o[8],D=8191&x,U=x>>>13,P=0|o[9],O=8191&P,j=P>>>13,V=0|s[0],q=8191&V,K=V>>>13,F=0|s[1],H=8191&F,z=F>>>13,G=0|s[2],W=8191&G,Z=G>>>13,Y=0|s[3],$=8191&Y,Q=Y>>>13,X=0|s[4],J=8191&X,tt=X>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],at=8191&nt,ot=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ft=8191<,ct=lt>>>13,dt=0|s[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(f,q))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(c,q)|0))<<13)|0;u=((a=Math.imul(c,K))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,q),n=(n=Math.imul(p,K))+Math.imul(m,q)|0,a=Math.imul(m,K);var yt=(u+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,z)|0)+Math.imul(c,H)|0))<<13)|0;u=((a=a+Math.imul(c,z)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,q),n=(n=Math.imul(y,K))+Math.imul(v,q)|0,a=Math.imul(v,K),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,H)|0,a=a+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(f,W)|0)|0)+((8191&(n=(n=n+Math.imul(f,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((a=a+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(w,q),n=(n=Math.imul(w,K))+Math.imul(M,q)|0,a=Math.imul(M,K),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(v,H)|0,a=a+Math.imul(v,z)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,a=a+Math.imul(m,Z)|0;var bt=(u+(i=i+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,Q)|0)+Math.imul(c,$)|0))<<13)|0;u=((a=a+Math.imul(c,Q)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(E,q),n=(n=Math.imul(E,K))+Math.imul(S,q)|0,a=Math.imul(S,K),i=i+Math.imul(w,H)|0,n=(n=n+Math.imul(w,z)|0)+Math.imul(M,H)|0,a=a+Math.imul(M,z)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(v,W)|0,a=a+Math.imul(v,Z)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(m,$)|0,a=a+Math.imul(m,Q)|0;var wt=(u+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(c,J)|0))<<13)|0;u=((a=a+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,q),n=(n=Math.imul(A,K))+Math.imul(I,q)|0,a=Math.imul(I,K),i=i+Math.imul(E,H)|0,n=(n=n+Math.imul(E,z)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,z)|0,i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(M,W)|0,a=a+Math.imul(M,Z)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(v,$)|0,a=a+Math.imul(v,Q)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,a=a+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((a=a+Math.imul(c,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(B,q),n=(n=Math.imul(B,K))+Math.imul(k,q)|0,a=Math.imul(k,K),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,z)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,z)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,Z)|0,i=i+Math.imul(w,$)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(M,$)|0,a=a+Math.imul(M,Q)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,a=a+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,a=a+Math.imul(m,it)|0;var _t=(u+(i=i+Math.imul(f,at)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(c,at)|0))<<13)|0;u=((a=a+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,K))+Math.imul(L,q)|0,a=Math.imul(L,K),i=i+Math.imul(B,H)|0,n=(n=n+Math.imul(B,z)|0)+Math.imul(k,H)|0,a=a+Math.imul(k,z)|0,i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,Z)|0)+Math.imul(I,W)|0,a=a+Math.imul(I,Z)|0,i=i+Math.imul(E,$)|0,n=(n=n+Math.imul(E,Q)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,Q)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,J)|0,a=a+Math.imul(M,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,a=a+Math.imul(v,it)|0,i=i+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,at)|0,a=a+Math.imul(m,ot)|0;var Et=(u+(i=i+Math.imul(f,ht)|0)|0)+((8191&(n=(n=n+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((a=a+Math.imul(c,ut)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,q),n=(n=Math.imul(D,K))+Math.imul(U,q)|0,a=Math.imul(U,K),i=i+Math.imul(N,H)|0,n=(n=n+Math.imul(N,z)|0)+Math.imul(L,H)|0,a=a+Math.imul(L,z)|0,i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(k,W)|0,a=a+Math.imul(k,Z)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,Q)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,Q)|0,i=i+Math.imul(E,J)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,it)|0,i=i+Math.imul(y,at)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(v,at)|0,a=a+Math.imul(v,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,a=a+Math.imul(m,ut)|0;var St=(u+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((a=a+Math.imul(c,ct)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(O,q),n=(n=Math.imul(O,K))+Math.imul(j,q)|0,a=Math.imul(j,K),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(U,H)|0,a=a+Math.imul(U,z)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Z)|0)+Math.imul(L,W)|0,a=a+Math.imul(L,Z)|0,i=i+Math.imul(B,$)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(k,$)|0,a=a+Math.imul(k,Q)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,J)|0,a=a+Math.imul(I,tt)|0,i=i+Math.imul(E,rt)|0,n=(n=n+Math.imul(E,it)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,it)|0,i=i+Math.imul(w,at)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,a=a+Math.imul(v,ut)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,a=a+Math.imul(m,ct)|0;var Ct=(u+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((a=a+Math.imul(c,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(O,H),n=(n=Math.imul(O,z))+Math.imul(j,H)|0,a=Math.imul(j,z),i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,Z)|0)+Math.imul(U,W)|0,a=a+Math.imul(U,Z)|0,i=i+Math.imul(N,$)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(L,$)|0,a=a+Math.imul(L,Q)|0,i=i+Math.imul(B,J)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(k,J)|0,a=a+Math.imul(k,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,it)|0,i=i+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,a=a+Math.imul(M,ut)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,a=a+Math.imul(v,ct)|0;var At=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((a=a+Math.imul(m,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,W),n=(n=Math.imul(O,Z))+Math.imul(j,W)|0,a=Math.imul(j,Z),i=i+Math.imul(D,$)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(U,$)|0,a=a+Math.imul(U,Q)|0,i=i+Math.imul(N,J)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(L,J)|0,a=a+Math.imul(L,tt)|0,i=i+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,it)|0)+Math.imul(k,rt)|0,a=a+Math.imul(k,it)|0,i=i+Math.imul(A,at)|0,n=(n=n+Math.imul(A,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,i=i+Math.imul(E,ht)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(S,ht)|0,a=a+Math.imul(S,ut)|0,i=i+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ct)|0;var It=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((a=a+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,Q))+Math.imul(j,$)|0,a=Math.imul(j,Q),i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(U,J)|0,a=a+Math.imul(U,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(L,rt)|0,a=a+Math.imul(L,it)|0,i=i+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(k,at)|0,a=a+Math.imul(k,ot)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(I,ht)|0,a=a+Math.imul(I,ut)|0,i=i+Math.imul(E,ft)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(S,ft)|0,a=a+Math.imul(S,ct)|0;var Tt=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((a=a+Math.imul(M,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(O,J),n=(n=Math.imul(O,tt))+Math.imul(j,J)|0,a=Math.imul(j,tt),i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(U,rt)|0,a=a+Math.imul(U,it)|0,i=i+Math.imul(N,at)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(L,at)|0,a=a+Math.imul(L,ot)|0,i=i+Math.imul(B,ht)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(k,ht)|0,a=a+Math.imul(k,ut)|0,i=i+Math.imul(A,ft)|0,n=(n=n+Math.imul(A,ct)|0)+Math.imul(I,ft)|0,a=a+Math.imul(I,ct)|0;var Bt=(u+(i=i+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((a=a+Math.imul(S,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(O,rt),n=(n=Math.imul(O,it))+Math.imul(j,rt)|0,a=Math.imul(j,it),i=i+Math.imul(D,at)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(U,at)|0,a=a+Math.imul(U,ot)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(L,ht)|0,a=a+Math.imul(L,ut)|0,i=i+Math.imul(B,ft)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(k,ft)|0,a=a+Math.imul(k,ct)|0;var kt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((a=a+Math.imul(I,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(O,at),n=(n=Math.imul(O,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(U,ht)|0,a=a+Math.imul(U,ut)|0,i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(L,ft)|0,a=a+Math.imul(L,ct)|0;var Rt=(u+(i=i+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((a=a+Math.imul(k,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(O,ht),n=(n=Math.imul(O,ut))+Math.imul(j,ht)|0,a=Math.imul(j,ut),i=i+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,ct)|0)+Math.imul(U,ft)|0,a=a+Math.imul(U,ct)|0;var Nt=(u+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,mt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((a=a+Math.imul(L,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(O,ft),n=(n=Math.imul(O,ct))+Math.imul(j,ft)|0,a=Math.imul(j,ct);var Lt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((a=a+Math.imul(U,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var xt=(u+(i=Math.imul(O,pt))|0)+((8191&(n=(n=Math.imul(O,mt))+Math.imul(j,pt)|0))<<13)|0;return u=((a=Math.imul(j,mt))+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=Et,h[8]=St,h[9]=Ct,h[10]=At,h[11]=It,h[12]=Tt,h[13]=Bt,h[14]=kt,h[15]=Rt,h[16]=Nt,h[17]=Lt,h[18]=xt,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,i=o,o=n}return 0!==i?r.words[a]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(m=p),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):y(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},v.prototype.permute=function(t,e,r,i,n,a){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,i+=a/67108864|0,i+=o>>>26,this.words[n]=67108863&o}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,a=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(e=0;e>>26-i}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=n);u--){var f=0|this.words[u];this.words[u]=l<<26-a|f>>>a,l=f&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),a=t,o=0|a.words[a.length-1];0!=(r=26-this._countBits(o))&&(a=a.ushln(r),i.iushln(r),o=0|a.words[a.length-1]);var s,h=i.length-a.length;if('mod'!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var c=67108864*(0|i.words[a.length+f])+(0|i.words[a.length+f-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(a,c,f);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(a,1,f),i.isZero()||(i.negative^=1);s&&(s.words[f]=c)}return s&&s._strip(),i._strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),'mod'!==e&&(a=s.div.neg()),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.iadd(t)),{div:a,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),'mod'!==e&&(a=s.div.neg()),{div:a,mod:s.mod}):this.negative&t.negative?(s=this.neg().divmod(t.neg(),e),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var a,o,s},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,a=this.length-1;a>=0;a--)n=(i*n+(0|this.words[a]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var a=(0|this.words[n])+67108864*i;this.words[n]=a/t|0,i=a%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a=new n(1),o=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;!(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(l),o.isub(f)),a.iushrn(1),o.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(f)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s),o.isub(h)):(i.isub(e),s.isub(a),h.isub(o))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,a=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var o=new n(1),s=new n(0),h=a.clone();i.cmpn(1)>0&&a.cmpn(1)>0;){for(var u=0,l=1;!(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;!(a.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(a.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);i.cmp(a)>=0?(i.isub(a),o.isub(s)):(a.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var a=e;e=r,r=a}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new C(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var b={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function M(){w.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function _(){w.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function E(){w.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function S(){w.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function C(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function A(t){C.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}w.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(M,w),M.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,a=o}a>>>=22,t.words[n-10]=a,0===a&&t.length>10?t.length-=10:t.length-=9},M.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(b[t])return b[t];var e;if('k256'===t)e=new M;else if('p224'===t)e=new _;else if('p192'===t)e=new E;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new S}return b[t]=e,e},C.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},C.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},C.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},C.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},C.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},C.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},C.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},C.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},C.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},C.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},C.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},C.prototype.isqr=function(t){return this.imul(t,t.clone())},C.prototype.sqr=function(t){return this.mul(t,t)},C.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),o=0;!a.isZero()&&0===a.andln(1);)o++,a.iushrn(1);r(!a.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,a),c=this.pow(t,a.addn(1).iushrn(1)),d=this.pow(t,a),p=o;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var f=u>>l&1;a!==r[0]&&(a=this.sqr(a)),0!==f||0!==o?(o<<=1,o|=f,(4==++s||0===i&&0===l)&&(a=this.mul(a,r[o]),s=0,o=0)):s=0}h=26}return a},C.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},C.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,C),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(i).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),ze=h(((t,e)=>{var r=He(),i=v();function n(t){var e,n=t.modulus.byteLength();do{e=new r(i(n))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function a(t,e){var i=function(t){var e=n(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),a=e.modulus.byteLength(),o=new r(t).mul(i.blinder).umod(e.modulus),s=o.toRed(r.mont(e.prime1)),h=o.toRed(r.mont(e.prime2)),u=e.coefficient,l=e.prime1,f=e.prime2,c=s.redPow(e.exponent1).fromRed(),d=h.redPow(e.exponent2).fromRed(),p=c.isub(d).imul(u).umod(l).imul(f);return d.iadd(p).imul(i.unblinder).umod(e.modulus).toArrayLike(Buffer,'be',a)}a.getr=n,e.exports=a})),Ge=h(((t,e)=>{e.exports={name:'elliptic',version:'6.5.4',description:'EC cryptography',main:'lib/elliptic.js',files:['lib'],scripts:{lint:'eslint lib test','lint:fix':'npm run lint -- --fix',unit:'istanbul test _mocha --reporter=spec test/index.js',test:'npm run lint && npm run unit',version:'grunt dist && git add dist/'},repository:{type:'git',url:'git@github.com:indutny/elliptic'},keywords:['EC','Elliptic','curve','Cryptography'],author:'Fedor Indutny ',license:'MIT',bugs:{url:'https://github.com/indutny/elliptic/issues'},homepage:'https://github.com/indutny/elliptic',devDependencies:{brfs:'^2.0.2',coveralls:'^3.1.0',eslint:'^7.6.0',grunt:'^1.2.1','grunt-browserify':'^5.3.0','grunt-cli':'^1.3.2','grunt-contrib-connect':'^3.0.0','grunt-contrib-copy':'^1.0.0','grunt-contrib-uglify':'^5.0.0','grunt-mocha-istanbul':'^5.0.2','grunt-saucelabs':'^9.0.1',istanbul:'^0.4.5',mocha:'^8.0.1'},dependencies:{'bn.js':'^4.11.9',brorand:'^1.1.0','hash.js':'^1.0.0','hmac-drbg':'^1.0.1',inherits:'^2.0.4','minimalistic-assert':'^1.0.1','minimalistic-crypto-utils':'^1.0.1'}}})),We=h(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var a;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{a=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:be().Buffer}catch{}function o(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if('le'===i)for(n=0,a=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=s(t,e,i)<=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var a=t.length-r,o=a%i,s=Math.min(a,a-o)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.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'],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],a=0|e.words[0],o=n*a,s=67108863&o,h=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(a=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,a=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,o--)}for(0!==a&&(i=a.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);i=(p=p.idivn(d)).isZero()?m+i:u[c-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof a<'u'),this.toArrayLike(a,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),a=i||Math.max(1,n);r(n<=a,'byte array longer than desired length'),r(a>0,'Requested array length <= 0'),this.strip();var o,s,h='le'===e,u=new t(a),l=this.clone();if(h){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,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(;at.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,M=b>>>13,_=0|o[4],E=8191&_,S=_>>>13,C=0|o[5],A=8191&C,I=C>>>13,T=0|o[6],B=8191&T,k=T>>>13,R=0|o[7],N=8191&R,L=R>>>13,x=0|o[8],D=8191&x,U=x>>>13,P=0|o[9],O=8191&P,j=P>>>13,V=0|s[0],q=8191&V,K=V>>>13,F=0|s[1],H=8191&F,z=F>>>13,G=0|s[2],W=8191&G,Z=G>>>13,Y=0|s[3],$=8191&Y,Q=Y>>>13,X=0|s[4],J=8191&X,tt=X>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],at=8191&nt,ot=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ft=8191<,ct=lt>>>13,dt=0|s[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(f,q))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(c,q)|0))<<13)|0;u=((a=Math.imul(c,K))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,q),n=(n=Math.imul(p,K))+Math.imul(m,q)|0,a=Math.imul(m,K);var yt=(u+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,z)|0)+Math.imul(c,H)|0))<<13)|0;u=((a=a+Math.imul(c,z)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,q),n=(n=Math.imul(y,K))+Math.imul(v,q)|0,a=Math.imul(v,K),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,H)|0,a=a+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(f,W)|0)|0)+((8191&(n=(n=n+Math.imul(f,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((a=a+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(w,q),n=(n=Math.imul(w,K))+Math.imul(M,q)|0,a=Math.imul(M,K),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(v,H)|0,a=a+Math.imul(v,z)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,a=a+Math.imul(m,Z)|0;var bt=(u+(i=i+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,Q)|0)+Math.imul(c,$)|0))<<13)|0;u=((a=a+Math.imul(c,Q)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(E,q),n=(n=Math.imul(E,K))+Math.imul(S,q)|0,a=Math.imul(S,K),i=i+Math.imul(w,H)|0,n=(n=n+Math.imul(w,z)|0)+Math.imul(M,H)|0,a=a+Math.imul(M,z)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(v,W)|0,a=a+Math.imul(v,Z)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(m,$)|0,a=a+Math.imul(m,Q)|0;var wt=(u+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(c,J)|0))<<13)|0;u=((a=a+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,q),n=(n=Math.imul(A,K))+Math.imul(I,q)|0,a=Math.imul(I,K),i=i+Math.imul(E,H)|0,n=(n=n+Math.imul(E,z)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,z)|0,i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(M,W)|0,a=a+Math.imul(M,Z)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(v,$)|0,a=a+Math.imul(v,Q)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,a=a+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((a=a+Math.imul(c,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(B,q),n=(n=Math.imul(B,K))+Math.imul(k,q)|0,a=Math.imul(k,K),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,z)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,z)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,Z)|0,i=i+Math.imul(w,$)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(M,$)|0,a=a+Math.imul(M,Q)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,a=a+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,a=a+Math.imul(m,it)|0;var _t=(u+(i=i+Math.imul(f,at)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(c,at)|0))<<13)|0;u=((a=a+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,K))+Math.imul(L,q)|0,a=Math.imul(L,K),i=i+Math.imul(B,H)|0,n=(n=n+Math.imul(B,z)|0)+Math.imul(k,H)|0,a=a+Math.imul(k,z)|0,i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,Z)|0)+Math.imul(I,W)|0,a=a+Math.imul(I,Z)|0,i=i+Math.imul(E,$)|0,n=(n=n+Math.imul(E,Q)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,Q)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,J)|0,a=a+Math.imul(M,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,a=a+Math.imul(v,it)|0,i=i+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,at)|0,a=a+Math.imul(m,ot)|0;var Et=(u+(i=i+Math.imul(f,ht)|0)|0)+((8191&(n=(n=n+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((a=a+Math.imul(c,ut)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,q),n=(n=Math.imul(D,K))+Math.imul(U,q)|0,a=Math.imul(U,K),i=i+Math.imul(N,H)|0,n=(n=n+Math.imul(N,z)|0)+Math.imul(L,H)|0,a=a+Math.imul(L,z)|0,i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(k,W)|0,a=a+Math.imul(k,Z)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,Q)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,Q)|0,i=i+Math.imul(E,J)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,it)|0,i=i+Math.imul(y,at)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(v,at)|0,a=a+Math.imul(v,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,a=a+Math.imul(m,ut)|0;var St=(u+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((a=a+Math.imul(c,ct)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(O,q),n=(n=Math.imul(O,K))+Math.imul(j,q)|0,a=Math.imul(j,K),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(U,H)|0,a=a+Math.imul(U,z)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Z)|0)+Math.imul(L,W)|0,a=a+Math.imul(L,Z)|0,i=i+Math.imul(B,$)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(k,$)|0,a=a+Math.imul(k,Q)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,J)|0,a=a+Math.imul(I,tt)|0,i=i+Math.imul(E,rt)|0,n=(n=n+Math.imul(E,it)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,it)|0,i=i+Math.imul(w,at)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,a=a+Math.imul(v,ut)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,a=a+Math.imul(m,ct)|0;var Ct=(u+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((a=a+Math.imul(c,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(O,H),n=(n=Math.imul(O,z))+Math.imul(j,H)|0,a=Math.imul(j,z),i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,Z)|0)+Math.imul(U,W)|0,a=a+Math.imul(U,Z)|0,i=i+Math.imul(N,$)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(L,$)|0,a=a+Math.imul(L,Q)|0,i=i+Math.imul(B,J)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(k,J)|0,a=a+Math.imul(k,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,it)|0,i=i+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,a=a+Math.imul(M,ut)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,a=a+Math.imul(v,ct)|0;var At=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((a=a+Math.imul(m,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,W),n=(n=Math.imul(O,Z))+Math.imul(j,W)|0,a=Math.imul(j,Z),i=i+Math.imul(D,$)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(U,$)|0,a=a+Math.imul(U,Q)|0,i=i+Math.imul(N,J)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(L,J)|0,a=a+Math.imul(L,tt)|0,i=i+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,it)|0)+Math.imul(k,rt)|0,a=a+Math.imul(k,it)|0,i=i+Math.imul(A,at)|0,n=(n=n+Math.imul(A,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,i=i+Math.imul(E,ht)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(S,ht)|0,a=a+Math.imul(S,ut)|0,i=i+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ct)|0;var It=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((a=a+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,Q))+Math.imul(j,$)|0,a=Math.imul(j,Q),i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(U,J)|0,a=a+Math.imul(U,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(L,rt)|0,a=a+Math.imul(L,it)|0,i=i+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(k,at)|0,a=a+Math.imul(k,ot)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(I,ht)|0,a=a+Math.imul(I,ut)|0,i=i+Math.imul(E,ft)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(S,ft)|0,a=a+Math.imul(S,ct)|0;var Tt=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((a=a+Math.imul(M,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(O,J),n=(n=Math.imul(O,tt))+Math.imul(j,J)|0,a=Math.imul(j,tt),i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(U,rt)|0,a=a+Math.imul(U,it)|0,i=i+Math.imul(N,at)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(L,at)|0,a=a+Math.imul(L,ot)|0,i=i+Math.imul(B,ht)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(k,ht)|0,a=a+Math.imul(k,ut)|0,i=i+Math.imul(A,ft)|0,n=(n=n+Math.imul(A,ct)|0)+Math.imul(I,ft)|0,a=a+Math.imul(I,ct)|0;var Bt=(u+(i=i+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((a=a+Math.imul(S,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(O,rt),n=(n=Math.imul(O,it))+Math.imul(j,rt)|0,a=Math.imul(j,it),i=i+Math.imul(D,at)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(U,at)|0,a=a+Math.imul(U,ot)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(L,ht)|0,a=a+Math.imul(L,ut)|0,i=i+Math.imul(B,ft)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(k,ft)|0,a=a+Math.imul(k,ct)|0;var kt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((a=a+Math.imul(I,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(O,at),n=(n=Math.imul(O,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(U,ht)|0,a=a+Math.imul(U,ut)|0,i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(L,ft)|0,a=a+Math.imul(L,ct)|0;var Rt=(u+(i=i+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((a=a+Math.imul(k,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(O,ht),n=(n=Math.imul(O,ut))+Math.imul(j,ht)|0,a=Math.imul(j,ut),i=i+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,ct)|0)+Math.imul(U,ft)|0,a=a+Math.imul(U,ct)|0;var Nt=(u+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,mt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((a=a+Math.imul(L,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(O,ft),n=(n=Math.imul(O,ct))+Math.imul(j,ft)|0,a=Math.imul(j,ct);var Lt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((a=a+Math.imul(U,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var xt=(u+(i=Math.imul(O,pt))|0)+((8191&(n=(n=Math.imul(O,mt))+Math.imul(j,pt)|0))<<13)|0;return u=((a=Math.imul(j,mt))+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=Et,h[8]=St,h[9]=Ct,h[10]=At,h[11]=It,h[12]=Tt,h[13]=Bt,h[14]=kt,h[15]=Rt,h[16]=Nt,h[17]=Lt,h[18]=xt,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?c(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,i=o,o=n}return 0!==i?r.words[a]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,a){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=n/67108864|0,e+=a>>>26,this.words[i]=67108863&a}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,a=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(e=0;e>>26-i}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=n);u--){var f=0|this.words[u];this.words[u]=l<<26-a|f>>>a,l=f&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n>26,this.words[n+i]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),a=t,o=0|a.words[a.length-1];0!=(r=26-this._countBits(o))&&(a=a.ushln(r),i.iushln(r),o=0|a.words[a.length-1]);var s,h=i.length-a.length;if('mod'!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var c=67108864*(0|i.words[a.length+f])+(0|i.words[a.length+f-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(a,c,f);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(a,1,f),i.isZero()||(i.negative^=1);s&&(s.words[f]=c)}return s&&s.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),'mod'!==e&&(a=s.div.neg()),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.iadd(t)),{div:a,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),'mod'!==e&&(a=s.div.neg()),{div:a,mod:s.mod}):this.negative&t.negative?(s=this.neg().divmod(t.neg(),e),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var a,o,s},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a=new n(1),o=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;!(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(l),o.isub(f)),a.iushrn(1),o.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(f)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s),o.isub(h)):(i.isub(e),s.isub(a),h.isub(o))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,a=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var o=new n(1),s=new n(0),h=a.clone();i.cmpn(1)>0&&a.cmpn(1)>0;){for(var u=0,l=1;!(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;!(a.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(a.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);i.cmp(a)>=0?(i.isub(a),o.isub(s)):(a.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var a=e;e=r,r=a}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new _(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function w(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function M(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function _(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function E(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,a=o}a>>>=22,t.words[n-10]=a,0===a&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new w;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new M}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},_.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),o=0;!a.isZero()&&0===a.andln(1);)o++,a.iushrn(1);r(!a.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,a),c=this.pow(t,a.addn(1).iushrn(1)),d=this.pow(t,a),p=o;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var f=u>>l&1;a!==r[0]&&(a=this.sqr(a)),0!==f||0!==o?(o<<=1,o|=f,(4==++s||0===i&&0===l)&&(a=this.mul(a,r[o]),s=0,o=0)):s=0}h=26}return a},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new E(t)},i(E,_),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(i).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),Ze=h((t=>{var e=t;function r(t){return 1===t.length?'0'+t:t}function i(t){for(var e='',i=0;i>8,o=255&n;a?r.push(a,o):r.push(o)}return r},e.zero2=r,e.toHex=i,e.encode=function(t,e){return'hex'===e?i(t):t}})),Ye=h((t=>{var e=t,r=We(),i=zt(),n=Ze();e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode,e.getNAF=function(t,e,r){var i=new Array(Math.max(t.bitLength(),r)+1);i.fill(0);for(var n=1<(n>>1)-1?(n>>1)-h:h,a.isubn(s)):s=0,i[o]=s,a.iushrn(1)}return i},e.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,a=0;t.cmpn(-n)>0||e.cmpn(-a)>0;){var o,s,h=t.andln(3)+n&3,u=e.andln(3)+a&3;3===h&&(h=-1),3===u&&(u=-1),o=1&h?3!=(i=t.andln(7)+n&7)&&5!==i||2!==u?h:-h:0,r[0].push(o),s=1&u?3!=(i=e.andln(7)+a&7)&&5!==i||2!==h?u:-u:0,r[1].push(s),2*n===o+1&&(n=1-n),2*a===s+1&&(a=1-a),t.iushrn(1),e.iushrn(1)}return r},e.cachedProperty=function(t,e,r){var i='_'+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},e.parseBytes=function(t){return'string'==typeof t?e.toArray(t,'hex'):t},e.intFromLE=function(t){return new r(t,'hex','le')}})),$e=h(((t,e)=>{var r=We(),i=Ye(),n=i.getNAF,a=i.getJSF,o=i.assert;function s(t,e){this.type=t,this.p=new r(e.p,16),this.red=e.prime?r.red(e.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=e.n&&new r(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var i=this.n&&this.p.div(this.n);!i||i.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function h(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=s,s.prototype.point=function(){throw new Error('Not implemented')},s.prototype.validate=function(){throw new Error('Not implemented')},s.prototype._fixedNafMul=function(t,e){o(t.precomputed);var r=t._getDoubles(),i=n(e,1,this._bitLength),a=(1<=s;l--)h=(h<<1)+i[l];u.push(h)}for(var f=this.jpoint(null,null,null),c=this.jpoint(null,null,null),d=a;d>0;d--){for(s=0;s=0;u--){for(var l=0;u>=0&&0===s[u];u--)l++;if(u>=0&&l++,h=h.dblp(l),u<0)break;var f=s[u];o(0!==f),h='affine'===t.type?f>0?h.mixedAdd(a[f-1>>1]):h.mixedAdd(a[-f-1>>1].neg()):f>0?h.add(a[f-1>>1]):h.add(a[-f-1>>1].neg())}return'affine'===t.type?h.toP():h},s.prototype._wnafMulAdd=function(t,e,r,i,o){var s,h,u,l=this._wnafT1,f=this._wnafT2,c=this._wnafT3,d=0;for(s=0;s=1;s-=2){var m=s-1,g=s;if(1===l[m]&&1===l[g]){var y=[e[m],null,null,e[g]];0===e[m].y.cmp(e[g].y)?(y[1]=e[m].add(e[g]),y[2]=e[m].toJ().mixedAdd(e[g].neg())):0===e[m].y.cmp(e[g].y.redNeg())?(y[1]=e[m].toJ().mixedAdd(e[g]),y[2]=e[m].add(e[g].neg())):(y[1]=e[m].toJ().mixedAdd(e[g]),y[2]=e[m].toJ().mixedAdd(e[g].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],b=a(r[m],r[g]);for(d=Math.max(b[0].length,d),c[m]=new Array(d),c[g]=new Array(d),h=0;h=0;s--){for(var S=0;s>=0;){var C=!0;for(h=0;h=0&&S++,_=_.dblp(S),s<0)break;for(h=0;h0?u=f[h][A-1>>1]:A<0&&(u=f[h][-A-1>>1].neg()),_='affine'===u.type?_.mixedAdd(u):_.add(u))}}for(s=0;s=Math.ceil((t.bitLength()+1)/e.step)},h.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n{var r=Ye(),i=We(),n=b(),a=$e(),o=r.assert;function s(t){a.call(this,'short',t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function h(t,e,r,n){a.BasePoint.call(this,t,'affine'),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function u(t,e,r,n){a.BasePoint.call(this,t,'jacobian'),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(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.zOne=this.z===this.curve.one}n(s,a),e.exports=s,s.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r,n;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var a=this._getEndoRoots(this.p);e=(e=a[0].cmp(a[1])<0?a[0]:a[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var s=this._getEndoRoots(this.n);0===this.g.mul(s[0]).x.cmp(this.g.x.redMul(e))?r=s[0]:(r=s[1],o(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return n=t.basis?t.basis.map((function(t){return{a:new i(t.a,16),b:new i(t.b,16)}})):this._getEndoBasis(r),{beta:e,lambda:r,basis:n}}},s.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),a=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(a).fromRed(),n.redSub(a).fromRed()]},s.prototype._getEndoBasis=function(t){for(var e,r,n,a,o,s,h,u,l,f=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=t,d=this.n.clone(),p=new i(1),m=new i(0),g=new i(0),y=new i(1),v=0;0!==c.cmpn(0);){var b=d.div(c);u=d.sub(b.mul(c)),l=g.sub(b.mul(p));var w=y.sub(b.mul(m));if(!n&&u.cmp(f)<0)e=h.neg(),r=p,n=u.neg(),a=l;else if(n&&2==++v)break;h=u,d=c,c=u,g=p,p=l,y=m,m=w}o=u.neg(),s=l;var M=n.sqr().add(a.sqr());return o.sqr().add(s.sqr()).cmp(M)>=0&&(o=e,s=r),n.negative&&(n=n.neg(),a=a.neg()),o.negative&&(o=o.neg(),s=s.neg()),[{a:n,b:a},{a:o,b:s}]},s.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),a=r.b.neg().mul(t).divRound(this.n),o=n.mul(r.a),s=a.mul(i.a),h=n.mul(r.b),u=a.mul(i.b);return{k1:t.sub(o).sub(s),k2:h.add(u).neg()}},s.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error('invalid point');var a=n.fromRed().isOdd();return(e&&!a||!e&&a)&&(n=n.redNeg()),this.point(t,n)},s.prototype.validate=function(t){if(t.inf)return!0;var{x:e,y:r}=t,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},s.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,a=0;a':''},h.prototype.isInfinity=function(){return this.inf},h.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},h.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),a=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,o)},h.prototype.getX=function(){return this.x.fromRed()},h.prototype.getY=function(){return this.y.fromRed()},h.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},h.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},h.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},h.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},h.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.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 e},h.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},n(u,a.BasePoint),s.prototype.jpoint=function(t,e,r){return new u(this,t,e,r)},u.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},u.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},u.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),a=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),s=i.redSub(n),h=a.redSub(o);if(0===s.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),l=u.redMul(s),f=i.redMul(u),c=h.redSqr().redIAdd(l).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(a.redMul(l)),p=this.z.redMul(t.z).redMul(s);return this.curve.jpoint(c,d,p)},u.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,a=t.y.redMul(e).redMul(this.z),o=r.redSub(i),s=n.redSub(a);if(0===o.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),u=h.redMul(o),l=r.redMul(h),f=s.redSqr().redIAdd(u).redISub(l).redISub(l),c=s.redMul(l.redISub(f)).redISub(n.redMul(u)),d=this.z.redMul(o);return this.curve.jpoint(f,c,d)},u.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},u.prototype.inspect=function(){return this.isInfinity()?'':''},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}})),Xe=h(((t,e)=>{var r=We(),i=b(),n=$e(),a=Ye();function o(t){n.call(this,'mont',t),this.a=new r(t.a,16).toRed(this.red),this.b=new r(t.b,16).toRed(this.red),this.i4=new r(4).toRed(this.red).redInvm(),this.two=new r(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function s(t,e,i){n.BasePoint.call(this,t,'projective'),null===e&&null===i?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new r(e,16),this.z=new r(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(o,n),e.exports=o,o.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),i=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===i.redSqrt().redSqr().cmp(i)},i(s,n.BasePoint),o.prototype.decodePoint=function(t,e){return this.point(a.toArray(t,e),1)},o.prototype.point=function(t,e){return new s(this,t,e)},o.prototype.pointFromJSON=function(t){return s.fromJSON(this,t)},s.prototype.precompute=function(){},s.prototype._encode=function(){return this.getX().toArray('be',this.curve.p.byteLength())},s.fromJSON=function(t,e){return new s(t,e[0],e[1]||t.one)},s.prototype.inspect=function(){return this.isInfinity()?'':''},s.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},s.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),i=t.redMul(e),n=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},s.prototype.add=function(){throw new Error('Not supported on Montgomery curve')},s.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=t.x.redAdd(t.z),a=t.x.redSub(t.z).redMul(r),o=n.redMul(i),s=e.z.redMul(a.redAdd(o).redSqr()),h=e.x.redMul(a.redISub(o).redSqr());return this.curve.point(s,h)},s.prototype.mul=function(t){for(var e=t.clone(),r=this,i=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.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},s.prototype.mulAdd=function(){throw new Error('Not supported on Montgomery curve')},s.prototype.jumlAdd=function(){throw new Error('Not supported on Montgomery curve')},s.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},s.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},s.prototype.getX=function(){return this.normalize(),this.x.fromRed()}})),Je=h(((t,e)=>{var r=Ye(),i=We(),n=b(),a=$e(),o=r.assert;function s(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,a.call(this,'edwards',t),this.a=new i(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),o(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function h(t,e,r,n,o){a.BasePoint.call(this,t,'projective'),null===e&&null===r&&null===n?(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 i(e,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=o&&new i(o,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()))))}n(s,a),e.exports=s,s.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},s.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},s.prototype.jpoint=function(t,e,r,i){return this.point(t,e,r,i)},s.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=this.c2.redSub(this.a.redMul(r)),a=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=n.redMul(a.redInvm()),s=o.redSqrt();if(0!==s.redSqr().redSub(o).cmp(this.zero))throw new Error('invalid point');var h=s.fromRed().isOdd();return(e&&!h||!e&&h)&&(s=s.redNeg()),this.point(t,s)},s.prototype.pointFromY=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=r.redSub(this.c2),a=r.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(a.redInvm());if(0===o.cmp(this.zero)){if(e)throw new Error('invalid point');return this.point(this.zero,t)}var s=o.redSqrt();if(0!==s.redSqr().redSub(o).cmp(this.zero))throw new Error('invalid point');return s.fromRed().isOdd()!==e&&(s=s.redNeg()),this.point(s,t)},s.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),i=e.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===i.cmp(n)},n(h,a.BasePoint),s.prototype.pointFromJSON=function(t){return h.fromJSON(this,t)},s.prototype.point=function(t,e,r,i){return new h(this,t,e,r,i)},h.fromJSON=function(t,e){return new h(t,e[0],e[1],e[2])},h.prototype.inspect=function(){return this.isInfinity()?'':''},h.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},h.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),a=i.redAdd(e),o=a.redSub(r),s=i.redSub(e),h=n.redMul(o),u=a.redMul(s),l=n.redMul(s),f=o.redMul(a);return this.curve.point(h,u,f,l)},h.prototype._projDbl=function(){var t,e,r,i,n,a,o=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),h=this.y.redSqr();if(this.curve.twisted){var u=(i=this.curve._mulA(s)).redAdd(h);this.zOne?(t=o.redSub(s).redSub(h).redMul(u.redSub(this.curve.two)),e=u.redMul(i.redSub(h)),r=u.redSqr().redSub(u).redSub(u)):(n=this.z.redSqr(),a=u.redSub(n).redISub(n),t=o.redSub(s).redISub(h).redMul(a),e=u.redMul(i.redSub(h)),r=u.redMul(a))}else i=s.redAdd(h),n=this.curve._mulC(this.z).redSqr(),a=i.redSub(n).redSub(n),t=this.curve._mulC(o.redISub(i)).redMul(a),e=this.curve._mulC(i).redMul(s.redISub(h)),r=i.redMul(a);return this.curve.point(t,e,r)},h.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},h.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),a=r.redSub(e),o=n.redSub(i),s=n.redAdd(i),h=r.redAdd(e),u=a.redMul(o),l=s.redMul(h),f=a.redMul(h),c=o.redMul(s);return this.curve.point(u,l,c,f)},h.prototype._projAdd=function(t){var e,r,i=this.z.redMul(t.z),n=i.redSqr(),a=this.x.redMul(t.x),o=this.y.redMul(t.y),s=this.curve.d.redMul(a).redMul(o),h=n.redSub(s),u=n.redAdd(s),l=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(a).redISub(o),f=i.redMul(h).redMul(l);return this.curve.twisted?(e=i.redMul(u).redMul(o.redSub(this.curve._mulA(a))),r=h.redMul(u)):(e=i.redMul(u).redMul(o.redSub(a)),r=this.curve._mulC(h).redMul(u)),this.curve.point(f,e,r)},h.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},h.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},h.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},h.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},h.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},h.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},h.prototype.getX=function(){return this.normalize(),this.x.fromRed()},h.prototype.getY=function(){return this.normalize(),this.y.fromRed()},h.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},h.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(i),0===this.x.cmp(e))return!0}},h.prototype.toP=h.prototype.normalize,h.prototype.mixedAdd=h.prototype.add})),tr=h((t=>{var e=t;e.base=$e(),e.short=Qe(),e.mont=Xe(),e.edwards=Je()})),er=h((t=>{var e=zt(),r=b();function i(t,e){return!(55296!=(64512&t.charCodeAt(e))||e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function n(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?'0'+t:t}function o(t){return 7===t.length?'0'+t:6===t.length?'00'+t:5===t.length?'000'+t:4===t.length?'0000'+t:3===t.length?'00000'+t:2===t.length?'000000'+t:1===t.length?'0000000'+t:t}t.inherits=r,t.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if('string'==typeof t)if(e){if('hex'===e)for((t=t.replace(/[^a-z0-9]+/gi,'')).length%2!=0&&(t='0'+t),a=0;a>6|192,r[n++]=63&o|128):i(t,a)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++a)),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=63&o|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=63&o|128)}else for(a=0;a>>0}return o},t.split32=function(t,e){for(var r=new Array(4*t.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},t.rotr32=function(t,e){return t>>>e|t<<32-e},t.rotl32=function(t,e){return t<>>32-e},t.sum32=function(t,e){return t+e>>>0},t.sum32_3=function(t,e,r){return t+e+r>>>0},t.sum32_4=function(t,e,r,i){return t+e+r+i>>>0},t.sum32_5=function(t,e,r,i,n){return t+e+r+i+n>>>0},t.sum64=function(t,e,r,i){var n=t[e],a=i+t[e+1]>>>0,o=(a>>0,t[e+1]=a},t.sum64_hi=function(t,e,r,i){return(e+i>>>0>>0},t.sum64_lo=function(t,e,r,i){return e+i>>>0},t.sum64_4_hi=function(t,e,r,i,n,a,o,s){var h=0,u=e;return h+=(u=u+i>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(t,e,r,i,n,a,o,s){return e+i+a+s>>>0},t.sum64_5_hi=function(t,e,r,i,n,a,o,s,h,u){var l=0,f=e;return l+=(f=f+i>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(t,e,r,i,n,a,o,s,h,u){return e+i+a+s+u>>>0},t.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},t.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},t.shr64_hi=function(t,e,r){return t>>>r},t.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}})),rr=h((t=>{var e=er(),r=zt();function i(){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}t.BlockHash=i,i.prototype.update=function(t,r){if(t=e.toArray(t,r),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var i=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-i,t.length),0===this.pending.length&&(this.pending=null),t=e.join32(t,0,t.length-i,this.endian);for(var n=0;n>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,a=8;a{var e=er().rotr32;function r(t,e,r){return t&e^~t&r}function i(t,e,r){return t&e^t&r^e&r}function n(t,e,r){return t^e^r}t.ft_1=function(t,e,a,o){return 0===t?r(e,a,o):1===t||3===t?n(e,a,o):2===t?i(e,a,o):void 0},t.ch32=r,t.maj32=i,t.p32=n,t.s0_256=function(t){return e(t,2)^e(t,13)^e(t,22)},t.s1_256=function(t){return e(t,6)^e(t,11)^e(t,25)},t.g0_256=function(t){return e(t,7)^e(t,18)^t>>>3},t.g1_256=function(t){return e(t,17)^e(t,19)^t>>>10}})),nr=h(((t,e)=>{var r=er(),i=rr(),n=ir(),a=r.rotl32,o=r.sum32,s=r.sum32_5,h=n.ft_1,u=i.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function f(){if(!(this instanceof f))return new f;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(f,u),e.exports=f,f.blockSize=512,f.outSize=160,f.hmacStrength=80,f.padLength=64,f.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i{var r=er(),i=rr(),n=ir(),a=zt(),o=r.sum32,s=r.sum32_4,h=r.sum32_5,u=n.ch32,l=n.maj32,f=n.s0_256,c=n.s1_256,d=n.g0_256,p=n.g1_256,m=i.BlockHash,g=[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 y(){if(!(this instanceof y))return new y;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(y,m),e.exports=y,y.blockSize=512,y.outSize=256,y.hmacStrength=192,y.padLength=64,y.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i{var r=er(),i=ar();function n(){if(!(this instanceof n))return new n;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}r.inherits(n,i),e.exports=n,n.blockSize=512,n.outSize=224,n.hmacStrength=192,n.padLength=64,n.prototype._digest=function(t){return'hex'===t?r.toHex32(this.h.slice(0,7),'big'):r.split32(this.h.slice(0,7),'big')}})),sr=h(((t,e)=>{var r=er(),i=rr(),n=zt(),a=r.rotr64_hi,o=r.rotr64_lo,s=r.shr64_hi,h=r.shr64_lo,u=r.sum64,l=r.sum64_hi,f=r.sum64_lo,c=r.sum64_4_hi,d=r.sum64_4_lo,p=r.sum64_5_hi,m=r.sum64_5_lo,g=i.BlockHash,y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=y,this.W=new Array(160)}function b(t,e,r,i,n){var a=t&r^~t&n;return a<0&&(a+=4294967296),a}function w(t,e,r,i,n,a){var o=e&i^~e&a;return o<0&&(o+=4294967296),o}function M(t,e,r,i,n){var a=t&r^t&n^r&n;return a<0&&(a+=4294967296),a}function _(t,e,r,i,n,a){var o=e&i^e&a^i&a;return o<0&&(o+=4294967296),o}function E(t,e){var r=a(t,e,28)^a(e,t,2)^a(e,t,7);return r<0&&(r+=4294967296),r}function S(t,e){var r=o(t,e,28)^o(e,t,2)^o(e,t,7);return r<0&&(r+=4294967296),r}function C(t,e){var r=a(t,e,14)^a(t,e,18)^a(e,t,9);return r<0&&(r+=4294967296),r}function A(t,e){var r=o(t,e,14)^o(t,e,18)^o(e,t,9);return r<0&&(r+=4294967296),r}function I(t,e){var r=a(t,e,1)^a(t,e,8)^s(t,e,7);return r<0&&(r+=4294967296),r}function T(t,e){var r=o(t,e,1)^o(t,e,8)^h(t,e,7);return r<0&&(r+=4294967296),r}function B(t,e){var r=a(t,e,19)^a(e,t,29)^s(t,e,6);return r<0&&(r+=4294967296),r}function k(t,e){var r=o(t,e,19)^o(e,t,29)^h(t,e,6);return r<0&&(r+=4294967296),r}r.inherits(v,g),e.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i{var r=er(),i=sr();function n(){if(!(this instanceof n))return new n;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}r.inherits(n,i),e.exports=n,n.blockSize=1024,n.outSize=384,n.hmacStrength=192,n.padLength=128,n.prototype._digest=function(t){return'hex'===t?r.toHex32(this.h.slice(0,12),'big'):r.split32(this.h.slice(0,12),'big')}})),ur=h((t=>{t.sha1=nr(),t.sha224=or(),t.sha256=ar(),t.sha384=hr(),t.sha512=sr()})),lr=h((t=>{var e=er(),r=rr(),i=e.rotl32,n=e.sum32,a=e.sum32_3,o=e.sum32_4,s=r.BlockHash;function h(){if(!(this instanceof h))return new h;s.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian='little'}function u(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function l(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function f(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}e.inherits(h,s),t.ripemd160=h,h.blockSize=512,h.outSize=160,h.hmacStrength=192,h.padLength=64,h.prototype._update=function(t,e){for(var r=this.h[0],s=this.h[1],h=this.h[2],g=this.h[3],y=this.h[4],v=r,b=s,w=h,M=g,_=y,E=0;E<80;E++){var S=n(i(o(r,u(E,s,h,g),t[c[E]+e],l(E)),p[E]),y);r=y,y=g,g=i(h,10),h=s,s=S,S=n(i(o(v,u(79-E,b,w,M),t[d[E]+e],f(E)),m[E]),_),v=_,_=M,M=i(w,10),w=b,b=S}S=a(this.h[1],h,M),this.h[1]=a(this.h[2],g,_),this.h[2]=a(this.h[3],y,v),this.h[3]=a(this.h[4],r,b),this.h[4]=a(this.h[0],s,w),this.h[0]=S},h.prototype._digest=function(t){return'hex'===t?e.toHex32(this.h,'little'):e.split32(this.h,'little')};var c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],d=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],p=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],m=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]})),fr=h(((t,e)=>{var r=er(),i=zt();function n(t,e,i){if(!(this instanceof n))return new n(t,e,i);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(e,i))}e.exports=n,n.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e{var e=t;e.utils=er(),e.common=rr(),e.sha=ur(),e.ripemd=lr(),e.hmac=fr(),e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160})),dr=h(((t,e)=>{e.exports={doubles:{step:4,points:[['e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a','f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'],['8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508','11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'],['175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739','d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'],['363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640','4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'],['8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c','4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'],['723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda','96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'],['eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa','5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'],['100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0','cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'],['e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d','9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'],['feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d','e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'],['da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1','9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'],['53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0','5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'],['8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047','10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'],['385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862','283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'],['6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7','7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'],['3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd','56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'],['85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83','7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'],['948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a','53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'],['6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8','bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'],['e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d','4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'],['e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725','7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'],['213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754','4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'],['4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c','17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'],['fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6','6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'],['76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39','c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'],['c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891','893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'],['d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b','febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'],['b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03','2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'],['e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d','eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'],['a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070','7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'],['90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4','e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'],['8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da','662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'],['e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11','1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'],['8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e','efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'],['e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41','2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'],['b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef','67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'],['d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8','db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'],['324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d','648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'],['4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96','35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'],['9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd','ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'],['6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5','9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'],['a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266','40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'],['7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71','34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'],['928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac','c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'],['85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751','1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'],['ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e','493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'],['827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241','c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'],['eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3','be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'],['e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f','4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'],['1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19','aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'],['146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be','b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'],['fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9','6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'],['da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2','8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'],['a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13','7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'],['174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c','ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'],['959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba','2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'],['d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151','e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'],['64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073','d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'],['8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458','38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'],['13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b','69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'],['bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366','d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'],['8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa','40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'],['8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0','620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'],['dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787','7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'],['f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e','ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82']]},naf:{wnd:7,points:[['f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9','388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'],['2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4','d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'],['5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc','6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'],['acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe','cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'],['774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb','d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'],['f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8','ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'],['d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e','581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'],['defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34','4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'],['2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c','85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'],['352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5','321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'],['2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f','2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'],['9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714','73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'],['daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729','a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'],['c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db','2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'],['6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4','e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'],['1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5','b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'],['605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479','2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'],['62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d','80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'],['80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f','1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'],['7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb','d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'],['d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9','eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'],['49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963','758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'],['77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74','958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'],['f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530','e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'],['463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b','5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'],['f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247','cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'],['caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1','cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'],['2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120','4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'],['7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435','91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'],['754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18','673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'],['e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8','59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'],['186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb','3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'],['df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f','55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'],['5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143','efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'],['290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba','e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'],['af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45','f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'],['766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a','744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'],['59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e','c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'],['f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8','e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'],['7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c','30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'],['948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519','e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'],['7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab','100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'],['3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca','ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'],['d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf','8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'],['1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610','68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'],['733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4','f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'],['15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c','d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'],['a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940','edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'],['e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980','a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'],['311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3','66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'],['34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf','9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'],['f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63','4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'],['d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448','fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'],['32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf','5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'],['7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5','8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'],['ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6','8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'],['16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5','5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'],['eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99','f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'],['78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51','f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'],['494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5','42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'],['a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5','204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'],['c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997','4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'],['841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881','73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'],['5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5','39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'],['36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66','d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'],['336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726','ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'],['8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede','6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'],['1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94','60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'],['85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31','3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'],['29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51','b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'],['a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252','ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'],['4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5','cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'],['d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b','6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'],['ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4','322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'],['af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f','6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'],['e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889','2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'],['591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246','b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'],['11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984','998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'],['3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a','b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'],['cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030','bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'],['c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197','6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'],['c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593','c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'],['a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef','21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'],['347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38','60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'],['da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a','49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'],['c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111','5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'],['4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502','7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'],['3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea','be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'],['cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26','8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'],['b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986','39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'],['d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e','62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'],['48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4','25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'],['dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda','ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'],['6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859','cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'],['e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f','f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'],['eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c','6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'],['13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942','fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'],['ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a','1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'],['b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80','5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'],['ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d','438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'],['8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1','cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'],['52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63','c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'],['e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352','6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'],['7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193','ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'],['5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00','9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'],['32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58','ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'],['e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7','d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'],['8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8','c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'],['4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e','67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'],['3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d','cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'],['674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b','299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'],['d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f','f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'],['30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6','462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'],['be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297','62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'],['93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a','7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'],['b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c','ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'],['d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52','4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'],['d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb','bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'],['463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065','bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'],['7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917','603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'],['74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9','cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'],['30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3','553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'],['9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57','712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'],['176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66','ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'],['75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8','9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'],['809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721','9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'],['1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180','4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9']]}}})),pr=h((t=>{var e,r=t,i=cr(),n=tr(),a=Ye().assert;function o(t){'short'===t.type?this.curve=new n.short(t):'edwards'===t.type?this.curve=new n.edwards(t):this.curve=new n.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),'Invalid curve'),a(this.g.mul(this.n).isInfinity(),'Invalid curve, G*N != O')}function s(t,e){Object.defineProperty(r,t,{configurable:!0,enumerable:!0,get:function(){var i=new o(e);return Object.defineProperty(r,t,{configurable:!0,enumerable:!0,value:i}),i}})}r.PresetCurve=o,s('p192',{type:'short',prime:'p192',p:'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',a:'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',b:'64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',n:'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',hash:i.sha256,gRed:!1,g:['188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012','07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811']}),s('p224',{type:'short',prime:'p224',p:'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',a:'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',b:'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',n:'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',hash:i.sha256,gRed:!1,g:['b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21','bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34']}),s('p256',{type:'short',prime:null,p:'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',a:'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',b:'5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',n:'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',hash:i.sha256,gRed:!1,g:['6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296','4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5']}),s('p384',{type:'short',prime:null,p:'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff',a:'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc',b:'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',n:'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',hash:i.sha384,gRed:!1,g:['aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7','3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f']}),s('p521',{type:'short',prime:null,p:'000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff',a:'000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc',b:'00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',n:'000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',hash:i.sha512,gRed:!1,g:['000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66','00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650']}),s('curve25519',{type:'mont',prime:'p25519',p:'7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',a:'76d06',b:'1',n:'1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',hash:i.sha256,gRed:!1,g:['9']}),s('ed25519',{type:'edwards',prime:'p25519',p:'7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',a:'-1',c:'1',d:'52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',n:'1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',hash:i.sha256,gRed:!1,g:['216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a','6666666666666666666666666666666666666666666666666666666666666658']});try{e=dr()}catch{e=void 0}s('secp256k1',{type:'short',prime:'k256',p:'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',a:'0',b:'7',n:'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',h:'1',hash:i.sha256,beta:'7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',lambda:'5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',basis:[{a:'3086d221a7d46bcde86c90e49284eb15',b:'-e4437ed6010e88286f547fa90abfe4c3'},{a:'114ca50f7a8e2f3f657c1108d9d44cfd8',b:'3086d221a7d46bcde86c90e49284eb15'}],gRed:!1,g:['79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798','483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',e]})})),mr=h(((t,e)=>{var r=cr(),i=Ze(),n=zt();function a(t){if(!(this instanceof a))return new a(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||'hex'),r=i.toArray(t.nonce,t.nonceEnc||'hex'),o=i.toArray(t.pers,t.persEnc||'hex');n(e.length>=this.minEntropy/8,'Not enough entropy. Minimum is: '+this.minEntropy+' bits'),this._init(e,r,o)}e.exports=a,a.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,'Not enough entropy. Minimum is: '+this.minEntropy+' bits'),this._update(t.concat(r||[])),this._reseed=1},a.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error('Reseed is required');'string'!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||'hex'),this._update(r));for(var a=[];a.length{var r=We(),i=Ye().assert;function n(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=n,n.fromPublic=function(t,e,r){return e instanceof n?e:new n(t,{pub:e,pubEnc:r})},n.fromPrivate=function(t,e,r){return e instanceof n?e:new n(t,{priv:e,privEnc:r})},n.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:'Invalid public key'}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:'Public key * N != O'}:{result:!1,reason:'Public key is not a point'}},n.prototype.getPublic=function(t,e){return'string'==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},n.prototype.getPrivate=function(t){return'hex'===t?this.priv.toString(16,2):this.priv},n.prototype._importPrivate=function(t,e){this.priv=new r(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},n.prototype._importPublic=function(t,e){if(t.x||t.y)return'mont'===this.ec.curve.type?i(t.x,'Need x coordinate'):('short'===this.ec.curve.type||'edwards'===this.ec.curve.type)&&i(t.x&&t.y,'Need both x and y coordinate'),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},n.prototype.derive=function(t){return t.validate()||i(t.validate(),'public point not validated'),t.mul(this.priv).getX()},n.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},n.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},n.prototype.inspect=function(){return''}})),yr=h(((t,e)=>{var r=We(),i=Ye(),n=i.assert;function a(t,e){if(t instanceof a)return t;this._importDER(t,e)||(n(t.r&&t.s,'Signature without r or s'),this.r=new r(t.r,16),this.s=new r(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function o(){this.place=0}function s(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,a=0,o=e.place;a>>=0;return!(n<=127)&&(e.place=o,n)}function h(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=a,a.prototype._importDER=function(t,e){t=i.toArray(t,e);var n=new o;if(48!==t[n.place++])return!1;var a=s(t,n);if(!1===a||a+n.place!==t.length||2!==t[n.place++])return!1;var h=s(t,n);if(!1===h)return!1;var u=t.slice(n.place,h+n.place);if(n.place+=h,2!==t[n.place++])return!1;var l=s(t,n);if(!1===l||t.length!==l+n.place)return!1;var f=t.slice(n.place,l+n.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new r(u),this.s=new r(f),this.recoveryParam=null,!0},a.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=h(e),r=h(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];u(n,e.length),(n=n.concat(e)).push(2),u(n,r.length);var a=n.concat(r),o=[48];return u(o,a.length),o=o.concat(a),i.encode(o,t)}})),vr=h(((t,e)=>{var r=We(),i=mr(),n=Ye(),a=pr(),o=Ee(),s=n.assert,h=gr(),u=yr();function l(t){if(!(this instanceof l))return new l(t);'string'==typeof t&&(s(Object.prototype.hasOwnProperty.call(a,t),'Unknown curve '+t),t=a[t]),t instanceof a.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=l,l.prototype.keyPair=function(t){return new h(this,t)},l.prototype.keyFromPrivate=function(t,e){return h.fromPrivate(this,t,e)},l.prototype.keyFromPublic=function(t,e){return h.fromPublic(this,t,e)},l.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||'utf8',entropy:t.entropy||o(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||'utf8',nonce:this.n.toArray()}),n=this.n.byteLength(),a=this.n.sub(new r(2));;){var s=new r(e.generate(n));if(!(s.cmp(a)>0))return s.iaddn(1),this.keyFromPrivate(s)}},l.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},l.prototype.sign=function(t,e,n,a){'object'==typeof n&&(a=n,n=null),a||(a={}),e=this.keyFromPrivate(e,n),t=this._truncateToN(new r(t,16));for(var o=this.n.byteLength(),s=e.getPrivate().toArray('be',o),h=t.toArray('be',o),l=new i({hash:this.hash,entropy:s,nonce:h,pers:a.pers,persEnc:a.persEnc||'utf8'}),f=this.n.sub(new r(1)),c=0;;c++){var d=a.k?a.k(c):new r(l.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(f)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var m=p.getX(),g=m.umod(this.n);if(0!==g.cmpn(0)){var y=d.invm(this.n).mul(g.mul(e.getPrivate()).iadd(t));if(0!==(y=y.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==m.cmp(g)?2:0);return a.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y),v^=1),new u({r:g,s:y,recoveryParam:v})}}}}}},l.prototype.verify=function(t,e,i,n){t=this._truncateToN(new r(t,16)),i=this.keyFromPublic(i,n),e=new u(e,'hex');var{r:a,s:o}=e;if(a.cmpn(1)<0||a.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var s,h=o.invm(this.n),l=h.mul(t).umod(this.n),f=h.mul(a).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(l,i.getPublic(),f)).isInfinity()&&s.eqXToP(a):!(s=this.g.mulAdd(l,i.getPublic(),f)).isInfinity()&&0===s.getX().umod(this.n).cmp(a)},l.prototype.recoverPubKey=function(t,e,i,n){s((3&i)===i,'The recovery param is more than two bits'),e=new u(e,n);var a=this.n,o=new r(t),h=e.r,l=e.s,f=1&i,c=i>>1;if(h.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error('Unable to find sencond key candinate');h=c?this.curve.pointFromX(h.add(this.curve.n),f):this.curve.pointFromX(h,f);var d=e.r.invm(a),p=a.sub(o).mul(d).umod(a),m=l.mul(d).umod(a);return this.g.mulAdd(p,h,m)},l.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new u(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var a;try{a=this.recoverPubKey(t,e,n)}catch{continue}if(a.eq(r))return n}throw new Error('Unable to find valid recovery factor')}})),br=h(((t,e)=>{var r=Ye(),i=r.assert,n=r.parseBytes,a=r.cachedProperty;function o(t,e){this.eddsa=t,this._secret=n(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=n(e.pub)}o.fromPublic=function(t,e){return e instanceof o?e:new o(t,{pub:e})},o.fromSecret=function(t,e){return e instanceof o?e:new o(t,{secret:e})},o.prototype.secret=function(){return this._secret},a(o,'pubBytes',(function(){return this.eddsa.encodePoint(this.pub())})),a(o,'pub',(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),a(o,'privBytes',(function(){var t=this.eddsa,e=this.hash(),r=t.encodingLength-1,i=e.slice(0,t.encodingLength);return i[0]&=248,i[r]&=127,i[r]|=64,i})),a(o,'priv',(function(){return this.eddsa.decodeInt(this.privBytes())})),a(o,'hash',(function(){return this.eddsa.hash().update(this.secret()).digest()})),a(o,'messagePrefix',(function(){return this.hash().slice(this.eddsa.encodingLength)})),o.prototype.sign=function(t){return i(this._secret,'KeyPair can only verify'),this.eddsa.sign(t,this)},o.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},o.prototype.getSecret=function(t){return i(this._secret,'KeyPair is public only'),r.encode(this.secret(),t)},o.prototype.getPublic=function(t){return r.encode(this.pubBytes(),t)},e.exports=o})),wr=h(((t,e)=>{var r=We(),i=Ye(),n=i.assert,a=i.cachedProperty,o=i.parseBytes;function s(t,e){this.eddsa=t,'object'!=typeof e&&(e=o(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),n(e.R&&e.S,'Signature without R or S'),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof r&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}a(s,'S',(function(){return this.eddsa.decodeInt(this.Sencoded())})),a(s,'R',(function(){return this.eddsa.decodePoint(this.Rencoded())})),a(s,'Rencoded',(function(){return this.eddsa.encodePoint(this.R())})),a(s,'Sencoded',(function(){return this.eddsa.encodeInt(this.S())})),s.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},s.prototype.toHex=function(){return i.encode(this.toBytes(),'hex').toUpperCase()},e.exports=s})),Mr=h(((t,e)=>{var r=cr(),i=pr(),n=Ye(),a=n.assert,o=n.parseBytes,s=br(),h=wr();function u(t){if(a('ed25519'===t,'only tested with ed25519 so far'),!(this instanceof u))return new u(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=r.sha512}e.exports=u,u.prototype.sign=function(t,e){t=o(t);var r=this.keyFromSecret(e),i=this.hashInt(r.messagePrefix(),t),n=this.g.mul(i),a=this.encodePoint(n),s=this.hashInt(a,r.pubBytes(),t).mul(r.priv()),h=i.add(s).umod(this.curve.n);return this.makeSignature({R:n,S:h,Rencoded:a})},u.prototype.verify=function(t,e,r){t=o(t),e=this.makeSignature(e);var i=this.keyFromPublic(r),n=this.hashInt(e.Rencoded(),i.pubBytes(),t),a=this.g.mul(e.S());return e.R().add(i.pub().mul(n)).eq(a)},u.prototype.hashInt=function(){for(var t=this.hash(),e=0;e{var e=t;e.version=Ge().version,e.utils=Ye(),e.rand=Ee(),e.curve=tr(),e.curves=pr(),e.ec=vr(),e.eddsa=Mr()})),Er=h(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var a;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{a=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:be().Buffer}catch{}function o(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if('le'===i)for(n=0,a=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=s(t,e,i)<=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var a=t.length-r,o=a%i,s=Math.min(a,a-o)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.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'],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],a=0|e.words[0],o=n*a,s=67108863&o,h=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(a=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,a=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,o--)}for(0!==a&&(i=a.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);i=(p=p.idivn(d)).isZero()?m+i:u[c-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof a<'u'),this.toArrayLike(a,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),a=i||Math.max(1,n);r(n<=a,'byte array longer than desired length'),r(a>0,'Requested array length <= 0'),this.strip();var o,s,h='le'===e,u=new t(a),l=this.clone();if(h){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,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(;at.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,M=b>>>13,_=0|o[4],E=8191&_,S=_>>>13,C=0|o[5],A=8191&C,I=C>>>13,T=0|o[6],B=8191&T,k=T>>>13,R=0|o[7],N=8191&R,L=R>>>13,x=0|o[8],D=8191&x,U=x>>>13,P=0|o[9],O=8191&P,j=P>>>13,V=0|s[0],q=8191&V,K=V>>>13,F=0|s[1],H=8191&F,z=F>>>13,G=0|s[2],W=8191&G,Z=G>>>13,Y=0|s[3],$=8191&Y,Q=Y>>>13,X=0|s[4],J=8191&X,tt=X>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],at=8191&nt,ot=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ft=8191<,ct=lt>>>13,dt=0|s[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(f,q))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(c,q)|0))<<13)|0;u=((a=Math.imul(c,K))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,q),n=(n=Math.imul(p,K))+Math.imul(m,q)|0,a=Math.imul(m,K);var yt=(u+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,z)|0)+Math.imul(c,H)|0))<<13)|0;u=((a=a+Math.imul(c,z)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,q),n=(n=Math.imul(y,K))+Math.imul(v,q)|0,a=Math.imul(v,K),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,H)|0,a=a+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(f,W)|0)|0)+((8191&(n=(n=n+Math.imul(f,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((a=a+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(w,q),n=(n=Math.imul(w,K))+Math.imul(M,q)|0,a=Math.imul(M,K),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(v,H)|0,a=a+Math.imul(v,z)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,a=a+Math.imul(m,Z)|0;var bt=(u+(i=i+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,Q)|0)+Math.imul(c,$)|0))<<13)|0;u=((a=a+Math.imul(c,Q)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(E,q),n=(n=Math.imul(E,K))+Math.imul(S,q)|0,a=Math.imul(S,K),i=i+Math.imul(w,H)|0,n=(n=n+Math.imul(w,z)|0)+Math.imul(M,H)|0,a=a+Math.imul(M,z)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(v,W)|0,a=a+Math.imul(v,Z)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(m,$)|0,a=a+Math.imul(m,Q)|0;var wt=(u+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(c,J)|0))<<13)|0;u=((a=a+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,q),n=(n=Math.imul(A,K))+Math.imul(I,q)|0,a=Math.imul(I,K),i=i+Math.imul(E,H)|0,n=(n=n+Math.imul(E,z)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,z)|0,i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(M,W)|0,a=a+Math.imul(M,Z)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(v,$)|0,a=a+Math.imul(v,Q)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,a=a+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((a=a+Math.imul(c,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(B,q),n=(n=Math.imul(B,K))+Math.imul(k,q)|0,a=Math.imul(k,K),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,z)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,z)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,Z)|0,i=i+Math.imul(w,$)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(M,$)|0,a=a+Math.imul(M,Q)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,a=a+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,a=a+Math.imul(m,it)|0;var _t=(u+(i=i+Math.imul(f,at)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(c,at)|0))<<13)|0;u=((a=a+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,K))+Math.imul(L,q)|0,a=Math.imul(L,K),i=i+Math.imul(B,H)|0,n=(n=n+Math.imul(B,z)|0)+Math.imul(k,H)|0,a=a+Math.imul(k,z)|0,i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,Z)|0)+Math.imul(I,W)|0,a=a+Math.imul(I,Z)|0,i=i+Math.imul(E,$)|0,n=(n=n+Math.imul(E,Q)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,Q)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,J)|0,a=a+Math.imul(M,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,a=a+Math.imul(v,it)|0,i=i+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,at)|0,a=a+Math.imul(m,ot)|0;var Et=(u+(i=i+Math.imul(f,ht)|0)|0)+((8191&(n=(n=n+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((a=a+Math.imul(c,ut)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,q),n=(n=Math.imul(D,K))+Math.imul(U,q)|0,a=Math.imul(U,K),i=i+Math.imul(N,H)|0,n=(n=n+Math.imul(N,z)|0)+Math.imul(L,H)|0,a=a+Math.imul(L,z)|0,i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(k,W)|0,a=a+Math.imul(k,Z)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,Q)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,Q)|0,i=i+Math.imul(E,J)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,it)|0,i=i+Math.imul(y,at)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(v,at)|0,a=a+Math.imul(v,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,a=a+Math.imul(m,ut)|0;var St=(u+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((a=a+Math.imul(c,ct)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(O,q),n=(n=Math.imul(O,K))+Math.imul(j,q)|0,a=Math.imul(j,K),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(U,H)|0,a=a+Math.imul(U,z)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Z)|0)+Math.imul(L,W)|0,a=a+Math.imul(L,Z)|0,i=i+Math.imul(B,$)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(k,$)|0,a=a+Math.imul(k,Q)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,J)|0,a=a+Math.imul(I,tt)|0,i=i+Math.imul(E,rt)|0,n=(n=n+Math.imul(E,it)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,it)|0,i=i+Math.imul(w,at)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,a=a+Math.imul(v,ut)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,a=a+Math.imul(m,ct)|0;var Ct=(u+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((a=a+Math.imul(c,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(O,H),n=(n=Math.imul(O,z))+Math.imul(j,H)|0,a=Math.imul(j,z),i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,Z)|0)+Math.imul(U,W)|0,a=a+Math.imul(U,Z)|0,i=i+Math.imul(N,$)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(L,$)|0,a=a+Math.imul(L,Q)|0,i=i+Math.imul(B,J)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(k,J)|0,a=a+Math.imul(k,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,it)|0,i=i+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,a=a+Math.imul(M,ut)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,a=a+Math.imul(v,ct)|0;var At=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((a=a+Math.imul(m,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,W),n=(n=Math.imul(O,Z))+Math.imul(j,W)|0,a=Math.imul(j,Z),i=i+Math.imul(D,$)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(U,$)|0,a=a+Math.imul(U,Q)|0,i=i+Math.imul(N,J)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(L,J)|0,a=a+Math.imul(L,tt)|0,i=i+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,it)|0)+Math.imul(k,rt)|0,a=a+Math.imul(k,it)|0,i=i+Math.imul(A,at)|0,n=(n=n+Math.imul(A,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,i=i+Math.imul(E,ht)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(S,ht)|0,a=a+Math.imul(S,ut)|0,i=i+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ct)|0;var It=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((a=a+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,Q))+Math.imul(j,$)|0,a=Math.imul(j,Q),i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(U,J)|0,a=a+Math.imul(U,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(L,rt)|0,a=a+Math.imul(L,it)|0,i=i+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(k,at)|0,a=a+Math.imul(k,ot)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(I,ht)|0,a=a+Math.imul(I,ut)|0,i=i+Math.imul(E,ft)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(S,ft)|0,a=a+Math.imul(S,ct)|0;var Tt=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((a=a+Math.imul(M,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(O,J),n=(n=Math.imul(O,tt))+Math.imul(j,J)|0,a=Math.imul(j,tt),i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(U,rt)|0,a=a+Math.imul(U,it)|0,i=i+Math.imul(N,at)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(L,at)|0,a=a+Math.imul(L,ot)|0,i=i+Math.imul(B,ht)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(k,ht)|0,a=a+Math.imul(k,ut)|0,i=i+Math.imul(A,ft)|0,n=(n=n+Math.imul(A,ct)|0)+Math.imul(I,ft)|0,a=a+Math.imul(I,ct)|0;var Bt=(u+(i=i+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((a=a+Math.imul(S,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(O,rt),n=(n=Math.imul(O,it))+Math.imul(j,rt)|0,a=Math.imul(j,it),i=i+Math.imul(D,at)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(U,at)|0,a=a+Math.imul(U,ot)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(L,ht)|0,a=a+Math.imul(L,ut)|0,i=i+Math.imul(B,ft)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(k,ft)|0,a=a+Math.imul(k,ct)|0;var kt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((a=a+Math.imul(I,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(O,at),n=(n=Math.imul(O,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(U,ht)|0,a=a+Math.imul(U,ut)|0,i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(L,ft)|0,a=a+Math.imul(L,ct)|0;var Rt=(u+(i=i+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((a=a+Math.imul(k,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(O,ht),n=(n=Math.imul(O,ut))+Math.imul(j,ht)|0,a=Math.imul(j,ut),i=i+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,ct)|0)+Math.imul(U,ft)|0,a=a+Math.imul(U,ct)|0;var Nt=(u+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,mt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((a=a+Math.imul(L,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(O,ft),n=(n=Math.imul(O,ct))+Math.imul(j,ft)|0,a=Math.imul(j,ct);var Lt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((a=a+Math.imul(U,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var xt=(u+(i=Math.imul(O,pt))|0)+((8191&(n=(n=Math.imul(O,mt))+Math.imul(j,pt)|0))<<13)|0;return u=((a=Math.imul(j,mt))+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=Et,h[8]=St,h[9]=Ct,h[10]=At,h[11]=It,h[12]=Tt,h[13]=Bt,h[14]=kt,h[15]=Rt,h[16]=Nt,h[17]=Lt,h[18]=xt,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?c(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,i=o,o=n}return 0!==i?r.words[a]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,a){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=n/67108864|0,e+=a>>>26,this.words[i]=67108863&a}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,a=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(e=0;e>>26-i}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=n);u--){var f=0|this.words[u];this.words[u]=l<<26-a|f>>>a,l=f&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n>26,this.words[n+i]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),a=t,o=0|a.words[a.length-1];0!=(r=26-this._countBits(o))&&(a=a.ushln(r),i.iushln(r),o=0|a.words[a.length-1]);var s,h=i.length-a.length;if('mod'!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var c=67108864*(0|i.words[a.length+f])+(0|i.words[a.length+f-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(a,c,f);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(a,1,f),i.isZero()||(i.negative^=1);s&&(s.words[f]=c)}return s&&s.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),'mod'!==e&&(a=s.div.neg()),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.iadd(t)),{div:a,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),'mod'!==e&&(a=s.div.neg()),{div:a,mod:s.mod}):this.negative&t.negative?(s=this.neg().divmod(t.neg(),e),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var a,o,s},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a=new n(1),o=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;!(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(l),o.isub(f)),a.iushrn(1),o.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(f)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s),o.isub(h)):(i.isub(e),s.isub(a),h.isub(o))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,a=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var o=new n(1),s=new n(0),h=a.clone();i.cmpn(1)>0&&a.cmpn(1)>0;){for(var u=0,l=1;!(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;!(a.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(a.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);i.cmp(a)>=0?(i.isub(a),o.isub(s)):(a.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var a=e;e=r,r=a}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new _(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function w(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function M(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function _(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function E(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,a=o}a>>>=22,t.words[n-10]=a,0===a&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new w;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new M}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},_.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),o=0;!a.isZero()&&0===a.andln(1);)o++,a.iushrn(1);r(!a.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,a),c=this.pow(t,a.addn(1).iushrn(1)),d=this.pow(t,a),p=o;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var f=u>>l&1;a!==r[0]&&(a=this.sqr(a)),0!==f||0!==o?(o<<=1,o|=f,(4==++s||0===i&&0===l)&&(a=this.mul(a,r[o]),s=0,o=0)):s=0}h=26}return a},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new E(t)},i(E,_),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(i).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),Sr=h(((t,e)=>{var r,i=g(),n=i.Buffer,a={};for(r in i)!i.hasOwnProperty(r)||'SlowBuffer'===r||'Buffer'===r||(a[r]=i[r]);var o=a.Buffer={};for(r in n)!n.hasOwnProperty(r)||'allocUnsafe'===r||'allocUnsafeSlow'===r||(o[r]=n[r]);if(a.Buffer.prototype=n.prototype,(!o.from||o.from===Uint8Array.from)&&(o.from=function(t,e,r){if('number'==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&typeof t.length>'u')throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type '+typeof t);return n(t,e,r)}),o.alloc||(o.alloc=function(t,e,r){if('number'!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var i=n(t);return e&&0!==e.length?'string'==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i}),!a.kStringMaxLength)try{a.kStringMaxLength=process.binding('buffer').kStringMaxLength}catch{}a.constants||(a.constants={MAX_LENGTH:a.kMaxLength},a.kStringMaxLength&&(a.constants.MAX_STRING_LENGTH=a.kStringMaxLength)),e.exports=a})),Cr=h((t=>{var e=b();function r(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function i(t,e){this.path=t,this.rethrow(e)}t.Reporter=r,r.prototype.isError=function(t){return t instanceof i},r.prototype.save=function(){let t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},r.prototype.restore=function(t){let e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},r.prototype.enterKey=function(t){return this._reporterState.path.push(t)},r.prototype.exitKey=function(t){let e=this._reporterState;e.path=e.path.slice(0,t-1)},r.prototype.leaveKey=function(t,e,r){let i=this._reporterState;this.exitKey(t),null!==i.obj&&(i.obj[e]=r)},r.prototype.path=function(){return this._reporterState.path.join('/')},r.prototype.enterObject=function(){let t=this._reporterState,e=t.obj;return t.obj={},e},r.prototype.leaveObject=function(t){let e=this._reporterState,r=e.obj;return e.obj=t,r},r.prototype.error=function(t){let e,r=this._reporterState,n=t instanceof i;if(e=n?t:new i(r.path.map((function(t){return'['+JSON.stringify(t)+']'})).join(''),t.message||t,t.stack),!r.options.partial)throw e;return n||r.errors.push(e),e},r.prototype.wrapResult=function(t){let e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},e(i,Error),i.prototype.rethrow=function(t){if(this.message=t+' at: '+(this.path||'(shallow)'),Error.captureStackTrace&&Error.captureStackTrace(this,i),!this.stack)try{throw new Error(this.message)}catch(t){this.stack=t.stack}return this}})),Ar=h((t=>{var e=b(),r=Cr().Reporter,i=Sr().Buffer;function n(t,e){r.call(this,e),i.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error('Input not Buffer')}function a(t,e){if(Array.isArray(t))this.length=0,this.value=t.map((function(t){return a.isEncoderBuffer(t)||(t=new a(t,e)),this.length+=t.length,t}),this);else if('number'==typeof t){if(!(0<=t&&t<=255))return e.error('non-byte EncoderBuffer value');this.value=t,this.length=1}else if('string'==typeof t)this.value=t,this.length=i.byteLength(t);else{if(!i.isBuffer(t))return e.error('Unsupported type: '+typeof t);this.value=t,this.length=t.length}}e(n,r),t.DecoderBuffer=n,n.isDecoderBuffer=function(t){return t instanceof n||'object'==typeof t&&i.isBuffer(t.base)&&'DecoderBuffer'===t.constructor.name&&'number'==typeof t.offset&&'number'==typeof t.length&&'function'==typeof t.save&&'function'==typeof t.restore&&'function'==typeof t.isEmpty&&'function'==typeof t.readUInt8&&'function'==typeof t.skip&&'function'==typeof t.raw},n.prototype.save=function(){return{offset:this.offset,reporter:r.prototype.save.call(this)}},n.prototype.restore=function(t){let e=new n(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,r.prototype.restore.call(this,t.reporter),e},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||'DecoderBuffer overrun')},n.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||'DecoderBuffer overrun');let r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+t,this.offset+=t,r},n.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},t.EncoderBuffer=a,a.isEncoderBuffer=function(t){return t instanceof a||'object'==typeof t&&'EncoderBuffer'===t.constructor.name&&'number'==typeof t.length&&'function'==typeof t.join},a.prototype.join=function(t,e){return t||(t=i.alloc(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(t,e),e+=r.length})):('number'==typeof this.value?t[e]=this.value:'string'==typeof this.value?t.write(this.value,e):i.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t}})),Ir=h(((t,e)=>{var r=Cr().Reporter,i=Ar().EncoderBuffer,n=Ar().DecoderBuffer,a=zt(),o=['seq','seqof','set','setof','objid','bool','gentime','utctime','null_','enum','int','objDesc','bitstr','bmpstr','charstr','genstr','graphstr','ia5str','iso646str','numstr','octstr','printstr','t61str','unistr','utf8str','videostr'],s=['key','obj','use','optional','explicit','implicit','def','choice','any','contains'].concat(o);function h(t,e,r){let i={};this._baseState=i,i.name=r,i.enc=t,i.parent=e||null,i.children=null,i.tag=null,i.args=null,i.reverseArgs=null,i.choice=null,i.optional=!1,i.any=!1,i.obj=!1,i.use=null,i.useDecoder=null,i.key=null,i.default=null,i.explicit=null,i.implicit=null,i.contains=null,i.parent||(i.children=[],this._wrap())}e.exports=h;var u=['enc','parent','children','tag','args','reverseArgs','choice','optional','any','obj','use','alteredUse','key','default','explicit','implicit','contains'];h.prototype.clone=function(){let t=this._baseState,e={};u.forEach((function(r){e[r]=t[r]}));let r=new this.constructor(e.parent);return r._baseState=e,r},h.prototype._wrap=function(){let t=this._baseState;s.forEach((function(e){this[e]=function(){let r=new this.constructor(this);return t.children.push(r),r[e].apply(r,arguments)}}),this)},h.prototype._init=function(t){let e=this._baseState;a(null===e.parent),t.call(this),e.children=e.children.filter((function(t){return t._baseState.parent===this}),this),a.equal(e.children.length,1,'Root node can have only one child')},h.prototype._useArgs=function(t){let e=this._baseState,r=t.filter((function(t){return t instanceof this.constructor}),this);t=t.filter((function(t){return!(t instanceof this.constructor)}),this),0!==r.length&&(a(null===e.children),e.children=r,r.forEach((function(t){t._baseState.parent=this}),this)),0!==t.length&&(a(null===e.args),e.args=t,e.reverseArgs=t.map((function(t){if('object'!=typeof t||t.constructor!==Object)return t;let e={};return Object.keys(t).forEach((function(r){r==(0|r)&&(r|=0);let i=t[r];e[i]=r})),e})))},['_peekTag','_decodeTag','_use','_decodeStr','_decodeObjid','_decodeTime','_decodeNull','_decodeInt','_decodeBool','_decodeList','_encodeComposite','_encodeStr','_encodeObjid','_encodeTime','_encodeNull','_encodeInt','_encodeBool'].forEach((function(t){h.prototype[t]=function(){let e=this._baseState;throw new Error(t+' not implemented for encoding: '+e.enc)}})),o.forEach((function(t){h.prototype[t]=function(){let e=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===e.tag),e.tag=t,this._useArgs(r),this}})),h.prototype.use=function(t){a(t);let e=this._baseState;return a(null===e.use),e.use=t,this},h.prototype.optional=function(){return this._baseState.optional=!0,this},h.prototype.def=function(t){let e=this._baseState;return a(null===e.default),e.default=t,e.optional=!0,this},h.prototype.explicit=function(t){let e=this._baseState;return a(null===e.explicit&&null===e.implicit),e.explicit=t,this},h.prototype.implicit=function(t){let e=this._baseState;return a(null===e.explicit&&null===e.implicit),e.implicit=t,this},h.prototype.obj=function(){let t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},h.prototype.key=function(t){let e=this._baseState;return a(null===e.key),e.key=t,this},h.prototype.any=function(){return this._baseState.any=!0,this},h.prototype.choice=function(t){let e=this._baseState;return a(null===e.choice),e.choice=t,this._useArgs(Object.keys(t).map((function(e){return t[e]}))),this},h.prototype.contains=function(t){let e=this._baseState;return a(null===e.use),e.contains=t,this},h.prototype._decode=function(t,e){let r=this._baseState;if(null===r.parent)return t.wrapResult(r.children[0]._decode(t,e));let i,a=r.default,o=!0,s=null;if(null!==r.key&&(s=t.enterKey(r.key)),r.optional){let i=null;if(null!==r.explicit?i=r.explicit:null!==r.implicit?i=r.implicit:null!==r.tag&&(i=r.tag),null!==i||r.any){if(o=this._peekTag(t,i,r.any),t.isError(o))return o}else{let i=t.save();try{null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e),o=!0}catch{o=!1}t.restore(i)}}if(r.obj&&o&&(i=t.enterObject()),o){if(null!==r.explicit){let e=this._decodeTag(t,r.explicit);if(t.isError(e))return e;t=e}let i=t.offset;if(null===r.use&&null===r.choice){let e;r.any&&(e=t.save());let i=this._decodeTag(t,null!==r.implicit?r.implicit:r.tag,r.any);if(t.isError(i))return i;r.any?a=t.raw(e):t=i}if(e&&e.track&&null!==r.tag&&e.track(t.path(),i,t.length,'tagged'),e&&e.track&&null!==r.tag&&e.track(t.path(),t.offset,t.length,'content'),r.any||(a=null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e)),t.isError(a))return a;if(!r.any&&null===r.choice&&null!==r.children&&r.children.forEach((function(r){r._decode(t,e)})),r.contains&&('octstr'===r.tag||'bitstr'===r.tag)){let i=new n(a);a=this._getUse(r.contains,t._reporterState.obj)._decode(i,e)}}return r.obj&&o&&(a=t.leaveObject(i)),null===r.key||null===a&&!0!==o?null!==s&&t.exitKey(s):t.leaveKey(s,r.key,a),a},h.prototype._decodeGeneric=function(t,e,r){let i=this._baseState;return'seq'===t||'set'===t?null:'seqof'===t||'setof'===t?this._decodeList(e,t,i.args[0],r):/str$/.test(t)?this._decodeStr(e,t,r):'objid'===t&&i.args?this._decodeObjid(e,i.args[0],i.args[1],r):'objid'===t?this._decodeObjid(e,null,null,r):'gentime'===t||'utctime'===t?this._decodeTime(e,t,r):'null_'===t?this._decodeNull(e,r):'bool'===t?this._decodeBool(e,r):'objDesc'===t?this._decodeStr(e,t,r):'int'===t||'enum'===t?this._decodeInt(e,i.args&&i.args[0],r):null!==i.use?this._getUse(i.use,e._reporterState.obj)._decode(e,r):e.error('unknown tag: '+t)},h.prototype._getUse=function(t,e){let r=this._baseState;return r.useDecoder=this._use(t,e),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},h.prototype._decodeChoice=function(t,e){let r=this._baseState,i=null,n=!1;return Object.keys(r.choice).some((function(a){let o=t.save(),s=r.choice[a];try{let r=s._decode(t,e);if(t.isError(r))return!1;i={type:a,value:r},n=!0}catch{return t.restore(o),!1}return!0}),this),n?i:t.error('Choice not matched')},h.prototype._createEncoderBuffer=function(t){return new i(t,this.reporter)},h.prototype._encode=function(t,e,r){let i=this._baseState;if(null!==i.default&&i.default===t)return;let n=this._encodeValue(t,e,r);return void 0===n||this._skipDefault(n,e,r)?void 0:n},h.prototype._encodeValue=function(t,e,i){let n=this._baseState;if(null===n.parent)return n.children[0]._encode(t,e||new r);let a=null;if(this.reporter=e,n.optional&&void 0===t){if(null===n.default)return;t=n.default}let o=null,s=!1;if(n.any)a=this._createEncoderBuffer(t);else if(n.choice)a=this._encodeChoice(t,e);else if(n.contains)o=this._getUse(n.contains,i)._encode(t,e),s=!0;else if(n.children)o=n.children.map((function(r){if('null_'===r._baseState.tag)return r._encode(null,e,t);if(null===r._baseState.key)return e.error('Child should have a key');let i=e.enterKey(r._baseState.key);if('object'!=typeof t)return e.error('Child expected, but input is not object');let n=r._encode(t[r._baseState.key],e,t);return e.leaveKey(i),n}),this).filter((function(t){return t})),o=this._createEncoderBuffer(o);else if('seqof'===n.tag||'setof'===n.tag){if(!n.args||1!==n.args.length)return e.error('Too many args for : '+n.tag);if(!Array.isArray(t))return e.error('seqof/setof, but data is not Array');let r=this.clone();r._baseState.implicit=null,o=this._createEncoderBuffer(t.map((function(r){let i=this._baseState;return this._getUse(i.args[0],t)._encode(r,e)}),r))}else null!==n.use?a=this._getUse(n.use,i)._encode(t,e):(o=this._encodePrimitive(n.tag,t),s=!0);if(!n.any&&null===n.choice){let t=null!==n.implicit?n.implicit:n.tag,r=null===n.implicit?'universal':'context';null===t?null===n.use&&e.error('Tag could be omitted only for .use()'):null===n.use&&(a=this._encodeComposite(t,s,r,o))}return null!==n.explicit&&(a=this._encodeComposite(n.explicit,!1,'context',a)),a},h.prototype._encodeChoice=function(t,e){let r=this._baseState,i=r.choice[t.type];return i||a(!1,t.type+' not found in '+JSON.stringify(Object.keys(r.choice))),i._encode(t.value,e)},h.prototype._encodePrimitive=function(t,e){let r=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if('objid'===t&&r.args)return this._encodeObjid(e,r.reverseArgs[0],r.args[1]);if('objid'===t)return this._encodeObjid(e,null,null);if('gentime'===t||'utctime'===t)return this._encodeTime(e,t);if('null_'===t)return this._encodeNull();if('int'===t||'enum'===t)return this._encodeInt(e,r.args&&r.reverseArgs[0]);if('bool'===t)return this._encodeBool(e);if('objDesc'===t)return this._encodeStr(e,t);throw new Error('Unsupported tag: '+t)},h.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},h.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(t)}})),Tr=h((t=>{function e(t){let e={};return Object.keys(t).forEach((function(r){(0|r)==r&&(r|=0);let i=t[r];e[i]=r})),e}t.tagClass={0:'universal',1:'application',2:'context',3:'private'},t.tagClassByName=e(t.tagClass),t.tag={0:'end',1:'bool',2:'int',3:'bitstr',4:'octstr',5:'null_',6:'objid',7:'objDesc',8:'external',9:'real',10:'enum',11:'embed',12:'utf8str',13:'relativeOid',16:'seq',17:'set',18:'numstr',19:'printstr',20:'t61str',21:'videostr',22:'ia5str',23:'utctime',24:'gentime',25:'graphstr',26:'iso646str',27:'genstr',28:'unistr',29:'charstr',30:'bmpstr'},t.tagByName=e(t.tag)})),Br=h(((t,e)=>{var r=b(),i=Sr().Buffer,n=Ir(),a=Tr();function o(t){this.enc='der',this.name=t.name,this.entity=t,this.tree=new s,this.tree._init(t.body)}function s(t){n.call(this,'der',t)}function h(t){return t<10?'0'+t:t}e.exports=o,o.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},r(s,n),s.prototype._encodeComposite=function(t,e,r,n){let o=function(t,e,r,i){let n;if('seqof'===t?t='seq':'setof'===t&&(t='set'),a.tagByName.hasOwnProperty(t))n=a.tagByName[t];else{if('number'!=typeof t||(0|t)!==t)return i.error('Unknown tag: '+t);n=t}return n>=31?i.error('Multi-octet tag encoding unsupported'):(e||(n|=32),n|=a.tagClassByName[r||'universal']<<6,n)}(t,e,r,this.reporter);if(n.length<128){let t=i.alloc(2);return t[0]=o,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;let h=i.alloc(2+s);h[0]=o,h[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)h[t]=255&e;return this._createEncoderBuffer([h,n])},s.prototype._encodeStr=function(t,e){if('bitstr'===e)return this._createEncoderBuffer([0|t.unused,t.data]);if('bmpstr'===e){let e=i.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error('Second objid identifier OOB');t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}let a=i.alloc(n),o=a.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(a[o--]=127&r;(r>>=7)>0;)a[o--]=128|127&r}return this._createEncoderBuffer(a)},s.prototype._encodeTime=function(t,e){let r,i=new Date(t);return'gentime'===e?r=[h(i.getUTCFullYear()),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),'Z'].join(''):'utctime'===e?r=[h(i.getUTCFullYear()%100),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),'Z'].join(''):this.reporter.error('Encoding '+e+' time is not supported yet'),this._encodeStr(r,'octstr')},s.prototype._encodeNull=function(){return this._createEncoderBuffer('')},s.prototype._encodeInt=function(t,e){if('string'==typeof t){if(!e)return this.reporter.error('String int or enum given, but no values map');if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if('number'!=typeof t&&!i.isBuffer(t)){let e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=i.from(e)}if(i.isBuffer(t)){let e=t.length;0===t.length&&e++;let r=i.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;let n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(i.from(n))},s.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},s.prototype._use=function(t,e){return'function'==typeof t&&(t=t(e)),t._getEncoder('der').tree},s.prototype._skipDefault=function(t,e,r){let i,n=this._baseState;if(null===n.default)return!1;let a=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),a.length!==n.defaultBuffer.length)return!1;for(i=0;i{var r=b(),i=Br();function n(t){i.call(this,t),this.enc='pem'}r(n,i),e.exports=n,n.prototype.encode=function(t,e){let r=i.prototype.encode.call(this,t).toString('base64'),n=['-----BEGIN '+e.label+'-----'];for(let t=0;t{var e=t;e.der=Br(),e.pem=kr()})),Nr=h(((t,e)=>{var r=b(),i=Er(),n=Ar().DecoderBuffer,a=Ir(),o=Tr();function s(t){this.enc='der',this.name=t.name,this.entity=t,this.tree=new h,this.tree._init(t.body)}function h(t){a.call(this,'der',t)}function u(t,e){let r=t.readUInt8(e);if(t.isError(r))return r;let i=o.tagClass[r>>6],n=!(32&r);if(31&~r)r&=31;else{let i=r;for(r=0;!(128&~i);){if(i=t.readUInt8(e),t.isError(i))return i;r<<=7,r|=127&i}}return{cls:i,primitive:n,tag:r,tagStr:o.tag[r]}}function l(t,e,r){let i=t.readUInt8(r);if(t.isError(i))return i;if(!e&&128===i)return null;if(!(128&i))return i;let n=127&i;if(n>4)return t.error('length octect is too long');i=0;for(let e=0;e{var r=b(),i=Sr().Buffer,n=Nr();function a(t){n.call(this,t),this.enc='pem'}r(a,n),e.exports=a,a.prototype.decode=function(t,e){let r=t.toString().split(/[\r\n]+/g),a=e.label.toUpperCase(),o=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,h=-1;for(let t=0;t{var e=t;e.der=Nr(),e.pem=Lr()})),Dr=h((t=>{var e=Rr(),r=xr(),i=b();function n(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}t.define=function(t,e){return new n(t,e)},n.prototype._createNamed=function(t){let e=this.name;function r(t){this._initNamed(t,e)}return i(r,t),r.prototype._initNamed=function(e,r){t.call(this,e,r)},new r(this)},n.prototype._getDecoder=function(t){return t=t||'der',this.decoders.hasOwnProperty(t)||(this.decoders[t]=this._createNamed(r[t])),this.decoders[t]},n.prototype.decode=function(t,e,r){return this._getDecoder(e).decode(t,r)},n.prototype._getEncoder=function(t){return t=t||'der',this.encoders.hasOwnProperty(t)||(this.encoders[t]=this._createNamed(e[t])),this.encoders[t]},n.prototype.encode=function(t,e,r){return this._getEncoder(e).encode(t,r)}})),Ur=h((t=>{var e=t;e.Reporter=Cr().Reporter,e.DecoderBuffer=Ar().DecoderBuffer,e.EncoderBuffer=Ar().EncoderBuffer,e.Node=Ir()})),Pr=h((t=>{var e=t;e._reverse=function(t){let e={};return Object.keys(t).forEach((function(r){(0|r)==r&&(r|=0);let i=t[r];e[i]=r})),e},e.der=Tr()})),Or=h((t=>{var e=t;e.bignum=Er(),e.define=Dr().define,e.base=Ur(),e.constants=Pr(),e.decoders=xr(),e.encoders=Rr()})),jr=h(((t,e)=>{var r=Or(),i=r.define('Time',(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),n=r.define('AttributeTypeValue',(function(){this.seq().obj(this.key('type').objid(),this.key('value').any())})),a=r.define('AlgorithmIdentifier',(function(){this.seq().obj(this.key('algorithm').objid(),this.key('parameters').optional(),this.key('curve').objid().optional())})),o=r.define('SubjectPublicKeyInfo',(function(){this.seq().obj(this.key('algorithm').use(a),this.key('subjectPublicKey').bitstr())})),s=r.define('RelativeDistinguishedName',(function(){this.setof(n)})),h=r.define('RDNSequence',(function(){this.seqof(s)})),u=r.define('Name',(function(){this.choice({rdnSequence:this.use(h)})})),l=r.define('Validity',(function(){this.seq().obj(this.key('notBefore').use(i),this.key('notAfter').use(i))})),f=r.define('Extension',(function(){this.seq().obj(this.key('extnID').objid(),this.key('critical').bool().def(!1),this.key('extnValue').octstr())})),c=r.define('TBSCertificate',(function(){this.seq().obj(this.key('version').explicit(0).int().optional(),this.key('serialNumber').int(),this.key('signature').use(a),this.key('issuer').use(u),this.key('validity').use(l),this.key('subject').use(u),this.key('subjectPublicKeyInfo').use(o),this.key('issuerUniqueID').implicit(1).bitstr().optional(),this.key('subjectUniqueID').implicit(2).bitstr().optional(),this.key('extensions').explicit(3).seqof(f).optional())})),d=r.define('X509Certificate',(function(){this.seq().obj(this.key('tbsCertificate').use(c),this.key('signatureAlgorithm').use(a),this.key('signatureValue').bitstr())}));e.exports=d})),Vr=h((t=>{var e=Or();t.certificate=jr();var r=e.define('RSAPrivateKey',(function(){this.seq().obj(this.key('version').int(),this.key('modulus').int(),this.key('publicExponent').int(),this.key('privateExponent').int(),this.key('prime1').int(),this.key('prime2').int(),this.key('exponent1').int(),this.key('exponent2').int(),this.key('coefficient').int())}));t.RSAPrivateKey=r;var i=e.define('RSAPublicKey',(function(){this.seq().obj(this.key('modulus').int(),this.key('publicExponent').int())}));t.RSAPublicKey=i;var n=e.define('SubjectPublicKeyInfo',(function(){this.seq().obj(this.key('algorithm').use(a),this.key('subjectPublicKey').bitstr())}));t.PublicKey=n;var a=e.define('AlgorithmIdentifier',(function(){this.seq().obj(this.key('algorithm').objid(),this.key('none').null_().optional(),this.key('curve').objid().optional(),this.key('params').seq().obj(this.key('p').int(),this.key('q').int(),this.key('g').int()).optional())})),o=e.define('PrivateKeyInfo',(function(){this.seq().obj(this.key('version').int(),this.key('algorithm').use(a),this.key('subjectPrivateKey').octstr())}));t.PrivateKey=o;var s=e.define('EncryptedPrivateKeyInfo',(function(){this.seq().obj(this.key('algorithm').seq().obj(this.key('id').objid(),this.key('decrypt').seq().obj(this.key('kde').seq().obj(this.key('id').objid(),this.key('kdeparams').seq().obj(this.key('salt').octstr(),this.key('iters').int())),this.key('cipher').seq().obj(this.key('algo').objid(),this.key('iv').octstr()))),this.key('subjectPrivateKey').octstr())}));t.EncryptedPrivateKey=s;var h=e.define('DSAPrivateKey',(function(){this.seq().obj(this.key('version').int(),this.key('p').int(),this.key('q').int(),this.key('g').int(),this.key('pub_key').int(),this.key('priv_key').int())}));t.DSAPrivateKey=h,t.DSAparam=e.define('DSAparam',(function(){this.int()}));var u=e.define('ECPrivateKey',(function(){this.seq().obj(this.key('version').int(),this.key('privateKey').octstr(),this.key('parameters').optional().explicit(0).use(l),this.key('publicKey').optional().explicit(1).bitstr())}));t.ECPrivateKey=u;var l=e.define('ECParameters',(function(){this.choice({namedCurve:this.objid()})}));t.signature=e.define('signature',(function(){this.seq().obj(this.key('r').int(),this.key('s').int())}))})),qr=h(((t,e)=>{e.exports={'2.16.840.1.101.3.4.1.1':'aes-128-ecb','2.16.840.1.101.3.4.1.2':'aes-128-cbc','2.16.840.1.101.3.4.1.3':'aes-128-ofb','2.16.840.1.101.3.4.1.4':'aes-128-cfb','2.16.840.1.101.3.4.1.21':'aes-192-ecb','2.16.840.1.101.3.4.1.22':'aes-192-cbc','2.16.840.1.101.3.4.1.23':'aes-192-ofb','2.16.840.1.101.3.4.1.24':'aes-192-cfb','2.16.840.1.101.3.4.1.41':'aes-256-ecb','2.16.840.1.101.3.4.1.42':'aes-256-cbc','2.16.840.1.101.3.4.1.43':'aes-256-ofb','2.16.840.1.101.3.4.1.44':'aes-256-cfb'}})),Kr=h(((t,e)=>{var r=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,i=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,a=de(),o=ge(),s=y().Buffer;e.exports=function(t,e){var h,u=t.toString(),l=u.match(r);if(l){var f='aes'+l[1],c=s.from(l[2],'hex'),d=s.from(l[3].replace(/[\r\n]/g,''),'base64'),p=a(e,c.slice(0,8),parseInt(l[1],10)).key,m=[],g=o.createDecipheriv(f,p,c);m.push(g.update(d)),m.push(g.final()),h=s.concat(m)}else{var y=u.match(n);h=s.from(y[2].replace(/[\r\n]/g,''),'base64')}return{tag:u.match(i)[1],data:h}}})),Fr=h(((t,e)=>{var r=Vr(),i=qr(),n=Kr(),a=ge(),o=Ft(),s=y().Buffer;function h(t){var e;'object'==typeof t&&!s.isBuffer(t)&&(e=t.passphrase,t=t.key),'string'==typeof t&&(t=s.from(t));var h,u,l=n(t,e),f=l.tag,c=l.data;switch(f){case'CERTIFICATE':u=r.certificate.decode(c,'der').tbsCertificate.subjectPublicKeyInfo;case'PUBLIC KEY':switch(u||(u=r.PublicKey.decode(c,'der')),h=u.algorithm.algorithm.join('.')){case'1.2.840.113549.1.1.1':return r.RSAPublicKey.decode(u.subjectPublicKey.data,'der');case'1.2.840.10045.2.1':return u.subjectPrivateKey=u.subjectPublicKey,{type:'ec',data:u};case'1.2.840.10040.4.1':return u.algorithm.params.pub_key=r.DSAparam.decode(u.subjectPublicKey.data,'der'),{type:'dsa',data:u.algorithm.params};default:throw new Error('unknown key id '+h)}case'ENCRYPTED PRIVATE KEY':c=function(t,e){var r=t.algorithm.decrypt.kde.kdeparams.salt,n=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),h=i[t.algorithm.decrypt.cipher.algo.join('.')],u=t.algorithm.decrypt.cipher.iv,l=t.subjectPrivateKey,f=parseInt(h.split('-')[1],10)/8,c=o.pbkdf2Sync(e,r,n,f,'sha1'),d=a.createDecipheriv(h,c,u),p=[];return p.push(d.update(l)),p.push(d.final()),s.concat(p)}(c=r.EncryptedPrivateKey.decode(c,'der'),e);case'PRIVATE KEY':switch(h=(u=r.PrivateKey.decode(c,'der')).algorithm.algorithm.join('.')){case'1.2.840.113549.1.1.1':return r.RSAPrivateKey.decode(u.subjectPrivateKey,'der');case'1.2.840.10045.2.1':return{curve:u.algorithm.curve,privateKey:r.ECPrivateKey.decode(u.subjectPrivateKey,'der').privateKey};case'1.2.840.10040.4.1':return u.algorithm.params.priv_key=r.DSAparam.decode(u.subjectPrivateKey,'der'),{type:'dsa',params:u.algorithm.params};default:throw new Error('unknown key id '+h)}case'RSA PUBLIC KEY':return r.RSAPublicKey.decode(c,'der');case'RSA PRIVATE KEY':return r.RSAPrivateKey.decode(c,'der');case'DSA PRIVATE KEY':return{type:'dsa',params:r.DSAPrivateKey.decode(c,'der')};case'EC PRIVATE KEY':return{curve:(c=r.ECPrivateKey.decode(c,'der')).parameters.value,privateKey:c.privateKey};default:throw new Error('unknown key type '+f)}}e.exports=h,h.signature=r.signature})),Hr=h(((t,e)=>{e.exports={'1.3.132.0.10':'secp256k1','1.3.132.0.33':'p224','1.2.840.10045.3.1.1':'p192','1.2.840.10045.3.1.7':'p256','1.3.132.0.34':'p384','1.3.132.0.35':'p521'}})),zr=h(((t,e)=>{var r=y().Buffer,i=Dt(),n=ze(),a=_r().ec,o=He(),s=Fr(),h=Hr();function u(t,e,n,a){if((t=r.from(t.toArray())).length0&&r.ishrn(i),r}function f(t,e,n){var a,o;do{for(a=r.alloc(0);8*a.length{var r=y().Buffer,i=He(),n=_r().ec,a=Fr(),o=Hr();function s(t,e){if(t.cmpn(0)<=0)throw new Error('invalid sig');if(t.cmp(e)>=e)throw new Error('invalid sig')}e.exports=function(t,e,h,u,l){var f=a(h);if('ec'===f.type){if('ecdsa'!==u&&'ecdsa/rsa'!==u)throw new Error('wrong public key type');return function(t,e,r){var i=o[r.data.algorithm.curve.join('.')];if(!i)throw new Error('unknown curve '+r.data.algorithm.curve.join('.'));var a=new n(i),s=r.data.subjectPrivateKey.data;return a.verify(e,t,s)}(t,e,f)}if('dsa'===f.type){if('dsa'!==u)throw new Error('wrong public key type');return function(t,e,r){var n=r.data.p,o=r.data.q,h=r.data.g,u=r.data.pub_key,l=a.signature.decode(t,'der'),f=l.s,c=l.r;s(f,o),s(c,o);var d=i.mont(n),p=f.invm(o),m=h.toRed(d).redPow(new i(e).mul(p).mod(o)).fromRed().mul(u.toRed(d).redPow(c.mul(p).mod(o)).fromRed()).mod(n).mod(o);return 0===m.cmp(c)}(t,e,f)}if('rsa'!==u&&'ecdsa/rsa'!==u)throw new Error('wrong public key type');e=r.concat([l,e]);for(var c=f.modulus.byteLength(),d=[1],p=0;e.length+d.length+2{var r=y().Buffer,i=Nt(),n=Fe(),a=b(),o=zr(),s=Gr(),h=Ut();function u(t){n.Writable.call(this);var e=h[t];if(!e)throw new Error('Unknown message digest');this._hashType=e.hash,this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign}function l(t){n.Writable.call(this);var e=h[t];if(!e)throw new Error('Unknown message digest');this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){return new u(t)}function c(t){return new l(t)}Object.keys(h).forEach((function(t){h[t].id=r.from(h[t].id,'hex'),h[t.toLowerCase()]=h[t]})),a(u,n.Writable),u.prototype._write=function(t,e,r){this._hash.update(t),r()},u.prototype.update=function(t,e){return'string'==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},u.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),i=o(r,t,this._hashType,this._signType,this._tag);return e?i.toString(e):i},a(l,n.Writable),l.prototype._write=function(t,e,r){this._hash.update(t),r()},l.prototype.update=function(t,e){return'string'==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},l.prototype.verify=function(t,e,i){'string'==typeof e&&(e=r.from(e,i)),this.end();var n=this._hash.digest();return s(e,n,t,this._signType,this._tag)},e.exports={Sign:f,Verify:c,createSign:f,createVerify:c}})),Zr=h(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var a;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{a=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:be().Buffer}catch{}function o(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if('le'===i)for(n=0,a=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=s(t,e,i)<=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var a=t.length-r,o=a%i,s=Math.min(a,a-o)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.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'],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],a=0|e.words[0],o=n*a,s=67108863&o,h=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(a=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,a=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,o--)}for(0!==a&&(i=a.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);i=(p=p.idivn(d)).isZero()?m+i:u[c-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof a<'u'),this.toArrayLike(a,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),a=i||Math.max(1,n);r(n<=a,'byte array longer than desired length'),r(a>0,'Requested array length <= 0'),this.strip();var o,s,h='le'===e,u=new t(a),l=this.clone();if(h){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,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(;at.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,M=b>>>13,_=0|o[4],E=8191&_,S=_>>>13,C=0|o[5],A=8191&C,I=C>>>13,T=0|o[6],B=8191&T,k=T>>>13,R=0|o[7],N=8191&R,L=R>>>13,x=0|o[8],D=8191&x,U=x>>>13,P=0|o[9],O=8191&P,j=P>>>13,V=0|s[0],q=8191&V,K=V>>>13,F=0|s[1],H=8191&F,z=F>>>13,G=0|s[2],W=8191&G,Z=G>>>13,Y=0|s[3],$=8191&Y,Q=Y>>>13,X=0|s[4],J=8191&X,tt=X>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],at=8191&nt,ot=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ft=8191<,ct=lt>>>13,dt=0|s[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(f,q))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(c,q)|0))<<13)|0;u=((a=Math.imul(c,K))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,q),n=(n=Math.imul(p,K))+Math.imul(m,q)|0,a=Math.imul(m,K);var yt=(u+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,z)|0)+Math.imul(c,H)|0))<<13)|0;u=((a=a+Math.imul(c,z)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,q),n=(n=Math.imul(y,K))+Math.imul(v,q)|0,a=Math.imul(v,K),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,H)|0,a=a+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(f,W)|0)|0)+((8191&(n=(n=n+Math.imul(f,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((a=a+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(w,q),n=(n=Math.imul(w,K))+Math.imul(M,q)|0,a=Math.imul(M,K),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(v,H)|0,a=a+Math.imul(v,z)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,a=a+Math.imul(m,Z)|0;var bt=(u+(i=i+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,Q)|0)+Math.imul(c,$)|0))<<13)|0;u=((a=a+Math.imul(c,Q)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(E,q),n=(n=Math.imul(E,K))+Math.imul(S,q)|0,a=Math.imul(S,K),i=i+Math.imul(w,H)|0,n=(n=n+Math.imul(w,z)|0)+Math.imul(M,H)|0,a=a+Math.imul(M,z)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(v,W)|0,a=a+Math.imul(v,Z)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(m,$)|0,a=a+Math.imul(m,Q)|0;var wt=(u+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(c,J)|0))<<13)|0;u=((a=a+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,q),n=(n=Math.imul(A,K))+Math.imul(I,q)|0,a=Math.imul(I,K),i=i+Math.imul(E,H)|0,n=(n=n+Math.imul(E,z)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,z)|0,i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(M,W)|0,a=a+Math.imul(M,Z)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(v,$)|0,a=a+Math.imul(v,Q)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,a=a+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((a=a+Math.imul(c,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(B,q),n=(n=Math.imul(B,K))+Math.imul(k,q)|0,a=Math.imul(k,K),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,z)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,z)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,Z)|0,i=i+Math.imul(w,$)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(M,$)|0,a=a+Math.imul(M,Q)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,a=a+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,a=a+Math.imul(m,it)|0;var _t=(u+(i=i+Math.imul(f,at)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(c,at)|0))<<13)|0;u=((a=a+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,K))+Math.imul(L,q)|0,a=Math.imul(L,K),i=i+Math.imul(B,H)|0,n=(n=n+Math.imul(B,z)|0)+Math.imul(k,H)|0,a=a+Math.imul(k,z)|0,i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,Z)|0)+Math.imul(I,W)|0,a=a+Math.imul(I,Z)|0,i=i+Math.imul(E,$)|0,n=(n=n+Math.imul(E,Q)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,Q)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,J)|0,a=a+Math.imul(M,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,a=a+Math.imul(v,it)|0,i=i+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,at)|0,a=a+Math.imul(m,ot)|0;var Et=(u+(i=i+Math.imul(f,ht)|0)|0)+((8191&(n=(n=n+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((a=a+Math.imul(c,ut)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,q),n=(n=Math.imul(D,K))+Math.imul(U,q)|0,a=Math.imul(U,K),i=i+Math.imul(N,H)|0,n=(n=n+Math.imul(N,z)|0)+Math.imul(L,H)|0,a=a+Math.imul(L,z)|0,i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(k,W)|0,a=a+Math.imul(k,Z)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,Q)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,Q)|0,i=i+Math.imul(E,J)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,it)|0,i=i+Math.imul(y,at)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(v,at)|0,a=a+Math.imul(v,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,a=a+Math.imul(m,ut)|0;var St=(u+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((a=a+Math.imul(c,ct)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(O,q),n=(n=Math.imul(O,K))+Math.imul(j,q)|0,a=Math.imul(j,K),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(U,H)|0,a=a+Math.imul(U,z)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Z)|0)+Math.imul(L,W)|0,a=a+Math.imul(L,Z)|0,i=i+Math.imul(B,$)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(k,$)|0,a=a+Math.imul(k,Q)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,J)|0,a=a+Math.imul(I,tt)|0,i=i+Math.imul(E,rt)|0,n=(n=n+Math.imul(E,it)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,it)|0,i=i+Math.imul(w,at)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,a=a+Math.imul(v,ut)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,a=a+Math.imul(m,ct)|0;var Ct=(u+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((a=a+Math.imul(c,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(O,H),n=(n=Math.imul(O,z))+Math.imul(j,H)|0,a=Math.imul(j,z),i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,Z)|0)+Math.imul(U,W)|0,a=a+Math.imul(U,Z)|0,i=i+Math.imul(N,$)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(L,$)|0,a=a+Math.imul(L,Q)|0,i=i+Math.imul(B,J)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(k,J)|0,a=a+Math.imul(k,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,it)|0,i=i+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,a=a+Math.imul(M,ut)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,a=a+Math.imul(v,ct)|0;var At=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((a=a+Math.imul(m,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,W),n=(n=Math.imul(O,Z))+Math.imul(j,W)|0,a=Math.imul(j,Z),i=i+Math.imul(D,$)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(U,$)|0,a=a+Math.imul(U,Q)|0,i=i+Math.imul(N,J)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(L,J)|0,a=a+Math.imul(L,tt)|0,i=i+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,it)|0)+Math.imul(k,rt)|0,a=a+Math.imul(k,it)|0,i=i+Math.imul(A,at)|0,n=(n=n+Math.imul(A,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,i=i+Math.imul(E,ht)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(S,ht)|0,a=a+Math.imul(S,ut)|0,i=i+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ct)|0;var It=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((a=a+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,Q))+Math.imul(j,$)|0,a=Math.imul(j,Q),i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(U,J)|0,a=a+Math.imul(U,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(L,rt)|0,a=a+Math.imul(L,it)|0,i=i+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(k,at)|0,a=a+Math.imul(k,ot)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(I,ht)|0,a=a+Math.imul(I,ut)|0,i=i+Math.imul(E,ft)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(S,ft)|0,a=a+Math.imul(S,ct)|0;var Tt=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((a=a+Math.imul(M,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(O,J),n=(n=Math.imul(O,tt))+Math.imul(j,J)|0,a=Math.imul(j,tt),i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(U,rt)|0,a=a+Math.imul(U,it)|0,i=i+Math.imul(N,at)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(L,at)|0,a=a+Math.imul(L,ot)|0,i=i+Math.imul(B,ht)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(k,ht)|0,a=a+Math.imul(k,ut)|0,i=i+Math.imul(A,ft)|0,n=(n=n+Math.imul(A,ct)|0)+Math.imul(I,ft)|0,a=a+Math.imul(I,ct)|0;var Bt=(u+(i=i+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((a=a+Math.imul(S,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(O,rt),n=(n=Math.imul(O,it))+Math.imul(j,rt)|0,a=Math.imul(j,it),i=i+Math.imul(D,at)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(U,at)|0,a=a+Math.imul(U,ot)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(L,ht)|0,a=a+Math.imul(L,ut)|0,i=i+Math.imul(B,ft)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(k,ft)|0,a=a+Math.imul(k,ct)|0;var kt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((a=a+Math.imul(I,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(O,at),n=(n=Math.imul(O,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(U,ht)|0,a=a+Math.imul(U,ut)|0,i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(L,ft)|0,a=a+Math.imul(L,ct)|0;var Rt=(u+(i=i+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((a=a+Math.imul(k,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(O,ht),n=(n=Math.imul(O,ut))+Math.imul(j,ht)|0,a=Math.imul(j,ut),i=i+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,ct)|0)+Math.imul(U,ft)|0,a=a+Math.imul(U,ct)|0;var Nt=(u+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,mt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((a=a+Math.imul(L,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(O,ft),n=(n=Math.imul(O,ct))+Math.imul(j,ft)|0,a=Math.imul(j,ct);var Lt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((a=a+Math.imul(U,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var xt=(u+(i=Math.imul(O,pt))|0)+((8191&(n=(n=Math.imul(O,mt))+Math.imul(j,pt)|0))<<13)|0;return u=((a=Math.imul(j,mt))+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=Et,h[8]=St,h[9]=Ct,h[10]=At,h[11]=It,h[12]=Tt,h[13]=Bt,h[14]=kt,h[15]=Rt,h[16]=Nt,h[17]=Lt,h[18]=xt,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?c(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,i=o,o=n}return 0!==i?r.words[a]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,a){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=n/67108864|0,e+=a>>>26,this.words[i]=67108863&a}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,a=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(e=0;e>>26-i}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=n);u--){var f=0|this.words[u];this.words[u]=l<<26-a|f>>>a,l=f&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n>26,this.words[n+i]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),a=t,o=0|a.words[a.length-1];0!=(r=26-this._countBits(o))&&(a=a.ushln(r),i.iushln(r),o=0|a.words[a.length-1]);var s,h=i.length-a.length;if('mod'!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var c=67108864*(0|i.words[a.length+f])+(0|i.words[a.length+f-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(a,c,f);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(a,1,f),i.isZero()||(i.negative^=1);s&&(s.words[f]=c)}return s&&s.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),'mod'!==e&&(a=s.div.neg()),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.iadd(t)),{div:a,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),'mod'!==e&&(a=s.div.neg()),{div:a,mod:s.mod}):this.negative&t.negative?(s=this.neg().divmod(t.neg(),e),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var a,o,s},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a=new n(1),o=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;!(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(l),o.isub(f)),a.iushrn(1),o.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(f)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s),o.isub(h)):(i.isub(e),s.isub(a),h.isub(o))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,a=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var o=new n(1),s=new n(0),h=a.clone();i.cmpn(1)>0&&a.cmpn(1)>0;){for(var u=0,l=1;!(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;!(a.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(a.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);i.cmp(a)>=0?(i.isub(a),o.isub(s)):(a.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var a=e;e=r,r=a}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new _(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function w(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function M(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function _(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function E(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,a=o}a>>>=22,t.words[n-10]=a,0===a&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new w;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new M}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},_.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),o=0;!a.isZero()&&0===a.andln(1);)o++,a.iushrn(1);r(!a.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,a),c=this.pow(t,a.addn(1).iushrn(1)),d=this.pow(t,a),p=o;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var f=u>>l&1;a!==r[0]&&(a=this.sqr(a)),0!==f||0!==o?(o<<=1,o|=f,(4==++s||0===i&&0===l)&&(a=this.mul(a,r[o]),s=0,o=0)):s=0}h=26}return a},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new E(t)},i(E,_),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(i).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),Yr=h(((t,e)=>{var r=_r(),i=Zr();e.exports=function(t){return new a(t)};var n={secp256k1:{name:'secp256k1',byteLength:32},secp224r1:{name:'p224',byteLength:28},prime256v1:{name:'p256',byteLength:32},prime192v1:{name:'p192',byteLength:24},ed25519:{name:'ed25519',byteLength:32},secp384r1:{name:'p384',byteLength:48},secp521r1:{name:'p521',byteLength:66}};function a(t){this.curveType=n[t],this.curveType||(this.curveType={name:t}),this.curve=new r.ec(this.curveType.name),this.keys=void 0}function o(t,e,r){Array.isArray(t)||(t=t.toArray());var i=new Buffer(t);if(r&&i.length{var r=Nt(),i=y().Buffer;function n(t){var e=i.allocUnsafe(4);return e.writeUInt32BE(t,0),e}e.exports=function(t,e){for(var a,o=i.alloc(0),s=0;o.length{e.exports=function(t,e){for(var r=t.length,i=-1;++i{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var a;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{a=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:be().Buffer}catch{}function o(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function s(t,e,r){var i=o(t,r);return r-1>=e&&(i|=o(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,a=Math.min(t.length,r),o=e;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[a]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);else if('le'===i)for(n=0,a=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,a++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=s(t,e,i)<=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(a-=18,o+=1,this.words[o]|=n>>>26):a+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var a=t.length-r,o=a%i,s=Math.min(a,a-o)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.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'],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],a=0|e.words[0],o=n*a,s=67108863&o,h=o/67108864|0;r.words[0]=s;for(var u=1;u>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var p=u-d|0;l+=(o=(n=0|t.words[p])*(a=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,a=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,o--)}for(0!==a&&(i=a.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);i=(p=p.idivn(d)).isZero()?m+i:u[c-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof a<'u'),this.toArrayLike(a,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),a=i||Math.max(1,n);r(n<=a,'byte array longer than desired length'),r(a>0,'Requested array length <= 0'),this.strip();var o,s,h='le'===e,u=new t(a),l=this.clone();if(h){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),u[s]=o;for(;s=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,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(;at.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var a=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==a&&o>26,this.words[o]=67108863&e;if(0===a&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,M=b>>>13,_=0|o[4],E=8191&_,S=_>>>13,C=0|o[5],A=8191&C,I=C>>>13,T=0|o[6],B=8191&T,k=T>>>13,R=0|o[7],N=8191&R,L=R>>>13,x=0|o[8],D=8191&x,U=x>>>13,P=0|o[9],O=8191&P,j=P>>>13,V=0|s[0],q=8191&V,K=V>>>13,F=0|s[1],H=8191&F,z=F>>>13,G=0|s[2],W=8191&G,Z=G>>>13,Y=0|s[3],$=8191&Y,Q=Y>>>13,X=0|s[4],J=8191&X,tt=X>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],at=8191&nt,ot=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ft=8191<,ct=lt>>>13,dt=0|s[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(f,q))|0)+((8191&(n=(n=Math.imul(f,K))+Math.imul(c,q)|0))<<13)|0;u=((a=Math.imul(c,K))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,q),n=(n=Math.imul(p,K))+Math.imul(m,q)|0,a=Math.imul(m,K);var yt=(u+(i=i+Math.imul(f,H)|0)|0)+((8191&(n=(n=n+Math.imul(f,z)|0)+Math.imul(c,H)|0))<<13)|0;u=((a=a+Math.imul(c,z)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,q),n=(n=Math.imul(y,K))+Math.imul(v,q)|0,a=Math.imul(v,K),i=i+Math.imul(p,H)|0,n=(n=n+Math.imul(p,z)|0)+Math.imul(m,H)|0,a=a+Math.imul(m,z)|0;var vt=(u+(i=i+Math.imul(f,W)|0)|0)+((8191&(n=(n=n+Math.imul(f,Z)|0)+Math.imul(c,W)|0))<<13)|0;u=((a=a+Math.imul(c,Z)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(w,q),n=(n=Math.imul(w,K))+Math.imul(M,q)|0,a=Math.imul(M,K),i=i+Math.imul(y,H)|0,n=(n=n+Math.imul(y,z)|0)+Math.imul(v,H)|0,a=a+Math.imul(v,z)|0,i=i+Math.imul(p,W)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(m,W)|0,a=a+Math.imul(m,Z)|0;var bt=(u+(i=i+Math.imul(f,$)|0)|0)+((8191&(n=(n=n+Math.imul(f,Q)|0)+Math.imul(c,$)|0))<<13)|0;u=((a=a+Math.imul(c,Q)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(E,q),n=(n=Math.imul(E,K))+Math.imul(S,q)|0,a=Math.imul(S,K),i=i+Math.imul(w,H)|0,n=(n=n+Math.imul(w,z)|0)+Math.imul(M,H)|0,a=a+Math.imul(M,z)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Z)|0)+Math.imul(v,W)|0,a=a+Math.imul(v,Z)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(m,$)|0,a=a+Math.imul(m,Q)|0;var wt=(u+(i=i+Math.imul(f,J)|0)|0)+((8191&(n=(n=n+Math.imul(f,tt)|0)+Math.imul(c,J)|0))<<13)|0;u=((a=a+Math.imul(c,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,q),n=(n=Math.imul(A,K))+Math.imul(I,q)|0,a=Math.imul(I,K),i=i+Math.imul(E,H)|0,n=(n=n+Math.imul(E,z)|0)+Math.imul(S,H)|0,a=a+Math.imul(S,z)|0,i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(M,W)|0,a=a+Math.imul(M,Z)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(v,$)|0,a=a+Math.imul(v,Q)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,a=a+Math.imul(m,tt)|0;var Mt=(u+(i=i+Math.imul(f,rt)|0)|0)+((8191&(n=(n=n+Math.imul(f,it)|0)+Math.imul(c,rt)|0))<<13)|0;u=((a=a+Math.imul(c,it)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(B,q),n=(n=Math.imul(B,K))+Math.imul(k,q)|0,a=Math.imul(k,K),i=i+Math.imul(A,H)|0,n=(n=n+Math.imul(A,z)|0)+Math.imul(I,H)|0,a=a+Math.imul(I,z)|0,i=i+Math.imul(E,W)|0,n=(n=n+Math.imul(E,Z)|0)+Math.imul(S,W)|0,a=a+Math.imul(S,Z)|0,i=i+Math.imul(w,$)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(M,$)|0,a=a+Math.imul(M,Q)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,a=a+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,a=a+Math.imul(m,it)|0;var _t=(u+(i=i+Math.imul(f,at)|0)|0)+((8191&(n=(n=n+Math.imul(f,ot)|0)+Math.imul(c,at)|0))<<13)|0;u=((a=a+Math.imul(c,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,K))+Math.imul(L,q)|0,a=Math.imul(L,K),i=i+Math.imul(B,H)|0,n=(n=n+Math.imul(B,z)|0)+Math.imul(k,H)|0,a=a+Math.imul(k,z)|0,i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,Z)|0)+Math.imul(I,W)|0,a=a+Math.imul(I,Z)|0,i=i+Math.imul(E,$)|0,n=(n=n+Math.imul(E,Q)|0)+Math.imul(S,$)|0,a=a+Math.imul(S,Q)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(M,J)|0,a=a+Math.imul(M,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,a=a+Math.imul(v,it)|0,i=i+Math.imul(p,at)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(m,at)|0,a=a+Math.imul(m,ot)|0;var Et=(u+(i=i+Math.imul(f,ht)|0)|0)+((8191&(n=(n=n+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((a=a+Math.imul(c,ut)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,q),n=(n=Math.imul(D,K))+Math.imul(U,q)|0,a=Math.imul(U,K),i=i+Math.imul(N,H)|0,n=(n=n+Math.imul(N,z)|0)+Math.imul(L,H)|0,a=a+Math.imul(L,z)|0,i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,Z)|0)+Math.imul(k,W)|0,a=a+Math.imul(k,Z)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,Q)|0)+Math.imul(I,$)|0,a=a+Math.imul(I,Q)|0,i=i+Math.imul(E,J)|0,n=(n=n+Math.imul(E,tt)|0)+Math.imul(S,J)|0,a=a+Math.imul(S,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(M,rt)|0,a=a+Math.imul(M,it)|0,i=i+Math.imul(y,at)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(v,at)|0,a=a+Math.imul(v,ot)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,ut)|0)+Math.imul(m,ht)|0,a=a+Math.imul(m,ut)|0;var St=(u+(i=i+Math.imul(f,ft)|0)|0)+((8191&(n=(n=n+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((a=a+Math.imul(c,ct)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(O,q),n=(n=Math.imul(O,K))+Math.imul(j,q)|0,a=Math.imul(j,K),i=i+Math.imul(D,H)|0,n=(n=n+Math.imul(D,z)|0)+Math.imul(U,H)|0,a=a+Math.imul(U,z)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Z)|0)+Math.imul(L,W)|0,a=a+Math.imul(L,Z)|0,i=i+Math.imul(B,$)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(k,$)|0,a=a+Math.imul(k,Q)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,J)|0,a=a+Math.imul(I,tt)|0,i=i+Math.imul(E,rt)|0,n=(n=n+Math.imul(E,it)|0)+Math.imul(S,rt)|0,a=a+Math.imul(S,it)|0,i=i+Math.imul(w,at)|0,n=(n=n+Math.imul(w,ot)|0)+Math.imul(M,at)|0,a=a+Math.imul(M,ot)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,a=a+Math.imul(v,ut)|0,i=i+Math.imul(p,ft)|0,n=(n=n+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,a=a+Math.imul(m,ct)|0;var Ct=(u+(i=i+Math.imul(f,pt)|0)|0)+((8191&(n=(n=n+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;u=((a=a+Math.imul(c,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(O,H),n=(n=Math.imul(O,z))+Math.imul(j,H)|0,a=Math.imul(j,z),i=i+Math.imul(D,W)|0,n=(n=n+Math.imul(D,Z)|0)+Math.imul(U,W)|0,a=a+Math.imul(U,Z)|0,i=i+Math.imul(N,$)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(L,$)|0,a=a+Math.imul(L,Q)|0,i=i+Math.imul(B,J)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(k,J)|0,a=a+Math.imul(k,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(I,rt)|0,a=a+Math.imul(I,it)|0,i=i+Math.imul(E,at)|0,n=(n=n+Math.imul(E,ot)|0)+Math.imul(S,at)|0,a=a+Math.imul(S,ot)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,ut)|0)+Math.imul(M,ht)|0,a=a+Math.imul(M,ut)|0,i=i+Math.imul(y,ft)|0,n=(n=n+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,a=a+Math.imul(v,ct)|0;var At=(u+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;u=((a=a+Math.imul(m,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(O,W),n=(n=Math.imul(O,Z))+Math.imul(j,W)|0,a=Math.imul(j,Z),i=i+Math.imul(D,$)|0,n=(n=n+Math.imul(D,Q)|0)+Math.imul(U,$)|0,a=a+Math.imul(U,Q)|0,i=i+Math.imul(N,J)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(L,J)|0,a=a+Math.imul(L,tt)|0,i=i+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,it)|0)+Math.imul(k,rt)|0,a=a+Math.imul(k,it)|0,i=i+Math.imul(A,at)|0,n=(n=n+Math.imul(A,ot)|0)+Math.imul(I,at)|0,a=a+Math.imul(I,ot)|0,i=i+Math.imul(E,ht)|0,n=(n=n+Math.imul(E,ut)|0)+Math.imul(S,ht)|0,a=a+Math.imul(S,ut)|0,i=i+Math.imul(w,ft)|0,n=(n=n+Math.imul(w,ct)|0)+Math.imul(M,ft)|0,a=a+Math.imul(M,ct)|0;var It=(u+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((a=a+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(O,$),n=(n=Math.imul(O,Q))+Math.imul(j,$)|0,a=Math.imul(j,Q),i=i+Math.imul(D,J)|0,n=(n=n+Math.imul(D,tt)|0)+Math.imul(U,J)|0,a=a+Math.imul(U,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(L,rt)|0,a=a+Math.imul(L,it)|0,i=i+Math.imul(B,at)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(k,at)|0,a=a+Math.imul(k,ot)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(I,ht)|0,a=a+Math.imul(I,ut)|0,i=i+Math.imul(E,ft)|0,n=(n=n+Math.imul(E,ct)|0)+Math.imul(S,ft)|0,a=a+Math.imul(S,ct)|0;var Tt=(u+(i=i+Math.imul(w,pt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((a=a+Math.imul(M,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(O,J),n=(n=Math.imul(O,tt))+Math.imul(j,J)|0,a=Math.imul(j,tt),i=i+Math.imul(D,rt)|0,n=(n=n+Math.imul(D,it)|0)+Math.imul(U,rt)|0,a=a+Math.imul(U,it)|0,i=i+Math.imul(N,at)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(L,at)|0,a=a+Math.imul(L,ot)|0,i=i+Math.imul(B,ht)|0,n=(n=n+Math.imul(B,ut)|0)+Math.imul(k,ht)|0,a=a+Math.imul(k,ut)|0,i=i+Math.imul(A,ft)|0,n=(n=n+Math.imul(A,ct)|0)+Math.imul(I,ft)|0,a=a+Math.imul(I,ct)|0;var Bt=(u+(i=i+Math.imul(E,pt)|0)|0)+((8191&(n=(n=n+Math.imul(E,mt)|0)+Math.imul(S,pt)|0))<<13)|0;u=((a=a+Math.imul(S,mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,i=Math.imul(O,rt),n=(n=Math.imul(O,it))+Math.imul(j,rt)|0,a=Math.imul(j,it),i=i+Math.imul(D,at)|0,n=(n=n+Math.imul(D,ot)|0)+Math.imul(U,at)|0,a=a+Math.imul(U,ot)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(L,ht)|0,a=a+Math.imul(L,ut)|0,i=i+Math.imul(B,ft)|0,n=(n=n+Math.imul(B,ct)|0)+Math.imul(k,ft)|0,a=a+Math.imul(k,ct)|0;var kt=(u+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(I,pt)|0))<<13)|0;u=((a=a+Math.imul(I,mt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(O,at),n=(n=Math.imul(O,ot))+Math.imul(j,at)|0,a=Math.imul(j,ot),i=i+Math.imul(D,ht)|0,n=(n=n+Math.imul(D,ut)|0)+Math.imul(U,ht)|0,a=a+Math.imul(U,ut)|0,i=i+Math.imul(N,ft)|0,n=(n=n+Math.imul(N,ct)|0)+Math.imul(L,ft)|0,a=a+Math.imul(L,ct)|0;var Rt=(u+(i=i+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((a=a+Math.imul(k,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(O,ht),n=(n=Math.imul(O,ut))+Math.imul(j,ht)|0,a=Math.imul(j,ut),i=i+Math.imul(D,ft)|0,n=(n=n+Math.imul(D,ct)|0)+Math.imul(U,ft)|0,a=a+Math.imul(U,ct)|0;var Nt=(u+(i=i+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,mt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((a=a+Math.imul(L,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(O,ft),n=(n=Math.imul(O,ct))+Math.imul(j,ft)|0,a=Math.imul(j,ct);var Lt=(u+(i=i+Math.imul(D,pt)|0)|0)+((8191&(n=(n=n+Math.imul(D,mt)|0)+Math.imul(U,pt)|0))<<13)|0;u=((a=a+Math.imul(U,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var xt=(u+(i=Math.imul(O,pt))|0)+((8191&(n=(n=Math.imul(O,mt))+Math.imul(j,pt)|0))<<13)|0;return u=((a=Math.imul(j,mt))+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Mt,h[6]=_t,h[7]=Et,h[8]=St,h[9]=Ct,h[10]=At,h[11]=It,h[12]=Tt,h[13]=Bt,h[14]=kt,h[15]=Rt,h[16]=Nt,h[17]=Lt,h[18]=xt,0!==u&&(h[19]=u,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?d(this,t,e):i<63?c(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,a=0;a>>26)|0)>>>26,o&=67108863}r.words[a]=s,i=o,o=n}return 0!==i?r.words[a]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,a){for(var o=0;o>>=1)n++;return 1<>>=13,i[2*o+1]=8191&a,a>>>=13;for(o=2*e;o>=26,e+=n/67108864|0,e+=a>>>26,this.words[i]=67108863&a}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,a=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(e=0;e>>26-i}o&&(this.words[e]=o,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var a=t%26,o=Math.min((t-a)/26,this.length),s=67108863^67108863>>>a<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=n);u--){var f=0|this.words[u];this.words[u]=l<<26-a|f>>>a,l=f&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n>26,this.words[n+i]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),a=t,o=0|a.words[a.length-1];0!=(r=26-this._countBits(o))&&(a=a.ushln(r),i.iushln(r),o=0|a.words[a.length-1]);var s,h=i.length-a.length;if('mod'!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u=0;f--){var c=67108864*(0|i.words[a.length+f])+(0|i.words[a.length+f-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(a,c,f);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(a,1,f),i.isZero()||(i.negative^=1);s&&(s.words[f]=c)}return s&&s.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),'mod'!==e&&(a=s.div.neg()),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.iadd(t)),{div:a,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),'mod'!==e&&(a=s.div.neg()),{div:a,mod:s.mod}):this.negative&t.negative?(s=this.neg().divmod(t.neg(),e),'div'!==e&&(o=s.mod.neg(),i&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var a,o,s},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),a=r.cmp(i);return a<0||1===n&&0===a?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var a=new n(1),o=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;!(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(a.isOdd()||o.isOdd())&&(a.iadd(l),o.isub(f)),a.iushrn(1),o.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(f)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s),o.isub(h)):(i.isub(e),s.isub(a),h.isub(o))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,a=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var o=new n(1),s=new n(0),h=a.clone();i.cmpn(1)>0&&a.cmpn(1)>0;){for(var u=0,l=1;!(i.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(i.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;!(a.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(a.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);i.cmp(a)>=0?(i.isub(a),o.isub(s)):(a.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var a=e;e=r,r=a}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==a&&(this.words[o]=a,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new _(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function w(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function M(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function _(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function E(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,a=o}a>>>=22,t.words[n-10]=a,0===a&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new w;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new M}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},_.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),o=0;!a.isZero()&&0===a.andln(1);)o++,a.iushrn(1);r(!a.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,a),c=this.pow(t,a.addn(1).iushrn(1)),d=this.pow(t,a),p=o;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var f=u>>l&1;a!==r[0]&&(a=this.sqr(a)),0!==f||0!==o?(o<<=1,o|=f,(4==++s||0===i&&0===l)&&(a=this.mul(a,r[o]),s=0,o=0)):s=0}h=26}return a},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new E(t)},i(E,_),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},E.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},E.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(i).iushrn(this.shift),o=a;return a.cmp(this.m)>=0?o=a.isub(this.m):a.cmpn(0)<0&&(o=a.iadd(this.m)),o._forceRed(this)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),Jr=h(((t,e)=>{var r=Xr(),i=y().Buffer;e.exports=function(t,e){return i.from(t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed().toArray())}})),ti=h(((t,e)=>{var r=Fr(),i=v(),n=Nt(),a=$r(),o=Qr(),s=Xr(),h=Jr(),u=ze(),l=y().Buffer;e.exports=function(t,e,f){var c;c=t.padding?t.padding:f?1:4;var d,p=r(t);if(4===c)d=function(t,e){var r=t.modulus.byteLength(),h=e.length,u=n('sha1').update(l.alloc(0)).digest(),f=u.length,c=2*f;if(h>r-c-2)throw new Error('message too long');var d=l.alloc(r-h-c-2),p=r-f-1,m=i(f),g=o(l.concat([u,d,l.alloc(1,1),e],p),a(m,p)),y=o(m,a(g,f));return new s(l.concat([l.alloc(1),y,g],r))}(p,e);else if(1===c)d=function(t,e,r){var n,a=e.length,o=t.modulus.byteLength();if(a>o-11)throw new Error('message too long');return n=r?l.alloc(o-a-3,255):function(t){for(var e,r=l.allocUnsafe(t),n=0,a=i(2*t),o=0;n=0)throw new Error('data too long for modulus')}return f?u(d,p):h(d,p)}})),ei=h(((t,e)=>{var r=Fr(),i=$r(),n=Qr(),a=Xr(),o=ze(),s=Nt(),h=Jr(),u=y().Buffer;e.exports=function(t,e,l){var f;f=t.padding?t.padding:l?1:4;var c,d=r(t),p=d.modulus.byteLength();if(e.length>p||new a(e).cmp(d.modulus)>=0)throw new Error('decryption error');c=l?h(new a(e),d):o(e,d);var m=u.alloc(p-c.length);if(c=u.concat([m,c],p),4===f)return function(t,e){var r=t.modulus.byteLength(),a=s('sha1').update(u.alloc(0)).digest(),o=a.length;if(0!==e[0])throw new Error('decryption error');var h=e.slice(1,o+1),l=e.slice(o+1),f=n(h,i(l,o)),c=n(l,i(f,r-o-1));if(function(t,e){t=u.from(t),e=u.from(e);var r=0,i=t.length;t.length!==e.length&&(r++,i=Math.min(t.length,e.length));for(var n=-1;++n=e.length){a++;break}var o=e.slice(2,n-1);if(('0002'!==i.toString('hex')&&!r||'0001'!==i.toString('hex')&&r)&&a++,o.length<8&&a++,a)throw new Error('decryption error');return e.slice(n)}(0,c,l);if(3===f)return c;throw new Error('unknown padding')}})),ri=h((t=>{t.publicEncrypt=ti(),t.privateDecrypt=ei(),t.privateEncrypt=function(e,r){return t.publicEncrypt(e,r,!0)},t.publicDecrypt=function(e,r){return t.privateDecrypt(e,r,!0)}})),ii=h((t=>{function e(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var r=y(),i=(v(),r.Buffer),n=r.kMaxLength,a=global.crypto||global.msCrypto,o=Math.pow(2,32)-1;function s(t,e){if('number'!=typeof t||t!=t)throw new TypeError('offset must be a number');if(t>o||t<0)throw new TypeError('offset must be a uint32');if(t>n||t>e)throw new RangeError('offset out of range')}function h(t,e,r){if('number'!=typeof t||t!=t)throw new TypeError('size must be a number');if(t>o||t<0)throw new TypeError('size must be a uint32');if(t+e>r||t>n)throw new RangeError('buffer too small')}function u(t,e,r,i){var n=t.buffer,o=new Uint8Array(n,e,r);return a.getRandomValues(o),i?void process.nextTick((function(){i(null,t)})):t}a&&a.getRandomValues?(t.randomFill=function(t,e,r,n){if(!(i.isBuffer(t)||t instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if('function'==typeof e)n=e,e=0,r=t.length;else if('function'==typeof r)n=r,r=t.length-e;else if('function'!=typeof n)throw new TypeError('"cb" argument must be a function');return s(e,t.length),h(r,e,t.length),u(t,e,r,n)},t.randomFillSync=function(t,e,r){if(typeof e>'u'&&(e=0),!(i.isBuffer(t)||t instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return s(e,t.length),void 0===r&&(r=t.length-e),h(r,e,t.length),u(t,e,r)}):(t.randomFill=e,t.randomFillSync=e)})),ni=h((t=>{t.randomBytes=t.rng=t.pseudoRandomBytes=t.prng=v(),t.createHash=t.Hash=Nt(),t.createHmac=t.Hmac=Dt();var e=Pt(),r=Object.keys(e),i=['sha1','sha224','sha256','sha384','sha512','md5','rmd160'].concat(r);t.getHashes=function(){return i};var n=Ft();t.pbkdf2=n.pbkdf2,t.pbkdf2Sync=n.pbkdf2Sync;var a=ve();t.Cipher=a.Cipher,t.createCipher=a.createCipher,t.Cipheriv=a.Cipheriv,t.createCipheriv=a.createCipheriv,t.Decipher=a.Decipher,t.createDecipher=a.createDecipher,t.Decipheriv=a.Decipheriv,t.createDecipheriv=a.createDecipheriv,t.getCiphers=a.getCiphers,t.listCiphers=a.listCiphers;var o=Te();t.DiffieHellmanGroup=o.DiffieHellmanGroup,t.createDiffieHellmanGroup=o.createDiffieHellmanGroup,t.getDiffieHellman=o.getDiffieHellman,t.createDiffieHellman=o.createDiffieHellman,t.DiffieHellman=o.DiffieHellman;var s=Wr();t.createSign=s.createSign,t.Sign=s.Sign,t.createVerify=s.createVerify,t.Verify=s.Verify,t.createECDH=Yr();var h=ri();t.publicEncrypt=h.publicEncrypt,t.privateEncrypt=h.privateEncrypt,t.publicDecrypt=h.publicDecrypt,t.privateDecrypt=h.privateDecrypt;var u=ii();t.randomFill=u.randomFill,t.randomFillSync=u.randomFillSync,t.createCredentials=function(){throw new Error(['sorry, createCredentials is not implemented yet','we accept pull requests','https://github.com/crypto-browserify/crypto-browserify'].join("\n"))},t.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}})),u(ai={},{DEFAULT_ENCODING:()=>si,default:()=>mi,getCurves:()=>t,getRandomValues:()=>hi,randomUUID:()=>ui,scrypt:()=>di,scryptSync:()=>ci,timingSafeEqual:()=>fi,webcrypto:()=>pi}),f(ai,c(ni())),oi=c(ni()),si='buffer',hi=t=>crypto.getRandomValues(t),ui=()=>crypto.randomUUID(),li=['p192','p224','p256','p384','p521','curve25519','ed25519','secp256k1','secp224r1','prime256v1','prime192v1','ed25519','secp384r1','secp521r1'],fi='timingSafeEqual'in crypto?(t,e)=>{let{byteLength:r}=t,{byteLength:i}=e;if('number'!=typeof r||'number'!=typeof i)throw new TypeError('Input must be an array buffer view');if(r!==i)throw new RangeError('Input buffers must have the same length');return crypto.timingSafeEqual(t,e)}:void 0,ci='scryptSync'in crypto?(t,e,r,i)=>{let n=crypto.scryptSync(t,e,r,i);return'buffer'!==si?new Buffer(n).toString(si):new Buffer(n)}:void 0,di='scryptSync'in crypto?function(t,e,r,i,n){if('function'==typeof i&&(n=i,i=void 0),'function'!=typeof n){var a=new TypeError('callback must be a function');throw a.code='ERR_INVALID_CALLBACK',a}try{let a=crypto.scryptSync(t,e,r,i);process.nextTick(n,null,'buffer'!==si?new Buffer(a).toString(si):new Buffer(a))}catch(t){throw t}}:void 0,fi&&(Object.defineProperty(fi,'name',{value:'::bunternal::'}),Object.defineProperty(di,'name',{value:'::bunternal::'}),Object.defineProperty(ci,'name',{value:'::bunternal::'})),pi=crypto,mi={...oi,getRandomValues:hi,randomUUID:ui,timingSafeEqual:fi,scryptSync:ci,scrypt:di,webcrypto:pi,getCurves:t}},()=>(ji&&(Vi=ji(ji=0)),Vi)),Hi=Si(((t,e)=>{var r=Ci();xi(),Li(),Ii();var i,n=r.pkcs5=r.pkcs5||{};r.util.isNodejs&&!r.options.usePureJavaScript&&(Fi(),i=Ei(Oi)),e.exports=r.pbkdf2=n.pbkdf2=function(t,e,n,a,o,s){if('function'==typeof o&&(s=o,o=null),r.util.isNodejs&&!r.options.usePureJavaScript&&i.pbkdf2&&(null===o||'object'!=typeof o)&&(i.pbkdf2Sync.length>4||!o||'sha1'===o))return'string'!=typeof o&&(o='sha1'),t=Buffer.from(t,'binary'),e=Buffer.from(e,'binary'),s?4===i.pbkdf2Sync.length?i.pbkdf2(t,e,n,a,(function(t,e){if(t)return s(t);s(null,e.toString('binary'))})):i.pbkdf2(t,e,n,a,o,(function(t,e){if(t)return s(t);s(null,e.toString('binary'))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(t,e,n,a).toString('binary'):i.pbkdf2Sync(t,e,n,a,o).toString('binary');if(null==o&&(o='sha1'),'string'==typeof o){if(!(o in r.md.algorithms))throw new Error('Unknown hash algorithm: '+o);o=r.md[o].create()}var h=o.digestLength;if(a>4294967295*h){var u=new Error('Derived key is too long.');if(s)return s(u);throw u}var l=Math.ceil(a/h),f=a-(l-1)*h,c=r.hmac.create();c.start(o,t);var d,p,m,g='';if(!s){for(var y=1;y<=l;++y){c.start(null,null),c.update(e),c.update(r.util.int32ToBytes(y)),d=m=c.digest().getBytes();for(var v=2;v<=n;++v)c.start(null,null),c.update(m),p=c.digest().getBytes(),d=r.util.xorBytes(d,p,h),m=p;g+=yl)return s(null,g);c.start(null,null),c.update(e),c.update(r.util.int32ToBytes(y)),d=m=c.digest().getBytes(),v=2,w()}function w(){if(v<=n)return c.start(null,null),c.update(m),p=c.digest().getBytes(),d=r.util.xorBytes(d,p,h),m=p,++v,r.util.setImmediate(w);g+=y{var r=function(t,e,r){for(var i,n,a,o,h,u,l,f,c,d,p,m,g,y=r.length();y>=64;){for(h=0;h<16;++h)e[h]=r.getInt32();for(;h<64;++h)i=((i=e[h-2])>>>17|i<<15)^(i>>>19|i<<13)^i>>>10,n=((n=e[h-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,e[h]=i+e[h-7]+n+e[h-16]|0;for(u=t.h0,l=t.h1,f=t.h2,c=t.h3,d=t.h4,p=t.h5,m=t.h6,g=t.h7,h=0;h<64;++h)a=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),o=u&l|f&(u^l),i=g+((d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(m^d&(p^m))+s[h]+e[h],g=m,m=p,p=d,d=c+i>>>0,c=f,f=l,l=u,u=i+(n=a+o)>>>0;t.h0=t.h0+u|0,t.h1=t.h1+l|0,t.h2=t.h2+f|0,t.h3=t.h3+c|0,t.h4=t.h4+d|0,t.h5=t.h5+p|0,t.h6=t.h6+m|0,t.h7=t.h7+g|0,y-=64}},i=Ci();Li(),Ii();var n=e.exports=i.sha256=i.sha256||{};i.md.sha256=i.md.algorithms.sha256=n,n.create=function(){o||(a=String.fromCharCode(128),a+=i.util.fillString(String.fromCharCode(0),64),s=[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],o=!0);var t=null,e=i.util.createBuffer(),n=new Array(64),h={algorithm:'sha256',blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){h.messageLength=0,h.fullMessageLength=h.messageLength64=[];for(var r=h.messageLengthSize/4,n=0;n>>0,s>>>0];for(var u=h.fullMessageLength.length-1;u>=0;--u)h.fullMessageLength[u]+=s[1],s[1]=s[0]+(h.fullMessageLength[u]/4294967296>>>0),h.fullMessageLength[u]=h.fullMessageLength[u]>>>0,s[0]=s[1]/4294967296>>>0;return e.putBytes(a),r(t,n,e),(e.read>2048||0===e.length())&&e.compact(),h},h.digest=function(){var o=i.util.createBuffer();o.putBytes(e.bytes());var s,u=h.fullMessageLength[h.fullMessageLength.length-1]+h.messageLengthSize&h.blockLength-1;o.putBytes(a.substr(0,h.blockLength-u));for(var l=8*h.fullMessageLength[0],f=0;f>>0,o.putInt32(l>>>0),l=s>>>0;o.putInt32(l);var c={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};r(c,n,o);var d=i.util.createBuffer();return d.putInt32(c.h0),d.putInt32(c.h1),d.putInt32(c.h2),d.putInt32(c.h3),d.putInt32(c.h4),d.putInt32(c.h5),d.putInt32(c.h6),d.putInt32(c.h7),d},h};var a=null,o=!1,s=null})),Gi=Si(((t,e)=>{var r=Ci();Ii();var i=null;!r.util.isNodejs||r.options.usePureJavaScript||process.versions['node-webkit']||(Fi(),i=Ei(Oi)),(e.exports=r.prng=r.prng||{}).create=function(t){for(var e={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:''},n=t.md,a=new Array(32),o=0;o<32;++o)a[o]=n.create();function s(){if(e.pools[0].messageLength>=32)return h();var t=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(t)),h()}function h(){e.reseeds=4294967295===e.reseeds?0:e.reseeds+1;var t=e.plugin.md.create();t.update(e.keyBytes);for(var r=1,i=0;i<32;++i)e.reseeds%r==0&&(t.update(e.pools[i].digest().getBytes()),e.pools[i].start()),r<<=1;e.keyBytes=t.digest().getBytes(),t.start(),t.update(e.keyBytes);var n=t.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(n),e.generated=0}function u(t){var e=null,i=r.util.globalScope,n=i.crypto||i.msCrypto;n&&n.getRandomValues&&(e=function(t){return n.getRandomValues(t)});var a=r.util.createBuffer();if(e)for(;a.length()>16)))<<16,c=4294967295&(l=(2147483647&(l+=u>>15))+(l>>31));for(h=0;h<3;++h)f=c>>>(h<<3),f^=Math.floor(256*Math.random()),a.putByte(255&f)}return a.getBytes(t)}return e.pools=a,e.pool=0,e.generate=function(t,i){if(!i)return e.generateSync(t);var n=e.plugin.cipher,a=e.plugin.increment,o=e.plugin.formatKey,s=e.plugin.formatSeed,u=r.util.createBuffer();e.key=null,function l(f){if(f)return i(f);if(u.length()>=t)return i(null,u.getBytes(t));e.generated>1048575&&(e.key=null);if(null===e.key)return r.util.nextTick((function(){!function(t){if(e.pools[0].messageLength>=32)return h(),t();var r=32-e.pools[0].messageLength<<5;e.seedFile(r,(function(r,i){if(r)return t(r);e.collect(i),h(),t()}))}(l)}));var c=n(e.key,e.seed);e.generated+=c.length,u.putBytes(c),e.key=o(n(e.key,a(e.seed))),e.seed=s(n(e.key,e.seed)),r.util.setImmediate(l)}()},e.generateSync=function(t){var i=e.plugin.cipher,n=e.plugin.increment,a=e.plugin.formatKey,o=e.plugin.formatSeed;e.key=null;for(var h=r.util.createBuffer();h.length()1048575&&(e.key=null),null===e.key&&s();var u=i(e.key,e.seed);e.generated+=u.length,h.putBytes(u),e.key=a(i(e.key,n(e.seed))),e.seed=o(i(e.key,e.seed))}return h.getBytes(t)},i?(e.seedFile=function(t,e){i.randomBytes(t,(function(t,r){if(t)return e(t);e(null,r.toString())}))},e.seedFileSync=function(t){return i.randomBytes(t).toString()}):(e.seedFile=function(t,e){try{e(null,u(t))}catch(t){e(t)}},e.seedFileSync=u),e.collect=function(t){for(var r=t.length,i=0;i>n&255);e.collect(i)},e.registerWorker=function(t){if(t===self)e.seedFile=function(t,e){self.addEventListener('message',(function t(r){var i=r.data;i.forge&&i.forge.prng&&(self.removeEventListener('message',t),e(i.forge.prng.err,i.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:t}}})};else{t.addEventListener('message',(function(r){var i=r.data;i.forge&&i.forge.prng&&e.seedFile(i.forge.prng.needed,(function(e,r){t.postMessage({forge:{prng:{err:e,bytes:r}}})}))}))}},e}})),Wi=Si(((t,e)=>{var r=Ci();ki(),zi(),Gi(),Ii(),r.random&&r.random.getBytes?e.exports=r.random:function(t){var i={},n=new Array(4),a=r.util.createBuffer();function o(){var t=r.prng.create(i);return t.getBytes=function(e,r){return t.generate(e,r)},t.getBytesSync=function(e){return t.generate(e)},t}i.formatKey=function(t){var e=r.util.createBuffer(t);return(t=new Array(4))[0]=e.getInt32(),t[1]=e.getInt32(),t[2]=e.getInt32(),t[3]=e.getInt32(),r.aes._expandKey(t,!1)},i.formatSeed=function(t){var e=r.util.createBuffer(t);return(t=new Array(4))[0]=e.getInt32(),t[1]=e.getInt32(),t[2]=e.getInt32(),t[3]=e.getInt32(),t},i.cipher=function(t,e){return r.aes._updateBlock(t,e,n,!1),a.putInt32(n[0]),a.putInt32(n[1]),a.putInt32(n[2]),a.putInt32(n[3]),a.getBytes()},i.increment=function(t){return++t[3],t},i.md=r.md.sha256;var s=o(),h=null,u=r.util.globalScope,l=u.crypto||u.msCrypto;if(l&&l.getRandomValues&&(h=function(t){return l.getRandomValues(t)}),r.options.usePureJavaScript||!r.util.isNodejs&&!h){if('undefined'==typeof window||window.document,s.collectInt(+new Date,32),'undefined'!=typeof navigator){var f='';for(var c in navigator)try{'string'==typeof navigator[c]&&(f+=navigator[c])}catch(t){}s.collect(f),f=null}t&&(t().mousemove((function(t){s.collectInt(t.clientX,16),s.collectInt(t.clientY,16)})),t().keypress((function(t){s.collectInt(t.charCode,8)})))}if(r.random)for(var c in s)r.random[c]=s[c];else r.random=s;r.random.createInstance=o,e.exports=r.random}('undefined'!=typeof jQuery?jQuery:null)})),Zi=Si(((t,e)=>{var r=Ci();Ii();var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],n=[1,2,3,5],a=function(t,e){return t<>16-e},o=function(t,e){return(65535&t)>>e|t<<16-e&65535};e.exports=r.rc2=r.rc2||{},r.rc2.expandKey=function(t,e){'string'==typeof t&&(t=r.util.createBuffer(t)),e=e||128;var n,a=t,o=t.length(),s=e,h=Math.ceil(s/8),u=255>>(7&s);for(n=o;n<128;n++)a.putByte(i[a.at(n-1)+a.at(n-o)&255]);for(a.setAt(128-h,i[a.at(128-h)&u]),n=127-h;n>=0;n--)a.setAt(n,i[a.at(n+1)^a.at(n+h)]);return a};var s=function(t,e,i){var s,h,u,l,f=!1,c=null,d=null,p=null,m=[];for(t=r.rc2.expandKey(t,e),u=0;u<64;u++)m.push(t.getInt16Le());i?(s=function(t){for(u=0;u<4;u++)t[u]+=m[l]+(t[(u+3)%4]&t[(u+2)%4])+(~t[(u+3)%4]&t[(u+1)%4]),t[u]=a(t[u],n[u]),l++},h=function(t){for(u=0;u<4;u++)t[u]+=m[63&t[(u+3)%4]]}):(s=function(t){for(u=3;u>=0;u--)t[u]=o(t[u],n[u]),t[u]-=m[l]+(t[(u+3)%4]&t[(u+2)%4])+(~t[(u+3)%4]&t[(u+1)%4]),l--},h=function(t){for(u=3;u>=0;u--)t[u]-=m[63&t[(u+3)%4]]});var g=function(t){var e=[];for(u=0;u<4;u++){var r=c.getInt16Le();null!==p&&(i?r^=p.getInt16Le():p.putInt16Le(r)),e.push(65535&r)}l=i?0:63;for(var n=0;n=8;)g([[5,s],[1,h],[6,s],[1,h],[5,s]])},finish:function(t){var e=!0;if(i)if(t)e=t(8,c,!i);else{var r=8===c.length()?8:8-c.length();c.fillWithByte(r,r)}if(e&&(f=!0,y.update()),!i&&(e=0===c.length()))if(t)e=t(8,d,!i);else{var n=d.length(),a=d.at(n-1);a>n?e=!1:d.truncate(a)}return e}}};r.rc2.startEncrypting=function(t,e,i){var n=r.rc2.createEncryptionCipher(t,128);return n.start(e,i),n},r.rc2.createEncryptionCipher=function(t,e){return s(t,e,!0)},r.rc2.startDecrypting=function(t,e,i){var n=r.rc2.createDecryptionCipher(t,128);return n.start(e,i),n},r.rc2.createDecryptionCipher=function(t,e){return s(t,e,!1)}})),Yi=Si(((t,e)=>{var r,i=function(t,e,r){this.data=[],null!=t&&('number'==typeof t?this.fromNumber(t,e,r):null==e&&'string'!=typeof t?this.fromString(t,256):this.fromString(t,e))},n=function(){return new i(null)},a=function(t,e,r,i,n,a){for(var o=16383&e,s=e>>14;--a>=0;){var h=16383&this.data[t],u=this.data[t++]>>14,l=s*h+u*o;n=((h=o*h+((16383&l)<<14)+r.data[i]+n)>>28)+(l>>14)+s*u,r.data[i++]=268435455&h}return n},o=function(t){return C.charAt(t)},s=function(t,e){var r=A[t.charCodeAt(e)];return null==r?-1:r},h=function(t){var e=n();return e.fromInt(t),e},u=function(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r},l=function(t){this.m=t},f=function(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e},y=function(t){for(var e=0;0!=t;)t&=t-1,++e;return e},v=function(){},b=function(t){return t},w=function(t){this.r2=n(),this.q3=n(),i.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t},M=function(){return{nextBytes:function(t){for(var e=0;e>15;--a>=0;){var h=32767&this.data[t],u=this.data[t++]>>15,l=s*h+u*o;n=((h=o*h+((32767&l)<<15)+r.data[i]+(1073741823&n))>>>30)+(l>>>15)+s*u+(n>>>30),r.data[i++]=1073741823&h}return n},r=30):'Netscape'!=navigator.appName?(i.prototype.am=function(t,e,r,i,n,a){for(;--a>=0;){var o=e*this.data[t++]+r.data[i]+n;n=Math.floor(o/67108864),r.data[i++]=67108863&o}return n},r=26):(i.prototype.am=a,r=28),i.prototype.DB=r,i.prototype.DM=(1<=0?t.mod(this.m):t},l.prototype.revert=function(t){return t},l.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},l.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},l.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},f.prototype.convert=function(t){var e=n();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(i.ZERO)>0&&this.m.subTo(e,e),e},f.prototype.revert=function(t){var e=n();return t.copyTo(e),this.reduce(e),e},f.prototype.reduce=function(t){for(;t.t<=this.mt2;)t.data[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t.data[r]+=this.m.am(0,i,t,e,0,this.m.t);t.data[r]>=t.DV;)t.data[r]-=t.DV,t.data[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},f.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},f.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},i.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t.data[e]=this.data[e];t.t=this.t,t.s=this.s},i.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this.data[0]=t:t<-1?this.data[0]=t+this.DV:this.t=0},i.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,a=!1,o=0;--n>=0;){var h=8==r?255&t[n]:s(t,n);h<0?'-'==t.charAt(n)&&(a=!0):(a=!1,0==o?this.data[this.t++]=h:o+r>this.DB?(this.data[this.t-1]|=(h&(1<>this.DB-o):this.data[this.t-1]|=h<=this.DB&&(o-=this.DB))}8==r&&128&t[0]&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==t;)--this.t},i.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e.data[r+t]=this.data[r];for(r=t-1;r>=0;--r)e.data[r]=0;e.t=this.t+t,e.s=this.s},i.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e.data[r+o+1]=this.data[r]>>n|s,s=(this.data[r]&a)<=0;--r)e.data[r]=0;e.data[o]=s,e.t=this.t+o+1,e.s=this.s,e.clamp()},i.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,n=this.DB-i,a=(1<>i;for(var o=r+1;o>i;i>0&&(e.data[this.t-r-1]|=(this.s&a)<>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e.data[r++]=this.DV+i:i>0&&(e.data[r++]=i),e.t=r,e.clamp()},i.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),a=r.t;for(e.t=a+n.t;--a>=0;)e.data[a]=0;for(a=0;a=0;)t.data[r]=0;for(r=0;r=e.DV&&(t.data[r+e.t]-=e.DV,t.data[r+e.t+1]=1)}t.t>0&&(t.data[t.t-1]+=e.am(r,e.data[r],t,2*r,0,1)),t.s=0,t.clamp()},i.prototype.divRemTo=function(t,e,r){var a=t.abs();if(!(a.t<=0)){var o=this.abs();if(o.t0?(a.lShiftTo(f,s),o.lShiftTo(f,r)):(a.copyTo(s),o.copyTo(r));var c=s.t,d=s.data[c-1];if(0!=d){var p=d*(1<1?s.data[c-2]>>this.F2:0),m=this.FV/p,g=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),i.ONE.dlShiftTo(c,w),w.subTo(s,s);s.t=0;){var M=r.data[--v]==d?this.DM:Math.floor(r.data[v]*m+(r.data[v-1]+y)*g);if((r.data[v]+=s.am(0,M,r,b,0,c))0&&r.rShiftTo(f,r),h<0&&i.ZERO.subTo(r,r)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var t=this.data[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},i.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},i.prototype.exp=function(t,e){if(t>4294967295||t<1)return i.ONE;var r=n(),a=n(),o=e.convert(this),s=u(t)-1;for(o.copyTo(r);--s>=0;)if(e.sqrTo(r,a),(t&1<0)e.mulTo(a,o,r);else{var h=r;r=a,a=h}return e.revert(r)},i.prototype.toString=function(t){if(this.s<0)return'-'+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<0)for(h>h)>0&&(n=!0,a=o(r));s>=0;)h>(h+=this.DB-e)):(r=this.data[s]>>(h-=e)&i,h<=0&&(h+=this.DB,--s)),r>0&&(n=!0),n&&(a+=o(r));return n?a:'0'},i.prototype.negate=function(){var t=n();return i.ZERO.subTo(this,t),t},i.prototype.abs=function(){return this.s<0?this.negate():this},i.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this.data[r]-t.data[r]))return e;return 0},i.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+u(this.data[this.t-1]^this.s&this.DM)},i.prototype.mod=function(t){var e=n();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(i.ZERO)>0&&t.subTo(e,e),e},i.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new l(e):new f(e),this.exp(t,r)},i.ZERO=h(0),i.ONE=h(1),v.prototype.convert=b,v.prototype.revert=b,v.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},v.prototype.sqrTo=function(t,e){t.squareTo(e)},w.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=n();return t.copyTo(e),this.reduce(e),e},w.prototype.revert=function(t){return t},w.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},w.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},w.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var I=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],T=(1<<26)/I[I.length-1];i.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},i.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return'0';var e=this.chunkSize(t),r=Math.pow(t,e),i=h(r),a=n(),o=n(),s='';for(this.divRemTo(i,a,o);a.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,a.divRemTo(i,a,o);return o.intValue().toString(t)+s},i.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),a=!1,o=0,h=0,u=0;u=r&&(this.dMultiply(n),this.dAddOffset(h,0),o=0,h=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(h,0)),a&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(t,e,r){if('number'==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(i.ONE.shiftLeft(t-1),d,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(i.ONE.shiftLeft(t-1),this);else{var n=new Array,a=7&t;n.length=1+(t>>3),e.nextBytes(n),a>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e.data[r++]=i:i<-1&&(e.data[r++]=this.DV+i),e.t=r,e.clamp()},i.prototype.dMultiply=function(t){this.data[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},i.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=t;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}},i.prototype.multiplyLowerTo=function(t,e,r){var i,n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;for(i=r.t-this.t;n=0;)r.data[i]=0;for(i=Math.max(e-this.t,0);i0)if(0==e)r=this.data[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this.data[i])%t;return r},i.prototype.millerRabin=function(t){var e=this.subtract(i.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n,a=e.shiftRight(r),o=M(),s=0;s=0);var h=n.modPow(a,this);if(0!=h.compareTo(i.ONE)&&0!=h.compareTo(e)){for(var u=1;u++>24},i.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},i.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},i.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i>i)!=(this.s&this.DM)>>i&&(e[n++]=r|this.s<=0;)i<8?(r=(this.data[t]&(1<>(i+=this.DB-8)):(r=this.data[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&r&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=r);return e},i.prototype.equals=function(t){return 0==this.compareTo(t)},i.prototype.min=function(t){return this.compareTo(t)<0?this:t},i.prototype.max=function(t){return this.compareTo(t)>0?this:t},i.prototype.and=function(t){var e=n();return this.bitwiseTo(t,c,e),e},i.prototype.or=function(t){var e=n();return this.bitwiseTo(t,d,e),e},i.prototype.xor=function(t){var e=n();return this.bitwiseTo(t,p,e),e},i.prototype.andNot=function(t){var e=n();return this.bitwiseTo(t,m,e),e},i.prototype.not=function(){for(var t=n(),e=0;e=this.t?0!=this.s:!!(this.data[e]&1<1){var m=n();for(i.sqrTo(s[1],m);c<=p;)s[c]=n(),i.mulTo(m,s[c-2],s[c]),c+=2}var g,y,v=t.t-1,b=!0,M=n();for(a=u(t.data[v])-1;v>=0;){for(a>=d?g=t.data[v]>>a-d&p:(g=(t.data[v]&(1<0&&(g|=t.data[v-1]>>this.DB+a-d)),c=r;!(1&g);)g>>=1,--c;if((a-=c)<0&&(a+=this.DB,--v),b)s[g].copyTo(o),b=!1;else{for(;c>1;)i.sqrTo(o,M),i.sqrTo(M,o),c-=2;c>0?i.sqrTo(o,M):(y=o,o=M,M=y),i.mulTo(M,s[g],o)}for(;v>=0&&!(t.data[v]&1<=0?(r.subTo(n,r),e&&a.subTo(s,a),o.subTo(u,o)):(n.subTo(r,n),e&&s.subTo(a,s),u.subTo(o,u))}return 0!=n.compareTo(i.ONE)?i.ZERO:u.compareTo(t)>=0?u.subtract(t):u.signum()<0?(u.addTo(t,u),u.signum()<0?u.add(t):u):u},i.prototype.pow=function(t){return this.exp(t,new v)},i.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var n=e.getLowestSetBit(),a=r.getLowestSetBit();if(a<0)return e;for(n0&&(e.rShiftTo(a,e),r.rShiftTo(a,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r},i.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r.data[0]<=I[I.length-1]){for(e=0;e{var r=function(t,e,r){for(var i,n,a,o,s,h,u,l=r.length();l>=64;){for(n=t.h0,a=t.h1,o=t.h2,s=t.h3,h=t.h4,u=0;u<16;++u)i=r.getInt32(),e[u]=i,i=(n<<5|n>>>27)+(s^a&(o^s))+h+1518500249+i,h=s,s=o,o=(a<<30|a>>>2)>>>0,a=n,n=i;for(;u<20;++u)i=(i=e[u-3]^e[u-8]^e[u-14]^e[u-16])<<1|i>>>31,e[u]=i,i=(n<<5|n>>>27)+(s^a&(o^s))+h+1518500249+i,h=s,s=o,o=(a<<30|a>>>2)>>>0,a=n,n=i;for(;u<32;++u)i=(i=e[u-3]^e[u-8]^e[u-14]^e[u-16])<<1|i>>>31,e[u]=i,i=(n<<5|n>>>27)+(a^o^s)+h+1859775393+i,h=s,s=o,o=(a<<30|a>>>2)>>>0,a=n,n=i;for(;u<40;++u)i=(i=e[u-6]^e[u-16]^e[u-28]^e[u-32])<<2|i>>>30,e[u]=i,i=(n<<5|n>>>27)+(a^o^s)+h+1859775393+i,h=s,s=o,o=(a<<30|a>>>2)>>>0,a=n,n=i;for(;u<60;++u)i=(i=e[u-6]^e[u-16]^e[u-28]^e[u-32])<<2|i>>>30,e[u]=i,i=(n<<5|n>>>27)+(a&o|s&(a^o))+h+2400959708+i,h=s,s=o,o=(a<<30|a>>>2)>>>0,a=n,n=i;for(;u<80;++u)i=(i=e[u-6]^e[u-16]^e[u-28]^e[u-32])<<2|i>>>30,e[u]=i,i=(n<<5|n>>>27)+(a^o^s)+h+3395469782+i,h=s,s=o,o=(a<<30|a>>>2)>>>0,a=n,n=i;t.h0=t.h0+n|0,t.h1=t.h1+a|0,t.h2=t.h2+o|0,t.h3=t.h3+s|0,t.h4=t.h4+h|0,l-=64}},i=Ci();Li(),Ii();var n=e.exports=i.sha1=i.sha1||{};i.md.sha1=i.md.algorithms.sha1=n,n.create=function(){o||(a=String.fromCharCode(128),a+=i.util.fillString(String.fromCharCode(0),64),o=!0);var t=null,e=i.util.createBuffer(),n=new Array(80),s={algorithm:'sha1',blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){s.messageLength=0,s.fullMessageLength=s.messageLength64=[];for(var r=s.messageLengthSize/4,n=0;n>>0,h>>>0];for(var u=s.fullMessageLength.length-1;u>=0;--u)s.fullMessageLength[u]+=h[1],h[1]=h[0]+(s.fullMessageLength[u]/4294967296>>>0),s.fullMessageLength[u]=s.fullMessageLength[u]>>>0,h[0]=h[1]/4294967296>>>0;return e.putBytes(a),r(t,n,e),(e.read>2048||0===e.length())&&e.compact(),s},s.digest=function(){var o=i.util.createBuffer();o.putBytes(e.bytes());var h,u=s.fullMessageLength[s.fullMessageLength.length-1]+s.messageLengthSize&s.blockLength-1;o.putBytes(a.substr(0,s.blockLength-u));for(var l=8*s.fullMessageLength[0],f=0;f>>0,o.putInt32(l>>>0),l=h>>>0;o.putInt32(l);var c={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};r(c,n,o);var d=i.util.createBuffer();return d.putInt32(c.h0),d.putInt32(c.h1),d.putInt32(c.h2),d.putInt32(c.h3),d.putInt32(c.h4),d},s};var a=null,o=!1})),Qi=Si(((t,e)=>{var r=function(t,e,r){r||(r=i.md.sha1.create());for(var n='',a=Math.ceil(e/r.digestLength),o=0;o>24&255,o>>16&255,o>>8&255,255&o);r.start(),r.update(t+s),n+=r.digest().getBytes()}return n.substring(0,e)},i=Ci();Ii(),Wi(),$i();var n=e.exports=i.pkcs1=i.pkcs1||{};n.encode_rsa_oaep=function(t,e,n){var a,o,s,h;'string'==typeof n?(a=n,o=arguments[3]||void 0,s=arguments[4]||void 0):n&&(a=n.label||void 0,o=n.seed||void 0,s=n.md||void 0,n.mgf1&&n.mgf1.md&&(h=n.mgf1.md)),s?s.start():s=i.md.sha1.create(),h||(h=s);var u=Math.ceil(t.n.bitLength()/8),l=u-2*s.digestLength-2;if(e.length>l)throw(g=new Error('RSAES-OAEP input message length is too long.')).length=e.length,g.maxLength=l,g;a||(a=''),s.update(a,'raw');for(var f=s.digest(),c='',d=l-e.length,p=0;p{var r=Ci();Ii(),Yi(),Wi(),function(){if(r.prime)e.exports=r.prime;else{var t=e.exports=r.prime=r.prime||{},i=r.jsbn.BigInteger,n=[6,4,2,4,2,4,6,2],a=new i(null);a.fromInt(30);var o=function(t,e){return t|e};t.generateProbablePrime=function(t,e,n){'function'==typeof e&&(n=e,e={});var a=(e=e||{}).algorithm||'PRIMEINC';'string'==typeof a&&(a={name:a}),a.options=a.options||{};var o=e.prng||r.random,h={nextBytes:function(t){for(var e=o.getBytesSync(t.length),r=0;rt&&(o=u(t,e));var d=o.toString(16);n.target.postMessage({hex:d,workLoad:l}),o.dAddOffset(f,0)}}}d()}(t,e,n,a);return s(t,e,n,a)}(t,h,a.options,n);throw new Error('Invalid prime generation algorithm: '+a.name)}}function s(t,e,r,i){var n=u(t,e),a=function(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}(n.bitLength());'millerRabinTests'in r&&(a=r.millerRabinTests);var o=10;'maxBlockTime'in r&&(o=r.maxBlockTime),h(n,t,e,0,a,o,i)}function h(t,e,i,a,o,s,l){var f=+new Date;do{if(t.bitLength()>e&&(t=u(e,i)),t.isProbablePrime(o))return l(null,t);t.dAddOffset(n[a++%8],0)}while(s<0||+new Date-f{var r,i=function(t,e,r){var i=f.util.createBuffer(),n=Math.ceil(e.n.bitLength()/8);if(t.length>n-11){var a=new Error('Message is too long for PKCS#1 v1.5 padding.');throw a.length=t.length,a.max=n-11,a}i.putByte(0),i.putByte(r);var o,s=n-3-t.length;if(0===r||1===r){o=0===r?0:255;for(var h=0;h0;){var u=0,l=f.random.getBytes(s);for(h=0;h1;){if(255!==a.getByte()){--a.read;break}++h}else if(2===s)for(h=0;a.length()>1;){if(0===a.getByte()){--a.read;break}++h}if(0!==a.getByte()||h!==n-3-a.length())throw new Error('Encryption block is invalid.');return a.getBytes()},a=function(t){var e=t.toString(16);e[0]>='8'&&(e='00'+e);var r=f.util.hexToBytes(e);return!(r.length>1)||(0!==r.charCodeAt(0)||128&r.charCodeAt(1))&&(255!==r.charCodeAt(0)||128&~r.charCodeAt(1))?r:r.substr(1)},o=function(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2},s=function(t){return f.util.isNodejs&&'function'==typeof c[t]},h=function(t){return void 0!==p.globalScope&&'object'==typeof p.globalScope.crypto&&'object'==typeof p.globalScope.crypto.subtle&&'function'==typeof p.globalScope.crypto.subtle[t]},u=function(t){return void 0!==p.globalScope&&'object'==typeof p.globalScope.msCrypto&&'object'==typeof p.globalScope.msCrypto.subtle&&'function'==typeof p.globalScope.msCrypto.subtle[t]},l=function(t){for(var e=f.util.hexToBytes(t.toString(16)),r=new Uint8Array(e.length),i=0;i=0||!n.gcd(e.n).equals(r.ONE));for(var a=(t=t.multiply(n.modPow(e.e,e.n)).mod(e.n)).mod(e.p).modPow(e.dP,e.p),o=t.mod(e.q).modPow(e.dQ,e.q);a.compareTo(o)<0;)a=a.add(e.p);var s=a.subtract(o).multiply(e.qInv).mod(e.p).multiply(e.q).add(o);return s=s.multiply(n.modInverse(e.n)).mod(e.n)};m.rsa.encrypt=function(t,e,n){var a,o=n,s=Math.ceil(e.n.bitLength()/8);!1!==n&&!0!==n?(o=2===n,a=i(t,e,n)):(a=f.util.createBuffer()).putBytes(t);for(var h=new r(a.toHex(),16),u=E(h,e,o).toString(16),l=f.util.createBuffer(),c=s-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(f.util.hexToBytes(u)),l.getBytes()},m.rsa.decrypt=function(t,e,i,a){var o=Math.ceil(e.n.bitLength()/8);if(t.length!==o){var s=new Error('Encrypted message length is invalid.');throw s.length=t.length,s.expected=o,s}var h=new r(f.util.createBuffer(t).toHex(),16);if(h.compareTo(e.n)>=0)throw new Error('Encrypted message is invalid.');for(var u=E(h,e,i).toString(16),l=f.util.createBuffer(),c=o-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(f.util.hexToBytes(u)),!1!==a?n(l.getBytes(),e,i):l.getBytes()},m.rsa.createKeyPairGenerationState=function(t,e,i){'string'==typeof t&&(t=parseInt(t,10)),t=t||2048;var n,a=(i=i||{}).prng||f.random,o={nextBytes:function(t){for(var e=a.getBytesSync(t.length),r=0;r>1,pBits:t-(t>>1),pqState:0,num:null,keys:null}).e.fromInt(n.eInt),n},m.rsa.stepKeyPairGenerationState=function(t,e){'algorithm'in t||(t.algorithm='PRIMEINC');var i=new r(null);i.fromInt(30);for(var n,a=0,s=function(t,e){return t|e},h=+new Date,u=0;null===t.keys&&(e<=0||ul?t.pqState=0:t.num.isProbablePrime(o(t.num.bitLength()))?++t.pqState:t.num.dAddOffset(g[a++%8],0):2===t.pqState?t.pqState=0===t.num.subtract(r.ONE).gcd(t.e).compareTo(r.ONE)?3:0:3===t.pqState&&(t.pqState=0,null===t.p?t.p=t.num:t.q=t.num,null!==t.p&&null!==t.q&&++t.state,t.num=null)}else if(1===t.state)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(2===t.state)t.p1=t.p.subtract(r.ONE),t.q1=t.q.subtract(r.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(3===t.state)0===t.phi.gcd(t.e).compareTo(r.ONE)?++t.state:(t.p=null,t.q=null,t.state=0);else if(4===t.state)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(5===t.state){var c=t.e.modInverse(t.phi);t.keys={privateKey:m.rsa.setPrivateKey(t.n,t.e,c,t.p,t.q,c.mod(t.p1),c.mod(t.q1),t.q.modInverse(t.p)),publicKey:m.rsa.setPublicKey(t.n,t.e)}}u+=(n=+new Date)-h,h=n}return null!==t.keys},m.rsa.generateKeyPair=function(t,e,i,n){if(1===arguments.length?'object'==typeof t?(i=t,t=void 0):'function'==typeof t&&(n=t,t=void 0):2===arguments.length?'number'==typeof t?'function'==typeof e?(n=e,e=void 0):'number'!=typeof e&&(i=e,e=void 0):(i=t,n=e,t=void 0,e=void 0):3===arguments.length&&('number'==typeof e?'function'==typeof i&&(n=i,i=void 0):(n=i,i=e,e=void 0)),i=i||{},void 0===t&&(t=i.bits||2048),void 0===e&&(e=i.e||65537),!f.options.usePureJavaScript&&!i.prng&&t>=256&&t<=16384&&(65537===e||3===e))if(n){if(s('generateKeyPair'))return c.generateKeyPair('rsa',{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:'spki',format:'pem'},privateKeyEncoding:{type:'pkcs8',format:'pem'}},(function(t,e,r){if(t)return n(t);n(null,{privateKey:m.privateKeyFromPem(r),publicKey:m.publicKeyFromPem(e)})}));if(h('generateKey')&&h('exportKey'))return p.globalScope.crypto.subtle.generateKey({name:'RSASSA-PKCS1-v1_5',modulusLength:t,publicExponent:l(e),hash:{name:'SHA-256'}},!0,['sign','verify']).then((function(t){return p.globalScope.crypto.subtle.exportKey('pkcs8',t.privateKey)})).then(void 0,(function(t){n(t)})).then((function(t){if(t){var e=m.privateKeyFromAsn1(d.fromDer(f.util.createBuffer(t)));n(null,{privateKey:e,publicKey:m.setRsaPublicKey(e.n,e.e)})}}));if(u('generateKey')&&u('exportKey')){var a=p.globalScope.msCrypto.subtle.generateKey({name:'RSASSA-PKCS1-v1_5',modulusLength:t,publicExponent:l(e),hash:{name:'SHA-256'}},!0,['sign','verify']);return a.oncomplete=function(t){var e=t.target.result,r=p.globalScope.msCrypto.subtle.exportKey('pkcs8',e.privateKey);r.oncomplete=function(t){var e=t.target.result,r=m.privateKeyFromAsn1(d.fromDer(f.util.createBuffer(e)));n(null,{privateKey:r,publicKey:m.setRsaPublicKey(r.n,r.e)})},r.onerror=function(t){n(t)}},void(a.onerror=function(t){n(t)})}}else if(s('generateKeyPairSync')){var o=c.generateKeyPairSync('rsa',{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:'spki',format:'pem'},privateKeyEncoding:{type:'pkcs8',format:'pem'}});return{privateKey:m.privateKeyFromPem(o.privateKey),publicKey:m.publicKeyFromPem(o.publicKey)}}var g=m.rsa.createKeyPairGenerationState(t,e,i);if(!n)return m.rsa.stepKeyPairGenerationState(g,0),g.keys;!function(t,e,i){'function'==typeof e&&(i=e,e={});var n={algorithm:{name:(e=e||{}).algorithm||'PRIMEINC',options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};function a(){o(t.pBits,(function(e,r){return e?i(e):(t.p=r,null!==t.q?s(e,t.q):void o(t.qBits,s))}))}function o(t,e){f.prime.generateProbablePrime(t,n,e)}function s(e,n){if(e)return i(e);if(t.q=n,t.p.compareTo(t.q)<0){var h=t.p;t.p=t.q,t.q=h}if(0!==t.p.subtract(r.ONE).gcd(t.e).compareTo(r.ONE))return t.p=null,void a();if(0!==t.q.subtract(r.ONE).gcd(t.e).compareTo(r.ONE))return t.q=null,void o(t.qBits,s);if(t.p1=t.p.subtract(r.ONE),t.q1=t.q.subtract(r.ONE),t.phi=t.p1.multiply(t.q1),0!==t.phi.gcd(t.e).compareTo(r.ONE))return t.p=t.q=null,void a();if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits)return t.q=null,void o(t.qBits,s);var u=t.e.modInverse(t.phi);t.keys={privateKey:m.rsa.setPrivateKey(t.n,t.e,u,t.p,t.q,u.mod(t.p1),u.mod(t.q1),t.q.modInverse(t.p)),publicKey:m.rsa.setPublicKey(t.n,t.e)},i(null,t.keys)}'prng'in e&&(n.prng=e.prng),a()}(g,i,n)},m.setRsaPublicKey=m.rsa.setPublicKey=function(t,e){var r={n:t,e,encrypt:function(t,e,n){if('string'==typeof e?e=e.toUpperCase():void 0===e&&(e='RSAES-PKCS1-V1_5'),'RSAES-PKCS1-V1_5'===e)e={encode:function(t,e,r){return i(t,e,2).getBytes()}};else if('RSA-OAEP'===e||'RSAES-OAEP'===e)e={encode:function(t,e){return f.pkcs1.encode_rsa_oaep(e,t,n)}};else if(-1!==['RAW','NONE','NULL',null].indexOf(e))e={encode:function(t){return t}};else if('string'==typeof e)throw new Error('Unsupported encryption scheme: "'+e+'".');var a=e.encode(t,r,!0);return m.rsa.encrypt(a,r,!0)},verify:function(t,e,i,a){'string'==typeof i?i=i.toUpperCase():void 0===i&&(i='RSASSA-PKCS1-V1_5'),void 0===a&&(a={_parseAllDigestBytes:!0}),'_parseAllDigestBytes'in a||(a._parseAllDigestBytes=!0),'RSASSA-PKCS1-V1_5'===i?i={verify:function(t,e){e=n(e,r,!0);var i=d.fromDer(e,{parseAllBytes:a._parseAllDigestBytes}),o={},s=[];if(!d.validate(i,M,o,s))throw(h=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=s,h;var h,u=d.derToOid(o.algorithmIdentifier);if(u!==f.oids.md2&&u!==f.oids.md5&&u!==f.oids.sha1&&u!==f.oids.sha224&&u!==f.oids.sha256&&u!==f.oids.sha384&&u!==f.oids.sha512&&u!==f.oids['sha512-224']&&u!==f.oids['sha512-256'])throw(h=new Error('Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.')).oid=u,h;if((u===f.oids.md2||u===f.oids.md5)&&!('parameters'in o))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return t===o.digest}}:'NONE'!==i&&'NULL'!==i&&null!==i||(i={verify:function(t,e){return t===(e=n(e,r,!0))}});var o=m.rsa.decrypt(e,r,!0,!1);return i.verify(t,o,r.n.bitLength())}};return r},m.setRsaPrivateKey=m.rsa.setPrivateKey=function(t,e,r,i,a,o,s,h){var u={n:t,e,d:r,p:i,q:a,dP:o,dQ:s,qInv:h,decrypt:function(t,e,r){'string'==typeof e?e=e.toUpperCase():void 0===e&&(e='RSAES-PKCS1-V1_5');var i=m.rsa.decrypt(t,u,!1,!1);if('RSAES-PKCS1-V1_5'===e)e={decode:n};else if('RSA-OAEP'===e||'RSAES-OAEP'===e)e={decode:function(t,e){return f.pkcs1.decode_rsa_oaep(e,t,r)}};else{if(-1===['RAW','NONE','NULL',null].indexOf(e))throw new Error('Unsupported encryption scheme: "'+e+'".');e={decode:function(t){return t}}}return e.decode(i,u,!1)},sign:function(t,e){var r=!1;'string'==typeof e&&(e=e.toUpperCase()),void 0===e||'RSASSA-PKCS1-V1_5'===e?(e={encode:_},r=1):'NONE'!==e&&'NULL'!==e&&null!==e||(e={encode:function(){return t}},r=1);var i=e.encode(t,u.n.bitLength());return m.rsa.encrypt(i,u,r)}};return u},m.wrapRsaPrivateKey=function(t){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(0).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(m.oids.rsaEncryption).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,'')]),d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,d.toDer(t).getBytes())])},m.privateKeyFromAsn1=function(t){var e,i,n,a,o,s,h,u,l={},c=[];if(d.validate(t,y,l,c)&&(t=d.fromDer(f.util.createBuffer(l.privateKey))),l={},c=[],!d.validate(t,v,l,c)){var p=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw p.errors=c,p}return e=f.util.createBuffer(l.privateKeyModulus).toHex(),i=f.util.createBuffer(l.privateKeyPublicExponent).toHex(),n=f.util.createBuffer(l.privateKeyPrivateExponent).toHex(),a=f.util.createBuffer(l.privateKeyPrime1).toHex(),o=f.util.createBuffer(l.privateKeyPrime2).toHex(),s=f.util.createBuffer(l.privateKeyExponent1).toHex(),h=f.util.createBuffer(l.privateKeyExponent2).toHex(),u=f.util.createBuffer(l.privateKeyCoefficient).toHex(),m.setRsaPrivateKey(new r(e,16),new r(i,16),new r(n,16),new r(a,16),new r(o,16),new r(s,16),new r(h,16),new r(u,16))},m.privateKeyToAsn1=m.privateKeyToRSAPrivateKey=function(t){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(0).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.n)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.e)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.d)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.p)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.q)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.dP)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.dQ)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.qInv))])},m.publicKeyFromAsn1=function(t){var e={},i=[];if(d.validate(t,w,e,i)){var n,a=d.derToOid(e.publicKeyOid);if(a!==m.oids.rsaEncryption)throw(n=new Error('Cannot read public key. Unknown OID.')).oid=a,n;t=e.rsaPublicKey}if(i=[],!d.validate(t,b,e,i))throw(n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=i,n;var o=f.util.createBuffer(e.publicKeyModulus).toHex(),s=f.util.createBuffer(e.publicKeyExponent).toHex();return m.setRsaPublicKey(new r(o,16),new r(s,16))},m.publicKeyToAsn1=m.publicKeyToSubjectPublicKeyInfo=function(t){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(m.oids.rsaEncryption).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,'')]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,[m.publicKeyToRSAPublicKey(t)])])},m.publicKeyToRSAPublicKey=function(t){return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.n)),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,a(t.e))])}})),tn=Si(((t,e)=>{var r,i=function(t,e){return t.start().update(e).digest().getBytes()},n=function(t){var e;if(t){if(!(e=h.oids[s.derToOid(t)])){var r=new Error('Unsupported PRF OID.');throw r.oid=t,r.supported=['hmacWithSHA1','hmacWithSHA224','hmacWithSHA256','hmacWithSHA384','hmacWithSHA512'],r}}else e='hmacWithSHA1';return a(e)},a=function(t){var e=o.md;switch(t){case'hmacWithSHA224':e=o.md.sha512;case'hmacWithSHA1':case'hmacWithSHA256':case'hmacWithSHA384':case'hmacWithSHA512':t=t.substr(8).toLowerCase();break;default:var r=new Error('Unsupported PRF algorithm.');throw r.algorithm=t,r.supported=['hmacWithSHA1','hmacWithSHA224','hmacWithSHA256','hmacWithSHA384','hmacWithSHA512'],r}if(!e||!(t in e))throw new Error('Unknown hash algorithm: '+t);return e[t].create()},o=Ci();ki(),Ni(),Pi(),Li(),Ri(),Hi(),Ui(),Wi(),Zi(),Ji(),Ii(),void 0===r&&(r=o.jsbn.BigInteger);var s=o.asn1,h=o.pki=o.pki||{};e.exports=h.pbe=o.pbe=o.pbe||{};var u=h.oids,l={name:'EncryptedPrivateKeyInfo',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedPrivateKeyInfo.encryptionAlgorithm',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:'encryptionOid'},{name:'AlgorithmIdentifier.parameters',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,captureAsn1:'encryptionParams'}]},{name:'EncryptedPrivateKeyInfo.encryptedData',tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:'encryptedData'}]},f={name:'PBES2Algorithms',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.keyDerivationFunc',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.keyDerivationFunc.oid',tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:'kdfOid'},{name:'PBES2Algorithms.params',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.params.salt',tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:'kdfSalt'},{name:'PBES2Algorithms.params.iterationCount',tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:'kdfIterationCount'},{name:'PBES2Algorithms.params.keyLength',tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,optional:!0,capture:'keyLength'},{name:'PBES2Algorithms.params.prf',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:'PBES2Algorithms.params.prf.algorithm',tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:'prfOid'}]}]}]},{name:'PBES2Algorithms.encryptionScheme',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.encryptionScheme.oid',tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:'encOid'},{name:'PBES2Algorithms.encryptionScheme.iv',tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:'encIv'}]}]},c={name:'pkcs-12PbeParams',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'pkcs-12PbeParams.salt',tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:'salt'},{name:'pkcs-12PbeParams.iterations',tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:'iterations'}]};h.encryptPrivateKeyInfo=function(t,e,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||'aes128',r.prfAlgorithm=r.prfAlgorithm||'sha1';var i,n,l,f=o.random.getBytesSync(r.saltSize),c=r.count,d=s.integerToDer(c);if(0===r.algorithm.indexOf('aes')||'des'===r.algorithm){var p,m,g;switch(r.algorithm){case'aes128':i=16,p=16,m=u['aes128-CBC'],g=o.aes.createEncryptionCipher;break;case'aes192':i=24,p=16,m=u['aes192-CBC'],g=o.aes.createEncryptionCipher;break;case'aes256':i=32,p=16,m=u['aes256-CBC'],g=o.aes.createEncryptionCipher;break;case'des':i=8,p=8,m=u.desCBC,g=o.des.createEncryptionCipher;break;default:throw(_=new Error('Cannot encrypt private key. Unknown encryption algorithm.')).algorithm=r.algorithm,_}var y='hmacWith'+r.prfAlgorithm.toUpperCase(),v=a(y),b=o.pkcs5.pbkdf2(e,f,c,i,v),w=o.random.getBytesSync(p);(E=g(b)).start(w),E.update(s.toDer(t)),E.finish(),l=E.output.getBytes();var M=function(t,e,r,i){var n=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,t),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,e.getBytes())]);return'hmacWithSHA1'!==i&&n.value.push(s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,o.util.hexToBytes(r.toString(16))),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(h.oids[i]).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,'')])),n}(f,d,i,y);n=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(u.pkcs5PBES2).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(u.pkcs5PBKDF2).getBytes()),M]),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(m).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,w)])])])}else{var _;if('3des'!==r.algorithm)throw(_=new Error('Cannot encrypt private key. Unknown encryption algorithm.')).algorithm=r.algorithm,_;i=24;var E,S=new o.util.ByteBuffer(f);b=h.pbe.generatePkcs12Key(e,S,1,c,i),w=h.pbe.generatePkcs12Key(e,S,2,c,i);(E=o.des.createEncryptionCipher(b)).start(w),E.update(s.toDer(t)),E.finish(),l=E.output.getBytes(),n=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(u['pbeWithSHAAnd3-KeyTripleDES-CBC']).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,f),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,d.getBytes())])])}return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[n,s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,l)])},h.decryptPrivateKeyInfo=function(t,e){var r=null,i={},n=[];if(!s.validate(t,l,i,n)){var a=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw a.errors=n,a}var u=s.derToOid(i.encryptionOid),f=h.pbe.getCipher(u,i.encryptionParams,e),c=o.util.createBuffer(i.encryptedData);return f.update(c),f.finish()&&(r=s.fromDer(f.output)),r},h.encryptedPrivateKeyToPem=function(t,e){var r={type:'ENCRYPTED PRIVATE KEY',body:s.toDer(t).getBytes()};return o.pem.encode(r,{maxline:e})},h.encryptedPrivateKeyFromPem=function(t){var e=o.pem.decode(t)[0];if('ENCRYPTED PRIVATE KEY'!==e.type){var r=new Error("Could not convert encrypted private key from PEM; PEM header type is \"ENCRYPTED PRIVATE KEY\".");throw r.headerType=e.type,r}if(e.procType&&'ENCRYPTED'===e.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return s.fromDer(e.body)},h.encryptRsaPrivateKey=function(t,e,r){if(!(r=r||{}).legacy){var i=h.wrapRsaPrivateKey(h.privateKeyToAsn1(t));return i=h.encryptPrivateKeyInfo(i,e,r),h.encryptedPrivateKeyToPem(i)}var n,a,u,l;switch(r.algorithm){case'aes128':n='AES-128-CBC',u=16,a=o.random.getBytesSync(16),l=o.aes.createEncryptionCipher;break;case'aes192':n='AES-192-CBC',u=24,a=o.random.getBytesSync(16),l=o.aes.createEncryptionCipher;break;case'aes256':n='AES-256-CBC',u=32,a=o.random.getBytesSync(16),l=o.aes.createEncryptionCipher;break;case'3des':n='DES-EDE3-CBC',u=24,a=o.random.getBytesSync(8),l=o.des.createEncryptionCipher;break;case'des':n='DES-CBC',u=8,a=o.random.getBytesSync(8),l=o.des.createEncryptionCipher;break;default:var f=new Error("Could not encrypt RSA private key; unsupported encryption algorithm \""+r.algorithm+'".');throw f.algorithm=r.algorithm,f}var c=l(o.pbe.opensslDeriveBytes(e,a.substr(0,8),u));c.start(a),c.update(s.toDer(h.privateKeyToAsn1(t))),c.finish();var d={type:'RSA PRIVATE KEY',procType:{version:'4',type:'ENCRYPTED'},dekInfo:{algorithm:n,parameters:o.util.bytesToHex(a).toUpperCase()},body:c.output.getBytes()};return o.pem.encode(d)},h.decryptRsaPrivateKey=function(t,e){var r=null,i=o.pem.decode(t)[0];if('ENCRYPTED PRIVATE KEY'!==i.type&&'PRIVATE KEY'!==i.type&&'RSA PRIVATE KEY'!==i.type)throw(u=new Error("Could not convert private key from PEM; PEM header type is not \"ENCRYPTED PRIVATE KEY\", \"PRIVATE KEY\", or \"RSA PRIVATE KEY\".")).headerType=u,u;if(i.procType&&'ENCRYPTED'===i.procType.type){var n,a;switch(i.dekInfo.algorithm){case'DES-CBC':n=8,a=o.des.createDecryptionCipher;break;case'DES-EDE3-CBC':n=24,a=o.des.createDecryptionCipher;break;case'AES-128-CBC':n=16,a=o.aes.createDecryptionCipher;break;case'AES-192-CBC':n=24,a=o.aes.createDecryptionCipher;break;case'AES-256-CBC':n=32,a=o.aes.createDecryptionCipher;break;case'RC2-40-CBC':n=5,a=function(t){return o.rc2.createDecryptionCipher(t,40)};break;case'RC2-64-CBC':n=8,a=function(t){return o.rc2.createDecryptionCipher(t,64)};break;case'RC2-128-CBC':n=16,a=function(t){return o.rc2.createDecryptionCipher(t,128)};break;default:var u;throw(u=new Error("Could not decrypt private key; unsupported encryption algorithm \""+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,u}var l=o.util.hexToBytes(i.dekInfo.parameters),f=a(o.pbe.opensslDeriveBytes(e,l.substr(0,8),n));if(f.start(l),f.update(o.util.createBuffer(i.body)),!f.finish())return r;r=f.output.getBytes()}else r=i.body;return null!==(r='ENCRYPTED PRIVATE KEY'===i.type?h.decryptPrivateKeyInfo(s.fromDer(r),e):s.fromDer(r))&&(r=h.privateKeyFromAsn1(r)),r},h.pbe.generatePkcs12Key=function(t,e,r,i,n,a){var s,h;if(null==a){if(!('sha1'in o.md))throw new Error('"sha1" hash algorithm unavailable.');a=o.md.sha1.create()}var u=a.digestLength,l=a.blockLength,f=new o.util.ByteBuffer,c=new o.util.ByteBuffer;if(null!=t){for(h=0;h=0;h--)B>>=8,B+=C.at(h)+T.at(h),T.setAt(h,255&B);I.putBuffer(T)}w=I,f.putBuffer(E)}return f.truncate(f.length()-n),f},h.pbe.getCipher=function(t,e,r){switch(t){case h.oids.pkcs5PBES2:return h.pbe.getCipherForPBES2(t,e,r);case h.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:case h.oids['pbewithSHAAnd40BitRC2-CBC']:return h.pbe.getCipherForPKCS12PBE(t,e,r);default:var i=new Error('Cannot read encrypted PBE data block. Unsupported OID.');throw i.oid=t,i.supportedOids=['pkcs5PBES2','pbeWithSHAAnd3-KeyTripleDES-CBC','pbewithSHAAnd40BitRC2-CBC'],i}},h.pbe.getCipherForPBES2=function(t,e,r){var i,a={},u=[];if(!s.validate(e,f,a,u))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=u,i;if((t=s.derToOid(a.kdfOid))!==h.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=t,i.supportedOids=['pkcs5PBKDF2'],i;if((t=s.derToOid(a.encOid))!==h.oids['aes128-CBC']&&t!==h.oids['aes192-CBC']&&t!==h.oids['aes256-CBC']&&t!==h.oids['des-EDE3-CBC']&&t!==h.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=t,i.supportedOids=['aes128-CBC','aes192-CBC','aes256-CBC','des-EDE3-CBC','desCBC'],i;var l,c,d=a.kdfSalt,p=o.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),h.oids[t]){case'aes128-CBC':l=16,c=o.aes.createDecryptionCipher;break;case'aes192-CBC':l=24,c=o.aes.createDecryptionCipher;break;case'aes256-CBC':l=32,c=o.aes.createDecryptionCipher;break;case'des-EDE3-CBC':l=24,c=o.des.createDecryptionCipher;break;case'desCBC':l=8,c=o.des.createDecryptionCipher}var m=n(a.prfOid),g=o.pkcs5.pbkdf2(r,d,p,l,m),y=a.encIv,v=c(g);return v.start(y),v},h.pbe.getCipherForPKCS12PBE=function(t,e,r){var i={},a=[];if(!s.validate(e,c,i,a))throw(m=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,m;var u,l,f,d=o.util.createBuffer(i.salt),p=o.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),t){case h.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:u=24,l=8,f=o.des.startDecrypting;break;case h.oids['pbewithSHAAnd40BitRC2-CBC']:u=5,l=8,f=function(t,e){var r=o.rc2.createDecryptionCipher(t,40);return r.start(e,null),r};break;default:var m;throw(m=new Error('Cannot read PKCS #12 PBE data block. Unsupported OID.')).oid=t,m}var g=n(i.prfOid),y=h.pbe.generatePkcs12Key(r,d,1,p,u,g);return g.start(),f(y,h.pbe.generatePkcs12Key(r,d,2,p,l,g))},h.pbe.opensslDeriveBytes=function(t,e,r,n){if(null==n){if(!('md5'in o.md))throw new Error('"md5" hash algorithm unavailable.');n=o.md.md5.create()}null===e&&(e='');for(var a=[i(n,t+e)],s=16,h=1;s{var r=Ci();Ni(),Ii();var i=r.asn1,n=e.exports=r.pkcs7asn1=r.pkcs7asn1||{};r.pkcs7=r.pkcs7||{},r.pkcs7.asn1=n;var a={name:'ContentInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'ContentInfo.ContentType',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'contentType'},{name:'ContentInfo.content',tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:'content'}]};n.contentInfoValidator=a;var o={name:'EncryptedContentInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedContentInfo.contentType',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'contentType'},{name:'EncryptedContentInfo.contentEncryptionAlgorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedContentInfo.contentEncryptionAlgorithm.algorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'encAlgorithm'},{name:'EncryptedContentInfo.contentEncryptionAlgorithm.parameter',tagClass:i.Class.UNIVERSAL,captureAsn1:'encParameter'}]},{name:'EncryptedContentInfo.encryptedContent',tagClass:i.Class.CONTEXT_SPECIFIC,type:0,capture:'encryptedContent',captureAsn1:'encryptedContentAsn1'}]};n.envelopedDataValidator={name:'EnvelopedData',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'EnvelopedData.Version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'version'},{name:'EnvelopedData.RecipientInfos',tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:'recipientInfos'}].concat(o)},n.encryptedDataValidator={name:'EncryptedData',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedData.Version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'version'}].concat(o)};var s={name:'SignerInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'SignerInfo.version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1},{name:'SignerInfo.issuerAndSerialNumber',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'SignerInfo.issuerAndSerialNumber.issuer',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:'issuer'},{name:'SignerInfo.issuerAndSerialNumber.serialNumber',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'serial'}]},{name:'SignerInfo.digestAlgorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'SignerInfo.digestAlgorithm.algorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'digestAlgorithm'},{name:'SignerInfo.digestAlgorithm.parameter',tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:'digestParameter',optional:!0}]},{name:'SignerInfo.authenticatedAttributes',tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:'authenticatedAttributes'},{name:'SignerInfo.digestEncryptionAlgorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,capture:'signatureAlgorithm'},{name:'SignerInfo.encryptedDigest',tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:'signature'},{name:'SignerInfo.unauthenticatedAttributes',tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:'unauthenticatedAttributes'}]};n.signedDataValidator={name:'SignedData',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'SignedData.Version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'version'},{name:'SignedData.DigestAlgorithms',tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:'digestAlgorithms'},a,{name:'SignedData.Certificates',tagClass:i.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:'certificates'},{name:'SignedData.CertificateRevocationLists',tagClass:i.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:'crls'},{name:'SignedData.SignerInfos',tagClass:i.Class.UNIVERSAL,type:i.Type.SET,capture:'signerInfos',optional:!0,value:[s]}]},n.recipientInfoValidator={name:'RecipientInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'RecipientInfo.version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'version'},{name:'RecipientInfo.issuerAndSerial',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'RecipientInfo.issuerAndSerial.issuer',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:'issuer'},{name:'RecipientInfo.issuerAndSerial.serialNumber',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'serial'}]},{name:'RecipientInfo.keyEncryptionAlgorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'RecipientInfo.keyEncryptionAlgorithm.algorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'encAlgorithm'},{name:'RecipientInfo.keyEncryptionAlgorithm.parameter',tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:'encParameter',optional:!0}]},{name:'RecipientInfo.encryptedKey',tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:'encKey'}]}})),rn=Si(((t,e)=>{var r=Ci();Ii(),r.mgf=r.mgf||{},(e.exports=r.mgf.mgf1=r.mgf1=r.mgf1||{}).create=function(t){var e={generate:function(e,i){for(var n=new r.util.ByteBuffer,a=Math.ceil(i/t.digestLength),o=0;o{var r=Ci();rn(),e.exports=r.mgf=r.mgf||{},r.mgf.mgf1=r.mgf1})),an=Si(((t,e)=>{var r=Ci();Wi(),Ii(),(e.exports=r.pss=r.pss||{}).create=function(t){3===arguments.length&&(t={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var e,i=t.md,n=t.mgf,a=i.digestLength,o=t.salt||null;if('string'==typeof o&&(o=r.util.createBuffer(o)),'saltLength'in t)e=t.saltLength;else{if(null===o)throw new Error('Salt length not specified or specific salt not given.');e=o.length()}if(null!==o&&o.length()!==e)throw new Error('Given salt length does not match length of given salt.');var s=t.prng||r.random,h={encode:function(t,h){var u,l,f=h-1,c=Math.ceil(f/8),d=t.digest().getBytes();if(c>8*c-f&255;return(w=String.fromCharCode(w.charCodeAt(0)&~M)+w.substr(1))+m+String.fromCharCode(188)},verify:function(t,o,s){var h,u=s-1,l=Math.ceil(u/8);if(o=o.substr(-l),l>8*l-u&255;if(c.charCodeAt(0)&p)throw new Error('Bits beyond keysize not zero as expected.');var m=n.generate(d,f),g='';for(h=0;h{var r=function(t,e){'string'==typeof e&&(e={shortName:e});for(var r,i=null,n=0;null===i&&n128)throw new Error('Invalid "nsComment" content.');t.value=l.create(l.Class.UNIVERSAL,l.Type.IA5STRING,!1,t.comment)}else if('subjectKeyIdentifier'===t.name&&e.cert){var p=e.cert.generateSubjectKeyIdentifier();t.subjectKeyIdentifier=p.toHex(),t.value=l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,p.getBytes())}else if('authorityKeyIdentifier'===t.name&&e.cert){t.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);s=t.value.value;if(t.keyIdentifier){var m=!0===t.keyIdentifier?e.cert.generateSubjectKeyIdentifier().getBytes():t.keyIdentifier;s.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!1,m))}if(t.authorityCertIssuer){var g=[l.create(l.Class.CONTEXT_SPECIFIC,4,!0,[i(!0===t.authorityCertIssuer?e.cert.issuer:t.authorityCertIssuer)])];s.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,g))}if(t.serialNumber){var y=u.util.hexToBytes(!0===t.serialNumber?e.cert.serialNumber:t.serialNumber);s.push(l.create(l.Class.CONTEXT_SPECIFIC,2,!1,y))}}else if('cRLDistributionPoints'===t.name){t.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);s=t.value.value;var v,b=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),w=l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[]);for(d=0;d=_&&t2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(c.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(s.validity.notBefore=c[0],s.validity.notAfter=c[1],s.tbsCertificate=i.tbsCertificate,e){s.md=w({signatureOid:s.signatureOid,type:'certificate'});var d=l.toDer(s.tbsCertificate);s.md.update(d.getBytes())}var p=u.md.sha1.create(),g=l.toDer(i.certIssuer);p.update(g.getBytes()),s.issuer.getField=function(t){return r(s.issuer,t)},s.issuer.addField=function(t){n([t]),s.issuer.attributes.push(t)},s.issuer.attributes=f.RDNAttributesAsArray(i.certIssuer),i.certIssuerUniqueId&&(s.issuer.uniqueId=i.certIssuerUniqueId),s.issuer.hash=p.digest().toHex();var y=u.md.sha1.create(),v=l.toDer(i.certSubject);return y.update(v.getBytes()),s.subject.getField=function(t){return r(s.subject,t)},s.subject.addField=function(t){n([t]),s.subject.attributes.push(t)},s.subject.attributes=f.RDNAttributesAsArray(i.certSubject),i.certSubjectUniqueId&&(s.subject.uniqueId=i.certSubjectUniqueId),s.subject.hash=y.digest().toHex(),i.certExtensions?s.extensions=f.certificateExtensionsFromAsn1(i.certExtensions):s.extensions=[],s.publicKey=f.publicKeyFromAsn1(i.subjectPublicKeyInfo),s},f.certificateExtensionsFromAsn1=function(t){for(var e=[],r=0;r1&&(r=a.value.charCodeAt(1),i=a.value.length>2?a.value.charCodeAt(2):0),e.digitalSignature=!(128&~r),e.nonRepudiation=!(64&~r),e.keyEncipherment=!(32&~r),e.dataEncipherment=!(16&~r),e.keyAgreement=!(8&~r),e.keyCertSign=!(4&~r),e.cRLSign=!(2&~r),e.encipherOnly=!(1&~r),e.decipherOnly=!(128&~i)}else if('basicConstraints'===e.name){(a=l.fromDer(e.value)).value.length>0&&a.value[0].type===l.Type.BOOLEAN?e.cA=0!==a.value[0].value.charCodeAt(0):e.cA=!1;var n=null;a.value.length>0&&a.value[0].type===l.Type.INTEGER?n=a.value[0].value:a.value.length>1&&(n=a.value[1].value),null!==n&&(e.pathLenConstraint=l.derToInteger(n))}else if('extKeyUsage'===e.name)for(var a=l.fromDer(e.value),o=0;o1&&(r=a.value.charCodeAt(1)),e.client=!(128&~r),e.server=!(64&~r),e.email=!(32&~r),e.objsign=!(16&~r),e.reserved=!(8&~r),e.sslCA=!(4&~r),e.emailCA=!(2&~r),e.objCA=!(1&~r)}else if('subjectAltName'===e.name||'issuerAltName'===e.name){var h;e.altNames=[];a=l.fromDer(e.value);for(var f=0;f0&&n.value.push(f.certificateExtensionsToAsn1(t.extensions)),n},f.getCertificationRequestInfo=function(t){return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(t.version).getBytes()),i(t.subject),f.publicKeyToAsn1(t.publicKey),s(t)])},f.distinguishedNameToAsn1=function(t){return i(t)},f.certificateToAsn1=function(t){var e=t.tbsCertificate||f.getTBSCertificate(t);return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[e,l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(t.signatureOid).getBytes()),o(t.signatureOid,t.signatureParameters)]),l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])},f.certificateExtensionsToAsn1=function(t){var e=l.create(l.Class.CONTEXT_SPECIFIC,3,!0,[]),r=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);e.value.push(r);for(var i=0;ih.validity.notAfter)&&(o={message:'Certificate is not valid yet or has expired.',error:f.certificateError.certificate_expired,notBefore:h.validity.notBefore,notAfter:h.validity.notAfter,now:n}),null===o){if(null===(l=e[0]||t.getIssuer(h))&&h.isIssuer(h)&&(c=!0,l=h),l){var d=l;u.util.isArray(d)||(d=[d]);for(var p=!1;!p&&d.length>0;){l=d.shift();try{p=l.verify(h)}catch(t){}}p||(o={message:'Certificate signature is invalid.',error:f.certificateError.bad_certificate})}null!==o||l&&!c||t.hasCertificate(h)||(o={message:'Certificate is not trusted.',error:f.certificateError.unknown_ca})}if(null===o&&l&&!h.isIssuer(l)&&(o={message:'Certificate issuer is invalid.',error:f.certificateError.bad_certificate}),null===o)for(var m={keyUsage:!0,basicConstraints:!0},g=0;null===o&&gv.pathLenConstraint&&(o={message:'Certificate basicConstraints pathLenConstraint violated.',error:f.certificateError.bad_certificate})}var w=null===o||o.error,M=r.verify?r.verify(w,s,i):w;if(!0!==M)throw!0===w&&(o={message:'The application rejected the certificate.',error:f.certificateError.bad_certificate}),(M||0===M)&&('object'!=typeof M||u.util.isArray(M)?'string'==typeof M&&(o.error=M):(M.message&&(o.message=M.message),M.error&&(o.error=M.error))),o;o=null,a=!1,++s}while(e.length>0);return!0}})),sn=Si(((t,e)=>{var r=function(t,e,r,i){for(var n=[],a=0;a=0&&n.push(s):n.push(s))}return n},i=function(t){if(t.composed||t.constructed){for(var e=s.util.createBuffer(),r=0;r0&&(n=h.create(h.Class.UNIVERSAL,h.Type.SET,!0,f));var c=[],d=[];null!==e&&(d=s.util.isArray(e)?e:[e]);for(var p=[],m=0;m0){var b=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,p),w=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(u.oids.data).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(b).getBytes())])]);c.push(w)}var M=null;if(null!==t){var _=u.wrapRsaPrivateKey(u.privateKeyToAsn1(t));M=null===r?h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(u.oids.keyBag).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[_]),n]):h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(u.oids.pkcs8ShroudedKeyBag).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[u.encryptPrivateKeyInfo(_,r,i)]),n]);var E=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[M]),S=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(u.oids.data).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(E).getBytes())])]);c.push(S)}var C,A=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,c);if(i.useMac){var I=s.md.sha1.create(),T=new s.util.ByteBuffer(s.random.getBytes(i.saltSize)),B=i.count,k=(t=l.generateKey(r,T,3,B,20),s.hmac.create());k.start(I,t),k.update(h.toDer(A).getBytes());var R=k.getMac();C=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(u.oids.sha1).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.NULL,!1,'')]),h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,R.getBytes())]),h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,T.getBytes()),h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(B).getBytes())])}return h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(3).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(u.oids.data).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(A).getBytes())])]),C])},l.generateKey=s.pbe.generatePkcs12Key})),hn=Si(((t,e)=>{var r=Ci();Ni(),Ri(),tn(),Ui(),Hi(),sn(),an(),Ji(),Ii(),on();var i=r.asn1,n=e.exports=r.pki=r.pki||{};n.pemToDer=function(t){var e=r.pem.decode(t)[0];if(e.procType&&'ENCRYPTED'===e.procType.type)throw new Error('Could not convert PEM to DER; PEM is encrypted.');return r.util.createBuffer(e.body)},n.privateKeyFromPem=function(t){var e=r.pem.decode(t)[0];if('PRIVATE KEY'!==e.type&&'RSA PRIVATE KEY'!==e.type){var a=new Error("Could not convert private key from PEM; PEM header type is not \"PRIVATE KEY\" or \"RSA PRIVATE KEY\".");throw a.headerType=e.type,a}if(e.procType&&'ENCRYPTED'===e.procType.type)throw new Error('Could not convert private key from PEM; PEM is encrypted.');var o=i.fromDer(e.body);return n.privateKeyFromAsn1(o)},n.privateKeyToPem=function(t,e){var a={type:'RSA PRIVATE KEY',body:i.toDer(n.privateKeyToAsn1(t)).getBytes()};return r.pem.encode(a,{maxline:e})},n.privateKeyInfoToPem=function(t,e){var n={type:'PRIVATE KEY',body:i.toDer(t).getBytes()};return r.pem.encode(n,{maxline:e})}})),un=Si(((t,e)=>{var r=Ci();Ni(),xi(),Di(),Ui(),hn(),Wi(),$i(),Ii();var i=function(t,e,i,n){var a=r.util.createBuffer(),o=t.length>>1,s=o+(1&t.length),h=t.substr(0,s),u=t.substr(o,s),l=r.util.createBuffer(),f=r.hmac.create();i=e+i;var c=Math.ceil(n/16),d=Math.ceil(n/20);f.start('MD5',h);var p=r.util.createBuffer();l.putBytes(i);for(var m=0;m0&&(h.queue(t,h.createAlert(t,{level:h.Alert.Level.warning,description:h.Alert.Description.no_renegotiation})),h.flush(t)),t.process()},h.parseHelloMessage=function(t,e,i){var n=null,a=t.entity===h.ConnectionEnd.client;if(i<38)t.error(t,{message:a?'Invalid ServerHello message. Message too short.':'Invalid ClientHello message. Message too short.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});else{var s=e.fragment,u=s.length();if(n={version:{major:s.getByte(),minor:s.getByte()},random:r.util.createBuffer(s.getBytes(32)),session_id:o(s,1),extensions:[]},a?(n.cipher_suite=s.getBytes(2),n.compression_method=s.getByte()):(n.cipher_suites=o(s,2),n.compression_methods=o(s,1)),(u=i-(u-s.length()))>0){for(var l=o(s,2);l.length()>0;)n.extensions.push({type:[l.getByte(),l.getByte()],data:o(l,2)});if(!a)for(var f=0;f0;){if(0!==d.getByte())break;t.session.extensions.server_name.serverNameList.push(o(d,2).getBytes())}}}if(t.session.version&&(n.version.major!==t.session.version.major||n.version.minor!==t.session.version.minor))return t.error(t,{message:'TLS version change is disallowed during renegotiation.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.protocol_version}});if(a)t.session.cipherSuite=h.getCipherSuite(n.cipher_suite);else for(var p=r.util.createBuffer(n.cipher_suites.bytes());p.length()>0&&(t.session.cipherSuite=h.getCipherSuite(p.getBytes(2)),null===t.session.cipherSuite););if(null===t.session.cipherSuite)return t.error(t,{message:'No cipher suites in common.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.handshake_failure},cipherSuite:r.util.bytesToHex(n.cipher_suite)});t.session.compressionMethod=a?n.compression_method:h.CompressionMethod.none}return n},h.createSecurityParameters=function(t,e){var r=t.entity===h.ConnectionEnd.client,i=e.random.bytes(),n=r?t.session.sp.client_random:i,a=r?i:h.createRandom().getBytes();t.session.sp={entity:t.entity,prf_algorithm:h.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:t.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:n,server_random:a}},h.handleServerHello=function(t,e,r){var i=h.parseHelloMessage(t,e,r);if(!t.fail){if(!(i.version.minor<=t.version.minor))return t.error(t,{message:'Incompatible TLS version.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.protocol_version}});t.version.minor=i.version.minor,t.session.version=t.version;var n=i.session_id.bytes();n.length>0&&n===t.session.id?(t.expect=d,t.session.resuming=!0,t.session.sp.server_random=i.random.bytes()):(t.expect=u,t.session.resuming=!1,h.createSecurityParameters(t,i)),t.session.id=n,t.process()}},h.handleClientHello=function(t,e,i){var n=h.parseHelloMessage(t,e,i);if(!t.fail){var a=n.session_id.bytes(),o=null;if(t.sessionCache&&(null===(o=t.sessionCache.getSession(a))?a='':(o.version.major!==n.version.major||o.version.minor>n.version.minor)&&(o=null,a='')),0===a.length&&(a=r.random.getBytes(32)),t.session.id=a,t.session.clientHelloVersion=n.version,t.session.sp={},o)t.version=t.session.version=o.version,t.session.sp=o.sp;else{for(var s,u=1;u0;)n=o(u.certificate_list,3),a=r.asn1.fromDer(n),n=r.pki.certificateFromAsn1(a,!0),f.push(n)}catch(e){return t.error(t,{message:'Could not parse certificate list.',cause:e,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_certificate}})}var c=t.entity===h.ConnectionEnd.client;!c&&!0!==t.verifyClient||0!==f.length?0===f.length?t.expect=c?l:v:(c?t.session.serverCertificate=f[0]:t.session.clientCertificate=f[0],h.verifyCertificateChain(t,f)&&(t.expect=c?l:v)):t.error(t,{message:c?'No server certificate provided.':'No client certificate provided.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}}),t.process()},h.handleServerKeyExchange=function(t,e,r){if(r>0)return t.error(t,{message:'Invalid key parameters. Only RSA is supported.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unsupported_certificate}});t.expect=f,t.process()},h.handleClientKeyExchange=function(t,e,i){if(i<48)return t.error(t,{message:'Invalid key parameters. Only RSA is supported.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unsupported_certificate}});var n=e.fragment,a={enc_pre_master_secret:o(n,2).getBytes()},s=null;if(t.getPrivateKey)try{s=t.getPrivateKey(t,t.session.serverCertificate),s=r.pki.privateKeyFromPem(s)}catch(e){t.error(t,{message:'Could not get private key.',cause:e,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}})}if(null===s)return t.error(t,{message:'No private key set.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}});try{var u=t.session.sp;u.pre_master_secret=s.decrypt(a.enc_pre_master_secret);var l=t.session.clientHelloVersion;if(l.major!==u.pre_master_secret.charCodeAt(0)||l.minor!==u.pre_master_secret.charCodeAt(1))throw new Error('TLS version rollback attack detected.')}catch(t){u.pre_master_secret=r.random.getBytes(48)}t.expect=w,null!==t.session.clientCertificate&&(t.expect=b),t.process()},h.handleCertificateRequest=function(t,e,r){if(r<3)return t.error(t,{message:'Invalid CertificateRequest. Message too short.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});var i=e.fragment,n={certificate_types:o(i,1),certificate_authorities:o(i,2)};t.session.certificateRequest=n,t.expect=c,t.process()},h.handleCertificateVerify=function(t,e,i){if(i<2)return t.error(t,{message:'Invalid CertificateVerify. Message too short.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});var n=e.fragment;n.read-=4;var a=n.bytes();n.read+=4;var s={signature:o(n,2).getBytes()},u=r.util.createBuffer();u.putBuffer(t.session.md5.digest()),u.putBuffer(t.session.sha1.digest()),u=u.getBytes();try{if(!t.session.clientCertificate.publicKey.verify(u,s.signature,'NONE'))throw new Error('CertificateVerify signature does not match.');t.session.md5.update(a),t.session.sha1.update(a)}catch(e){return t.error(t,{message:'Bad signature in CertificateVerify.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.handshake_failure}})}t.expect=w,t.process()},h.handleServerHelloDone=function(t,e,i){if(i>0)return t.error(t,{message:'Invalid ServerHelloDone message. Invalid length.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.record_overflow}});if(null===t.serverCertificate){var n={message:'No server certificate provided. Not enough security.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.insufficient_security}},a=t.verify(t,n.alert.description,0,[]);if(!0!==a)return(a||0===a)&&('object'!=typeof a||r.util.isArray(a)?'number'==typeof a&&(n.alert.description=a):(a.message&&(n.message=a.message),a.alert&&(n.alert.description=a.alert))),t.error(t,n)}null!==t.session.certificateRequest&&(e=h.createRecord(t,{type:h.ContentType.handshake,data:h.createCertificate(t)}),h.queue(t,e)),e=h.createRecord(t,{type:h.ContentType.handshake,data:h.createClientKeyExchange(t)}),h.queue(t,e),t.expect=g;var o=function(t,e){null!==t.session.certificateRequest&&null!==t.session.clientCertificate&&h.queue(t,h.createRecord(t,{type:h.ContentType.handshake,data:h.createCertificateVerify(t,e)})),h.queue(t,h.createRecord(t,{type:h.ContentType.change_cipher_spec,data:h.createChangeCipherSpec()})),t.state.pending=h.createConnectionState(t),t.state.current.write=t.state.pending.write,h.queue(t,h.createRecord(t,{type:h.ContentType.handshake,data:h.createFinished(t)})),t.expect=d,h.flush(t),t.process()};if(null===t.session.certificateRequest||null===t.session.clientCertificate)return o(t,null);h.getClientSignature(t,o)},h.handleChangeCipherSpec=function(t,e){if(1!==e.fragment.getByte())return t.error(t,{message:'Invalid ChangeCipherSpec message received.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});var r=t.entity===h.ConnectionEnd.client;(t.session.resuming&&r||!t.session.resuming&&!r)&&(t.state.pending=h.createConnectionState(t)),t.state.current.read=t.state.pending.read,(!t.session.resuming&&r||t.session.resuming&&!r)&&(t.state.pending=null),t.expect=r?p:M,t.process()},h.handleFinished=function(t,e,n){var a=e.fragment;a.read-=4;var o=a.bytes();a.read+=4;var s=e.fragment.getBytes();(a=r.util.createBuffer()).putBuffer(t.session.md5.digest()),a.putBuffer(t.session.sha1.digest());var u=t.entity===h.ConnectionEnd.client,l=u?'server finished':'client finished',f=t.session.sp;if((a=i(f.master_secret,l,a.getBytes(),12)).getBytes()!==s)return t.error(t,{message:'Invalid verify_data in Finished message.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.decrypt_error}});t.session.md5.update(o),t.session.sha1.update(o),(t.session.resuming&&u||!t.session.resuming&&!u)&&(h.queue(t,h.createRecord(t,{type:h.ContentType.change_cipher_spec,data:h.createChangeCipherSpec()})),t.state.current.write=t.state.pending.write,t.state.pending=null,h.queue(t,h.createRecord(t,{type:h.ContentType.handshake,data:h.createFinished(t)}))),t.expect=u?m:_,t.handshaking=!1,++t.handshakes,t.peerCertificate=u?t.session.serverCertificate:t.session.clientCertificate,h.flush(t),t.isConnected=!0,t.connected(t),t.process()},h.handleAlert=function(t,e){var r,i=e.fragment,n={level:i.getByte(),description:i.getByte()};switch(n.description){case h.Alert.Description.close_notify:r='Connection closed.';break;case h.Alert.Description.unexpected_message:r='Unexpected message.';break;case h.Alert.Description.bad_record_mac:r='Bad record MAC.';break;case h.Alert.Description.decryption_failed:r='Decryption failed.';break;case h.Alert.Description.record_overflow:r='Record overflow.';break;case h.Alert.Description.decompression_failure:r='Decompression failed.';break;case h.Alert.Description.handshake_failure:r='Handshake failure.';break;case h.Alert.Description.bad_certificate:r='Bad certificate.';break;case h.Alert.Description.unsupported_certificate:r='Unsupported certificate.';break;case h.Alert.Description.certificate_revoked:r='Certificate revoked.';break;case h.Alert.Description.certificate_expired:r='Certificate expired.';break;case h.Alert.Description.certificate_unknown:r='Certificate unknown.';break;case h.Alert.Description.illegal_parameter:r='Illegal parameter.';break;case h.Alert.Description.unknown_ca:r='Unknown certificate authority.';break;case h.Alert.Description.access_denied:r='Access denied.';break;case h.Alert.Description.decode_error:r='Decode error.';break;case h.Alert.Description.decrypt_error:r='Decrypt error.';break;case h.Alert.Description.export_restriction:r='Export restriction.';break;case h.Alert.Description.protocol_version:r='Unsupported protocol version.';break;case h.Alert.Description.insufficient_security:r='Insufficient security.';break;case h.Alert.Description.internal_error:r='Internal error.';break;case h.Alert.Description.user_canceled:r='User canceled.';break;case h.Alert.Description.no_renegotiation:r='Renegotiation not supported.';break;default:r='Unknown error.'}if(n.description===h.Alert.Description.close_notify)return t.close();t.error(t,{message:r,send:!1,origin:t.entity===h.ConnectionEnd.client?'server':'client',alert:n}),t.process()},h.handleHandshake=function(t,e){var i=e.fragment,n=i.getByte(),a=i.getInt24();if(a>i.length())return t.fragmented=e,e.fragment=r.util.createBuffer(),i.read-=4,t.process();t.fragmented=null,i.read-=4;var o=i.bytes(a+4);i.read+=4,n in P[t.entity][t.expect]?(t.entity!==h.ConnectionEnd.server||t.open||t.fail||(t.handshaking=!0,t.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:r.md.md5.create(),sha1:r.md.sha1.create()}),n!==h.HandshakeType.hello_request&&n!==h.HandshakeType.certificate_verify&&n!==h.HandshakeType.finished&&(t.session.md5.update(o),t.session.sha1.update(o)),P[t.entity][t.expect][n](t,e,a)):h.handleUnexpected(t,e)},h.handleApplicationData=function(t,e){t.data.putBuffer(e.fragment),t.dataReady(t),t.process()},h.handleHeartbeat=function(t,e){var i=e.fragment,n=i.getByte(),a=i.getInt16(),o=i.getBytes(a);if(n===h.HeartbeatMessageType.heartbeat_request){if(t.handshaking||a>o.length)return t.process();h.queue(t,h.createRecord(t,{type:h.ContentType.heartbeat,data:h.createHeartbeat(h.HeartbeatMessageType.heartbeat_response,o)})),h.flush(t)}else if(n===h.HeartbeatMessageType.heartbeat_response){if(o!==t.expectedHeartbeatPayload)return t.process();t.heartbeatReceived&&t.heartbeatReceived(t,r.util.createBuffer(o))}t.process()};var u=1,l=2,f=3,c=4,d=5,p=6,m=7,g=8,y=1,v=2,b=3,w=4,M=5,_=6,E=h.handleUnexpected,S=h.handleChangeCipherSpec,C=h.handleAlert,A=h.handleHandshake,I=h.handleApplicationData,T=h.handleHeartbeat,B=[];B[h.ConnectionEnd.client]=[[E,C,A,E,T],[E,C,A,E,T],[E,C,A,E,T],[E,C,A,E,T],[E,C,A,E,T],[S,C,E,E,T],[E,C,A,E,T],[E,C,A,I,T],[E,C,A,E,T]],B[h.ConnectionEnd.server]=[[E,C,A,E,T],[E,C,A,E,T],[E,C,A,E,T],[E,C,A,E,T],[S,C,E,E,T],[E,C,A,E,T],[E,C,A,I,T],[E,C,A,E,T]];var k=h.handleHelloRequest,R=h.handleServerHello,N=h.handleCertificate,L=h.handleServerKeyExchange,x=h.handleCertificateRequest,D=h.handleServerHelloDone,U=h.handleFinished,P=[];P[h.ConnectionEnd.client]=[[E,E,R,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[k,E,E,E,E,E,E,E,E,E,E,N,L,x,D,E,E,E,E,E,E],[k,E,E,E,E,E,E,E,E,E,E,E,L,x,D,E,E,E,E,E,E],[k,E,E,E,E,E,E,E,E,E,E,E,E,x,D,E,E,E,E,E,E],[k,E,E,E,E,E,E,E,E,E,E,E,E,E,D,E,E,E,E,E,E],[k,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[k,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,U],[k,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[k,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]];var O=h.handleClientHello,j=h.handleClientKeyExchange,V=h.handleCertificateVerify;P[h.ConnectionEnd.server]=[[E,O,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,N,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,j,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,V,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,U],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]],h.generateKeys=function(t,e){var r=i,n=e.client_random+e.server_random;t.session.resuming||(e.master_secret=r(e.pre_master_secret,'master secret',n,48).bytes(),e.pre_master_secret=null),n=e.server_random+e.client_random;var a=2*e.mac_key_length+2*e.enc_key_length,o=t.version.major===h.Versions.TLS_1_0.major&&t.version.minor===h.Versions.TLS_1_0.minor;o&&(a+=2*e.fixed_iv_length);var s=r(e.master_secret,'key expansion',n,a),u={client_write_MAC_key:s.getBytes(e.mac_key_length),server_write_MAC_key:s.getBytes(e.mac_key_length),client_write_key:s.getBytes(e.enc_key_length),server_write_key:s.getBytes(e.enc_key_length)};return o&&(u.client_write_IV=s.getBytes(e.fixed_iv_length),u.server_write_IV=s.getBytes(e.fixed_iv_length)),u},h.createConnectionState=function(t){var e=t.entity===h.ConnectionEnd.client,r=function(){var t={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(t){return!0},compressionState:null,compressFunction:function(t){return!0},updateSequenceNumber:function(){4294967295===t.sequenceNumber[1]?(t.sequenceNumber[1]=0,++t.sequenceNumber[0]):++t.sequenceNumber[1]}};return t},i={read:r(),write:r()};if(i.read.update=function(t,e){return i.read.cipherFunction(e,i.read)?i.read.compressFunction(t,e,i.read)||t.error(t,{message:'Could not decompress record.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.decompression_failure}}):t.error(t,{message:'Could not decrypt record or bad MAC.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_record_mac}}),!t.fail},i.write.update=function(t,e){return i.write.compressFunction(t,e,i.write)?i.write.cipherFunction(e,i.write)||t.error(t,{message:'Could not encrypt record.',send:!1,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}}):t.error(t,{message:'Could not compress record.',send:!1,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}}),!t.fail},t.session){var o=t.session.sp;switch(t.session.cipherSuite.initSecurityParameters(o),o.keys=h.generateKeys(t,o),i.read.macKey=e?o.keys.server_write_MAC_key:o.keys.client_write_MAC_key,i.write.macKey=e?o.keys.client_write_MAC_key:o.keys.server_write_MAC_key,t.session.cipherSuite.initConnectionState(i,t,o),o.compression_algorithm){case h.CompressionMethod.none:break;case h.CompressionMethod.deflate:i.read.compressFunction=a,i.write.compressFunction=n;break;default:throw new Error('Unsupported compression algorithm.')}}return i},h.createRandom=function(){var t=new Date,e=+t+6e4*t.getTimezoneOffset(),i=r.util.createBuffer();return i.putInt32(e),i.putBytes(r.random.getBytes(28)),i},h.createRecord=function(t,e){return e.data?{type:e.type,version:{major:t.version.major,minor:t.version.minor},length:e.data.length(),fragment:e.data}:null},h.createAlert=function(t,e){var i=r.util.createBuffer();return i.putByte(e.level),i.putByte(e.description),h.createRecord(t,{type:h.ContentType.alert,data:i})},h.createClientHello=function(t){t.session.clientHelloVersion={major:t.version.major,minor:t.version.minor};for(var e=r.util.createBuffer(),i=0;i0&&(p+=2);var m=t.session.id,g=m.length+1+2+4+28+2+a+1+u+p,y=r.util.createBuffer();return y.putByte(h.HandshakeType.client_hello),y.putInt24(g),y.putByte(t.version.major),y.putByte(t.version.minor),y.putBytes(t.session.sp.client_random),s(y,1,r.util.createBuffer(m)),s(y,2,e),s(y,1,o),p>0&&s(y,2,l),y},h.createServerHello=function(t){var e=t.session.id,i=e.length+1+2+4+28+2+1,n=r.util.createBuffer();return n.putByte(h.HandshakeType.server_hello),n.putInt24(i),n.putByte(t.version.major),n.putByte(t.version.minor),n.putBytes(t.session.sp.server_random),s(n,1,r.util.createBuffer(e)),n.putByte(t.session.cipherSuite.id[0]),n.putByte(t.session.cipherSuite.id[1]),n.putByte(t.session.compressionMethod),n},h.createCertificate=function(t){var e,i=t.entity===h.ConnectionEnd.client,n=null;t.getCertificate&&(e=i?t.session.certificateRequest:t.session.extensions.server_name.serverNameList,n=t.getCertificate(t,e));var a=r.util.createBuffer();if(null!==n)try{r.util.isArray(n)||(n=[n]);for(var o=null,u=0;uh.MaxFragment;)n.push(h.createRecord(t,{type:e.type,data:r.util.createBuffer(a.slice(0,h.MaxFragment))})),a=a.slice(h.MaxFragment);a.length>0&&n.push(h.createRecord(t,{type:e.type,data:r.util.createBuffer(a)}))}for(var o=0;o0&&(n=i.order[0]),null!==n&&n in i.cache)for(var a in e=i.cache[n],delete i.cache[n],i.order)if(i.order[a]===n){i.order.splice(a,1);break}return e},i.setSession=function(t,e){if(i.order.length===i.capacity){var n=i.order.shift();delete i.cache[n]}n=r.util.bytesToHex(t);i.order.push(n),i.cache[n]=e}}return i},h.createConnection=function(t){var e=null;e=t.caStore?r.util.isArray(t.caStore)?r.pki.createCaStore(t.caStore):t.caStore:r.pki.createCaStore();var i=t.cipherSuites||null;if(null===i)for(var n in i=[],h.CipherSuites)i.push(h.CipherSuites[n]);var a=t.server?h.ConnectionEnd.server:h.ConnectionEnd.client,o=t.sessionCache?h.createSessionCache(t.sessionCache):null,s={version:{major:h.Version.major,minor:h.Version.minor},entity:a,sessionId:t.sessionId,caStore:e,sessionCache:o,cipherSuites:i,connected:t.connected,virtualHost:t.virtualHost||null,verifyClient:t.verifyClient||!1,verify:t.verify||function(t,e,r,i){return e},verifyOptions:t.verifyOptions||{},getCertificate:t.getCertificate||null,getPrivateKey:t.getPrivateKey||null,getSignature:t.getSignature||null,input:r.util.createBuffer(),tlsData:r.util.createBuffer(),data:r.util.createBuffer(),tlsDataReady:t.tlsDataReady,dataReady:t.dataReady,heartbeatReceived:t.heartbeatReceived,closed:t.closed,error:function(e,r){r.origin=r.origin||(e.entity===h.ConnectionEnd.client?'client':'server'),r.send&&(h.queue(e,h.createAlert(e,r.alert)),h.flush(e));var i=!1!==r.fatal;i&&(e.fail=!0),t.error(e,r),i&&e.close(!1)},deflate:t.deflate||null,inflate:t.inflate||null,reset:function(t){s.version={major:h.Version.major,minor:h.Version.minor},s.record=null,s.session=null,s.peerCertificate=null,s.state={pending:null,current:null},s.expect=(s.entity,h.ConnectionEnd.client,0),s.fragmented=null,s.records=[],s.open=!1,s.handshakes=0,s.handshaking=!1,s.isConnected=!1,s.fail=!(t||void 0===t),s.input.clear(),s.tlsData.clear(),s.data.clear(),s.state.current=h.createConnectionState(s)}};s.reset();return s.handshake=function(t){if(s.entity!==h.ConnectionEnd.client)s.error(s,{message:'Cannot initiate handshake as a server.',fatal:!1});else if(s.handshaking)s.error(s,{message:'Handshake already in progress.',fatal:!1});else{s.fail&&!s.open&&0===s.handshakes&&(s.fail=!1),s.handshaking=!0;var e=null;(t=t||'').length>0&&(s.sessionCache&&(e=s.sessionCache.getSession(t)),null===e&&(t='')),0===t.length&&s.sessionCache&&null!==(e=s.sessionCache.getSession())&&(t=e.id),s.session={id:t,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:r.md.md5.create(),sha1:r.md.sha1.create()},e&&(s.version=e.version,s.session.sp=e.sp),s.session.sp.client_random=h.createRandom().getBytes(),s.open=!0,h.queue(s,h.createRecord(s,{type:h.ContentType.handshake,data:h.createClientHello(s)})),h.flush(s)}},s.process=function(t){var e,i,n,a,o=0;return t&&s.input.putBytes(t),s.fail||(null!==s.record&&s.record.ready&&s.record.fragment.isEmpty()&&(s.record=null),null===s.record&&(o=function(t){var e=0,i=t.input,n=i.length();if(n<5)e=5-n;else{t.record={type:i.getByte(),version:{major:i.getByte(),minor:i.getByte()},length:i.getInt16(),fragment:r.util.createBuffer(),ready:!1};var a=t.record.version.major===t.version.major;a&&t.session&&t.session.version&&(a=t.record.version.minor===t.version.minor),a||t.error(t,{message:'Incompatible TLS version.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.protocol_version}})}return e}(s)),s.fail||null===s.record||s.record.ready||(o=function(t){var e=0,r=t.input,i=r.length();return i{var r=function(t,e,r){var n=e.entity===h.tls.ConnectionEnd.client;t.read.cipherState={init:!1,cipher:h.cipher.createDecipher('AES-CBC',n?r.keys.server_write_key:r.keys.client_write_key),iv:n?r.keys.server_write_IV:r.keys.client_write_IV},t.write.cipherState={init:!1,cipher:h.cipher.createCipher('AES-CBC',n?r.keys.client_write_key:r.keys.server_write_key),iv:n?r.keys.client_write_IV:r.keys.server_write_IV},t.read.cipherFunction=o,t.write.cipherFunction=i,t.read.macLength=t.write.macLength=r.mac_length,t.read.macFunction=t.write.macFunction=u.hmac_sha1},i=function(t,e){var r,i=!1,a=e.macFunction(e.macKey,e.sequenceNumber,t);t.fragment.putBytes(a),e.updateSequenceNumber(),r=t.version.minor===u.Versions.TLS_1_0.minor?e.cipherState.init?null:e.cipherState.iv:h.random.getBytesSync(16),e.cipherState.init=!0;var o=e.cipherState.cipher;return o.start({iv:r}),t.version.minor>=u.Versions.TLS_1_1.minor&&o.output.putBytes(r),o.update(t.fragment),o.finish(n)&&(t.fragment=o.output,t.length=t.fragment.length(),i=!0),i},n=function(t,e,r){if(!r){var i=t-e.length()%t;e.fillWithByte(i-1,i)}return!0},a=function(t,e,r){var i=!0;if(r){for(var n=e.length(),a=e.last(),o=n-1-a;o=o?(t.fragment=n.output.getBytes(f-o),l=n.output.getBytes(o)):t.fragment=n.output.getBytes(),t.fragment=h.util.createBuffer(t.fragment),t.length=t.fragment.length();var c=e.macFunction(e.macKey,e.sequenceNumber,t);return e.updateSequenceNumber(),i=s(e.macKey,l,c)&&i},s=function(t,e,r){var i=h.hmac.create();return i.start('SHA1',t),i.update(e),e=i.digest().getBytes(),i.start(null,null),i.update(r),e===(r=i.digest().getBytes())},h=Ci();ki(),un();var u=e.exports=h.tls;u.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:'TLS_RSA_WITH_AES_128_CBC_SHA',initSecurityParameters:function(t){t.bulk_cipher_algorithm=u.BulkCipherAlgorithm.aes,t.cipher_type=u.CipherType.block,t.enc_key_length=16,t.block_length=16,t.fixed_iv_length=16,t.record_iv_length=16,t.mac_algorithm=u.MACAlgorithm.hmac_sha1,t.mac_length=20,t.mac_key_length=20},initConnectionState:r},u.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:'TLS_RSA_WITH_AES_256_CBC_SHA',initSecurityParameters:function(t){t.bulk_cipher_algorithm=u.BulkCipherAlgorithm.aes,t.cipher_type=u.CipherType.block,t.enc_key_length=32,t.block_length=16,t.fixed_iv_length=16,t.record_iv_length=16,t.mac_algorithm=u.MACAlgorithm.hmac_sha1,t.mac_length=20,t.mac_key_length=20},initConnectionState:r}})),fn=Si(((t,e)=>{var r=function(t,e,r){for(var i,n,a,o,s,u,l,f,c,d,p,m,g,y,v,b,w,M,_,E,S,C,A,I,T,B,k,R,N,L,x,D,U,P=r.length();P>=128;){for(k=0;k<16;++k)e[k][0]=r.getInt32()>>>0,e[k][1]=r.getInt32()>>>0;for(;k<80;++k)i=(((R=(L=e[k-2])[0])>>>19|(N=L[1])<<13)^(N>>>29|R<<3)^R>>>6)>>>0,n=((R<<13|N>>>19)^(N<<3|R>>>29)^(R<<26|N>>>6))>>>0,a=(((R=(D=e[k-15])[0])>>>1|(N=D[1])<<31)^(R>>>8|N<<24)^R>>>7)>>>0,o=((R<<31|N>>>1)^(R<<24|N>>>8)^(R<<25|N>>>7))>>>0,x=e[k-7],U=e[k-16],N=n+x[1]+o+U[1],e[k][0]=i+x[0]+a+U[0]+(N/4294967296>>>0)>>>0,e[k][1]=N>>>0;for(p=t[0][0],m=t[0][1],g=t[1][0],y=t[1][1],v=t[2][0],b=t[2][1],w=t[3][0],M=t[3][1],_=t[4][0],E=t[4][1],S=t[5][0],C=t[5][1],A=t[6][0],I=t[6][1],T=t[7][0],B=t[7][1],k=0;k<80;++k)l=((_>>>14|E<<18)^(_>>>18|E<<14)^(E>>>9|_<<23))>>>0,f=(A^_&(S^A))>>>0,s=((p>>>28|m<<4)^(m>>>2|p<<30)^(m>>>7|p<<25))>>>0,u=((p<<4|m>>>28)^(m<<30|p>>>2)^(m<<25|p>>>7))>>>0,c=(p&g|v&(p^g))>>>0,d=(m&y|b&(m^y))>>>0,N=B+(((_<<18|E>>>14)^(_<<14|E>>>18)^(E<<23|_>>>9))>>>0)+((I^E&(C^I))>>>0)+h[k][1]+e[k][1],i=T+l+f+h[k][0]+e[k][0]+(N/4294967296>>>0)>>>0,n=N>>>0,a=s+c+((N=u+d)/4294967296>>>0)>>>0,o=N>>>0,T=A,B=I,A=S,I=C,S=_,C=E,_=w+i+((N=M+n)/4294967296>>>0)>>>0,E=N>>>0,w=v,M=b,v=g,b=y,g=p,y=m,p=i+a+((N=n+o)/4294967296>>>0)>>>0,m=N>>>0;N=t[0][1]+m,t[0][0]=t[0][0]+p+(N/4294967296>>>0)>>>0,t[0][1]=N>>>0,N=t[1][1]+y,t[1][0]=t[1][0]+g+(N/4294967296>>>0)>>>0,t[1][1]=N>>>0,N=t[2][1]+b,t[2][0]=t[2][0]+v+(N/4294967296>>>0)>>>0,t[2][1]=N>>>0,N=t[3][1]+M,t[3][0]=t[3][0]+w+(N/4294967296>>>0)>>>0,t[3][1]=N>>>0,N=t[4][1]+E,t[4][0]=t[4][0]+_+(N/4294967296>>>0)>>>0,t[4][1]=N>>>0,N=t[5][1]+C,t[5][0]=t[5][0]+S+(N/4294967296>>>0)>>>0,t[5][1]=N>>>0,N=t[6][1]+I,t[6][0]=t[6][0]+A+(N/4294967296>>>0)>>>0,t[6][1]=N>>>0,N=t[7][1]+B,t[7][0]=t[7][0]+T+(N/4294967296>>>0)>>>0,t[7][1]=N>>>0,P-=128}},i=Ci();Li(),Ii();var n=e.exports=i.sha512=i.sha512||{};i.md.sha512=i.md.algorithms.sha512=n;var a=i.sha384=i.sha512.sha384=i.sha512.sha384||{};a.create=function(){return n.create('SHA-384')},i.md.sha384=i.md.algorithms.sha384=a,i.sha512.sha256=i.sha512.sha256||{create:function(){return n.create('SHA-512/256')}},i.md['sha512/256']=i.md.algorithms['sha512/256']=i.sha512.sha256,i.sha512.sha224=i.sha512.sha224||{create:function(){return n.create('SHA-512/224')}},i.md['sha512/224']=i.md.algorithms['sha512/224']=i.sha512.sha224,n.create=function(t){if(s||(o=String.fromCharCode(128),o+=i.util.fillString(String.fromCharCode(0),128),h=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(u={})['SHA-512']=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],u['SHA-384']=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],u['SHA-512/256']=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],u['SHA-512/224']=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],s=!0),void 0===t&&(t='SHA-512'),!(t in u))throw new Error('Invalid SHA-512 algorithm: '+t);for(var e=u[t],n=null,a=i.util.createBuffer(),l=new Array(80),f=0;f<80;++f)l[f]=new Array(2);var c=64;switch(t){case'SHA-384':c=48;break;case'SHA-512/256':c=32;break;case'SHA-512/224':c=28}var d={algorithm:t.replace('-','').toLowerCase(),blockLength:128,digestLength:c,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){d.messageLength=0,d.fullMessageLength=d.messageLength128=[];for(var t=d.messageLengthSize/4,r=0;r>>0,o>>>0];for(var s=d.fullMessageLength.length-1;s>=0;--s)d.fullMessageLength[s]+=o[1],o[1]=o[0]+(d.fullMessageLength[s]/4294967296>>>0),d.fullMessageLength[s]=d.fullMessageLength[s]>>>0,o[0]=o[1]/4294967296>>>0;return a.putBytes(t),r(n,l,a),(a.read>2048||0===a.length())&&a.compact(),d},d.digest=function(){var e=i.util.createBuffer();e.putBytes(a.bytes());var s,h=d.fullMessageLength[d.fullMessageLength.length-1]+d.messageLengthSize&d.blockLength-1;e.putBytes(o.substr(0,d.blockLength-h));for(var u=8*d.fullMessageLength[0],f=0;f>>0,e.putInt32(u>>>0),u=s>>>0;e.putInt32(u);var c=new Array(n.length);for(f=0;f{var e=Ci();Ni();var r=e.asn1;t.privateKeyValidator={name:'PrivateKeyInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'PrivateKeyInfo.version',tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:'privateKeyVersion'},{name:'PrivateKeyInfo.privateKeyAlgorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'privateKeyOid'}]},{name:'PrivateKeyInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:'privateKey'}]},t.publicKeyValidator={name:'SubjectPublicKeyInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:'subjectPublicKeyInfo',value:[{name:'SubjectPublicKeyInfo.AlgorithmIdentifier',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'publicKeyOid'}]},{tagClass:r.Class.UNIVERSAL,type:r.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:'ed25519PublicKey'}]}})),dn=Si(((t,e)=>{var r=function(t){var e=t.message;if(e instanceof Uint8Array||e instanceof x)return e;var r=t.encoding;if(void 0===e){if(!t.md)throw new TypeError('"options.message" or "options.md" not specified.');e=t.md.digest().getBytes(),r='binary'}if('string'==typeof e&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if('string'==typeof e){if('undefined'!=typeof Buffer)return Buffer.from(e,r);e=new L(e,r)}else if(!(e instanceof L))throw new TypeError("\"options.message\" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with \"options.encoding\" specifying its encoding.");for(var i=new x(e.length()),n=0;n=32;--i){for(r=0,n=i-32,a=i-12;n>8,e[n]-=256*r;e[n]+=r,e[i]=0}for(r=0,n=0;n<32;++n)e[n]+=r-(e[31]>>4)*K[n],r=e[n]>>8,e[n]&=255;for(n=0;n<32;++n)e[n]-=r*K[n];for(i=0;i<32;++i)e[i+1]+=e[i]>>8,t[i]=255&e[i]},a=function(t){for(var e=new Float64Array(64),r=0;r<64;++r)e[r]=t[r],t[r]=0;n(t,e)},o=function(t,e){var r=E(),i=E(),n=E(),a=E(),o=E(),s=E(),h=E(),u=E(),l=E();C(r,t[1],t[0]),C(l,e[1],e[0]),I(r,r,l),S(i,t[0],t[1]),S(l,e[0],e[1]),I(i,i,l),I(n,t[3],e[3]),I(n,n,j),I(a,t[2],e[2]),S(a,a,a),C(o,i,r),C(s,a,n),S(h,a,n),S(u,i,r),I(t[0],o,s),I(t[1],u,h),I(t[2],h,s),I(t[3],o,u)},s=function(t,e,r){for(var i=0;i<4;++i)_(t[i],e[i],r)},h=function(t,e){var r=E(),i=E(),n=E();w(n,e[2]),I(r,e[0],n),I(i,e[1],n),u(t,i),t[31]^=g(r)<<7},u=function(t,e){var r,i,n,a=E(),o=E();for(r=0;r<16;++r)o[r]=e[r];for(M(o),M(o),M(o),i=0;i<2;++i){for(a[0]=o[0]-65517,r=1;r<15;++r)a[r]=o[r]-65535-(a[r-1]>>16&1),a[r-1]&=65535;a[15]=o[15]-32767-(a[14]>>16&1),n=a[15]>>16&1,a[14]&=65535,_(o,a,1-n)}for(r=0;r<16;r++)t[2*r]=255&o[r],t[2*r+1]=o[r]>>8},l=function(t,e){var r=E(),i=E(),n=E(),a=E(),o=E(),s=E(),h=E();return b(t[2],P),f(t[1],e),A(n,t[1]),I(a,n,O),C(n,n,t[2]),S(a,t[2],a),A(o,a),A(s,o),I(h,s,o),I(r,h,n),I(r,r,a),c(r,r),I(r,r,n),I(r,r,a),I(r,r,a),I(t[0],r,a),A(i,t[0]),I(i,i,a),d(i,n)&&I(t[0],t[0],F),A(i,t[0]),I(i,i,a),d(i,n)?-1:(g(t[0])===e[31]>>7&&C(t[0],U,t[0]),I(t[3],t[0],t[1]),0)},f=function(t,e){var r;for(r=0;r<16;++r)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767},c=function(t,e){var r,i=E();for(r=0;r<16;++r)i[r]=e[r];for(r=250;r>=0;--r)A(i,i),1!==r&&I(i,i,e);for(r=0;r<16;++r)t[r]=i[r]},d=function(t,e){var r=new x(32),i=new x(32);return u(r,t),u(i,e),p(r,0,i,0)},p=function(t,e,r,i){return m(t,e,r,i,32)},m=function(t,e,r,i,n){var a,o=0;for(a=0;a>>8)-1},g=function(t){var e=new x(32);return u(e,t),1&e[0]},y=function(t,e,r){var i,n;for(b(t[0],U),b(t[1],P),b(t[2],P),b(t[3],U),n=255;n>=0;--n)i=r[n/8|0]>>(7&n)&1,s(t,e,i),o(e,t),o(t,t),s(t,e,i)},v=function(t,e){var r=[E(),E(),E(),E()];b(r[0],V),b(r[1],q),b(r[2],P),I(r[3],V,q),y(t,r,e)},b=function(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]},w=function(t,e){var r,i=E();for(r=0;r<16;++r)i[r]=e[r];for(r=253;r>=0;--r)A(i,i),2!==r&&4!==r&&I(i,i,e);for(r=0;r<16;++r)t[r]=i[r]},M=function(t){var e,r,i=1;for(e=0;e<16;++e)r=t[e]+i+65535,i=Math.floor(r/65536),t[e]=r-65536*i;t[0]+=i-1+37*(i-1)},_=function(t,e,r){for(var i,n=~(r-1),a=0;a<16;++a)i=n&(t[a]^e[a]),t[a]^=i,e[a]^=i},E=function(t){var e,r=new Float64Array(16);if(t)for(e=0;e=0};var U=E(),P=E([1]),O=E([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),j=E([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),V=E([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),q=E([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),K=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]),F=E([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139])})),pn=Si(((t,e)=>{var r=function(t,e,r,n){t.generate=function(t,a){for(var o=new i.util.ByteBuffer,s=Math.ceil(a/n)+r,h=new i.util.ByteBuffer,u=r;u0&&(o=i.util.fillString(String.fromCharCode(0),h)+o),{encapsulation:e.encrypt(o,'NONE'),key:t.generate(o,a)}},decrypt:function(e,r,i){var n=e.decrypt(r,'NONE');return t.generate(n,i)}};return a},i.kem.kdf1=function(t,e){r(this,t,0,e||t.digestLength)},i.kem.kdf2=function(t,e){r(this,t,1,e||t.digestLength)}})),mn=Si(((t,e)=>{var r=Ci();Ii(),e.exports=r.log=r.log||{},r.log.levels=['none','error','warning','info','debug','verbose','max'];var i,n,a,o,s,h,u,l={},f=[],c=null;for(r.log.LEVEL_LOCKED=2,r.log.NO_LEVEL_CHECK=4,r.log.INTERPOLATE=8,a=0;a{e.exports=Li(),Di(),$i(),zi(),fn()})),yn=Si(((t,e)=>{var r=function(t){var e={},r=[];if(!u.validate(t,l.asn1.recipientInfoValidator,e,r)){var i=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw i.errors=r,i}return{version:e.version.charCodeAt(0),issuer:h.pki.RDNAttributesAsArray(e.issuer),serialNumber:h.util.createBuffer(e.serial).toHex(),encryptedContent:{algorithm:u.derToOid(e.encAlgorithm),parameter:e.encParameter?e.encParameter.value:void 0,content:e.encKey}}},i=function(t){for(var e,r=[],i=0;i0){for(var r=u.create(u.Class.CONTEXT_SPECIFIC,1,!0,[]),i=0;i=r&&n0&&n.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!0,e)),i.length>0&&n.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,i)),n.value[0].value.push(u.create(u.Class.UNIVERSAL,u.Type.SET,!0,t.signerInfos)),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(t.type).getBytes()),n])},addSigner:function(e){var r=e.issuer,i=e.serialNumber;if(e.certificate){var n=e.certificate;'string'==typeof n&&(n=h.pki.certificateFromPem(n)),r=n.issuer.attributes,i=n.serialNumber}var a=e.key;if(!a)throw new Error('Could not add PKCS#7 signer; no private key specified.');'string'==typeof a&&(a=h.pki.privateKeyFromPem(a));var o=e.digestAlgorithm||h.pki.oids.sha1;switch(o){case h.pki.oids.sha1:case h.pki.oids.sha256:case h.pki.oids.sha384:case h.pki.oids.sha512:case h.pki.oids.md5:break;default:throw new Error('Could not add PKCS#7 signer; unknown message digest algorithm: '+o)}var s=e.authenticatedAttributes||[];if(s.length>0){for(var u=!1,l=!1,f=0;f{var r=function(t,e){var r=e.toString(16);r[0]>='8'&&(r='00'+r);var i=a.util.hexToBytes(r);t.putInt32(i.length),t.putBytes(i)},i=function(t,e){t.putInt32(e.length),t.putString(e)},n=function(){for(var t=a.md.sha1.create(),e=arguments.length,r=0;r{e.exports=Ci(),ki(),ln(),Ni(),Ti(),Pi(),dn(),xi(),pn(),mn(),gn(),rn(),Hi(),Ui(),Qi(),sn(),yn(),hn(),Xi(),Gi(),an(),Wi(),Zi(),vn(),un(),Ii()})),wn=_i(bn(),1),{default:Mn}=()=>({}),{default:_n}=()=>({}),{default:En}=()=>({}),Sn=Object.create,Cn=Object.defineProperty,An=Object.getOwnPropertyDescriptor,In=Object.getOwnPropertyNames,Tn=Object.getPrototypeOf,Bn=Object.prototype.hasOwnProperty,kn=(t,e,r,i)=>{if(e&&'object'==typeof e||'function'==typeof e)for(let n of In(e))!Bn.call(t,n)&&n!==r&&Cn(t,n,{get:()=>e[n],enumerable:!(i=An(e,n))||i.enumerable});return t},Rn=(t,e,r)=>(r=null!=t?Sn(Tn(t)):{},kn(!e&&t&&t.__esModule?r:Cn(r,'default',{value:t,enumerable:!0}),t)),Nn=(qi=(t,e)=>{function r(t){if('string'!=typeof t)throw new TypeError('Path must be a string. Received '+JSON.stringify(t))}function i(t,e){for(var r,i='',n=0,a=-1,o=0,s=0;s<=t.length;++s){if(s2){var h=i.lastIndexOf('/');if(h!==i.length-1){-1===h?(i='',n=0):n=(i=i.slice(0,h)).length-1-i.lastIndexOf('/'),a=s,o=0;continue}}else if(2===i.length||1===i.length){i='',n=0,a=s,o=0;continue}e&&(i.length>0?i+='/..':i='..',n=2)}else i.length>0?i+='/'+t.slice(a+1,s):i=t.slice(a+1,s),n=s-a-1;a=s,o=0}else 46===r&&-1!==o?++o:o=-1}return i}var n={resolve:function(){for(var t,e='',n=!1,a=arguments.length-1;a>=-1&&!n;a--){var o;a>=0?o=arguments[a]:(void 0===t&&(t=process.cwd()),o=t),r(o),0!==o.length&&(e=o+'/'+e,n=47===o.charCodeAt(0))}return e=i(e,!n),n?e.length>0?'/'+e:'/':e.length>0?e:'.'},normalize:function(t){if(r(t),0===t.length)return'.';var e=47===t.charCodeAt(0),n=47===t.charCodeAt(t.length-1);return 0===(t=i(t,!e)).length&&!e&&(t='.'),t.length>0&&n&&(t+='/'),e?'/'+t:t},isAbsolute:function(t){return r(t),t.length>0&&47===t.charCodeAt(0)},join:function(){if(0===arguments.length)return'.';for(var t,e=0;e0&&(void 0===t?t=i:t+='/'+i)}return void 0===t?'.':n.normalize(t)},relative:function(t,e){if(r(t),r(e),t===e||(t=n.resolve(t))===(e=n.resolve(e)))return'';for(var i=1;iu){if(47===e.charCodeAt(s+f))return e.slice(s+f+1);if(0===f)return e.slice(s+f)}else o>u&&(47===t.charCodeAt(i+f)?l=f:0===f&&(l=0));break}var c=t.charCodeAt(i+f);if(c!==e.charCodeAt(s+f))break;47===c&&(l=f)}var d='';for(f=i+l+1;f<=a;++f)(f===a||47===t.charCodeAt(f))&&(0===d.length?d+='..':d+='/..');return d.length>0?d+e.slice(s+l):(s+=l,47===e.charCodeAt(s)&&++s,e.slice(s))},_makeLong:function(t){return t},dirname:function(t){if(r(t),0===t.length)return'.';for(var e=t.charCodeAt(0),i=47===e,n=-1,a=!0,o=t.length-1;o>=1;--o)if(47===(e=t.charCodeAt(o))){if(!a){n=o;break}}else a=!1;return-1===n?i?'/':'.':i&&1===n?'//':t.slice(0,n)},basename:function(t,e){if(void 0!==e&&'string'!=typeof e)throw new TypeError('"ext" argument must be a string');r(t);var i,n=0,a=-1,o=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return'';var s=e.length-1,h=-1;for(i=t.length-1;i>=0;--i){var u=t.charCodeAt(i);if(47===u){if(!o){n=i+1;break}}else-1===h&&(o=!1,h=i+1),s>=0&&(u===e.charCodeAt(s)?-1==--s&&(a=i):(s=-1,a=h))}return n===a?a=h:-1===a&&(a=t.length),t.slice(n,a)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!o){n=i+1;break}}else-1===a&&(o=!1,a=i+1);return-1===a?'':t.slice(n,a)},extname:function(t){r(t);for(var e=-1,i=0,n=-1,a=!0,o=0,s=t.length-1;s>=0;--s){var h=t.charCodeAt(s);if(47!==h)-1===n&&(a=!1,n=s+1),46===h?-1===e?e=s:1!==o&&(o=1):-1!==e&&(o=-1);else if(!a){i=s+1;break}}return-1===e||-1===n||0===o||1===o&&e===n-1&&e===i+1?'':t.slice(e,n)},format:function(t){if(null===t||'object'!=typeof t)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return function(t,e){var r=e.dir||e.root,i=e.base||(e.name||'')+(e.ext||'');return r?r===e.root?r+i:r+t+i:i}('/',t)},parse:function(t){r(t);var e={root:'',dir:'',base:'',ext:'',name:''};if(0===t.length)return e;var i,n=t.charCodeAt(0),a=47===n;a?(e.root='/',i=1):i=0;for(var o=-1,s=0,h=-1,u=!0,l=t.length-1,f=0;l>=i;--l)if(47!==(n=t.charCodeAt(l)))-1===h&&(u=!1,h=l+1),46===n?-1===o?o=l:1!==f&&(f=1):-1!==o&&(f=-1);else if(!u){s=l+1;break}return-1===o||-1===h||0===f||1===f&&o===h-1&&o===s+1?-1!==h&&(e.base=e.name=0===s&&a?t.slice(1,h):t.slice(s,h)):(0===s&&a?(e.name=t.slice(1,o),e.base=t.slice(1,h)):(e.name=t.slice(s,o),e.base=t.slice(s,h)),e.ext=t.slice(o,h)),s>0?e.dir=t.slice(0,s-1):a&&(e.dir='/'),e},sep:'/',delimiter:':',win32:null,posix:null};n.posix=n,e.exports=n},()=>(Ki||qi((Ki={exports:{}}).exports,Ki),Ki.exports)),Ln={};((t,e)=>{for(var r in e)Cn(t,r,{get:e[r],enumerable:!0})})(Ln,{default:()=>xn}),((t,e,r)=>{kn(t,e,'default'),r&&kn(r,e,'default')})(Ln,Rn(Nn()));var xn=Rn(Nn()),Dn=_i(bn(),1);class Un{key;next;prev;constructor(){this.key=0n,this.next=this,this.prev=this}unlink(){this.prev&&this.next&&(this.prev.next=this.next,this.next.prev=this.prev,this.next=null,this.prev=null)}}class Pn{sentinel;cursor=null;constructor(){const t=new Un;t.next=t,t.prev=t,this.sentinel=t}addTail(t){t.prev&&t.unlink(),t.prev=this.sentinel.prev,t.next=this.sentinel,t.prev&&(t.prev.next=t),t.next.prev=t}addHead(t){t.prev&&t.unlink(),t.prev=this.sentinel,t.next=this.sentinel.next,t.prev.next=t,t.next&&(t.next.prev=t)}removeHead(){const t=this.sentinel.next;return t===this.sentinel?null:(t?.unlink(),t)}head(){const t=this.sentinel.next;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.next||null,t)}tail(){const t=this.sentinel.prev;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.prev||null,t)}next(){const t=this.cursor;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.next||null,t)}prev(){const t=this.cursor;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.prev||null,t)}clear(){for(;;){const t=this.sentinel.next;if(t===this.sentinel)return;t?.unlink()}}}class On extends Un{nextHashable;prevHashable;constructor(){super(),this.nextHashable=this,this.prevHashable=this}uncache(){this.prevHashable&&this.nextHashable&&(this.prevHashable.nextHashable=this.nextHashable,this.nextHashable.prevHashable=this.prevHashable,this.nextHashable=null,this.prevHashable=null)}}Dn.default.pki.rsa.PrivateKey;var jn=Dn.default.jsbn.BigInteger;class Vn extends On{static crctable=new Int32Array(256);static bitmask=new Uint32Array(33);static crc32b=3988292384;static{for(let t=0;t<32;t++)this.bitmask[t]=(1<>>=1:e=e>>>1^this.crc32b;this.crctable[t]=e}}static getcrc(t,e,r){let i=4294967295;for(let n=e;n>>8^this.crctable[255&(i^t[n])];return~i}static checkcrc(t,e,r,i=0){return Vn.getcrc(t,e,r)==i}static alloc(t){let e=null;return 0===t&&this.cacheMinCount>0?(e=this.cacheMin.removeHead(),this.cacheMinCount--):1===t&&this.cacheMidCount>0?(e=this.cacheMid.removeHead(),this.cacheMidCount--):2===t&&this.cacheMaxCount>0?(e=this.cacheMax.removeHead(),this.cacheMaxCount--):3===t&&this.cacheBigCount>0?(e=this.cacheBig.removeHead(),this.cacheBigCount--):4===t&&this.cacheHugeCount>0?(e=this.cacheHuge.removeHead(),this.cacheHugeCount--):5===t&&this.cacheUnimaginableCount>0&&(e=this.cacheUnimaginable.removeHead(),this.cacheUnimaginableCount--),null!==e?(e.pos=0,e.bitPos=0,e):new Vn(0===t?new Uint8Array(100):1===t?new Uint8Array(5e3):2===t?new Uint8Array(3e4):3===t?new Uint8Array(1e5):4===t?new Uint8Array(5e5):5===t?new Uint8Array(2e6):new Uint8Array(t))}static load(t,e=!1){const r=new Vn(new Uint8Array(En.readFileSync(t)));return e&&(r.pos=r.data.length),r}static async loadAsync(t,e=!1){const r=new Vn(new Uint8Array(await(await fetch(t)).arrayBuffer()));return e&&(r.pos=r.data.length),r}static cacheMinCount=0;static cacheMidCount=0;static cacheMaxCount=0;static cacheBigCount=0;static cacheHugeCount=0;static cacheUnimaginableCount=0;static cacheMin=new Pn;static cacheMid=new Pn;static cacheMax=new Pn;static cacheBig=new Pn;static cacheHuge=new Pn;static cacheUnimaginable=new Pn;data;#t;pos;bitPos;constructor(t){super(),this.data=t,this.#t=new DataView(this.data.buffer),this.pos=0,this.bitPos=0}get available(){return this.data.length-this.pos}get length(){return this.data.length}release(){this.pos=0,this.bitPos=0,100===this.data.length&&Vn.cacheMinCount<1e3?(Vn.cacheMin.addTail(this),Vn.cacheMinCount++):5e3===this.data.length&&Vn.cacheMidCount<250?(Vn.cacheMid.addTail(this),Vn.cacheMidCount++):3e4===this.data.length&&Vn.cacheMaxCount<50?(Vn.cacheMax.addTail(this),Vn.cacheMaxCount++):1e5===this.data.length&&Vn.cacheBigCount<10?(Vn.cacheBig.addTail(this),Vn.cacheBigCount++):5e5===this.data.length&&Vn.cacheHugeCount<5?(Vn.cacheHuge.addTail(this),Vn.cacheHugeCount++):2e6===this.data.length&&Vn.cacheUnimaginableCount<2&&(Vn.cacheUnimaginable.addTail(this),Vn.cacheUnimaginableCount++)}save(t,e=this.pos,r=0){if('undefined'!=typeof self){const i=new Blob([this.data.subarray(r,r+e)],{type:'application/octet-stream'}),n=URL.createObjectURL(i);self.postMessage({type:'save',value:n,path:t})}else{const i=xn.dirname(t);En.existsSync(i)||En.mkdirSync(i,{recursive:!0}),En.writeFileSync(t,this.data.subarray(r,r+e))}}p1(t){this.#t.setUint8(this.pos++,t)}p2(t){this.#t.setUint16(this.pos,t),this.pos+=2}ip2(t){this.#t.setUint16(this.pos,t,!0),this.pos+=2}p3(t){this.#t.setUint8(this.pos++,t>>16),this.#t.setUint16(this.pos,t),this.pos+=2}p4(t){this.#t.setInt32(this.pos,t),this.pos+=4}ip4(t){this.#t.setInt32(this.pos,t,!0),this.pos+=4}p8(t){this.#t.setBigInt64(this.pos,t),this.pos+=8}pbool(t){this.p1(t?1:0)}pjstr(t,e=10){const r=t.length;for(let e=0;e=64)this.p1(t+64);else{if(!(t<16384&&t>=-16384))throw new Error('Error psmarts out of range: '+t);this.p2(t+49152)}}psmart(t){if(t>=0&&t<128)this.p1(t);else{if(!(t>=0&&t<32768))throw new Error('Error psmart out of range: '+t);this.p2(t+32768)}}g1(){return this.#t.getUint8(this.pos++)}g1b(){return this.#t.getInt8(this.pos++)}g2(){return this.pos+=2,this.#t.getUint16(this.pos-2)}g2s(){return this.pos+=2,this.#t.getInt16(this.pos-2)}ig2(){return this.pos+=2,this.#t.getUint16(this.pos-2,!0)}g3(){const t=this.#t.getUint8(this.pos++)<<16|this.#t.getUint16(this.pos);return this.pos+=2,t}g4(){return this.pos+=4,this.#t.getInt32(this.pos-4)}ig4(){return this.pos+=4,this.#t.getInt32(this.pos-4,!0)}g8(){return this.pos+=8,this.#t.getBigInt64(this.pos-8)}gbool(){return 1===this.g1()}gjstr(t=10){const e=this.data.length;let r,i='';for(;(r=this.#t.getUint8(this.pos++))!==t&&this.pos>>3}gBit(t){let e=this.bitPos>>>3,r=8-(7&this.bitPos),i=0;for(this.bitPos+=t;t>r;r=8)i+=(this.#t.getUint8(e++)&Vn.bitmask[r])<>>r-t&Vn.bitmask[t],i}pBit(t,e){const r=this.bitPos;this.bitPos+=t;let i=r>>>3,n=8-(7&r);const a=this.#t;for(;t>n;n=8){const r=(1<>>t-n&r),t-=n}const o=n-t,s=(1<=65&&i<=90?e+=BigInt(i+1-65):i>=97&&i<=122?e+=BigInt(i+1-97):i>=48&&i<=57&&(e+=BigInt(i+27-48))}return e}function Kn(t){return function(t){if(t<0n||t>=6582952005840035281n)return'invalid_name';if(t%37n===0n)return'invalid_name';let e=0;const r=Array(12);for(;0n!==t;){const i=t;t/=37n,r[11-e++]=Fn[Number(i-37n*t)]}return r.slice(12-e).join('')}(qn(t))}var Fn=['_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9'],{default:Hn}=()=>({}),{default:zn}=()=>({}),Gn=function(t){return $n.test(t)},Wn=function(t){return Xn.test(t)},Zn='(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])',Yn=`(?:${Zn}\\.){3}${Zn}`,$n=new RegExp(`^${Yn}$`),Qn='(?:[0-9a-fA-F]{1,4})',Xn=new RegExp(`^(?:(?:${Qn}:){7}(?:${Qn}|:)|(?:${Qn}:){6}(?:${Yn}|:${Qn}|:)|(?:${Qn}:){5}(?::${Yn}|(?::${Qn}){1,2}|:)|(?:${Qn}:){4}(?:(?::${Qn}){0,1}:${Yn}|(?::${Qn}){1,3}|:)|(?:${Qn}:){3}(?:(?::${Qn}){0,2}:${Yn}|(?::${Qn}){1,4}|:)|(?:${Qn}:){2}(?:(?::${Qn}){0,3}:${Yn}|(?::${Qn}){1,5}|:)|(?:${Qn}:){1}(?:(?::${Qn}){0,4}:${Yn}|(?::${Qn}){1,6}|:)|(?::(?:(?::${Qn}){0,5}:${Yn}|(?::${Qn}){1,7}|:)))(?:%[0-9a-zA-Z-.:]{1,})?$`),Jn={isIP:function(t){return Gn(t)?4:Wn(t)?6:0},isIPv4:Gn,isIPv6:Wn};class ta{queue=[];available=0;buffer=null;offset=0;waiting=0;received(t){this.queue.push(t),this.available+=t.length}clear(){this.queue=[],this.available=0,this.buffer=null,this.offset=0}async readByte(t){if(null===t||t.closed)return 0;if(this.available<1)return await new Promise((t=>setTimeout(t,10))),this.readByte(t);null===this.buffer&&(this.buffer=this.queue.shift()??null,this.offset=0);const e=this.buffer?.[this.offset]??0;return this.offset++,this.available--,this.buffer&&this.offset===this.buffer.length&&(this.buffer=null),e}async readBytes(t,e,r,i,n=!0){if(null===t||t.closed)return 0;if(this.availablesetTimeout(t,10))),this.readBytes(t,e,r,i);i=this.available}e.pos=r;for(let t=0;t{this.socket=Jn.createConnection({port:sa.LOGIN_PORT,host:sa.LOGIN_HOST}),this.socket.setNoDelay(!0),this.socket.setTimeout(1e3),this.socket.on('data',(async t=>{this.stream.received(t)})),this.socket.once('close',(()=>{this.disconnect(),t()})),this.socket.once('error',(()=>{this.disconnect(),t()})),this.socket.once('connect',(()=>{t()}))}))}disconnect(){null!==this.socket&&(this.socket.destroy(),this.socket=null,this.stream.clear())}async write(t,e,r=null,i=!0){if(null===t)return;const n=new Vn(new Uint8Array(3+(null!==r?r?.length:0)));n.p1(e),null!==r?(n.p2(r.length),n.pdata(r,0,r.length)):n.p2(0);!t.write(n.data)&&i&&await new Promise((e=>{const r=setInterval((()=>{(null===t||t.closed)&&(clearInterval(r),e())}),100);t.once('drain',(()=>{clearInterval(r),e()}))}))}async load(t,e,r){if(await this.connect(),null===this.socket)return{reply:-1,data:null};const i=new Vn(new Uint8Array(10+e.length+1+4));i.p2(sa.NODE_ID),i.p8(t),i.pjstr(e),i.p4(r),await this.write(this.socket,1,i.data);const n=await this.stream.readByte(this.socket);if(1!==n)return this.disconnect(),{reply:n,data:null};const a=new Vn(new Uint8Array(2));await this.stream.readBytes(this.socket,a,0,2);const o=a.g2(),s=new Vn(new Uint8Array(o));return await this.stream.readBytes(this.socket,s,0,o),this.disconnect(),{reply:n,data:s}}async save(t,e){if(await this.connect(),null===this.socket)return-1;const r=new Vn(new Uint8Array(12+e.length));r.p2(sa.NODE_ID),r.p8(t),r.p2(e.length),r.pdata(e,0,e.length),await this.write(this.socket,2,r.data);const i=await this.stream.readByte(this.socket);return this.disconnect(),i}async reset(){if(await this.connect(),null===this.socket)return-1;const t=new Vn(new Uint8Array(2));t.p2(sa.NODE_ID),await this.write(this.socket,3,t.data),this.disconnect()}async count(t){if(await this.connect(),null===this.socket)return-1;const e=new Vn(new Uint8Array(2));e.p2(t),await this.write(this.socket,4,e.data);const r=new Vn(new Uint8Array(2));await this.stream.readBytes(this.socket,r,0,2);const i=r.g2();return this.disconnect(),i}async heartbeat(t){if(await this.connect(),null===this.socket)return-1;const e=new Vn(new Uint8Array(4+8*t.length));e.p2(sa.NODE_ID),e.p2(t.length);for(const r of t)e.p8(r);await this.write(this.socket,5,e.data),this.disconnect()}}if('undefined'!=typeof self)oa=wn.default.pki.privateKeyFromPem(await(await fetch('data/config/private.pem')).text());else{if(!parentPort)throw new Error('This file must be run as a worker thread.');oa=wn.default.pki.privateKeyFromPem(Mn.readFileSync('data/config/private.pem','ascii'))}'undefined'==typeof self&&parentPort?parentPort.on('message',(async t=>{try{if(!parentPort)throw new Error('This file must be run as a worker thread.');switch(t.type){case'reset':{if(!sa.LOGIN_KEY)return;const t=new ua;await t.reset();break}case'heartbeat':{if(!sa.LOGIN_KEY)return;const e=new ua;await e.heartbeat(t.players);break}case'loginreq':{const{opcode:e,data:r,socket:i}=t,n=new Vn(r);if(225!==n.g1())return void parentPort.postMessage({type:'loginreply',status:ha.SERVER_UPDATED,socket:i});const a=n.g1(),o=new Uint8Array(36);if(n.gdata(o,0,o.length),n.rsadec(oa),10!==n.g1())return void parentPort.postMessage({type:'loginreply',status:ha.LOGIN_REJECTED,socket:i});const s=[];for(let t=0;t<4;t++)s[t]=n.g4();const h=n.g4(),u=n.gjstr(),l=n.gjstr();if(u.length<1||u.length>12)return void parentPort.postMessage({type:'loginreply',status:ha.INVALID_USER_OR_PASS,socket:i});if(sa.LOGIN_KEY){if(l.length<5||l.length>20)return void parentPort.postMessage({type:'loginreply',status:ha.INVALID_USER_OR_PASS,socket:i});const t=new ua,r=await t.load(qn(Kn(u)),l,h);if(1===r.reply&&r.data)parentPort.postMessage({type:'loginreply',status:ha.SUCCESSFUL,socket:i,info:a,seed:s,username:Kn(u),save:r.data.data});else{if((2===r.reply||3===r.reply)&&16===e)return void parentPort.postMessage({type:'loginreply',status:ha.LOGGED_IN,socket:i});if(3===r.reply&&18===e)return void parentPort.postMessage({type:'loginreply',status:ha.LOGGED_IN,socket:i});if(4!==r.reply)return 5===r.reply?void parentPort.postMessage({type:'loginreply',status:ha.INVALID_USER_OR_PASS,socket:i}):-1===r.reply?void parentPort.postMessage({type:'loginreply',status:ha.LOGIN_SERVER_OFFLINE,socket:i}):void parentPort.postMessage({type:'loginreply',status:ha.LOGIN_REJECTED,socket:i});parentPort.postMessage({type:'loginreply',status:ha.SUCCESSFUL,socket:i,info:a,seed:s,username:Kn(u),save:new Uint8Array})}}else{let t=new Uint8Array;const e=Kn(u);Mn.existsSync(`data/players/${e}.sav`)&&(t=await _n.readFile(`data/players/${e}.sav`)),parentPort.postMessage({type:'loginreply',status:ha.SUCCESSFUL,socket:i,info:a,seed:s,username:e,save:t})}break}case'logout':{const{username:e,save:r}=t;if(sa.LOGIN_KEY){const t=new ua;0===await t.save(qn(e),r)&&parentPort.postMessage({type:'logoutreply',username:e})}else parentPort.postMessage({type:'logoutreply',username:e});break}default:console.error('Unknown message type: '+t.type)}}catch(t){console.error(t)}})):self.onmessage=async t=>{try{switch(t.data.type){case'reset':case'heartbeat':break;case'loginreq':{const{opcode:e,data:r,socket:i}=t.data,n=new Vn(r);if(225!==n.g1())return void self.postMessage({type:'loginreply',status:ha.SERVER_UPDATED,socket:i});const a=n.g1(),o=new Uint8Array(36);if(n.gdata(o,0,o.length),n.rsadec(oa),10!==n.g1())return void self.postMessage({type:'loginreply',status:ha.LOGIN_REJECTED,socket:i});const s=[];for(let t=0;t<4;t++)s[t]=n.g4();const h=n.g4(),u=n.gjstr(),l=n.gjstr();if(u.length<1||u.length>12)return void self.postMessage({type:'loginreply',status:ha.INVALID_USER_OR_PASS,socket:i});if(sa.LOGIN_KEY){if(l.length<5||l.length>20)return void self.postMessage({type:'loginreply',status:ha.INVALID_USER_OR_PASS,socket:i});const t=new ua,r=await t.load(qn(Kn(u)),l,h);if(1===r.reply&&r.data)self.postMessage({type:'loginreply',status:ha.SUCCESSFUL,socket:i,info:a,seed:s,username:Kn(u),save:r.data.data});else{if((2===r.reply||3===r.reply)&&16===e)return void self.postMessage({type:'loginreply',status:ha.LOGGED_IN,socket:i});if(3===r.reply&&18===e)return void self.postMessage({type:'loginreply',status:ha.LOGGED_IN,socket:i});if(4!==r.reply)return 5===r.reply?void self.postMessage({type:'loginreply',status:ha.INVALID_USER_OR_PASS,socket:i}):-1===r.reply?void self.postMessage({type:'loginreply',status:ha.LOGIN_SERVER_OFFLINE,socket:i}):void self.postMessage({type:'loginreply',status:ha.LOGIN_REJECTED,socket:i});self.postMessage({type:'loginreply',status:ha.SUCCESSFUL,socket:i,info:a,seed:s,username:Kn(u),save:new Uint8Array})}}else{let t=new Uint8Array;const e=Kn(u),r=new URL(`data/players/${e}.sav`,self.location.origin);(await fetch(r)).ok&&(t=new Uint8Array(await(await fetch(r)).arrayBuffer())),self.postMessage({type:'loginreply',status:ha.SUCCESSFUL,socket:i,info:a,seed:s,username:e,save:t})}break}case'logout':{const{username:e,save:r}=t.data;if(sa.LOGIN_KEY){const t=new ua;0===await t.save(qn(e),r)&&self.postMessage({type:'logoutreply',username:e})}else self.postMessage({type:'logoutreply',username:e});break}default:console.error('Unknown message type: '+t.data.type)}}catch(t){console.error(t)}}; \ No newline at end of file +var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,s=(e=>'undefined'!=typeof require?require:'undefined'!=typeof Proxy?new Proxy(e,{get:(e,t)=>('undefined'!=typeof require?require:e)[t]}):e)((function(e){if('undefined'!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')})),o=(e,t)=>function(){return t||(0,e[a(e)[0]])((t={exports:{}}).exports,t),t.exports},c=(s,o,c)=>(c=null!=s?e(n(s)):{},((e,n,s,o)=>{if(n&&'object'==typeof n||'function'==typeof n)for(let c of a(n))i.call(e,c)||c===s||t(e,c,{get:()=>n[c],enumerable:!(o=r(n,c))||o.enumerable});return e})(!o&&s&&s.__esModule?c:t(c,'default',{value:s,enumerable:!0}),s)),u=o({'node_modules/node-forge/lib/forge.js'(e,t){t.exports={options:{usePureJavaScript:!1}}}}),l=o({'node_modules/node-forge/lib/baseN.js'(e,t){var r={};t.exports=r;var a={};r.encode=function(e,t,r){if('string'!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&'number'!=typeof r)throw new TypeError('"maxline" must be a number.');var a='';if(e instanceof Uint8Array){var n=0,i=t.length,s=t.charAt(0),o=[0];for(n=0;n0;)o.push(u%i),u=u/i|0}for(n=0;0===e[n]&&n=0;--n)a+=t[o[n]]}else a=function(e,t){var r=0,a=t.length,n=t.charAt(0),i=[0];for(r=0;r0;)i.push(o%a),o=o/a|0}var c='';for(r=0;0===e.at(r)&&r=0;--r)c+=t[i[r]];return c}(e,t);if(r){var l=new RegExp('.{1,'+r+'}','g');a=a.match(l).join('\r\n')}return a},r.decode=function(e,t){if('string'!=typeof e)throw new TypeError('"input" must be a string.');if('string'!=typeof t)throw new TypeError('"alphabet" must be a string.');var r=a[t];if(!r){r=a[t]=[];for(var n=0;n>=8;for(;l>0;)o.push(255&l),l>>=8}for(var p=0;e[p]===s&&p15?(r=Date.now(),s(e)):(t.push(e),1===t.length&&i.setAttribute('a',a=!a))}}n.nextTick=n.setImmediate}(),n.isNodejs='undefined'!=typeof process&&process.versions&&process.versions.node,n.globalScope=n.isNodejs?global:'undefined'==typeof self?window:self,n.isArray=Array.isArray||function(e){return'[object Array]'===Object.prototype.toString.call(e)},n.isArrayBuffer=function(e){return'undefined'!=typeof ArrayBuffer&&e instanceof ArrayBuffer},n.isArrayBufferView=function(e){return e&&n.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},n.ByteBuffer=s,n.ByteStringBuffer=s;n.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},n.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},n.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},n.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},n.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},n.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},n.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(n.encodeUtf8(e))},n.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},n.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},n.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},n.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},n.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},n.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},n.ByteStringBuffer.prototype.putInt=function(e,t){i(t);var r='';do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},n.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},n.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},n.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t='':(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},n.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},n.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},n.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},n.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},n.ByteStringBuffer.prototype.copy=function(){var e=n.createBuffer(this.data);return e.read=this.read,e},n.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},n.ByteStringBuffer.prototype.clear=function(){return this.data='',this.read=0,this},n.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},n.ByteStringBuffer.prototype.toHex=function(){for(var e='',t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),a=new Uint8Array(this.length()+t);return a.set(r),this.data=new DataView(a.buffer),this},n.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},n.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},n.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},n.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},n.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},n.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},n.DataBuffer.prototype.putInt=function(e,t){i(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},n.DataBuffer.prototype.putSignedInt=function(e,t){return i(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},n.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},n.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t='':(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},n.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},n.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},n.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},n.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},n.DataBuffer.prototype.copy=function(){return new n.DataBuffer(this)},n.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},n.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},n.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},n.DataBuffer.prototype.toHex=function(){for(var e='',t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},n.xorBytes=function(e,t,r){for(var a='',n='',i='',s=0,o=0;r>0;--r,++s)n=e.charCodeAt(s)^t.charCodeAt(s),o>=10&&(a+=i,i='',o=0),i+=String.fromCharCode(n),++o;return a+=i},n.hexToBytes=function(e){var t='',r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',c=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],p='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';n.encode64=function(e,t){for(var r,a,n,i='',s='',c=0;c>2),i+=o.charAt((3&r)<<4|a>>4),isNaN(a)?i+='==':(i+=o.charAt((15&a)<<2|n>>6),i+=isNaN(n)?'=':o.charAt(63&n)),t&&i.length>t&&(s+=i.substr(0,t)+'\r\n',i=i.substr(t));return s+=i},n.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,'');for(var t,r,a,n,i='',s=0;s>4),64!==a&&(i+=String.fromCharCode((15&r)<<4|a>>2),64!==n&&(i+=String.fromCharCode((3&a)<<6|n)));return i},n.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},n.decodeUtf8=function(e){return decodeURIComponent(escape(e))},n.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:a.encode,decode:a.decode}},n.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},n.binary.raw.decode=function(e,t,r){var a=t;a||(a=new Uint8Array(e.length));for(var n=r=r||0,i=0;i>2),i+=o.charAt((3&r)<<4|a>>4),isNaN(a)?i+='==':(i+=o.charAt((15&a)<<2|n>>6),i+=isNaN(n)?'=':o.charAt(63&n)),t&&i.length>t&&(s+=i.substr(0,t)+'\r\n',i=i.substr(t));return s+=i},n.binary.base64.decode=function(e,t,r){var a,n,i,s,o=t;o||(o=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,'');for(var u=0,l=r=r||0;u>4,64!==i&&(o[l++]=(15&n)<<4|i>>2,64!==s&&(o[l++]=(3&i)<<6|s));return t?l-r:o.subarray(0,l)},n.binary.base58.encode=function(e,t){return n.binary.baseN.encode(e,p,t)},n.binary.base58.decode=function(e,t){return n.binary.baseN.decode(e,p,t)},n.text={utf8:{},utf16:{}},n.text.utf8.encode=function(e,t,r){e=n.encodeUtf8(e);var a=t;a||(a=new Uint8Array(e.length));for(var i=r=r||0,s=0;s0&&i.push(r),s=a.lastIndex;var o=t[0][1];switch(o){case's':case'o':n');break;case'%':i.push('%');break;default:i.push('<%'+o+'?>')}}return i.push(e.substring(s)),i.join('')},n.formatNumber=function(e,t,r,a){var n=e,i=isNaN(t=Math.abs(t))?2:t,s=void 0===r?',':r,o=void 0===a?'.':a,c=n<0?'-':'',u=parseInt(n=Math.abs(+n||0).toFixed(i),10)+'',l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+o:'')+u.substr(l).replace(/(\d{3})(?=\d)/g,'$1'+o)+(i?s+Math.abs(n-u).toFixed(i).slice(2):'')},n.formatSize=function(e){return e=e>=1073741824?n.formatNumber(e/1073741824,2,'.','')+' GiB':e>=1048576?n.formatNumber(e/1048576,2,'.','')+' MiB':e>=1024?n.formatNumber(e/1024,0)+' KiB':n.formatNumber(e,0)+' bytes'},n.bytesFromIP=function(e){return-1!==e.indexOf('.')?n.bytesFromIPv4(e):-1!==e.indexOf(':')?n.bytesFromIPv6(e):null},n.bytesFromIPv4=function(e){if(4!==(e=e.split('.')).length)return null;for(var t=n.createBuffer(),r=0;rr[a].end-r[a].start&&(a=r.length-1)):r.push({start:c,end:c})}t.push(s)}if(r.length>0){var u=r[a];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,''),0===u.start&&t.unshift(''),7===u.end&&t.push(''))}return t.join(':')},n.estimateCores=function(e,t){if('function'==typeof e&&(t=e,e={}),e=e||{},'cores'in n&&!e.update)return t(null,n.cores);if('undefined'!=typeof navigator&&'hardwareConcurrency'in navigator&&navigator.hardwareConcurrency>0)return n.cores=navigator.hardwareConcurrency,t(null,n.cores);if('undefined'==typeof Worker)return n.cores=1,t(null,n.cores);if('undefined'==typeof Blob)return n.cores=2,t(null,n.cores);var r=URL.createObjectURL(new Blob(['(',function(){self.addEventListener('message',(function(e){for(var t=Date.now(),r=t+4;Date.now()o.st&&n.stn.st&&o.st4){var a=e;e=r.util.createBuffer();for(var n=0;n0))return!0;for(var a=0;a0))return!0;for(var a=0;a0)return!1;var r=e.length(),a=e.at(r-1);return!(a>this.blockSize<<2)&&(e.truncate(a),!0)},a.cbc=function(e){e=e||{},this.name='CBC',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},a.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error('Invalid IV parameter.');this._iv=this._prev.slice(0)}else{if(!('iv'in e))throw new Error('Invalid IV parameter.');this._iv=n(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},a.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var a=0;a0))return!0;for(var a=0;a0)return!1;var r=e.length(),a=e.at(r-1);return!(a>this.blockSize<<2)&&(e.truncate(a),!0)},a.cfb=function(e){e=e||{},this.name='CFB',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=r.util.createBuffer(),this._partialBytes=0},a.cfb.prototype.start=function(e){if(!('iv'in e))throw new Error('Invalid IV parameter.');this._iv=n(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},a.cfb.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(n=0;n0)e.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}},a.cfb.prototype.decrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(n=0;n0)e.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}},a.ofb=function(e){e=e||{},this.name='OFB',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=r.util.createBuffer(),this._partialBytes=0},a.ofb.prototype.start=function(e){if(!('iv'in e))throw new Error('Invalid IV parameter.');this._iv=n(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},a.ofb.prototype.encrypt=function(e,t,r){var a=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(n=0;n0)e.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}},a.ofb.prototype.decrypt=a.ofb.prototype.encrypt,a.ctr=function(e){e=e||{},this.name='CTR',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=r.util.createBuffer(),this._partialBytes=0},a.ctr.prototype.start=function(e){if(!('iv'in e))throw new Error('Invalid IV parameter.');this._iv=n(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},a.ctr.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}i(this._inBlock)},a.ctr.prototype.decrypt=a.ctr.prototype.encrypt,a.gcm=function(e){e=e||{},this.name='GCM',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=r.util.createBuffer(),this._partialBytes=0,this._R=3774873600},a.gcm.prototype.start=function(e){if(!('iv'in e))throw new Error('Invalid IV parameter.');var t,a=r.util.createBuffer(e.iv);if(this._cipherLength=0,t='additionalData'in e?r.util.createBuffer(e.additionalData):r.util.createBuffer(),this._tagLength='tagLength'in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=r.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error('Authentication tag does not match tag length.');this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var n=a.length();if(12===n)this._j0=[a.getInt32(),a.getInt32(),a.getInt32(),1];else{for(this._j0=[0,0,0,0];a.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(s(8*n)))}this._inBlock=this._j0.slice(0),i(this._inBlock),this._partialBytes=0,t=r.util.createBuffer(t),this._aDataLength=s(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},a.gcm.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize){for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),i(this._inBlock)},a.gcm.prototype.decrypt=function(e,t,r){var a=e.length();if(a0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),i(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var n=0;n0;--a)t[a]=e[a]>>>1|(1&e[a-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},a.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var a=e[r/8|0]>>>4*(7-r%8)&15,n=this._m[r][a];t[0]^=n[0],t[1]^=n[1],t[2]^=n[2],t[3]^=n[3]}return t},a.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},a.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,a=4*r,n=16*r,i=new Array(n),s=0;s>>1,n=new Array(r);n[a]=e.slice(0);for(var i=a>>>1;i>0;)this.pow(n[2*i],n[i]=[]),i>>=1;for(i=2;i>>=2;for(n=0;n>8^255&p^99,n[y]=p,i[p]=y,f=(h=e[p])<<24^p<<16^p<<8^p^h,d=((r=e[y])^(a=e[r])^(u=e[a]))<<24^(y^u)<<16^(y^a^u)<<8^y^r^u;for(var v=0;v<4;++v)o[v][y]=f,c[v][p]=d,f=f<<24|f>>>8,d=d<<24|d>>>8;0===y?y=g=1:(y=r^e[e[e[r^u]]],g^=e[e[g]])}}function y(e,t){for(var r,a=e.slice(0),i=1,o=a.length,u=4*(o+6+1),l=o;l>>16&255]<<24^n[r>>>8&255]<<16^n[255&r]<<8^n[r>>>24]^s[i]<<24,i++):o>6&&l%o==4&&(r=n[r>>>24]<<24^n[r>>>16&255]<<16^n[r>>>8&255]<<8^n[255&r]),a[l]=a[l-o]^r;if(t){for(var p,h=c[0],f=c[1],d=c[2],y=c[3],g=a.slice(0),v=(l=0,(u=a.length)-4);l>>24]]^f[n[p>>>16&255]]^d[n[p>>>8&255]]^y[n[255&p]];a=g}return a}function g(e,t,r,a){var s,u,l,p,h,f,d,y,g,v,m,C,E=e.length/4-1;a?(s=c[0],u=c[1],l=c[2],p=c[3],h=i):(s=o[0],u=o[1],l=o[2],p=o[3],h=n),f=t[0]^e[0],d=t[a?3:1]^e[1],y=t[2]^e[2],g=t[a?1:3]^e[3];for(var S=3,T=1;T>>24]^u[d>>>16&255]^l[y>>>8&255]^p[255&g]^e[++S],m=s[d>>>24]^u[y>>>16&255]^l[g>>>8&255]^p[255&f]^e[++S],C=s[y>>>24]^u[g>>>16&255]^l[f>>>8&255]^p[255&d]^e[++S],g=s[g>>>24]^u[f>>>16&255]^l[d>>>8&255]^p[255&y]^e[++S],f=v,d=m,y=C;r[0]=h[f>>>24]<<24^h[d>>>16&255]<<16^h[y>>>8&255]<<8^h[255&g]^e[++S],r[a?3:1]=h[d>>>24]<<24^h[y>>>16&255]<<16^h[g>>>8&255]<<8^h[255&f]^e[++S],r[2]=h[y>>>24]<<24^h[g>>>16&255]<<16^h[f>>>8&255]<<8^h[255&d]^e[++S],r[a?1:3]=h[g>>>24]<<24^h[f>>>16&255]<<16^h[d>>>8&255]<<8^h[255&y]^e[++S]}function v(e){var t,a='AES-'+((e=e||{}).mode||'CBC').toUpperCase(),n=(t=e.decrypt?r.cipher.createDecipher(a,e.key):r.cipher.createCipher(a,e.key)).start;return t.start=function(e,a){var i=null;a instanceof r.util.ByteBuffer&&(i=a,a={}),(a=a||{}).output=i,a.iv=e,n.call(t,a)},t}}}),y=o({'node_modules/node-forge/lib/oids.js'(e,t){var r=u();r.pki=r.pki||{};var a=t.exports=r.pki.oids=r.oids=r.oids||{};function n(e,t){a[e]=t,a[t]=e}function i(e,t){a[e]=t}n('1.2.840.113549.1.1.1','rsaEncryption'),n('1.2.840.113549.1.1.4','md5WithRSAEncryption'),n('1.2.840.113549.1.1.5','sha1WithRSAEncryption'),n('1.2.840.113549.1.1.7','RSAES-OAEP'),n('1.2.840.113549.1.1.8','mgf1'),n('1.2.840.113549.1.1.9','pSpecified'),n('1.2.840.113549.1.1.10','RSASSA-PSS'),n('1.2.840.113549.1.1.11','sha256WithRSAEncryption'),n('1.2.840.113549.1.1.12','sha384WithRSAEncryption'),n('1.2.840.113549.1.1.13','sha512WithRSAEncryption'),n('1.3.101.112','EdDSA25519'),n('1.2.840.10040.4.3','dsa-with-sha1'),n('1.3.14.3.2.7','desCBC'),n('1.3.14.3.2.26','sha1'),n('1.3.14.3.2.29','sha1WithRSASignature'),n('2.16.840.1.101.3.4.2.1','sha256'),n('2.16.840.1.101.3.4.2.2','sha384'),n('2.16.840.1.101.3.4.2.3','sha512'),n('2.16.840.1.101.3.4.2.4','sha224'),n('2.16.840.1.101.3.4.2.5','sha512-224'),n('2.16.840.1.101.3.4.2.6','sha512-256'),n('1.2.840.113549.2.2','md2'),n('1.2.840.113549.2.5','md5'),n('1.2.840.113549.1.7.1','data'),n('1.2.840.113549.1.7.2','signedData'),n('1.2.840.113549.1.7.3','envelopedData'),n('1.2.840.113549.1.7.4','signedAndEnvelopedData'),n('1.2.840.113549.1.7.5','digestedData'),n('1.2.840.113549.1.7.6','encryptedData'),n('1.2.840.113549.1.9.1','emailAddress'),n('1.2.840.113549.1.9.2','unstructuredName'),n('1.2.840.113549.1.9.3','contentType'),n('1.2.840.113549.1.9.4','messageDigest'),n('1.2.840.113549.1.9.5','signingTime'),n('1.2.840.113549.1.9.6','counterSignature'),n('1.2.840.113549.1.9.7','challengePassword'),n('1.2.840.113549.1.9.8','unstructuredAddress'),n('1.2.840.113549.1.9.14','extensionRequest'),n('1.2.840.113549.1.9.20','friendlyName'),n('1.2.840.113549.1.9.21','localKeyId'),n('1.2.840.113549.1.9.22.1','x509Certificate'),n('1.2.840.113549.1.12.10.1.1','keyBag'),n('1.2.840.113549.1.12.10.1.2','pkcs8ShroudedKeyBag'),n('1.2.840.113549.1.12.10.1.3','certBag'),n('1.2.840.113549.1.12.10.1.4','crlBag'),n('1.2.840.113549.1.12.10.1.5','secretBag'),n('1.2.840.113549.1.12.10.1.6','safeContentsBag'),n('1.2.840.113549.1.5.13','pkcs5PBES2'),n('1.2.840.113549.1.5.12','pkcs5PBKDF2'),n('1.2.840.113549.1.12.1.1','pbeWithSHAAnd128BitRC4'),n('1.2.840.113549.1.12.1.2','pbeWithSHAAnd40BitRC4'),n('1.2.840.113549.1.12.1.3','pbeWithSHAAnd3-KeyTripleDES-CBC'),n('1.2.840.113549.1.12.1.4','pbeWithSHAAnd2-KeyTripleDES-CBC'),n('1.2.840.113549.1.12.1.5','pbeWithSHAAnd128BitRC2-CBC'),n('1.2.840.113549.1.12.1.6','pbewithSHAAnd40BitRC2-CBC'),n('1.2.840.113549.2.7','hmacWithSHA1'),n('1.2.840.113549.2.8','hmacWithSHA224'),n('1.2.840.113549.2.9','hmacWithSHA256'),n('1.2.840.113549.2.10','hmacWithSHA384'),n('1.2.840.113549.2.11','hmacWithSHA512'),n('1.2.840.113549.3.7','des-EDE3-CBC'),n('2.16.840.1.101.3.4.1.2','aes128-CBC'),n('2.16.840.1.101.3.4.1.22','aes192-CBC'),n('2.16.840.1.101.3.4.1.42','aes256-CBC'),n('2.5.4.3','commonName'),n('2.5.4.4','surname'),n('2.5.4.5','serialNumber'),n('2.5.4.6','countryName'),n('2.5.4.7','localityName'),n('2.5.4.8','stateOrProvinceName'),n('2.5.4.9','streetAddress'),n('2.5.4.10','organizationName'),n('2.5.4.11','organizationalUnitName'),n('2.5.4.12','title'),n('2.5.4.13','description'),n('2.5.4.15','businessCategory'),n('2.5.4.17','postalCode'),n('2.5.4.42','givenName'),n('1.3.6.1.4.1.311.60.2.1.2','jurisdictionOfIncorporationStateOrProvinceName'),n('1.3.6.1.4.1.311.60.2.1.3','jurisdictionOfIncorporationCountryName'),n('2.16.840.1.113730.1.1','nsCertType'),n('2.16.840.1.113730.1.13','nsComment'),i('2.5.29.1','authorityKeyIdentifier'),i('2.5.29.2','keyAttributes'),i('2.5.29.3','certificatePolicies'),i('2.5.29.4','keyUsageRestriction'),i('2.5.29.5','policyMapping'),i('2.5.29.6','subtreesConstraint'),i('2.5.29.7','subjectAltName'),i('2.5.29.8','issuerAltName'),i('2.5.29.9','subjectDirectoryAttributes'),i('2.5.29.10','basicConstraints'),i('2.5.29.11','nameConstraints'),i('2.5.29.12','policyConstraints'),i('2.5.29.13','basicConstraints'),n('2.5.29.14','subjectKeyIdentifier'),n('2.5.29.15','keyUsage'),i('2.5.29.16','privateKeyUsagePeriod'),n('2.5.29.17','subjectAltName'),n('2.5.29.18','issuerAltName'),n('2.5.29.19','basicConstraints'),i('2.5.29.20','cRLNumber'),i('2.5.29.21','cRLReason'),i('2.5.29.22','expirationDate'),i('2.5.29.23','instructionCode'),i('2.5.29.24','invalidityDate'),i('2.5.29.25','cRLDistributionPoints'),i('2.5.29.26','issuingDistributionPoint'),i('2.5.29.27','deltaCRLIndicator'),i('2.5.29.28','issuingDistributionPoint'),i('2.5.29.29','certificateIssuer'),i('2.5.29.30','nameConstraints'),n('2.5.29.31','cRLDistributionPoints'),n('2.5.29.32','certificatePolicies'),i('2.5.29.33','policyMappings'),i('2.5.29.34','policyConstraints'),n('2.5.29.35','authorityKeyIdentifier'),i('2.5.29.36','policyConstraints'),n('2.5.29.37','extKeyUsage'),i('2.5.29.46','freshestCRL'),i('2.5.29.54','inhibitAnyPolicy'),n('1.3.6.1.4.1.11129.2.4.2','timestampList'),n('1.3.6.1.5.5.7.1.1','authorityInfoAccess'),n('1.3.6.1.5.5.7.3.1','serverAuth'),n('1.3.6.1.5.5.7.3.2','clientAuth'),n('1.3.6.1.5.5.7.3.3','codeSigning'),n('1.3.6.1.5.5.7.3.4','emailProtection'),n('1.3.6.1.5.5.7.3.8','timeStamping')}}),g=o({'node_modules/node-forge/lib/asn1.js'(e,t){var r=u();p(),y();var a=t.exports=r.asn1=r.asn1||{};function n(e,t,r){if(r>t){var a=new Error('Too few bytes to parse DER.');throw a.available=e.length(),a.remaining=t,a.requested=r,a}}a.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},a.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},a.create=function(e,t,n,i,s){if(r.util.isArray(i)){for(var o=[],c=0;ct){if(s.strict){var d=new Error('Too few bytes to read ASN.1 value.');throw d.available=e.length(),d.remaining=t,d.requested=f,d}f=t}var y=!(32&~c);if(y)if(p=[],void 0===f)for(;;){if(n(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}o=e.length(),p.push(i(e,t,r+1,s)),t-=o-e.length()}else for(;f>0;)o=e.length(),p.push(i(e,f,r+1,s)),t-=o-e.length(),f-=o-e.length();if(void 0===p&&u===a.Class.UNIVERSAL&&l===a.Type.BITSTRING&&(h=e.bytes(f)),void 0===p&&s.decodeBitStrings&&u===a.Class.UNIVERSAL&&l===a.Type.BITSTRING&&f>1){var g=e.read,v=t,m=0;if(l===a.Type.BITSTRING&&(n(e,t,1),m=e.getByte(),t--),0===m)try{o=e.length();var C=i(e,t,r+1,{strict:!0,decodeBitStrings:!0}),E=o-e.length();t-=E,l==a.Type.BITSTRING&&E++;var S=C.tagClass;E!==f||S!==a.Class.UNIVERSAL&&S!==a.Class.CONTEXT_SPECIFIC||(p=[C])}catch(e){}void 0===p&&(e.read=g,t=v)}if(void 0===p){if(void 0===f){if(s.strict)throw new Error('Non-constructed ASN.1 object of indefinite length.');f=t}if(l===a.Type.BMPSTRING)for(p='';f>0;f-=2)n(e,t,2),p+=String.fromCharCode(e.getInt16()),t-=2;else p=e.getBytes(f),t-=f}var T=void 0===h?null:{bitStringContents:h};return a.create(u,l,y,p,T)}a.fromDer=function(e,t){void 0===t&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),'boolean'==typeof t&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),'strict'in t||(t.strict=!0),'parseAllBytes'in t||(t.parseAllBytes=!0),'decodeBitStrings'in t||(t.decodeBitStrings=!0),'string'==typeof e&&(e=r.util.createBuffer(e));var a=e.length(),n=i(e,e.length(),0,t);if(t.parseAllBytes&&0!==e.length()){var s=new Error('Unparsed DER bytes remain after ASN.1 parsing.');throw s.byteCount=a,s.remaining=e.length(),s}return n},a.toDer=function(e){var t=r.util.createBuffer(),n=e.tagClass|e.type,i=r.util.createBuffer(),s=!1;if('bitStringContents'in e&&(s=!0,e.original&&(s=a.equals(e,e.original))),s)i.putBytes(e.bitStringContents);else if(e.composed){e.constructed?n|=32:i.putByte(0);for(var o=0;o1)||(0!==e.value.charCodeAt(0)||128&e.value.charCodeAt(1))&&(255!==e.value.charCodeAt(0)||128&~e.value.charCodeAt(1))?i.putBytes(e.value):i.putBytes(e.value.substr(1));if(t.putByte(n),i.length()<=127)t.putByte(127&i.length());else{var c=i.length(),u='';do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|u.length);for(o=u.length-1;o>=0;--o)t.putByte(u.charCodeAt(o))}return t.putBuffer(i),t},a.oidToDer=function(e){var t,a,n,i,s=e.split('.'),o=r.util.createBuffer();o.putByte(40*parseInt(s[0],10)+parseInt(s[1],10));for(var c=2;c>>=7,t||(i|=128),a.push(i),t=!1}while(n>0);for(var u=a.length-1;u>=0;--u)o.putByte(a[u])}return o},a.derToOid=function(e){var t;'string'==typeof e&&(e=r.util.createBuffer(e));var a=e.getByte();t=Math.floor(a/40)+'.'+a%40;for(var n=0;e.length()>0;)n<<=7,128&(a=e.getByte())?n+=127&a:(t+='.'+(n+a),n=0);return t},a.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var a=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),i=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var c=e.charAt(10),u=10;'+'!==c&&'-'!==c&&(o=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,a,n),t.setUTCHours(i,s,o,0),u&&('+'===(c=e.charAt(u))||'-'===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,'+'===c?t.setTime(+t-l):t.setTime(+t+l)}return t},a.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),a=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),i=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;'Z'===e.charAt(e.length-1)&&(l=!0);var p=e.length-5,h=e.charAt(p);'+'!==h&&'-'!==h||(u=60*parseInt(e.substr(p+1,2),10)+parseInt(e.substr(p+4,2),10),u*=6e4,'+'===h&&(u*=-1),l=!0);return'.'===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,a,n),t.setUTCHours(i,s,o,c),t.setTime(+t+u)):(t.setFullYear(r,a,n),t.setHours(i,s,o,c)),t},a.dateToUtcTime=function(e){if('string'==typeof e)return e;var t='',r=[];r.push((''+e.getUTCFullYear()).substr(2)),r.push(''+(e.getUTCMonth()+1)),r.push(''+e.getUTCDate()),r.push(''+e.getUTCHours()),r.push(''+e.getUTCMinutes()),r.push(''+e.getUTCSeconds());for(var a=0;a=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var a=new Error('Integer too large; max is 32-bits.');throw a.integer=e,a},a.derToInteger=function(e){'string'==typeof e&&(e=r.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error('Integer too large; max is 32-bits.');return e.getSignedInt(t)},a.validate=function(e,t,n,i){var s=!1;if(e.tagClass!==t.tagClass&&void 0!==t.tagClass||e.type!==t.type&&void 0!==t.type)i&&(e.tagClass!==t.tagClass&&i.push('['+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&i.push('['+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||void 0===t.constructed){if(s=!0,t.value&&r.util.isArray(t.value))for(var o=0,c=0;s&&c0&&(i+='\n');for(var o='',c=0;c1?i+='0x'+r.util.bytesToHex(e.value.slice(1)):i+='(none)',e.value.length>0){var h=e.value.charCodeAt(0);1==h?i+=' (1 unused bit shown)':h>1&&(i+=' ('+h+' unused bits shown)')}}else if(e.type===a.Type.OCTETSTRING)s.test(e.value)||(i+='('+e.value+') '),i+='0x'+r.util.bytesToHex(e.value);else if(e.type===a.Type.UTF8)try{i+=r.util.decodeUtf8(e.value)}catch(t){if('URI malformed'!==t.message)throw t;i+='0x'+r.util.bytesToHex(e.value)+' (malformed UTF8)'}else e.type===a.Type.PRINTABLESTRING||e.type===a.Type.IA5String?i+=e.value:s.test(e.value)?i+='0x'+r.util.bytesToHex(e.value):0===e.value.length?i+='[null]':i+=e.value}return i}}}),v=o({'node_modules/node-forge/lib/md.js'(e,t){var r=u();t.exports=r.md=r.md||{},r.md.algorithms=r.md.algorithms||{}}}),m=o({'node_modules/node-forge/lib/hmac.js'(e,t){var r=u();v(),p(),(t.exports=r.hmac=r.hmac||{}).create=function(){var e=null,t=null,a=null,n=null,i={start:function(i,s){if(null!==i)if('string'==typeof i){if(!((i=i.toLowerCase())in r.md.algorithms))throw new Error('Unknown hash algorithm "'+i+'"');t=r.md.algorithms[i].create()}else t=i;if(null===s)s=e;else{if('string'==typeof s)s=r.util.createBuffer(s);else if(r.util.isArray(s)){var o=s;s=r.util.createBuffer();for(var c=0;ct.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),a=r.util.createBuffer(),n=r.util.createBuffer(),u=s.length();for(c=0;c>>0,s>>>0];for(var o=u.fullMessageLength.length-1;o>=0;--o)u.fullMessageLength[o]+=s[1],s[1]=s[0]+(u.fullMessageLength[o]/4294967296>>>0),u.fullMessageLength[o]=u.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(n),l(e,a,t),(t.read>2048||0===t.length())&&t.compact(),u},u.digest=function(){var i=r.util.createBuffer();i.putBytes(t.bytes());var s=u.fullMessageLength[u.fullMessageLength.length-1]+u.messageLengthSize&u.blockLength-1;i.putBytes(n.substr(0,u.blockLength-s));for(var o,c=0,p=u.fullMessageLength.length-1;p>=0;--p)c=(o=8*u.fullMessageLength[p]+c)/4294967296>>>0,i.putInt32Le(o>>>0);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};l(h,a,i);var f=r.util.createBuffer();return f.putInt32Le(h.h0),f.putInt32Le(h.h1),f.putInt32Le(h.h2),f.putInt32Le(h.h3),f},u};var n=null,i=null,s=null,o=null,c=!1;function l(e,t,r){for(var a,n,c,u,l,p,h,f=r.length();f>=64;){for(n=e.h0,c=e.h1,u=e.h2,l=e.h3,h=0;h<16;++h)t[h]=r.getInt32Le(),a=n+(l^c&(u^l))+o[h]+t[h],n=l,l=u,u=c,c+=a<<(p=s[h])|a>>>32-p;for(;h<32;++h)a=n+(u^l&(c^u))+o[h]+t[i[h]],n=l,l=u,u=c,c+=a<<(p=s[h])|a>>>32-p;for(;h<48;++h)a=n+(c^u^l)+o[h]+t[i[h]],n=l,l=u,u=c,c+=a<<(p=s[h])|a>>>32-p;for(;h<64;++h)a=n+(u^(c|~l))+o[h]+t[i[h]],n=l,l=u,u=c,c+=a<<(p=s[h])|a>>>32-p;e.h0=e.h0+n|0,e.h1=e.h1+c|0,e.h2=e.h2+u|0,e.h3=e.h3+l|0,f-=64}}}}),E=o({'node_modules/node-forge/lib/pem.js'(e,t){var r=u();p();var a=t.exports=r.pem=r.pem||{};function n(e){for(var t=e.name+': ',r=[],a=function(e,t){return' '+t},n=0;n65&&-1!==s){var o=t[s];','===o?(++s,t=t.substr(0,s)+'\r\n '+t.substr(s)):t=t.substr(0,s)+'\r\n'+o+t.substr(s+1),i=n-s-1,s=-1,++n}else' '!==t[n]&&'\t'!==t[n]&&','!==t[n]||(s=n);return t}function i(e){return e.replace(/^\s+/,'')}a.encode=function(e,t){t=t||{};var a,i='-----BEGIN '+e.type+'-----\r\n';if(e.procType&&(i+=n(a={name:'Proc-Type',values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=n(a={name:'Content-Domain',values:[e.contentDomain]})),e.dekInfo&&(a={name:'DEK-Info',values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&a.values.push(e.dekInfo.parameters),i+=n(a)),e.headers)for(var s=0;s8?3:1,v=[],m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],C=0,E=0;E>>4^T))<<4,S^=t=65535&((T^=t)>>>-16^S),S^=(t=858993459&(S>>>2^(T^=t<<-16)))<<2,S^=t=65535&((T^=t)>>>-16^S),S^=(t=1431655765&(S>>>1^(T^=t<<-16)))<<1,S^=t=16711935&((T^=t)>>>8^S),t=(S^=(t=1431655765&(S>>>1^(T^=t<<8)))<<1)<<8|(T^=t)>>>20&240,S=T<<24|T<<8&16711680|T>>>8&65280|T>>>24&240,T=t;for(var I=0;I>>26,T=T<<2|T>>>26):(S=S<<1|S>>>27,T=T<<1|T>>>27),T&=-15;var A=r[(S&=-15)>>>28]|a[S>>>24&15]|n[S>>>20&15]|i[S>>>16&15]|s[S>>>12&15]|o[S>>>8&15]|c[S>>>4&15],b=u[T>>>28]|l[T>>>24&15]|p[T>>>20&15]|h[T>>>16&15]|f[T>>>12&15]|d[T>>>8&15]|y[T>>>4&15];t=65535&(b>>>16^A),v[C++]=A^t,v[C++]=b^t<<16}}return v}(t),this._init=!0}},a('DES-ECB',r.cipher.modes.ecb),a('DES-CBC',r.cipher.modes.cbc),a('DES-CFB',r.cipher.modes.cfb),a('DES-OFB',r.cipher.modes.ofb),a('DES-CTR',r.cipher.modes.ctr),a('3DES-ECB',r.cipher.modes.ecb),a('3DES-CBC',r.cipher.modes.cbc),a('3DES-CFB',r.cipher.modes.cfb),a('3DES-OFB',r.cipher.modes.ofb),a('3DES-CTR',r.cipher.modes.ctr);var n=[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],i=[-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],s=[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],o=[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],c=[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],l=[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],d=[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],y=[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];function g(e,t,r,a){var u,p,h=32===e.length?3:9;u=3===h?a?[30,-2,-2]:[0,32,2]:a?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var f=t[0],g=t[1];f^=(p=252645135&(f>>>4^g))<<4,f^=(p=65535&(f>>>16^(g^=p)))<<16,f^=p=858993459&((g^=p)>>>2^f),f^=p=16711935&((g^=p<<2)>>>8^f),f=(f^=(p=1431655765&(f>>>1^(g^=p<<8)))<<1)<<1|f>>>31,g=(g^=p)<<1|g>>>31;for(var v=0;v>>4|g<<28)^e[E+1];p=f,f=g,g=p^(i[S>>>24&63]|o[S>>>16&63]|l[S>>>8&63]|y[63&S]|n[T>>>24&63]|s[T>>>16&63]|c[T>>>8&63]|d[63&T])}p=f,f=g,g=p}g=g>>>1|g<<31,g^=p=1431655765&((f=f>>>1|f<<31)>>>1^g),g^=(p=16711935&(g>>>8^(f^=p<<1)))<<8,g^=(p=858993459&(g>>>2^(f^=p)))<<2,g^=p=65535&((f^=p)>>>16^g),g^=p=252645135&((f^=p<<16)>>>4^g),f^=p<<4,r[0]=f,r[1]=g}function v(e){var t,a='DES-'+((e=e||{}).mode||'CBC').toUpperCase(),n=(t=e.decrypt?r.cipher.createDecipher(a,e.key):r.cipher.createCipher(a,e.key)).start;return t.start=function(e,a){var i=null;a instanceof r.util.ByteBuffer&&(i=a,a={}),(a=a||{}).output=i,a.iv=e,n.call(t,a)},t}}}),T=o({'node_modules/node-forge/lib/pbkdf2.js'(e,t){var r=u();m(),v(),p();var a,n=r.pkcs5=r.pkcs5||{};r.util.isNodejs&&!r.options.usePureJavaScript&&(a=s('crypto')),t.exports=r.pbkdf2=n.pbkdf2=function(e,t,n,i,s,o){if('function'==typeof s&&(o=s,s=null),r.util.isNodejs&&!r.options.usePureJavaScript&&a.pbkdf2&&(null===s||'object'!=typeof s)&&(a.pbkdf2Sync.length>4||!s||'sha1'===s))return'string'!=typeof s&&(s='sha1'),e=Buffer.from(e,'binary'),t=Buffer.from(t,'binary'),o?4===a.pbkdf2Sync.length?a.pbkdf2(e,t,n,i,(function(e,t){if(e)return o(e);o(null,t.toString('binary'))})):a.pbkdf2(e,t,n,i,s,(function(e,t){if(e)return o(e);o(null,t.toString('binary'))})):4===a.pbkdf2Sync.length?a.pbkdf2Sync(e,t,n,i).toString('binary'):a.pbkdf2Sync(e,t,n,i,s).toString('binary');if(null==s&&(s='sha1'),'string'==typeof s){if(!(s in r.md.algorithms))throw new Error('Unknown hash algorithm: '+s);s=r.md[s].create()}var c=s.digestLength;if(i>4294967295*c){var u=new Error('Derived key is too long.');if(o)return o(u);throw u}var l=Math.ceil(i/c),p=i-(l-1)*c,h=r.hmac.create();h.start(s,e);var f,d,y,g='';if(!o){for(var v=1;v<=l;++v){h.start(null,null),h.update(t),h.update(r.util.int32ToBytes(v)),f=y=h.digest().getBytes();for(var m=2;m<=n;++m)h.start(null,null),h.update(y),d=h.digest().getBytes(),f=r.util.xorBytes(f,d,c),y=d;g+=vl)return o(null,g);h.start(null,null),h.update(t),h.update(r.util.int32ToBytes(v)),f=y=h.digest().getBytes(),m=2,E()}function E(){if(m<=n)return h.start(null,null),h.update(y),d=h.digest().getBytes(),f=r.util.xorBytes(f,d,c),y=d,++m,r.util.setImmediate(E);g+=v>>0,s>>>0];for(var u=c.fullMessageLength.length-1;u>=0;--u)c.fullMessageLength[u]+=s[1],s[1]=s[0]+(c.fullMessageLength[u]/4294967296>>>0),c.fullMessageLength[u]=c.fullMessageLength[u]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(n),o(e,a,t),(t.read>2048||0===t.length())&&t.compact(),c},c.digest=function(){var i=r.util.createBuffer();i.putBytes(t.bytes());var s,u=c.fullMessageLength[c.fullMessageLength.length-1]+c.messageLengthSize&c.blockLength-1;i.putBytes(n.substr(0,c.blockLength-u));for(var l=8*c.fullMessageLength[0],p=0;p>>0,i.putInt32(l>>>0),l=s>>>0;i.putInt32(l);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};o(h,a,i);var f=r.util.createBuffer();return f.putInt32(h.h0),f.putInt32(h.h1),f.putInt32(h.h2),f.putInt32(h.h3),f.putInt32(h.h4),f.putInt32(h.h5),f.putInt32(h.h6),f.putInt32(h.h7),f},c};var n=null,i=!1,s=null;function o(e,t,r){for(var a,n,i,o,c,u,l,p,h,f,d,y,g,v=r.length();v>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)a=((a=t[c-2])>>>17|a<<15)^(a>>>19|a<<13)^a>>>10,n=((n=t[c-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[c]=a+t[c-7]+n+t[c-16]|0;for(u=e.h0,l=e.h1,p=e.h2,h=e.h3,f=e.h4,d=e.h5,y=e.h6,g=e.h7,c=0;c<64;++c)i=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),o=u&l|p&(u^l),a=g+((f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(y^f&(d^y))+s[c]+t[c],g=y,y=d,d=f,f=h+a>>>0,h=p,p=l,l=u,u=a+(n=i+o)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+p|0,e.h3=e.h3+h|0,e.h4=e.h4+f|0,e.h5=e.h5+d|0,e.h6=e.h6+y|0,e.h7=e.h7+g|0,v-=64}}}}),A=o({'node_modules/node-forge/lib/prng.js'(e,t){var r=u();p();var a=null;!r.util.isNodejs||r.options.usePureJavaScript||process.versions['node-webkit']||(a=s('crypto')),(t.exports=r.prng=r.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:''},n=e.md,i=new Array(32),s=0;s<32;++s)i[s]=n.create();function o(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,a=0;a<32;++a)t.reseeds%r==0&&(e.update(t.pools[a].digest().getBytes()),t.pools[a].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var n=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(n),t.generated=0}function u(e){var t=null,a=r.util.globalScope,n=a.crypto||a.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var i=r.util.createBuffer();if(t)for(;i.length()>16)))<<16,h=4294967295&(l=(2147483647&(l+=u>>15))+(l>>31));for(c=0;c<3;++c)p=h>>>(c<<3),p^=Math.floor(256*Math.random()),i.putByte(255&p)}return i.getBytes(e)}return t.pools=i,t.pool=0,t.generate=function(e,a){if(!a)return t.generateSync(e);var n=t.plugin.cipher,i=t.plugin.increment,s=t.plugin.formatKey,o=t.plugin.formatSeed,u=r.util.createBuffer();t.key=null,function l(p){if(p)return a(p);if(u.length()>=e)return a(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return r.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,a){if(r)return e(r);t.collect(a),c(),e()}))}(l)}));var h=n(t.key,t.seed);t.generated+=h.length,u.putBytes(h),t.key=s(n(t.key,i(t.seed))),t.seed=o(n(t.key,t.seed)),r.util.setImmediate(l)}()},t.generateSync=function(e){var a=t.plugin.cipher,n=t.plugin.increment,i=t.plugin.formatKey,s=t.plugin.formatSeed;t.key=null;for(var c=r.util.createBuffer();c.length()1048575&&(t.key=null),null===t.key&&o();var u=a(t.key,t.seed);t.generated+=u.length,c.putBytes(u),t.key=i(a(t.key,n(t.seed))),t.seed=s(a(t.key,t.seed))}return c.getBytes(e)},a?(t.seedFile=function(e,t){a.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return a.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(e){t(e)}},t.seedFileSync=u),t.collect=function(e){for(var r=e.length,a=0;a>n&255);t.collect(a)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener('message',(function e(r){var a=r.data;a.forge&&a.forge.prng&&(self.removeEventListener('message',e),t(a.forge.prng.err,a.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener('message',(function(r){var a=r.data;a.forge&&a.forge.prng&&t.seedFile(a.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}}}),b=o({'node_modules/node-forge/lib/random.js'(e,t){var r=u();d(),I(),A(),p(),r.random&&r.random.getBytes?t.exports=r.random:function(e){var a={},n=new Array(4),i=r.util.createBuffer();function s(){var e=r.prng.create(a);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}a.formatKey=function(e){var t=r.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),r.aes._expandKey(e,!1)},a.formatSeed=function(e){var t=r.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},a.cipher=function(e,t){return r.aes._updateBlock(e,t,n,!1),i.putInt32(n[0]),i.putInt32(n[1]),i.putInt32(n[2]),i.putInt32(n[3]),i.getBytes()},a.increment=function(e){return++e[3],e},a.md=r.md.sha256;var o=s(),c=null,u=r.util.globalScope,l=u.crypto||u.msCrypto;if(l&&l.getRandomValues&&(c=function(e){return l.getRandomValues(e)}),r.options.usePureJavaScript||!r.util.isNodejs&&!c){if('undefined'==typeof window||window.document,o.collectInt(+new Date,32),'undefined'!=typeof navigator){var p='';for(var h in navigator)try{'string'==typeof navigator[h]&&(p+=navigator[h])}catch(e){}o.collect(p),p=null}e&&(e().mousemove((function(e){o.collectInt(e.clientX,16),o.collectInt(e.clientY,16)})),e().keypress((function(e){o.collectInt(e.charCode,8)})))}if(r.random)for(var h in o)r.random[h]=o[h];else r.random=o;r.random.createInstance=s,t.exports=r.random}('undefined'!=typeof jQuery?jQuery:null)}}),B=o({'node_modules/node-forge/lib/rc2.js'(e,t){var r=u();p();var a=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],n=[1,2,3,5],i=function(e,t){return e<>16-t},s=function(e,t){return(65535&e)>>t|e<<16-t&65535};t.exports=r.rc2=r.rc2||{},r.rc2.expandKey=function(e,t){'string'==typeof e&&(e=r.util.createBuffer(e)),t=t||128;var n,i=e,s=e.length(),o=t,c=Math.ceil(o/8),u=255>>(7&o);for(n=s;n<128;n++)i.putByte(a[i.at(n-1)+i.at(n-s)&255]);for(i.setAt(128-c,a[i.at(128-c)&u]),n=127-c;n>=0;n--)i.setAt(n,a[i.at(n+1)^i.at(n+c)]);return i};var o=function(e,t,a){var o,c,u,l,p=!1,h=null,f=null,d=null,y=[];for(e=r.rc2.expandKey(e,t),u=0;u<64;u++)y.push(e.getInt16Le());a?(o=function(e){for(u=0;u<4;u++)e[u]+=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=i(e[u],n[u]),l++},c=function(e){for(u=0;u<4;u++)e[u]+=y[63&e[(u+3)%4]]}):(o=function(e){for(u=3;u>=0;u--)e[u]=s(e[u],n[u]),e[u]-=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),l--},c=function(e){for(u=3;u>=0;u--)e[u]-=y[63&e[(u+3)%4]]});var g=function(e){var t=[];for(u=0;u<4;u++){var r=h.getInt16Le();null!==d&&(a?r^=d.getInt16Le():d.putInt16Le(r)),t.push(65535&r)}l=a?0:63;for(var n=0;n=8;)g([[5,o],[1,c],[6,o],[1,c],[5,o]])},finish:function(e){var t=!0;if(a)if(e)t=e(8,h,!a);else{var r=8===h.length()?8:8-h.length();h.fillWithByte(r,r)}if(t&&(p=!0,v.update()),!a&&(t=0===h.length()))if(e)t=e(8,f,!a);else{var n=f.length(),i=f.at(n-1);i>n?t=!1:f.truncate(i)}return t}}};r.rc2.startEncrypting=function(e,t,a){var n=r.rc2.createEncryptionCipher(e,128);return n.start(t,a),n},r.rc2.createEncryptionCipher=function(e,t){return o(e,t,!0)},r.rc2.startDecrypting=function(e,t,a){var n=r.rc2.createDecryptionCipher(e,128);return n.start(t,a),n},r.rc2.createDecryptionCipher=function(e,t){return o(e,t,!1)}}}),N=o({'node_modules/node-forge/lib/jsbn.js'(e,t){var r,a=u();t.exports=a.jsbn=a.jsbn||{};function n(e,t,r){this.data=[],null!=e&&('number'==typeof e?this.fromNumber(e,t,r):null==t&&'string'!=typeof e?this.fromString(e,256):this.fromString(e,t))}function i(){return new n(null)}function s(e,t,r,a,n,i){for(var s=16383&t,o=t>>14;--i>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=o*c+u*s;n=((c=s*c+((16383&l)<<14)+r.data[a]+n)>>28)+(l>>14)+o*u,r.data[a++]=268435455&c}return n}a.jsbn.BigInteger=n,'undefined'==typeof navigator?(n.prototype.am=s,r=28):'Microsoft Internet Explorer'==navigator.appName?(n.prototype.am=function(e,t,r,a,n,i){for(var s=32767&t,o=t>>15;--i>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=o*c+u*s;n=((c=s*c+((32767&l)<<15)+r.data[a]+(1073741823&n))>>>30)+(l>>>15)+o*u+(n>>>30),r.data[a++]=1073741823&c}return n},r=30):'Netscape'!=navigator.appName?(n.prototype.am=function(e,t,r,a,n,i){for(;--i>=0;){var s=t*this.data[e++]+r.data[a]+n;n=Math.floor(s/67108864),r.data[a++]=67108863&s}return n},r=26):(n.prototype.am=s,r=28),n.prototype.DB=r,n.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function y(e){this.m=e}function g(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function T(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function I(){}function A(e){return e}function b(e){this.r2=i(),this.q3=i(),n.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}y.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},y.prototype.revert=function(e){return e},y.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},g.prototype.convert=function(e){var t=i();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(n.ZERO)>0&&this.m.subTo(t,t),t},g.prototype.revert=function(e){var t=i();return e.copyTo(t),this.reduce(t),t},g.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,a,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},n.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},n.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},n.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var a=e.length,i=!1,s=0;--a>=0;){var o=8==r?255&e[a]:h(e,a);o<0?'-'==e.charAt(a)&&(i=!0):(i=!1,0==s?this.data[this.t++]=o:s+r>this.DB?(this.data[this.t-1]|=(o&(1<>this.DB-s):this.data[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==r&&128&e[0]&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},n.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},n.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t.data[r+s+1]=this.data[r]>>n|o,o=(this.data[r]&i)<=0;--r)t.data[r]=0;t.data[s]=o,t.t=this.t+s+1,t.s=this.s,t.clamp()},n.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var a=e%this.DB,n=this.DB-a,i=(1<>a;for(var s=r+1;s>a;a>0&&(t.data[this.t-r-1]|=(this.s&i)<>=this.DB;if(e.t>=this.DB;a+=this.s}else{for(a+=this.s;r>=this.DB;a-=e.s}t.s=a<0?-1:0,a<-1?t.data[r++]=this.DV+a:a>0&&(t.data[r++]=a),t.t=r,t.clamp()},n.prototype.multiplyTo=function(e,t){var r=this.abs(),a=e.abs(),i=r.t;for(t.t=i+a.t;--i>=0;)t.data[i]=0;for(i=0;i=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},n.prototype.divRemTo=function(e,t,r){var a=e.abs();if(!(a.t<=0)){var s=this.abs();if(s.t0?(a.lShiftTo(l,o),s.lShiftTo(l,r)):(a.copyTo(o),s.copyTo(r));var p=o.t,h=o.data[p-1];if(0!=h){var f=h*(1<1?o.data[p-2]>>this.F2:0),y=this.FV/f,g=(1<=0&&(r.data[r.t++]=1,r.subTo(E,r)),n.ONE.dlShiftTo(p,E),E.subTo(o,o);o.t=0;){var S=r.data[--m]==h?this.DM:Math.floor(r.data[m]*y+(r.data[m-1]+v)*g);if((r.data[m]+=o.am(0,S,r,C,0,p))0&&r.rShiftTo(l,r),c<0&&n.ZERO.subTo(r,r)}}},n.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},n.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},n.prototype.exp=function(e,t){if(e>4294967295||e<1)return n.ONE;var r=i(),a=i(),s=t.convert(this),o=d(e)-1;for(s.copyTo(r);--o>=0;)if(t.sqrTo(r,a),(e&1<0)t.mulTo(a,s,r);else{var c=r;r=a,a=c}return t.revert(r)},n.prototype.toString=function(e){if(this.s<0)return'-'+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,a=(1<0)for(o>o)>0&&(n=!0,i=p(r));s>=0;)o>(o+=this.DB-t)):(r=this.data[s]>>(o-=t)&a,o<=0&&(o+=this.DB,--s)),r>0&&(n=!0),n&&(i+=p(r));return n?i:'0'},n.prototype.negate=function(){var e=i();return n.ZERO.subTo(this,e),e},n.prototype.abs=function(){return this.s<0?this.negate():this},n.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},n.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+d(this.data[this.t-1]^this.s&this.DM)},n.prototype.mod=function(e){var t=i();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(n.ZERO)>0&&e.subTo(t,t),t},n.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new y(t):new g(t),this.exp(e,r)},n.ZERO=f(0),n.ONE=f(1),I.prototype.convert=A,I.prototype.revert=A,I.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},I.prototype.sqrTo=function(e,t){e.squareTo(t)},b.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=i();return e.copyTo(t),this.reduce(t),t},b.prototype.revert=function(e){return e},b.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},b.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},b.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],N=(1<<26)/B[B.length-1];n.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},n.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return'0';var t=this.chunkSize(e),r=Math.pow(e,t),a=f(r),n=i(),s=i(),o='';for(this.divRemTo(a,n,s);n.signum()>0;)o=(r+s.intValue()).toString(e).substr(1)+o,n.divRemTo(a,n,s);return s.intValue().toString(e)+o},n.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),a=Math.pow(t,r),i=!1,s=0,o=0,c=0;c=r&&(this.dMultiply(a),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(o,0)),i&&n.ZERO.subTo(this,this)},n.prototype.fromNumber=function(e,t,r){if('number'==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(n.ONE.shiftLeft(e-1),m,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(n.ONE.shiftLeft(e-1),this);else{var a=new Array,i=7&e;a.length=1+(e>>3),t.nextBytes(a),i>0?a[0]&=(1<>=this.DB;if(e.t>=this.DB;a+=this.s}else{for(a+=this.s;r>=this.DB;a+=e.s}t.s=a<0?-1:0,a>0?t.data[r++]=a:a<-1&&(t.data[r++]=this.DV+a),t.t=r,t.clamp()},n.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},n.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},n.prototype.multiplyLowerTo=function(e,t,r){var a,n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;for(a=r.t-this.t;n=0;)r.data[a]=0;for(a=Math.max(t-this.t,0);a0)if(0==t)r=this.data[0]%e;else for(var a=this.t-1;a>=0;--a)r=(t*r+this.data[a])%e;return r},n.prototype.millerRabin=function(e){var t=this.subtract(n.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var a,i=t.shiftRight(r),s={nextBytes:function(e){for(var t=0;t=0);var c=a.modPow(i,this);if(0!=c.compareTo(n.ONE)&&0!=c.compareTo(t)){for(var u=1;u++>24},n.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},n.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},n.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,a=this.DB-e*this.DB%8,n=0;if(e-- >0)for(a>a)!=(this.s&this.DM)>>a&&(t[n++]=r|this.s<=0;)a<8?(r=(this.data[e]&(1<>(a+=this.DB-8)):(r=this.data[e]>>(a-=8)&255,a<=0&&(a+=this.DB,--e)),128&r&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t},n.prototype.equals=function(e){return 0==this.compareTo(e)},n.prototype.min=function(e){return this.compareTo(e)<0?this:e},n.prototype.max=function(e){return this.compareTo(e)>0?this:e},n.prototype.and=function(e){var t=i();return this.bitwiseTo(e,v,t),t},n.prototype.or=function(e){var t=i();return this.bitwiseTo(e,m,t),t},n.prototype.xor=function(e){var t=i();return this.bitwiseTo(e,C,t),t},n.prototype.andNot=function(e){var t=i();return this.bitwiseTo(e,E,t),t},n.prototype.not=function(){for(var e=i(),t=0;t=this.t?0!=this.s:!!(this.data[t]&1<1){var p=i();for(a.sqrTo(o[1],p);c<=l;)o[c]=i(),a.mulTo(p,o[c-2],o[c]),c+=2}var h,v,m=e.t-1,C=!0,E=i();for(n=d(e.data[m])-1;m>=0;){for(n>=u?h=e.data[m]>>n-u&l:(h=(e.data[m]&(1<0&&(h|=e.data[m-1]>>this.DB+n-u)),c=r;!(1&h);)h>>=1,--c;if((n-=c)<0&&(n+=this.DB,--m),C)o[h].copyTo(s),C=!1;else{for(;c>1;)a.sqrTo(s,E),a.sqrTo(E,s),c-=2;c>0?a.sqrTo(s,E):(v=s,s=E,E=v),a.mulTo(E,o[h],s)}for(;m>=0&&!(e.data[m]&1<=0?(r.subTo(a,r),t&&i.subTo(o,i),s.subTo(c,s)):(a.subTo(r,a),t&&o.subTo(i,o),c.subTo(s,c))}return 0!=a.compareTo(n.ONE)?n.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},n.prototype.pow=function(e){return this.exp(e,new I)},n.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var a=t;t=r,r=a}var n=t.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return t;for(n0&&(t.rShiftTo(i,t),r.rShiftTo(i,r));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r},n.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=B[B.length-1]){for(t=0;t>>0,c>>>0];for(var u=o.fullMessageLength.length-1;u>=0;--u)o.fullMessageLength[u]+=c[1],c[1]=c[0]+(o.fullMessageLength[u]/4294967296>>>0),o.fullMessageLength[u]=o.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(n),s(e,a,t),(t.read>2048||0===t.length())&&t.compact(),o},o.digest=function(){var i=r.util.createBuffer();i.putBytes(t.bytes());var c,u=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;i.putBytes(n.substr(0,o.blockLength-u));for(var l=8*o.fullMessageLength[0],p=0;p>>0,i.putInt32(l>>>0),l=c>>>0;i.putInt32(l);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};s(h,a,i);var f=r.util.createBuffer();return f.putInt32(h.h0),f.putInt32(h.h1),f.putInt32(h.h2),f.putInt32(h.h3),f.putInt32(h.h4),f},o};var n=null,i=!1;function s(e,t,r){for(var a,n,i,s,o,c,u,l=r.length();l>=64;){for(n=e.h0,i=e.h1,s=e.h2,o=e.h3,c=e.h4,u=0;u<16;++u)a=r.getInt32(),t[u]=a,a=(n<<5|n>>>27)+(o^i&(s^o))+c+1518500249+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<20;++u)a=(a=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|a>>>31,t[u]=a,a=(n<<5|n>>>27)+(o^i&(s^o))+c+1518500249+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<32;++u)a=(a=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|a>>>31,t[u]=a,a=(n<<5|n>>>27)+(i^s^o)+c+1859775393+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<40;++u)a=(a=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|a>>>30,t[u]=a,a=(n<<5|n>>>27)+(i^s^o)+c+1859775393+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<60;++u)a=(a=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|a>>>30,t[u]=a,a=(n<<5|n>>>27)+(i&s|o&(i^s))+c+2400959708+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<80;++u)a=(a=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|a>>>30,t[u]=a,a=(n<<5|n>>>27)+(i^s^o)+c+3395469782+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;e.h0=e.h0+n|0,e.h1=e.h1+i|0,e.h2=e.h2+s|0,e.h3=e.h3+o|0,e.h4=e.h4+c|0,l-=64}}}}),_=o({'node_modules/node-forge/lib/pkcs1.js'(e,t){var r=u();p(),b(),w();var a=t.exports=r.pkcs1=r.pkcs1||{};function n(e,t,a){a||(a=r.md.sha1.create());for(var n='',i=Math.ceil(t/a.digestLength),s=0;s>24&255,s>>16&255,s>>8&255,255&s);a.start(),a.update(e+o),n+=a.digest().getBytes()}return n.substring(0,t)}a.encode_rsa_oaep=function(e,t,a){var i,s,o,c;'string'==typeof a?(i=a,s=arguments[3]||void 0,o=arguments[4]||void 0):a&&(i=a.label||void 0,s=a.seed||void 0,o=a.md||void 0,a.mgf1&&a.mgf1.md&&(c=a.mgf1.md)),o?o.start():o=r.md.sha1.create(),c||(c=o);var u=Math.ceil(e.n.bitLength()/8),l=u-2*o.digestLength-2;if(t.length>l)throw(g=new Error('RSAES-OAEP input message length is too long.')).length=t.length,g.maxLength=l,g;i||(i=''),o.update(i,'raw');for(var p=o.digest(),h='',f=l-t.length,d=0;de&&(s=u(e,t));var f=s.toString(16);n.target.postMessage({hex:f,workLoad:l}),s.dAddOffset(p,0)}}}f()}(e,t,n,i);return o(e,t,n,i)}(e,c,i.options,n);throw new Error('Invalid prime generation algorithm: '+i.name)}}function o(e,t,r,a){var n=u(e,t),i=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(n.bitLength());'millerRabinTests'in r&&(i=r.millerRabinTests);var s=10;'maxBlockTime'in r&&(s=r.maxBlockTime),c(n,e,t,0,i,s,a)}function c(e,t,a,i,s,o,l){var p=+new Date;do{if(e.bitLength()>t&&(e=u(t,a)),e.isProbablePrime(s))return l(null,e);e.dAddOffset(n[i++%8],0)}while(o<0||+new Date-p=0||!i.gcd(t.n).equals(r.ONE));for(var s=(e=e.multiply(i.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),o=e.mod(t.q).modPow(t.dQ,t.q);s.compareTo(o)<0;)s=s.add(t.p);var c=s.subtract(o).multiply(t.qInv).mod(t.p).multiply(t.q).add(o);return c=c.multiply(i.modInverse(t.n)).mod(t.n)};function S(e,t,r){var n=a.util.createBuffer(),i=Math.ceil(t.n.bitLength()/8);if(e.length>i-11){var s=new Error('Message is too long for PKCS#1 v1.5 padding.');throw s.length=e.length,s.max=i-11,s}n.putByte(0),n.putByte(r);var o,c=i-3-e.length;if(0===r||1===r){o=0===r?0:255;for(var u=0;u0;){var l=0,p=a.random.getBytes(c);for(u=0;u1;){if(255!==s.getByte()){--s.read;break}++u}else if(2===c)for(u=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++u}if(0!==s.getByte()||u!==i-3-s.length())throw new Error('Encryption block is invalid.');return s.getBytes()}function I(e){var t=e.toString(16);t[0]>='8'&&(t='00'+t);var r=a.util.hexToBytes(t);return!(r.length>1)||(0!==r.charCodeAt(0)||128&r.charCodeAt(1))&&(255!==r.charCodeAt(0)||128&~r.charCodeAt(1))?r:r.substr(1)}function A(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function B(e){return a.util.isNodejs&&'function'==typeof n[e]}function w(e){return void 0!==o.globalScope&&'object'==typeof o.globalScope.crypto&&'object'==typeof o.globalScope.crypto.subtle&&'function'==typeof o.globalScope.crypto.subtle[e]}function k(e){return void 0!==o.globalScope&&'object'==typeof o.globalScope.msCrypto&&'object'==typeof o.globalScope.msCrypto.subtle&&'function'==typeof o.globalScope.msCrypto.subtle[e]}function L(e){for(var t=a.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n0;)l.putByte(0),--p;return l.putBytes(a.util.hexToBytes(u)),l.getBytes()},c.rsa.decrypt=function(e,t,n,i){var s=Math.ceil(t.n.bitLength()/8);if(e.length!==s){var o=new Error('Encrypted message length is invalid.');throw o.length=e.length,o.expected=s,o}var c=new r(a.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error('Encrypted message is invalid.');for(var u=E(c,t,n).toString(16),l=a.util.createBuffer(),p=s-Math.ceil(u.length/2);p>0;)l.putByte(0),--p;return l.putBytes(a.util.hexToBytes(u)),!1!==i?T(l.getBytes(),t,n):l.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,n){'string'==typeof e&&(e=parseInt(e,10)),e=e||2048;var i,s=(n=n||{}).prng||a.random,o={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(i.eInt),i},c.rsa.stepKeyPairGenerationState=function(e,t){'algorithm'in e||(e.algorithm='PRIMEINC');var a=new r(null);a.fromInt(30);for(var n,i=0,s=function(e,t){return e|t},o=+new Date,u=0;null===e.keys&&(t<=0||up?e.pqState=0:e.num.isProbablePrime(A(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(l[i++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(r.ONE).gcd(e.e).compareTo(r.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(r.ONE),e.q1=e.q.subtract(r.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(r.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var f=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}u+=(n=+new Date)-o,o=n}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,s,u){if(1===arguments.length?'object'==typeof e?(s=e,e=void 0):'function'==typeof e&&(u=e,e=void 0):2===arguments.length?'number'==typeof e?'function'==typeof t?(u=t,t=void 0):'number'!=typeof t&&(s=t,t=void 0):(s=e,u=t,e=void 0,t=void 0):3===arguments.length&&('number'==typeof t?'function'==typeof s&&(u=s,s=void 0):(u=s,s=t,t=void 0)),s=s||{},void 0===e&&(e=s.bits||2048),void 0===t&&(t=s.e||65537),!a.options.usePureJavaScript&&!s.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(u){if(B('generateKeyPair'))return n.generateKeyPair('rsa',{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:'spki',format:'pem'},privateKeyEncoding:{type:'pkcs8',format:'pem'}},(function(e,t,r){if(e)return u(e);u(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(w('generateKey')&&w('exportKey'))return o.globalScope.crypto.subtle.generateKey({name:'RSASSA-PKCS1-v1_5',modulusLength:e,publicExponent:L(t),hash:{name:'SHA-256'}},!0,['sign','verify']).then((function(e){return o.globalScope.crypto.subtle.exportKey('pkcs8',e.privateKey)})).then(void 0,(function(e){u(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(i.fromDer(a.util.createBuffer(e)));u(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(k('generateKey')&&k('exportKey')){var l=o.globalScope.msCrypto.subtle.generateKey({name:'RSASSA-PKCS1-v1_5',modulusLength:e,publicExponent:L(t),hash:{name:'SHA-256'}},!0,['sign','verify']);return l.oncomplete=function(e){var t=e.target.result,r=o.globalScope.msCrypto.subtle.exportKey('pkcs8',t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(i.fromDer(a.util.createBuffer(t)));u(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){u(e)}},void(l.onerror=function(e){u(e)})}}else if(B('generateKeyPairSync')){var p=n.generateKeyPairSync('rsa',{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:'spki',format:'pem'},privateKeyEncoding:{type:'pkcs8',format:'pem'}});return{privateKey:c.privateKeyFromPem(p.privateKey),publicKey:c.publicKeyFromPem(p.publicKey)}}var h=c.rsa.createKeyPairGenerationState(e,t,s);if(!u)return c.rsa.stepKeyPairGenerationState(h,0),h.keys;!function(e,t,n){'function'==typeof t&&(n=t,t={});t=t||{};var i={algorithm:{name:t.algorithm||'PRIMEINC',options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};'prng'in t&&(i.prng=t.prng);function s(){o(e.pBits,(function(t,r){return t?n(t):(e.p=r,null!==e.q?u(t,e.q):void o(e.qBits,u))}))}function o(e,t){a.prime.generateProbablePrime(e,i,t)}function u(t,a){if(t)return n(t);if(e.q=a,e.p.compareTo(e.q)<0){var i=e.p;e.p=e.q,e.q=i}if(0!==e.p.subtract(r.ONE).gcd(e.e).compareTo(r.ONE))return e.p=null,void s();if(0!==e.q.subtract(r.ONE).gcd(e.e).compareTo(r.ONE))return e.q=null,void o(e.qBits,u);if(e.p1=e.p.subtract(r.ONE),e.q1=e.q.subtract(r.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(r.ONE))return e.p=e.q=null,void s();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void o(e.qBits,u);var l=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},n(null,e.keys)}s()}(h,s,u)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,n){if('string'==typeof t?t=t.toUpperCase():void 0===t&&(t='RSAES-PKCS1-V1_5'),'RSAES-PKCS1-V1_5'===t)t={encode:function(e,t,r){return S(e,t,2).getBytes()}};else if('RSA-OAEP'===t||'RSAES-OAEP'===t)t={encode:function(e,t){return a.pkcs1.encode_rsa_oaep(t,e,n)}};else if(-1!==['RAW','NONE','NULL',null].indexOf(t))t={encode:function(e){return e}};else if('string'==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var i=t.encode(e,r,!0);return c.rsa.encrypt(i,r,!0)},verify:function(e,t,n,s){'string'==typeof n?n=n.toUpperCase():void 0===n&&(n='RSASSA-PKCS1-V1_5'),void 0===s&&(s={_parseAllDigestBytes:!0}),'_parseAllDigestBytes'in s||(s._parseAllDigestBytes=!0),'RSASSA-PKCS1-V1_5'===n?n={verify:function(e,t){t=T(t,r,!0);var n=i.fromDer(t,{parseAllBytes:s._parseAllDigestBytes}),o={},c=[];if(!i.validate(n,m,o,c))throw(u=new Error('ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.')).errors=c,u;var u,l=i.derToOid(o.algorithmIdentifier);if(l!==a.oids.md2&&l!==a.oids.md5&&l!==a.oids.sha1&&l!==a.oids.sha224&&l!==a.oids.sha256&&l!==a.oids.sha384&&l!==a.oids.sha512&&l!==a.oids['sha512-224']&&l!==a.oids['sha512-256'])throw(u=new Error('Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.')).oid=l,u;if((l===a.oids.md2||l===a.oids.md5)&&!('parameters'in o))throw new Error('ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.');return e===o.digest}}:'NONE'!==n&&'NULL'!==n&&null!==n||(n={verify:function(e,t){return e===(t=T(t,r,!0))}});var o=c.rsa.decrypt(t,r,!0,!1);return n.verify(e,o,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,n,i,s,o,u){var l={n:e,e:t,d:r,p:n,q:i,dP:s,dQ:o,qInv:u,decrypt:function(e,t,r){'string'==typeof t?t=t.toUpperCase():void 0===t&&(t='RSAES-PKCS1-V1_5');var n=c.rsa.decrypt(e,l,!1,!1);if('RSAES-PKCS1-V1_5'===t)t={decode:T};else if('RSA-OAEP'===t||'RSAES-OAEP'===t)t={decode:function(e,t){return a.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===['RAW','NONE','NULL',null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(n,l,!1)},sign:function(e,t){var r=!1;'string'==typeof t&&(t=t.toUpperCase()),void 0===t||'RSASSA-PKCS1-V1_5'===t?(t={encode:C},r=1):'NONE'!==t&&'NULL'!==t&&null!==t||(t={encode:function(){return e}},r=1);var a=t.encode(e,l.n.bitLength());return c.rsa.encrypt(a,l,r)}};return l},c.wrapRsaPrivateKey=function(e){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(0).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(c.oids.rsaEncryption).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,'')]),i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,i.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,n,s,o,u,l,p,d,y={},g=[];if(i.validate(e,h,y,g)&&(e=i.fromDer(a.util.createBuffer(y.privateKey))),y={},g=[],!i.validate(e,f,y,g)){var v=new Error('Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.');throw v.errors=g,v}return t=a.util.createBuffer(y.privateKeyModulus).toHex(),n=a.util.createBuffer(y.privateKeyPublicExponent).toHex(),s=a.util.createBuffer(y.privateKeyPrivateExponent).toHex(),o=a.util.createBuffer(y.privateKeyPrime1).toHex(),u=a.util.createBuffer(y.privateKeyPrime2).toHex(),l=a.util.createBuffer(y.privateKeyExponent1).toHex(),p=a.util.createBuffer(y.privateKeyExponent2).toHex(),d=a.util.createBuffer(y.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new r(t,16),new r(n,16),new r(s,16),new r(o,16),new r(u,16),new r(l,16),new r(p,16),new r(d,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(0).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.n)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.e)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.d)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.p)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.q)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.dP)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.dQ)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},n=[];if(i.validate(e,v,t,n)){var s,o=i.derToOid(t.publicKeyOid);if(o!==c.oids.rsaEncryption)throw(s=new Error('Cannot read public key. Unknown OID.')).oid=o,s;e=t.rsaPublicKey}if(n=[],!i.validate(e,d,t,n))throw(s=new Error('Cannot read public key. ASN.1 object does not contain an RSAPublicKey.')).errors=n,s;var u=a.util.createBuffer(t.publicKeyModulus).toHex(),l=a.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new r(u,16),new r(l,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(c.oids.rsaEncryption).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,'')]),i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.n)),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,I(e.e))])}}}),L=o({'node_modules/node-forge/lib/pbe.js'(e,t){var r,a=u();d(),g(),S(),v(),y(),T(),E(),b(),B(),k(),p(),void 0===r&&(r=a.jsbn.BigInteger);var n=a.asn1,i=a.pki=a.pki||{};t.exports=i.pbe=a.pbe=a.pbe||{};var s=i.oids,o={name:'EncryptedPrivateKeyInfo',tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedPrivateKeyInfo.encryptionAlgorithm',tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:'encryptionOid'},{name:'AlgorithmIdentifier.parameters',tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,captureAsn1:'encryptionParams'}]},{name:'EncryptedPrivateKeyInfo.encryptedData',tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:'encryptedData'}]},c={name:'PBES2Algorithms',tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.keyDerivationFunc',tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.keyDerivationFunc.oid',tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:'kdfOid'},{name:'PBES2Algorithms.params',tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.params.salt',tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:'kdfSalt'},{name:'PBES2Algorithms.params.iterationCount',tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:'kdfIterationCount'},{name:'PBES2Algorithms.params.keyLength',tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,optional:!0,capture:'keyLength'},{name:'PBES2Algorithms.params.prf',tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:'PBES2Algorithms.params.prf.algorithm',tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:'prfOid'}]}]}]},{name:'PBES2Algorithms.encryptionScheme',tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.encryptionScheme.oid',tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:'encOid'},{name:'PBES2Algorithms.encryptionScheme.iv',tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:'encIv'}]}]},l={name:'pkcs-12PbeParams',tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:'pkcs-12PbeParams.salt',tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:'salt'},{name:'pkcs-12PbeParams.iterations',tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:'iterations'}]};function h(e,t){return e.start().update(t).digest().getBytes()}function f(e){var t;if(e){if(!(t=i.oids[n.derToOid(e)])){var r=new Error('Unsupported PRF OID.');throw r.oid=e,r.supported=['hmacWithSHA1','hmacWithSHA224','hmacWithSHA256','hmacWithSHA384','hmacWithSHA512'],r}}else t='hmacWithSHA1';return m(t)}function m(e){var t=a.md;switch(e){case'hmacWithSHA224':t=a.md.sha512;case'hmacWithSHA1':case'hmacWithSHA256':case'hmacWithSHA384':case'hmacWithSHA512':e=e.substr(8).toLowerCase();break;default:var r=new Error('Unsupported PRF algorithm.');throw r.algorithm=e,r.supported=['hmacWithSHA1','hmacWithSHA224','hmacWithSHA256','hmacWithSHA384','hmacWithSHA512'],r}if(!t||!(e in t))throw new Error('Unknown hash algorithm: '+e);return t[e].create()}i.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||'aes128',r.prfAlgorithm=r.prfAlgorithm||'sha1';var o,c,u,l=a.random.getBytesSync(r.saltSize),p=r.count,h=n.integerToDer(p);if(0===r.algorithm.indexOf('aes')||'des'===r.algorithm){var f,d,y;switch(r.algorithm){case'aes128':o=16,f=16,d=s['aes128-CBC'],y=a.aes.createEncryptionCipher;break;case'aes192':o=24,f=16,d=s['aes192-CBC'],y=a.aes.createEncryptionCipher;break;case'aes256':o=32,f=16,d=s['aes256-CBC'],y=a.aes.createEncryptionCipher;break;case'des':o=8,f=8,d=s.desCBC,y=a.des.createEncryptionCipher;break;default:throw(T=new Error('Cannot encrypt private key. Unknown encryption algorithm.')).algorithm=r.algorithm,T}var g='hmacWith'+r.prfAlgorithm.toUpperCase(),v=m(g),C=a.pkcs5.pbkdf2(t,l,p,o,v),E=a.random.getBytesSync(f);(I=y(C)).start(E),I.update(n.toDer(e)),I.finish(),u=I.output.getBytes();var S=function(e,t,r,s){var o=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,e),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,t.getBytes())]);'hmacWithSHA1'!==s&&o.value.push(n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,a.util.hexToBytes(r.toString(16))),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(i.oids[s]).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.NULL,!1,'')]));return o}(l,h,o,g);c=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(s.pkcs5PBES2).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(s.pkcs5PBKDF2).getBytes()),S]),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(d).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,E)])])])}else{var T;if('3des'!==r.algorithm)throw(T=new Error('Cannot encrypt private key. Unknown encryption algorithm.')).algorithm=r.algorithm,T;o=24;var I,A=new a.util.ByteBuffer(l);C=i.pbe.generatePkcs12Key(t,A,1,p,o),E=i.pbe.generatePkcs12Key(t,A,2,p,o);(I=a.des.createEncryptionCipher(C)).start(E),I.update(n.toDer(e)),I.finish(),u=I.output.getBytes(),c=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(s['pbeWithSHAAnd3-KeyTripleDES-CBC']).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,l),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,h.getBytes())])])}return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[c,n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,u)])},i.decryptPrivateKeyInfo=function(e,t){var r=null,s={},c=[];if(!n.validate(e,o,s,c)){var u=new Error('Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.');throw u.errors=c,u}var l=n.derToOid(s.encryptionOid),p=i.pbe.getCipher(l,s.encryptionParams,t),h=a.util.createBuffer(s.encryptedData);return p.update(h),p.finish()&&(r=n.fromDer(p.output)),r},i.encryptedPrivateKeyToPem=function(e,t){var r={type:'ENCRYPTED PRIVATE KEY',body:n.toDer(e).getBytes()};return a.pem.encode(r,{maxline:t})},i.encryptedPrivateKeyFromPem=function(e){var t=a.pem.decode(e)[0];if('ENCRYPTED PRIVATE KEY'!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&'ENCRYPTED'===t.procType.type)throw new Error('Could not convert encrypted private key from PEM; PEM is encrypted.');return n.fromDer(t.body)},i.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var s=i.wrapRsaPrivateKey(i.privateKeyToAsn1(e));return s=i.encryptPrivateKeyInfo(s,t,r),i.encryptedPrivateKeyToPem(s)}var o,c,u,l;switch(r.algorithm){case'aes128':o='AES-128-CBC',u=16,c=a.random.getBytesSync(16),l=a.aes.createEncryptionCipher;break;case'aes192':o='AES-192-CBC',u=24,c=a.random.getBytesSync(16),l=a.aes.createEncryptionCipher;break;case'aes256':o='AES-256-CBC',u=32,c=a.random.getBytesSync(16),l=a.aes.createEncryptionCipher;break;case'3des':o='DES-EDE3-CBC',u=24,c=a.random.getBytesSync(8),l=a.des.createEncryptionCipher;break;case'des':o='DES-CBC',u=8,c=a.random.getBytesSync(8),l=a.des.createEncryptionCipher;break;default:var p=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw p.algorithm=r.algorithm,p}var h=l(a.pbe.opensslDeriveBytes(t,c.substr(0,8),u));h.start(c),h.update(n.toDer(i.privateKeyToAsn1(e))),h.finish();var f={type:'RSA PRIVATE KEY',procType:{version:'4',type:'ENCRYPTED'},dekInfo:{algorithm:o,parameters:a.util.bytesToHex(c).toUpperCase()},body:h.output.getBytes()};return a.pem.encode(f)},i.decryptRsaPrivateKey=function(e,t){var r=null,s=a.pem.decode(e)[0];if('ENCRYPTED PRIVATE KEY'!==s.type&&'PRIVATE KEY'!==s.type&&'RSA PRIVATE KEY'!==s.type)throw(u=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=u,u;if(s.procType&&'ENCRYPTED'===s.procType.type){var o,c;switch(s.dekInfo.algorithm){case'DES-CBC':o=8,c=a.des.createDecryptionCipher;break;case'DES-EDE3-CBC':o=24,c=a.des.createDecryptionCipher;break;case'AES-128-CBC':o=16,c=a.aes.createDecryptionCipher;break;case'AES-192-CBC':o=24,c=a.aes.createDecryptionCipher;break;case'AES-256-CBC':o=32,c=a.aes.createDecryptionCipher;break;case'RC2-40-CBC':o=5,c=function(e){return a.rc2.createDecryptionCipher(e,40)};break;case'RC2-64-CBC':o=8,c=function(e){return a.rc2.createDecryptionCipher(e,64)};break;case'RC2-128-CBC':o=16,c=function(e){return a.rc2.createDecryptionCipher(e,128)};break;default:var u;throw(u=new Error('Could not decrypt private key; unsupported encryption algorithm "'+s.dekInfo.algorithm+'".')).algorithm=s.dekInfo.algorithm,u}var l=a.util.hexToBytes(s.dekInfo.parameters),p=c(a.pbe.opensslDeriveBytes(t,l.substr(0,8),o));if(p.start(l),p.update(a.util.createBuffer(s.body)),!p.finish())return r;r=p.output.getBytes()}else r=s.body;return null!==(r='ENCRYPTED PRIVATE KEY'===s.type?i.decryptPrivateKeyInfo(n.fromDer(r),t):n.fromDer(r))&&(r=i.privateKeyFromAsn1(r)),r},i.pbe.generatePkcs12Key=function(e,t,r,n,i,s){var o,c;if(null==s){if(!('sha1'in a.md))throw new Error('"sha1" hash algorithm unavailable.');s=a.md.sha1.create()}var u=s.digestLength,l=s.blockLength,p=new a.util.ByteBuffer,h=new a.util.ByteBuffer;if(null!=e){for(c=0;c=0;c--)_>>=8,_+=b.at(c)+w.at(c),w.setAt(c,255&_);N.putBuffer(w)}E=N,p.putBuffer(I)}return p.truncate(p.length()-i),p},i.pbe.getCipher=function(e,t,r){switch(e){case i.oids.pkcs5PBES2:return i.pbe.getCipherForPBES2(e,t,r);case i.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:case i.oids['pbewithSHAAnd40BitRC2-CBC']:return i.pbe.getCipherForPKCS12PBE(e,t,r);default:var a=new Error('Cannot read encrypted PBE data block. Unsupported OID.');throw a.oid=e,a.supportedOids=['pkcs5PBES2','pbeWithSHAAnd3-KeyTripleDES-CBC','pbewithSHAAnd40BitRC2-CBC'],a}},i.pbe.getCipherForPBES2=function(e,t,r){var s,o={},u=[];if(!n.validate(t,c,o,u))throw(s=new Error('Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.')).errors=u,s;if((e=n.derToOid(o.kdfOid))!==i.oids.pkcs5PBKDF2)throw(s=new Error('Cannot read encrypted private key. Unsupported key derivation function OID.')).oid=e,s.supportedOids=['pkcs5PBKDF2'],s;if((e=n.derToOid(o.encOid))!==i.oids['aes128-CBC']&&e!==i.oids['aes192-CBC']&&e!==i.oids['aes256-CBC']&&e!==i.oids['des-EDE3-CBC']&&e!==i.oids.desCBC)throw(s=new Error('Cannot read encrypted private key. Unsupported encryption scheme OID.')).oid=e,s.supportedOids=['aes128-CBC','aes192-CBC','aes256-CBC','des-EDE3-CBC','desCBC'],s;var l,p,h=o.kdfSalt,d=a.util.createBuffer(o.kdfIterationCount);switch(d=d.getInt(d.length()<<3),i.oids[e]){case'aes128-CBC':l=16,p=a.aes.createDecryptionCipher;break;case'aes192-CBC':l=24,p=a.aes.createDecryptionCipher;break;case'aes256-CBC':l=32,p=a.aes.createDecryptionCipher;break;case'des-EDE3-CBC':l=24,p=a.des.createDecryptionCipher;break;case'desCBC':l=8,p=a.des.createDecryptionCipher}var y=f(o.prfOid),g=a.pkcs5.pbkdf2(r,h,d,l,y),v=o.encIv,m=p(g);return m.start(v),m},i.pbe.getCipherForPKCS12PBE=function(e,t,r){var s={},o=[];if(!n.validate(t,l,s,o))throw(y=new Error('Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.')).errors=o,y;var c,u,p,h=a.util.createBuffer(s.salt),d=a.util.createBuffer(s.iterations);switch(d=d.getInt(d.length()<<3),e){case i.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:c=24,u=8,p=a.des.startDecrypting;break;case i.oids['pbewithSHAAnd40BitRC2-CBC']:c=5,u=8,p=function(e,t){var r=a.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var y;throw(y=new Error('Cannot read PKCS #12 PBE data block. Unsupported OID.')).oid=e,y}var g=f(s.prfOid),v=i.pbe.generatePkcs12Key(r,h,1,d,c,g);return g.start(),p(v,i.pbe.generatePkcs12Key(r,h,2,d,u,g))},i.pbe.opensslDeriveBytes=function(e,t,r,n){if(null==n){if(!('md5'in a.md))throw new Error('"md5" hash algorithm unavailable.');n=a.md.md5.create()}null===t&&(t='');for(var i=[h(n,e+t)],s=16,o=1;s>8*h-p&255;return(E=String.fromCharCode(E.charCodeAt(0)&~S)+E.substr(1))+y+String.fromCharCode(188)},verify:function(e,s,o){var c,u=o-1,l=Math.ceil(u/8);if(s=s.substr(-l),l>8*l-u&255;if(h.charCodeAt(0)&d)throw new Error('Bits beyond keysize not zero as expected.');var y=n.generate(f,p),g='';for(c=0;c128)throw new Error('Invalid "nsComment" content.');e.value=a.create(a.Class.UNIVERSAL,a.Type.IA5STRING,!1,e.comment)}else if('subjectKeyIdentifier'===e.name&&t.cert){var f=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=f.toHex(),e.value=a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,f.getBytes())}else if('authorityKeyIdentifier'===e.name&&t.cert){e.value=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[]);l=e.value.value;if(e.keyIdentifier){var d=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;l.push(a.create(a.Class.CONTEXT_SPECIFIC,0,!1,d))}if(e.authorityCertIssuer){var y=[a.create(a.Class.CONTEXT_SPECIFIC,4,!0,[A(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];l.push(a.create(a.Class.CONTEXT_SPECIFIC,1,!0,y))}if(e.serialNumber){var g=r.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);l.push(a.create(a.Class.CONTEXT_SPECIFIC,2,!1,g))}}else if('cRLDistributionPoints'===e.name){e.value=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[]);l=e.value.value;var v,m=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[]),C=a.create(a.Class.CONTEXT_SPECIFIC,0,!0,[]);for(h=0;h2)throw new Error('Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.');if(p.length<2)throw new Error('Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.');if(u.validity.notBefore=p[0],u.validity.notAfter=p[1],u.tbsCertificate=i.tbsCertificate,t){u.md=T({signatureOid:u.signatureOid,type:'certificate'});var h=a.toDer(u.tbsCertificate);u.md.update(h.getBytes())}var f=r.md.sha1.create(),d=a.toDer(i.certIssuer);f.update(d.getBytes()),u.issuer.getField=function(e){return m(u.issuer,e)},u.issuer.addField=function(e){b([e]),u.issuer.attributes.push(e)},u.issuer.attributes=n.RDNAttributesAsArray(i.certIssuer),i.certIssuerUniqueId&&(u.issuer.uniqueId=i.certIssuerUniqueId),u.issuer.hash=f.digest().toHex();var y=r.md.sha1.create(),g=a.toDer(i.certSubject);return y.update(g.getBytes()),u.subject.getField=function(e){return m(u.subject,e)},u.subject.addField=function(e){b([e]),u.subject.attributes.push(e)},u.subject.attributes=n.RDNAttributesAsArray(i.certSubject),i.certSubjectUniqueId&&(u.subject.uniqueId=i.certSubjectUniqueId),u.subject.hash=y.digest().toHex(),i.certExtensions?u.extensions=n.certificateExtensionsFromAsn1(i.certExtensions):u.extensions=[],u.publicKey=n.publicKeyFromAsn1(i.subjectPublicKeyInfo),u},n.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(n=c.value.charCodeAt(1),s=c.value.length>2?c.value.charCodeAt(2):0),t.digitalSignature=!(128&~n),t.nonRepudiation=!(64&~n),t.keyEncipherment=!(32&~n),t.dataEncipherment=!(16&~n),t.keyAgreement=!(8&~n),t.keyCertSign=!(4&~n),t.cRLSign=!(2&~n),t.encipherOnly=!(1&~n),t.decipherOnly=!(128&~s)}else if('basicConstraints'===t.name){(c=a.fromDer(t.value)).value.length>0&&c.value[0].type===a.Type.BOOLEAN?t.cA=0!==c.value[0].value.charCodeAt(0):t.cA=!1;var o=null;c.value.length>0&&c.value[0].type===a.Type.INTEGER?o=c.value[0].value:c.value.length>1&&(o=c.value[1].value),null!==o&&(t.pathLenConstraint=a.derToInteger(o))}else if('extKeyUsage'===t.name)for(var c=a.fromDer(t.value),u=0;u1&&(n=c.value.charCodeAt(1)),t.client=!(128&~n),t.server=!(64&~n),t.email=!(32&~n),t.objsign=!(16&~n),t.reserved=!(8&~n),t.sslCA=!(4&~n),t.emailCA=!(2&~n),t.objCA=!(1&~n)}else if('subjectAltName'===t.name||'issuerAltName'===t.name){var p;t.altNames=[];c=a.fromDer(t.value);for(var h=0;h=_&&e0&&s.value.push(n.certificateExtensionsToAsn1(e.extensions)),s},n.getCertificationRequestInfo=function(e){return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,a.integerToDer(e.version).getBytes()),A(e.subject),n.publicKeyToAsn1(e.publicKey),w(e)])},n.distinguishedNameToAsn1=function(e){return A(e)},n.certificateToAsn1=function(e){var t=e.tbsCertificate||n.getTBSCertificate(e);return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[t,a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(e.signatureOid).getBytes()),N(e.signatureOid,e.signatureParameters)]),a.create(a.Class.UNIVERSAL,a.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},n.certificateExtensionsToAsn1=function(e){var t=a.create(a.Class.CONTEXT_SPECIFIC,3,!0,[]),r=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[]);t.value.push(r);for(var i=0;il.validity.notAfter)&&(c={message:'Certificate is not valid yet or has expired.',error:n.certificateError.certificate_expired,notBefore:l.validity.notBefore,notAfter:l.validity.notAfter,now:s}),null===c){if(null===(p=t[0]||e.getIssuer(l))&&l.isIssuer(l)&&(h=!0,p=l),p){var f=p;r.util.isArray(f)||(f=[f]);for(var d=!1;!d&&f.length>0;){p=f.shift();try{d=p.verify(l)}catch(e){}}d||(c={message:'Certificate signature is invalid.',error:n.certificateError.bad_certificate})}null!==c||p&&!h||e.hasCertificate(l)||(c={message:'Certificate is not trusted.',error:n.certificateError.unknown_ca})}if(null===c&&p&&!l.isIssuer(p)&&(c={message:'Certificate issuer is invalid.',error:n.certificateError.bad_certificate}),null===c)for(var y={keyUsage:!0,basicConstraints:!0},g=0;null===c&&gm.pathLenConstraint&&(c={message:'Certificate basicConstraints pathLenConstraint violated.',error:n.certificateError.bad_certificate})}var E=null===c||c.error,S=a.verify?a.verify(E,u,i):E;if(!0!==S)throw!0===E&&(c={message:'The application rejected the certificate.',error:n.certificateError.bad_certificate}),(S||0===S)&&('object'!=typeof S||r.util.isArray(S)?'string'==typeof S&&(c.error=S):(S.message&&(c.message=S.message),S.error&&(c.error=S.error))),c;c=null,o=!1,++u}while(t.length>0);return!0}}}),K=o({'node_modules/node-forge/lib/pkcs12.js'(e,t){var r=u();g(),m(),y(),U(),L(),b(),k(),w(),p(),V();var a=r.asn1,n=r.pki,i=t.exports=r.pkcs12=r.pkcs12||{},s={name:'ContentInfo',tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:'ContentInfo.contentType',tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:'contentType'},{name:'ContentInfo.content',tagClass:a.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:'content'}]},o={name:'PFX',tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:'PFX.version',tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:'version'},s,{name:'PFX.macData',tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:'mac',value:[{name:'PFX.macData.mac',tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:'PFX.macData.mac.digestAlgorithm',tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:'PFX.macData.mac.digestAlgorithm.algorithm',tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:'macAlgorithm'},{name:'PFX.macData.mac.digestAlgorithm.parameters',tagClass:a.Class.UNIVERSAL,captureAsn1:'macAlgorithmParameters'}]},{name:'PFX.macData.mac.digest',tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:'macDigest'}]},{name:'PFX.macData.macSalt',tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:'macSalt'},{name:'PFX.macData.iterations',tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,optional:!0,capture:'macIterations'}]}]},c={name:'SafeBag',tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:'SafeBag.bagId',tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:'bagId'},{name:'SafeBag.bagValue',tagClass:a.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:'bagValue'},{name:'SafeBag.bagAttributes',tagClass:a.Class.UNIVERSAL,type:a.Type.SET,constructed:!0,optional:!0,capture:'bagAttributes'}]},l={name:'Attribute',tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:'Attribute.attrId',tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:'oid'},{name:'Attribute.attrValues',tagClass:a.Class.UNIVERSAL,type:a.Type.SET,constructed:!0,capture:'values'}]},h={name:'CertBag',tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:'CertBag.certId',tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:'certId'},{name:'CertBag.certValue',tagClass:a.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:'CertBag.certValue[0]',tagClass:a.Class.UNIVERSAL,type:a.Class.OCTETSTRING,constructed:!1,capture:'cert'}]}]};function f(e,t,r,a){for(var n=[],i=0;i=0&&n.push(o):n.push(o))}return n}function d(e){if(e.composed||e.constructed){for(var t=r.util.createBuffer(),a=0;a0&&(c=a.create(a.Class.UNIVERSAL,a.Type.SET,!0,p));var h=[],f=[];null!==t&&(f=r.util.isArray(t)?t:[t]);for(var d=[],y=0;y0){var C=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,d),E=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(n.oids.data).getBytes()),a.create(a.Class.CONTEXT_SPECIFIC,0,!0,[a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,a.toDer(C).getBytes())])]);h.push(E)}var S=null;if(null!==e){var T=n.wrapRsaPrivateKey(n.privateKeyToAsn1(e));S=null===s?a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(n.oids.keyBag).getBytes()),a.create(a.Class.CONTEXT_SPECIFIC,0,!0,[T]),c]):a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(n.oids.pkcs8ShroudedKeyBag).getBytes()),a.create(a.Class.CONTEXT_SPECIFIC,0,!0,[n.encryptPrivateKeyInfo(T,s,o)]),c]);var I=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[S]),A=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(n.oids.data).getBytes()),a.create(a.Class.CONTEXT_SPECIFIC,0,!0,[a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,a.toDer(I).getBytes())])]);h.push(A)}var b,B=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,h);if(o.useMac){var N=r.md.sha1.create(),w=new r.util.ByteBuffer(r.random.getBytes(o.saltSize)),_=o.count,R=(e=i.generateKey(s,w,3,_,20),r.hmac.create());R.start(N,e),R.update(a.toDer(B).getBytes());var k=R.getMac();b=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(n.oids.sha1).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,'')]),a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,k.getBytes())]),a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,w.getBytes()),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,a.integerToDer(_).getBytes())])}return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,a.integerToDer(3).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(n.oids.data).getBytes()),a.create(a.Class.CONTEXT_SPECIFIC,0,!0,[a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,a.toDer(B).getBytes())])]),b])},i.generateKey=r.pbe.generatePkcs12Key}}),x=o({'node_modules/node-forge/lib/pki.js'(e,t){var r=u();g(),y(),L(),E(),T(),K(),O(),k(),p(),V();var a=r.asn1,n=t.exports=r.pki=r.pki||{};n.pemToDer=function(e){var t=r.pem.decode(e)[0];if(t.procType&&'ENCRYPTED'===t.procType.type)throw new Error('Could not convert PEM to DER; PEM is encrypted.');return r.util.createBuffer(t.body)},n.privateKeyFromPem=function(e){var t=r.pem.decode(e)[0];if('PRIVATE KEY'!==t.type&&'RSA PRIVATE KEY'!==t.type){var i=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw i.headerType=t.type,i}if(t.procType&&'ENCRYPTED'===t.procType.type)throw new Error('Could not convert private key from PEM; PEM is encrypted.');var s=a.fromDer(t.body);return n.privateKeyFromAsn1(s)},n.privateKeyToPem=function(e,t){var i={type:'RSA PRIVATE KEY',body:a.toDer(n.privateKeyToAsn1(e)).getBytes()};return r.pem.encode(i,{maxline:t})},n.privateKeyInfoToPem=function(e,t){var n={type:'PRIVATE KEY',body:a.toDer(e).getBytes()};return r.pem.encode(n,{maxline:t})}}}),M=o({'node_modules/node-forge/lib/tls.js'(e,t){var r=u();g(),m(),C(),E(),x(),b(),w(),p();var a=function(e,t,a,n){var i=r.util.createBuffer(),s=e.length>>1,o=s+(1&e.length),c=e.substr(0,o),u=e.substr(s,o),l=r.util.createBuffer(),p=r.hmac.create();a=t+a;var h=Math.ceil(n/16),f=Math.ceil(n/20);p.start('MD5',c);var d=r.util.createBuffer();l.putBytes(a);for(var y=0;y0&&(c.queue(e,c.createAlert(e,{level:c.Alert.Level.warning,description:c.Alert.Description.no_renegotiation})),c.flush(e)),e.process()},c.parseHelloMessage=function(e,t,a){var n=null,i=e.entity===c.ConnectionEnd.client;if(a<38)e.error(e,{message:i?'Invalid ServerHello message. Message too short.':'Invalid ClientHello message. Message too short.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});else{var o=t.fragment,u=o.length();if(n={version:{major:o.getByte(),minor:o.getByte()},random:r.util.createBuffer(o.getBytes(32)),session_id:s(o,1),extensions:[]},i?(n.cipher_suite=o.getBytes(2),n.compression_method=o.getByte()):(n.cipher_suites=s(o,2),n.compression_methods=s(o,1)),(u=a-(u-o.length()))>0){for(var l=s(o,2);l.length()>0;)n.extensions.push({type:[l.getByte(),l.getByte()],data:s(l,2)});if(!i)for(var p=0;p0;){if(0!==f.getByte())break;e.session.extensions.server_name.serverNameList.push(s(f,2).getBytes())}}}if(e.session.version&&(n.version.major!==e.session.version.major||n.version.minor!==e.session.version.minor))return e.error(e,{message:'TLS version change is disallowed during renegotiation.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}});if(i)e.session.cipherSuite=c.getCipherSuite(n.cipher_suite);else for(var d=r.util.createBuffer(n.cipher_suites.bytes());d.length()>0&&(e.session.cipherSuite=c.getCipherSuite(d.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:'No cipher suites in common.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.handshake_failure},cipherSuite:r.util.bytesToHex(n.cipher_suite)});e.session.compressionMethod=i?n.compression_method:c.CompressionMethod.none}return n},c.createSecurityParameters=function(e,t){var r=e.entity===c.ConnectionEnd.client,a=t.random.bytes(),n=r?e.session.sp.client_random:a,i=r?a:c.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:c.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:n,server_random:i}},c.handleServerHello=function(e,t,r){var a=c.parseHelloMessage(e,t,r);if(!e.fail){if(!(a.version.minor<=e.version.minor))return e.error(e,{message:'Incompatible TLS version.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}});e.version.minor=a.version.minor,e.session.version=e.version;var n=a.session_id.bytes();n.length>0&&n===e.session.id?(e.expect=y,e.session.resuming=!0,e.session.sp.server_random=a.random.bytes()):(e.expect=l,e.session.resuming=!1,c.createSecurityParameters(e,a)),e.session.id=n,e.process()}},c.handleClientHello=function(e,t,a){var n=c.parseHelloMessage(e,t,a);if(!e.fail){var i=n.session_id.bytes(),s=null;if(e.sessionCache&&(null===(s=e.sessionCache.getSession(i))?i='':(s.version.major!==n.version.major||s.version.minor>n.version.minor)&&(s=null,i='')),0===i.length&&(i=r.random.getBytes(32)),e.session.id=i,e.session.clientHelloVersion=n.version,e.session.sp={},s)e.version=e.session.version=s.version,e.session.sp=s.sp;else{for(var o,u=1;u0;)n=s(u.certificate_list,3),i=r.asn1.fromDer(n),n=r.pki.certificateFromAsn1(i,!0),l.push(n)}catch(t){return e.error(e,{message:'Could not parse certificate list.',cause:t,send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.bad_certificate}})}var p=e.entity===c.ConnectionEnd.client;!p&&!0!==e.verifyClient||0!==l.length?0===l.length?e.expect=p?h:A:(p?e.session.serverCertificate=l[0]:e.session.clientCertificate=l[0],c.verifyCertificateChain(e,l)&&(e.expect=p?h:A)):e.error(e,{message:p?'No server certificate provided.':'No client certificate provided.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}}),e.process()},c.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:'Invalid key parameters. Only RSA is supported.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.unsupported_certificate}});e.expect=f,e.process()},c.handleClientKeyExchange=function(e,t,a){if(a<48)return e.error(e,{message:'Invalid key parameters. Only RSA is supported.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.unsupported_certificate}});var n=t.fragment,i={enc_pre_master_secret:s(n,2).getBytes()},o=null;if(e.getPrivateKey)try{o=e.getPrivateKey(e,e.session.serverCertificate),o=r.pki.privateKeyFromPem(o)}catch(t){e.error(e,{message:'Could not get private key.',cause:t,send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}})}if(null===o)return e.error(e,{message:'No private key set.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}});try{var u=e.session.sp;u.pre_master_secret=o.decrypt(i.enc_pre_master_secret);var l=e.session.clientHelloVersion;if(l.major!==u.pre_master_secret.charCodeAt(0)||l.minor!==u.pre_master_secret.charCodeAt(1))throw new Error('TLS version rollback attack detected.')}catch(e){u.pre_master_secret=r.random.getBytes(48)}e.expect=N,null!==e.session.clientCertificate&&(e.expect=B),e.process()},c.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:'Invalid CertificateRequest. Message too short.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var a=t.fragment,n={certificate_types:s(a,1),certificate_authorities:s(a,2)};e.session.certificateRequest=n,e.expect=d,e.process()},c.handleCertificateVerify=function(e,t,a){if(a<2)return e.error(e,{message:'Invalid CertificateVerify. Message too short.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var o={signature:s(n,2).getBytes()},u=r.util.createBuffer();u.putBuffer(e.session.md5.digest()),u.putBuffer(e.session.sha1.digest()),u=u.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(u,o.signature,'NONE'))throw new Error('CertificateVerify signature does not match.');e.session.md5.update(i),e.session.sha1.update(i)}catch(t){return e.error(e,{message:'Bad signature in CertificateVerify.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.handshake_failure}})}e.expect=N,e.process()},c.handleServerHelloDone=function(e,t,a){if(a>0)return e.error(e,{message:'Invalid ServerHelloDone message. Invalid length.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.record_overflow}});if(null===e.serverCertificate){var n={message:'No server certificate provided. Not enough security.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.insufficient_security}},i=e.verify(e,n.alert.description,0,[]);if(!0!==i)return(i||0===i)&&('object'!=typeof i||r.util.isArray(i)?'number'==typeof i&&(n.alert.description=i):(i.message&&(n.message=i.message),i.alert&&(n.alert.description=i.alert))),e.error(e,n)}null!==e.session.certificateRequest&&(t=c.createRecord(e,{type:c.ContentType.handshake,data:c.createCertificate(e)}),c.queue(e,t)),t=c.createRecord(e,{type:c.ContentType.handshake,data:c.createClientKeyExchange(e)}),c.queue(e,t),e.expect=T;var s=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createCertificateVerify(e,t)})),c.queue(e,c.createRecord(e,{type:c.ContentType.change_cipher_spec,data:c.createChangeCipherSpec()})),e.state.pending=c.createConnectionState(e),e.state.current.write=e.state.pending.write,c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createFinished(e)})),e.expect=y,c.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return s(e,null);c.getClientSignature(e,s)},c.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:'Invalid ChangeCipherSpec message received.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var r=e.entity===c.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=c.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?v:_,e.process()},c.handleFinished=function(e,t,n){var i=t.fragment;i.read-=4;var s=i.bytes();i.read+=4;var o=t.fragment.getBytes();(i=r.util.createBuffer()).putBuffer(e.session.md5.digest()),i.putBuffer(e.session.sha1.digest());var u=e.entity===c.ConnectionEnd.client,l=u?'server finished':'client finished',p=e.session.sp;if((i=a(p.master_secret,l,i.getBytes(),12)).getBytes()!==o)return e.error(e,{message:'Invalid verify_data in Finished message.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.decrypt_error}});e.session.md5.update(s),e.session.sha1.update(s),(e.session.resuming&&u||!e.session.resuming&&!u)&&(c.queue(e,c.createRecord(e,{type:c.ContentType.change_cipher_spec,data:c.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createFinished(e)}))),e.expect=u?S:R,e.handshaking=!1,++e.handshakes,e.peerCertificate=u?e.session.serverCertificate:e.session.clientCertificate,c.flush(e),e.isConnected=!0,e.connected(e),e.process()},c.handleAlert=function(e,t){var r,a=t.fragment,n={level:a.getByte(),description:a.getByte()};switch(n.description){case c.Alert.Description.close_notify:r='Connection closed.';break;case c.Alert.Description.unexpected_message:r='Unexpected message.';break;case c.Alert.Description.bad_record_mac:r='Bad record MAC.';break;case c.Alert.Description.decryption_failed:r='Decryption failed.';break;case c.Alert.Description.record_overflow:r='Record overflow.';break;case c.Alert.Description.decompression_failure:r='Decompression failed.';break;case c.Alert.Description.handshake_failure:r='Handshake failure.';break;case c.Alert.Description.bad_certificate:r='Bad certificate.';break;case c.Alert.Description.unsupported_certificate:r='Unsupported certificate.';break;case c.Alert.Description.certificate_revoked:r='Certificate revoked.';break;case c.Alert.Description.certificate_expired:r='Certificate expired.';break;case c.Alert.Description.certificate_unknown:r='Certificate unknown.';break;case c.Alert.Description.illegal_parameter:r='Illegal parameter.';break;case c.Alert.Description.unknown_ca:r='Unknown certificate authority.';break;case c.Alert.Description.access_denied:r='Access denied.';break;case c.Alert.Description.decode_error:r='Decode error.';break;case c.Alert.Description.decrypt_error:r='Decrypt error.';break;case c.Alert.Description.export_restriction:r='Export restriction.';break;case c.Alert.Description.protocol_version:r='Unsupported protocol version.';break;case c.Alert.Description.insufficient_security:r='Insufficient security.';break;case c.Alert.Description.internal_error:r='Internal error.';break;case c.Alert.Description.user_canceled:r='User canceled.';break;case c.Alert.Description.no_renegotiation:r='Renegotiation not supported.';break;default:r='Unknown error.'}if(n.description===c.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===c.ConnectionEnd.client?'server':'client',alert:n}),e.process()},c.handleHandshake=function(e,t){var a=t.fragment,n=a.getByte(),i=a.getInt24();if(i>a.length())return e.fragmented=t,t.fragment=r.util.createBuffer(),a.read-=4,e.process();e.fragmented=null,a.read-=4;var s=a.bytes(i+4);a.read+=4,n in Q[e.entity][e.expect]?(e.entity!==c.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:r.md.md5.create(),sha1:r.md.sha1.create()}),n!==c.HandshakeType.hello_request&&n!==c.HandshakeType.certificate_verify&&n!==c.HandshakeType.finished&&(e.session.md5.update(s),e.session.sha1.update(s)),Q[e.entity][e.expect][n](e,t,i)):c.handleUnexpected(e,t)},c.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},c.handleHeartbeat=function(e,t){var a=t.fragment,n=a.getByte(),i=a.getInt16(),s=a.getBytes(i);if(n===c.HeartbeatMessageType.heartbeat_request){if(e.handshaking||i>s.length)return e.process();c.queue(e,c.createRecord(e,{type:c.ContentType.heartbeat,data:c.createHeartbeat(c.HeartbeatMessageType.heartbeat_response,s)})),c.flush(e)}else if(n===c.HeartbeatMessageType.heartbeat_response){if(s!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,r.util.createBuffer(s))}e.process()};var l=1,h=2,f=3,d=4,y=5,v=6,S=7,T=8,I=1,A=2,B=3,N=4,_=5,R=6,k=c.handleUnexpected,L=c.handleChangeCipherSpec,U=c.handleAlert,D=c.handleHandshake,P=c.handleApplicationData,O=c.handleHeartbeat,V=[];V[c.ConnectionEnd.client]=[[k,U,D,k,O],[k,U,D,k,O],[k,U,D,k,O],[k,U,D,k,O],[k,U,D,k,O],[L,U,k,k,O],[k,U,D,k,O],[k,U,D,P,O],[k,U,D,k,O]],V[c.ConnectionEnd.server]=[[k,U,D,k,O],[k,U,D,k,O],[k,U,D,k,O],[k,U,D,k,O],[L,U,k,k,O],[k,U,D,k,O],[k,U,D,P,O],[k,U,D,k,O]];var K=c.handleHelloRequest,M=c.handleServerHello,F=c.handleCertificate,j=c.handleServerKeyExchange,G=c.handleCertificateRequest,H=c.handleServerHelloDone,q=c.handleFinished,Q=[];Q[c.ConnectionEnd.client]=[[k,k,M,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[K,k,k,k,k,k,k,k,k,k,k,F,j,G,H,k,k,k,k,k,k],[K,k,k,k,k,k,k,k,k,k,k,k,j,G,H,k,k,k,k,k,k],[K,k,k,k,k,k,k,k,k,k,k,k,k,G,H,k,k,k,k,k,k],[K,k,k,k,k,k,k,k,k,k,k,k,k,k,H,k,k,k,k,k,k],[K,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[K,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,q],[K,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[K,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k]];var z=c.handleClientHello,Y=c.handleClientKeyExchange,W=c.handleCertificateVerify;Q[c.ConnectionEnd.server]=[[k,z,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,F,k,k,k,k,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,Y,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,W,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,q],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k],[k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k]],c.generateKeys=function(e,t){var r=a,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,'master secret',n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var i=2*t.mac_key_length+2*t.enc_key_length,s=e.version.major===c.Versions.TLS_1_0.major&&e.version.minor===c.Versions.TLS_1_0.minor;s&&(i+=2*t.fixed_iv_length);var o=r(t.master_secret,'key expansion',n,i),u={client_write_MAC_key:o.getBytes(t.mac_key_length),server_write_MAC_key:o.getBytes(t.mac_key_length),client_write_key:o.getBytes(t.enc_key_length),server_write_key:o.getBytes(t.enc_key_length)};return s&&(u.client_write_IV=o.getBytes(t.fixed_iv_length),u.server_write_IV=o.getBytes(t.fixed_iv_length)),u},c.createConnectionState=function(e){var t=e.entity===c.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},a={read:r(),write:r()};if(a.read.update=function(e,t){return a.read.cipherFunction(t,a.read)?a.read.compressFunction(e,t,a.read)||e.error(e,{message:'Could not decompress record.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.decompression_failure}}):e.error(e,{message:'Could not decrypt record or bad MAC.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.bad_record_mac}}),!e.fail},a.write.update=function(e,t){return a.write.compressFunction(e,t,a.write)?a.write.cipherFunction(t,a.write)||e.error(e,{message:'Could not encrypt record.',send:!1,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}}):e.error(e,{message:'Could not compress record.',send:!1,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}}),!e.fail},e.session){var s=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(s),s.keys=c.generateKeys(e,s),a.read.macKey=t?s.keys.server_write_MAC_key:s.keys.client_write_MAC_key,a.write.macKey=t?s.keys.client_write_MAC_key:s.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(a,e,s),s.compression_algorithm){case c.CompressionMethod.none:break;case c.CompressionMethod.deflate:a.read.compressFunction=i,a.write.compressFunction=n;break;default:throw new Error('Unsupported compression algorithm.')}}return a},c.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),a=r.util.createBuffer();return a.putInt32(t),a.putBytes(r.random.getBytes(28)),a},c.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},c.createAlert=function(e,t){var a=r.util.createBuffer();return a.putByte(t.level),a.putByte(t.description),c.createRecord(e,{type:c.ContentType.alert,data:a})},c.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=r.util.createBuffer(),a=0;a0&&(d+=2);var y=e.session.id,g=y.length+1+2+4+28+2+i+1+u+d,v=r.util.createBuffer();return v.putByte(c.HandshakeType.client_hello),v.putInt24(g),v.putByte(e.version.major),v.putByte(e.version.minor),v.putBytes(e.session.sp.client_random),o(v,1,r.util.createBuffer(y)),o(v,2,t),o(v,1,s),d>0&&o(v,2,l),v},c.createServerHello=function(e){var t=e.session.id,a=t.length+1+2+4+28+2+1,n=r.util.createBuffer();return n.putByte(c.HandshakeType.server_hello),n.putInt24(a),n.putByte(e.version.major),n.putByte(e.version.minor),n.putBytes(e.session.sp.server_random),o(n,1,r.util.createBuffer(t)),n.putByte(e.session.cipherSuite.id[0]),n.putByte(e.session.cipherSuite.id[1]),n.putByte(e.session.compressionMethod),n},c.createCertificate=function(e){var t,a=e.entity===c.ConnectionEnd.client,n=null;e.getCertificate&&(t=a?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,n=e.getCertificate(e,t));var i=r.util.createBuffer();if(null!==n)try{r.util.isArray(n)||(n=[n]);for(var s=null,u=0;uc.MaxFragment;)n.push(c.createRecord(e,{type:t.type,data:r.util.createBuffer(i.slice(0,c.MaxFragment))})),i=i.slice(c.MaxFragment);i.length>0&&n.push(c.createRecord(e,{type:t.type,data:r.util.createBuffer(i)}))}for(var s=0;s0&&(n=a.order[0]),null!==n&&n in a.cache)for(var i in t=a.cache[n],delete a.cache[n],a.order)if(a.order[i]===n){a.order.splice(i,1);break}return t},a.setSession=function(e,t){if(a.order.length===a.capacity){var n=a.order.shift();delete a.cache[n]}n=r.util.bytesToHex(e);a.order.push(n),a.cache[n]=t}}return a},c.createConnection=function(e){var t=null;t=e.caStore?r.util.isArray(e.caStore)?r.pki.createCaStore(e.caStore):e.caStore:r.pki.createCaStore();var a=e.cipherSuites||null;if(null===a)for(var n in a=[],c.CipherSuites)a.push(c.CipherSuites[n]);var i=e.server?c.ConnectionEnd.server:c.ConnectionEnd.client,s=e.sessionCache?c.createSessionCache(e.sessionCache):null,o={version:{major:c.Version.major,minor:c.Version.minor},entity:i,sessionId:e.sessionId,caStore:t,sessionCache:s,cipherSuites:a,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,a){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:r.util.createBuffer(),tlsData:r.util.createBuffer(),data:r.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===c.ConnectionEnd.client?'client':'server'),r.send&&(c.queue(t,c.createAlert(t,r.alert)),c.flush(t));var a=!1!==r.fatal;a&&(t.fail=!0),e.error(t,r),a&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){o.version={major:c.Version.major,minor:c.Version.minor},o.record=null,o.session=null,o.peerCertificate=null,o.state={pending:null,current:null},o.expect=(o.entity,c.ConnectionEnd.client,0),o.fragmented=null,o.records=[],o.open=!1,o.handshakes=0,o.handshaking=!1,o.isConnected=!1,o.fail=!(e||void 0===e),o.input.clear(),o.tlsData.clear(),o.data.clear(),o.state.current=c.createConnectionState(o)}};o.reset();return o.handshake=function(e){if(o.entity!==c.ConnectionEnd.client)o.error(o,{message:'Cannot initiate handshake as a server.',fatal:!1});else if(o.handshaking)o.error(o,{message:'Handshake already in progress.',fatal:!1});else{o.fail&&!o.open&&0===o.handshakes&&(o.fail=!1),o.handshaking=!0;var t=null;(e=e||'').length>0&&(o.sessionCache&&(t=o.sessionCache.getSession(e)),null===t&&(e='')),0===e.length&&o.sessionCache&&null!==(t=o.sessionCache.getSession())&&(e=t.id),o.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:r.md.md5.create(),sha1:r.md.sha1.create()},t&&(o.version=t.version,o.session.sp=t.sp),o.session.sp.client_random=c.createRandom().getBytes(),o.open=!0,c.queue(o,c.createRecord(o,{type:c.ContentType.handshake,data:c.createClientHello(o)})),c.flush(o)}},o.process=function(e){var t,a,n,i,s=0;return e&&o.input.putBytes(e),o.fail||(null!==o.record&&o.record.ready&&o.record.fragment.isEmpty()&&(o.record=null),null===o.record&&(s=function(e){var t=0,a=e.input,n=a.length();if(n<5)t=5-n;else{e.record={type:a.getByte(),version:{major:a.getByte(),minor:a.getByte()},length:a.getInt16(),fragment:r.util.createBuffer(),ready:!1};var i=e.record.version.major===e.version.major;i&&e.session&&e.session.version&&(i=e.record.version.minor===e.version.minor),i||e.error(e,{message:'Incompatible TLS version.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}})}return t}(o)),o.fail||null===o.record||o.record.ready||(s=function(e){var t=0,r=e.input,a=r.length();return a=a.Versions.TLS_1_1.minor&&c.output.putBytes(n),c.update(e.fragment),c.finish(s)&&(e.fragment=c.output,e.length=e.fragment.length(),i=!0),i}function s(e,t,r){if(!r){var a=e-t.length()%e;t.fillWithByte(a-1,a)}return!0}function o(e,t,r){var a=!0;if(r){for(var n=t.length(),i=t.last(),s=n-1-i;s=c?(e.fragment=s.output.getBytes(l-c),u=s.output.getBytes(c)):e.fragment=s.output.getBytes(),e.fragment=r.util.createBuffer(e.fragment),e.length=e.fragment.length();var p=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),i=function(e,t,a){var n=r.hmac.create();return n.start('SHA1',e),n.update(t),t=n.digest().getBytes(),n.start(null,null),n.update(a),a=n.digest().getBytes(),t===a}(t.macKey,u,p)&&i,i}a.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:'TLS_RSA_WITH_AES_128_CBC_SHA',initSecurityParameters:function(e){e.bulk_cipher_algorithm=a.BulkCipherAlgorithm.aes,e.cipher_type=a.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=a.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:n},a.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:'TLS_RSA_WITH_AES_256_CBC_SHA',initSecurityParameters:function(e){e.bulk_cipher_algorithm=a.BulkCipherAlgorithm.aes,e.cipher_type=a.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=a.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:n}}}),j=o({'node_modules/node-forge/lib/sha512.js'(e,t){var r=u();v(),p();var a=t.exports=r.sha512=r.sha512||{};r.md.sha512=r.md.algorithms.sha512=a;var n=r.sha384=r.sha512.sha384=r.sha512.sha384||{};n.create=function(){return a.create('SHA-384')},r.md.sha384=r.md.algorithms.sha384=n,r.sha512.sha256=r.sha512.sha256||{create:function(){return a.create('SHA-512/256')}},r.md['sha512/256']=r.md.algorithms['sha512/256']=r.sha512.sha256,r.sha512.sha224=r.sha512.sha224||{create:function(){return a.create('SHA-512/224')}},r.md['sha512/224']=r.md.algorithms['sha512/224']=r.sha512.sha224,a.create=function(e){if(s||(i=String.fromCharCode(128),i+=r.util.fillString(String.fromCharCode(0),128),o=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(c={})['SHA-512']=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c['SHA-384']=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c['SHA-512/256']=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c['SHA-512/224']=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],s=!0),void 0===e&&(e='SHA-512'),!(e in c))throw new Error('Invalid SHA-512 algorithm: '+e);for(var t=c[e],a=null,n=r.util.createBuffer(),u=new Array(80),p=0;p<80;++p)u[p]=new Array(2);var h=64;switch(e){case'SHA-384':h=48;break;case'SHA-512/256':h=32;break;case'SHA-512/224':h=28}var f={algorithm:e.replace('-','').toLowerCase(),blockLength:128,digestLength:h,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){f.messageLength=0,f.fullMessageLength=f.messageLength128=[];for(var e=f.messageLengthSize/4,i=0;i>>0,i>>>0];for(var s=f.fullMessageLength.length-1;s>=0;--s)f.fullMessageLength[s]+=i[1],i[1]=i[0]+(f.fullMessageLength[s]/4294967296>>>0),f.fullMessageLength[s]=f.fullMessageLength[s]>>>0,i[0]=i[1]/4294967296>>>0;return n.putBytes(e),l(a,u,n),(n.read>2048||0===n.length())&&n.compact(),f},f.digest=function(){var t=r.util.createBuffer();t.putBytes(n.bytes());var s,o=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize&f.blockLength-1;t.putBytes(i.substr(0,f.blockLength-o));for(var c=8*f.fullMessageLength[0],p=0;p>>0,t.putInt32(c>>>0),c=s>>>0;t.putInt32(c);var h=new Array(a.length);for(p=0;p=128;){for(R=0;R<16;++R)t[R][0]=r.getInt32()>>>0,t[R][1]=r.getInt32()>>>0;for(;R<80;++R)a=(((k=(U=t[R-2])[0])>>>19|(L=U[1])<<13)^(L>>>29|k<<3)^k>>>6)>>>0,n=((k<<13|L>>>19)^(L<<3|k>>>29)^(k<<26|L>>>6))>>>0,i=(((k=(P=t[R-15])[0])>>>1|(L=P[1])<<31)^(k>>>8|L<<24)^k>>>7)>>>0,s=((k<<31|L>>>1)^(k<<24|L>>>8)^(k<<25|L>>>7))>>>0,D=t[R-7],O=t[R-16],L=n+D[1]+s+O[1],t[R][0]=a+D[0]+i+O[0]+(L/4294967296>>>0)>>>0,t[R][1]=L>>>0;for(d=e[0][0],y=e[0][1],g=e[1][0],v=e[1][1],m=e[2][0],C=e[2][1],E=e[3][0],S=e[3][1],T=e[4][0],I=e[4][1],A=e[5][0],b=e[5][1],B=e[6][0],N=e[6][1],w=e[7][0],_=e[7][1],R=0;R<80;++R)l=((T>>>14|I<<18)^(T>>>18|I<<14)^(I>>>9|T<<23))>>>0,p=(B^T&(A^B))>>>0,c=((d>>>28|y<<4)^(y>>>2|d<<30)^(y>>>7|d<<25))>>>0,u=((d<<4|y>>>28)^(y<<30|d>>>2)^(y<<25|d>>>7))>>>0,h=(d&g|m&(d^g))>>>0,f=(y&v|C&(y^v))>>>0,L=_+(((T<<18|I>>>14)^(T<<14|I>>>18)^(I<<23|T>>>9))>>>0)+((N^I&(b^N))>>>0)+o[R][1]+t[R][1],a=w+l+p+o[R][0]+t[R][0]+(L/4294967296>>>0)>>>0,n=L>>>0,i=c+h+((L=u+f)/4294967296>>>0)>>>0,s=L>>>0,w=B,_=N,B=A,N=b,A=T,b=I,T=E+a+((L=S+n)/4294967296>>>0)>>>0,I=L>>>0,E=m,S=C,m=g,C=v,g=d,v=y,d=a+i+((L=n+s)/4294967296>>>0)>>>0,y=L>>>0;L=e[0][1]+y,e[0][0]=e[0][0]+d+(L/4294967296>>>0)>>>0,e[0][1]=L>>>0,L=e[1][1]+v,e[1][0]=e[1][0]+g+(L/4294967296>>>0)>>>0,e[1][1]=L>>>0,L=e[2][1]+C,e[2][0]=e[2][0]+m+(L/4294967296>>>0)>>>0,e[2][1]=L>>>0,L=e[3][1]+S,e[3][0]=e[3][0]+E+(L/4294967296>>>0)>>>0,e[3][1]=L>>>0,L=e[4][1]+I,e[4][0]=e[4][0]+T+(L/4294967296>>>0)>>>0,e[4][1]=L>>>0,L=e[5][1]+b,e[5][0]=e[5][0]+A+(L/4294967296>>>0)>>>0,e[5][1]=L>>>0,L=e[6][1]+N,e[6][0]=e[6][0]+B+(L/4294967296>>>0)>>>0,e[6][1]=L>>>0,L=e[7][1]+_,e[7][0]=e[7][0]+w+(L/4294967296>>>0)>>>0,e[7][1]=L>>>0,V-=128}}}}),G=o({'node_modules/node-forge/lib/asn1-validator.js'(e){var t=u();g();var r=t.asn1;e.privateKeyValidator={name:'PrivateKeyInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'PrivateKeyInfo.version',tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:'privateKeyVersion'},{name:'PrivateKeyInfo.privateKeyAlgorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'privateKeyOid'}]},{name:'PrivateKeyInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:'privateKey'}]},e.publicKeyValidator={name:'SubjectPublicKeyInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:'subjectPublicKeyInfo',value:[{name:'SubjectPublicKeyInfo.AlgorithmIdentifier',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'publicKeyOid'}]},{tagClass:r.Class.UNIVERSAL,type:r.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:'ed25519PublicKey'}]}}}),H=o({'node_modules/node-forge/lib/ed25519.js'(e,t){var r=u();N(),b(),j(),p();var a,n=G(),i=n.publicKeyValidator,s=n.privateKeyValidator;void 0===a&&(a=r.jsbn.BigInteger);var o=r.util.ByteBuffer,c='undefined'==typeof Buffer?Uint8Array:Buffer;r.pki=r.pki||{},t.exports=r.pki.ed25519=r.ed25519=r.ed25519||{};var l=r.ed25519;function h(e){var t=e.message;if(t instanceof Uint8Array||t instanceof c)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r='binary'}if('string'==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if('string'==typeof t){if('undefined'!=typeof Buffer)return Buffer.from(t,r);t=new o(t,r)}else if(!(t instanceof o))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var a=new c(t.length()),n=0;n=0;--r)F(a,a),1!==r&&H(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}(r,r),H(r,r,n),H(r,r,i),H(r,r,i),H(e[0],r,i),F(a,e[0]),H(a,a,i),R(a,n)&&H(e[0],e[0],E);if(F(a,e[0]),H(a,a,i),R(a,n))return-1;L(e[0])===t[31]>>7&&M(e[0],f,e[0]);return H(e[3],e[0],e[1]),0}(o,a))return-1;for(n=0;n=0};var f=K(),d=K([1]),y=K([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),g=K([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),v=K([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=K([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),C=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]),E=K([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function S(e,t){var a=r.md.sha512.create(),n=new o(e);a.update(n.getBytes(t),'binary');var i=a.digest().getBytes();if('undefined'!=typeof Buffer)return Buffer.from(i,'binary');for(var s=new c(l.constants.HASH_BYTE_LENGTH),u=0;u<64;++u)s[u]=i.charCodeAt(u);return s}function T(e,t){var r,a,n,i;for(a=63;a>=32;--a){for(r=0,n=a-32,i=a-12;n>8,t[n]-=256*r;t[n]+=r,t[a]=0}for(r=0,n=0;n<32;++n)t[n]+=r-(t[31]>>4)*C[n],r=t[n]>>8,t[n]&=255;for(n=0;n<32;++n)t[n]-=r*C[n];for(a=0;a<32;++a)t[a+1]+=t[a]>>8,e[a]=255&t[a]}function I(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;T(e,t)}function A(e,t){var r=K(),a=K(),n=K(),i=K(),s=K(),o=K(),c=K(),u=K(),l=K();M(r,e[1],e[0]),M(l,t[1],t[0]),H(r,r,l),x(a,e[0],e[1]),x(l,t[0],t[1]),H(a,a,l),H(n,e[3],t[3]),H(n,n,g),H(i,e[2],t[2]),x(i,i,i),M(s,a,r),M(o,i,n),x(c,i,n),x(u,a,r),H(e[0],s,o),H(e[1],u,c),H(e[2],c,o),H(e[3],s,u)}function B(e,t,r){for(var a=0;a<4;++a)V(e[a],t[a],r)}function w(e,t){var r=K(),a=K(),n=K();!function(e,t){var r,a=K();for(r=0;r<16;++r)a[r]=t[r];for(r=253;r>=0;--r)F(a,a),2!==r&&4!==r&&H(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}(n,t[2]),H(r,t[0],n),H(a,t[1],n),_(e,a),e[31]^=L(r)<<7}function _(e,t){var r,a,n,i=K(),s=K();for(r=0;r<16;++r)s[r]=t[r];for(O(s),O(s),O(s),a=0;a<2;++a){for(i[0]=s[0]-65517,r=1;r<15;++r)i[r]=s[r]-65535-(i[r-1]>>16&1),i[r-1]&=65535;i[15]=s[15]-32767-(i[14]>>16&1),n=i[15]>>16&1,i[14]&=65535,V(s,i,1-n)}for(r=0;r<16;r++)e[2*r]=255&s[r],e[2*r+1]=s[r]>>8}function R(e,t){var r=new c(32),a=new c(32);return _(r,e),_(a,t),k(r,0,a,0)}function k(e,t,r,a){return function(e,t,r,a,n){var i,s=0;for(i=0;i>>8)-1}(e,t,r,a,32)}function L(e){var t=new c(32);return _(t,e),1&t[0]}function U(e,t,r){var a,n;for(P(e[0],f),P(e[1],d),P(e[2],d),P(e[3],f),n=255;n>=0;--n)B(e,t,a=r[n/8|0]>>(7&n)&1),A(t,e),A(e,e),B(e,t,a)}function D(e,t){var r=[K(),K(),K(),K()];P(r[0],v),P(r[1],m),P(r[2],d),H(r[3],v,m),U(e,r,t)}function P(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function O(e){var t,r,a=1;for(t=0;t<16;++t)r=e[t]+a+65535,a=Math.floor(r/65536),e[t]=r-65536*a;e[0]+=a-1+37*(a-1)}function V(e,t,r){for(var a,n=~(r-1),i=0;i<16;++i)a=n&(e[i]^t[i]),e[i]^=a,t[i]^=a}function K(e){var t,r=new Float64Array(16);if(e)for(t=0;t0&&(s=r.util.fillString(String.fromCharCode(0),c)+s),{encapsulation:t.encrypt(s,'NONE'),key:e.generate(s,i)}},decrypt:function(t,r,a){var n=t.decrypt(r,'NONE');return e.generate(n,a)}};return i},r.kem.kdf1=function(e,t){n(this,e,0,t||e.digestLength)},r.kem.kdf2=function(e,t){n(this,e,1,t||e.digestLength)}}}),Q=o({'node_modules/node-forge/lib/log.js'(e,t){var r=u();p(),t.exports=r.log=r.log||{},r.log.levels=['none','error','warning','info','debug','verbose','max'];var a,n,i,s,o,c,l,h={},f=[],d=null;for(r.log.LEVEL_LOCKED=2,r.log.NO_LEVEL_CHECK=4,r.log.INTERPOLATE=8,i=0;i0){for(var n=a.create(a.Class.CONTEXT_SPECIFIC,1,!0,[]),i=0;i=n&&s0&&s.value[0].value.push(a.create(a.Class.CONTEXT_SPECIFIC,0,!0,t)),i.length>0&&s.value[0].value.push(a.create(a.Class.CONTEXT_SPECIFIC,1,!0,i)),s.value[0].value.push(a.create(a.Class.UNIVERSAL,a.Type.SET,!0,e.signerInfos)),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(e.type).getBytes()),s])},addSigner:function(t){var a=t.issuer,n=t.serialNumber;if(t.certificate){var i=t.certificate;'string'==typeof i&&(i=r.pki.certificateFromPem(i)),a=i.issuer.attributes,n=i.serialNumber}var s=t.key;if(!s)throw new Error('Could not add PKCS#7 signer; no private key specified.');'string'==typeof s&&(s=r.pki.privateKeyFromPem(s));var o=t.digestAlgorithm||r.pki.oids.sha1;switch(o){case r.pki.oids.sha1:case r.pki.oids.sha256:case r.pki.oids.sha384:case r.pki.oids.sha512:case r.pki.oids.md5:break;default:throw new Error('Could not add PKCS#7 signer; unknown message digest algorithm: '+o)}var c=t.authenticatedAttributes||[];if(c.length>0){for(var u=!1,l=!1,p=0;p='8'&&(a='00'+a);var n=r.util.hexToBytes(a);e.putInt32(n.length),e.putBytes(n)}function i(e,t){e.putInt32(t.length),e.putString(t)}function s(){for(var e=r.md.sha1.create(),t=arguments.length,a=0;a>>=1:t=t>>>1^this.crc32b;this.crctable[e]=t}}static getcrc(e,t,r){let a=4294967295;for(let n=t;n>>8^this.crctable[255&(a^e[n])];return~a}static checkcrc(t,r,a,n=0){return e.getcrc(t,r,a)==n}static alloc(t){let r=null;return 0===t&&this.cacheMinCount>0?(r=this.cacheMin.removeHead(),this.cacheMinCount--):1===t&&this.cacheMidCount>0?(r=this.cacheMid.removeHead(),this.cacheMidCount--):2===t&&this.cacheMaxCount>0?(r=this.cacheMax.removeHead(),this.cacheMaxCount--):3===t&&this.cacheBigCount>0?(r=this.cacheBig.removeHead(),this.cacheBigCount--):4===t&&this.cacheHugeCount>0?(r=this.cacheHuge.removeHead(),this.cacheHugeCount--):5===t&&this.cacheUnimaginableCount>0&&(r=this.cacheUnimaginable.removeHead(),this.cacheUnimaginableCount--),null!==r?(r.pos=0,r.bitPos=0,r):new e(0===t?new Uint8Array(100):1===t?new Uint8Array(5e3):2===t?new Uint8Array(3e4):3===t?new Uint8Array(1e5):4===t?new Uint8Array(5e5):5===t?new Uint8Array(2e6):new Uint8Array(t))}static load(t,r=!1){const a=new e(new Uint8Array(fs.readFileSync(t)));return r&&(a.pos=a.data.length),a}static async loadAsync(t,r=!1){const a=new e(new Uint8Array(await(await fetch(t)).arrayBuffer()));return r&&(a.pos=a.data.length),a}static cacheMinCount=0;static cacheMidCount=0;static cacheMaxCount=0;static cacheBigCount=0;static cacheHugeCount=0;static cacheUnimaginableCount=0;static cacheMin=new ee;static cacheMid=new ee;static cacheMax=new ee;static cacheBig=new ee;static cacheHuge=new ee;static cacheUnimaginable=new ee;data;#e;pos;bitPos;constructor(e){super(),this.data=e,this.#e=new DataView(this.data.buffer),this.pos=0,this.bitPos=0}get available(){return this.data.length-this.pos}get length(){return this.data.length}release(){this.pos=0,this.bitPos=0,100===this.data.length&&e.cacheMinCount<1e3?(e.cacheMin.addTail(this),e.cacheMinCount++):5e3===this.data.length&&e.cacheMidCount<250?(e.cacheMid.addTail(this),e.cacheMidCount++):3e4===this.data.length&&e.cacheMaxCount<50?(e.cacheMax.addTail(this),e.cacheMaxCount++):1e5===this.data.length&&e.cacheBigCount<10?(e.cacheBig.addTail(this),e.cacheBigCount++):5e5===this.data.length&&e.cacheHugeCount<5?(e.cacheHuge.addTail(this),e.cacheHugeCount++):2e6===this.data.length&&e.cacheUnimaginableCount<2&&(e.cacheUnimaginable.addTail(this),e.cacheUnimaginableCount++)}save(e,t=this.pos,r=0){if('undefined'==typeof self){const a=path.dirname(e);fs.existsSync(a)||fs.mkdirSync(a,{recursive:!0}),fs.writeFileSync(e,this.data.subarray(r,r+t))}else{const a=new Blob([this.data.subarray(r,r+t)],{type:'application/octet-stream'}),n=URL.createObjectURL(a);self.postMessage({type:'save',value:n,path:e})}}p1(e){this.#e.setUint8(this.pos++,e)}p2(e){this.#e.setUint16(this.pos,e),this.pos+=2}ip2(e){this.#e.setUint16(this.pos,e,!0),this.pos+=2}p3(e){this.#e.setUint8(this.pos++,e>>16),this.#e.setUint16(this.pos,e),this.pos+=2}p4(e){this.#e.setInt32(this.pos,e),this.pos+=4}ip4(e){this.#e.setInt32(this.pos,e,!0),this.pos+=4}p8(e){this.#e.setBigInt64(this.pos,e),this.pos+=8}pbool(e){this.p1(e?1:0)}pjstr(e,t=10){const r=e.length;for(let t=0;t=64)this.p1(e+64);else{if(!(e<16384&&e>=-16384))throw new Error('Error psmarts out of range: '+e);this.p2(e+49152)}}psmart(e){if(e>=0&&e<128)this.p1(e);else{if(!(e>=0&&e<32768))throw new Error('Error psmart out of range: '+e);this.p2(e+32768)}}g1(){return this.#e.getUint8(this.pos++)}g1b(){return this.#e.getInt8(this.pos++)}g2(){return this.pos+=2,this.#e.getUint16(this.pos-2)}g2s(){return this.pos+=2,this.#e.getInt16(this.pos-2)}ig2(){return this.pos+=2,this.#e.getUint16(this.pos-2,!0)}g3(){const e=this.#e.getUint8(this.pos++)<<16|this.#e.getUint16(this.pos);return this.pos+=2,e}g4(){return this.pos+=4,this.#e.getInt32(this.pos-4)}ig4(){return this.pos+=4,this.#e.getInt32(this.pos-4,!0)}g8(){return this.pos+=8,this.#e.getBigInt64(this.pos-8)}gbool(){return 1===this.g1()}gjstr(e=10){const t=this.data.length;let r,a='';for(;(r=this.#e.getUint8(this.pos++))!==e&&this.pos>>3}gBit(t){let r=this.bitPos>>>3,a=8-(7&this.bitPos),n=0;for(this.bitPos+=t;t>a;a=8)n+=(this.#e.getUint8(r++)&e.bitmask[a])<>>a-t&e.bitmask[t],n}pBit(e,t){const r=this.bitPos;this.bitPos+=e;let a=r>>>3,n=8-(7&r);const i=this.#e;for(;e>n;n=8){const r=(1<>>e-n&r),e-=n}const s=n-e,o=(1<=65&&a<=90?t+=BigInt(a+1-65):a>=97&&a<=122?t+=BigInt(a+1-97):a>=48&&a<=57&&(t+=BigInt(a+27-48))}return t}var ie=['_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9'];function se(e){return function(e){if(e<0n||e>=6582952005840035281n)return'invalid_name';if(e%37n===0n)return'invalid_name';let t=0;const r=Array(12);for(;0n!==e;){const a=e;e/=37n,r[11-t++]=ie[Number(a-37n*e)]}return r.slice(12-t).join('')}(ne(e))}var oe=class{queue=[];available=0;buffer=null;offset=0;waiting=0;received(e){this.queue.push(e),this.available+=e.length}clear(){this.queue=[],this.available=0,this.buffer=null,this.offset=0}async readByte(e){if(null===e||e.closed)return 0;if(this.available<1)return await new Promise((e=>setTimeout(e,10))),this.readByte(e);null===this.buffer&&(this.buffer=this.queue.shift()??null,this.offset=0);const t=this.buffer?.[this.offset]??0;return this.offset++,this.available--,this.buffer&&this.offset===this.buffer.length&&(this.buffer=null),t}async readBytes(e,t,r,a,n=!0){if(null===e||e.closed)return 0;if(this.availablesetTimeout(e,10))),this.readBytes(e,t,r,a);a=this.available}t.pos=r;for(let e=0;e{this.socket=net.createConnection({port:de.LOGIN_PORT,host:de.LOGIN_HOST}),this.socket.setNoDelay(!0),this.socket.setTimeout(1e3),this.socket.on('data',(async e=>{this.stream.received(e)})),this.socket.once('close',(()=>{this.disconnect(),e()})),this.socket.once('error',(()=>{this.disconnect(),e()})),this.socket.once('connect',(()=>{e()}))}))}disconnect(){null!==this.socket&&(this.socket.destroy(),this.socket=null,this.stream.clear())}async write(e,t,r=null,a=!0){if(null===e)return;const n=new ae(new Uint8Array(3+(null!==r?r?.length:0)));n.p1(t),null!==r?(n.p2(r.length),n.pdata(r,0,r.length)):n.p2(0);!e.write(n.data)&&a&&await new Promise((t=>{const r=setInterval((()=>{(null===e||e.closed)&&(clearInterval(r),t())}),100);e.once('drain',(()=>{clearInterval(r),t()}))}))}async load(e,t,r){if(await this.connect(),null===this.socket)return{reply:-1,data:null};const a=new ae(new Uint8Array(10+t.length+1+4));a.p2(de.NODE_ID),a.p8(e),a.pjstr(t),a.p4(r),await this.write(this.socket,1,a.data);const n=await this.stream.readByte(this.socket);if(1!==n)return this.disconnect(),{reply:n,data:null};const i=new ae(new Uint8Array(2));await this.stream.readBytes(this.socket,i,0,2);const s=i.g2(),o=new ae(new Uint8Array(s));return await this.stream.readBytes(this.socket,o,0,s),this.disconnect(),{reply:n,data:o}}async save(e,t){if(await this.connect(),null===this.socket)return-1;const r=new ae(new Uint8Array(12+t.length));r.p2(de.NODE_ID),r.p8(e),r.p2(t.length),r.pdata(t,0,t.length),await this.write(this.socket,2,r.data);const a=await this.stream.readByte(this.socket);return this.disconnect(),a}async reset(){if(await this.connect(),null===this.socket)return-1;const e=new ae(new Uint8Array(2));e.p2(de.NODE_ID),await this.write(this.socket,3,e.data),this.disconnect()}async count(e){if(await this.connect(),null===this.socket)return-1;const t=new ae(new Uint8Array(2));t.p2(e),await this.write(this.socket,4,t.data);const r=new ae(new Uint8Array(2));await this.stream.readBytes(this.socket,r,0,2);const a=r.g2();return this.disconnect(),a}async heartbeat(e){if(await this.connect(),null===this.socket)return-1;const t=new ae(new Uint8Array(4+8*e.length));t.p2(de.NODE_ID),t.p2(e.length);for(const r of e)t.p8(r);await this.write(this.socket,5,t.data),this.disconnect()}};if('undefined'==typeof self){if(!parentPort)throw new Error('This file must be run as a worker thread.');fe=Z.default.pki.privateKeyFromPem(fs3.readFileSync('data/config/private.pem','ascii'))}else fe=Z.default.pki.privateKeyFromPem(await(await fetch('data/config/private.pem')).text());'undefined'==typeof self&&parentPort?parentPort.on('message',(async e=>{try{if(!parentPort)throw new Error('This file must be run as a worker thread.');switch(e.type){case'reset':{if(!de.LOGIN_KEY)return;const e=new ge;await e.reset();break}case'heartbeat':{if(!de.LOGIN_KEY)return;const t=new ge;await t.heartbeat(e.players);break}case'loginreq':{const{opcode:t,data:r,socket:a}=e,n=new ae(r);if(225!==n.g1())return void parentPort.postMessage({type:'loginreply',status:ye.SERVER_UPDATED,socket:a});const i=n.g1(),s=new Uint8Array(36);if(n.gdata(s,0,s.length),n.rsadec(fe),10!==n.g1())return void parentPort.postMessage({type:'loginreply',status:ye.LOGIN_REJECTED,socket:a});const o=[];for(let e=0;e<4;e++)o[e]=n.g4();const c=n.g4(),u=n.gjstr(),l=n.gjstr();if(u.length<1||u.length>12)return void parentPort.postMessage({type:'loginreply',status:ye.INVALID_USER_OR_PASS,socket:a});if(de.LOGIN_KEY){if(l.length<5||l.length>20)return void parentPort.postMessage({type:'loginreply',status:ye.INVALID_USER_OR_PASS,socket:a});const e=new ge,r=await e.load(ne(se(u)),l,c);if(1===r.reply&&r.data)parentPort.postMessage({type:'loginreply',status:ye.SUCCESSFUL,socket:a,info:i,seed:o,username:se(u),save:r.data.data});else{if((2===r.reply||3===r.reply)&&16===t)return void parentPort.postMessage({type:'loginreply',status:ye.LOGGED_IN,socket:a});if(3===r.reply&&18===t)return void parentPort.postMessage({type:'loginreply',status:ye.LOGGED_IN,socket:a});if(4!==r.reply)return 5===r.reply?void parentPort.postMessage({type:'loginreply',status:ye.INVALID_USER_OR_PASS,socket:a}):-1===r.reply?void parentPort.postMessage({type:'loginreply',status:ye.LOGIN_SERVER_OFFLINE,socket:a}):void parentPort.postMessage({type:'loginreply',status:ye.LOGIN_REJECTED,socket:a});parentPort.postMessage({type:'loginreply',status:ye.SUCCESSFUL,socket:a,info:i,seed:o,username:se(u),save:new Uint8Array})}}else{let e=new Uint8Array;const t=se(u);fs3.existsSync(`data/players/${t}.sav`)&&(e=await fsp2.readFile(`data/players/${t}.sav`)),parentPort.postMessage({type:'loginreply',status:ye.SUCCESSFUL,socket:a,info:i,seed:o,username:t,save:e})}break}case'logout':{const{username:t,save:r}=e;if(de.LOGIN_KEY){const e=new ge;0===await e.save(ne(t),r)&&parentPort.postMessage({type:'logoutreply',username:t})}else parentPort.postMessage({type:'logoutreply',username:t});break}default:console.error('Unknown message type: '+e.type)}}catch(e){console.error(e)}})):self.onmessage=async e=>{try{switch(e.data.type){case'reset':case'heartbeat':break;case'loginreq':{const{opcode:t,data:r,socket:a}=e.data,n=new ae(r);if(225!==n.g1())return void self.postMessage({type:'loginreply',status:ye.SERVER_UPDATED,socket:a});const i=n.g1(),s=new Uint8Array(36);if(n.gdata(s,0,s.length),n.rsadec(fe),10!==n.g1())return void self.postMessage({type:'loginreply',status:ye.LOGIN_REJECTED,socket:a});const o=[];for(let e=0;e<4;e++)o[e]=n.g4();const c=n.g4(),u=n.gjstr(),l=n.gjstr();if(u.length<1||u.length>12)return void self.postMessage({type:'loginreply',status:ye.INVALID_USER_OR_PASS,socket:a});if(de.LOGIN_KEY){if(l.length<5||l.length>20)return void self.postMessage({type:'loginreply',status:ye.INVALID_USER_OR_PASS,socket:a});const e=new ge,r=await e.load(ne(se(u)),l,c);if(1===r.reply&&r.data)self.postMessage({type:'loginreply',status:ye.SUCCESSFUL,socket:a,info:i,seed:o,username:se(u),save:r.data.data});else{if((2===r.reply||3===r.reply)&&16===t)return void self.postMessage({type:'loginreply',status:ye.LOGGED_IN,socket:a});if(3===r.reply&&18===t)return void self.postMessage({type:'loginreply',status:ye.LOGGED_IN,socket:a});if(4!==r.reply)return 5===r.reply?void self.postMessage({type:'loginreply',status:ye.INVALID_USER_OR_PASS,socket:a}):-1===r.reply?void self.postMessage({type:'loginreply',status:ye.LOGIN_SERVER_OFFLINE,socket:a}):void self.postMessage({type:'loginreply',status:ye.LOGIN_REJECTED,socket:a});self.postMessage({type:'loginreply',status:ye.SUCCESSFUL,socket:a,info:i,seed:o,username:se(u),save:new Uint8Array})}}else{let e=new Uint8Array;const t=se(u),r=new URL(`data/players/${t}.sav`,self.location.origin);(await fetch(r)).ok&&(e=new Uint8Array(await(await fetch(r)).arrayBuffer())),self.postMessage({type:'loginreply',status:ye.SUCCESSFUL,socket:a,info:i,seed:o,username:t,save:e})}break}case'logout':{const{username:t,save:r}=e.data;if(de.LOGIN_KEY){const e=new ge;0===await e.save(ne(t),r)&&self.postMessage({type:'logoutreply',username:t})}else self.postMessage({type:'logoutreply',username:t});break}default:console.error('Unknown message type: '+e.data.type)}}catch(e){console.error(e)}}; \ No newline at end of file diff --git a/LoginThread.js.LICENSE.txt b/LoginThread.js.LICENSE.txt deleted file mode 100644 index 4b2642b7..00000000 --- a/LoginThread.js.LICENSE.txt +++ /dev/null @@ -1,10 +0,0 @@ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ - -/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ - -/*! safe-buffer. MIT License. Feross Aboukhadijeh */ diff --git a/worker.js b/worker.js index 22eb812f..c6b45a11 100644 --- a/worker.js +++ b/worker.js @@ -1,2 +1 @@ -/*! For license information please see worker.js.LICENSE.txt */ -var t,e,r,i,n,s,a,o,h,l,c,u,d,f,p=Object.create,m=Object.defineProperty,g=Object.getPrototypeOf,y=Object.getOwnPropertyNames,v=Object.getOwnPropertyDescriptor,b=Object.prototype.hasOwnProperty,_=t=>{const e=_.moduleCache??=new WeakMap;var r=e.get(t);if(r)return r;var i=m({},'__esModule',{value:!0}),n={enumerable:!1};if(t&&'object'==typeof t||'function'==typeof t)for(let e of y(t))b.call(i,e)||m(i,e,{get:()=>t[e],enumerable:!(n=v(t,e))||n.enumerable});return e.set(t,i),i},w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),E=(t,e)=>{for(var r in e)m(t,r,{get:e[r],enumerable:!0,configurable:!0,set:t=>e[r]=()=>t})},A=(t,e)=>()=>(t&&(e=t(t=0)),e),S=(t=function(t){if('undefined'!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')},'undefined'!=typeof require?require:'undefined'!=typeof Proxy&&new Proxy(t,{get:(t,e)=>('undefined'!=typeof require?require:t)[e]}),{});E(S,{default:()=>f});var T,M,I,C,O,N,L,R,P,B,k,D,U,x,F,H,j,V,G,z,W,K,q,Y,Z,$,X,Q,J,tt,et,rt,it,nt,st,at,ot,ht,lt,ct,ut,dt,ft,pt,mt,gt,yt,vt,bt,_t,wt,Et,At,St,Tt,Mt,It,Ct,Ot,Nt,Lt,Rt,Pt,Bt,kt,Dt,Ut,xt,Ft,Ht,jt,Vt,Gt,zt,Wt,Kt,qt,Yt,Zt,$t,Xt,Qt,Jt,te,ee,re,ie,ne,se,ae,oe,he,le,ce,ue,de,fe,pe,me,ge,ye,ve,be,_e,we,Ee,Ae,Se,Te,Me,Ie,Ce,Oe,Ne,Le,Re,Pe,Be,ke,De,Ue,xe,Fe,He,je,Ve,Ge,ze,We,Ke,qe,Ye,Ze,$e,Xe,Qe,Je,tr,er,rr,ir,nr,sr,ar,or,hr,lr,cr,ur,dr,fr,pr,mr,gr,yr,vr,br,_r,wr,Er,Ar,Sr,Tr,Mr,Ir,Cr,Or,Nr,Lr,Rr,Pr,Br,kr,Dr,Ur,xr,Fr,Hr,jr,Vr,Gr,zr,Wr,Kr,qr,Yr,Zr,$r,Xr,Qr,Jr,ti,ei,ri,ii,ni,si,ai,oi,hi,li,ci,ui,di,fi,pi,mi,gi,yi,vi,bi,_i,wi,Ei,Ai,Si,Ti,Mi,Ii,Ci,Oi,Ni,Li,Ri,Pi,Bi,ki,Di,Ui,xi,Fi,Hi,ji=A((()=>{e=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(t,e)=>{for(var i in e)r(t,i,{get:e[i],enumerable:!0})},h=(t,e,s,o)=>{if(e&&'object'==typeof e||'function'==typeof e)for(let h of n(e))!a.call(t,h)&&h!==s&&r(t,h,{get:()=>e[h],enumerable:!(o=i(e,h))||o.enumerable});return t},l=(t,e,r)=>(h(t,e,'default'),r&&h(r,e,'default')),c=(t,i,n)=>(n=null!=t?e(s(t)):{},h(!i&&t&&t.__esModule?n:r(n,'default',{value:t,enumerable:!0}),t)),u=((t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports))(((t,e)=>{function r(t){if('string'!=typeof t)throw new TypeError('Path must be a string. Received '+JSON.stringify(t))}function i(t,e){for(var r,i='',n=0,s=-1,a=0,o=0;o<=t.length;++o){if(o2){var h=i.lastIndexOf('/');if(h!==i.length-1){-1===h?(i='',n=0):n=(i=i.slice(0,h)).length-1-i.lastIndexOf('/'),s=o,a=0;continue}}else if(2===i.length||1===i.length){i='',n=0,s=o,a=0;continue}e&&(i.length>0?i+='/..':i='..',n=2)}else i.length>0?i+='/'+t.slice(s+1,o):i=t.slice(s+1,o),n=o-s-1;s=o,a=0}else 46===r&&-1!==a?++a:a=-1}return i}var n={resolve:function(){for(var t,e='',n=!1,s=arguments.length-1;s>=-1&&!n;s--){var a;s>=0?a=arguments[s]:(void 0===t&&(t=process.cwd()),a=t),r(a),0!==a.length&&(e=a+'/'+e,n=47===a.charCodeAt(0))}return e=i(e,!n),n?e.length>0?'/'+e:'/':e.length>0?e:'.'},normalize:function(t){if(r(t),0===t.length)return'.';var e=47===t.charCodeAt(0),n=47===t.charCodeAt(t.length-1);return 0===(t=i(t,!e)).length&&!e&&(t='.'),t.length>0&&n&&(t+='/'),e?'/'+t:t},isAbsolute:function(t){return r(t),t.length>0&&47===t.charCodeAt(0)},join:function(){if(0===arguments.length)return'.';for(var t,e=0;e0&&(void 0===t?t=i:t+='/'+i)}return void 0===t?'.':n.normalize(t)},relative:function(t,e){if(r(t),r(e),t===e||(t=n.resolve(t))===(e=n.resolve(e)))return'';for(var i=1;il){if(47===e.charCodeAt(o+u))return e.slice(o+u+1);if(0===u)return e.slice(o+u)}else a>l&&(47===t.charCodeAt(i+u)?c=u:0===u&&(c=0));break}var d=t.charCodeAt(i+u);if(d!==e.charCodeAt(o+u))break;47===d&&(c=u)}var f='';for(u=i+c+1;u<=s;++u)(u===s||47===t.charCodeAt(u))&&(0===f.length?f+='..':f+='/..');return f.length>0?f+e.slice(o+c):(o+=c,47===e.charCodeAt(o)&&++o,e.slice(o))},_makeLong:function(t){return t},dirname:function(t){if(r(t),0===t.length)return'.';for(var e=t.charCodeAt(0),i=47===e,n=-1,s=!0,a=t.length-1;a>=1;--a)if(47===(e=t.charCodeAt(a))){if(!s){n=a;break}}else s=!1;return-1===n?i?'/':'.':i&&1===n?'//':t.slice(0,n)},basename:function(t,e){if(void 0!==e&&'string'!=typeof e)throw new TypeError('"ext" argument must be a string');r(t);var i,n=0,s=-1,a=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return'';var o=e.length-1,h=-1;for(i=t.length-1;i>=0;--i){var l=t.charCodeAt(i);if(47===l){if(!a){n=i+1;break}}else-1===h&&(a=!1,h=i+1),o>=0&&(l===e.charCodeAt(o)?-1==--o&&(s=i):(o=-1,s=h))}return n===s?s=h:-1===s&&(s=t.length),t.slice(n,s)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!a){n=i+1;break}}else-1===s&&(a=!1,s=i+1);return-1===s?'':t.slice(n,s)},extname:function(t){r(t);for(var e=-1,i=0,n=-1,s=!0,a=0,o=t.length-1;o>=0;--o){var h=t.charCodeAt(o);if(47!==h)-1===n&&(s=!1,n=o+1),46===h?-1===e?e=o:1!==a&&(a=1):-1!==e&&(a=-1);else if(!s){i=o+1;break}}return-1===e||-1===n||0===a||1===a&&e===n-1&&e===i+1?'':t.slice(e,n)},format:function(t){if(null===t||'object'!=typeof t)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return function(t,e){var r=e.dir||e.root,i=e.base||(e.name||'')+(e.ext||'');return r?r===e.root?r+i:r+t+i:i}('/',t)},parse:function(t){r(t);var e={root:'',dir:'',base:'',ext:'',name:''};if(0===t.length)return e;var i,n=t.charCodeAt(0),s=47===n;s?(e.root='/',i=1):i=0;for(var a=-1,o=0,h=-1,l=!0,c=t.length-1,u=0;c>=i;--c)if(47!==(n=t.charCodeAt(c)))-1===h&&(l=!1,h=c+1),46===n?-1===a?a=c:1!==u&&(u=1):-1!==a&&(u=-1);else if(!l){o=c+1;break}return-1===a||-1===h||0===u||1===u&&a===h-1&&a===o+1?-1!==h&&(e.base=e.name=0===o&&s?t.slice(1,h):t.slice(o,h)):(0===o&&s?(e.name=t.slice(1,a),e.base=t.slice(1,h)):(e.name=t.slice(o,a),e.base=t.slice(o,h)),e.ext=t.slice(a,h)),o>0?e.dir=t.slice(0,o-1):s&&(e.dir='/'),e},sep:'/',delimiter:':',win32:null,posix:null};n.posix=n,e.exports=n})),o(d={},{default:()=>f}),l(d,c(u())),f=c(u())})),Vi=w(((t,e)=>{e.exports={options:{usePureJavaScript:!1}}})),Gi=w(((t,e)=>{var r={};e.exports=r;var i={};r.encode=function(t,e,r){if('string'!=typeof e)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&'number'!=typeof r)throw new TypeError('"maxline" must be a number.');var i='';if(t instanceof Uint8Array){var n=0,s=e.length,a=e.charAt(0),o=[0];for(n=0;n0;)o.push(l%s),l=l/s|0}for(n=0;0===t[n]&&n=0;--n)i+=e[o[n]]}else i=function(t,e){var r=0,i=e.length,n=e.charAt(0),s=[0];for(r=0;r0;)s.push(o%i),o=o/i|0}var h='';for(r=0;0===t.at(r)&&r=0;--r)h+=e[s[r]];return h}(t,e);if(r){var c=new RegExp('.{1,'+r+'}','g');i=i.match(c).join('\r\n')}return i},r.decode=function(t,e){if('string'!=typeof t)throw new TypeError('"input" must be a string.');if('string'!=typeof e)throw new TypeError('"alphabet" must be a string.');var r=i[e];if(!r){r=i[e]=[];for(var n=0;n>=8;for(;c>0;)o.push(255&c),c>>=8}for(var u=0;t[u]===a&&u{var r=function(t){if(8!==t&&16!==t&&24!==t&&32!==t)throw new Error('Only 8, 16, 24, or 32 bits supported: '+t)},i=function(t){if(this.data='',this.read=0,'string'==typeof t)this.data=t;else if(a.isArrayBuffer(t)||a.isArrayBufferView(t))if('undefined'!=typeof Buffer&&t instanceof Buffer)this.data=t.toString('binary');else{var e=new Uint8Array(t);try{this.data=String.fromCharCode.apply(null,e)}catch(t){for(var r=0;r15?(r=Date.now(),s(t)):(e.push(t),1===e.length&&n.setAttribute('a',i=!i))}}a.nextTick=a.setImmediate}(),a.isNodejs='undefined'!=typeof process&&process.versions&&process.versions.node,a.globalScope=a.isNodejs?global:'undefined'==typeof self?window:self,a.isArray=Array.isArray||function(t){return'[object Array]'===Object.prototype.toString.call(t)},a.isArrayBuffer=function(t){return'undefined'!=typeof ArrayBuffer&&t instanceof ArrayBuffer},a.isArrayBufferView=function(t){return t&&a.isArrayBuffer(t.buffer)&&void 0!==t.byteLength},a.ByteBuffer=i,a.ByteStringBuffer=i;a.ByteStringBuffer.prototype._optimizeConstructedString=function(t){this._constructedStringLength+=t,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},a.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},a.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},a.ByteStringBuffer.prototype.putByte=function(t){return this.putBytes(String.fromCharCode(t))},a.ByteStringBuffer.prototype.fillWithByte=function(t,e){t=String.fromCharCode(t);for(var r=this.data;e>0;)1&e&&(r+=t),(e>>>=1)>0&&(t+=t);return this.data=r,this._optimizeConstructedString(e),this},a.ByteStringBuffer.prototype.putBytes=function(t){return this.data+=t,this._optimizeConstructedString(t.length),this},a.ByteStringBuffer.prototype.putString=function(t){return this.putBytes(a.encodeUtf8(t))},a.ByteStringBuffer.prototype.putInt16=function(t){return this.putBytes(String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},a.ByteStringBuffer.prototype.putInt24=function(t){return this.putBytes(String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},a.ByteStringBuffer.prototype.putInt32=function(t){return this.putBytes(String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t))},a.ByteStringBuffer.prototype.putInt16Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255))},a.ByteStringBuffer.prototype.putInt24Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255))},a.ByteStringBuffer.prototype.putInt32Le=function(t){return this.putBytes(String.fromCharCode(255&t)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>24&255))},a.ByteStringBuffer.prototype.putInt=function(t,e){r(e);var i='';do{e-=8,i+=String.fromCharCode(t>>e&255)}while(e>0);return this.putBytes(i)},a.ByteStringBuffer.prototype.putSignedInt=function(t,e){return t<0&&(t+=2<0);return e},a.ByteStringBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<=r&&(e-=r<<1),e},a.ByteStringBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):0===t?e='':(e=0===this.read?this.data:this.data.slice(this.read),this.clear()),e},a.ByteStringBuffer.prototype.bytes=function(t){return void 0===t?this.data.slice(this.read):this.data.slice(this.read,this.read+t)},a.ByteStringBuffer.prototype.at=function(t){return this.data.charCodeAt(this.read+t)},a.ByteStringBuffer.prototype.setAt=function(t,e){return this.data=this.data.substr(0,this.read+t)+String.fromCharCode(e)+this.data.substr(this.read+t+1),this},a.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},a.ByteStringBuffer.prototype.copy=function(){var t=a.createBuffer(this.data);return t.read=this.read,t},a.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},a.ByteStringBuffer.prototype.clear=function(){return this.data='',this.read=0,this},a.ByteStringBuffer.prototype.truncate=function(t){var e=Math.max(0,this.length()-t);return this.data=this.data.substr(this.read,e),this.read=0,this},a.ByteStringBuffer.prototype.toHex=function(){for(var t='',e=this.read;e=t)return this;e=Math.max(e||this.growSize,t);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),i=new Uint8Array(this.length()+e);return i.set(r),this.data=new DataView(i.buffer),this},a.DataBuffer.prototype.putByte=function(t){return this.accommodate(1),this.data.setUint8(this.write++,t),this},a.DataBuffer.prototype.fillWithByte=function(t,e){this.accommodate(e);for(var r=0;r>8&65535),this.data.setInt8(this.write,t>>16&255),this.write+=3,this},a.DataBuffer.prototype.putInt32=function(t){return this.accommodate(4),this.data.setInt32(this.write,t),this.write+=4,this},a.DataBuffer.prototype.putInt16Le=function(t){return this.accommodate(2),this.data.setInt16(this.write,t,!0),this.write+=2,this},a.DataBuffer.prototype.putInt24Le=function(t){return this.accommodate(3),this.data.setInt8(this.write,t>>16&255),this.data.setInt16(this.write,t>>8&65535,!0),this.write+=3,this},a.DataBuffer.prototype.putInt32Le=function(t){return this.accommodate(4),this.data.setInt32(this.write,t,!0),this.write+=4,this},a.DataBuffer.prototype.putInt=function(t,e){r(e),this.accommodate(e/8);do{e-=8,this.data.setInt8(this.write++,t>>e&255)}while(e>0);return this},a.DataBuffer.prototype.putSignedInt=function(t,e){return r(e),this.accommodate(e/8),t<0&&(t+=2<0);return e},a.DataBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<=r&&(e-=r<<1),e},a.DataBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):0===t?e='':(e=0===this.read?this.data:this.data.slice(this.read),this.clear()),e},a.DataBuffer.prototype.bytes=function(t){return void 0===t?this.data.slice(this.read):this.data.slice(this.read,this.read+t)},a.DataBuffer.prototype.at=function(t){return this.data.getUint8(this.read+t)},a.DataBuffer.prototype.setAt=function(t,e){return this.data.setUint8(t,e),this},a.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},a.DataBuffer.prototype.copy=function(){return new a.DataBuffer(this)},a.DataBuffer.prototype.compact=function(){if(this.read>0){var t=new Uint8Array(this.data.buffer,this.read),e=new Uint8Array(t.byteLength);e.set(t),this.data=new DataView(e),this.write-=this.read,this.read=0}return this},a.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},a.DataBuffer.prototype.truncate=function(t){return this.write=Math.max(0,this.length()-t),this.read=Math.min(this.read,this.write),this},a.DataBuffer.prototype.toHex=function(){for(var t='',e=this.read;e0;)1&e&&(r+=t),(e>>>=1)>0&&(t+=t);return r},a.xorBytes=function(t,e,r){for(var i='',n='',s='',a=0,o=0;r>0;--r,++a)n=t.charCodeAt(a)^e.charCodeAt(a),o>=10&&(i+=s,s='',o=0),s+=String.fromCharCode(n),++o;return i+=s},a.hexToBytes=function(t){var e='',r=0;for(!0&t.length&&(r=1,e+=String.fromCharCode(parseInt(t[0],16)));r>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t)};var o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',h=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],l='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';a.encode64=function(t,e){for(var r,i,n,s='',a='',h=0;h>2),s+=o.charAt((3&r)<<4|i>>4),isNaN(i)?s+='==':(s+=o.charAt((15&i)<<2|n>>6),s+=isNaN(n)?'=':o.charAt(63&n)),e&&s.length>e&&(a+=s.substr(0,e)+'\r\n',s=s.substr(e));return a+=s},a.decode64=function(t){t=t.replace(/[^A-Za-z0-9\+\/\=]/g,'');for(var e,r,i,n,s='',a=0;a>4),64!==i&&(s+=String.fromCharCode((15&r)<<4|i>>2),64!==n&&(s+=String.fromCharCode((3&i)<<6|n)));return s},a.encodeUtf8=function(t){return unescape(encodeURIComponent(t))},a.decodeUtf8=function(t){return decodeURIComponent(escape(t))},a.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:s.encode,decode:s.decode}},a.binary.raw.encode=function(t){return String.fromCharCode.apply(null,t)},a.binary.raw.decode=function(t,e,r){var i=e;i||(i=new Uint8Array(t.length));for(var n=r=r||0,s=0;s>2),s+=o.charAt((3&r)<<4|i>>4),isNaN(i)?s+='==':(s+=o.charAt((15&i)<<2|n>>6),s+=isNaN(n)?'=':o.charAt(63&n)),e&&s.length>e&&(a+=s.substr(0,e)+'\r\n',s=s.substr(e));return a+=s},a.binary.base64.decode=function(t,e,r){var i,n,s,a,o=e;o||(o=new Uint8Array(3*Math.ceil(t.length/4))),t=t.replace(/[^A-Za-z0-9\+\/\=]/g,'');for(var l=0,c=r=r||0;l>4,64!==s&&(o[c++]=(15&n)<<4|s>>2,64!==a&&(o[c++]=(3&s)<<6|a));return e?c-r:o.subarray(0,c)},a.binary.base58.encode=function(t,e){return a.binary.baseN.encode(t,l,e)},a.binary.base58.decode=function(t,e){return a.binary.baseN.decode(t,l,e)},a.text={utf8:{},utf16:{}},a.text.utf8.encode=function(t,e,r){t=a.encodeUtf8(t);var i=e;i||(i=new Uint8Array(t.length));for(var n=r=r||0,s=0;s0&&s.push(r),a=i.lastIndex;var o=e[0][1];switch(o){case's':case'o':n');break;case'%':s.push('%');break;default:s.push('<%'+o+'?>')}}return s.push(t.substring(a)),s.join('')},a.formatNumber=function(t,e,r,i){var n=t,s=isNaN(e=Math.abs(e))?2:e,a=void 0===r?',':r,o=void 0===i?'.':i,h=n<0?'-':'',l=parseInt(n=Math.abs(+n||0).toFixed(s),10)+'',c=l.length>3?l.length%3:0;return h+(c?l.substr(0,c)+o:'')+l.substr(c).replace(/(\d{3})(?=\d)/g,'$1'+o)+(s?a+Math.abs(n-l).toFixed(s).slice(2):'')},a.formatSize=function(t){return t=t>=1073741824?a.formatNumber(t/1073741824,2,'.','')+' GiB':t>=1048576?a.formatNumber(t/1048576,2,'.','')+' MiB':t>=1024?a.formatNumber(t/1024,0)+' KiB':a.formatNumber(t,0)+' bytes'},a.bytesFromIP=function(t){return-1!==t.indexOf('.')?a.bytesFromIPv4(t):-1!==t.indexOf(':')?a.bytesFromIPv6(t):null},a.bytesFromIPv4=function(t){if(4!==(t=t.split('.')).length)return null;for(var e=a.createBuffer(),r=0;rr[i].end-r[i].start&&(i=r.length-1)):r.push({start:h,end:h})}e.push(s)}if(r.length>0){var l=r[i];l.end-l.start>0&&(e.splice(l.start,l.end-l.start+1,''),0===l.start&&e.unshift(''),7===l.end&&e.push(''))}return e.join(':')},a.estimateCores=function(t,e){if('function'==typeof t&&(e=t,t={}),t=t||{},'cores'in a&&!t.update)return e(null,a.cores);if('undefined'!=typeof navigator&&'hardwareConcurrency'in navigator&&navigator.hardwareConcurrency>0)return a.cores=navigator.hardwareConcurrency,e(null,a.cores);if('undefined'==typeof Worker)return a.cores=1,e(null,a.cores);if('undefined'==typeof Blob)return a.cores=2,e(null,a.cores);var r=URL.createObjectURL(new Blob(['(',function(){self.addEventListener('message',(function(t){for(var e=Date.now(),r=e+4;Date.now()o.st&&n.stn.st&&o.st{var r=Vi();zi(),e.exports=r.cipher=r.cipher||{},r.cipher.algorithms=r.cipher.algorithms||{},r.cipher.createCipher=function(t,e){var i=t;if('string'==typeof i&&(i=r.cipher.getAlgorithm(i))&&(i=i()),!i)throw new Error('Unsupported algorithm: '+t);return new r.cipher.BlockCipher({algorithm:i,key:e,decrypt:!1})},r.cipher.createDecipher=function(t,e){var i=t;if('string'==typeof i&&(i=r.cipher.getAlgorithm(i))&&(i=i()),!i)throw new Error('Unsupported algorithm: '+t);return new r.cipher.BlockCipher({algorithm:i,key:e,decrypt:!0})},r.cipher.registerAlgorithm=function(t,e){t=t.toUpperCase(),r.cipher.algorithms[t]=e},r.cipher.getAlgorithm=function(t){return(t=t.toUpperCase())in r.cipher.algorithms?r.cipher.algorithms[t]:null};var i=r.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};i.prototype.start=function(t){t=t||{};var e={};for(var i in t)e[i]=t[i];e.decrypt=this._decrypt,this._finish=!1,this._input=r.util.createBuffer(),this.output=t.output||r.util.createBuffer(),this.mode.start(e)},i.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(t){!t||'ECB'!==this.mode.name&&'CBC'!==this.mode.name||(this.mode.pad=function(e){return t(this.blockSize,e,!1)},this.mode.unpad=function(e){return t(this.blockSize,e,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,e)))}})),Ki=w(((t,e)=>{var r=function(t,e){if('string'==typeof t&&(t=s.util.createBuffer(t)),s.util.isArray(t)&&t.length>4){var r=t;t=s.util.createBuffer();for(var i=0;i0))return!0;for(var i=0;i0))return!0;for(var i=0;i0)return!1;var r=t.length(),i=t.at(r-1);return!(i>this.blockSize<<2)&&(t.truncate(i),!0)},a.cbc=function(t){t=t||{},this.name='CBC',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},a.cbc.prototype.start=function(t){if(null===t.iv){if(!this._prev)throw new Error('Invalid IV parameter.');this._iv=this._prev.slice(0)}else{if(!('iv'in t))throw new Error('Invalid IV parameter.');this._iv=r(t.iv,this.blockSize),this._prev=this._iv.slice(0)}},a.cbc.prototype.encrypt=function(t,e,r){if(t.length()0))return!0;for(var i=0;i0))return!0;for(var i=0;i0)return!1;var r=t.length(),i=t.at(r-1);return!(i>this.blockSize<<2)&&(t.truncate(i),!0)},a.cfb=function(t){t=t||{},this.name='CFB',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0},a.cfb.prototype.start=function(t){if(!('iv'in t))throw new Error('Invalid IV parameter.');this._iv=r(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},a.cfb.prototype.encrypt=function(t,e,r){var i=t.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0)t.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}},a.cfb.prototype.decrypt=function(t,e,r){var i=t.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0)t.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}},a.ofb=function(t){t=t||{},this.name='OFB',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0},a.ofb.prototype.start=function(t){if(!('iv'in t))throw new Error('Invalid IV parameter.');this._iv=r(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},a.ofb.prototype.encrypt=function(t,e,r){var i=t.length();if(0===t.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0)t.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}},a.ofb.prototype.decrypt=a.ofb.prototype.encrypt,a.ctr=function(t){t=t||{},this.name='CTR',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0},a.ctr.prototype.start=function(t){if(!('iv'in t))throw new Error('Invalid IV parameter.');this._iv=r(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},a.ctr.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var s=0;s0&&(a=this.blockSize-a),this._partialOutput.clear();for(s=0;s0&&(t.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}i(this._inBlock)},a.ctr.prototype.decrypt=a.ctr.prototype.encrypt,a.gcm=function(t){t=t||{},this.name='GCM',this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0,this._R=3774873600},a.gcm.prototype.start=function(t){if(!('iv'in t))throw new Error('Invalid IV parameter.');var e,r=s.util.createBuffer(t.iv);if(this._cipherLength=0,e='additionalData'in t?s.util.createBuffer(t.additionalData):s.util.createBuffer(),this._tagLength='tagLength'in t?t.tagLength:128,this._tag=null,t.decrypt&&(this._tag=s.util.createBuffer(t.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error('Authentication tag does not match tag length.');this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var a=r.length();if(12===a)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(n(8*a)))}this._inBlock=this._j0.slice(0),i(this._inBlock),this._partialBytes=0,e=s.util.createBuffer(e),this._aDataLength=n(8*e.length());var o=e.length()%this.blockSize;for(o&&e.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];e.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[e.getInt32(),e.getInt32(),e.getInt32(),e.getInt32()])},a.gcm.prototype.encrypt=function(t,e,r){var n=t.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var s=0;s0&&(a=this.blockSize-a),this._partialOutput.clear();for(s=0;s0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.read-=this.blockSize,e.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),i(this._inBlock)},a.gcm.prototype.decrypt=function(t,e,r){var n=t.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),i(this._inBlock),this._hashBlock[0]=t.getInt32(),this._hashBlock[1]=t.getInt32(),this._hashBlock[2]=t.getInt32(),this._hashBlock[3]=t.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var s=0;s0;--i)e[i]=t[i]>>>1|(1&t[i-1])<<31;e[0]=t[0]>>>1,r&&(e[0]^=this._R)},a.gcm.prototype.tableMultiply=function(t){for(var e=[0,0,0,0],r=0;r<32;++r){var i=t[r/8|0]>>>4*(7-r%8)&15,n=this._m[r][i];e[0]^=n[0],e[1]^=n[1],e[2]^=n[2],e[3]^=n[3]}return e},a.gcm.prototype.ghash=function(t,e,r){return e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3],this.tableMultiply(e)},a.gcm.prototype.generateHashTable=function(t,e){for(var r=8/e,i=4*r,n=16*r,s=new Array(n),a=0;a>>1,n=new Array(r);n[i]=t.slice(0);for(var s=i>>>1;s>0;)this.pow(n[2*s],n[s]=[]),s>>=1;for(s=2;s{var r=function(t,e){o.cipher.registerAlgorithm(t,(function(){return new o.aes.Algorithm(t,e)}))},i=function(){f=!0,c=[0,1,2,4,8,16,32,64,128,27,54];for(var t=new Array(256),e=0;e<128;++e)t[e]=e<<1,t[e+128]=e+128<<1^283;h=new Array(256),l=new Array(256),u=new Array(4),d=new Array(4);for(e=0;e<4;++e)u[e]=new Array(256),d[e]=new Array(256);var r,i,n,s,a,o,p,m=0,g=0;for(e=0;e<256;++e){s=(s=g^g<<1^g<<2^g<<3^g<<4)>>8^255&s^99,h[m]=s,l[s]=m,o=(a=t[s])<<24^s<<16^s<<8^s^a,p=((r=t[m])^(i=t[r])^(n=t[i]))<<24^(m^n)<<16^(m^i^n)<<8^m^r^n;for(var y=0;y<4;++y)u[y][m]=o,d[y][s]=p,o=o<<24|o>>>8,p=p<<24|p>>>8;0===m?m=g=1:(m=r^t[t[t[r^n]]],g^=t[t[g]])}},n=function(t,e){for(var r,i=t.slice(0),n=1,s=i.length,a=p*(s+6+1),o=s;o>>16&255]<<24^h[r>>>8&255]<<16^h[255&r]<<8^h[r>>>24]^c[n]<<24,n++):s>6&&o%s==4&&(r=h[r>>>24]<<24^h[r>>>16&255]<<16^h[r>>>8&255]<<8^h[255&r]),i[o]=i[o-s]^r;if(e){for(var l,u=d[0],f=d[1],m=d[2],g=d[3],y=i.slice(0),v=(o=0,(a=i.length)-p);o>>24]]^f[h[l>>>16&255]]^m[h[l>>>8&255]]^g[h[255&l]];i=y}return i},s=function(t,e,r,i){var n,s,a,o,c,f,p,m,g,y,v,b,_=t.length/4-1;i?(n=d[0],s=d[1],a=d[2],o=d[3],c=l):(n=u[0],s=u[1],a=u[2],o=u[3],c=h),f=e[0]^t[0],p=e[i?3:1]^t[1],m=e[2]^t[2],g=e[i?1:3]^t[3];for(var w=3,E=1;E<_;++E)y=n[f>>>24]^s[p>>>16&255]^a[m>>>8&255]^o[255&g]^t[++w],v=n[p>>>24]^s[m>>>16&255]^a[g>>>8&255]^o[255&f]^t[++w],b=n[m>>>24]^s[g>>>16&255]^a[f>>>8&255]^o[255&p]^t[++w],g=n[g>>>24]^s[f>>>16&255]^a[p>>>8&255]^o[255&m]^t[++w],f=y,p=v,m=b;r[0]=c[f>>>24]<<24^c[p>>>16&255]<<16^c[m>>>8&255]<<8^c[255&g]^t[++w],r[i?3:1]=c[p>>>24]<<24^c[m>>>16&255]<<16^c[g>>>8&255]<<8^c[255&f]^t[++w],r[2]=c[m>>>24]<<24^c[g>>>16&255]<<16^c[f>>>8&255]<<8^c[255&p]^t[++w],r[i?1:3]=c[g>>>24]<<24^c[f>>>16&255]<<16^c[p>>>8&255]<<8^c[255&m]^t[++w]},a=function(t){var e,r='AES-'+((t=t||{}).mode||'CBC').toUpperCase(),i=(e=t.decrypt?o.cipher.createDecipher(r,t.key):o.cipher.createCipher(r,t.key)).start;return e.start=function(t,r){var n=null;r instanceof o.util.ByteBuffer&&(n=r,r={}),(r=r||{}).output=n,r.iv=t,i.call(e,r)},e},o=Vi();Wi(),Ki(),zi(),e.exports=o.aes=o.aes||{},o.aes.startEncrypting=function(t,e,r,i){var n=a({key:t,output:r,decrypt:!1,mode:i});return n.start(e),n},o.aes.createEncryptionCipher=function(t,e){return a({key:t,output:null,decrypt:!1,mode:e})},o.aes.startDecrypting=function(t,e,r,i){var n=a({key:t,output:r,decrypt:!0,mode:i});return n.start(e),n},o.aes.createDecryptionCipher=function(t,e){return a({key:t,output:null,decrypt:!0,mode:e})},o.aes.Algorithm=function(t,e){f||i();var r=this;r.name=t,r.mode=new e({blockSize:16,cipher:{encrypt:function(t,e){return s(r._w,t,e,!1)},decrypt:function(t,e){return s(r._w,t,e,!0)}}}),r._init=!1},o.aes.Algorithm.prototype.initialize=function(t){if(!this._init){var e,r=t.key;if('string'!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(o.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){e=r,r=o.util.createBuffer();for(var i=0;i>>=2;for(i=0;i{var r=function(t,e){s[t]=e,s[e]=t},i=function(t,e){s[t]=e},n=Vi();n.pki=n.pki||{};var s=e.exports=n.pki.oids=n.oids=n.oids||{};r('1.2.840.113549.1.1.1','rsaEncryption'),r('1.2.840.113549.1.1.4','md5WithRSAEncryption'),r('1.2.840.113549.1.1.5','sha1WithRSAEncryption'),r('1.2.840.113549.1.1.7','RSAES-OAEP'),r('1.2.840.113549.1.1.8','mgf1'),r('1.2.840.113549.1.1.9','pSpecified'),r('1.2.840.113549.1.1.10','RSASSA-PSS'),r('1.2.840.113549.1.1.11','sha256WithRSAEncryption'),r('1.2.840.113549.1.1.12','sha384WithRSAEncryption'),r('1.2.840.113549.1.1.13','sha512WithRSAEncryption'),r('1.3.101.112','EdDSA25519'),r('1.2.840.10040.4.3','dsa-with-sha1'),r('1.3.14.3.2.7','desCBC'),r('1.3.14.3.2.26','sha1'),r('1.3.14.3.2.29','sha1WithRSASignature'),r('2.16.840.1.101.3.4.2.1','sha256'),r('2.16.840.1.101.3.4.2.2','sha384'),r('2.16.840.1.101.3.4.2.3','sha512'),r('2.16.840.1.101.3.4.2.4','sha224'),r('2.16.840.1.101.3.4.2.5','sha512-224'),r('2.16.840.1.101.3.4.2.6','sha512-256'),r('1.2.840.113549.2.2','md2'),r('1.2.840.113549.2.5','md5'),r('1.2.840.113549.1.7.1','data'),r('1.2.840.113549.1.7.2','signedData'),r('1.2.840.113549.1.7.3','envelopedData'),r('1.2.840.113549.1.7.4','signedAndEnvelopedData'),r('1.2.840.113549.1.7.5','digestedData'),r('1.2.840.113549.1.7.6','encryptedData'),r('1.2.840.113549.1.9.1','emailAddress'),r('1.2.840.113549.1.9.2','unstructuredName'),r('1.2.840.113549.1.9.3','contentType'),r('1.2.840.113549.1.9.4','messageDigest'),r('1.2.840.113549.1.9.5','signingTime'),r('1.2.840.113549.1.9.6','counterSignature'),r('1.2.840.113549.1.9.7','challengePassword'),r('1.2.840.113549.1.9.8','unstructuredAddress'),r('1.2.840.113549.1.9.14','extensionRequest'),r('1.2.840.113549.1.9.20','friendlyName'),r('1.2.840.113549.1.9.21','localKeyId'),r('1.2.840.113549.1.9.22.1','x509Certificate'),r('1.2.840.113549.1.12.10.1.1','keyBag'),r('1.2.840.113549.1.12.10.1.2','pkcs8ShroudedKeyBag'),r('1.2.840.113549.1.12.10.1.3','certBag'),r('1.2.840.113549.1.12.10.1.4','crlBag'),r('1.2.840.113549.1.12.10.1.5','secretBag'),r('1.2.840.113549.1.12.10.1.6','safeContentsBag'),r('1.2.840.113549.1.5.13','pkcs5PBES2'),r('1.2.840.113549.1.5.12','pkcs5PBKDF2'),r('1.2.840.113549.1.12.1.1','pbeWithSHAAnd128BitRC4'),r('1.2.840.113549.1.12.1.2','pbeWithSHAAnd40BitRC4'),r('1.2.840.113549.1.12.1.3','pbeWithSHAAnd3-KeyTripleDES-CBC'),r('1.2.840.113549.1.12.1.4','pbeWithSHAAnd2-KeyTripleDES-CBC'),r('1.2.840.113549.1.12.1.5','pbeWithSHAAnd128BitRC2-CBC'),r('1.2.840.113549.1.12.1.6','pbewithSHAAnd40BitRC2-CBC'),r('1.2.840.113549.2.7','hmacWithSHA1'),r('1.2.840.113549.2.8','hmacWithSHA224'),r('1.2.840.113549.2.9','hmacWithSHA256'),r('1.2.840.113549.2.10','hmacWithSHA384'),r('1.2.840.113549.2.11','hmacWithSHA512'),r('1.2.840.113549.3.7','des-EDE3-CBC'),r('2.16.840.1.101.3.4.1.2','aes128-CBC'),r('2.16.840.1.101.3.4.1.22','aes192-CBC'),r('2.16.840.1.101.3.4.1.42','aes256-CBC'),r('2.5.4.3','commonName'),r('2.5.4.4','surname'),r('2.5.4.5','serialNumber'),r('2.5.4.6','countryName'),r('2.5.4.7','localityName'),r('2.5.4.8','stateOrProvinceName'),r('2.5.4.9','streetAddress'),r('2.5.4.10','organizationName'),r('2.5.4.11','organizationalUnitName'),r('2.5.4.12','title'),r('2.5.4.13','description'),r('2.5.4.15','businessCategory'),r('2.5.4.17','postalCode'),r('2.5.4.42','givenName'),r('1.3.6.1.4.1.311.60.2.1.2','jurisdictionOfIncorporationStateOrProvinceName'),r('1.3.6.1.4.1.311.60.2.1.3','jurisdictionOfIncorporationCountryName'),r('2.16.840.1.113730.1.1','nsCertType'),r('2.16.840.1.113730.1.13','nsComment'),i('2.5.29.1','authorityKeyIdentifier'),i('2.5.29.2','keyAttributes'),i('2.5.29.3','certificatePolicies'),i('2.5.29.4','keyUsageRestriction'),i('2.5.29.5','policyMapping'),i('2.5.29.6','subtreesConstraint'),i('2.5.29.7','subjectAltName'),i('2.5.29.8','issuerAltName'),i('2.5.29.9','subjectDirectoryAttributes'),i('2.5.29.10','basicConstraints'),i('2.5.29.11','nameConstraints'),i('2.5.29.12','policyConstraints'),i('2.5.29.13','basicConstraints'),r('2.5.29.14','subjectKeyIdentifier'),r('2.5.29.15','keyUsage'),i('2.5.29.16','privateKeyUsagePeriod'),r('2.5.29.17','subjectAltName'),r('2.5.29.18','issuerAltName'),r('2.5.29.19','basicConstraints'),i('2.5.29.20','cRLNumber'),i('2.5.29.21','cRLReason'),i('2.5.29.22','expirationDate'),i('2.5.29.23','instructionCode'),i('2.5.29.24','invalidityDate'),i('2.5.29.25','cRLDistributionPoints'),i('2.5.29.26','issuingDistributionPoint'),i('2.5.29.27','deltaCRLIndicator'),i('2.5.29.28','issuingDistributionPoint'),i('2.5.29.29','certificateIssuer'),i('2.5.29.30','nameConstraints'),r('2.5.29.31','cRLDistributionPoints'),r('2.5.29.32','certificatePolicies'),i('2.5.29.33','policyMappings'),i('2.5.29.34','policyConstraints'),r('2.5.29.35','authorityKeyIdentifier'),i('2.5.29.36','policyConstraints'),r('2.5.29.37','extKeyUsage'),i('2.5.29.46','freshestCRL'),i('2.5.29.54','inhibitAnyPolicy'),r('1.3.6.1.4.1.11129.2.4.2','timestampList'),r('1.3.6.1.5.5.7.1.1','authorityInfoAccess'),r('1.3.6.1.5.5.7.3.1','serverAuth'),r('1.3.6.1.5.5.7.3.2','clientAuth'),r('1.3.6.1.5.5.7.3.3','codeSigning'),r('1.3.6.1.5.5.7.3.4','emailProtection'),r('1.3.6.1.5.5.7.3.8','timeStamping')})),Zi=w(((t,e)=>{var r=function(t,e,r){if(r>e){var i=new Error('Too few bytes to parse DER.');throw i.available=t.length(),i.remaining=e,i.requested=r,i}},i=function(t,e,n,o){var h;r(t,e,2);var l=t.getByte();e--;var c=192&l,u=31&l;h=t.length();var d,f,p=a(t,e);if(e-=h-t.length(),void 0!==p&&p>e){if(o.strict){var m=new Error('Too few bytes to read ASN.1 value.');throw m.available=t.length(),m.remaining=e,m.requested=p,m}p=e}var g=!(32&~l);if(g)if(d=[],void 0===p)for(;;){if(r(t,e,2),t.bytes(2)===String.fromCharCode(0,0)){t.getBytes(2),e-=2;break}h=t.length(),d.push(i(t,e,n+1,o)),e-=h-t.length()}else for(;p>0;)h=t.length(),d.push(i(t,p,n+1,o)),e-=h-t.length(),p-=h-t.length();if(void 0===d&&c===s.Class.UNIVERSAL&&u===s.Type.BITSTRING&&(f=t.bytes(p)),void 0===d&&o.decodeBitStrings&&c===s.Class.UNIVERSAL&&u===s.Type.BITSTRING&&p>1){var y=t.read,v=e,b=0;if(u===s.Type.BITSTRING&&(r(t,e,1),b=t.getByte(),e--),0===b)try{h=t.length();var _=i(t,e,n+1,{strict:!0,decodeBitStrings:!0}),w=h-t.length();e-=w,u==s.Type.BITSTRING&&w++;var E=_.tagClass;w!==p||E!==s.Class.UNIVERSAL&&E!==s.Class.CONTEXT_SPECIFIC||(d=[_])}catch(t){}void 0===d&&(t.read=y,e=v)}if(void 0===d){if(void 0===p){if(o.strict)throw new Error('Non-constructed ASN.1 object of indefinite length.');p=e}if(u===s.Type.BMPSTRING)for(d='';p>0;p-=2)r(t,e,2),d+=String.fromCharCode(t.getInt16()),e-=2;else d=t.getBytes(p),e-=p}var A=void 0===f?null:{bitStringContents:f};return s.create(c,u,g,d,A)},n=Vi();zi(),Yi();var s=e.exports=n.asn1=n.asn1||{};s.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},s.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},s.create=function(t,e,r,i,a){if(n.util.isArray(i)){for(var o=[],h=0;h1)||(0!==t.value.charCodeAt(0)||128&t.value.charCodeAt(1))&&(255!==t.value.charCodeAt(0)||128&~t.value.charCodeAt(1))?i.putBytes(t.value):i.putBytes(t.value.substr(1));if(e.putByte(r),i.length()<=127)e.putByte(127&i.length());else{var h=i.length(),l='';do{l+=String.fromCharCode(255&h),h>>>=8}while(h>0);e.putByte(128|l.length);for(o=l.length-1;o>=0;--o)e.putByte(l.charCodeAt(o))}return e.putBuffer(i),e},s.oidToDer=function(t){var e,r,i,s,a=t.split('.'),o=n.util.createBuffer();o.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var h=2;h>>=7,e||(s|=128),r.push(s),e=!1}while(i>0);for(var l=r.length-1;l>=0;--l)o.putByte(r[l])}return o},s.derToOid=function(t){var e;'string'==typeof t&&(t=n.util.createBuffer(t));var r=t.getByte();e=Math.floor(r/40)+'.'+r%40;for(var i=0;t.length()>0;)i<<=7,128&(r=t.getByte())?i+=127&r:(e+='.'+(i+r),i=0);return e},s.utcTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,2),10);r=r>=50?1900+r:2e3+r;var i=parseInt(t.substr(2,2),10)-1,n=parseInt(t.substr(4,2),10),s=parseInt(t.substr(6,2),10),a=parseInt(t.substr(8,2),10),o=0;if(t.length>11){var h=t.charAt(10),l=10;'+'!==h&&'-'!==h&&(o=parseInt(t.substr(10,2),10),l+=2)}if(e.setUTCFullYear(r,i,n),e.setUTCHours(s,a,o,0),l&&('+'===(h=t.charAt(l))||'-'===h)){var c=60*parseInt(t.substr(l+1,2),10)+parseInt(t.substr(l+4,2),10);c*=6e4,'+'===h?e.setTime(+e-c):e.setTime(+e+c)}return e},s.generalizedTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,4),10),i=parseInt(t.substr(4,2),10)-1,n=parseInt(t.substr(6,2),10),s=parseInt(t.substr(8,2),10),a=parseInt(t.substr(10,2),10),o=parseInt(t.substr(12,2),10),h=0,l=0,c=!1;'Z'===t.charAt(t.length-1)&&(c=!0);var u=t.length-5,d=t.charAt(u);'+'!==d&&'-'!==d||(l=60*parseInt(t.substr(u+1,2),10)+parseInt(t.substr(u+4,2),10),l*=6e4,'+'===d&&(l*=-1),c=!0);return'.'===t.charAt(14)&&(h=1e3*parseFloat(t.substr(14),10)),c?(e.setUTCFullYear(r,i,n),e.setUTCHours(s,a,o,h),e.setTime(+e+l)):(e.setFullYear(r,i,n),e.setHours(s,a,o,h)),e},s.dateToUtcTime=function(t){if('string'==typeof t)return t;var e='',r=[];r.push((''+t.getUTCFullYear()).substr(2)),r.push(''+(t.getUTCMonth()+1)),r.push(''+t.getUTCDate()),r.push(''+t.getUTCHours()),r.push(''+t.getUTCMinutes()),r.push(''+t.getUTCSeconds());for(var i=0;i=-128&&t<128)return e.putSignedInt(t,8);if(t>=-32768&&t<32768)return e.putSignedInt(t,16);if(t>=-8388608&&t<8388608)return e.putSignedInt(t,24);if(t>=-2147483648&&t<2147483648)return e.putSignedInt(t,32);var r=new Error('Integer too large; max is 32-bits.');throw r.integer=t,r},s.derToInteger=function(t){'string'==typeof t&&(t=n.util.createBuffer(t));var e=8*t.length();if(e>32)throw new Error('Integer too large; max is 32-bits.');return t.getSignedInt(e)},s.validate=function(t,e,r,i){var a=!1;if(t.tagClass!==e.tagClass&&void 0!==e.tagClass||t.type!==e.type&&void 0!==e.type)i&&(t.tagClass!==e.tagClass&&i.push('['+e.name+"] Expected tag class \""+e.tagClass+'", got "'+t.tagClass+'"'),t.type!==e.type&&i.push('['+e.name+"] Expected type \""+e.type+'", got "'+t.type+'"'));else if(t.constructed===e.constructed||void 0===e.constructed){if(a=!0,e.value&&n.util.isArray(e.value))for(var o=0,h=0;a&&h0&&(i+='\n');for(var a='',h=0;h1?i+='0x'+n.util.bytesToHex(t.value.slice(1)):i+='(none)',t.value.length>0){var d=t.value.charCodeAt(0);1==d?i+=' (1 unused bit shown)':d>1&&(i+=' ('+d+' unused bits shown)')}}else if(t.type===s.Type.OCTETSTRING)o.test(t.value)||(i+='('+t.value+') '),i+='0x'+n.util.bytesToHex(t.value);else if(t.type===s.Type.UTF8)try{i+=n.util.decodeUtf8(t.value)}catch(e){if('URI malformed'!==e.message)throw e;i+='0x'+n.util.bytesToHex(t.value)+' (malformed UTF8)'}else t.type===s.Type.PRINTABLESTRING||t.type===s.Type.IA5String?i+=t.value:o.test(t.value)?i+='0x'+n.util.bytesToHex(t.value):0===t.value.length?i+='[null]':i+=t.value}return i}})),$i=w(((t,e)=>{var r=Vi();e.exports=r.md=r.md||{},r.md.algorithms=r.md.algorithms||{}})),Xi=w(((t,e)=>{var r=Vi();$i(),zi(),(e.exports=r.hmac=r.hmac||{}).create=function(){var t=null,e=null,i=null,n=null,s={start:function(s,a){if(null!==s)if('string'==typeof s){if(!((s=s.toLowerCase())in r.md.algorithms))throw new Error('Unknown hash algorithm "'+s+'"');e=r.md.algorithms[s].create()}else e=s;if(null===a)a=t;else{if('string'==typeof a)a=r.util.createBuffer(a);else if(r.util.isArray(a)){var o=a;a=r.util.createBuffer();for(var h=0;he.blockLength&&(e.start(),e.update(a.bytes()),a=e.digest()),i=r.util.createBuffer(),n=r.util.createBuffer(),l=a.length();for(h=0;h{var r=function(t,e,r){for(var i,n,s,l,c,u,d,f=r.length();f>=64;){for(n=t.h0,s=t.h1,l=t.h2,c=t.h3,d=0;d<16;++d)e[d]=r.getInt32Le(),i=n+(c^s&(l^c))+h[d]+e[d],n=c,c=l,l=s,s+=i<<(u=o[d])|i>>>32-u;for(;d<32;++d)i=n+(l^c&(s^l))+h[d]+e[a[d]],n=c,c=l,l=s,s+=i<<(u=o[d])|i>>>32-u;for(;d<48;++d)i=n+(s^l^c)+h[d]+e[a[d]],n=c,c=l,l=s,s+=i<<(u=o[d])|i>>>32-u;for(;d<64;++d)i=n+(l^(s|~c))+h[d]+e[a[d]],n=c,c=l,l=s,s+=i<<(u=o[d])|i>>>32-u;t.h0=t.h0+n|0,t.h1=t.h1+s|0,t.h2=t.h2+l|0,t.h3=t.h3+c|0,f-=64}},i=Vi();$i(),zi();var n=e.exports=i.md5=i.md5||{};i.md.md5=i.md.algorithms.md5=n,n.create=function(){l||function(){s=String.fromCharCode(128),s+=i.util.fillString(String.fromCharCode(0),64),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],o=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],h=new Array(64);for(var t=0;t<64;++t)h[t]=Math.floor(4294967296*Math.abs(Math.sin(t+1)));l=!0}();var t=null,e=i.util.createBuffer(),n=new Array(16),c={algorithm:'md5',blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){c.messageLength=0,c.fullMessageLength=c.messageLength64=[];for(var r=c.messageLengthSize/4,n=0;n>>0,o>>>0];for(var h=c.fullMessageLength.length-1;h>=0;--h)c.fullMessageLength[h]+=o[1],o[1]=o[0]+(c.fullMessageLength[h]/4294967296>>>0),c.fullMessageLength[h]=c.fullMessageLength[h]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(s),r(t,n,e),(e.read>2048||0===e.length())&&e.compact(),c},c.digest=function(){var a=i.util.createBuffer();a.putBytes(e.bytes());var o=c.fullMessageLength[c.fullMessageLength.length-1]+c.messageLengthSize&c.blockLength-1;a.putBytes(s.substr(0,c.blockLength-o));for(var h,l=0,u=c.fullMessageLength.length-1;u>=0;--u)l=(h=8*c.fullMessageLength[u]+l)/4294967296>>>0,a.putInt32Le(h>>>0);var d={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3};r(d,n,a);var f=i.util.createBuffer();return f.putInt32Le(d.h0),f.putInt32Le(d.h1),f.putInt32Le(d.h2),f.putInt32Le(d.h3),f},c};var s=null,a=null,o=null,h=null,l=!1})),Ji=w(((t,e)=>{var r=function(t){for(var e=t.name+': ',r=[],i=function(t,e){return' '+e},n=0;n65&&-1!==a){var o=e[a];','===o?(++a,e=e.substr(0,a)+'\r\n '+e.substr(a)):e=e.substr(0,a)+'\r\n'+o+e.substr(a+1),s=n-a-1,a=-1,++n}else' '!==e[n]&&'\t'!==e[n]&&','!==e[n]||(a=n);return e},i=function(t){return t.replace(/^\s+/,'')},n=Vi();zi();var s=e.exports=n.pem=n.pem||{};s.encode=function(t,e){e=e||{};var i,s='-----BEGIN '+t.type+'-----\r\n';if(t.procType&&(i={name:'Proc-Type',values:[String(t.procType.version),t.procType.type]},s+=r(i)),t.contentDomain&&(i={name:'Content-Domain',values:[t.contentDomain]},s+=r(i)),t.dekInfo&&(i={name:'DEK-Info',values:[t.dekInfo.algorithm]},t.dekInfo.parameters&&i.values.push(t.dekInfo.parameters),s+=r(i)),t.headers)for(var a=0;a{var r=function(t,e){s.cipher.registerAlgorithm(t,(function(){return new s.des.Algorithm(t,e)}))},i=function(t,e,r,i){var n,s,p=32===t.length?3:9;n=3===p?i?[30,-2,-2]:[0,32,2]:i?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var m=e[0],g=e[1];m^=(s=252645135&(m>>>4^g))<<4,m^=(s=65535&(m>>>16^(g^=s)))<<16,m^=s=858993459&((g^=s)>>>2^m),m^=s=16711935&((g^=s<<2)>>>8^m),m=(m^=(s=1431655765&(m>>>1^(g^=s<<8)))<<1)<<1|m>>>31,g=(g^=s)<<1|g>>>31;for(var y=0;y>>4|g<<28)^t[_+1];s=m,m=g,g=s^(o[w>>>24&63]|l[w>>>16&63]|u[w>>>8&63]|f[63&w]|a[E>>>24&63]|h[E>>>16&63]|c[E>>>8&63]|d[63&E])}s=m,m=g,g=s}g=g>>>1|g<<31,g^=s=1431655765&((m=m>>>1|m<<31)>>>1^g),g^=(s=16711935&(g>>>8^(m^=s<<1)))<<8,g^=(s=858993459&(g>>>2^(m^=s)))<<2,g^=s=65535&((m^=s)>>>16^g),g^=s=252645135&((m^=s<<16)>>>4^g),m^=s<<4,r[0]=m,r[1]=g},n=function(t){var e,r='DES-'+((t=t||{}).mode||'CBC').toUpperCase(),i=(e=t.decrypt?s.cipher.createDecipher(r,t.key):s.cipher.createCipher(r,t.key)).start;return e.start=function(t,r){var n=null;r instanceof s.util.ByteBuffer&&(n=r,r={}),(r=r||{}).output=n,r.iv=t,i.call(e,r)},e},s=Vi();Wi(),Ki(),zi(),e.exports=s.des=s.des||{},s.des.startEncrypting=function(t,e,r,i){var s=n({key:t,output:r,decrypt:!1,mode:i||(null===e?'ECB':'CBC')});return s.start(e),s},s.des.createEncryptionCipher=function(t,e){return n({key:t,output:null,decrypt:!1,mode:e})},s.des.startDecrypting=function(t,e,r,i){var s=n({key:t,output:r,decrypt:!0,mode:i||(null===e?'ECB':'CBC')});return s.start(e),s},s.des.createDecryptionCipher=function(t,e){return n({key:t,output:null,decrypt:!0,mode:e})},s.des.Algorithm=function(t,e){var r=this;r.name=t,r.mode=new e({blockSize:8,cipher:{encrypt:function(t,e){return i(r._keys,t,e,!1)},decrypt:function(t,e){return i(r._keys,t,e,!0)}}}),r._init=!1},s.des.Algorithm.prototype.initialize=function(t){if(!this._init){var e=s.util.createBuffer(t.key);if(0===this.name.indexOf('3DES')&&24!==e.length())throw new Error('Invalid Triple-DES key size: '+8*e.length());this._keys=function(t){for(var e,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],i=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],s=[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],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],h=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],l=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],c=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],u=[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],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],m=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=t.length()>8?3:1,y=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,_=0;_>>4^E))<<4,w^=e=65535&((E^=e)>>>-16^w),w^=(e=858993459&(w>>>2^(E^=e<<-16)))<<2,w^=e=65535&((E^=e)>>>-16^w),w^=(e=1431655765&(w>>>1^(E^=e<<-16)))<<1,w^=e=16711935&((E^=e)>>>8^w),e=(w^=(e=1431655765&(w>>>1^(E^=e<<8)))<<1)<<8|(E^=e)>>>20&240,w=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=e;for(var A=0;A>>26,E=E<<2|E>>>26):(w=w<<1|w>>>27,E=E<<1|E>>>27);var S=r[(w&=-15)>>>28]|i[w>>>24&15]|n[w>>>20&15]|s[w>>>16&15]|a[w>>>12&15]|o[w>>>8&15]|h[w>>>4&15],T=l[(E&=-15)>>>28]|c[E>>>24&15]|u[E>>>20&15]|d[E>>>16&15]|f[E>>>12&15]|p[E>>>8&15]|m[E>>>4&15];e=65535&(T>>>16^S),y[b++]=S^e,y[b++]=T^e<<16}}return y}(e),this._init=!0}},r('DES-ECB',s.cipher.modes.ecb),r('DES-CBC',s.cipher.modes.cbc),r('DES-CFB',s.cipher.modes.cfb),r('DES-OFB',s.cipher.modes.ofb),r('DES-CTR',s.cipher.modes.ctr),r('3DES-ECB',s.cipher.modes.ecb),r('3DES-CBC',s.cipher.modes.cbc),r('3DES-CFB',s.cipher.modes.cfb),r('3DES-OFB',s.cipher.modes.ofb),r('3DES-CTR',s.cipher.modes.ctr);var a=[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],h=[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],l=[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],c=[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],u=[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],d=[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],f=[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]})),en={};E(en,{webcrypto:()=>Fi,timingSafeEqual:()=>Di,scryptSync:()=>Ui,scrypt:()=>xi,randomUUID:()=>Bi,getRandomValues:()=>Pi,getCurves:()=>T,default:()=>Hi,DEFAULT_ENCODING:()=>Ri});var rn,nn,sn,an,on=A((()=>{T=function(){return ki},M=Object.create,I=Object.defineProperty,C=Object.getOwnPropertyDescriptor,O=Object.getOwnPropertyNames,N=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty,R=(t,e)=>()=>(t&&(e=t(t=0)),e),P=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),B=(t,e)=>{for(var r in e)I(t,r,{get:e[r],enumerable:!0})},k=(t,e,r,i)=>{if(e&&'object'==typeof e||'function'==typeof e)for(let n of O(e))!L.call(t,n)&&n!==r&&I(t,n,{get:()=>e[n],enumerable:!(i=C(e,n))||i.enumerable});return t},D=(t,e,r)=>(k(t,e,'default'),r&&k(r,e,'default')),U=(t,e,r)=>(r=null!=t?M(N(t)):{},k(!e&&t&&t.__esModule?r:I(r,'default',{value:t,enumerable:!0}),t)),x=t=>k(I({},'__esModule',{value:!0}),t),F=P((t=>{t.byteLength=function(t){var e=a(t),r=e[0],i=e[1];return 3*(r+i)/4-i},t.toByteArray=function(t){var e,r,s=a(t),o=s[0],h=s[1],l=new n(function(t,e,r){return 3*(e+r)/4-r}(0,o,h)),c=0,u=h>0?o-4:o;for(r=0;r>16&255,l[c++]=e>>8&255,l[c++]=255&e;return 2===h&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,l[c++]=255&e),1===h&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,l[c++]=e>>8&255,l[c++]=255&e),l},t.fromByteArray=function(t){for(var e,i=t.length,n=i%3,s=[],a=16383,o=0,l=i-n;ol?l:o+a));return 1===n?(e=t[i-1],s.push(r[e>>2]+r[e<<4&63]+'==')):2===n&&(e=(t[i-2]<<8)+t[i-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+'=')),s.join('')};var e,r=[],i=[],n=typeof Uint8Array<'u'?Uint8Array:Array,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';for(e=0,64;e<64;++e)r[e]=s[e],i[s.charCodeAt(e)]=e;function a(t){var e=t.length;if(e%4>0)throw new Error('Invalid string. Length must be a multiple of 4');var r=t.indexOf('=');return-1===r&&(r=e),[r,r===e?0:4-r%4]}function o(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function h(t,e,r){for(var i,n=[],s=e;s{t.read=function(t,e,r,i,n){var s,a,o=8*n-i-1,h=(1<>1,c=-7,u=r?n-1:0,d=r?-1:1,f=t[e+u];for(u+=d,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+u],u+=d,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=i;c>0;a=256*a+t[e+u],u+=d,c-=8);if(0===s)s=1-l;else{if(s===h)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,i),s-=l}return(f?-1:1)*a*Math.pow(2,s-i)},t.write=function(t,e,r,i,n,s){var a,o,h,l=8*s-n-1,c=(1<>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:s-1,p=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-a))<1&&(a--,h*=2),(e+=a+u>=1?d/h:d*Math.pow(2,1-u))*h>=2&&(a++,h/=2),a+u>=c?(o=0,a=c):a+u>=1?(o=(e*h-1)*Math.pow(2,n),a+=u):(o=e*Math.pow(2,u-1)*Math.pow(2,n),a=0));n>=8;t[r+f]=255&o,f+=p,o/=256,n-=8);for(a=a<0;t[r+f]=255&a,f+=p,a/=256,l-=8);t[r+f-p]|=128*m}})),j=P((t=>{var e=F(),r=H(),i='function'==typeof Symbol&&'function'==typeof Symbol.for?Symbol.for('nodejs.util.inspect.custom'):null;t.Buffer=a,t.SlowBuffer=function(t){return+t!=t&&(t=0),a.alloc(+t)},t.INSPECT_MAX_BYTES=50;var n=2147483647;function s(t){if(t>n)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if('number'==typeof t){if('string'==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return o(t,e,r)}function o(t,e,r){if('string'==typeof t)return function(t,e){if(('string'!=typeof e||''===e)&&(e='utf8'),!a.isEncoding(e))throw new TypeError('Unknown encoding: '+e);let r=0|f(t,e),i=s(r),n=i.write(t,e);return n!==r&&(i=i.slice(0,n)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){let e=new Uint8Array(t);return u(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type '+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<'u'&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return u(t,e,r);if('number'==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');let i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return a.from(i,e,r);let n=function(t){if(a.isBuffer(t)){let e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return'number'!=typeof t.length||$(t.length)?s(0):c(t);if('Buffer'===t.type&&Array.isArray(t.data))return c(t.data)}(t);if(n)return n;if(typeof Symbol<'u'&&null!=Symbol.toPrimitive&&'function'==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]('string'),e,r);throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type '+typeof t)}function h(t){if('number'!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return h(t),s(t<0?0:0|d(t))}function c(t){let e=t.length<0?0:0|d(t.length),r=s(e);for(let i=0;i=n)throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x'+n.toString(16)+' bytes');return 0|t}function f(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if('string'!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;let n=!1;for(;;)switch(e){case'ascii':case'latin1':case'binary':return r;case'utf8':case'utf-8':return K(t).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*r;case'hex':return r>>>1;case'base64':return q(t).length;default:if(n)return i?-1:K(t).length;e=(''+e).toLowerCase(),n=!0}}function p(t,e,r){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0)||(r>>>=0)<=(e>>>=0))return'';for(t||(t='utf8');;)switch(t){case'hex':return C(this,e,r);case'utf8':case'utf-8':return S(this,e,r);case'ascii':return M(this,e,r);case'latin1':case'binary':return I(this,e,r);case'base64':return A(this,e,r);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return O(this,e,r);default:if(i)throw new TypeError('Unknown encoding: '+t);t=(t+'').toLowerCase(),i=!0}}function m(t,e,r){let i=t[e];t[e]=t[r],t[r]=i}function g(t,e,r,i,n){if(0===t.length)return-1;if('string'==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),$(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if('string'==typeof e&&(e=a.from(e,i)),a.isBuffer(e))return 0===e.length?-1:y(t,e,r,i,n);if('number'==typeof e)return e&=255,'function'==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,i,n);throw new TypeError('val must be string, number or Buffer')}function y(t,e,r,i,n){let s,a=1,o=t.length,h=e.length;if(void 0!==i&&('ucs2'===(i=String(i).toLowerCase())||'ucs-2'===i||'utf16le'===i||'utf-16le'===i)){if(t.length<2||e.length<2)return-1;a=2,o/=2,h/=2,r/=2}function l(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(n){let i=-1;for(s=r;so&&(r=o-h),s=r;s>=0;s--){let r=!0;for(let i=0;in&&(i=n):i=n;let s,a=e.length;for(i>a/2&&(i=a/2),s=0;s>8,n=r%256,s.push(n),s.push(i);return s}(e,t.length-r),t,r,i)}function A(t,r,i){return 0===r&&i===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,i))}function S(t,e,r){r=Math.min(t.length,r);let i=[],n=e;for(;n239?4:e>223?3:e>191?2:1;if(n+a<=r){let r,i,o,h;switch(a){case 1:e<128&&(s=e);break;case 2:r=t[n+1],128==(192&r)&&(h=(31&e)<<6|63&r,h>127&&(s=h));break;case 3:r=t[n+1],i=t[n+2],128==(192&r)&&128==(192&i)&&(h=(15&e)<<12|(63&r)<<6|63&i,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:r=t[n+1],i=t[n+2],o=t[n+3],128==(192&r)&&128==(192&i)&&128==(192&o)&&(h=(15&e)<<18|(63&r)<<12|(63&i)<<6|63&o,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|1023&s),i.push(s),n+=a}return function(t){let e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let r='',i=0;for(;ii.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(i,n)):Uint8Array.prototype.set.call(i,e,n);else{if(!a.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,n)}n+=e.length}return i},a.byteLength=f,a.prototype._isBuffer=!0,a.prototype.swap16=function(){let t=this.length;if(t%2!=0)throw new RangeError('Buffer size must be a multiple of 16-bits');for(let e=0;er&&(e+=' ... '),''},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(t,e,r,i,n){if(Z(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError('out of range index');if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;let s=(n>>>=0)-(i>>>=0),o=(r>>>=0)-(e>>>=0),h=Math.min(s,o),l=this.slice(i,n),c=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i='utf8')):(i=r,r=void 0)}let n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError('Attempt to write outside buffer bounds');i||(i='utf8');let s=!1;for(;;)switch(i){case'hex':return v(this,t,e,r);case'utf8':case'utf-8':return b(this,t,e,r);case'ascii':case'latin1':case'binary':return _(this,t,e,r);case'base64':return w(this,t,e,r);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return E(this,t,e,r);default:if(s)throw new TypeError('Unknown encoding: '+i);i=(''+i).toLowerCase(),s=!0}},a.prototype.toJSON=function(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function M(t,e,r){let i='';r=Math.min(t.length,r);for(let n=e;ni)&&(r=i);let n='';for(let i=e;ir)throw new RangeError('Trying to access beyond buffer length')}function L(t,e,r,i,n,s){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||et.length)throw new RangeError('Index out of range')}function R(t,e,r,i,n){V(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function P(t,e,r,i,n){V(e,i,n,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s>>=8,t[r+6]=s,s>>=8,t[r+5]=s,s>>=8,t[r+4]=s;let a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function B(t,e,r,i,n,s){if(r+i>t.length)throw new RangeError('Index out of range');if(r<0)throw new RangeError('Index out of range')}function k(t,e,i,n,s){return e=+e,i>>>=0,s||B(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function D(t,e,i,n,s){return e=+e,i>>>=0,s||B(t,0,i,8),r.write(t,e,i,n,52,8),i+8}a.prototype.slice=function(t,e){let r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);let i=this[t],n=1,s=0;for(;++s>>=0,e>>>=0,r||N(t,e,this.length);let i=this[t+--e],n=1;for(;e>0&&(n*=256);)i+=this[t+--e]*n;return i},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=Q((function(t){G(t>>>=0,'offset');let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&z(t,this.length-8);let i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,n=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(i)+(BigInt(n)<>>=0,'offset');let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&z(t,this.length-8);let i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],n=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(i)<>>=0,e>>>=0,r||N(t,e,this.length);let i=this[t],n=1,s=0;for(;++s=n&&(i-=Math.pow(2,8*e)),i},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let i=e,n=1,s=this[t+--i];for(;i>0&&(n*=256);)s+=this[t+--i]*n;return n*=128,s>=n&&(s-=Math.pow(2,8*e)),s},a.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);let r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);let r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=Q((function(t){G(t>>>=0,'offset');let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&z(t,this.length-8);let i=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(i)<>>=0,'offset');let e=this[t],r=this[t+7];(void 0===e||void 0===r)&&z(t,this.length-8);let i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<>>=0,e||N(t,4,this.length),r.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),r.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),r.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),r.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e>>>=0,r>>>=0,!i){L(this,t,e,r,Math.pow(2,8*r)-1,0)}let n=1,s=0;for(this[e]=255&t;++s>>=0,r>>>=0,!i){L(this,t,e,r,Math.pow(2,8*r)-1,0)}let n=r-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=Q((function(t,e=0){return R(this,t,e,BigInt(0),BigInt('0xffffffffffffffff'))})),a.prototype.writeBigUInt64BE=Q((function(t,e=0){return P(this,t,e,BigInt(0),BigInt('0xffffffffffffffff'))})),a.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e>>>=0,!i){let i=Math.pow(2,8*r-1);L(this,t,e,r,i-1,-i)}let n=0,s=1,a=0;for(this[e]=255&t;++n>>=0,!i){let i=Math.pow(2,8*r-1);L(this,t,e,r,i-1,-i)}let n=r-1,s=1,a=0;for(this[e+n]=255&t;--n>=0&&(s*=256);)t<0&&0===a&&0!==this[e+n+1]&&(a=1),this[e+n]=(t/s|0)-a&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=Q((function(t,e=0){return R(this,t,e,-BigInt('0x8000000000000000'),BigInt('0x7fffffffffffffff'))})),a.prototype.writeBigInt64BE=Q((function(t,e=0){return P(this,t,e,-BigInt('0x8000000000000000'),BigInt('0x7fffffffffffffff'))})),a.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,i){if(!a.isBuffer(t))throw new TypeError('argument should be a Buffer');if(r||(r=0),!i&&0!==i&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError('Index out of range');if(i<0)throw new RangeError('sourceEnd out of bounds');i>this.length&&(i=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),'number'==typeof t)for(n=e;n=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function V(t,e,r,i,n,s){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new U.ERR_OUT_OF_RANGE('value',i,t)}!function(t,e,r){G(e,'offset'),(void 0===t[e]||void 0===t[e+r])&&z(e,t.length-(r+1))}(i,n,s)}function G(t,e){if('number'!=typeof t)throw new U.ERR_INVALID_ARG_TYPE(e,'number',t)}function z(t,e,r){throw Math.floor(t)!==t?(G(t,r),new U.ERR_OUT_OF_RANGE(r||'offset','an integer',t)):e<0?new U.ERR_BUFFER_OUT_OF_BOUNDS:new U.ERR_OUT_OF_RANGE(r||'offset',`>= ${r?1:0} and <= ${e}`,t)}x('ERR_BUFFER_OUT_OF_BOUNDS',(function(t){return t?`${t} is outside of buffer bounds`:'Attempt to access memory outside buffer bounds'}),RangeError),x('ERR_INVALID_ARG_TYPE',(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),x('ERR_OUT_OF_RANGE',(function(t,e,r){let i=`The value of "${t}" is out of range.`,n=r;return Number.isInteger(r)&&Math.abs(r)>2**32?n=j(String(r)):'bigint'==typeof r&&(n=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(n=j(n)),n+='n'),i+=` It must be ${e}. Received ${n}`,i}),RangeError);var W=/[^+/0-9A-Za-z-_]/g;function K(t,e){e=e||1/0;let r,i=t.length,n=null,s=[];for(let a=0;a55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(a+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error('Invalid code point');if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function q(t){return e.toByteArray(function(t){if((t=(t=t.split('=')[0]).trim().replace(W,'')).length<2)return'';for(;t.length%4!=0;)t+='=';return t}(t))}function Y(t,e,r,i){let n;for(n=0;n=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function $(t){return t!=t}var X=function(){let t='0123456789abcdef',e=new Array(256);for(let r=0;r<16;++r){let i=16*r;for(let n=0;n<16;++n)e[i+n]=t[r]+t[n]}return e}();function Q(t){return typeof BigInt>'u'?J:t}function J(){throw new Error('BigInt not supported')}})),V=P(((t,e)=>{var r=j(),i=r.Buffer;function n(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(n(r,t),t.Buffer=s),s.prototype=Object.create(i.prototype),n(i,s),s.from=function(t,e,r){if('number'==typeof t)throw new TypeError('Argument must not be a number');return i(t,e,r)},s.alloc=function(t,e,r){if('number'!=typeof t)throw new TypeError('Argument must be a number');var n=i(t);return void 0!==e?'string'==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if('number'!=typeof t)throw new TypeError('Argument must be a number');return i(t)},s.allocUnsafeSlow=function(t){if('number'!=typeof t)throw new TypeError('Argument must be a number');return r.SlowBuffer(t)}})),G=P(((t,e)=>{var r=65536;var i=V().Buffer,n=global.crypto||global.msCrypto;n&&n.getRandomValues?e.exports=function(t,e){if(t>4294967295)throw new RangeError('requested too many random bytes');var s=i.allocUnsafe(t);if(t>0)if(t>r)for(var a=0;a{'function'==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),W=P(((t,e)=>{var r,i='object'==typeof Reflect?Reflect:null,n=i&&'function'==typeof i.apply?i.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};r=i&&'function'==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var s=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(t,e){return new Promise((function(r,i){function n(r){t.removeListener(e,s),i(r)}function s(){'function'==typeof t.removeListener&&t.removeListener('error',n),r([].slice.call(arguments))}g(t,e,s,{once:!0}),'error'!==e&&function(t,e,r){'function'==typeof t.on&&g(t,'error',e,r)}(t,n,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function h(t){if('function'!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function c(t,e,r,i){var n,s,a;if(h(r),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit('newListener',e,r.listener?r.listener:r),s=t._events),a=s[e]),void 0===a)a=s[e]=r,++t._eventsCount;else if('function'==typeof a?a=s[e]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),(n=l(t))>0&&a.length>n&&!a.warned){a.warned=!0;var o=new Error('Possible EventEmitter memory leak detected. '+a.length+' '+String(e)+' listeners added. Use emitter.setMaxListeners() to increase limit');o.name='MaxListenersExceededWarning',o.emitter=t,o.type=e,o.count=a.length,function(t){console&&console.warn&&console.warn(t)}(o)}return t}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=u.bind(i);return n.listener=r,i.wrapFn=n,n}function f(t,e,r){var i=t._events;if(void 0===i)return[];var n=i[e];return void 0===n?[]:'function'==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(a=e[0]),a instanceof Error)throw a;var o=new Error('Unhandled error.'+(a?' ('+a.message+')':''));throw o.context=a,o}var h=s[t];if(void 0===h)return!1;if('function'==typeof h)n(h,this,e);else{var l=h.length,c=m(h,l);for(r=0;r=0;s--)if(r[s]===e||r[s].listener===e){a=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},a.prototype.listeners=function(t){return f(this,t,!0)},a.prototype.rawListeners=function(t){return f(this,t,!1)},a.listenerCount=function(t,e){return'function'==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},a.prototype.listenerCount=p,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}})),K=P(((t,e)=>{e.exports=W().EventEmitter})),q=P((()=>{})),Y=P(((t,e)=>{function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:'unshift',value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:'shift',value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:'clear',value:function(){this.head=this.tail=null,this.length=0}},{key:'join',value:function(t){if(0===this.length)return'';for(var e=this.head,r=''+e.data;e=e.next;)r+=t+e.data;return r}},{key:'concat',value:function(t){if(0===this.length)return s.alloc(0);for(var e=s.allocUnsafe(t>>>0),r=this.head,i=0;r;)h(r.data,e,i),i+=r.data.length,r=r.next;return e}},{key:'consume',value:function(t,e){var r;return tn.length?n.length:t;if(s===n.length?i+=n:i+=n.slice(0,t),0===(t-=s)){s===n.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++r}return this.length-=r,i}},{key:'_getBuffer',value:function(t){var e=s.allocUnsafe(t),r=this.head,i=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var n=r.data,a=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,a),0===(t-=a)){a===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(a));break}++i}return this.length-=i,e}},{key:o,value:function(t,e){return a(this,function(t){for(var e=1;e{function r(t,e){n(t,e),i(t)}function i(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit('close')}function n(t,e){t.emit('error',e)}e.exports={destroy:function(t,e){var s=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||o?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?s._writableState?s._writableState.errorEmitted?process.nextTick(i,s):(s._writableState.errorEmitted=!0,process.nextTick(r,s,t)):process.nextTick(r,s,t):e?(process.nextTick(i,s),e(t)):process.nextTick(i,s)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var{_readableState:r,_writableState:i}=t;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit('error',e)}}})),$=P(((t,e)=>{var r={};function i(t,e,i){i||(i=Error);var n=function(t){function r(r,i,n){return t.call(this,function(t,r,i){return'string'==typeof e?e:e(t,r,i)}(r,i,n))||this}return function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(r,t),r}(i);n.prototype.name=i.name,n.prototype.code=t,r[t]=n}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?'one of '.concat(e,' ').concat(t.slice(0,r-1).join(', '),', or ')+t[r-1]:2===r?'one of '.concat(e,' ').concat(t[0],' or ').concat(t[1]):'of '.concat(e,' ').concat(t[0])}return'of '.concat(e,' ').concat(String(t))}i('ERR_INVALID_OPT_VALUE',(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),i('ERR_INVALID_ARG_TYPE',(function(t,e,r){var i,s;if('string'==typeof e&&function(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}(e,'not ')?(i='must not be',e=e.replace(/^not /,'')):i='must be',function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t,' argument'))s='The '.concat(t,' ').concat(i,' ').concat(n(e,'type'));else{var a=function(t,e,r){return'number'!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,'.')?'property':'argument';s='The "'.concat(t,'" ').concat(a,' ').concat(i,' ').concat(n(e,'type'))}return s+='. Received type '.concat(typeof r)}),TypeError),i('ERR_STREAM_PUSH_AFTER_EOF','stream.push() after EOF'),i('ERR_METHOD_NOT_IMPLEMENTED',(function(t){return'The '+t+' method is not implemented'})),i('ERR_STREAM_PREMATURE_CLOSE','Premature close'),i('ERR_STREAM_DESTROYED',(function(t){return'Cannot call '+t+' after a stream was destroyed'})),i('ERR_MULTIPLE_CALLBACK','Callback called multiple times'),i('ERR_STREAM_CANNOT_PIPE','Cannot pipe, not readable'),i('ERR_STREAM_WRITE_AFTER_END','write after end'),i('ERR_STREAM_NULL_VALUES','May not write null values to stream',TypeError),i('ERR_UNKNOWN_ENCODING',(function(t){return'Unknown encoding: '+t}),TypeError),i('ERR_STREAM_UNSHIFT_AFTER_END_EVENT','stream.unshift() after end event'),e.exports.codes=r})),X=P(((t,e)=>{var r=$().codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,i,n){var s=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,n,i);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(n?i:'highWaterMark',s);return Math.floor(s)}return t.objectMode?16:16384}}})),Q=P(((t,e)=>{function r(t){try{if(!global.localStorage)return!1}catch{return!1}var e=global.localStorage[t];return null!=e&&'true'===String(e).toLowerCase()}e.exports=function(t,e){if(r('noDeprecation'))return t;var i=!1;return function(){if(!i){if(r('throwDeprecation'))throw new Error(e);r('traceDeprecation')?console.trace(e):console.warn(e),i=!0}return t.apply(this,arguments)}}})),J=P(((t,e)=>{function r(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}var i;e.exports=A,A.WritableState=E;var n={deprecate:Q()},s=K(),a=j().Buffer,o=global.Uint8Array||function(){};var h,l=Z(),c=X().getHighWaterMark,u=$().codes,d=u.ERR_INVALID_ARG_TYPE,f=u.ERR_METHOD_NOT_IMPLEMENTED,p=u.ERR_MULTIPLE_CALLBACK,m=u.ERR_STREAM_CANNOT_PIPE,g=u.ERR_STREAM_DESTROYED,y=u.ERR_STREAM_NULL_VALUES,v=u.ERR_STREAM_WRITE_AFTER_END,b=u.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function w(){}function E(t,e,n){i=i||tt(),t=t||{},'boolean'!=typeof n&&(n=e instanceof i),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=c(this,t,'writableHighWaterMark',n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||'utf8',this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if('function'!=typeof n)throw new p;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,n){--e.pendingcb,r?(process.nextTick(n,i),process.nextTick(O,t,e),t._writableState.errorEmitted=!0,_(t,i)):(n(i),t._writableState.errorEmitted=!0,_(t,i),O(t,e))}(t,r,i,e,n);else{var s=I(r)||t.destroyed;!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&M(t,r),i?process.nextTick(T,t,r,s,n):T(t,r,s,n)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}function A(t){var e=this instanceof(i=i||tt());if(!e&&!h.call(A,this))return new A(t);this._writableState=new E(t,this,e),this.writable=!0,t&&('function'==typeof t.write&&(this._write=t.write),'function'==typeof t.writev&&(this._writev=t.writev),'function'==typeof t.destroy&&(this._destroy=t.destroy),'function'==typeof t.final&&(this._final=t.final)),s.call(this)}function S(t,e,r,i,n,s,a){e.writelen=i,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g('write')):r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function T(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit('drain'))}(t,e),e.pendingcb--,i(),O(t,e)}function M(t,e){e.bufferProcessing=!0;var i=e.bufferedRequest;if(t._writev&&i&&i.next){var n=e.bufferedRequestCount,s=new Array(n),a=e.corkedRequestsFree;a.entry=i;for(var o=0,h=!0;i;)s[o]=i,i.isBuf||(h=!1),i=i.next,o+=1;s.allBuffers=h,S(t,e,!0,e.length,s,'',a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new r(e),e.bufferedRequestCount=0}else{for(;i;){var{chunk:l,encoding:c,callback:u}=i;if(S(t,e,!1,e.objectMode?1:l.length,l,c,u),i=i.next,e.bufferedRequestCount--,e.writing)break}null===i&&(e.lastBufferedRequest=null)}e.bufferedRequest=i,e.bufferProcessing=!1}function I(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function C(t,e){t._final((function(r){e.pendingcb--,r&&_(t,r),e.prefinished=!0,t.emit('prefinish'),O(t,e)}))}function O(t,e){var r=I(e);if(r&&(function(t,e){!e.prefinished&&!e.finalCalled&&('function'!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit('prefinish')):(e.pendingcb++,e.finalCalled=!0,process.nextTick(C,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit('finish'),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return r}z()(A,s),E.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(E.prototype,'buffer',{get:n.deprecate((function(){return this.getBuffer()}),'_writableState.buffer is deprecated. Use _writableState.getBuffer instead.','DEP0003')})}catch{}}(),'function'==typeof Symbol&&Symbol.hasInstance&&'function'==typeof Function.prototype[Symbol.hasInstance]?(h=Function.prototype[Symbol.hasInstance],Object.defineProperty(A,Symbol.hasInstance,{value:function(t){return!!h.call(this,t)||this===A&&(t&&t._writableState instanceof E)}})):h=function(t){return t instanceof this},A.prototype.pipe=function(){_(this,new m)},A.prototype.write=function(t,e,r){var i=this._writableState,n=!1,s=!i.objectMode&&function(t){return a.isBuffer(t)||t instanceof o}(t);return s&&!a.isBuffer(t)&&(t=function(t){return a.from(t)}(t)),'function'==typeof e&&(r=e,e=null),s?e='buffer':e||(e=i.defaultEncoding),'function'!=typeof r&&(r=w),i.ending?function(t,e){var r=new v;_(t,r),process.nextTick(e,r)}(this,r):(s||function(t,e,r,i){var n;return null===r?n=new y:'string'!=typeof r&&!e.objectMode&&(n=new d('chunk',['string','Buffer'],r)),!n||(_(t,n),process.nextTick(i,n),!1)}(this,i,t,r))&&(i.pendingcb++,n=function(t,e,r,i,n,s){if(!r){var o=function(t,e,r){return!t.objectMode&&!1!==t.decodeStrings&&'string'==typeof e&&(e=a.from(e,r)),e}(e,i,n);i!==o&&(r=!0,n='buffer',i=o)}var h=e.objectMode?1:i.length;e.length+=h;var l=e.length-1))throw new b(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(A.prototype,'writableBuffer',{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,'writableHighWaterMark',{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(t,e,r){r(new f('_write()'))},A.prototype._writev=null,A.prototype.end=function(t,e,r){var i=this._writableState;return'function'==typeof t?(r=t,t=null,e=null):'function'==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,O(t,e),r&&(e.finished?process.nextTick(r):t.once('finish',r)),e.ended=!0,t.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,'writableLength',{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,'destroyed',{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){!this._writableState||(this._writableState.destroyed=t)}}),A.prototype.destroy=l.destroy,A.prototype._undestroy=l.undestroy,A.prototype._destroy=function(t,e){e(t)}})),tt=P(((t,e)=>{var r=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var i,n,s,a=ht(),o=J();for(z()(h,a),i=r(o.prototype),s=0;s{var e=V().Buffer,r=e.isEncoding||function(t){switch((t=''+t)&&t.toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':case'raw':return!0;default:return!1}};function i(t){var i;switch(this.encoding=function(t){var i=function(t){if(!t)return'utf8';for(var e;;)switch(t){case'utf8':case'utf-8':return'utf8';case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return'utf16le';case'latin1':case'binary':return'latin1';case'base64':case'ascii':case'hex':return t;default:if(e)return;t=(''+t).toLowerCase(),e=!0}}(t);if('string'!=typeof i&&(e.isEncoding===r||!r(t)))throw new Error('Unknown encoding: '+t);return i||t}(t),this.encoding){case'utf16le':this.text=a,this.end=o,i=4;break;case'utf8':this.fillLast=s,i=4;break;case'base64':this.text=h,this.end=l,i=3;break;default:return this.write=c,void(this.end=u)}this.lastNeed=0,this.lastTotal=0,this.lastChar=e.allocUnsafe(i)}function n(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,'�';if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,'�';if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,'�'}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString('utf16le',e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString('utf16le',e,t.length-1)}function o(t){var e=t&&t.length?this.write(t):'';if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString('utf16le',0,r)}return e}function h(t,e){var r=(t.length-e)%3;return 0===r?t.toString('base64',e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString('base64',e,t.length-r))}function l(t){var e=t&&t.length?this.write(t):'';return this.lastNeed?e+this.lastChar.toString('base64',0,3-this.lastNeed):e}function c(t){return t.toString(this.encoding)}function u(t){return t&&t.length?this.write(t):''}t.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return'';var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return'';r=this.lastNeed,this.lastNeed=0}else r=0;return r=0?(s>0&&(t.lastNeed=s-1),s):--i=0?(s>0&&(t.lastNeed=s-2),s):--i=0?(s>0&&(2===s?s=0:t.lastNeed=s-3),s):0))}(this,t,e);if(!this.lastNeed)return t.toString('utf8',e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString('utf8',e,i)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}})),B(rt={},{StringDecoder:()=>it.StringDecoder,default:()=>it.StringDecoder}),nt=R((()=>{it=U(et())})),st=P(((t,e)=>{var r=$().codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function t(e,n,s){if('function'==typeof n)return t(e,null,n);n||(n={}),s=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,i=new Array(r),n=0;n{var r;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var n=st(),s=Symbol('lastResolve'),a=Symbol('lastReject'),o=Symbol('error'),h=Symbol('ended'),l=Symbol('lastPromise'),c=Symbol('handlePromise'),u=Symbol('stream');function d(t,e){return{value:t,done:e}}function f(t){var e=t[s];if(null!==e){var r=t[u].read();null!==r&&(t[l]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}function p(t){process.nextTick(f,t)}var m=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((r={get stream(){return this[u]},next:function(){var t=this,e=this[o];if(null!==e)return Promise.reject(e);if(this[h])return Promise.resolve(d(void 0,!0));if(this[u].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[o]?r(t[o]):e(d(void 0,!0))}))}));var r,i=this[l];if(i)r=new Promise(function(t,e){return function(r,i){t.then((function(){e[h]?r(d(void 0,!0)):e[c](r,i)}),i)}}(i,this));else{var n=this[u].read();if(null!==n)return Promise.resolve(d(n,!1));r=new Promise(this[c])}return this[l]=r,r}},i(r,Symbol.asyncIterator,(function(){return this})),i(r,'return',(function(){var t=this;return new Promise((function(e,r){t[u].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),r),m);e.exports=function(t){var e,r=Object.create(g,(i(e={},u,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,o,{value:null,writable:!0}),i(e,h,{value:t._readableState.endEmitted,writable:!0}),i(e,c,{value:function(t,e){var i=r[u].read();i?(r[l]=null,r[s]=null,r[a]=null,t(d(i,!1))):(r[s]=t,r[a]=e)},writable:!0}),e));return r[l]=null,n(t,(function(t){if(t&&'ERR_STREAM_PREMATURE_CLOSE'!==t.code){var e=r[a];return null!==e&&(r[l]=null,r[s]=null,r[a]=null,e(t)),void(r[o]=t)}var i=r[s];null!==i&&(r[l]=null,r[s]=null,r[a]=null,i(d(void 0,!0))),r[h]=!0})),t.on('readable',p.bind(null,r)),r}})),ot=P(((t,e)=>{e.exports=function(){throw new Error('Readable.from is not available in the browser')}})),ht=P(((t,e)=>{var r;e.exports=A,A.ReadableState=E;W().EventEmitter;var i=function(t,e){return t.listeners(e).length},n=K(),s=j().Buffer,a=global.Uint8Array||function(){};var o,h=q();o=h&&h.debuglog?h.debuglog('stream'):function(){};var l,c,u,d=Y(),f=Z(),p=X().getHighWaterMark,m=$().codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_STREAM_PUSH_AFTER_EOF,v=m.ERR_METHOD_NOT_IMPLEMENTED,b=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;z()(A,n);var _=f.errorOrDestroy,w=['error','close','destroy','pause','resume'];function E(t,e,i){r=r||tt(),t=t||{},'boolean'!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=p(this,t,'readableHighWaterMark',i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||'utf8',this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=(nt(),x(rt)).StringDecoder),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function A(t){if(r=r||tt(),!(this instanceof A))return new A(t);var e=this instanceof r;this._readableState=new E(t,this,e),this.readable=!0,t&&('function'==typeof t.read&&(this._read=t.read),'function'==typeof t.destroy&&(this._destroy=t.destroy)),n.call(this)}function S(t,e,r,i,n){o('readableAddChunk',e);var h,l=t._readableState;if(null===e)l.reading=!1,function(t,e){if(o('onEofChunk'),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?C(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,O(t)))}}(t,l);else if(n||(h=function(t,e){var r;return!function(t){return s.isBuffer(t)||t instanceof a}(e)&&'string'!=typeof e&&void 0!==e&&!t.objectMode&&(r=new g('chunk',['string','Buffer','Uint8Array'],e)),r}(l,e)),h)_(t,h);else if(l.objectMode||e&&e.length>0)if('string'!=typeof e&&!l.objectMode&&Object.getPrototypeOf(e)!==s.prototype&&(e=function(t){return s.from(t)}(e)),i)l.endEmitted?_(t,new b):T(t,l,e,!0);else if(l.ended)_(t,new y);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!r?(e=l.decoder.write(e),l.objectMode||0!==e.length?T(t,l,e,!1):N(t,l)):T(t,l,e,!1)}else i||(l.reading=!1,N(t,l));return!l.ended&&(l.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=M?t=M:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function C(t){var e=t._readableState;o('emitReadable',e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o('emitReadable',e.flowing),e.emittedReadable=!0,process.nextTick(O,t))}function O(t){var e=t._readableState;o('emitReadable_',e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit('readable'),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,k(t)}function N(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(L,t,e))}function L(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount('data')>0&&t.resume()}function P(t){o('readable nexttick read 0'),t.read(0)}function B(t,e){o('resume',e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit('resume'),k(t),e.flowing&&!e.reading&&t.read(0)}function k(t){var e=t._readableState;for(o('flow',e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(''):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function U(t){var e=t._readableState;o('endReadable',e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(F,e,t))}function F(t,e){if(o('endReadableNT',t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit('end'),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,i=t.length;r=e.highWaterMark:e.length>0)||e.ended))return o('read: emitReadable',e.length,e.ended),0===e.length&&e.ended?U(this):C(this),null;if(0===(t=I(t,e))&&e.ended)return 0===e.length&&U(this),null;var i,n=e.needReadable;return o('need readable',n),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&U(this)),null!==i&&this.emit('data',i),i},A.prototype._read=function(t){_(this,new v('_read()'))},A.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o('pipe count=%d opts=%j',n.pipesCount,e);var s=(!e||!1!==e.end)&&t!==process.stdout&&t!==process.stderr?h:m;function a(e,i){o('onunpipe'),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,o('cleanup'),t.removeListener('close',f),t.removeListener('finish',p),t.removeListener('drain',l),t.removeListener('error',d),t.removeListener('unpipe',a),r.removeListener('end',h),r.removeListener('end',m),r.removeListener('data',u),c=!0,n.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&l())}function h(){o('onend'),t.end()}n.endEmitted?process.nextTick(s):r.once('end',s),t.on('unpipe',a);var l=function(t){return function(){var e=t._readableState;o('pipeOnDrain',e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,'data')&&(e.flowing=!0,k(t))}}(r);t.on('drain',l);var c=!1;function u(e){o('ondata');var i=t.write(e);o('dest.write',i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!c&&(o('false write response, pause',n.awaitDrain),n.awaitDrain++),r.pause())}function d(e){o('onerror',e),m(),t.removeListener('error',d),0===i(t,'error')&&_(t,e)}function f(){t.removeListener('finish',p),m()}function p(){o('onfinish'),t.removeListener('close',f),m()}function m(){o('unpipe'),r.unpipe(t)}return r.on('data',u),function(t,e,r){if('function'==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,'error',d),t.once('close',f),t.once('finish',p),t.emit('pipe',r),n.flowing||(o('pipe resume'),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit('unpipe',this,r)),this;if(!t){var{pipes:i,pipesCount:n}=e;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==i.flowing&&this.resume()):'readable'===t&&!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,o('on readable',i.length,i.reading),i.length?C(this):i.reading||process.nextTick(P,this)),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,e){var r=n.prototype.removeListener.call(this,t,e);return'readable'===t&&process.nextTick(R,this),r},A.prototype.removeAllListeners=function(t){var e=n.prototype.removeAllListeners.apply(this,arguments);return('readable'===t||void 0===t)&&process.nextTick(R,this),e},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(o('resume'),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(B,t,e))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return o('call pause flowing=%j',this._readableState.flowing),!1!==this._readableState.flowing&&(o('pause'),this._readableState.flowing=!1,this.emit('pause')),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;for(var n in t.on('end',(function(){if(o('wrapped end'),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on('data',(function(n){(o('wrapped data'),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n||!(r.objectMode||n&&n.length))||(e.push(n)||(i=!0,t.pause()))})),t)void 0===this[n]&&'function'==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var s=0;s{e.exports=l;var r=$().codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,n=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,o=tt();function h(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit('error',new n);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var s=this._readableState;s.reading=!1,(s.needReadable||s.length{e.exports=i;var r=lt();function i(t){if(!(this instanceof i))return new i(t);r.call(this,t)}z()(i,r),i.prototype._transform=function(t,e,r){r(null,t)}})),ut=P(((t,e)=>{var r;var i=$().codes,n=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function o(t){t()}function h(t,e){return t.pipe(e)}e.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){c||(c=t),t&&u.forEach(o),!n&&(u.forEach(o),l(c))}))}));return e.reduce(h)}})),dt=P(((t,e)=>{(t=e.exports=ht()).Stream=t,t.Readable=t,t.Writable=J(),t.Duplex=tt(),t.Transform=lt(),t.PassThrough=ct(),t.finished=st(),t.pipeline=ut()})),ft=P(((t,e)=>{var r=V().Buffer,i=dt().Transform;function n(t){i.call(this),this._block=r.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}z()(n,i),n.prototype._transform=function(t,e,r){var i=null;try{this.update(t,e)}catch(t){i=t}r(i)},n.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},n.prototype.update=function(t,e){if(function(t,e){if(!r.isBuffer(t)&&'string'!=typeof t)throw new TypeError(e+' must be a string or a buffer')}(t,'Data'),this._finalized)throw new Error('Digest already called');r.isBuffer(t)||(t=r.from(t,e));for(var i=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var s=this._blockOffset;s0;++a)this._length[a]+=o,(o=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*o);return this},n.prototype._update=function(){throw new Error('_update is not implemented')},n.prototype.digest=function(t){if(this._finalized)throw new Error('Digest already called');this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},n.prototype._digest=function(){throw new Error('_digest is not implemented')},e.exports=n})),pt=P(((t,e)=>{var r=z(),i=ft(),n=V().Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function o(t,e){return t<>>32-e}function h(t,e,r,i,n,s,a){return o(t+(e&r|~e&i)+n+s|0,a)+e|0}function l(t,e,r,i,n,s,a){return o(t+(e&i|r&~i)+n+s|0,a)+e|0}function c(t,e,r,i,n,s,a){return o(t+(e^r^i)+n+s|0,a)+e|0}function u(t,e,r,i,n,s,a){return o(t+(r^(e|~i))+n+s|0,a)+e|0}r(a,i),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,i=this._b,n=this._c,a=this._d;r=h(r,i,n,a,t[0],3614090360,7),a=h(a,r,i,n,t[1],3905402710,12),n=h(n,a,r,i,t[2],606105819,17),i=h(i,n,a,r,t[3],3250441966,22),r=h(r,i,n,a,t[4],4118548399,7),a=h(a,r,i,n,t[5],1200080426,12),n=h(n,a,r,i,t[6],2821735955,17),i=h(i,n,a,r,t[7],4249261313,22),r=h(r,i,n,a,t[8],1770035416,7),a=h(a,r,i,n,t[9],2336552879,12),n=h(n,a,r,i,t[10],4294925233,17),i=h(i,n,a,r,t[11],2304563134,22),r=h(r,i,n,a,t[12],1804603682,7),a=h(a,r,i,n,t[13],4254626195,12),n=h(n,a,r,i,t[14],2792965006,17),r=l(r,i=h(i,n,a,r,t[15],1236535329,22),n,a,t[1],4129170786,5),a=l(a,r,i,n,t[6],3225465664,9),n=l(n,a,r,i,t[11],643717713,14),i=l(i,n,a,r,t[0],3921069994,20),r=l(r,i,n,a,t[5],3593408605,5),a=l(a,r,i,n,t[10],38016083,9),n=l(n,a,r,i,t[15],3634488961,14),i=l(i,n,a,r,t[4],3889429448,20),r=l(r,i,n,a,t[9],568446438,5),a=l(a,r,i,n,t[14],3275163606,9),n=l(n,a,r,i,t[3],4107603335,14),i=l(i,n,a,r,t[8],1163531501,20),r=l(r,i,n,a,t[13],2850285829,5),a=l(a,r,i,n,t[2],4243563512,9),n=l(n,a,r,i,t[7],1735328473,14),r=c(r,i=l(i,n,a,r,t[12],2368359562,20),n,a,t[5],4294588738,4),a=c(a,r,i,n,t[8],2272392833,11),n=c(n,a,r,i,t[11],1839030562,16),i=c(i,n,a,r,t[14],4259657740,23),r=c(r,i,n,a,t[1],2763975236,4),a=c(a,r,i,n,t[4],1272893353,11),n=c(n,a,r,i,t[7],4139469664,16),i=c(i,n,a,r,t[10],3200236656,23),r=c(r,i,n,a,t[13],681279174,4),a=c(a,r,i,n,t[0],3936430074,11),n=c(n,a,r,i,t[3],3572445317,16),i=c(i,n,a,r,t[6],76029189,23),r=c(r,i,n,a,t[9],3654602809,4),a=c(a,r,i,n,t[12],3873151461,11),n=c(n,a,r,i,t[15],530742520,16),r=u(r,i=c(i,n,a,r,t[2],3299628645,23),n,a,t[0],4096336452,6),a=u(a,r,i,n,t[7],1126891415,10),n=u(n,a,r,i,t[14],2878612391,15),i=u(i,n,a,r,t[5],4237533241,21),r=u(r,i,n,a,t[12],1700485571,6),a=u(a,r,i,n,t[3],2399980690,10),n=u(n,a,r,i,t[10],4293915773,15),i=u(i,n,a,r,t[1],2240044497,21),r=u(r,i,n,a,t[8],1873313359,6),a=u(a,r,i,n,t[15],4264355552,10),n=u(n,a,r,i,t[6],2734768916,15),i=u(i,n,a,r,t[13],1309151649,21),r=u(r,i,n,a,t[4],4149444226,6),a=u(a,r,i,n,t[11],3174756917,10),n=u(n,a,r,i,t[2],718787259,15),i=u(i,n,a,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+n|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=a})),mt=P(((t,e)=>{var r=j().Buffer,i=z(),n=ft(),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],h=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],l=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],c=[0,1518500249,1859775393,2400959708,2840853838],u=[1352829926,1548603684,1836072691,2053994217,0];function d(){n.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function f(t,e){return t<>>32-e}function p(t,e,r,i,n,s,a,o){return f(t+(e^r^i)+s+a|0,o)+n|0}function m(t,e,r,i,n,s,a,o){return f(t+(e&r|~e&i)+s+a|0,o)+n|0}function g(t,e,r,i,n,s,a,o){return f(t+((e|~r)^i)+s+a|0,o)+n|0}function y(t,e,r,i,n,s,a,o){return f(t+(e&i|r&~i)+s+a|0,o)+n|0}function v(t,e,r,i,n,s,a,o){return f(t+(e^(r|~i))+s+a|0,o)+n|0}i(d,n),d.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,i=0|this._b,n=0|this._c,d=0|this._d,b=0|this._e,_=0|this._a,w=0|this._b,E=0|this._c,A=0|this._d,S=0|this._e,T=0;T<80;T+=1){var M,I;T<16?(M=p(r,i,n,d,b,t[a[T]],c[0],h[T]),I=v(_,w,E,A,S,t[o[T]],u[0],l[T])):T<32?(M=m(r,i,n,d,b,t[a[T]],c[1],h[T]),I=y(_,w,E,A,S,t[o[T]],u[1],l[T])):T<48?(M=g(r,i,n,d,b,t[a[T]],c[2],h[T]),I=g(_,w,E,A,S,t[o[T]],u[2],l[T])):T<64?(M=y(r,i,n,d,b,t[a[T]],c[3],h[T]),I=m(_,w,E,A,S,t[o[T]],u[3],l[T])):(M=v(r,i,n,d,b,t[a[T]],c[4],h[T]),I=p(_,w,E,A,S,t[o[T]],u[4],l[T])),r=b,b=d,d=f(n,10),n=i,i=M,_=S,S=A,A=f(E,10),E=w,w=I}var C=this._b+n+A|0;this._b=this._c+d+S|0,this._c=this._d+b+_|0,this._d=this._e+r+w|0,this._e=this._a+i+E|0,this._a=C},d.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=r.alloc?r.alloc(20):new r(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=d})),gt=P(((t,e)=>{var r=V().Buffer;function i(t,e){this._block=r.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){'string'==typeof t&&(e=e||'utf8',t=r.from(t,e));for(var i=this._block,n=this._blockSize,s=t.length,a=this._len,o=0;o=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(4294967295&r)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var s=this._hash();return t?s.toString(t):s},i.prototype._update=function(){throw new Error('_update must be implemented by subclass')},e.exports=i})),yt=P(((t,e)=>{var r=z(),i=gt(),n=V().Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function o(){this.init(),this._w=a,i.call(this,64,56)}function h(t){return t<<5|t>>>27}function l(t){return t<<30|t>>>2}function c(t,e,r,i){return 0===t?e&r|~e&i:2===t?e&r|e&i|r&i:e^r^i}r(o,i),o.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},o.prototype._update=function(t){for(var e=this._w,r=0|this._a,i=0|this._b,n=0|this._c,a=0|this._d,o=0|this._e,u=0;u<16;++u)e[u]=t.readInt32BE(4*u);for(;u<80;++u)e[u]=e[u-3]^e[u-8]^e[u-14]^e[u-16];for(var d=0;d<80;++d){var f=~~(d/20),p=h(r)+c(f,i,n,a)+o+e[d]+s[f]|0;o=a,a=n,n=l(i),i=r,r=p}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=a+this._d|0,this._e=o+this._e|0},o.prototype._hash=function(){var t=n.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=o})),vt=P(((t,e)=>{var r=z(),i=gt(),n=V().Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function o(){this.init(),this._w=a,i.call(this,64,56)}function h(t){return t<<1|t>>>31}function l(t){return t<<5|t>>>27}function c(t){return t<<30|t>>>2}function u(t,e,r,i){return 0===t?e&r|~e&i:2===t?e&r|e&i|r&i:e^r^i}r(o,i),o.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},o.prototype._update=function(t){for(var e=this._w,r=0|this._a,i=0|this._b,n=0|this._c,a=0|this._d,o=0|this._e,d=0;d<16;++d)e[d]=t.readInt32BE(4*d);for(;d<80;++d)e[d]=h(e[d-3]^e[d-8]^e[d-14]^e[d-16]);for(var f=0;f<80;++f){var p=~~(f/20),m=l(r)+u(p,i,n,a)+o+e[f]+s[p]|0;o=a,a=n,n=c(i),i=r,r=m}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=a+this._d|0,this._e=o+this._e|0},o.prototype._hash=function(){var t=n.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=o})),bt=P(((t,e)=>{var r=z(),i=gt(),n=V().Buffer,s=[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],a=new Array(64);function o(){this.init(),this._w=a,i.call(this,64,56)}function h(t,e,r){return r^t&(e^r)}function l(t,e,r){return t&e|r&(t|e)}function c(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function u(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function d(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}function f(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}r(o,i),o.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},o.prototype._update=function(t){for(var e=this._w,r=0|this._a,i=0|this._b,n=0|this._c,a=0|this._d,o=0|this._e,p=0|this._f,m=0|this._g,g=0|this._h,y=0;y<16;++y)e[y]=t.readInt32BE(4*y);for(;y<64;++y)e[y]=f(e[y-2])+e[y-7]+d(e[y-15])+e[y-16]|0;for(var v=0;v<64;++v){var b=g+u(o)+h(o,p,m)+s[v]+e[v]|0,_=c(r)+l(r,i,n)|0;g=m,m=p,p=o,o=a+b|0,a=n,n=i,i=r,r=b+_|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=a+this._d|0,this._e=o+this._e|0,this._f=p+this._f|0,this._g=m+this._g|0,this._h=g+this._h|0},o.prototype._hash=function(){var t=n.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=o})),_t=P(((t,e)=>{var r=z(),i=bt(),n=gt(),s=V().Buffer,a=new Array(64);function o(){this.init(),this._w=a,n.call(this,64,56)}r(o,i),o.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},o.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=o})),wt=P(((t,e)=>{var r=z(),i=gt(),n=V().Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function o(){this.init(),this._w=a,i.call(this,128,112)}function h(t,e,r){return r^t&(e^r)}function l(t,e,r){return t&e|r&(t|e)}function c(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function u(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function f(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function m(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(t,e){return t>>>0>>0?1:0}r(o,i),o.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},o.prototype._update=function(t){for(var e=this._w,r=0|this._ah,i=0|this._bh,n=0|this._ch,a=0|this._dh,o=0|this._eh,y=0|this._fh,v=0|this._gh,b=0|this._hh,_=0|this._al,w=0|this._bl,E=0|this._cl,A=0|this._dl,S=0|this._el,T=0|this._fl,M=0|this._gl,I=0|this._hl,C=0;C<32;C+=2)e[C]=t.readInt32BE(4*C),e[C+1]=t.readInt32BE(4*C+4);for(;C<160;C+=2){var O=e[C-30],N=e[C-30+1],L=d(O,N),R=f(N,O),P=p(O=e[C-4],N=e[C-4+1]),B=m(N,O),k=e[C-14],D=e[C-14+1],U=e[C-32],x=e[C-32+1],F=R+D|0,H=L+k+g(F,R)|0;H=(H=H+P+g(F=F+B|0,B)|0)+U+g(F=F+x|0,x)|0,e[C]=H,e[C+1]=F}for(var j=0;j<160;j+=2){H=e[j],F=e[j+1];var V=l(r,i,n),G=l(_,w,E),z=c(r,_),W=c(_,r),K=u(o,S),q=u(S,o),Y=s[j],Z=s[j+1],$=h(o,y,v),X=h(S,T,M),Q=I+q|0,J=b+K+g(Q,I)|0;J=(J=(J=J+$+g(Q=Q+X|0,X)|0)+Y+g(Q=Q+Z|0,Z)|0)+H+g(Q=Q+F|0,F)|0;var tt=W+G|0,et=z+V+g(tt,W)|0;b=v,I=M,v=y,M=T,y=o,T=S,o=a+J+g(S=A+Q|0,A)|0,a=n,A=E,n=i,E=w,i=r,w=_,r=J+et+g(_=Q+tt|0,Q)|0}this._al=this._al+_|0,this._bl=this._bl+w|0,this._cl=this._cl+E|0,this._dl=this._dl+A|0,this._el=this._el+S|0,this._fl=this._fl+T|0,this._gl=this._gl+M|0,this._hl=this._hl+I|0,this._ah=this._ah+r+g(this._al,_)|0,this._bh=this._bh+i+g(this._bl,w)|0,this._ch=this._ch+n+g(this._cl,E)|0,this._dh=this._dh+a+g(this._dl,A)|0,this._eh=this._eh+o+g(this._el,S)|0,this._fh=this._fh+y+g(this._fl,T)|0,this._gh=this._gh+v+g(this._gl,M)|0,this._hh=this._hh+b+g(this._hl,I)|0},o.prototype._hash=function(){var t=n.allocUnsafe(64);function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=o})),Et=P(((t,e)=>{var r=z(),i=wt(),n=gt(),s=V().Buffer,a=new Array(160);function o(){this.init(),this._w=a,n.call(this,128,112)}r(o,i),o.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},o.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,i){t.writeInt32BE(e,i),t.writeInt32BE(r,i+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=o})),At=P(((t,e)=>{t=e.exports=function(e){e=e.toLowerCase();var r=t[e];if(!r)throw new Error(e+' is not supported (we accept pull requests)');return new r};t.sha=yt(),t.sha1=vt(),t.sha224=_t(),t.sha256=bt(),t.sha384=Et(),t.sha512=wt()})),St=P(((t,e)=>{e.exports={ArrayIsArray:t=>Array.isArray(t),ArrayPrototypeIncludes:(t,e)=>t.includes(e),ArrayPrototypeIndexOf:(t,e)=>t.indexOf(e),ArrayPrototypeJoin:(t,e)=>t.join(e),ArrayPrototypeMap:(t,e)=>t.map(e),ArrayPrototypePop:(t,e)=>t.pop(e),ArrayPrototypePush:(t,e)=>t.push(e),ArrayPrototypeSlice:(t,e,r)=>t.slice(e,r),Error,FunctionPrototypeCall:(t,e,...r)=>t.call(e,...r),FunctionPrototypeSymbolHasInstance:(t,e)=>Function.prototype[Symbol.hasInstance].call(t,e),MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties:(t,e)=>Object.defineProperties(t,e),ObjectDefineProperty:(t,e,r)=>Object.defineProperty(t,e,r),ObjectGetOwnPropertyDescriptor:(t,e)=>Object.getOwnPropertyDescriptor(t,e),ObjectKeys:t=>Object.keys(t),ObjectSetPrototypeOf:(t,e)=>Object.setPrototypeOf(t,e),Promise,PromisePrototypeCatch:(t,e)=>t.catch(e),PromisePrototypeThen:(t,e,r)=>t.then(e,r),PromiseReject:t=>Promise.reject(t),ReflectApply:Reflect.apply,RegExpPrototypeTest:(t,e)=>t.test(e),SafeSet:Set,String,StringPrototypeSlice:(t,e,r)=>t.slice(e,r),StringPrototypeToLowerCase:t=>t.toLowerCase(),StringPrototypeToUpperCase:t=>t.toUpperCase(),StringPrototypeTrim:t=>t.trim(),Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet:(t,e,r)=>t.set(e,r),Uint8Array}})),Tt=P(((t,e)=>{var r=j(),i=Object.getPrototypeOf((async function(){})).constructor,n=globalThis.Blob||r.Blob,s=typeof n<'u'?function(t){return t instanceof n}:function(t){return!1},a=class extends Error{constructor(t){if(!Array.isArray(t))throw new TypeError("Expected input to be an Array, got "+typeof t);let e='';for(let r=0;r{t=r,e=i})),resolve:t,reject:e}},promisify:t=>new Promise(((e,r)=>{t(((t,...i)=>t?r(t):e(...i)))})),debuglog:()=>function(){},format:(t,...e)=>t.replace(/%([sdifj])/g,(function(...[t,r]){let i=e.shift();return'f'===r?i.toFixed(6):'j'===r?JSON.stringify(i):'s'===r&&'object'==typeof i?`${i.constructor!==Object?i.constructor.name:''} {}`.trim():i.toString()})),inspect(t){switch(typeof t){case'string':if(t.includes("'")){if(!t.includes('"'))return`"${t}"`;if(!t.includes('`')&&!t.includes('${'))return`\`${t}\``}return`'${t}'`;case'number':return isNaN(t)?'NaN':Object.is(t,-0)?String(t):t;case'bigint':return`${String(t)}n`;case'boolean':case'undefined':return String(t);case'object':return'{}'}},types:{isAsyncFunction:t=>t instanceof i,isArrayBufferView:t=>ArrayBuffer.isView(t)},isBlob:s},e.exports.promisify.custom=Symbol.for('nodejs.util.promisify.custom')})),Mt=P(((t,e)=>{var{AbortController:r,AbortSignal:i}=typeof self<'u'?self:typeof window<'u'?window:void 0;e.exports=r,e.exports.AbortSignal=i,e.exports.default=r})),It=P(((t,e)=>{var{format:r,inspect:i,AggregateError:n}=Tt(),s=globalThis.AggregateError||n,a=Symbol('kIsNodeError'),o=['string','function','number','object','Function','Object','boolean','bigint','symbol'],h=/^([A-Z][a-z0-9]*)+$/,l={};function c(t,e){if(!t)throw new l.ERR_INTERNAL_ASSERTION(e)}function u(t){let e='',r=t.length,i='-'===t[0]?1:0;for(;r>=i+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function d(t,e,i){i||(i=Error);class n extends i{constructor(...i){super(function(t,e,i){if('function'==typeof e)return c(e.length<=i.length,`Code: ${t}; The provided arguments length (${i.length}) does not match the required ones (${e.length}).`),e(...i);let n=(e.match(/%[dfijoOs]/g)||[]).length;return c(n===i.length,`Code: ${t}; The provided arguments length (${i.length}) does not match the required ones (${n}).`),0===i.length?e:r(e,...i)}(t,e,i))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(n.prototype,{name:{value:i.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),n.prototype.code=t,n.prototype[a]=!0,l[t]=n}function f(t){let e="__node_internal_"+t.name;return Object.defineProperty(t,'name',{value:e}),t}var p=class extends Error{constructor(t="The operation was aborted",e=void 0){if(void 0!==e&&'object'!=typeof e)throw new l.ERR_INVALID_ARG_TYPE('options','Object',e);super(t,e),this.code='ABORT_ERR',this.name='AbortError'}};d('ERR_ASSERTION','%s',Error),d('ERR_INVALID_ARG_TYPE',((t,e,r)=>{c('string'==typeof t,"'name' must be a string"),Array.isArray(e)||(e=[e]);let n='The ';t.endsWith(' argument')?n+=`${t} `:n+=`"${t}" ${t.includes('.')?'property':'argument'} `,n+='must be ';let s=[],a=[],l=[];for(let t of e)c('string'==typeof t,'All expected entries have to be of type string'),o.includes(t)?s.push(t.toLowerCase()):h.test(t)?a.push(t):(c('object'!==t,'The value "object" should be written as "Object"'),l.push(t));if(a.length>0){let t=s.indexOf('object');-1!==t&&(s.splice(s,t,1),a.push('Object'))}if(s.length>0){switch(s.length){case 1:n+=`of type ${s[0]}`;break;case 2:n+=`one of type ${s[0]} or ${s[1]}`;break;default:{let t=s.pop();n+=`one of type ${s.join(', ')}, or ${t}`}}(a.length>0||l.length>0)&&(n+=' or ')}if(a.length>0){switch(a.length){case 1:n+=`an instance of ${a[0]}`;break;case 2:n+=`an instance of ${a[0]} or ${a[1]}`;break;default:{let t=a.pop();n+=`an instance of ${a.join(', ')}, or ${t}`}}l.length>0&&(n+=' or ')}switch(l.length){case 0:break;case 1:l[0].toLowerCase()!==l[0]&&(n+='an '),n+=`${l[0]}`;break;case 2:n+=`one of ${l[0]} or ${l[1]}`;break;default:{let t=l.pop();n+=`one of ${l.join(', ')}, or ${t}`}}if(null==r)n+=`. Received ${r}`;else if('function'==typeof r&&r.name)n+=`. Received function ${r.name}`;else if('object'==typeof r){var u;null!==(u=r.constructor)&&void 0!==u&&u.name?n+=`. Received an instance of ${r.constructor.name}`:n+=`. Received ${i(r,{depth:-1})}`}else{let t=i(r,{colors:!1});t.length>25&&(t=`${t.slice(0,25)}...`),n+=`. Received type ${typeof r} (${t})`}return n}),TypeError),d('ERR_INVALID_ARG_VALUE',((t,e,r="is invalid")=>{let n=i(e);return n.length>128&&(n=n.slice(0,128)+'...'),`The ${t.includes('.')?'property':'argument'} '${t}' ${r}. Received ${n}`}),TypeError),d('ERR_INVALID_RETURN_VALUE',((t,e,r)=>{var i;return`Expected ${t} to be returned from the "${e}" function but got ${null!=r&&null!==(i=r.constructor)&&void 0!==i&&i.name?`instance of ${r.constructor.name}`:"type "+typeof r}.`}),TypeError),d('ERR_MISSING_ARGS',((...t)=>{c(t.length>0,'At least one arg needs to be specified');let e,r=t.length;switch(t=(Array.isArray(t)?t:[t]).map((t=>`"${t}"`)).join(' or '),r){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{let r=t.pop();e+=`The ${t.join(', ')}, and ${r} arguments`}}return`${e} must be specified`}),TypeError),d('ERR_OUT_OF_RANGE',((t,e,r)=>{let n;return c(e,'Missing "range" argument'),Number.isInteger(r)&&Math.abs(r)>2**32?n=u(String(r)):'bigint'==typeof r?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=u(n)),n+='n'):n=i(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`}),RangeError),d('ERR_MULTIPLE_CALLBACK','Callback called multiple times',Error),d('ERR_METHOD_NOT_IMPLEMENTED','The %s method is not implemented',Error),d('ERR_STREAM_ALREADY_FINISHED','Cannot call %s after a stream was finished',Error),d('ERR_STREAM_CANNOT_PIPE','Cannot pipe, not readable',Error),d('ERR_STREAM_DESTROYED','Cannot call %s after a stream was destroyed',Error),d('ERR_STREAM_NULL_VALUES','May not write null values to stream',TypeError),d('ERR_STREAM_PREMATURE_CLOSE','Premature close',Error),d('ERR_STREAM_PUSH_AFTER_EOF','stream.push() after EOF',Error),d('ERR_STREAM_UNSHIFT_AFTER_END_EVENT','stream.unshift() after end event',Error),d('ERR_STREAM_WRITE_AFTER_END','write after end',Error),d('ERR_UNKNOWN_ENCODING','Unknown encoding: %s',TypeError),e.exports={AbortError:p,aggregateTwoErrors:f((function(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new s([e,t],e.message);return r.code=e.code,r}return t||e})),hideStackFrames:f,codes:l}})),Ct=P(((t,e)=>{var{ArrayIsArray:r,ArrayPrototypeIncludes:i,ArrayPrototypeJoin:n,ArrayPrototypeMap:s,NumberIsInteger:a,NumberIsNaN:o,NumberMAX_SAFE_INTEGER:h,NumberMIN_SAFE_INTEGER:l,NumberParseInt:c,ObjectPrototypeHasOwnProperty:u,RegExpPrototypeExec:d,String:f,StringPrototypeToUpperCase:p,StringPrototypeTrim:m}=St(),{hideStackFrames:g,codes:{ERR_SOCKET_BAD_PORT:y,ERR_INVALID_ARG_TYPE:v,ERR_INVALID_ARG_VALUE:b,ERR_OUT_OF_RANGE:_,ERR_UNKNOWN_SIGNAL:w}}=It(),{normalizeEncoding:E}=Tt(),{isAsyncFunction:A,isArrayBufferView:S}=Tt().types,T={};var M=/^[0-7]+$/;var I=g(((t,e,r=l,i=h)=>{if('number'!=typeof t)throw new v(e,'number',t);if(!a(t))throw new _(e,'an integer',t);if(ti)throw new _(e,`>= ${r} && <= ${i}`,t)})),C=g(((t,e,r=-2147483648,i=2147483647)=>{if('number'!=typeof t)throw new v(e,'number',t);if(!a(t))throw new _(e,'an integer',t);if(ti)throw new _(e,`>= ${r} && <= ${i}`,t)})),O=g(((t,e,r=!1)=>{if('number'!=typeof t)throw new v(e,'number',t);if(!a(t))throw new _(e,'an integer',t);let i=r?1:0,n=4294967295;if(tn)throw new _(e,`>= ${i} && <= ${n}`,t)}));function N(t,e){if('string'!=typeof t)throw new v(e,'string',t)}var L=g(((t,e,r)=>{if(!i(r,t)){let i=n(s(r,(t=>'string'==typeof t?`'${t}'`:f(t))),', ');throw new b(e,t,'must be one of: '+i)}}));function R(t,e,r){return null!=t&&u(t,e)?t[e]:r}var P=g(((t,e,i=null)=>{let n=R(i,'allowArray',!1),s=R(i,'allowFunction',!1);if(!R(i,'nullable',!1)&&null===t||!n&&r(t)||'object'!=typeof t&&(!s||'function'!=typeof t))throw new v(e,'Object',t)})),B=g(((t,e,i=0)=>{if(!r(t))throw new v(e,'Array',t);if(t.length{if(!S(t))throw new v(e,['Buffer','TypedArray','DataView'],t)}));var D=g(((t,e)=>{if(void 0!==t&&(null===t||'object'!=typeof t||!('aborted'in t)))throw new v(e,'AbortSignal',t)})),U=g(((t,e)=>{if('function'!=typeof t)throw new v(e,'Function',t)})),x=g(((t,e)=>{if('function'!=typeof t||A(t))throw new v(e,'Function',t)})),F=g(((t,e)=>{if(void 0!==t)throw new v(e,'undefined',t)}));e.exports={isInt32:function(t){return t===(0|t)},isUint32:function(t){return t===t>>>0},parseFileMode:function(t,e,r){if(typeof t>'u'&&(t=r),'string'==typeof t){if(null===d(M,t))throw new b(e,t,"must be a 32-bit unsigned integer or an octal string");t=c(t,8)}return O(t,e),t},validateArray:B,validateBoolean:function(t,e){if('boolean'!=typeof t)throw new v(e,'boolean',t)},validateBuffer:k,validateEncoding:function(t,e){let r=E(e),i=t.length;if('hex'===r&&i%2!=0)throw new b('encoding',e,`is invalid for data of length ${i}`)},validateFunction:U,validateInt32:C,validateInteger:I,validateNumber:function(t,e,r=void 0,i){if('number'!=typeof t)throw new v(e,'number',t);if(null!=r&&ti||(null!=r||null!=i)&&o(t))throw new _(e,`${null!=r?`>= ${r}`:''}${null!=r&&null!=i?' && ':''}${null!=i?`<= ${i}`:''}`,t)},validateObject:P,validateOneOf:L,validatePlainFunction:x,validatePort:function(t,e="Port",r=!0){if('number'!=typeof t&&'string'!=typeof t||'string'==typeof t&&0===m(t).length||+t!=+t>>>0||t>65535||0===t&&!r)throw new y(e,t,r);return 0|t},validateSignalName:function(t,e="signal"){if(N(t,e),void 0===T[t])throw void 0!==T[p(t)]?new w(t+' (signals must use all capital letters)'):new w(t)},validateString:N,validateUint32:O,validateUndefined:F,validateUnion:function(t,e,r){if(!i(r,t))throw new v(e,`('${n(r,'|')}')`,t)},validateAbortSignal:D}})),Ot=P(((t,e)=>{var r,i,n=e.exports={};function s(){throw new Error('setTimeout has not been defined')}function a(){throw new Error('clearTimeout has not been defined')}function o(t){if(r===setTimeout)return setTimeout(t,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch{try{return r.call(null,t,0)}catch{return r.call(this,t,0)}}}!function(){try{r='function'==typeof setTimeout?setTimeout:s}catch{r=s}try{i='function'==typeof clearTimeout?clearTimeout:a}catch{i=a}}();var h,l=[],c=!1,u=-1;function d(){!c||!h||(c=!1,h.length?l=h.concat(l):u=-1,l.length&&f())}function f(){if(!c){var t=o(d);c=!0;for(var e=l.length;e;){for(h=l,l=[];++u1)for(var r=1;rLt}),Rt=R((()=>{D(Nt,U(Ot())),Lt=U(Ot())})),Pt=P(((t,e)=>{var{Symbol:r,SymbolAsyncIterator:i,SymbolIterator:n}=St(),s=r('kDestroyed'),a=r('kIsErrored'),o=r('kIsReadable'),h=r('kIsDisturbed');function l(t,e=!1){var r;return!(!t||'function'!=typeof t.pipe||'function'!=typeof t.on||e&&('function'!=typeof t.pause||'function'!=typeof t.resume)||t._writableState&&!1===(null===(r=t._readableState)||void 0===r?void 0:r.readable)||t._writableState&&!t._readableState)}function c(t){var e;return!(!t||'function'!=typeof t.write||'function'!=typeof t.on||t._readableState&&!1===(null===(e=t._writableState)||void 0===e?void 0:e.writable))}function u(t){return t&&(t._readableState||t._writableState||'function'==typeof t.write&&'function'==typeof t.on||'function'==typeof t.pipe&&'function'==typeof t.on)}function d(t){if(!u(t))return null;let{_writableState:e,_readableState:r}=t,i=e||r;return!!(t.destroyed||t[s]||null!=i&&i.destroyed)}function f(t){if(!c(t))return null;if(!0===t.writableEnded)return!0;let e=t._writableState;return(null==e||!e.errored)&&('boolean'!=typeof e?.ended?null:e.ended)}function p(t,e){if(!l(t))return null;let r=t._readableState;return(null==r||!r.errored)&&('boolean'!=typeof r?.endEmitted?null:!!(r.endEmitted||!1===e&&!0===r.ended&&0===r.length))}function m(t){return t&&null!=t[o]?t[o]:'boolean'!=typeof t?.readable?null:!d(t)&&(l(t)&&t.readable&&!p(t))}function g(t){return'boolean'!=typeof t?.writable?null:!d(t)&&(c(t)&&t.writable&&!f(t))}function y(t){return'boolean'==typeof t._closed&&'boolean'==typeof t._defaultKeepAlive&&'boolean'==typeof t._removedConnection&&'boolean'==typeof t._removedContLen}function v(t){return'boolean'==typeof t._sent100&&y(t)}e.exports={kDestroyed:s,isDisturbed:function(t){var e;return!(!t||!(null!==(e=t[h])&&void 0!==e?e:t.readableDidRead||t.readableAborted))},kIsDisturbed:h,isErrored:function(t){var e,r,i,n,s,o,h,l,c,u;return!(!t||!(null!==(e=null!==(r=null!==(i=null!==(n=null!==(s=null!==(o=t[a])&&void 0!==o?o:t.readableErrored)&&void 0!==s?s:t.writableErrored)&&void 0!==n?n:null===(h=t._readableState)||void 0===h?void 0:h.errorEmitted)&&void 0!==i?i:null===(l=t._writableState)||void 0===l?void 0:l.errorEmitted)&&void 0!==r?r:null===(c=t._readableState)||void 0===c?void 0:c.errored)&&void 0!==e?e:null===(u=t._writableState)||void 0===u?void 0:u.errored))},kIsErrored:a,isReadable:m,kIsReadable:o,isClosed:function(t){if(!u(t))return null;if('boolean'==typeof t.closed)return t.closed;let{_writableState:e,_readableState:r}=t;return'boolean'==typeof e?.closed||'boolean'==typeof r?.closed?e?.closed||r?.closed:'boolean'==typeof t._closed&&y(t)?t._closed:null},isDestroyed:d,isDuplexNodeStream:function(t){return!(!t||'function'!=typeof t.pipe||!t._readableState||'function'!=typeof t.on||'function'!=typeof t.write)},isFinished:function(t,e){return u(t)?!!d(t)||!(!1!==e?.readable&&m(t)||!1!==e?.writable&&g(t)):null},isIterable:function(t,e){return null!=t&&(!0===e?'function'==typeof t[i]:!1===e?'function'==typeof t[n]:'function'==typeof t[i]||'function'==typeof t[n])},isReadableNodeStream:l,isReadableEnded:function(t){if(!l(t))return null;if(!0===t.readableEnded)return!0;let e=t._readableState;return!(!e||e.errored)&&('boolean'!=typeof e?.ended?null:e.ended)},isReadableFinished:p,isReadableErrored:function(t){var e,r;return u(t)?t.readableErrored?t.readableErrored:null!==(e=null===(r=t._readableState)||void 0===r?void 0:r.errored)&&void 0!==e?e:null:null},isNodeStream:u,isWritable:g,isWritableNodeStream:c,isWritableEnded:f,isWritableFinished:function(t,e){if(!c(t))return null;if(!0===t.writableFinished)return!0;let r=t._writableState;return(null==r||!r.errored)&&('boolean'!=typeof r?.finished?null:!!(r.finished||!1===e&&!0===r.ended&&0===r.length))},isWritableErrored:function(t){var e,r;return u(t)?t.writableErrored?t.writableErrored:null!==(e=null===(r=t._writableState)||void 0===r?void 0:r.errored)&&void 0!==e?e:null:null},isServerRequest:function(t){var e;return'boolean'==typeof t._consuming&&'boolean'==typeof t._dumped&&void 0===(null===(e=t.req)||void 0===e?void 0:e.upgradeOrConnect)},isServerResponse:v,willEmitClose:function(t){if(!u(t))return null;let{_writableState:e,_readableState:r}=t,i=e||r;return!i&&v(t)||!!(i&&i.autoDestroy&&i.emitClose&&!1===i.closed)}}})),Bt=P(((t,e)=>{var r=(Rt(),x(Nt)),{AbortError:i,codes:n}=It(),{ERR_INVALID_ARG_TYPE:s,ERR_STREAM_PREMATURE_CLOSE:a}=n,{kEmptyObject:o,once:h}=Tt(),{validateAbortSignal:l,validateFunction:c,validateObject:u}=Ct(),{Promise:d}=St(),{isClosed:f,isReadable:p,isReadableNodeStream:m,isReadableFinished:g,isReadableErrored:y,isWritable:v,isWritableNodeStream:b,isWritableFinished:_,isWritableErrored:w,isNodeStream:E,willEmitClose:A}=Pt();var S=()=>{};function T(t,e,n){var d,T;2===arguments.length?(n=e,e=o):null==e?e=o:u(e,'options'),c(n,'callback'),l(e.signal,'options.signal'),n=h(n);let M=null!==(d=e.readable)&&void 0!==d?d:m(t),I=null!==(T=e.writable)&&void 0!==T?T:b(t);if(!E(t))throw new s('stream','Stream',t);let{_writableState:C,_readableState:O}=t,N=()=>{t.writable||P()},L=A(t)&&m(t)===M&&b(t)===I,R=_(t,!1),P=()=>{R=!0,t.destroyed&&(L=!1),(!L||t.readable&&!M)&&(!M||B)&&n.call(t)},B=g(t,!1),k=()=>{B=!0,t.destroyed&&(L=!1),(!L||t.writable&&!I)&&(!I||R)&&n.call(t)},D=e=>{n.call(t,e)},U=f(t),x=()=>{U=!0;let e=w(t)||y(t);return e&&'boolean'!=typeof e?n.call(t,e):M&&!B&&m(t,!0)&&!g(t,!1)?n.call(t,new a):!I||R||_(t,!1)?void n.call(t):n.call(t,new a)},F=()=>{t.req.on('finish',P)};!function(t){return t.setHeader&&'function'==typeof t.abort}(t)?I&&!C&&(t.on('end',N),t.on('close',N)):(t.on('complete',P),L||t.on('abort',x),t.req?F():t.on('request',F)),!L&&'boolean'==typeof t.aborted&&t.on('aborted',x),t.on('end',k),t.on('finish',P),!1!==e.error&&t.on('error',D),t.on('close',x),U?r.nextTick(x):null!=C&&C.errorEmitted||null!=O&&O.errorEmitted?L||r.nextTick(x):(!M&&(!L||p(t))&&(R||!1===v(t))||!I&&(!L||v(t))&&(B||!1===p(t))||O&&t.req&&t.aborted)&&r.nextTick(x);let H=()=>{n=S,t.removeListener('aborted',x),t.removeListener('complete',P),t.removeListener('abort',x),t.removeListener('request',F),t.req&&t.req.removeListener('finish',P),t.removeListener('end',N),t.removeListener('close',N),t.removeListener('finish',P),t.removeListener('end',k),t.removeListener('error',D),t.removeListener('close',x)};if(e.signal&&!U){let s=()=>{let r=n;H(),r.call(t,new i(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)r.nextTick(s);else{let r=n;n=h(((...i)=>{e.signal.removeEventListener('abort',s),r.apply(t,i)})),e.signal.addEventListener('abort',s)}}return H}e.exports=T,e.exports.finished=function(t,e){return new d(((r,i)=>{T(t,e,(t=>{t?i(t):r()}))}))}})),kt=P(((t,e)=>{var r=globalThis.AbortController||Mt().AbortController,{codes:{ERR_INVALID_ARG_TYPE:i,ERR_MISSING_ARGS:n,ERR_OUT_OF_RANGE:s},AbortError:a}=It(),{validateAbortSignal:o,validateInteger:h,validateObject:l}=Ct(),c=St().Symbol('kWeak'),{finished:u}=Bt(),{ArrayPrototypePush:d,MathFloor:f,Number:p,NumberIsNaN:m,Promise:g,PromiseReject:y,PromisePrototypeThen:v,Symbol:b}=St(),_=b('kEmpty'),w=b('kEof');function E(t,e){if('function'!=typeof t)throw new i('fn',['Function','AsyncFunction'],t);null!=e&&l(e,'options'),null!=e?.signal&&o(e.signal,'options.signal');let n=1;return null!=e?.concurrency&&(n=f(e.concurrency)),h(n,'concurrency',1),async function*(){var i,s;let o=new r,h=this,l=[],c=o.signal,u={signal:c},d=()=>o.abort();null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted&&d(),null==e||null===(s=e.signal)||void 0===s||s.addEventListener('abort',d);let f,p,m=!1;function b(){m=!0}!async function(){try{for await(let e of h){var r;if(m)return;if(c.aborted)throw new a;try{e=t(e,u)}catch(t){e=y(t)}e!==_&&('function'==typeof(null===(r=e)||void 0===r?void 0:r.catch)&&e.catch(b),l.push(e),f&&(f(),f=null),!m&&l.length&&l.length>=n&&await new g((t=>{p=t})))}l.push(w)}catch(t){let e=y(t);v(e,void 0,b),l.push(e)}finally{var i;m=!0,f&&(f(),f=null),null==e||null===(i=e.signal)||void 0===i||i.removeEventListener('abort',d)}}();try{for(;;){for(;l.length>0;){let t=await l[0];if(t===w)return;if(c.aborted)throw new a;t!==_&&(yield t),l.shift(),p&&(p(),p=null)}await new g((t=>{f=t}))}}finally{o.abort(),m=!0,p&&(p(),p=null)}}.call(this)}async function A(t,e=void 0){for await(let r of S.call(this,t,e))return!0;return!1}function S(t,e){if('function'!=typeof t)throw new i('fn',['Function','AsyncFunction'],t);return E.call(this,(async function(e,r){return await t(e,r)?e:_}),e)}var T=class extends n{constructor(){super('reduce'),this.message='Reduce of an empty stream requires an initial value'}};function M(t){if(t=p(t),m(t))return 0;if(t<0)throw new s('number','>= 0',t);return t}e.exports.streamReturningOperators={asIndexedPairs:function(t=void 0){return null!=t&&l(t,'options'),null!=t?.signal&&o(t.signal,'options.signal'),async function*(){let e=0;for await(let i of this){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new a({cause:t.signal.reason});yield[e++,i]}}.call(this)},drop:function(t,e=void 0){return null!=e&&l(e,'options'),null!=e?.signal&&o(e.signal,'options.signal'),t=M(t),async function*(){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new a;for await(let r of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new a;t--<=0&&(yield r)}}.call(this)},filter:S,flatMap:function(t,e){let r=E.call(this,t,e);return async function*(){for await(let t of r)yield*t}.call(this)},map:E,take:function(t,e=void 0){return null!=e&&l(e,'options'),null!=e?.signal&&o(e.signal,'options.signal'),t=M(t),async function*(){var r;if(null!=e&&null!==(r=e.signal)&&void 0!==r&&r.aborted)throw new a;for await(let r of this){var i;if(null!=e&&null!==(i=e.signal)&&void 0!==i&&i.aborted)throw new a;if(!(t-- >0))return;yield r}}.call(this)}},e.exports.promiseReturningOperators={every:async function(t,e=void 0){if('function'!=typeof t)throw new i('fn',['Function','AsyncFunction'],t);return!await A.call(this,(async(...e)=>!await t(...e)),e)},forEach:async function(t,e){if('function'!=typeof t)throw new i('fn',['Function','AsyncFunction'],t);for await(let r of E.call(this,(async function(e,r){return await t(e,r),_}),e));},reduce:async function(t,e,n){var s;if('function'!=typeof t)throw new i('reducer',['Function','AsyncFunction'],t);null!=n&&l(n,'options'),null!=n?.signal&&o(n.signal,'options.signal');let h=arguments.length>1;if(null!=n&&null!==(s=n.signal)&&void 0!==s&&s.aborted){let t=new a(void 0,{cause:n.signal.reason});throw this.once('error',(()=>{})),await u(this.destroy(t)),t}let d=new r,f=d.signal;if(null!=n&&n.signal){let t={once:!0,[c]:this};n.signal.addEventListener('abort',(()=>d.abort()),t)}let p=!1;try{for await(let r of this){var m;if(p=!0,null!=n&&null!==(m=n.signal)&&void 0!==m&&m.aborted)throw new a;h?e=await t(e,r,{signal:f}):(e=r,h=!0)}if(!p&&!h)throw new T}finally{d.abort()}return e},toArray:async function(t){null!=t&&l(t,'options'),null!=t?.signal&&o(t.signal,'options.signal');let e=[];for await(let i of this){var r;if(null!=t&&null!==(r=t.signal)&&void 0!==r&&r.aborted)throw new a(void 0,{cause:t.signal.reason});d(e,i)}return e},some:A,find:async function(t,e){for await(let r of S.call(this,t,e))return r}}})),Dt=P(((t,e)=>{var r=(Rt(),x(Nt)),{aggregateTwoErrors:i,codes:{ERR_MULTIPLE_CALLBACK:n},AbortError:s}=It(),{Symbol:a}=St(),{kDestroyed:o,isDestroyed:h,isFinished:l,isServerRequest:c}=Pt(),u=a('kDestroy'),d=a('kConstruct');function f(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function p(t,e,i){let n=!1;function s(e){if(n)return;n=!0;let{_readableState:s,_writableState:a}=t;f(e,a,s),a&&(a.closed=!0),s&&(s.closed=!0),'function'==typeof i&&i(e),e?r.nextTick(m,t,e):r.nextTick(g,t)}try{t._destroy(e||null,s)}catch(t){s(t)}}function m(t,e){y(t,e),g(t)}function g(t){let{_readableState:e,_writableState:r}=t;r&&(r.closeEmitted=!0),e&&(e.closeEmitted=!0),(r&&r.emitClose||e&&e.emitClose)&&t.emit('close')}function y(t,e){let{_readableState:r,_writableState:i}=t;i&&i.errorEmitted||r&&r.errorEmitted||(i&&(i.errorEmitted=!0),r&&(r.errorEmitted=!0),t.emit('error',e))}function v(t,e,i){let{_readableState:n,_writableState:s}=t;if(s&&s.destroyed||n&&n.destroyed)return this;n&&n.autoDestroy||s&&s.autoDestroy?t.destroy(e):e&&(e.stack,s&&!s.errored&&(s.errored=e),n&&!n.errored&&(n.errored=e),i?r.nextTick(y,t,e):y(t,e))}function b(t){let e=!1;function i(i){if(e)return void v(t,i??new n);e=!0;let{_readableState:s,_writableState:a}=t,o=a||s;s&&(s.constructed=!0),a&&(a.constructed=!0),o.destroyed?t.emit(u,i):i?v(t,i,!0):r.nextTick(_,t)}try{t._construct(i)}catch(t){i(t)}}function _(t){t.emit(d)}function w(t){return t&&t.setHeader&&'function'==typeof t.abort}function E(t){t.emit('close')}function A(t,e){t.emit('error',e),r.nextTick(E,t)}e.exports={construct:function(t,e){if('function'!=typeof t._construct)return;let{_readableState:i,_writableState:n}=t;i&&(i.constructed=!1),n&&(n.constructed=!1),t.once(d,e),!(t.listenerCount(d)>1)&&r.nextTick(b,t)},destroyer:function(t,e){!t||h(t)||(!e&&!l(t)&&(e=new s),c(t)?(t.socket=null,t.destroy(e)):w(t)?t.abort():w(t.req)?t.req.abort():'function'==typeof t.destroy?t.destroy(e):'function'==typeof t.close?t.close():e?r.nextTick(A,t,e):r.nextTick(E,t),t.destroyed||(t[o]=!0))},destroy:function(t,e){let r=this._readableState,n=this._writableState,s=n||r;return n&&n.destroyed||r&&r.destroyed?('function'==typeof e&&e(),this):(f(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),s.constructed?p(this,t,e):this.once(u,(function(r){p(this,i(r,t),e)})),this)},undestroy:function(){let t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=!1===t.readable,t.endEmitted=!1===t.readable),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=!1===e.writable,e.ending=!1===e.writable,e.finished=!1===e.writable)},errorOrDestroy:v}})),Ut=P(((t,e)=>{var{ArrayIsArray:r,ObjectSetPrototypeOf:i}=St(),{EventEmitter:n}=W();function s(t){n.call(this,t)}function a(t,e,i){if('function'==typeof t.prependListener)return t.prependListener(e,i);t._events&&t._events[e]?r(t._events[e])?t._events[e].unshift(i):t._events[e]=[i,t._events[e]]:t.on(e,i)}i(s.prototype,n.prototype),i(s,n),s.prototype.pipe=function(t,e){let r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on('data',i),t.on('drain',s),!t._isStdio&&(!e||!1!==e.end)&&(r.on('end',h),r.on('close',l));let o=!1;function h(){o||(o=!0,t.end())}function l(){o||(o=!0,'function'==typeof t.destroy&&t.destroy())}function c(t){u(),0===n.listenerCount(this,'error')&&this.emit('error',t)}function u(){r.removeListener('data',i),t.removeListener('drain',s),r.removeListener('end',h),r.removeListener('close',l),r.removeListener('error',c),t.removeListener('error',c),r.removeListener('end',u),r.removeListener('close',u),t.removeListener('close',u)}return a(r,'error',c),a(t,'error',c),r.on('end',u),r.on('close',u),t.on('close',u),t.emit('pipe',r),t},e.exports={Stream:s,prependListener:a}})),xt=P(((t,e)=>{var{AbortError:r,codes:i}=It(),n=Bt(),{ERR_INVALID_ARG_TYPE:s}=i;e.exports.addAbortSignal=function(t,r){if(((t,e)=>{if('object'!=typeof t||!('aborted'in t))throw new s(e,'AbortSignal',t)})(t,'signal'),!function(t){return!(!t||'function'!=typeof t.pipe)}(r))throw new s('stream','stream.Stream',r);return e.exports.addAbortSignalNoValidate(t,r)},e.exports.addAbortSignalNoValidate=function(t,e){if('object'!=typeof t||!('aborted'in t))return e;let i=()=>{e.destroy(new r(void 0,{cause:t.reason}))};return t.aborted?i():(t.addEventListener('abort',i),n(e,(()=>t.removeEventListener('abort',i)))),e}})),Ft=P(((t,e)=>{var{StringPrototypeSlice:r,SymbolIterator:i,TypedArrayPrototypeSet:n,Uint8Array:s}=St(),{Buffer:a}=j(),{inspect:o}=Tt();e.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(t){let e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}unshift(t){let e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}shift(){if(0===this.length)return;let t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}clear(){this.head=this.tail=null,this.length=0}join(t){if(0===this.length)return'';let e=this.head,r=''+e.data;for(;null!==(e=e.next);)r+=t+e.data;return r}concat(t){if(0===this.length)return a.alloc(0);let e=a.allocUnsafe(t>>>0),r=this.head,i=0;for(;r;)n(e,r.data,i),i+=r.data.length,r=r.next;return e}consume(t,e){let r=this.head.data;if(ts.length)){t===s.length?(e+=s,++n,i.next?this.head=i.next:this.head=this.tail=null):(e+=r(s,0,t),this.head=i,i.data=r(s,t));break}e+=s,t-=s.length,++n}while(null!==(i=i.next));return this.length-=n,e}_getBuffer(t){let e=a.allocUnsafe(t),r=t,i=this.head,o=0;do{let a=i.data;if(!(t>a.length)){t===a.length?(n(e,a,r-t),++o,i.next?this.head=i.next:this.head=this.tail=null):(n(e,new s(a.buffer,a.byteOffset,t),r-t),this.head=i,i.data=a.slice(t));break}n(e,a,r-t),t-=a.length,++o}while(null!==(i=i.next));return this.length-=o,e}[Symbol.for('nodejs.util.inspect.custom')](t,e){return o(this,{...e,depth:0,customInspect:!1})}}})),Ht=P(((t,e)=>{var{MathFloor:r,NumberIsInteger:i}=St(),{ERR_INVALID_ARG_VALUE:n}=It().codes;function s(t){return t?16:16384}e.exports={getHighWaterMark:function(t,e,a,o){let h=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,o,a);if(null!=h){if(!i(h)||h<0){throw new n(o?`options.${a}`:'options.highWaterMark',h)}return r(h)}return s(t.objectMode)},getDefaultHighWaterMark:s}})),jt=P(((t,e)=>{var r=(Rt(),x(Nt)),{PromisePrototypeThen:i,SymbolAsyncIterator:n,SymbolIterator:s}=St(),{Buffer:a}=j(),{ERR_INVALID_ARG_TYPE:o,ERR_STREAM_NULL_VALUES:h}=It().codes;e.exports=function(t,e,l){let c,u;if('string'==typeof e||e instanceof a)return new t({objectMode:!0,...l,read(){this.push(e),this.push(null)}});if(e&&e[n])u=!0,c=e[n]();else{if(!e||!e[s])throw new o('iterable',['Iterable'],e);u=!1,c=e[s]()}let d=new t({objectMode:!0,highWaterMark:1,...l}),f=!1;return d._read=function(){f||(f=!0,async function(){for(;;){try{let{value:t,done:e}=u?await c.next():c.next();if(e)d.push(null);else{let e=t&&'function'==typeof t.then?await t:t;if(null===e)throw f=!1,new h;if(d.push(e))continue;f=!1}}catch(t){d.destroy(t)}break}}())},d._destroy=function(t,e){i(async function(t){let e=null!=t,r='function'==typeof c.throw;if(e&&r){let{value:e,done:r}=await c.throw(t);if(await e,r)return}if('function'==typeof c.return){let{value:t}=await c.return();await t}}(t),(()=>r.nextTick(e,t)),(i=>r.nextTick(e,i||t)))},d}})),Vt=P(((t,e)=>{var r=(Rt(),x(Nt)),{ArrayPrototypeIndexOf:i,NumberIsInteger:n,NumberIsNaN:s,NumberParseInt:a,ObjectDefineProperties:o,ObjectKeys:h,ObjectSetPrototypeOf:l,Promise:c,SafeSet:u,SymbolAsyncIterator:d,Symbol:f}=St();e.exports=F,F.ReadableState=U;var{EventEmitter:p}=W(),{Stream:m,prependListener:g}=Ut(),{Buffer:y}=j(),{addAbortSignal:v}=xt(),b=Bt(),_=Tt().debuglog('stream',(t=>{_=t})),w=Ft(),E=Dt(),{getHighWaterMark:A,getDefaultHighWaterMark:S}=Ht(),{aggregateTwoErrors:T,codes:{ERR_INVALID_ARG_TYPE:M,ERR_METHOD_NOT_IMPLEMENTED:I,ERR_OUT_OF_RANGE:C,ERR_STREAM_PUSH_AFTER_EOF:O,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:N}}=It(),{validateObject:L}=Ct(),R=f('kPaused'),{StringDecoder:P}=et(),B=jt();l(F.prototype,m.prototype),l(F,m);var k=()=>{},{errorOrDestroy:D}=E;function U(t,e,r){'boolean'!=typeof r&&(r=e instanceof Wt()),this.objectMode=!(!t||!t.objectMode),r&&(this.objectMode=this.objectMode||!(!t||!t.readableObjectMode)),this.highWaterMark=t?A(this,t,'readableHighWaterMark',r):S(!1),this.buffer=new w,this.length=0,this.pipes=[],this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.constructed=!0,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this[R]=null,this.errorEmitted=!1,this.emitClose=!t||!1!==t.emitClose,this.autoDestroy=!t||!1!==t.autoDestroy,this.destroyed=!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this.defaultEncoding=t&&t.defaultEncoding||'utf8',this.awaitDrainWriters=null,this.multiAwaitDrain=!1,this.readingMore=!1,this.dataEmitted=!1,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new P(t.encoding),this.encoding=t.encoding)}function F(t){if(!(this instanceof F))return new F(t);let e=this instanceof Wt();this._readableState=new U(t,this,e),t&&('function'==typeof t.read&&(this._read=t.read),'function'==typeof t.destroy&&(this._destroy=t.destroy),'function'==typeof t.construct&&(this._construct=t.construct),t.signal&&!e&&v(t.signal,this)),m.call(this,t),E.construct(this,(()=>{this._readableState.needReadable&&Y(this,this._readableState)}))}function H(t,e,r,i){_('readableAddChunk',e);let n,s=t._readableState;if(s.objectMode||('string'==typeof e?(r=r||s.defaultEncoding,s.encoding!==r&&(i&&s.encoding?e=y.from(e,r).toString(s.encoding):(e=y.from(e,r),r=''))):e instanceof y?r='':m._isUint8Array(e)?(e=m._uint8ArrayToBuffer(e),r=''):null!=e&&(n=new M('chunk',['string','Buffer','Uint8Array'],e))),n)D(t,n);else if(null===e)s.reading=!1,function(t,e){if(_('onEofChunk'),!e.ended){if(e.decoder){let t=e.decoder.end();t&&t.length&&(e.buffer.push(t),e.length+=e.objectMode?1:t.length)}e.ended=!0,e.sync?K(t):(e.needReadable=!1,e.emittedReadable=!0,q(t))}}(t,s);else if(s.objectMode||e&&e.length>0)if(i)if(s.endEmitted)D(t,new N);else{if(s.destroyed||s.errored)return!1;V(t,s,e,!0)}else if(s.ended)D(t,new O);else{if(s.destroyed||s.errored)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?V(t,s,e,!1):Y(t,s)):V(t,s,e,!1)}else i||(s.reading=!1,Y(t,s));return!s.ended&&(s.length0?(e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null,e.dataEmitted=!0,t.emit('data',r)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&K(t)),Y(t,e)}F.prototype.destroy=E.destroy,F.prototype._undestroy=E.undestroy,F.prototype._destroy=function(t,e){e(t)},F.prototype[p.captureRejectionSymbol]=function(t){this.destroy(t)},F.prototype.push=function(t,e){return H(this,t,e,!1)},F.prototype.unshift=function(t,e){return H(this,t,e,!0)},F.prototype.isPaused=function(){let t=this._readableState;return!0===t[R]||!1===t.flowing},F.prototype.setEncoding=function(t){let e=new P(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;let r=this._readableState.buffer,i='';for(let t of r)i+=e.write(t);return r.clear(),''!==i&&r.push(i),this._readableState.length=i.length,this};var G;function z(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:s(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}function K(t){let e=t._readableState;_('emitReadable',e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(_('emitReadable',e.flowing),e.emittedReadable=!0,r.nextTick(q,t))}function q(t){let e=t._readableState;_('emitReadable_',e.destroyed,e.length,e.ended),!e.destroyed&&!e.errored&&(e.length||e.ended)&&(t.emit('readable'),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,J(t)}function Y(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,r.nextTick(Z,t,e))}function Z(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!1===e[R]?e.flowing=!0:t.listenerCount('data')>0?t.resume():e.readableListening||(e.flowing=null)}function X(t){_('readable nexttick read 0'),t.read(0)}function Q(t,e){_('resume',e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit('resume'),J(t),e.flowing&&!e.reading&&t.read(0)}function J(t){let e=t._readableState;for(_('flow',e.flowing);e.flowing&&null!==t.read(););}function tt(t,e){'function'!=typeof t.read&&(t=F.wrap(t,{objectMode:!0}));let r=async function*(t,e){let r=k;function i(e){this===t?(r(),r=k):r=e}t.on('readable',i);let n,s=b(t,{writable:!1},(t=>{n=t?T(n,t):null,r(),r=k}));try{for(;;){let e=t.destroyed?null:t.read();if(null!==e)yield e;else{if(n)throw n;if(null===n)return;await new c(i)}}}catch(t){throw n=T(n,t),n}finally{!n&&!1===e?.destroyOnReturn||void 0!==n&&!t._readableState.autoDestroy?(t.off('readable',i),s()):E.destroyer(t,null)}}(t,e);return r.stream=t,r}function rt(t,e){if(0===e.length)return null;let r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(''):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function it(t){let e=t._readableState;_('endReadable',e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(nt,e,t))}function nt(t,e){if(_('endReadableNT',t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&0===t.length)if(t.endEmitted=!0,e.emit('end'),e.writable&&!1===e.allowHalfOpen)r.nextTick(st,e);else if(t.autoDestroy){let t=e._writableState;(!t||t.autoDestroy&&(t.finished||!1===t.writable))&&e.destroy()}}function st(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}function at(){return void 0===G&&(G={}),G}F.prototype.read=function(t){_('read',t),void 0===t?t=NaN:n(t)||(t=a(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=function(t){if(t>1073741824)throw new C('size','<= 1GiB',t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,++t}(t)),0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return _('read: emitReadable',e.length,e.ended),0===e.length&&e.ended?it(this):K(this),null;if(0===(t=z(t,e))&&e.ended)return 0===e.length&&it(this),null;let i,s=e.needReadable;if(_('need readable',s),(0===e.length||e.length-t0?rt(t,e):null,null===i?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&it(this)),null!==i&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit('data',i)),i},F.prototype._read=function(t){throw new I('_read()')},F.prototype.pipe=function(t,e){let i=this,n=this._readableState;1===n.pipes.length&&(n.multiAwaitDrain||(n.multiAwaitDrain=!0,n.awaitDrainWriters=new u(n.awaitDrainWriters?[n.awaitDrainWriters]:[]))),n.pipes.push(t),_('pipe count=%d opts=%j',n.pipes.length,e);let s=e&&!1===e.end||t===r.stdout||t===r.stderr?y:o;function a(e,r){_('onunpipe'),e===i&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,_('cleanup'),t.removeListener('close',p),t.removeListener('finish',m),h&&t.removeListener('drain',h),t.removeListener('error',f),t.removeListener('unpipe',a),i.removeListener('end',o),i.removeListener('end',y),i.removeListener('data',d),l=!0,h&&n.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&h())}function o(){_('onend'),t.end()}n.endEmitted?r.nextTick(s):i.once('end',s),t.on('unpipe',a);let h,l=!1;function c(){l||(1===n.pipes.length&&n.pipes[0]===t?(_('false write response, pause',0),n.awaitDrainWriters=t,n.multiAwaitDrain=!1):n.pipes.length>1&&n.pipes.includes(t)&&(_('false write response, pause',n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),i.pause()),h||(h=function(t,e){return function(){let r=t._readableState;r.awaitDrainWriters===e?(_('pipeOnDrain',1),r.awaitDrainWriters=null):r.multiAwaitDrain&&(_('pipeOnDrain',r.awaitDrainWriters.size),r.awaitDrainWriters.delete(e)),(!r.awaitDrainWriters||0===r.awaitDrainWriters.size)&&t.listenerCount('data')&&t.resume()}}(i,t),t.on('drain',h))}function d(e){_('ondata');let r=t.write(e);_('dest.write',r),!1===r&&c()}function f(e){if(_('onerror',e),y(),t.removeListener('error',f),0===t.listenerCount('error')){let r=t._writableState||t._readableState;r&&!r.errorEmitted?D(t,e):t.emit('error',e)}}function p(){t.removeListener('finish',m),y()}function m(){_('onfinish'),t.removeListener('close',p),y()}function y(){_('unpipe'),i.unpipe(t)}return i.on('data',d),g(t,'error',f),t.once('close',p),t.once('finish',m),t.emit('pipe',i),!0===t.writableNeedDrain?n.flowing&&c():n.flowing||(_('pipe resume'),i.resume()),t},F.prototype.unpipe=function(t){let e=this._readableState;if(0===e.pipes.length)return this;if(!t){let t=e.pipes;e.pipes=[],this.pause();for(let e=0;e0,!1!==n.flowing&&this.resume()):'readable'===t&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,_('on readable',n.length,n.reading),n.length?K(this):n.reading||r.nextTick(X,this)),i},F.prototype.addListener=F.prototype.on,F.prototype.removeListener=function(t,e){let i=m.prototype.removeListener.call(this,t,e);return'readable'===t&&r.nextTick($,this),i},F.prototype.off=F.prototype.removeListener,F.prototype.removeAllListeners=function(t){let e=m.prototype.removeAllListeners.apply(this,arguments);return('readable'===t||void 0===t)&&r.nextTick($,this),e},F.prototype.resume=function(){let t=this._readableState;return t.flowing||(_('resume'),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(Q,t,e))}(this,t)),t[R]=!1,this},F.prototype.pause=function(){return _('call pause flowing=%j',this._readableState.flowing),!1!==this._readableState.flowing&&(_('pause'),this._readableState.flowing=!1,this.emit('pause')),this._readableState[R]=!0,this},F.prototype.wrap=function(t){let e=!1;t.on('data',(r=>{!this.push(r)&&t.pause&&(e=!0,t.pause())})),t.on('end',(()=>{this.push(null)})),t.on('error',(t=>{D(this,t)})),t.on('close',(()=>{this.destroy()})),t.on('destroy',(()=>{this.destroy()})),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=h(t);for(let e=1;e{var r=(Rt(),x(Nt)),{ArrayPrototypeSlice:i,Error:n,FunctionPrototypeSymbolHasInstance:s,ObjectDefineProperty:a,ObjectDefineProperties:o,ObjectSetPrototypeOf:h,StringPrototypeToLowerCase:l,Symbol:c,SymbolHasInstance:u}=St();e.exports=P,P.WritableState=L;var{EventEmitter:d}=W(),f=Ut().Stream,{Buffer:p}=j(),m=Dt(),{addAbortSignal:g}=xt(),{getHighWaterMark:y,getDefaultHighWaterMark:v}=Ht(),{ERR_INVALID_ARG_TYPE:b,ERR_METHOD_NOT_IMPLEMENTED:_,ERR_MULTIPLE_CALLBACK:w,ERR_STREAM_CANNOT_PIPE:E,ERR_STREAM_DESTROYED:A,ERR_STREAM_ALREADY_FINISHED:S,ERR_STREAM_NULL_VALUES:T,ERR_STREAM_WRITE_AFTER_END:M,ERR_UNKNOWN_ENCODING:I}=It().codes,{errorOrDestroy:C}=m;function O(){}h(P.prototype,f.prototype),h(P,f);var N=c('kOnFinished');function L(t,e,r){'boolean'!=typeof r&&(r=e instanceof Wt()),this.objectMode=!(!t||!t.objectMode),r&&(this.objectMode=this.objectMode||!(!t||!t.writableObjectMode)),this.highWaterMark=t?y(this,t,'writableHighWaterMark',r):v(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let i=!(!t||!1!==t.decodeStrings);this.decodeStrings=!i,this.defaultEncoding=t&&t.defaultEncoding||'utf8',this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=U.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,R(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||!1!==t.emitClose,this.autoDestroy=!t||!1!==t.autoDestroy,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[N]=[]}function R(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}function P(t){let e=this instanceof Wt();if(!e&&!s(P,this))return new P(t);this._writableState=new L(t,this,e),t&&('function'==typeof t.write&&(this._write=t.write),'function'==typeof t.writev&&(this._writev=t.writev),'function'==typeof t.destroy&&(this._destroy=t.destroy),'function'==typeof t.final&&(this._final=t.final),'function'==typeof t.construct&&(this._construct=t.construct),t.signal&&g(t.signal,this)),f.call(this,t),m.construct(this,(()=>{let t=this._writableState;t.writing||G(this,t),q(this,t)}))}function B(t,e,i,n){let s,a=t._writableState;if('function'==typeof i)n=i,i=a.defaultEncoding;else{if(i){if('buffer'!==i&&!p.isEncoding(i))throw new I(i)}else i=a.defaultEncoding;'function'!=typeof n&&(n=O)}if(null===e)throw new T;if(!a.objectMode)if('string'==typeof e)!1!==a.decodeStrings&&(e=p.from(e,i),i='buffer');else if(e instanceof p)i='buffer';else{if(!f._isUint8Array(e))throw new b('chunk',['string','Buffer','Uint8Array'],e);e=f._uint8ArrayToBuffer(e),i='buffer'}return a.ending?s=new M:a.destroyed&&(s=new A('write')),s?(r.nextTick(n,s),C(t,s,!0),s):(a.pendingcb++,function(t,e,r,i,n){let s=e.objectMode?1:r.length;e.length+=s;let a=e.lengthi.bufferedIndex&&G(t,i),n?null!==i.afterWriteTickInfo&&i.afterWriteTickInfo.cb===s?i.afterWriteTickInfo.count++:(i.afterWriteTickInfo={count:1,cb:s,stream:t,state:i},r.nextTick(F,i.afterWriteTickInfo)):H(t,i,1,s))):C(t,new w)}function F({stream:t,state:e,count:r,cb:i}){return e.afterWriteTickInfo=null,H(t,e,r,i)}function H(t,e,r,i){for(!e.ending&&!t.destroyed&&0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit('drain'));r-- >0;)e.pendingcb--,i();e.destroyed&&V(e),q(t,e)}function V(t){if(t.writing)return;for(let r=t.bufferedIndex;r1&&t._writev){e.pendingcb-=a-1;let n=e.allNoop?O:t=>{for(let e=o;e256?(r.splice(0,o),e.bufferedIndex=0):e.bufferedIndex=o}e.bufferProcessing=!1}function z(t){return t.ending&&!t.destroyed&&t.constructed&&0===t.length&&!t.errored&&0===t.buffered.length&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function K(t,e){!e.prefinished&&!e.finalCalled&&('function'!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit('prefinish')):(e.finalCalled=!0,function(t,e){let i=!1;function n(n){if(i)C(t,n??w());else if(i=!0,e.pendingcb--,n){let r=e[N].splice(0);for(let t=0;t{z(e)?Y(t,e):e.pendingcb--}),t,e)):z(e)&&(e.pendingcb++,Y(t,e))))}function Y(t,e){e.pendingcb--,e.finished=!0;let r=e[N].splice(0);for(let t=0;t{var r=(Rt(),x(Nt)),i=j(),{isReadable:n,isWritable:s,isIterable:a,isNodeStream:o,isReadableNodeStream:h,isWritableNodeStream:l,isDuplexNodeStream:c}=Pt(),u=Bt(),{AbortError:d,codes:{ERR_INVALID_ARG_TYPE:f,ERR_INVALID_RETURN_VALUE:p}}=It(),{destroyer:m}=Dt(),g=Wt(),y=Vt(),{createDeferredPromise:v}=Tt(),b=jt(),_=globalThis.Blob||i.Blob,w=typeof _<'u'?function(t){return t instanceof _}:function(t){return!1},E=globalThis.AbortController||Mt().AbortController,{FunctionPrototypeCall:A}=St(),S=class extends g{constructor(t){super(t),!1===t?.readable&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),!1===t?.writable&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};function T(t){let e,r,i,a,o,h=t.readable&&'function'!=typeof t.readable.read?y.wrap(t.readable):t.readable,l=t.writable,c=!!n(h),f=!!s(l);function p(t){let e=a;a=null,e?e(t):t?o.destroy(t):!c&&!f&&o.destroy()}return o=new S({readableObjectMode:!(null==h||!h.readableObjectMode),writableObjectMode:!(null==l||!l.writableObjectMode),readable:c,writable:f}),f&&(u(l,(t=>{f=!1,t&&m(h,t),p(t)})),o._write=function(t,r,i){l.write(t,r)?i():e=i},o._final=function(t){l.end(),r=t},l.on('drain',(function(){if(e){let t=e;e=null,t()}})),l.on('finish',(function(){if(r){let t=r;r=null,t()}}))),c&&(u(h,(t=>{c=!1,t&&m(h,t),p(t)})),h.on('readable',(function(){if(i){let t=i;i=null,t()}})),h.on('end',(function(){o.push(null)})),o._read=function(){for(;;){let t=h.read();if(null===t)return void(i=o._read);if(!o.push(t))return}}),o._destroy=function(t,n){!t&&null!==a&&(t=new d),i=null,e=null,r=null,null===a?n(t):(a=n,m(l,t),m(h,t))},o}e.exports=function t(e,i){if(c(e))return e;if(h(e))return T({readable:e});if(l(e))return T({writable:e});if(o(e))return T({writable:!1,readable:!1});if('function'==typeof e){let{value:t,write:n,final:s,destroy:o}=function(t){let{promise:e,resolve:i}=v(),n=new E,s=n.signal;return{value:t(async function*(){for(;;){let t=e;e=null;let{chunk:n,done:a,cb:o}=await t;if(r.nextTick(o),a)return;if(s.aborted)throw new d(void 0,{cause:s.reason});({promise:e,resolve:i}=v()),yield n}}(),{signal:s}),write(t,e,r){let n=i;i=null,n({chunk:t,done:!1,cb:r})},final(t){let e=i;i=null,e({done:!0,cb:t})},destroy(t,e){n.abort(),e(t)}}}(e);if(a(t))return b(S,t,{objectMode:!0,write:n,final:s,destroy:o});let h=t?.then;if('function'==typeof h){let e,i=A(h,t,(t=>{if(null!=t)throw new p('nully','body',t)}),(t=>{m(e,t)}));return e=new S({objectMode:!0,readable:!1,write:n,final(t){s((async()=>{try{await i,r.nextTick(t,null)}catch(e){r.nextTick(t,e)}}))},destroy:o})}throw new p('Iterable, AsyncIterable or AsyncFunction',i,t)}if(w(e))return t(e.arrayBuffer());if(a(e))return b(S,e,{objectMode:!0,writable:!1});if('object'==typeof e?.writable||'object'==typeof e?.readable){return T({readable:null!=e&&e.readable?h(e?.readable)?e?.readable:t(e.readable):void 0,writable:null!=e&&e.writable?l(e?.writable)?e?.writable:t(e.writable):void 0})}let n=e?.then;if('function'==typeof n){let t;return A(n,e,(e=>{null!=e&&t.push(e),t.push(null)}),(e=>{m(t,e)})),t=new S({objectMode:!0,writable:!1,read(){}})}throw new f(i,['Blob','ReadableStream','WritableStream','Stream','Iterable','AsyncIterable','Function','{ readable, writable } pair','Promise'],e)}})),Wt=P(((t,e)=>{var{ObjectDefineProperties:r,ObjectGetOwnPropertyDescriptor:i,ObjectKeys:n,ObjectSetPrototypeOf:s}=St();e.exports=c;var a,o,h=Vt(),l=Gt();s(c.prototype,h.prototype),s(c,h);{let t=n(l.prototype);for(let e=0;e{var{ObjectSetPrototypeOf:r,Symbol:i}=St();e.exports=h;var{ERR_METHOD_NOT_IMPLEMENTED:n}=It().codes,s=Wt(),{getHighWaterMark:a}=Ht();r(h.prototype,s.prototype),r(h,s);var o=i('kCallback');function h(t){if(!(this instanceof h))return new h(t);let e=t?a(this,t,'readableHighWaterMark',!0):null;0===e&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),s.call(this,t),this._readableState.sync=!1,this[o]=null,t&&('function'==typeof t.transform&&(this._transform=t.transform),'function'==typeof t.flush&&(this._flush=t.flush)),this.on('prefinish',c)}function l(t){'function'!=typeof this._flush||this.destroyed?(this.push(null),t&&t()):this._flush(((e,r)=>{e?t?t(e):this.destroy(e):(null!=r&&this.push(r),this.push(null),t&&t())}))}function c(){this._final!==l&&l.call(this)}h.prototype._final=l,h.prototype._transform=function(t,e,r){throw new n('_transform()')},h.prototype._write=function(t,e,r){let i=this._readableState,n=this._writableState,s=i.length;this._transform(t,e,((t,e)=>{t?r(t):(null!=e&&this.push(e),n.ended||s===i.length||i.length{var{ObjectSetPrototypeOf:r}=St();e.exports=n;var i=Kt();function n(t){if(!(this instanceof n))return new n(t);i.call(this,t)}r(n.prototype,i.prototype),r(n,i),n.prototype._transform=function(t,e,r){r(null,t)}})),Yt=P(((t,e)=>{var r,i,n=(Rt(),x(Nt)),{ArrayIsArray:s,Promise:a,SymbolAsyncIterator:o}=St(),h=Bt(),{once:l}=Tt(),c=Dt(),u=Wt(),{aggregateTwoErrors:d,codes:{ERR_INVALID_ARG_TYPE:f,ERR_INVALID_RETURN_VALUE:p,ERR_MISSING_ARGS:m,ERR_STREAM_DESTROYED:g,ERR_STREAM_PREMATURE_CLOSE:y},AbortError:v}=It(),{validateFunction:b,validateAbortSignal:_}=Ct(),{isIterable:w,isReadable:E,isReadableNodeStream:A,isNodeStream:S}=Pt(),T=globalThis.AbortController||Mt().AbortController;function M(t,e,r){let i=!1;return t.on('close',(()=>{i=!0})),{destroy:e=>{i||(i=!0,c.destroyer(t,e||new g('pipe')))},cleanup:h(t,{readable:e,writable:r},(t=>{i=!t}))}}function I(t){if(w(t))return t;if(A(t))return async function*(t){i||(i=Vt()),yield*i.prototype[o].call(t)}(t);throw new f('val',['Readable','Iterable','AsyncIterable'],t)}async function C(t,e,r,{end:i}){let n,s=null,o=t=>{if(t&&(n=t),s){let t=s;s=null,t()}},l=()=>new a(((t,e)=>{n?e(n):s=()=>{n?e(n):t()}}));e.on('drain',o);let c=h(e,{readable:!1},o);try{e.writableNeedDrain&&await l();for await(let r of t)e.write(r)||await l();i&&e.end(),await l(),r()}catch(t){r(n!==t?d(n,t):t)}finally{c(),e.off('drain',o)}}function O(t,e,i){if(1===t.length&&s(t[0])&&(t=t[0]),t.length<2)throw new m('streams');let a=new T,o=a.signal,h=i?.signal,l=[];function c(){R(new v)}_(h,'options.signal'),h?.addEventListener('abort',c);let d,g,y,b=[],O=0;function L(t){R(t,0==--O)}function R(t,r){if(t&&(!d||'ERR_STREAM_PREMATURE_CLOSE'===d.code)&&(d=t),d||r){for(;b.length;)b.shift()(d);h?.removeEventListener('abort',c),a.abort(),r&&(d||l.forEach((t=>t())),n.nextTick(e,d,g))}}for(let e=0;e0,c=a||!1!==i?.end,d=e===t.length-1;if(S(s)){let t=function(t){t&&'AbortError'!==t.name&&'ERR_STREAM_PREMATURE_CLOSE'!==t.code&&L(t)};if(c){let{destroy:t,cleanup:e}=M(s,a,h);b.push(t),E(s)&&d&&l.push(e)}s.on('error',t),E(s)&&d&&l.push((()=>{s.removeListener('error',t)}))}if(0===e)if('function'==typeof s){if(y=s({signal:o}),!w(y))throw new p('Iterable, AsyncIterable or Stream','source',y)}else y=w(s)||A(s)?s:u.from(s);else if('function'==typeof s)if(y=I(y),y=s(y,{signal:o}),a){if(!w(y,!0))throw new p('AsyncIterable',`transform[${e-1}]`,y)}else{var P;r||(r=qt());let t=new r({objectMode:!0}),e=null===(P=y)||void 0===P?void 0:P.then;if('function'==typeof e)O++,e.call(y,(e=>{g=e,null!=e&&t.write(e),c&&t.end(),n.nextTick(L)}),(e=>{t.destroy(e),n.nextTick(L,e)}));else{if(!w(y,!0))throw new p('AsyncIterable or Promise','destination',y);O++,C(y,t,L,{end:c})}y=t;let{destroy:i,cleanup:s}=M(y,!1,!0);b.push(i),d&&l.push(s)}else if(S(s)){if(A(y)){O+=2;let t=N(y,s,L,{end:c});E(s)&&d&&l.push(t)}else{if(!w(y))throw new f('val',['Readable','Iterable','AsyncIterable'],y);O++,C(y,s,L,{end:c})}y=s}else y=u.from(s)}return(null!=o&&o.aborted||null!=h&&h.aborted)&&n.nextTick(c),y}function N(t,e,r,{end:i}){let n=!1;return e.on('close',(()=>{n||r(new y)})),t.pipe(e,{end:i}),i?t.once('end',(()=>{n=!0,e.end()})):r(),h(t,{readable:!0,writable:!1},(e=>{let i=t._readableState;e&&'ERR_STREAM_PREMATURE_CLOSE'===e.code&&i&&i.ended&&!i.errored&&!i.errorEmitted?t.once('end',r).once('error',r):r(e)})),h(e,{readable:!1,writable:!0},r)}e.exports={pipelineImpl:O,pipeline:function(...t){return O(t,l(function(t){return b(t[t.length-1],'streams[stream.length - 1]'),t.pop()}(t)))}}})),Zt=P(((t,e)=>{var{pipeline:r}=Yt(),i=Wt(),{destroyer:n}=Dt(),{isNodeStream:s,isReadable:a,isWritable:o}=Pt(),{AbortError:h,codes:{ERR_INVALID_ARG_VALUE:l,ERR_MISSING_ARGS:c}}=It();e.exports=function(...t){if(0===t.length)throw new c('streams');if(1===t.length)return i.from(t[0]);let e,u,d,f,p,m=[...t];if('function'==typeof t[0]&&(t[0]=i.from(t[0])),'function'==typeof t[t.length-1]){let e=t.length-1;t[e]=i.from(t[e])}for(let e=0;e0&&!o(t[e]))throw new l(`streams[${e}]`,m[e],'must be writable')}let g=t[0],y=r(t,(function(t){let e=f;f=null,e?e(t):t?p.destroy(t):!b&&!v&&p.destroy()})),v=!!o(g),b=!!a(y);return p=new i({writableObjectMode:!(null==g||!g.writableObjectMode),readableObjectMode:!(null==y||!y.writableObjectMode),writable:v,readable:b}),v&&(p._write=function(t,r,i){g.write(t,r)?i():e=i},p._final=function(t){g.end(),u=t},g.on('drain',(function(){if(e){let t=e;e=null,t()}})),y.on('finish',(function(){if(u){let t=u;u=null,t()}}))),b&&(y.on('readable',(function(){if(d){let t=d;d=null,t()}})),y.on('end',(function(){p.push(null)})),p._read=function(){for(;;){let t=y.read();if(null===t)return void(d=p._read);if(!p.push(t))return}}),p._destroy=function(t,r){!t&&null!==f&&(t=new h),d=null,e=null,u=null,null===f?r(t):(f=r,n(y,t))},p}})),$t=P(((t,e)=>{var{ArrayPrototypePop:r,Promise:i}=St(),{isIterable:n,isNodeStream:s}=Pt(),{pipelineImpl:a}=Yt(),{finished:o}=Bt();e.exports={finished:o,pipeline:function(...t){return new i(((e,i)=>{let o,h,l=t[t.length-1];if(l&&'object'==typeof l&&!s(l)&&!n(l)){let e=r(t);o=e.signal,h=e.end}a(t,((t,r)=>{t?i(t):e(r)}),{signal:o,end:h})}))}}})),Xt=P(((t,e)=>{var{Buffer:r}=j(),{ObjectDefineProperty:i,ObjectKeys:n,ReflectApply:s}=St(),{promisify:{custom:a}}=Tt(),{streamReturningOperators:o,promiseReturningOperators:h}=kt(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:l}}=It(),c=Zt(),{pipeline:u}=Yt(),{destroyer:d}=Dt(),f=Bt(),p=$t(),m=Pt(),g=e.exports=Ut().Stream;g.isDisturbed=m.isDisturbed,g.isErrored=m.isErrored,g.isReadable=m.isReadable,g.Readable=Vt();for(let t of n(o)){let e=function(...t){if(new.target)throw l();return g.Readable.from(s(r,this,t))};e;let r=o[t];i(e,'name',{__proto__:null,value:r.name}),i(e,'length',{__proto__:null,value:r.length}),i(g.Readable.prototype,t,{__proto__:null,value:e,enumerable:!1,configurable:!0,writable:!0})}for(let t of n(h)){let e=function(...t){if(new.target)throw l();return s(r,this,t)};e;let r=h[t];i(e,'name',{__proto__:null,value:r.name}),i(e,'length',{__proto__:null,value:r.length}),i(g.Readable.prototype,t,{__proto__:null,value:e,enumerable:!1,configurable:!0,writable:!0})}g.Writable=Gt(),g.Duplex=Wt(),g.Transform=Kt(),g.PassThrough=qt(),g.pipeline=u;var{addAbortSignal:y}=xt();g.addAbortSignal=y,g.finished=f,g.destroy=d,g.compose=c,i(g,'promises',{__proto__:null,configurable:!0,enumerable:!0,get:()=>p}),i(u,a,{__proto__:null,enumerable:!0,get:()=>p.pipeline}),i(f,a,{__proto__:null,enumerable:!0,get:()=>p.finished}),g.Stream=g,g._isUint8Array=function(t){return t instanceof Uint8Array},g._uint8ArrayToBuffer=function(t){return r.from(t.buffer,t.byteOffset,t.byteLength)}})),Qt=P(((t,e)=>{var r=Xt(),i=$t(),n=r.Readable.destroy;e.exports=r.Readable,e.exports._uint8ArrayToBuffer=r._uint8ArrayToBuffer,e.exports._isUint8Array=r._isUint8Array,e.exports.isDisturbed=r.isDisturbed,e.exports.isErrored=r.isErrored,e.exports.isReadable=r.isReadable,e.exports.Readable=r.Readable,e.exports.Writable=r.Writable,e.exports.Duplex=r.Duplex,e.exports.Transform=r.Transform,e.exports.PassThrough=r.PassThrough,e.exports.addAbortSignal=r.addAbortSignal,e.exports.finished=r.finished,e.exports.destroy=r.destroy,e.exports.destroy=n,e.exports.pipeline=r.pipeline,e.exports.compose=r.compose,Object.defineProperty(r,'promises',{configurable:!0,enumerable:!0,get:()=>i}),e.exports.Stream=r.Stream,e.exports.default=e.exports})),B(Jt={},{default:()=>te}),ee=R((()=>{D(Jt,U(Qt())),te=U(Qt())})),re=P(((t,e)=>{var r=V().Buffer,i=(ee(),x(Jt)).Transform,n=et().StringDecoder;function s(t){i.call(this),this.hashMode='string'==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}z()(s,i),s.prototype.update=function(t,e,i){'string'==typeof t&&(t=r.from(t,e));var n=this._update(t);return this.hashMode?this:(i&&(n=this._toString(n,i)),n)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error('trying to get auth tag in unsupported state')},s.prototype.setAuthTag=function(){throw new Error('trying to set auth tag in unsupported state')},s.prototype.setAAD=function(){throw new Error('trying to set aad in unsupported state')},s.prototype._transform=function(t,e,r){var i;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){i=t}finally{r(i)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||r.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new n(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var i=this._decoder.write(t);return r&&(i+=this._decoder.end()),i},e.exports=s})),ie=P(((t,e)=>{var r=z(),i=pt(),n=mt(),s=At(),a=re();function o(t){a.call(this,'digest'),this._hash=t}r(o,a),o.prototype._update=function(t){this._hash.update(t)},o.prototype._final=function(){return this._hash.digest()},e.exports=function(t){return'md5'===(t=t.toLowerCase())?new i:'rmd160'===t||'ripemd160'===t?new n:new o(s(t))}})),ne=P(((t,e)=>{var r=z(),i=V().Buffer,n=re(),s=i.alloc(128),a=64;function o(t,e){n.call(this,'digest'),'string'==typeof e&&(e=i.from(e)),this._alg=t,this._key=e,e.length>a?e=t(e):e.length{var r=pt();e.exports=function(t){return(new r).update(t).digest()}})),ae=P(((t,e)=>{var r=z(),i=ne(),n=re(),s=V().Buffer,a=se(),o=mt(),h=At(),l=s.alloc(128);function c(t,e){n.call(this,'digest'),'string'==typeof e&&(e=s.from(e));var r='sha512'===t||'sha384'===t?128:64;(this._alg=t,this._key=e,e.length>r)?e=('rmd160'===t?new o:h(t)).update(e).digest():e.length{e.exports={sha224WithRSAEncryption:{sign:'rsa',hash:'sha224',id:'302d300d06096086480165030402040500041c'},'RSA-SHA224':{sign:'ecdsa/rsa',hash:'sha224',id:'302d300d06096086480165030402040500041c'},sha256WithRSAEncryption:{sign:'rsa',hash:'sha256',id:'3031300d060960864801650304020105000420'},'RSA-SHA256':{sign:'ecdsa/rsa',hash:'sha256',id:'3031300d060960864801650304020105000420'},sha384WithRSAEncryption:{sign:'rsa',hash:'sha384',id:'3041300d060960864801650304020205000430'},'RSA-SHA384':{sign:'ecdsa/rsa',hash:'sha384',id:'3041300d060960864801650304020205000430'},sha512WithRSAEncryption:{sign:'rsa',hash:'sha512',id:'3051300d060960864801650304020305000440'},'RSA-SHA512':{sign:'ecdsa/rsa',hash:'sha512',id:'3051300d060960864801650304020305000440'},'RSA-SHA1':{sign:'rsa',hash:'sha1',id:'3021300906052b0e03021a05000414'},'ecdsa-with-SHA1':{sign:'ecdsa',hash:'sha1',id:''},sha256:{sign:'ecdsa',hash:'sha256',id:''},sha224:{sign:'ecdsa',hash:'sha224',id:''},sha384:{sign:'ecdsa',hash:'sha384',id:''},sha512:{sign:'ecdsa',hash:'sha512',id:''},'DSA-SHA':{sign:'dsa',hash:'sha1',id:''},'DSA-SHA1':{sign:'dsa',hash:'sha1',id:''},DSA:{sign:'dsa',hash:'sha1',id:''},'DSA-WITH-SHA224':{sign:'dsa',hash:'sha224',id:''},'DSA-SHA224':{sign:'dsa',hash:'sha224',id:''},'DSA-WITH-SHA256':{sign:'dsa',hash:'sha256',id:''},'DSA-SHA256':{sign:'dsa',hash:'sha256',id:''},'DSA-WITH-SHA384':{sign:'dsa',hash:'sha384',id:''},'DSA-SHA384':{sign:'dsa',hash:'sha384',id:''},'DSA-WITH-SHA512':{sign:'dsa',hash:'sha512',id:''},'DSA-SHA512':{sign:'dsa',hash:'sha512',id:''},'DSA-RIPEMD160':{sign:'dsa',hash:'rmd160',id:''},ripemd160WithRSA:{sign:'rsa',hash:'rmd160',id:'3021300906052b2403020105000414'},'RSA-RIPEMD160':{sign:'rsa',hash:'rmd160',id:'3021300906052b2403020105000414'},md5WithRSAEncryption:{sign:'rsa',hash:'md5',id:'3020300c06082a864886f70d020505000410'},'RSA-MD5':{sign:'rsa',hash:'md5',id:'3020300c06082a864886f70d020505000410'}}})),he=P(((t,e)=>{e.exports=oe()})),le=P(((t,e)=>{var r=Math.pow(2,30)-1;e.exports=function(t,e){if('number'!=typeof t)throw new TypeError('Iterations not a number');if(t<0)throw new TypeError('Bad iterations');if('number'!=typeof e)throw new TypeError('Key length not a number');if(e<0||e>r||e!=e)throw new TypeError('Bad key length')}})),ce=P(((t,e)=>{var r;global.process&&global.process.browser?r='utf-8':global.process&&global.process.version?r=parseInt(process.version.split('.')[0].slice(1),10)>=6?'utf-8':'binary':r='utf-8',e.exports=r})),ue=P(((t,e)=>{var r=V().Buffer;e.exports=function(t,e,i){if(r.isBuffer(t))return t;if('string'==typeof t)return r.from(t,e);if(ArrayBuffer.isView(t))return r.from(t.buffer);throw new TypeError(i+' must be a string, a Buffer, a typed array or a DataView')}})),de=P(((t,e)=>{var r=se(),i=mt(),n=At(),s=V().Buffer,a=le(),o=ce(),h=ue(),l=s.alloc(128),c={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function u(t,e,a){var o=function(t){function e(e){return n(t).update(e).digest()}function s(t){return(new i).update(t).digest()}return'rmd160'===t||'ripemd160'===t?s:'md5'===t?r:e}(t),h='sha512'===t||'sha384'===t?128:64;e.length>h?e=o(e):e.length{var r,i,n=V().Buffer,s=le(),a=ce(),o=de(),h=ue(),l=global.crypto&&global.crypto.subtle,c={sha:'SHA-1','sha-1':'SHA-1',sha1:'SHA-1',sha256:'SHA-256','sha-256':'SHA-256',sha384:'SHA-384','sha-384':'SHA-384','sha-512':'SHA-512',sha512:'SHA-512'},u=[];function d(){return i||(i=global.process&&global.process.nextTick?global.process.nextTick:global.queueMicrotask?global.queueMicrotask:global.setImmediate?global.setImmediate:global.setTimeout)}function f(t,e,r,i,s){return l.importKey('raw',t,{name:'PBKDF2'},!1,['deriveBits']).then((function(t){return l.deriveBits({name:'PBKDF2',salt:e,iterations:r,hash:{name:s}},t,i<<3)})).then((function(t){return n.from(t)}))}e.exports=function(t,e,i,p,m,g){'function'==typeof m&&(g=m,m=void 0);var y=c[(m=m||'sha1').toLowerCase()];if(y&&'function'==typeof global.Promise){if(s(i,p),t=h(t,a,'Password'),e=h(e,a,'Salt'),'function'!=typeof g)throw new Error('No callback provided to pbkdf2');!function(t,e){t.then((function(t){d()((function(){e(null,t)}))}),(function(t){d()((function(){e(t)}))}))}(function(t){if(global.process&&!global.process.browser||!l||!l.importKey||!l.deriveBits)return Promise.resolve(!1);if(void 0!==u[t])return u[t];var e=f(r=r||n.alloc(8),r,10,128,t).then((function(){return!0})).catch((function(){return!1}));return u[t]=e,e}(y).then((function(r){return r?f(t,e,i,p,y):o(t,e,i,p,m)})),g)}else d()((function(){var r;try{r=o(t,e,i,p,m)}catch(t){return g(t)}g(null,r)}))}})),pe=P((t=>{t.pbkdf2=fe(),t.pbkdf2Sync=de()})),me=P((t=>{t.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},t.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},t.ip=function(t,e,r,i){for(var n=0,s=0,a=6;a>=0;a-=2){for(var o=0;o<=24;o+=8)n<<=1,n|=e>>>o+a&1;for(o=0;o<=24;o+=8)n<<=1,n|=t>>>o+a&1}for(a=6;a>=0;a-=2){for(o=1;o<=25;o+=8)s<<=1,s|=e>>>o+a&1;for(o=1;o<=25;o+=8)s<<=1,s|=t>>>o+a&1}r[i+0]=n>>>0,r[i+1]=s>>>0},t.rip=function(t,e,r,i){for(var n=0,s=0,a=0;a<4;a++)for(var o=24;o>=0;o-=8)n<<=1,n|=e>>>o+a&1,n<<=1,n|=t>>>o+a&1;for(a=4;a<8;a++)for(o=24;o>=0;o-=8)s<<=1,s|=e>>>o+a&1,s<<=1,s|=t>>>o+a&1;r[i+0]=n>>>0,r[i+1]=s>>>0},t.pc1=function(t,e,r,i){for(var n=0,s=0,a=7;a>=5;a--){for(var o=0;o<=24;o+=8)n<<=1,n|=e>>o+a&1;for(o=0;o<=24;o+=8)n<<=1,n|=t>>o+a&1}for(o=0;o<=24;o+=8)n<<=1,n|=e>>o+a&1;for(a=1;a<=3;a++){for(o=0;o<=24;o+=8)s<<=1,s|=e>>o+a&1;for(o=0;o<=24;o+=8)s<<=1,s|=t>>o+a&1}for(o=0;o<=24;o+=8)s<<=1,s|=t>>o+a&1;r[i+0]=n>>>0,r[i+1]=s>>>0},t.r28shl=function(t,e){return t<>>28-e};var e=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];t.pc2=function(t,r,i,n){for(var s=0,a=0,o=e.length>>>1,h=0;h>>e[h]&1;for(h=o;h>>e[h]&1;i[n+0]=s>>>0,i[n+1]=a>>>0},t.expand=function(t,e,r){var i=0,n=0;i=(1&t)<<5|t>>>27;for(var s=23;s>=15;s-=4)i<<=6,i|=t>>>s&63;for(s=11;s>=3;s-=4)n|=t>>>s&63,n<<=6;n|=(31&t)<<1|t>>>31,e[r+0]=i>>>0,e[r+1]=n>>>0};var r=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];t.substitute=function(t,e){for(var i=0,n=0;n<4;n++){i<<=4,i|=r[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){i<<=4,i|=r[256+64*n+(e>>>18-6*n&63)]}return i>>>0};var i=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];t.permute=function(t){for(var e=0,r=0;r>>i[r]&1;return e>>>0},t.padSplit=function(t,e,r){for(var i=t.toString(2);i.length{function r(t,e){if(!t)throw new Error(e||'Assertion failed')}e.exports=r,r.equal=function(t,e,r){if(t!=e)throw new Error(r||'Assertion failed: '+t+' != '+e)}})),ye=P(((t,e)=>{var r=ge();function i(t){this.options=t,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}e.exports=i,i.prototype._init=function(){},i.prototype.update=function(t){return 0===t.length?[]:'decrypt'===this.type?this._updateDecrypt(t):this._updateEncrypt(t)},i.prototype._buffer=function(t,e){for(var r=Math.min(this.buffer.length-this.bufferOff,t.length-e),i=0;i0;i--)e+=this._buffer(t,e),r+=this._flushBuffer(n,r);return e+=this._buffer(t,e),n},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r='encrypt'===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e{var r=ge(),i=z(),n=me(),s=ye();function a(){this.tmp=new Array(2),this.keys=null}function o(t){s.call(this,t);var e=new a;this._desState=e,this.deriveKeys(e,t.key)}i(o,s),e.exports=o,o.create=function(t){return new o(t)};var h=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];o.prototype.deriveKeys=function(t,e){t.keys=new Array(32),r.equal(e.length,this.blockSize,'Invalid key length');var i=n.readUInt32BE(e,0),s=n.readUInt32BE(e,4);n.pc1(i,s,t.tmp,0),i=t.tmp[0],s=t.tmp[1];for(var a=0;a>>1];i=n.r28shl(i,o),s=n.r28shl(s,o),n.pc2(i,s,t.keys,a)}},o.prototype._update=function(t,e,r,i){var s=this._desState,a=n.readUInt32BE(t,e),o=n.readUInt32BE(t,e+4);n.ip(a,o,s.tmp,0),a=s.tmp[0],o=s.tmp[1],'encrypt'===this.type?this._encrypt(s,a,o,s.tmp,0):this._decrypt(s,a,o,s.tmp,0),a=s.tmp[0],o=s.tmp[1],n.writeUInt32BE(r,a,i),n.writeUInt32BE(r,o,i+4)},o.prototype._pad=function(t,e){for(var r=t.length-e,i=e;i>>0,a=d}n.rip(o,a,i,s)},o.prototype._decrypt=function(t,e,r,i,s){for(var a=r,o=e,h=t.keys.length-2;h>=0;h-=2){var l=t.keys[h],c=t.keys[h+1];n.expand(a,t.tmp,0),l^=t.tmp[0],c^=t.tmp[1];var u=n.substitute(l,c),d=a;a=(o^n.permute(u))>>>0,o=d}n.rip(a,o,i,s)}})),be=P((t=>{var e=ge(),r=z(),i={};function n(t){e.equal(t.length,8,'Invalid IV length'),this.iv=new Array(8);for(var r=0;r{var r=ge(),i=z(),n=ye(),s=ve();function a(t,e){r.equal(e.length,24,'Invalid key length');var i=e.slice(0,8),n=e.slice(8,16),a=e.slice(16,24);this.ciphers='encrypt'===t?[s.create({type:'encrypt',key:i}),s.create({type:'decrypt',key:n}),s.create({type:'encrypt',key:a})]:[s.create({type:'decrypt',key:a}),s.create({type:'encrypt',key:n}),s.create({type:'decrypt',key:i})]}function o(t){n.call(this,t);var e=new a(this.type,this.options.key);this._edeState=e}i(o,n),e.exports=o,o.create=function(t){return new o(t)},o.prototype._update=function(t,e,r,i){var n=this._edeState;n.ciphers[0]._update(t,e,r,i),n.ciphers[1]._update(r,i,r,i),n.ciphers[2]._update(r,i,r,i)},o.prototype._pad=s.prototype._pad,o.prototype._unpad=s.prototype._unpad})),we=P((t=>{t.utils=me(),t.Cipher=ye(),t.DES=ve(),t.CBC=be(),t.EDE=_e()})),Ee=P(((t,e)=>{var r=re(),i=we(),n=z(),s=V().Buffer,a={'des-ede3-cbc':i.CBC.instantiate(i.EDE),'des-ede3':i.EDE,'des-ede-cbc':i.CBC.instantiate(i.EDE),'des-ede':i.EDE,'des-cbc':i.CBC.instantiate(i.DES),'des-ecb':i.DES};function o(t){r.call(this);var e,i=t.mode.toLowerCase(),n=a[i];e=t.decrypt?'decrypt':'encrypt';var o=t.key;s.isBuffer(o)||(o=s.from(o)),('des-ede'===i||'des-ede-cbc'===i)&&(o=s.concat([o,o.slice(0,8)]));var h=t.iv;s.isBuffer(h)||(h=s.from(h)),this._des=n.create({key:o,iv:h,type:e})}a.des=a['des-cbc'],a.des3=a['des-ede3-cbc'],e.exports=o,n(o,r),o.prototype._update=function(t){return s.from(this._des.update(t))},o.prototype._final=function(){return s.from(this._des.final())}})),Ae=P((t=>{t.encrypt=function(t,e){return t._cipher.encryptBlock(e)},t.decrypt=function(t,e){return t._cipher.decryptBlock(e)}})),Se=P(((t,e)=>{e.exports=function(t,e){for(var r=Math.min(t.length,e.length),i=new Buffer(r),n=0;n{var e=Se();t.encrypt=function(t,r){var i=e(r,t._prev);return t._prev=t._cipher.encryptBlock(i),t._prev},t.decrypt=function(t,r){var i=t._prev;t._prev=r;var n=t._cipher.decryptBlock(r);return e(n,i)}})),Me=P((t=>{var e=V().Buffer,r=Se();function i(t,i,n){var s=i.length,a=r(i,t._cache);return t._cache=t._cache.slice(s),t._prev=e.concat([t._prev,n?i:a]),a}t.encrypt=function(t,r,n){for(var s,a=e.allocUnsafe(0);r.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=e.allocUnsafe(0)),!(t._cache.length<=r.length)){a=e.concat([a,i(t,r,n)]);break}s=t._cache.length,a=e.concat([a,i(t,r.slice(0,s),n)]),r=r.slice(s)}return a}})),Ie=P((t=>{var e=V().Buffer;function r(t,r,i){var n=t._cipher.encryptBlock(t._prev)[0]^r;return t._prev=e.concat([t._prev.slice(1),e.from([i?r:n])]),n}t.encrypt=function(t,i,n){for(var s=i.length,a=e.allocUnsafe(s),o=-1;++o{var e=V().Buffer;function r(t,e,r){for(var n,s,a=-1,o=0;++a<8;)n=e&1<<7-a?128:0,o+=(128&(s=t._cipher.encryptBlock(t._prev)[0]^n))>>a%8,t._prev=i(t._prev,r?n:s);return o}function i(t,r){var i=t.length,n=-1,s=e.allocUnsafe(t.length);for(t=e.concat([t,e.from([r])]);++n>7;return s}t.encrypt=function(t,i,n){for(var s=i.length,a=e.allocUnsafe(s),o=-1;++o{var e=Se();function r(t){return t._prev=t._cipher.encryptBlock(t._prev),t._prev}t.encrypt=function(t,i){for(;t._cache.length{e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}})),Le=P((t=>{var e=Se(),r=V().Buffer,i=Ne();function n(t){var e=t._cipher.encryptBlockRaw(t._prev);return i(t._prev),e}t.encrypt=function(t,i){var s=Math.ceil(i.length/16),a=t._cache.length;t._cache=r.concat([t._cache,r.allocUnsafe(16*s)]);for(var o=0;o{e.exports={'aes-128-ecb':{cipher:'AES',key:128,iv:0,mode:'ECB',type:'block'},'aes-192-ecb':{cipher:'AES',key:192,iv:0,mode:'ECB',type:'block'},'aes-256-ecb':{cipher:'AES',key:256,iv:0,mode:'ECB',type:'block'},'aes-128-cbc':{cipher:'AES',key:128,iv:16,mode:'CBC',type:'block'},'aes-192-cbc':{cipher:'AES',key:192,iv:16,mode:'CBC',type:'block'},'aes-256-cbc':{cipher:'AES',key:256,iv:16,mode:'CBC',type:'block'},aes128:{cipher:'AES',key:128,iv:16,mode:'CBC',type:'block'},aes192:{cipher:'AES',key:192,iv:16,mode:'CBC',type:'block'},aes256:{cipher:'AES',key:256,iv:16,mode:'CBC',type:'block'},'aes-128-cfb':{cipher:'AES',key:128,iv:16,mode:'CFB',type:'stream'},'aes-192-cfb':{cipher:'AES',key:192,iv:16,mode:'CFB',type:'stream'},'aes-256-cfb':{cipher:'AES',key:256,iv:16,mode:'CFB',type:'stream'},'aes-128-cfb8':{cipher:'AES',key:128,iv:16,mode:'CFB8',type:'stream'},'aes-192-cfb8':{cipher:'AES',key:192,iv:16,mode:'CFB8',type:'stream'},'aes-256-cfb8':{cipher:'AES',key:256,iv:16,mode:'CFB8',type:'stream'},'aes-128-cfb1':{cipher:'AES',key:128,iv:16,mode:'CFB1',type:'stream'},'aes-192-cfb1':{cipher:'AES',key:192,iv:16,mode:'CFB1',type:'stream'},'aes-256-cfb1':{cipher:'AES',key:256,iv:16,mode:'CFB1',type:'stream'},'aes-128-ofb':{cipher:'AES',key:128,iv:16,mode:'OFB',type:'stream'},'aes-192-ofb':{cipher:'AES',key:192,iv:16,mode:'OFB',type:'stream'},'aes-256-ofb':{cipher:'AES',key:256,iv:16,mode:'OFB',type:'stream'},'aes-128-ctr':{cipher:'AES',key:128,iv:16,mode:'CTR',type:'stream'},'aes-192-ctr':{cipher:'AES',key:192,iv:16,mode:'CTR',type:'stream'},'aes-256-ctr':{cipher:'AES',key:256,iv:16,mode:'CTR',type:'stream'},'aes-128-gcm':{cipher:'AES',key:128,iv:12,mode:'GCM',type:'auth'},'aes-192-gcm':{cipher:'AES',key:192,iv:12,mode:'GCM',type:'auth'},'aes-256-gcm':{cipher:'AES',key:256,iv:12,mode:'GCM',type:'auth'}}})),Pe=P(((t,e)=>{var r,i={ECB:Ae(),CBC:Te(),CFB:Me(),CFB8:Ie(),CFB1:Ce(),OFB:Oe(),CTR:Le(),GCM:Le()},n=Re();for(r in n)n[r].module=i[n[r].mode];e.exports=n})),Be=P(((t,e)=>{var r=V().Buffer;function i(t){r.isBuffer(t)||(t=r.from(t));for(var e=t.length/4|0,i=new Array(e),n=0;n>>24]^c[p>>>16&255]^u[m>>>8&255]^d[255&g]^e[y++],a=l[p>>>24]^c[m>>>16&255]^u[g>>>8&255]^d[255&f]^e[y++],o=l[m>>>24]^c[g>>>16&255]^u[f>>>8&255]^d[255&p]^e[y++],h=l[g>>>24]^c[f>>>16&255]^u[p>>>8&255]^d[255&m]^e[y++],f=s,p=a,m=o,g=h;return s=(i[f>>>24]<<24|i[p>>>16&255]<<16|i[m>>>8&255]<<8|i[255&g])^e[y++],a=(i[p>>>24]<<24|i[m>>>16&255]<<16|i[g>>>8&255]<<8|i[255&f])^e[y++],o=(i[m>>>24]<<24|i[g>>>16&255]<<16|i[f>>>8&255]<<8|i[255&p])^e[y++],h=(i[g>>>24]<<24|i[f>>>16&255]<<16|i[p>>>8&255]<<8|i[255&m])^e[y++],[s>>>=0,a>>>=0,o>>>=0,h>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],o=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],i=[],n=[[],[],[],[]],s=[[],[],[],[]],a=0,o=0,h=0;h<256;++h){var l=o^o<<1^o<<2^o<<3^o<<4;l=l>>>8^255&l^99,r[a]=l,i[l]=a;var c=t[a],u=t[c],d=t[u],f=257*t[l]^16843008*l;n[0][a]=f<<24|f>>>8,n[1][a]=f<<16|f>>>16,n[2][a]=f<<8|f>>>24,n[3][a]=f,f=16843009*d^65537*u^257*c^16843008*a,s[0][l]=f<<24|f>>>8,s[1][l]=f<<16|f>>>16,s[2][l]=f<<8|f>>>24,s[3][l]=f,0===a?a=o=1:(a=c^t[t[t[d^c]]],o^=t[t[o]])}return{SBOX:r,INV_SBOX:i,SUB_MIX:n,INV_SUB_MIX:s}}();function h(t){this._key=i(t),this._reset()}h.blockSize=16,h.keySize=32,h.prototype.blockSize=h.blockSize,h.prototype.keySize=h.keySize,h.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,i=4*(r+1),n=[],s=0;s>>24,h=o.SBOX[h>>>24]<<24|o.SBOX[h>>>16&255]<<16|o.SBOX[h>>>8&255]<<8|o.SBOX[255&h],h^=a[s/e|0]<<24):e>6&&s%e==4&&(h=o.SBOX[h>>>24]<<24|o.SBOX[h>>>16&255]<<16|o.SBOX[h>>>8&255]<<8|o.SBOX[255&h]),n[s]=n[s-e]^h}for(var l=[],c=0;c>>24]]^o.INV_SUB_MIX[1][o.SBOX[d>>>16&255]]^o.INV_SUB_MIX[2][o.SBOX[d>>>8&255]]^o.INV_SUB_MIX[3][o.SBOX[255&d]]}this._nRounds=r,this._keySchedule=n,this._invKeySchedule=l},h.prototype.encryptBlockRaw=function(t){return s(t=i(t),this._keySchedule,o.SUB_MIX,o.SBOX,this._nRounds)},h.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),i=r.allocUnsafe(16);return i.writeUInt32BE(e[0],0),i.writeUInt32BE(e[1],4),i.writeUInt32BE(e[2],8),i.writeUInt32BE(e[3],12),i},h.prototype.decryptBlock=function(t){var e=(t=i(t))[1];t[1]=t[3],t[3]=e;var n=s(t,this._invKeySchedule,o.INV_SUB_MIX,o.INV_SBOX,this._nRounds),a=r.allocUnsafe(16);return a.writeUInt32BE(n[0],0),a.writeUInt32BE(n[3],4),a.writeUInt32BE(n[2],8),a.writeUInt32BE(n[1],12),a},h.prototype.scrub=function(){n(this._keySchedule),n(this._invKeySchedule),n(this._key)},e.exports.AES=h})),ke=P(((t,e)=>{var r=V().Buffer,i=r.alloc(16,0);function n(t){var e=r.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function s(t){this.h=t,this.state=r.alloc(16,0),this.cache=r.allocUnsafe(0)}s.prototype.ghash=function(t){for(var e=-1;++e0;t--)r[t]=r[t]>>>1|(1&r[t-1])<<31;r[0]=r[0]>>>1,e&&(r[0]=r[0]^225<<24)}this.state=n(i)},s.prototype.update=function(t){this.cache=r.concat([this.cache,t]);for(var e;this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},s.prototype.final=function(t,e){return this.cache.length&&this.ghash(r.concat([this.cache,i],16)),this.ghash(n([0,t,0,e])),this.state},e.exports=s})),De=P(((t,e)=>{var r=Be(),i=V().Buffer,n=re(),s=z(),a=ke(),o=Se(),h=Ne();function l(t,e,s,o){n.call(this);var l=i.alloc(4,0);this._cipher=new r.AES(e);var c=this._cipher.encryptBlock(l);this._ghash=new a(c),s=function(t,e,r){if(12===e.length)return t._finID=i.concat([e,i.from([0,0,0,1])]),i.concat([e,i.from([0,0,0,2])]);var n=new a(r),s=e.length,o=s%16;n.update(e),o&&(o=16-o,n.update(i.alloc(o,0))),n.update(i.alloc(8,0));var l=8*s,c=i.alloc(8);c.writeUIntBE(l,0,8),n.update(c),t._finID=n.state;var u=i.from(t._finID);return h(u),u}(this,s,c),this._prev=i.from(s),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}s(l,n),l.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=i.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},l.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error('Unsupported state or unable to authenticate data');var t=o(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var i=Math.min(t.length,e.length),n=0;n{var r=Be(),i=V().Buffer,n=re();function s(t,e,s,a){n.call(this),this._cipher=new r.AES(e),this._prev=i.from(s),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._mode=t}z()(s,n),s.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt)},s.prototype._final=function(){this._cipher.scrub()},e.exports=s})),xe=P(((t,e)=>{var r=V().Buffer,i=pt();e.exports=function(t,e,n,s){if(r.isBuffer(t)||(t=r.from(t,'binary')),e&&(r.isBuffer(e)||(e=r.from(e,'binary')),8!==e.length))throw new RangeError('salt should be Buffer with 8 byte length');for(var a=n/8,o=r.alloc(a),h=r.alloc(s||0),l=r.alloc(0);a>0||s>0;){var c=new i;c.update(l),c.update(t),e&&c.update(e),l=c.digest();var u=0;if(a>0){var d=o.length-a;u=Math.min(a,l.length),l.copy(o,d,0,u),a-=u}if(u0){var f=h.length-s,p=Math.min(s,l.length-u);l.copy(h,f,u,u+p),s-=p}}return l.fill(0),{key:o,iv:h}}})),Fe=P((t=>{var e=Pe(),r=De(),i=V().Buffer,n=Ue(),s=re(),a=Be(),o=xe();function h(t,e,r){s.call(this),this._cache=new c,this._cipher=new a.AES(e),this._prev=i.from(r),this._mode=t,this._autopadding=!0}z()(h,s),h.prototype._update=function(t){this._cache.add(t);for(var e,r,n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return i.concat(n)};var l=i.alloc(16,16);function c(){this.cache=i.allocUnsafe(0)}function u(t,s,a){var o=e[t.toLowerCase()];if(!o)throw new TypeError('invalid suite type');if('string'==typeof s&&(s=i.from(s)),s.length!==o.key/8)throw new TypeError('invalid key length '+s.length);if('string'==typeof a&&(a=i.from(a)),'GCM'!==o.mode&&a.length!==o.iv)throw new TypeError('invalid iv length '+a.length);return'stream'===o.type?new n(o.module,s,a):'auth'===o.type?new r(o.module,s,a):new h(o.module,s,a)}h.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(l))throw this._cipher.scrub(),new Error('data not multiple of block length')},h.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},c.prototype.add=function(t){this.cache=i.concat([this.cache,t])},c.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},c.prototype.flush=function(){for(var t=16-this.cache.length,e=i.allocUnsafe(t),r=-1;++r{var e=De(),r=V().Buffer,i=Pe(),n=Ue(),s=re(),a=Be(),o=xe();function h(t,e,i){s.call(this),this._cache=new l,this._last=void 0,this._cipher=new a.AES(e),this._prev=r.from(i),this._mode=t,this._autopadding=!0}function l(){this.cache=r.allocUnsafe(0)}function c(t,s,a){var o=i[t.toLowerCase()];if(!o)throw new TypeError('invalid suite type');if('string'==typeof a&&(a=r.from(a)),'GCM'!==o.mode&&a.length!==o.iv)throw new TypeError('invalid iv length '+a.length);if('string'==typeof s&&(s=r.from(s)),s.length!==o.key/8)throw new TypeError('invalid key length '+s.length);return'stream'===o.type?new n(o.module,s,a,!0):'auth'===o.type?new e(o.module,s,a,!0):new h(o.module,s,a)}z()(h,s),h.prototype._update=function(t){this._cache.add(t);for(var e,i,n=[];e=this._cache.get(this._autopadding);)i=this._mode.decrypt(this,e),n.push(i);return r.concat(n)},h.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return function(t){var e=t[15];if(e<1||e>16)throw new Error('unable to decrypt data');for(var r=-1;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},l.prototype.flush=function(){if(this.cache.length)return this.cache},t.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError('invalid suite type');var n=o(e,!1,r.key,r.iv);return c(t,n.key,n.iv)},t.createDecipheriv=c})),je=P((t=>{var e=Fe(),r=He(),i=Re();t.createCipher=t.Cipher=e.createCipher,t.createCipheriv=t.Cipheriv=e.createCipheriv,t.createDecipher=t.Decipher=r.createDecipher,t.createDecipheriv=t.Decipheriv=r.createDecipheriv,t.listCiphers=t.getCiphers=function(){return Object.keys(i)}})),Ve=P((t=>{t['des-ecb']={key:8,iv:0},t['des-cbc']=t.des={key:8,iv:8},t['des-ede3-cbc']=t.des3={key:24,iv:8},t['des-ede3']={key:24,iv:0},t['des-ede-cbc']={key:16,iv:8},t['des-ede']={key:16,iv:0}})),Ge=P((t=>{var e=Ee(),r=je(),i=Pe(),n=Ve(),s=xe();function a(t,s,a){if(t=t.toLowerCase(),i[t])return r.createCipheriv(t,s,a);if(n[t])return new e({key:s,iv:a,mode:t});throw new TypeError('invalid suite type')}function o(t,s,a){if(t=t.toLowerCase(),i[t])return r.createDecipheriv(t,s,a);if(n[t])return new e({key:s,iv:a,mode:t,decrypt:!0});throw new TypeError('invalid suite type')}t.createCipher=t.Cipher=function(t,e){var r,o;if(t=t.toLowerCase(),i[t])r=i[t].key,o=i[t].iv;else{if(!n[t])throw new TypeError('invalid suite type');r=8*n[t].key,o=n[t].iv}var h=s(e,!1,r,o);return a(t,h.key,h.iv)},t.createCipheriv=t.Cipheriv=a,t.createDecipher=t.Decipher=function(t,e){var r,a;if(t=t.toLowerCase(),i[t])r=i[t].key,a=i[t].iv;else{if(!n[t])throw new TypeError('invalid suite type');r=8*n[t].key,a=n[t].iv}var h=s(e,!1,r,a);return o(t,h.key,h.iv)},t.createDecipheriv=t.Decipheriv=o,t.listCiphers=t.getCiphers=function(){return Object.keys(n).concat(r.getCiphers())}})),ze=P((()=>{})),We=P(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var s;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{s=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:ze().Buffer}catch{}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function o(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,s=Math.min(t.length,r),a=e;a=49?o-49+10:o>=17?o-17+10:o}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=a<>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);else if('le'===i)for(n=0,s=0;n>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=o(t,e,i)<=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,a=s%i,o=Math.min(s,s-a)+r,l=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?''};var l=['','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'],c=[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],u=[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 d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],a=n*s,o=67108863&a,h=a/67108864|0;r.words[0]=o;for(var l=1;l>>26,u=67108863&h,d=Math.min(l,e.length-1),f=Math.max(0,l-t.length+1);f<=d;f++){var p=l-f|0;c+=(a=(n=0|t.words[p])*(s=0|e.words[f])+u)/67108864|0,u=67108863&a}r.words[l]=0|u,h=0|c}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,s=0,a=0;a>>24-n&16777215)||a!==this.length-1?l[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,a--)}for(0!==s&&(i=s.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var d=c[t],f=u[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(f).toString(t);i=(p=p.idivn(f)).isZero()?m+i:l[d-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof s<'u'),this.toArrayLike(s,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),s=i||Math.max(1,n);r(n<=s,'byte array longer than desired length'),r(s>0,'Requested array length <= 0'),this.strip();var a,o,h='le'===e,l=new t(s),c=this.clone();if(h){for(o=0;!c.isZero();o++)a=c.andln(255),c.iushrn(8),l[o]=a;for(;o=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,a=0;a>26,this.words[a]=67108863&e;for(;0!==s&&a>26,this.words[a]=67108863&e;if(0===s&&a>>13,f=0|a[1],p=8191&f,m=f>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],_=8191&b,w=b>>>13,E=0|a[4],A=8191&E,S=E>>>13,T=0|a[5],M=8191&T,I=T>>>13,C=0|a[6],O=8191&C,N=C>>>13,L=0|a[7],R=8191&L,P=L>>>13,B=0|a[8],k=8191&B,D=B>>>13,U=0|a[9],x=8191&U,F=U>>>13,H=0|o[0],j=8191&H,V=H>>>13,G=0|o[1],z=8191&G,W=G>>>13,K=0|o[2],q=8191&K,Y=K>>>13,Z=0|o[3],$=8191&Z,X=Z>>>13,Q=0|o[4],J=8191&Q,tt=Q>>>13,et=0|o[5],rt=8191&et,it=et>>>13,nt=0|o[6],st=8191&nt,at=nt>>>13,ot=0|o[7],ht=8191&ot,lt=ot>>>13,ct=0|o[8],ut=8191&ct,dt=ct>>>13,ft=0|o[9],pt=8191&ft,mt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(i=Math.imul(u,j))|0)+((8191&(n=(n=Math.imul(u,V))+Math.imul(d,j)|0))<<13)|0;l=((s=Math.imul(d,V))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,j),n=(n=Math.imul(p,V))+Math.imul(m,j)|0,s=Math.imul(m,V);var yt=(l+(i=i+Math.imul(u,z)|0)|0)+((8191&(n=(n=n+Math.imul(u,W)|0)+Math.imul(d,z)|0))<<13)|0;l=((s=s+Math.imul(d,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,j),n=(n=Math.imul(y,V))+Math.imul(v,j)|0,s=Math.imul(v,V),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,z)|0,s=s+Math.imul(m,W)|0;var vt=(l+(i=i+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,Y)|0)+Math.imul(d,q)|0))<<13)|0;l=((s=s+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,j),n=(n=Math.imul(_,V))+Math.imul(w,j)|0,s=Math.imul(w,V),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(v,z)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,q)|0,s=s+Math.imul(m,Y)|0;var bt=(l+(i=i+Math.imul(u,$)|0)|0)+((8191&(n=(n=n+Math.imul(u,X)|0)+Math.imul(d,$)|0))<<13)|0;l=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(A,j),n=(n=Math.imul(A,V))+Math.imul(S,j)|0,s=Math.imul(S,V),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,z)|0,s=s+Math.imul(w,W)|0,i=i+Math.imul(y,q)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(v,q)|0,s=s+Math.imul(v,Y)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,$)|0,s=s+Math.imul(m,X)|0;var _t=(l+(i=i+Math.imul(u,J)|0)|0)+((8191&(n=(n=n+Math.imul(u,tt)|0)+Math.imul(d,J)|0))<<13)|0;l=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(M,j),n=(n=Math.imul(M,V))+Math.imul(I,j)|0,s=Math.imul(I,V),i=i+Math.imul(A,z)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(S,z)|0,s=s+Math.imul(S,W)|0,i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(w,q)|0,s=s+Math.imul(w,Y)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(v,$)|0,s=s+Math.imul(v,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var wt=(l+(i=i+Math.imul(u,rt)|0)|0)+((8191&(n=(n=n+Math.imul(u,it)|0)+Math.imul(d,rt)|0))<<13)|0;l=((s=s+Math.imul(d,it)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(O,j),n=(n=Math.imul(O,V))+Math.imul(N,j)|0,s=Math.imul(N,V),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(I,z)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(A,q)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(S,q)|0,s=s+Math.imul(S,Y)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,X)|0)+Math.imul(w,$)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Et=(l+(i=i+Math.imul(u,st)|0)|0)+((8191&(n=(n=n+Math.imul(u,at)|0)+Math.imul(d,st)|0))<<13)|0;l=((s=s+Math.imul(d,at)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(R,j),n=(n=Math.imul(R,V))+Math.imul(P,j)|0,s=Math.imul(P,V),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(N,z)|0,s=s+Math.imul(N,W)|0,i=i+Math.imul(M,q)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,Y)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(S,$)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(_,J)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,at)|0;var At=(l+(i=i+Math.imul(u,ht)|0)|0)+((8191&(n=(n=n+Math.imul(u,lt)|0)+Math.imul(d,ht)|0))<<13)|0;l=((s=s+Math.imul(d,lt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(k,j),n=(n=Math.imul(k,V))+Math.imul(D,j)|0,s=Math.imul(D,V),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(P,z)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(O,q)|0,n=(n=n+Math.imul(O,Y)|0)+Math.imul(N,q)|0,s=s+Math.imul(N,Y)|0,i=i+Math.imul(M,$)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,at)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(i=i+Math.imul(u,ut)|0)|0)+((8191&(n=(n=n+Math.imul(u,dt)|0)+Math.imul(d,ut)|0))<<13)|0;l=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(x,j),n=(n=Math.imul(x,V))+Math.imul(F,j)|0,s=Math.imul(F,V),i=i+Math.imul(k,z)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(D,z)|0,s=s+Math.imul(D,W)|0,i=i+Math.imul(R,q)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,Y)|0,i=i+Math.imul(O,$)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(N,$)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(_,st)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,ut)|0,s=s+Math.imul(m,dt)|0;var Tt=(l+(i=i+Math.imul(u,pt)|0)|0)+((8191&(n=(n=n+Math.imul(u,mt)|0)+Math.imul(d,pt)|0))<<13)|0;l=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(x,z),n=(n=Math.imul(x,W))+Math.imul(F,z)|0,s=Math.imul(F,W),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,Y)|0)+Math.imul(D,q)|0,s=s+Math.imul(D,Y)|0,i=i+Math.imul(R,$)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(P,$)|0,s=s+Math.imul(P,X)|0,i=i+Math.imul(O,J)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(A,st)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,lt)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,lt)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(v,ut)|0,s=s+Math.imul(v,dt)|0;var Mt=(l+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(x,q),n=(n=Math.imul(x,Y))+Math.imul(F,q)|0,s=Math.imul(F,Y),i=i+Math.imul(k,$)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(D,$)|0,s=s+Math.imul(D,X)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(M,st)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,at)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(w,ut)|0,s=s+Math.imul(w,dt)|0;var It=(l+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(x,$),n=(n=Math.imul(x,X))+Math.imul(F,$)|0,s=Math.imul(F,X),i=i+Math.imul(k,J)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(O,st)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,at)|0,i=i+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,lt)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,lt)|0,i=i+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,dt)|0)+Math.imul(S,ut)|0,s=s+Math.imul(S,dt)|0;var Ct=(l+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,mt)|0)+Math.imul(w,pt)|0))<<13)|0;l=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(x,J),n=(n=Math.imul(x,tt))+Math.imul(F,J)|0,s=Math.imul(F,tt),i=i+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,it)|0)+Math.imul(D,rt)|0,s=s+Math.imul(D,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,at)|0,i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(I,ut)|0,s=s+Math.imul(I,dt)|0;var Ot=(l+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(x,rt),n=(n=Math.imul(x,it))+Math.imul(F,rt)|0,s=Math.imul(F,it),i=i+Math.imul(k,st)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,at)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(N,ut)|0,s=s+Math.imul(N,dt)|0;var Nt=(l+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(I,pt)|0))<<13)|0;l=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(x,st),n=(n=Math.imul(x,at))+Math.imul(F,st)|0,s=Math.imul(F,at),i=i+Math.imul(k,ht)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(D,ht)|0,s=s+Math.imul(D,lt)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ut)|0,s=s+Math.imul(P,dt)|0;var Lt=(l+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,i=Math.imul(x,ht),n=(n=Math.imul(x,lt))+Math.imul(F,ht)|0,s=Math.imul(F,lt),i=i+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,dt)|0)+Math.imul(D,ut)|0,s=s+Math.imul(D,dt)|0;var Rt=(l+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(x,ut),n=(n=Math.imul(x,dt))+Math.imul(F,ut)|0,s=Math.imul(F,dt);var Pt=(l+(i=i+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,mt)|0)+Math.imul(D,pt)|0))<<13)|0;l=((s=s+Math.imul(D,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var Bt=(l+(i=Math.imul(x,pt))|0)+((8191&(n=(n=Math.imul(x,mt))+Math.imul(F,pt)|0))<<13)|0;return l=((s=Math.imul(F,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=_t,h[5]=wt,h[6]=Et,h[7]=At,h[8]=St,h[9]=Tt,h[10]=Mt,h[11]=It,h[12]=Ct,h[13]=Ot,h[14]=Nt,h[15]=Lt,h[16]=Rt,h[17]=Pt,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(f=d),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?f(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,a&=67108863}r.words[s]=o,i=a,a=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,s){for(var a=0;a>>=1)n++;return 1<>>=13,i[2*a+1]=8191&s,s>>>=13;for(a=2*e;a>=26,e+=n/67108864|0,e+=s>>>26,this.words[i]=67108863&s}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,s=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var s=t%26,a=Math.min((t-s)/26,this.length),o=67108863^67108863>>>s<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=n);l--){var u=0|this.words[l];this.words[l]=c<<26-s|u>>>s,c=u&o}return h&&0!==c&&(h.words[h.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&a}for(;n>26,this.words[n+i]=67108863&a;if(0===o)return this.strip();for(r(-1===o),o=0,n=0;n>26,this.words[n]=67108863&a;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,a=0|s.words[s.length-1];0!==(r=26-this._countBits(a))&&(s=s.ushln(r),i.iushln(r),a=0|s.words[s.length-1]);var o,h=i.length-s.length;if('mod'!==e){(o=new n(null)).length=h+1,o.words=new Array(o.length);for(var l=0;l=0;u--){var d=67108864*(0|i.words[s.length+u])+(0|i.words[s.length+u-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(s,d,u);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(s,1,u),i.isZero()||(i.negative^=1);o&&(o.words[u]=d)}return o&&o.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),'mod'!==e&&(s=o.div.neg()),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:s,mod:a}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),'mod'!==e&&(s=o.div.neg()),{div:s,mod:o.mod}):this.negative&t.negative?(o=this.neg().divmod(t.neg(),e),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:o.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var s,a,o},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),a=new n(0),o=new n(0),h=new n(1),l=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++l;for(var c=i.clone(),u=e.clone();!e.isZero();){for(var d=0,f=1;!(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||a.isOdd())&&(s.iadd(c),a.isub(u)),s.iushrn(1),a.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(c),h.isub(u)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o),a.isub(h)):(i.isub(e),o.isub(s),h.isub(a))}return{a:o,b:h,gcd:i.iushln(l)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,s=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var a=new n(1),o=new n(0),h=s.clone();i.cmpn(1)>0&&s.cmpn(1)>0;){for(var l=0,c=1;!(i.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(i.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var u=0,d=1;!(s.words[0]&d)&&u<26;++u,d<<=1);if(u>0)for(s.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);i.cmp(s)>=0?(i.isub(s),a.isub(o)):(s.isub(i),o.isub(a))}return(e=0===i.cmpn(1)?a:o).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,o&=67108863,this.words[a]=o}return 0!==s&&(this.words[a]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function _(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function w(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function E(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=a}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new _;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new w}return g[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},E.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),a=0;!s.isZero()&&0===s.andln(1);)a++,s.iushrn(1);r(!s.isZero());var o=new n(1).toRed(this),h=o.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);0!==this.pow(c,l).cmp(h);)c.redIAdd(h);for(var u=this.pow(c,s),d=this.pow(t,s.addn(1).iushrn(1)),f=this.pow(t,s),p=a;0!==f.cmp(o);){for(var m=f,g=0;0!==m.cmp(o);g++)m=m.redSqr();r(g=0;i--){for(var l=e.words[i],c=h-1;c>=0;c--){var u=l>>c&1;(s!==r[0]&&(s=this.sqr(s)),0!==u||0!==a)?(a<<=1,a|=u,(4===++o||0===i&&0===c)&&(s=this.mul(s,r[a]),o=0,a=0)):o=0}h=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),Ke=P(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var s;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{s=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:ze().Buffer}catch{}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function o(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,s=Math.min(t.length,r),a=e;a=49?o-49+10:o>=17?o-17+10:o}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=a<>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);else if('le'===i)for(n=0,s=0;n>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=o(t,e,i)<=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,a=s%i,o=Math.min(s,s-a)+r,l=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?''};var l=['','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'],c=[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],u=[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 d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],a=n*s,o=67108863&a,h=a/67108864|0;r.words[0]=o;for(var l=1;l>>26,u=67108863&h,d=Math.min(l,e.length-1),f=Math.max(0,l-t.length+1);f<=d;f++){var p=l-f|0;c+=(a=(n=0|t.words[p])*(s=0|e.words[f])+u)/67108864|0,u=67108863&a}r.words[l]=0|u,h=0|c}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,s=0,a=0;a>>24-n&16777215)||a!==this.length-1?l[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,a--)}for(0!==s&&(i=s.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var d=c[t],f=u[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(f).toString(t);i=(p=p.idivn(f)).isZero()?m+i:l[d-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof s<'u'),this.toArrayLike(s,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),s=i||Math.max(1,n);r(n<=s,'byte array longer than desired length'),r(s>0,'Requested array length <= 0'),this.strip();var a,o,h='le'===e,l=new t(s),c=this.clone();if(h){for(o=0;!c.isZero();o++)a=c.andln(255),c.iushrn(8),l[o]=a;for(;o=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,a=0;a>26,this.words[a]=67108863&e;for(;0!==s&&a>26,this.words[a]=67108863&e;if(0===s&&a>>13,f=0|a[1],p=8191&f,m=f>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],_=8191&b,w=b>>>13,E=0|a[4],A=8191&E,S=E>>>13,T=0|a[5],M=8191&T,I=T>>>13,C=0|a[6],O=8191&C,N=C>>>13,L=0|a[7],R=8191&L,P=L>>>13,B=0|a[8],k=8191&B,D=B>>>13,U=0|a[9],x=8191&U,F=U>>>13,H=0|o[0],j=8191&H,V=H>>>13,G=0|o[1],z=8191&G,W=G>>>13,K=0|o[2],q=8191&K,Y=K>>>13,Z=0|o[3],$=8191&Z,X=Z>>>13,Q=0|o[4],J=8191&Q,tt=Q>>>13,et=0|o[5],rt=8191&et,it=et>>>13,nt=0|o[6],st=8191&nt,at=nt>>>13,ot=0|o[7],ht=8191&ot,lt=ot>>>13,ct=0|o[8],ut=8191&ct,dt=ct>>>13,ft=0|o[9],pt=8191&ft,mt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(i=Math.imul(u,j))|0)+((8191&(n=(n=Math.imul(u,V))+Math.imul(d,j)|0))<<13)|0;l=((s=Math.imul(d,V))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,j),n=(n=Math.imul(p,V))+Math.imul(m,j)|0,s=Math.imul(m,V);var yt=(l+(i=i+Math.imul(u,z)|0)|0)+((8191&(n=(n=n+Math.imul(u,W)|0)+Math.imul(d,z)|0))<<13)|0;l=((s=s+Math.imul(d,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,j),n=(n=Math.imul(y,V))+Math.imul(v,j)|0,s=Math.imul(v,V),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,z)|0,s=s+Math.imul(m,W)|0;var vt=(l+(i=i+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,Y)|0)+Math.imul(d,q)|0))<<13)|0;l=((s=s+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,j),n=(n=Math.imul(_,V))+Math.imul(w,j)|0,s=Math.imul(w,V),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(v,z)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,q)|0,s=s+Math.imul(m,Y)|0;var bt=(l+(i=i+Math.imul(u,$)|0)|0)+((8191&(n=(n=n+Math.imul(u,X)|0)+Math.imul(d,$)|0))<<13)|0;l=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(A,j),n=(n=Math.imul(A,V))+Math.imul(S,j)|0,s=Math.imul(S,V),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,z)|0,s=s+Math.imul(w,W)|0,i=i+Math.imul(y,q)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(v,q)|0,s=s+Math.imul(v,Y)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,$)|0,s=s+Math.imul(m,X)|0;var _t=(l+(i=i+Math.imul(u,J)|0)|0)+((8191&(n=(n=n+Math.imul(u,tt)|0)+Math.imul(d,J)|0))<<13)|0;l=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(M,j),n=(n=Math.imul(M,V))+Math.imul(I,j)|0,s=Math.imul(I,V),i=i+Math.imul(A,z)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(S,z)|0,s=s+Math.imul(S,W)|0,i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(w,q)|0,s=s+Math.imul(w,Y)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(v,$)|0,s=s+Math.imul(v,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var wt=(l+(i=i+Math.imul(u,rt)|0)|0)+((8191&(n=(n=n+Math.imul(u,it)|0)+Math.imul(d,rt)|0))<<13)|0;l=((s=s+Math.imul(d,it)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(O,j),n=(n=Math.imul(O,V))+Math.imul(N,j)|0,s=Math.imul(N,V),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(I,z)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(A,q)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(S,q)|0,s=s+Math.imul(S,Y)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,X)|0)+Math.imul(w,$)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Et=(l+(i=i+Math.imul(u,st)|0)|0)+((8191&(n=(n=n+Math.imul(u,at)|0)+Math.imul(d,st)|0))<<13)|0;l=((s=s+Math.imul(d,at)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(R,j),n=(n=Math.imul(R,V))+Math.imul(P,j)|0,s=Math.imul(P,V),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(N,z)|0,s=s+Math.imul(N,W)|0,i=i+Math.imul(M,q)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,Y)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(S,$)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(_,J)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,at)|0;var At=(l+(i=i+Math.imul(u,ht)|0)|0)+((8191&(n=(n=n+Math.imul(u,lt)|0)+Math.imul(d,ht)|0))<<13)|0;l=((s=s+Math.imul(d,lt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(k,j),n=(n=Math.imul(k,V))+Math.imul(D,j)|0,s=Math.imul(D,V),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(P,z)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(O,q)|0,n=(n=n+Math.imul(O,Y)|0)+Math.imul(N,q)|0,s=s+Math.imul(N,Y)|0,i=i+Math.imul(M,$)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,at)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(i=i+Math.imul(u,ut)|0)|0)+((8191&(n=(n=n+Math.imul(u,dt)|0)+Math.imul(d,ut)|0))<<13)|0;l=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(x,j),n=(n=Math.imul(x,V))+Math.imul(F,j)|0,s=Math.imul(F,V),i=i+Math.imul(k,z)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(D,z)|0,s=s+Math.imul(D,W)|0,i=i+Math.imul(R,q)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,Y)|0,i=i+Math.imul(O,$)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(N,$)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(_,st)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,ut)|0,s=s+Math.imul(m,dt)|0;var Tt=(l+(i=i+Math.imul(u,pt)|0)|0)+((8191&(n=(n=n+Math.imul(u,mt)|0)+Math.imul(d,pt)|0))<<13)|0;l=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(x,z),n=(n=Math.imul(x,W))+Math.imul(F,z)|0,s=Math.imul(F,W),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,Y)|0)+Math.imul(D,q)|0,s=s+Math.imul(D,Y)|0,i=i+Math.imul(R,$)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(P,$)|0,s=s+Math.imul(P,X)|0,i=i+Math.imul(O,J)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(A,st)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,lt)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,lt)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(v,ut)|0,s=s+Math.imul(v,dt)|0;var Mt=(l+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(x,q),n=(n=Math.imul(x,Y))+Math.imul(F,q)|0,s=Math.imul(F,Y),i=i+Math.imul(k,$)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(D,$)|0,s=s+Math.imul(D,X)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(M,st)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,at)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(w,ut)|0,s=s+Math.imul(w,dt)|0;var It=(l+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(x,$),n=(n=Math.imul(x,X))+Math.imul(F,$)|0,s=Math.imul(F,X),i=i+Math.imul(k,J)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(O,st)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,at)|0,i=i+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,lt)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,lt)|0,i=i+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,dt)|0)+Math.imul(S,ut)|0,s=s+Math.imul(S,dt)|0;var Ct=(l+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,mt)|0)+Math.imul(w,pt)|0))<<13)|0;l=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(x,J),n=(n=Math.imul(x,tt))+Math.imul(F,J)|0,s=Math.imul(F,tt),i=i+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,it)|0)+Math.imul(D,rt)|0,s=s+Math.imul(D,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,at)|0,i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(I,ut)|0,s=s+Math.imul(I,dt)|0;var Ot=(l+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(x,rt),n=(n=Math.imul(x,it))+Math.imul(F,rt)|0,s=Math.imul(F,it),i=i+Math.imul(k,st)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,at)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(N,ut)|0,s=s+Math.imul(N,dt)|0;var Nt=(l+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(I,pt)|0))<<13)|0;l=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(x,st),n=(n=Math.imul(x,at))+Math.imul(F,st)|0,s=Math.imul(F,at),i=i+Math.imul(k,ht)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(D,ht)|0,s=s+Math.imul(D,lt)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ut)|0,s=s+Math.imul(P,dt)|0;var Lt=(l+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,i=Math.imul(x,ht),n=(n=Math.imul(x,lt))+Math.imul(F,ht)|0,s=Math.imul(F,lt),i=i+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,dt)|0)+Math.imul(D,ut)|0,s=s+Math.imul(D,dt)|0;var Rt=(l+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(x,ut),n=(n=Math.imul(x,dt))+Math.imul(F,ut)|0,s=Math.imul(F,dt);var Pt=(l+(i=i+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,mt)|0)+Math.imul(D,pt)|0))<<13)|0;l=((s=s+Math.imul(D,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var Bt=(l+(i=Math.imul(x,pt))|0)+((8191&(n=(n=Math.imul(x,mt))+Math.imul(F,pt)|0))<<13)|0;return l=((s=Math.imul(F,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=_t,h[5]=wt,h[6]=Et,h[7]=At,h[8]=St,h[9]=Tt,h[10]=Mt,h[11]=It,h[12]=Ct,h[13]=Ot,h[14]=Nt,h[15]=Lt,h[16]=Rt,h[17]=Pt,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(f=d),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?f(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,a&=67108863}r.words[s]=o,i=a,a=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,s){for(var a=0;a>>=1)n++;return 1<>>=13,i[2*a+1]=8191&s,s>>>=13;for(a=2*e;a>=26,e+=n/67108864|0,e+=s>>>26,this.words[i]=67108863&s}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,s=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var s=t%26,a=Math.min((t-s)/26,this.length),o=67108863^67108863>>>s<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=n);l--){var u=0|this.words[l];this.words[l]=c<<26-s|u>>>s,c=u&o}return h&&0!==c&&(h.words[h.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&a}for(;n>26,this.words[n+i]=67108863&a;if(0===o)return this.strip();for(r(-1===o),o=0,n=0;n>26,this.words[n]=67108863&a;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,a=0|s.words[s.length-1];0!==(r=26-this._countBits(a))&&(s=s.ushln(r),i.iushln(r),a=0|s.words[s.length-1]);var o,h=i.length-s.length;if('mod'!==e){(o=new n(null)).length=h+1,o.words=new Array(o.length);for(var l=0;l=0;u--){var d=67108864*(0|i.words[s.length+u])+(0|i.words[s.length+u-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(s,d,u);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(s,1,u),i.isZero()||(i.negative^=1);o&&(o.words[u]=d)}return o&&o.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),'mod'!==e&&(s=o.div.neg()),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:s,mod:a}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),'mod'!==e&&(s=o.div.neg()),{div:s,mod:o.mod}):this.negative&t.negative?(o=this.neg().divmod(t.neg(),e),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:o.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var s,a,o},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),a=new n(0),o=new n(0),h=new n(1),l=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++l;for(var c=i.clone(),u=e.clone();!e.isZero();){for(var d=0,f=1;!(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||a.isOdd())&&(s.iadd(c),a.isub(u)),s.iushrn(1),a.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(c),h.isub(u)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o),a.isub(h)):(i.isub(e),o.isub(s),h.isub(a))}return{a:o,b:h,gcd:i.iushln(l)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,s=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var a=new n(1),o=new n(0),h=s.clone();i.cmpn(1)>0&&s.cmpn(1)>0;){for(var l=0,c=1;!(i.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(i.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var u=0,d=1;!(s.words[0]&d)&&u<26;++u,d<<=1);if(u>0)for(s.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);i.cmp(s)>=0?(i.isub(s),a.isub(o)):(s.isub(i),o.isub(a))}return(e=0===i.cmpn(1)?a:o).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,o&=67108863,this.words[a]=o}return 0!==s&&(this.words[a]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function _(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function w(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function E(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=a}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new _;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new w}return g[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},E.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),a=0;!s.isZero()&&0===s.andln(1);)a++,s.iushrn(1);r(!s.isZero());var o=new n(1).toRed(this),h=o.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);0!==this.pow(c,l).cmp(h);)c.redIAdd(h);for(var u=this.pow(c,s),d=this.pow(t,s.addn(1).iushrn(1)),f=this.pow(t,s),p=a;0!==f.cmp(o);){for(var m=f,g=0;0!==m.cmp(o);g++)m=m.redSqr();r(g=0;i--){for(var l=e.words[i],c=h-1;c>=0;c--){var u=l>>c&1;(s!==r[0]&&(s=this.sqr(s)),0!==u||0!==a)?(a<<=1,a|=u,(4===++o||0===i&&0===c)&&(s=this.mul(s,r[a]),o=0,a=0)):o=0}h=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),qe=P((()=>{})),Ye=P(((t,e)=>{var r,i;function n(t){this.rand=t}if(e.exports=function(t){return r||(r=new n(null)),r.generate(t)},e.exports.Rand=n,n.prototype.generate=function(t){return this._rand(t)},n.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r{var r=Ke(),i=Ye();function n(t){this.rand=t||new i.Rand}e.exports=n,n.create=function(t){return new n(t)},n.prototype._randbelow=function(t){var e=t.bitLength(),i=Math.ceil(e/8);do{var n=new r(this.rand.generate(i))}while(n.cmp(t)>=0);return n},n.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},n.prototype.test=function(t,e,i){var n=t.bitLength(),s=r.mont(t),a=new r(1).toRed(s);e||(e=Math.max(1,n/48|0));for(var o=t.subn(1),h=0;!o.testn(h);h++);for(var l=t.shrn(h),c=o.toRed(s);e>0;e--){var u=this._randrange(new r(2),o);i&&i(u);var d=u.toRed(s).redPow(l);if(0!==d.cmp(a)&&0!==d.cmp(c)){for(var f=1;f0;e--){var c=this._randrange(new r(2),a),u=t.gcd(c);if(0!==u.cmpn(1))return u;var d=c.toRed(n).redPow(h);if(0!==d.cmp(s)&&0!==d.cmp(l)){for(var f=1;f{var r=G();e.exports=g,g.simpleSieve=p,g.fermatTest=m;var i=We(),n=new i(24),s=new(Ze()),a=new i(1),o=new i(2),h=new i(5),l=(new i(16),new i(8),new i(10)),c=new i(3),u=(new i(7),new i(11)),d=new i(4),f=(new i(12),null);function p(t){for(var e=function(){if(null!==f)return f;var t=[];t[0]=2;for(var e=1,r=3;r<1048576;r+=2){for(var i=Math.ceil(Math.sqrt(r)),n=0;nt;)f.ishrn(1);if(f.isEven()&&f.iadd(a),f.testn(1)||f.iadd(o),e.cmp(o)){if(!e.cmp(h))for(;f.mod(l).cmp(c);)f.iadd(d)}else for(;f.mod(n).cmp(u);)f.iadd(d);if(p(g=f.shrn(1))&&p(f)&&m(g)&&m(f)&&s.test(g)&&s.test(f))return f}}})),Xe=P(((t,e)=>{e.exports={modp1:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff'},modp2:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff'},modp5:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff'},modp14:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff'},modp15:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff'},modp16:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff'},modp17:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff'},modp18:{gen:'02',prime:'ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff'}}})),Qe=P(((t,e)=>{var r=We(),i=new(Ze()),n=new r(24),s=new r(11),a=new r(10),o=new r(3),h=new r(7),l=$e(),c=G();function u(t,e){return e=e||'utf8',Buffer.isBuffer(t)||(t=new Buffer(t,e)),this._pub=new r(t),this}function d(t,e){return e=e||'utf8',Buffer.isBuffer(t)||(t=new Buffer(t,e)),this._priv=new r(t),this}e.exports=p;var f={};function p(t,e,i){this.setGenerator(e),this.__prime=new r(t),this._prime=r.mont(this.__prime),this._primeLen=t.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,i?(this.setPublicKey=u,this.setPrivateKey=d):this._primeCode=8}function m(t,e){var r=new Buffer(t.toArray());return e?r.toString(e):r}Object.defineProperty(p.prototype,'verifyError',{enumerable:!0,get:function(){return'number'!=typeof this._primeCode&&(this._primeCode=function(t,e){var r=e.toString('hex'),c=[r,t.toString(16)].join('_');if(c in f)return f[c];var u,d=0;if(t.isEven()||!l.simpleSieve||!l.fermatTest(t)||!i.test(t))return d+=1,d+='02'===r||'05'===r?8:4,f[c]=d,d;switch(i.test(t.shrn(1))||(d+=2),r){case'02':t.mod(n).cmp(s)&&(d+=8);break;case'05':(u=t.mod(a)).cmp(o)&&u.cmp(h)&&(d+=8);break;default:d+=4}return f[c]=d,d}(this.__prime,this.__gen)),this._primeCode}}),p.prototype.generateKeys=function(){return this._priv||(this._priv=new r(c(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},p.prototype.computeSecret=function(t){var e=(t=(t=new r(t)).toRed(this._prime)).redPow(this._priv).fromRed(),i=new Buffer(e.toArray()),n=this.getPrime();if(i.length{var e=$e(),r=Xe(),i=Qe();var n={binary:!0,hex:!0,base64:!0};t.DiffieHellmanGroup=t.createDiffieHellmanGroup=t.getDiffieHellman=function(t){var e=new Buffer(r[t].prime,'hex'),n=new Buffer(r[t].gen,'hex');return new i(e,n)},t.createDiffieHellman=t.DiffieHellman=function t(r,s,a,o){return Buffer.isBuffer(s)||void 0===n[s]?t(r,'binary',s,a):(s=s||'binary',o=o||'binary',a=a||new Buffer([2]),Buffer.isBuffer(a)||(a=new Buffer(a,o)),'number'==typeof r?new i(e(r,a),a,!0):(Buffer.isBuffer(r)||(r=new Buffer(r,s)),new i(r,a,!0)))}})),tr=P(((t,e)=>{e.exports=W().EventEmitter})),er=P(((t,e)=>{function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:'unshift',value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:'shift',value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:'clear',value:function(){this.head=this.tail=null,this.length=0}},{key:'join',value:function(t){if(0===this.length)return'';for(var e=this.head,r=''+e.data;e=e.next;)r+=t+e.data;return r}},{key:'concat',value:function(t){if(0===this.length)return s.alloc(0);for(var e=s.allocUnsafe(t>>>0),r=this.head,i=0;r;)h(r.data,e,i),i+=r.data.length,r=r.next;return e}},{key:'consume',value:function(t,e){var r;return tn.length?n.length:t;if(s===n.length?i+=n:i+=n.slice(0,t),0===(t-=s)){s===n.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(s));break}++r}return this.length-=r,i}},{key:'_getBuffer',value:function(t){var e=s.allocUnsafe(t),r=this.head,i=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var n=r.data,a=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,a),0===(t-=a)){a===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(a));break}++i}return this.length-=i,e}},{key:o,value:function(t,e){return a(this,function(t){for(var e=1;e{function r(t,e){n(t,e),i(t)}function i(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit('close')}function n(t,e){t.emit('error',e)}e.exports={destroy:function(t,e){var s=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||o?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?s._writableState?s._writableState.errorEmitted?process.nextTick(i,s):(s._writableState.errorEmitted=!0,process.nextTick(r,s,t)):process.nextTick(r,s,t):e?(process.nextTick(i,s),e(t)):process.nextTick(i,s)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var{_readableState:r,_writableState:i}=t;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit('error',e)}}})),ir=P(((t,e)=>{var r={};function i(t,e,i){i||(i=Error);var n=function(t){function r(r,i,n){return t.call(this,function(t,r,i){return'string'==typeof e?e:e(t,r,i)}(r,i,n))||this}return function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}(r,t),r}(i);n.prototype.name=i.name,n.prototype.code=t,r[t]=n}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?'one of '.concat(e,' ').concat(t.slice(0,r-1).join(', '),', or ')+t[r-1]:2===r?'one of '.concat(e,' ').concat(t[0],' or ').concat(t[1]):'of '.concat(e,' ').concat(t[0])}return'of '.concat(e,' ').concat(String(t))}i('ERR_INVALID_OPT_VALUE',(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),i('ERR_INVALID_ARG_TYPE',(function(t,e,r){var i,s;if('string'==typeof e&&function(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}(e,'not ')?(i='must not be',e=e.replace(/^not /,'')):i='must be',function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t,' argument'))s='The '.concat(t,' ').concat(i,' ').concat(n(e,'type'));else{var a=function(t,e,r){return'number'!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,'.')?'property':'argument';s='The "'.concat(t,'" ').concat(a,' ').concat(i,' ').concat(n(e,'type'))}return s+='. Received type '.concat(typeof r)}),TypeError),i('ERR_STREAM_PUSH_AFTER_EOF','stream.push() after EOF'),i('ERR_METHOD_NOT_IMPLEMENTED',(function(t){return'The '+t+' method is not implemented'})),i('ERR_STREAM_PREMATURE_CLOSE','Premature close'),i('ERR_STREAM_DESTROYED',(function(t){return'Cannot call '+t+' after a stream was destroyed'})),i('ERR_MULTIPLE_CALLBACK','Callback called multiple times'),i('ERR_STREAM_CANNOT_PIPE','Cannot pipe, not readable'),i('ERR_STREAM_WRITE_AFTER_END','write after end'),i('ERR_STREAM_NULL_VALUES','May not write null values to stream',TypeError),i('ERR_UNKNOWN_ENCODING',(function(t){return'Unknown encoding: '+t}),TypeError),i('ERR_STREAM_UNSHIFT_AFTER_END_EVENT','stream.unshift() after end event'),e.exports.codes=r})),nr=P(((t,e)=>{var r=ir().codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,i,n){var s=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,n,i);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(n?i:'highWaterMark',s);return Math.floor(s)}return t.objectMode?16:16384}}})),sr=P(((t,e)=>{function r(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}var i;e.exports=A,A.WritableState=E;var n={deprecate:Q()},s=tr(),a=j().Buffer,o=global.Uint8Array||function(){};var h,l=rr(),c=nr().getHighWaterMark,u=ir().codes,d=u.ERR_INVALID_ARG_TYPE,f=u.ERR_METHOD_NOT_IMPLEMENTED,p=u.ERR_MULTIPLE_CALLBACK,m=u.ERR_STREAM_CANNOT_PIPE,g=u.ERR_STREAM_DESTROYED,y=u.ERR_STREAM_NULL_VALUES,v=u.ERR_STREAM_WRITE_AFTER_END,b=u.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function w(){}function E(t,e,n){i=i||ar(),t=t||{},'boolean'!=typeof n&&(n=e instanceof i),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=c(this,t,'writableHighWaterMark',n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||'utf8',this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,i=r.sync,n=r.writecb;if('function'!=typeof n)throw new p;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,i,n){--e.pendingcb,r?(process.nextTick(n,i),process.nextTick(O,t,e),t._writableState.errorEmitted=!0,_(t,i)):(n(i),t._writableState.errorEmitted=!0,_(t,i),O(t,e))}(t,r,i,e,n);else{var s=I(r)||t.destroyed;!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest&&M(t,r),i?process.nextTick(T,t,r,s,n):T(t,r,s,n)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}function A(t){var e=this instanceof(i=i||ar());if(!e&&!h.call(A,this))return new A(t);this._writableState=new E(t,this,e),this.writable=!0,t&&('function'==typeof t.write&&(this._write=t.write),'function'==typeof t.writev&&(this._writev=t.writev),'function'==typeof t.destroy&&(this._destroy=t.destroy),'function'==typeof t.final&&(this._final=t.final)),s.call(this)}function S(t,e,r,i,n,s,a){e.writelen=i,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g('write')):r?t._writev(n,e.onwrite):t._write(n,s,e.onwrite),e.sync=!1}function T(t,e,r,i){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit('drain'))}(t,e),e.pendingcb--,i(),O(t,e)}function M(t,e){e.bufferProcessing=!0;var i=e.bufferedRequest;if(t._writev&&i&&i.next){var n=e.bufferedRequestCount,s=new Array(n),a=e.corkedRequestsFree;a.entry=i;for(var o=0,h=!0;i;)s[o]=i,i.isBuf||(h=!1),i=i.next,o+=1;s.allBuffers=h,S(t,e,!0,e.length,s,'',a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new r(e),e.bufferedRequestCount=0}else{for(;i;){var{chunk:l,encoding:c,callback:u}=i;if(S(t,e,!1,e.objectMode?1:l.length,l,c,u),i=i.next,e.bufferedRequestCount--,e.writing)break}null===i&&(e.lastBufferedRequest=null)}e.bufferedRequest=i,e.bufferProcessing=!1}function I(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function C(t,e){t._final((function(r){e.pendingcb--,r&&_(t,r),e.prefinished=!0,t.emit('prefinish'),O(t,e)}))}function O(t,e){var r=I(e);if(r&&(function(t,e){!e.prefinished&&!e.finalCalled&&('function'!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit('prefinish')):(e.pendingcb++,e.finalCalled=!0,process.nextTick(C,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit('finish'),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return r}z()(A,s),E.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(E.prototype,'buffer',{get:n.deprecate((function(){return this.getBuffer()}),'_writableState.buffer is deprecated. Use _writableState.getBuffer instead.','DEP0003')})}catch{}}(),'function'==typeof Symbol&&Symbol.hasInstance&&'function'==typeof Function.prototype[Symbol.hasInstance]?(h=Function.prototype[Symbol.hasInstance],Object.defineProperty(A,Symbol.hasInstance,{value:function(t){return!!h.call(this,t)||this===A&&(t&&t._writableState instanceof E)}})):h=function(t){return t instanceof this},A.prototype.pipe=function(){_(this,new m)},A.prototype.write=function(t,e,r){var i=this._writableState,n=!1,s=!i.objectMode&&function(t){return a.isBuffer(t)||t instanceof o}(t);return s&&!a.isBuffer(t)&&(t=function(t){return a.from(t)}(t)),'function'==typeof e&&(r=e,e=null),s?e='buffer':e||(e=i.defaultEncoding),'function'!=typeof r&&(r=w),i.ending?function(t,e){var r=new v;_(t,r),process.nextTick(e,r)}(this,r):(s||function(t,e,r,i){var n;return null===r?n=new y:'string'!=typeof r&&!e.objectMode&&(n=new d('chunk',['string','Buffer'],r)),!n||(_(t,n),process.nextTick(i,n),!1)}(this,i,t,r))&&(i.pendingcb++,n=function(t,e,r,i,n,s){if(!r){var o=function(t,e,r){return!t.objectMode&&!1!==t.decodeStrings&&'string'==typeof e&&(e=a.from(e,r)),e}(e,i,n);i!==o&&(r=!0,n='buffer',i=o)}var h=e.objectMode?1:i.length;e.length+=h;var l=e.length-1))throw new b(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(A.prototype,'writableBuffer',{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,'writableHighWaterMark',{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(t,e,r){r(new f('_write()'))},A.prototype._writev=null,A.prototype.end=function(t,e,r){var i=this._writableState;return'function'==typeof t?(r=t,t=null,e=null):'function'==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,O(t,e),r&&(e.finished?process.nextTick(r):t.once('finish',r)),e.ended=!0,t.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,'writableLength',{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,'destroyed',{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){!this._writableState||(this._writableState.destroyed=t)}}),A.prototype.destroy=l.destroy,A.prototype._undestroy=l.undestroy,A.prototype._destroy=function(t,e){e(t)}})),ar=P(((t,e)=>{var r=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var i,n,s,a=cr(),o=sr();for(z()(h,a),i=r(o.prototype),s=0;s{var r=ir().codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function t(e,n,s){if('function'==typeof n)return t(e,null,n);n||(n={}),s=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,i=new Array(r),n=0;n{var r;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var n=or(),s=Symbol('lastResolve'),a=Symbol('lastReject'),o=Symbol('error'),h=Symbol('ended'),l=Symbol('lastPromise'),c=Symbol('handlePromise'),u=Symbol('stream');function d(t,e){return{value:t,done:e}}function f(t){var e=t[s];if(null!==e){var r=t[u].read();null!==r&&(t[l]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}function p(t){process.nextTick(f,t)}var m=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((r={get stream(){return this[u]},next:function(){var t=this,e=this[o];if(null!==e)return Promise.reject(e);if(this[h])return Promise.resolve(d(void 0,!0));if(this[u].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[o]?r(t[o]):e(d(void 0,!0))}))}));var r,i=this[l];if(i)r=new Promise(function(t,e){return function(r,i){t.then((function(){e[h]?r(d(void 0,!0)):e[c](r,i)}),i)}}(i,this));else{var n=this[u].read();if(null!==n)return Promise.resolve(d(n,!1));r=new Promise(this[c])}return this[l]=r,r}},i(r,Symbol.asyncIterator,(function(){return this})),i(r,'return',(function(){var t=this;return new Promise((function(e,r){t[u].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),r),m);e.exports=function(t){var e,r=Object.create(g,(i(e={},u,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,o,{value:null,writable:!0}),i(e,h,{value:t._readableState.endEmitted,writable:!0}),i(e,c,{value:function(t,e){var i=r[u].read();i?(r[l]=null,r[s]=null,r[a]=null,t(d(i,!1))):(r[s]=t,r[a]=e)},writable:!0}),e));return r[l]=null,n(t,(function(t){if(t&&'ERR_STREAM_PREMATURE_CLOSE'!==t.code){var e=r[a];return null!==e&&(r[l]=null,r[s]=null,r[a]=null,e(t)),void(r[o]=t)}var i=r[s];null!==i&&(r[l]=null,r[s]=null,r[a]=null,i(d(void 0,!0))),r[h]=!0})),t.on('readable',p.bind(null,r)),r}})),lr=P(((t,e)=>{e.exports=function(){throw new Error('Readable.from is not available in the browser')}})),cr=P(((t,e)=>{var r;e.exports=A,A.ReadableState=E;W().EventEmitter;var i=function(t,e){return t.listeners(e).length},n=tr(),s=j().Buffer,a=global.Uint8Array||function(){};var o,h=q();o=h&&h.debuglog?h.debuglog('stream'):function(){};var l,c,u,d=er(),f=rr(),p=nr().getHighWaterMark,m=ir().codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_STREAM_PUSH_AFTER_EOF,v=m.ERR_METHOD_NOT_IMPLEMENTED,b=m.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;z()(A,n);var _=f.errorOrDestroy,w=['error','close','destroy','pause','resume'];function E(t,e,i){r=r||ar(),t=t||{},'boolean'!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=p(this,t,'readableHighWaterMark',i),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||'utf8',this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=(nt(),x(rt)).StringDecoder),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function A(t){if(r=r||ar(),!(this instanceof A))return new A(t);var e=this instanceof r;this._readableState=new E(t,this,e),this.readable=!0,t&&('function'==typeof t.read&&(this._read=t.read),'function'==typeof t.destroy&&(this._destroy=t.destroy)),n.call(this)}function S(t,e,r,i,n){o('readableAddChunk',e);var h,l=t._readableState;if(null===e)l.reading=!1,function(t,e){if(o('onEofChunk'),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?C(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,O(t)))}}(t,l);else if(n||(h=function(t,e){var r;return!function(t){return s.isBuffer(t)||t instanceof a}(e)&&'string'!=typeof e&&void 0!==e&&!t.objectMode&&(r=new g('chunk',['string','Buffer','Uint8Array'],e)),r}(l,e)),h)_(t,h);else if(l.objectMode||e&&e.length>0)if('string'!=typeof e&&!l.objectMode&&Object.getPrototypeOf(e)!==s.prototype&&(e=function(t){return s.from(t)}(e)),i)l.endEmitted?_(t,new b):T(t,l,e,!0);else if(l.ended)_(t,new y);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!r?(e=l.decoder.write(e),l.objectMode||0!==e.length?T(t,l,e,!1):N(t,l)):T(t,l,e,!1)}else i||(l.reading=!1,N(t,l));return!l.ended&&(l.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=M?t=M:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function C(t){var e=t._readableState;o('emitReadable',e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o('emitReadable',e.flowing),e.emittedReadable=!0,process.nextTick(O,t))}function O(t){var e=t._readableState;o('emitReadable_',e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&(t.emit('readable'),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,k(t)}function N(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(L,t,e))}function L(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount('data')>0&&t.resume()}function P(t){o('readable nexttick read 0'),t.read(0)}function B(t,e){o('resume',e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit('resume'),k(t),e.flowing&&!e.reading&&t.read(0)}function k(t){var e=t._readableState;for(o('flow',e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(''):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function U(t){var e=t._readableState;o('endReadable',e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(F,e,t))}function F(t,e){if(o('endReadableNT',t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit('end'),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,i=t.length;r=e.highWaterMark:e.length>0)||e.ended))return o('read: emitReadable',e.length,e.ended),0===e.length&&e.ended?U(this):C(this),null;if(0===(t=I(t,e))&&e.ended)return 0===e.length&&U(this),null;var i,n=e.needReadable;return o('need readable',n),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&U(this)),null!==i&&this.emit('data',i),i},A.prototype._read=function(t){_(this,new v('_read()'))},A.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o('pipe count=%d opts=%j',n.pipesCount,e);var s=(!e||!1!==e.end)&&t!==process.stdout&&t!==process.stderr?h:m;function a(e,i){o('onunpipe'),e===r&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,o('cleanup'),t.removeListener('close',f),t.removeListener('finish',p),t.removeListener('drain',l),t.removeListener('error',d),t.removeListener('unpipe',a),r.removeListener('end',h),r.removeListener('end',m),r.removeListener('data',u),c=!0,n.awaitDrain&&(!t._writableState||t._writableState.needDrain)&&l())}function h(){o('onend'),t.end()}n.endEmitted?process.nextTick(s):r.once('end',s),t.on('unpipe',a);var l=function(t){return function(){var e=t._readableState;o('pipeOnDrain',e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&i(t,'data')&&(e.flowing=!0,k(t))}}(r);t.on('drain',l);var c=!1;function u(e){o('ondata');var i=t.write(e);o('dest.write',i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!c&&(o('false write response, pause',n.awaitDrain),n.awaitDrain++),r.pause())}function d(e){o('onerror',e),m(),t.removeListener('error',d),0===i(t,'error')&&_(t,e)}function f(){t.removeListener('finish',p),m()}function p(){o('onfinish'),t.removeListener('close',f),m()}function m(){o('unpipe'),r.unpipe(t)}return r.on('data',u),function(t,e,r){if('function'==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,'error',d),t.once('close',f),t.once('finish',p),t.emit('pipe',r),n.flowing||(o('pipe resume'),r.resume()),t},A.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit('unpipe',this,r)),this;if(!t){var{pipes:i,pipesCount:n}=e;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==i.flowing&&this.resume()):'readable'===t&&!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,o('on readable',i.length,i.reading),i.length?C(this):i.reading||process.nextTick(P,this)),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(t,e){var r=n.prototype.removeListener.call(this,t,e);return'readable'===t&&process.nextTick(R,this),r},A.prototype.removeAllListeners=function(t){var e=n.prototype.removeAllListeners.apply(this,arguments);return('readable'===t||void 0===t)&&process.nextTick(R,this),e},A.prototype.resume=function(){var t=this._readableState;return t.flowing||(o('resume'),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(B,t,e))}(this,t)),t.paused=!1,this},A.prototype.pause=function(){return o('call pause flowing=%j',this._readableState.flowing),!1!==this._readableState.flowing&&(o('pause'),this._readableState.flowing=!1,this.emit('pause')),this._readableState.paused=!0,this},A.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;for(var n in t.on('end',(function(){if(o('wrapped end'),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on('data',(function(n){(o('wrapped data'),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n||!(r.objectMode||n&&n.length))||(e.push(n)||(i=!0,t.pause()))})),t)void 0===this[n]&&'function'==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var s=0;s{e.exports=l;var r=ir().codes,i=r.ERR_METHOD_NOT_IMPLEMENTED,n=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,o=ar();function h(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit('error',new n);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var s=this._readableState;s.reading=!1,(s.needReadable||s.length{e.exports=i;var r=ur();function i(t){if(!(this instanceof i))return new i(t);r.call(this,t)}z()(i,r),i.prototype._transform=function(t,e,r){r(null,t)}})),fr=P(((t,e)=>{var r;var i=ir().codes,n=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function o(t){t()}function h(t,e){return t.pipe(e)}e.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){c||(c=t),t&&u.forEach(o),!n&&(u.forEach(o),l(c))}))}));return e.reduce(h)}})),pr=P(((t,e)=>{(t=e.exports=cr()).Stream=t,t.Readable=t,t.Writable=sr(),t.Duplex=ar(),t.Transform=ur(),t.PassThrough=dr(),t.finished=or(),t.pipeline=fr()})),mr=P(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var s;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{s=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:ze().Buffer}catch{}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,'Invalid character in '+t)}function o(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var s=0,a=0,o=Math.min(t.length,i),h=e;h=49?l-49+10:l>=17?l-17+10:l,r(l>=0&&a0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=a<>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);else if('le'===i)for(n=0,s=0;n>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=o(t,e,i)<=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,a=s%i,o=Math.min(s,s-a)+r,l=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},typeof Symbol<'u'&&'function'==typeof Symbol.for)try{n.prototype[Symbol.for('nodejs.util.inspect.custom')]=c}catch{n.prototype.inspect=c}else n.prototype.inspect=c;function c(){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'],d=[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],f=[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];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,s=0,a=0;a>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==s||a!==this.length-1?u[6-h.length]+h+i:h+i}for(0!==s&&(i=s.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var l=d[t],c=f[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modrn(c).toString(t);i=(p=p.idivn(c)).isZero()?m+i:u[l-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(s,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],a=n*s,o=67108863&a,h=a/67108864|0;r.words[0]=o;for(var l=1;l>>26,u=67108863&h,d=Math.min(l,e.length-1),f=Math.max(0,l-t.length+1);f<=d;f++){var p=l-f|0;c+=(a=(n=0|t.words[p])*(s=0|e.words[f])+u)/67108864|0,u=67108863&a}r.words[l]=0|u,h=0|c}return 0!==h?r.words[l]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),s=i||Math.max(1,n);r(n<=s,'byte array longer than desired length'),r(s>0,'Requested array length <= 0');var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this['_toArrayLike'+('le'===e?'LE':'BE')](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,s=0;n>8&255),r>16&255),6===s?(r>24&255),i=0,s=0):(i=a>>>24,s+=2)}if(r=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===s?(r>=0&&(t[r--]=a>>24&255),i=0,s=0):(i=a>>>24,s+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,a=0;a>26,this.words[a]=67108863&e;for(;0!==s&&a>26,this.words[a]=67108863&e;if(0===s&&a>>13,f=0|a[1],p=8191&f,m=f>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],_=8191&b,w=b>>>13,E=0|a[4],A=8191&E,S=E>>>13,T=0|a[5],M=8191&T,I=T>>>13,C=0|a[6],O=8191&C,N=C>>>13,L=0|a[7],R=8191&L,P=L>>>13,B=0|a[8],k=8191&B,D=B>>>13,U=0|a[9],x=8191&U,F=U>>>13,H=0|o[0],j=8191&H,V=H>>>13,G=0|o[1],z=8191&G,W=G>>>13,K=0|o[2],q=8191&K,Y=K>>>13,Z=0|o[3],$=8191&Z,X=Z>>>13,Q=0|o[4],J=8191&Q,tt=Q>>>13,et=0|o[5],rt=8191&et,it=et>>>13,nt=0|o[6],st=8191&nt,at=nt>>>13,ot=0|o[7],ht=8191&ot,lt=ot>>>13,ct=0|o[8],ut=8191&ct,dt=ct>>>13,ft=0|o[9],pt=8191&ft,mt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(i=Math.imul(u,j))|0)+((8191&(n=(n=Math.imul(u,V))+Math.imul(d,j)|0))<<13)|0;l=((s=Math.imul(d,V))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,j),n=(n=Math.imul(p,V))+Math.imul(m,j)|0,s=Math.imul(m,V);var yt=(l+(i=i+Math.imul(u,z)|0)|0)+((8191&(n=(n=n+Math.imul(u,W)|0)+Math.imul(d,z)|0))<<13)|0;l=((s=s+Math.imul(d,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,j),n=(n=Math.imul(y,V))+Math.imul(v,j)|0,s=Math.imul(v,V),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,z)|0,s=s+Math.imul(m,W)|0;var vt=(l+(i=i+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,Y)|0)+Math.imul(d,q)|0))<<13)|0;l=((s=s+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,j),n=(n=Math.imul(_,V))+Math.imul(w,j)|0,s=Math.imul(w,V),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(v,z)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,q)|0,s=s+Math.imul(m,Y)|0;var bt=(l+(i=i+Math.imul(u,$)|0)|0)+((8191&(n=(n=n+Math.imul(u,X)|0)+Math.imul(d,$)|0))<<13)|0;l=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(A,j),n=(n=Math.imul(A,V))+Math.imul(S,j)|0,s=Math.imul(S,V),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,z)|0,s=s+Math.imul(w,W)|0,i=i+Math.imul(y,q)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(v,q)|0,s=s+Math.imul(v,Y)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,$)|0,s=s+Math.imul(m,X)|0;var _t=(l+(i=i+Math.imul(u,J)|0)|0)+((8191&(n=(n=n+Math.imul(u,tt)|0)+Math.imul(d,J)|0))<<13)|0;l=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(M,j),n=(n=Math.imul(M,V))+Math.imul(I,j)|0,s=Math.imul(I,V),i=i+Math.imul(A,z)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(S,z)|0,s=s+Math.imul(S,W)|0,i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(w,q)|0,s=s+Math.imul(w,Y)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(v,$)|0,s=s+Math.imul(v,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var wt=(l+(i=i+Math.imul(u,rt)|0)|0)+((8191&(n=(n=n+Math.imul(u,it)|0)+Math.imul(d,rt)|0))<<13)|0;l=((s=s+Math.imul(d,it)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(O,j),n=(n=Math.imul(O,V))+Math.imul(N,j)|0,s=Math.imul(N,V),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(I,z)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(A,q)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(S,q)|0,s=s+Math.imul(S,Y)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,X)|0)+Math.imul(w,$)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Et=(l+(i=i+Math.imul(u,st)|0)|0)+((8191&(n=(n=n+Math.imul(u,at)|0)+Math.imul(d,st)|0))<<13)|0;l=((s=s+Math.imul(d,at)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(R,j),n=(n=Math.imul(R,V))+Math.imul(P,j)|0,s=Math.imul(P,V),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(N,z)|0,s=s+Math.imul(N,W)|0,i=i+Math.imul(M,q)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,Y)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(S,$)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(_,J)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,at)|0;var At=(l+(i=i+Math.imul(u,ht)|0)|0)+((8191&(n=(n=n+Math.imul(u,lt)|0)+Math.imul(d,ht)|0))<<13)|0;l=((s=s+Math.imul(d,lt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(k,j),n=(n=Math.imul(k,V))+Math.imul(D,j)|0,s=Math.imul(D,V),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(P,z)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(O,q)|0,n=(n=n+Math.imul(O,Y)|0)+Math.imul(N,q)|0,s=s+Math.imul(N,Y)|0,i=i+Math.imul(M,$)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,at)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(i=i+Math.imul(u,ut)|0)|0)+((8191&(n=(n=n+Math.imul(u,dt)|0)+Math.imul(d,ut)|0))<<13)|0;l=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(x,j),n=(n=Math.imul(x,V))+Math.imul(F,j)|0,s=Math.imul(F,V),i=i+Math.imul(k,z)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(D,z)|0,s=s+Math.imul(D,W)|0,i=i+Math.imul(R,q)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,Y)|0,i=i+Math.imul(O,$)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(N,$)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(_,st)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,ut)|0,s=s+Math.imul(m,dt)|0;var Tt=(l+(i=i+Math.imul(u,pt)|0)|0)+((8191&(n=(n=n+Math.imul(u,mt)|0)+Math.imul(d,pt)|0))<<13)|0;l=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(x,z),n=(n=Math.imul(x,W))+Math.imul(F,z)|0,s=Math.imul(F,W),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,Y)|0)+Math.imul(D,q)|0,s=s+Math.imul(D,Y)|0,i=i+Math.imul(R,$)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(P,$)|0,s=s+Math.imul(P,X)|0,i=i+Math.imul(O,J)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(A,st)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,lt)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,lt)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(v,ut)|0,s=s+Math.imul(v,dt)|0;var Mt=(l+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(x,q),n=(n=Math.imul(x,Y))+Math.imul(F,q)|0,s=Math.imul(F,Y),i=i+Math.imul(k,$)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(D,$)|0,s=s+Math.imul(D,X)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(M,st)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,at)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(w,ut)|0,s=s+Math.imul(w,dt)|0;var It=(l+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(x,$),n=(n=Math.imul(x,X))+Math.imul(F,$)|0,s=Math.imul(F,X),i=i+Math.imul(k,J)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(O,st)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,at)|0,i=i+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,lt)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,lt)|0,i=i+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,dt)|0)+Math.imul(S,ut)|0,s=s+Math.imul(S,dt)|0;var Ct=(l+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,mt)|0)+Math.imul(w,pt)|0))<<13)|0;l=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(x,J),n=(n=Math.imul(x,tt))+Math.imul(F,J)|0,s=Math.imul(F,tt),i=i+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,it)|0)+Math.imul(D,rt)|0,s=s+Math.imul(D,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,at)|0,i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(I,ut)|0,s=s+Math.imul(I,dt)|0;var Ot=(l+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(x,rt),n=(n=Math.imul(x,it))+Math.imul(F,rt)|0,s=Math.imul(F,it),i=i+Math.imul(k,st)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,at)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(N,ut)|0,s=s+Math.imul(N,dt)|0;var Nt=(l+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(I,pt)|0))<<13)|0;l=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(x,st),n=(n=Math.imul(x,at))+Math.imul(F,st)|0,s=Math.imul(F,at),i=i+Math.imul(k,ht)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(D,ht)|0,s=s+Math.imul(D,lt)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ut)|0,s=s+Math.imul(P,dt)|0;var Lt=(l+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,i=Math.imul(x,ht),n=(n=Math.imul(x,lt))+Math.imul(F,ht)|0,s=Math.imul(F,lt),i=i+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,dt)|0)+Math.imul(D,ut)|0,s=s+Math.imul(D,dt)|0;var Rt=(l+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(x,ut),n=(n=Math.imul(x,dt))+Math.imul(F,ut)|0,s=Math.imul(F,dt);var Pt=(l+(i=i+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,mt)|0)+Math.imul(D,pt)|0))<<13)|0;l=((s=s+Math.imul(D,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var Bt=(l+(i=Math.imul(x,pt))|0)+((8191&(n=(n=Math.imul(x,mt))+Math.imul(F,pt)|0))<<13)|0;return l=((s=Math.imul(F,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=_t,h[5]=wt,h[6]=Et,h[7]=At,h[8]=St,h[9]=Tt,h[10]=Mt,h[11]=It,h[12]=Ct,h[13]=Ot,h[14]=Nt,h[15]=Lt,h[16]=Rt,h[17]=Pt,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,a&=67108863}r.words[s]=o,i=a,a=n}return 0!==i?r.words[s]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(m=p),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):y(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},v.prototype.permute=function(t,e,r,i,n,s){for(var a=0;a>>=1)n++;return 1<>>=13,i[2*a+1]=8191&s,s>>>=13;for(a=2*e;a>=26,i+=s/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,s=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var s=t%26,a=Math.min((t-s)/26,this.length),o=67108863^67108863>>>s<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=n);l--){var u=0|this.words[l];this.words[l]=c<<26-s|u>>>s,c=u&o}return h&&0!==c&&(h.words[h.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&a}for(;n>26,this.words[n+i]=67108863&a;if(0===o)return this._strip();for(r(-1===o),o=0,n=0;n>26,this.words[n]=67108863&a;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,a=0|s.words[s.length-1];0!==(r=26-this._countBits(a))&&(s=s.ushln(r),i.iushln(r),a=0|s.words[s.length-1]);var o,h=i.length-s.length;if('mod'!==e){(o=new n(null)).length=h+1,o.words=new Array(o.length);for(var l=0;l=0;u--){var d=67108864*(0|i.words[s.length+u])+(0|i.words[s.length+u-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(s,d,u);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(s,1,u),i.isZero()||(i.negative^=1);o&&(o.words[u]=d)}return o&&o._strip(),i._strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),'mod'!==e&&(s=o.div.neg()),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:s,mod:a}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),'mod'!==e&&(s=o.div.neg()),{div:s,mod:o.mod}):this.negative&t.negative?(o=this.neg().divmod(t.neg(),e),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:o.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var s,a,o},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,s=this.length-1;s>=0;s--)n=(i*n+(0|this.words[s]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var s=(0|this.words[n])+67108864*i;this.words[n]=s/t|0,i=s%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),a=new n(0),o=new n(0),h=new n(1),l=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++l;for(var c=i.clone(),u=e.clone();!e.isZero();){for(var d=0,f=1;!(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||a.isOdd())&&(s.iadd(c),a.isub(u)),s.iushrn(1),a.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(c),h.isub(u)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o),a.isub(h)):(i.isub(e),o.isub(s),h.isub(a))}return{a:o,b:h,gcd:i.iushln(l)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,s=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var a=new n(1),o=new n(0),h=s.clone();i.cmpn(1)>0&&s.cmpn(1)>0;){for(var l=0,c=1;!(i.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(i.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var u=0,d=1;!(s.words[0]&d)&&u<26;++u,d<<=1);if(u>0)for(s.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);i.cmp(s)>=0?(i.isub(s),a.isub(o)):(s.isub(i),o.isub(a))}return(e=0===i.cmpn(1)?a:o).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,o&=67108863,this.words[a]=o}return 0!==s&&(this.words[a]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new T(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var b={k256:null,p224:null,p192:null,p25519:null};function _(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){_.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function E(){_.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function A(){_.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function S(){_.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function T(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function M(t){T.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}_.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},_.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},_.prototype.split=function(t,e){t.iushrn(this.n,0,e)},_.prototype.imulK=function(t){return t.imul(this.k)},i(w,_),w.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=a}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},w.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(b[t])return b[t];var e;if('k256'===t)e=new w;else if('p224'===t)e=new E;else if('p192'===t)e=new A;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new S}return b[t]=e,e},T.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},T.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},T.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},T.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},T.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},T.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},T.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},T.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},T.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},T.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},T.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},T.prototype.isqr=function(t){return this.imul(t,t.clone())},T.prototype.sqr=function(t){return this.mul(t,t)},T.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),a=0;!s.isZero()&&0===s.andln(1);)a++,s.iushrn(1);r(!s.isZero());var o=new n(1).toRed(this),h=o.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);0!==this.pow(c,l).cmp(h);)c.redIAdd(h);for(var u=this.pow(c,s),d=this.pow(t,s.addn(1).iushrn(1)),f=this.pow(t,s),p=a;0!==f.cmp(o);){for(var m=f,g=0;0!==m.cmp(o);g++)m=m.redSqr();r(g=0;i--){for(var l=e.words[i],c=h-1;c>=0;c--){var u=l>>c&1;(s!==r[0]&&(s=this.sqr(s)),0!==u||0!==a)?(a<<=1,a|=u,(4===++o||0===i&&0===c)&&(s=this.mul(s,r[a]),o=0,a=0)):o=0}h=26}return s},T.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},T.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new M(t)},i(M,T),M.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},M.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},M.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},M.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},M.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),gr=P(((t,e)=>{var r=mr(),i=G();function n(t){var e,n=t.modulus.byteLength();do{e=new r(i(n))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function s(t,e){var i=function(t){var e=n(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),s=e.modulus.byteLength(),a=new r(t).mul(i.blinder).umod(e.modulus),o=a.toRed(r.mont(e.prime1)),h=a.toRed(r.mont(e.prime2)),l=e.coefficient,c=e.prime1,u=e.prime2,d=o.redPow(e.exponent1).fromRed(),f=h.redPow(e.exponent2).fromRed(),p=d.isub(f).imul(l).umod(c).imul(u);return f.iadd(p).imul(i.unblinder).umod(e.modulus).toArrayLike(Buffer,'be',s)}s.getr=n,e.exports=s})),yr=P(((t,e)=>{e.exports={name:'elliptic',version:'6.5.4',description:'EC cryptography',main:'lib/elliptic.js',files:['lib'],scripts:{lint:'eslint lib test','lint:fix':'npm run lint -- --fix',unit:'istanbul test _mocha --reporter=spec test/index.js',test:'npm run lint && npm run unit',version:'grunt dist && git add dist/'},repository:{type:'git',url:'git@github.com:indutny/elliptic'},keywords:['EC','Elliptic','curve','Cryptography'],author:'Fedor Indutny ',license:'MIT',bugs:{url:'https://github.com/indutny/elliptic/issues'},homepage:'https://github.com/indutny/elliptic',devDependencies:{brfs:'^2.0.2',coveralls:'^3.1.0',eslint:'^7.6.0',grunt:'^1.2.1','grunt-browserify':'^5.3.0','grunt-cli':'^1.3.2','grunt-contrib-connect':'^3.0.0','grunt-contrib-copy':'^1.0.0','grunt-contrib-uglify':'^5.0.0','grunt-mocha-istanbul':'^5.0.2','grunt-saucelabs':'^9.0.1',istanbul:'^0.4.5',mocha:'^8.0.1'},dependencies:{'bn.js':'^4.11.9',brorand:'^1.1.0','hash.js':'^1.0.0','hmac-drbg':'^1.0.1',inherits:'^2.0.4','minimalistic-assert':'^1.0.1','minimalistic-crypto-utils':'^1.0.1'}}})),vr=P(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var s;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{s=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:ze().Buffer}catch{}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function o(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,s=Math.min(t.length,r),a=e;a=49?o-49+10:o>=17?o-17+10:o}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=a<>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);else if('le'===i)for(n=0,s=0;n>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=o(t,e,i)<=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,a=s%i,o=Math.min(s,s-a)+r,l=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?''};var l=['','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'],c=[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],u=[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 d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],a=n*s,o=67108863&a,h=a/67108864|0;r.words[0]=o;for(var l=1;l>>26,u=67108863&h,d=Math.min(l,e.length-1),f=Math.max(0,l-t.length+1);f<=d;f++){var p=l-f|0;c+=(a=(n=0|t.words[p])*(s=0|e.words[f])+u)/67108864|0,u=67108863&a}r.words[l]=0|u,h=0|c}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,s=0,a=0;a>>24-n&16777215)||a!==this.length-1?l[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,a--)}for(0!==s&&(i=s.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var d=c[t],f=u[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(f).toString(t);i=(p=p.idivn(f)).isZero()?m+i:l[d-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof s<'u'),this.toArrayLike(s,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),s=i||Math.max(1,n);r(n<=s,'byte array longer than desired length'),r(s>0,'Requested array length <= 0'),this.strip();var a,o,h='le'===e,l=new t(s),c=this.clone();if(h){for(o=0;!c.isZero();o++)a=c.andln(255),c.iushrn(8),l[o]=a;for(;o=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,a=0;a>26,this.words[a]=67108863&e;for(;0!==s&&a>26,this.words[a]=67108863&e;if(0===s&&a>>13,f=0|a[1],p=8191&f,m=f>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],_=8191&b,w=b>>>13,E=0|a[4],A=8191&E,S=E>>>13,T=0|a[5],M=8191&T,I=T>>>13,C=0|a[6],O=8191&C,N=C>>>13,L=0|a[7],R=8191&L,P=L>>>13,B=0|a[8],k=8191&B,D=B>>>13,U=0|a[9],x=8191&U,F=U>>>13,H=0|o[0],j=8191&H,V=H>>>13,G=0|o[1],z=8191&G,W=G>>>13,K=0|o[2],q=8191&K,Y=K>>>13,Z=0|o[3],$=8191&Z,X=Z>>>13,Q=0|o[4],J=8191&Q,tt=Q>>>13,et=0|o[5],rt=8191&et,it=et>>>13,nt=0|o[6],st=8191&nt,at=nt>>>13,ot=0|o[7],ht=8191&ot,lt=ot>>>13,ct=0|o[8],ut=8191&ct,dt=ct>>>13,ft=0|o[9],pt=8191&ft,mt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(i=Math.imul(u,j))|0)+((8191&(n=(n=Math.imul(u,V))+Math.imul(d,j)|0))<<13)|0;l=((s=Math.imul(d,V))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,j),n=(n=Math.imul(p,V))+Math.imul(m,j)|0,s=Math.imul(m,V);var yt=(l+(i=i+Math.imul(u,z)|0)|0)+((8191&(n=(n=n+Math.imul(u,W)|0)+Math.imul(d,z)|0))<<13)|0;l=((s=s+Math.imul(d,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,j),n=(n=Math.imul(y,V))+Math.imul(v,j)|0,s=Math.imul(v,V),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,z)|0,s=s+Math.imul(m,W)|0;var vt=(l+(i=i+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,Y)|0)+Math.imul(d,q)|0))<<13)|0;l=((s=s+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,j),n=(n=Math.imul(_,V))+Math.imul(w,j)|0,s=Math.imul(w,V),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(v,z)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,q)|0,s=s+Math.imul(m,Y)|0;var bt=(l+(i=i+Math.imul(u,$)|0)|0)+((8191&(n=(n=n+Math.imul(u,X)|0)+Math.imul(d,$)|0))<<13)|0;l=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(A,j),n=(n=Math.imul(A,V))+Math.imul(S,j)|0,s=Math.imul(S,V),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,z)|0,s=s+Math.imul(w,W)|0,i=i+Math.imul(y,q)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(v,q)|0,s=s+Math.imul(v,Y)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,$)|0,s=s+Math.imul(m,X)|0;var _t=(l+(i=i+Math.imul(u,J)|0)|0)+((8191&(n=(n=n+Math.imul(u,tt)|0)+Math.imul(d,J)|0))<<13)|0;l=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(M,j),n=(n=Math.imul(M,V))+Math.imul(I,j)|0,s=Math.imul(I,V),i=i+Math.imul(A,z)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(S,z)|0,s=s+Math.imul(S,W)|0,i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(w,q)|0,s=s+Math.imul(w,Y)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(v,$)|0,s=s+Math.imul(v,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var wt=(l+(i=i+Math.imul(u,rt)|0)|0)+((8191&(n=(n=n+Math.imul(u,it)|0)+Math.imul(d,rt)|0))<<13)|0;l=((s=s+Math.imul(d,it)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(O,j),n=(n=Math.imul(O,V))+Math.imul(N,j)|0,s=Math.imul(N,V),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(I,z)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(A,q)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(S,q)|0,s=s+Math.imul(S,Y)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,X)|0)+Math.imul(w,$)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Et=(l+(i=i+Math.imul(u,st)|0)|0)+((8191&(n=(n=n+Math.imul(u,at)|0)+Math.imul(d,st)|0))<<13)|0;l=((s=s+Math.imul(d,at)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(R,j),n=(n=Math.imul(R,V))+Math.imul(P,j)|0,s=Math.imul(P,V),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(N,z)|0,s=s+Math.imul(N,W)|0,i=i+Math.imul(M,q)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,Y)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(S,$)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(_,J)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,at)|0;var At=(l+(i=i+Math.imul(u,ht)|0)|0)+((8191&(n=(n=n+Math.imul(u,lt)|0)+Math.imul(d,ht)|0))<<13)|0;l=((s=s+Math.imul(d,lt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(k,j),n=(n=Math.imul(k,V))+Math.imul(D,j)|0,s=Math.imul(D,V),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(P,z)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(O,q)|0,n=(n=n+Math.imul(O,Y)|0)+Math.imul(N,q)|0,s=s+Math.imul(N,Y)|0,i=i+Math.imul(M,$)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,at)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(i=i+Math.imul(u,ut)|0)|0)+((8191&(n=(n=n+Math.imul(u,dt)|0)+Math.imul(d,ut)|0))<<13)|0;l=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(x,j),n=(n=Math.imul(x,V))+Math.imul(F,j)|0,s=Math.imul(F,V),i=i+Math.imul(k,z)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(D,z)|0,s=s+Math.imul(D,W)|0,i=i+Math.imul(R,q)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,Y)|0,i=i+Math.imul(O,$)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(N,$)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(_,st)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,ut)|0,s=s+Math.imul(m,dt)|0;var Tt=(l+(i=i+Math.imul(u,pt)|0)|0)+((8191&(n=(n=n+Math.imul(u,mt)|0)+Math.imul(d,pt)|0))<<13)|0;l=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(x,z),n=(n=Math.imul(x,W))+Math.imul(F,z)|0,s=Math.imul(F,W),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,Y)|0)+Math.imul(D,q)|0,s=s+Math.imul(D,Y)|0,i=i+Math.imul(R,$)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(P,$)|0,s=s+Math.imul(P,X)|0,i=i+Math.imul(O,J)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(A,st)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,lt)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,lt)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(v,ut)|0,s=s+Math.imul(v,dt)|0;var Mt=(l+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(x,q),n=(n=Math.imul(x,Y))+Math.imul(F,q)|0,s=Math.imul(F,Y),i=i+Math.imul(k,$)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(D,$)|0,s=s+Math.imul(D,X)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(M,st)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,at)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(w,ut)|0,s=s+Math.imul(w,dt)|0;var It=(l+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(x,$),n=(n=Math.imul(x,X))+Math.imul(F,$)|0,s=Math.imul(F,X),i=i+Math.imul(k,J)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(O,st)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,at)|0,i=i+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,lt)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,lt)|0,i=i+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,dt)|0)+Math.imul(S,ut)|0,s=s+Math.imul(S,dt)|0;var Ct=(l+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,mt)|0)+Math.imul(w,pt)|0))<<13)|0;l=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(x,J),n=(n=Math.imul(x,tt))+Math.imul(F,J)|0,s=Math.imul(F,tt),i=i+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,it)|0)+Math.imul(D,rt)|0,s=s+Math.imul(D,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,at)|0,i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(I,ut)|0,s=s+Math.imul(I,dt)|0;var Ot=(l+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(x,rt),n=(n=Math.imul(x,it))+Math.imul(F,rt)|0,s=Math.imul(F,it),i=i+Math.imul(k,st)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,at)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(N,ut)|0,s=s+Math.imul(N,dt)|0;var Nt=(l+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(I,pt)|0))<<13)|0;l=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(x,st),n=(n=Math.imul(x,at))+Math.imul(F,st)|0,s=Math.imul(F,at),i=i+Math.imul(k,ht)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(D,ht)|0,s=s+Math.imul(D,lt)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ut)|0,s=s+Math.imul(P,dt)|0;var Lt=(l+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,i=Math.imul(x,ht),n=(n=Math.imul(x,lt))+Math.imul(F,ht)|0,s=Math.imul(F,lt),i=i+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,dt)|0)+Math.imul(D,ut)|0,s=s+Math.imul(D,dt)|0;var Rt=(l+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(x,ut),n=(n=Math.imul(x,dt))+Math.imul(F,ut)|0,s=Math.imul(F,dt);var Pt=(l+(i=i+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,mt)|0)+Math.imul(D,pt)|0))<<13)|0;l=((s=s+Math.imul(D,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var Bt=(l+(i=Math.imul(x,pt))|0)+((8191&(n=(n=Math.imul(x,mt))+Math.imul(F,pt)|0))<<13)|0;return l=((s=Math.imul(F,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=_t,h[5]=wt,h[6]=Et,h[7]=At,h[8]=St,h[9]=Tt,h[10]=Mt,h[11]=It,h[12]=Ct,h[13]=Ot,h[14]=Nt,h[15]=Lt,h[16]=Rt,h[17]=Pt,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(f=d),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?f(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,a&=67108863}r.words[s]=o,i=a,a=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,s){for(var a=0;a>>=1)n++;return 1<>>=13,i[2*a+1]=8191&s,s>>>=13;for(a=2*e;a>=26,e+=n/67108864|0,e+=s>>>26,this.words[i]=67108863&s}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,s=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var s=t%26,a=Math.min((t-s)/26,this.length),o=67108863^67108863>>>s<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=n);l--){var u=0|this.words[l];this.words[l]=c<<26-s|u>>>s,c=u&o}return h&&0!==c&&(h.words[h.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&a}for(;n>26,this.words[n+i]=67108863&a;if(0===o)return this.strip();for(r(-1===o),o=0,n=0;n>26,this.words[n]=67108863&a;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,a=0|s.words[s.length-1];0!==(r=26-this._countBits(a))&&(s=s.ushln(r),i.iushln(r),a=0|s.words[s.length-1]);var o,h=i.length-s.length;if('mod'!==e){(o=new n(null)).length=h+1,o.words=new Array(o.length);for(var l=0;l=0;u--){var d=67108864*(0|i.words[s.length+u])+(0|i.words[s.length+u-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(s,d,u);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(s,1,u),i.isZero()||(i.negative^=1);o&&(o.words[u]=d)}return o&&o.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),'mod'!==e&&(s=o.div.neg()),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:s,mod:a}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),'mod'!==e&&(s=o.div.neg()),{div:s,mod:o.mod}):this.negative&t.negative?(o=this.neg().divmod(t.neg(),e),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:o.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var s,a,o},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),a=new n(0),o=new n(0),h=new n(1),l=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++l;for(var c=i.clone(),u=e.clone();!e.isZero();){for(var d=0,f=1;!(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||a.isOdd())&&(s.iadd(c),a.isub(u)),s.iushrn(1),a.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(c),h.isub(u)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o),a.isub(h)):(i.isub(e),o.isub(s),h.isub(a))}return{a:o,b:h,gcd:i.iushln(l)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,s=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var a=new n(1),o=new n(0),h=s.clone();i.cmpn(1)>0&&s.cmpn(1)>0;){for(var l=0,c=1;!(i.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(i.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var u=0,d=1;!(s.words[0]&d)&&u<26;++u,d<<=1);if(u>0)for(s.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);i.cmp(s)>=0?(i.isub(s),a.isub(o)):(s.isub(i),o.isub(a))}return(e=0===i.cmpn(1)?a:o).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,o&=67108863,this.words[a]=o}return 0!==s&&(this.words[a]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function _(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function w(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function E(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=a}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new _;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new w}return g[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},E.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),a=0;!s.isZero()&&0===s.andln(1);)a++,s.iushrn(1);r(!s.isZero());var o=new n(1).toRed(this),h=o.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);0!==this.pow(c,l).cmp(h);)c.redIAdd(h);for(var u=this.pow(c,s),d=this.pow(t,s.addn(1).iushrn(1)),f=this.pow(t,s),p=a;0!==f.cmp(o);){for(var m=f,g=0;0!==m.cmp(o);g++)m=m.redSqr();r(g=0;i--){for(var l=e.words[i],c=h-1;c>=0;c--){var u=l>>c&1;(s!==r[0]&&(s=this.sqr(s)),0!==u||0!==a)?(a<<=1,a|=u,(4===++o||0===i&&0===c)&&(s=this.mul(s,r[a]),o=0,a=0)):o=0}h=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),br=P((t=>{var e=t;function r(t){return 1===t.length?'0'+t:t}function i(t){for(var e='',i=0;i>8,a=255&n;s?r.push(s,a):r.push(a)}return r},e.zero2=r,e.toHex=i,e.encode=function(t,e){return'hex'===e?i(t):t}})),_r=P((t=>{var e=t,r=vr(),i=ge(),n=br();e.assert=i,e.toArray=n.toArray,e.zero2=n.zero2,e.toHex=n.toHex,e.encode=n.encode,e.getNAF=function(t,e,r){var i=new Array(Math.max(t.bitLength(),r)+1);i.fill(0);for(var n=1<(n>>1)-1?(n>>1)-h:h,s.isubn(o)):o=0,i[a]=o,s.iushrn(1)}return i},e.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,s=0;t.cmpn(-n)>0||e.cmpn(-s)>0;){var a,o,h=t.andln(3)+n&3,l=e.andln(3)+s&3;3===h&&(h=-1),3===l&&(l=-1),1&h?a=3!==(i=t.andln(7)+n&7)&&5!==i||2!==l?h:-h:a=0,r[0].push(a),1&l?o=3!==(i=e.andln(7)+s&7)&&5!==i||2!==h?l:-l:o=0,r[1].push(o),2*n===a+1&&(n=1-n),2*s===o+1&&(s=1-s),t.iushrn(1),e.iushrn(1)}return r},e.cachedProperty=function(t,e,r){var i='_'+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},e.parseBytes=function(t){return'string'==typeof t?e.toArray(t,'hex'):t},e.intFromLE=function(t){return new r(t,'hex','le')}})),wr=P(((t,e)=>{var r=vr(),i=_r(),n=i.getNAF,s=i.getJSF,a=i.assert;function o(t,e){this.type=t,this.p=new r(e.p,16),this.red=e.prime?r.red(e.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=e.n&&new r(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var i=this.n&&this.p.div(this.n);!i||i.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function h(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=o,o.prototype.point=function(){throw new Error('Not implemented')},o.prototype.validate=function(){throw new Error('Not implemented')},o.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),i=n(e,1,this._bitLength),s=(1<=o;c--)h=(h<<1)+i[c];l.push(h)}for(var u=this.jpoint(null,null,null),d=this.jpoint(null,null,null),f=s;f>0;f--){for(o=0;o=0;l--){for(var c=0;l>=0&&0===o[l];l--)c++;if(l>=0&&c++,h=h.dblp(c),l<0)break;var u=o[l];a(0!==u),h='affine'===t.type?u>0?h.mixedAdd(s[u-1>>1]):h.mixedAdd(s[-u-1>>1].neg()):u>0?h.add(s[u-1>>1]):h.add(s[-u-1>>1].neg())}return'affine'===t.type?h.toP():h},o.prototype._wnafMulAdd=function(t,e,r,i,a){var o,h,l,c=this._wnafT1,u=this._wnafT2,d=this._wnafT3,f=0;for(o=0;o=1;o-=2){var m=o-1,g=o;if(1===c[m]&&1===c[g]){var y=[e[m],null,null,e[g]];0===e[m].y.cmp(e[g].y)?(y[1]=e[m].add(e[g]),y[2]=e[m].toJ().mixedAdd(e[g].neg())):0===e[m].y.cmp(e[g].y.redNeg())?(y[1]=e[m].toJ().mixedAdd(e[g]),y[2]=e[m].add(e[g].neg())):(y[1]=e[m].toJ().mixedAdd(e[g]),y[2]=e[m].toJ().mixedAdd(e[g].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],b=s(r[m],r[g]);for(f=Math.max(b[0].length,f),d[m]=new Array(f),d[g]=new Array(f),h=0;h=0;o--){for(var S=0;o>=0;){var T=!0;for(h=0;h=0&&S++,E=E.dblp(S),o<0)break;for(h=0;h0?l=u[h][M-1>>1]:M<0&&(l=u[h][-M-1>>1].neg()),E='affine'===l.type?E.mixedAdd(l):E.add(l))}}for(o=0;o=Math.ceil((t.bitLength()+1)/e.step)},h.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n{var r=_r(),i=vr(),n=z(),s=wr(),a=r.assert;function o(t){s.call(this,'short',t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function h(t,e,r,n){s.BasePoint.call(this,t,'affine'),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function l(t,e,r,n){s.BasePoint.call(this,t,'jacobian'),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(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.zOne=this.z===this.curve.one}n(o,s),e.exports=o,o.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r,n;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var s=this._getEndoRoots(this.p);e=(e=s[0].cmp(s[1])<0?s[0]:s[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return n=t.basis?t.basis.map((function(t){return{a:new i(t.a,16),b:new i(t.b,16)}})):this._getEndoBasis(r),{beta:e,lambda:r,basis:n}}},o.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),s=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(s).fromRed(),n.redSub(s).fromRed()]},o.prototype._getEndoBasis=function(t){for(var e,r,n,s,a,o,h,l,c,u=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=t,f=this.n.clone(),p=new i(1),m=new i(0),g=new i(0),y=new i(1),v=0;0!==d.cmpn(0);){var b=f.div(d);l=f.sub(b.mul(d)),c=g.sub(b.mul(p));var _=y.sub(b.mul(m));if(!n&&l.cmp(u)<0)e=h.neg(),r=p,n=l.neg(),s=c;else if(n&&2==++v)break;h=l,f=d,d=l,g=p,p=c,y=m,m=_}a=l.neg(),o=c;var w=n.sqr().add(s.sqr());return a.sqr().add(o.sqr()).cmp(w)>=0&&(a=e,o=r),n.negative&&(n=n.neg(),s=s.neg()),a.negative&&(a=a.neg(),o=o.neg()),[{a:n,b:s},{a,b:o}]},o.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),a=n.mul(r.a),o=s.mul(i.a),h=n.mul(r.b),l=s.mul(i.b);return{k1:t.sub(a).sub(o),k2:h.add(l).neg()}},o.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error('invalid point');var s=n.fromRed().isOdd();return(e&&!s||!e&&s)&&(n=n.redNeg()),this.point(t,n)},o.prototype.validate=function(t){if(t.inf)return!0;var{x:e,y:r}=t,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},o.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s':''},h.prototype.isInfinity=function(){return this.inf},h.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},h.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),a=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,a)},h.prototype.getX=function(){return this.x.fromRed()},h.prototype.getY=function(){return this.y.fromRed()},h.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},h.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},h.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},h.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},h.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.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 e},h.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},n(l,s.BasePoint),o.prototype.jpoint=function(t,e,r){return new l(this,t,e,r)},l.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),a=t.y.redMul(r.redMul(this.z)),o=i.redSub(n),h=s.redSub(a);if(0===o.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=o.redSqr(),c=l.redMul(o),u=i.redMul(l),d=h.redSqr().redIAdd(c).redISub(u).redISub(u),f=h.redMul(u.redISub(d)).redISub(s.redMul(c)),p=this.z.redMul(t.z).redMul(o);return this.curve.jpoint(d,f,p)},l.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,s=t.y.redMul(e).redMul(this.z),a=r.redSub(i),o=n.redSub(s);if(0===a.cmpn(0))return 0!==o.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),l=h.redMul(a),c=r.redMul(h),u=o.redSqr().redIAdd(l).redISub(c).redISub(c),d=o.redMul(c.redISub(u)).redISub(n.redMul(l)),f=this.z.redMul(a);return this.curve.jpoint(u,d,f)},l.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},l.prototype.inspect=function(){return this.isInfinity()?'':''},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}})),Ar=P(((t,e)=>{var r=vr(),i=z(),n=wr(),s=_r();function a(t){n.call(this,'mont',t),this.a=new r(t.a,16).toRed(this.red),this.b=new r(t.b,16).toRed(this.red),this.i4=new r(4).toRed(this.red).redInvm(),this.two=new r(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function o(t,e,i){n.BasePoint.call(this,t,'projective'),null===e&&null===i?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new r(e,16),this.z=new r(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,n),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),i=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===i.redSqrt().redSqr().cmp(i)},i(o,n.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new o(this,t,e)},a.prototype.pointFromJSON=function(t){return o.fromJSON(this,t)},o.prototype.precompute=function(){},o.prototype._encode=function(){return this.getX().toArray('be',this.curve.p.byteLength())},o.fromJSON=function(t,e){return new o(t,e[0],e[1]||t.one)},o.prototype.inspect=function(){return this.isInfinity()?'':''},o.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},o.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),i=t.redMul(e),n=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},o.prototype.add=function(){throw new Error('Not supported on Montgomery curve')},o.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=t.x.redAdd(t.z),s=t.x.redSub(t.z).redMul(r),a=n.redMul(i),o=e.z.redMul(s.redAdd(a).redSqr()),h=e.x.redMul(s.redISub(a).redSqr());return this.curve.point(o,h)},o.prototype.mul=function(t){for(var e=t.clone(),r=this,i=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.andln(1));for(var s=n.length-1;s>=0;s--)0===n[s]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},o.prototype.mulAdd=function(){throw new Error('Not supported on Montgomery curve')},o.prototype.jumlAdd=function(){throw new Error('Not supported on Montgomery curve')},o.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},o.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},o.prototype.getX=function(){return this.normalize(),this.x.fromRed()}})),Sr=P(((t,e)=>{var r=_r(),i=vr(),n=z(),s=wr(),a=r.assert;function o(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,s.call(this,'edwards',t),this.a=new i(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function h(t,e,r,n,a){s.BasePoint.call(this,t,'projective'),null===e&&null===r&&null===n?(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 i(e,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=a&&new i(a,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()))))}n(o,s),e.exports=o,o.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},o.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},o.prototype.jpoint=function(t,e,r,i){return this.point(t,e,r,i)},o.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=n.redMul(s.redInvm()),o=a.redSqrt();if(0!==o.redSqr().redSub(a).cmp(this.zero))throw new Error('invalid point');var h=o.fromRed().isOdd();return(e&&!h||!e&&h)&&(o=o.redNeg()),this.point(t,o)},o.prototype.pointFromY=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=r.redSub(this.c2),s=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=n.redMul(s.redInvm());if(0===a.cmp(this.zero)){if(e)throw new Error('invalid point');return this.point(this.zero,t)}var o=a.redSqrt();if(0!==o.redSqr().redSub(a).cmp(this.zero))throw new Error('invalid point');return o.fromRed().isOdd()!==e&&(o=o.redNeg()),this.point(o,t)},o.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),i=e.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===i.cmp(n)},n(h,s.BasePoint),o.prototype.pointFromJSON=function(t){return h.fromJSON(this,t)},o.prototype.point=function(t,e,r,i){return new h(this,t,e,r,i)},h.fromJSON=function(t,e){return new h(t,e[0],e[1],e[2])},h.prototype.inspect=function(){return this.isInfinity()?'':''},h.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},h.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=i.redAdd(e),a=s.redSub(r),o=i.redSub(e),h=n.redMul(a),l=s.redMul(o),c=n.redMul(o),u=a.redMul(s);return this.curve.point(h,l,u,c)},h.prototype._projDbl=function(){var t,e,r,i,n,s,a=this.x.redAdd(this.y).redSqr(),o=this.x.redSqr(),h=this.y.redSqr();if(this.curve.twisted){var l=(i=this.curve._mulA(o)).redAdd(h);this.zOne?(t=a.redSub(o).redSub(h).redMul(l.redSub(this.curve.two)),e=l.redMul(i.redSub(h)),r=l.redSqr().redSub(l).redSub(l)):(n=this.z.redSqr(),s=l.redSub(n).redISub(n),t=a.redSub(o).redISub(h).redMul(s),e=l.redMul(i.redSub(h)),r=l.redMul(s))}else i=o.redAdd(h),n=this.curve._mulC(this.z).redSqr(),s=i.redSub(n).redSub(n),t=this.curve._mulC(a.redISub(i)).redMul(s),e=this.curve._mulC(i).redMul(o.redISub(h)),r=i.redMul(s);return this.curve.point(t,e,r)},h.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},h.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(e),a=n.redSub(i),o=n.redAdd(i),h=r.redAdd(e),l=s.redMul(a),c=o.redMul(h),u=s.redMul(h),d=a.redMul(o);return this.curve.point(l,c,d,u)},h.prototype._projAdd=function(t){var e,r,i=this.z.redMul(t.z),n=i.redSqr(),s=this.x.redMul(t.x),a=this.y.redMul(t.y),o=this.curve.d.redMul(s).redMul(a),h=n.redSub(o),l=n.redAdd(o),c=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(a),u=i.redMul(h).redMul(c);return this.curve.twisted?(e=i.redMul(l).redMul(a.redSub(this.curve._mulA(s))),r=h.redMul(l)):(e=i.redMul(l).redMul(a.redSub(s)),r=this.curve._mulC(h).redMul(l)),this.curve.point(u,e,r)},h.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},h.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},h.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},h.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},h.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},h.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},h.prototype.getX=function(){return this.normalize(),this.x.fromRed()},h.prototype.getY=function(){return this.normalize(),this.y.fromRed()},h.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},h.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(i),0===this.x.cmp(e))return!0}},h.prototype.toP=h.prototype.normalize,h.prototype.mixedAdd=h.prototype.add})),Tr=P((t=>{var e=t;e.base=wr(),e.short=Er(),e.mont=Ar(),e.edwards=Sr()})),Mr=P((t=>{var e=ge(),r=z();function i(t,e){return!(55296!=(64512&t.charCodeAt(e))||e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1))}function n(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function s(t){return 1===t.length?'0'+t:t}function a(t){return 7===t.length?'0'+t:6===t.length?'00'+t:5===t.length?'000'+t:4===t.length?'0000'+t:3===t.length?'00000'+t:2===t.length?'000000'+t:1===t.length?'0000000'+t:t}t.inherits=r,t.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if('string'==typeof t)if(e){if('hex'===e)for((t=t.replace(/[^a-z0-9]+/gi,'')).length%2!=0&&(t='0'+t),s=0;s>6|192,r[n++]=63&a|128):i(t,s)?(a=65536+((1023&a)<<10)+(1023&t.charCodeAt(++s)),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}else for(s=0;s>>0}return a},t.split32=function(t,e){for(var r=new Array(4*t.length),i=0,n=0;i>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=255&s):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=255&s)}return r},t.rotr32=function(t,e){return t>>>e|t<<32-e},t.rotl32=function(t,e){return t<>>32-e},t.sum32=function(t,e){return t+e>>>0},t.sum32_3=function(t,e,r){return t+e+r>>>0},t.sum32_4=function(t,e,r,i){return t+e+r+i>>>0},t.sum32_5=function(t,e,r,i,n){return t+e+r+i+n>>>0},t.sum64=function(t,e,r,i){var n=t[e],s=i+t[e+1]>>>0,a=(s>>0,t[e+1]=s},t.sum64_hi=function(t,e,r,i){return(e+i>>>0>>0},t.sum64_lo=function(t,e,r,i){return e+i>>>0},t.sum64_4_hi=function(t,e,r,i,n,s,a,o){var h=0,l=e;return h+=(l=l+i>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(t,e,r,i,n,s,a,o){return e+i+s+o>>>0},t.sum64_5_hi=function(t,e,r,i,n,s,a,o,h,l){var c=0,u=e;return c+=(u=u+i>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(t,e,r,i,n,s,a,o,h,l){return e+i+s+o+l>>>0},t.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},t.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},t.shr64_hi=function(t,e,r){return t>>>r},t.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}})),Ir=P((t=>{var e=Mr(),r=ge();function i(){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}t.BlockHash=i,i.prototype.update=function(t,r){if(t=e.toArray(t,r),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var i=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-i,t.length),0===this.pending.length&&(this.pending=null),t=e.join32(t,0,t.length-i,this.endian);for(var n=0;n>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s{var e=Mr().rotr32;function r(t,e,r){return t&e^~t&r}function i(t,e,r){return t&e^t&r^e&r}function n(t,e,r){return t^e^r}t.ft_1=function(t,e,s,a){return 0===t?r(e,s,a):1===t||3===t?n(e,s,a):2===t?i(e,s,a):void 0},t.ch32=r,t.maj32=i,t.p32=n,t.s0_256=function(t){return e(t,2)^e(t,13)^e(t,22)},t.s1_256=function(t){return e(t,6)^e(t,11)^e(t,25)},t.g0_256=function(t){return e(t,7)^e(t,18)^t>>>3},t.g1_256=function(t){return e(t,17)^e(t,19)^t>>>10}})),Or=P(((t,e)=>{var r=Mr(),i=Ir(),n=Cr(),s=r.rotl32,a=r.sum32,o=r.sum32_5,h=n.ft_1,l=i.BlockHash,c=[1518500249,1859775393,2400959708,3395469782];function u(){if(!(this instanceof u))return new u;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(u,l),e.exports=u,u.blockSize=512,u.outSize=160,u.hmacStrength=80,u.padLength=64,u.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i{var r=Mr(),i=Ir(),n=Cr(),s=ge(),a=r.sum32,o=r.sum32_4,h=r.sum32_5,l=n.ch32,c=n.maj32,u=n.s0_256,d=n.s1_256,f=n.g0_256,p=n.g1_256,m=i.BlockHash,g=[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 y(){if(!(this instanceof y))return new y;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(y,m),e.exports=y,y.blockSize=512,y.outSize=256,y.hmacStrength=192,y.padLength=64,y.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i{var r=Mr(),i=Nr();function n(){if(!(this instanceof n))return new n;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}r.inherits(n,i),e.exports=n,n.blockSize=512,n.outSize=224,n.hmacStrength=192,n.padLength=64,n.prototype._digest=function(t){return'hex'===t?r.toHex32(this.h.slice(0,7),'big'):r.split32(this.h.slice(0,7),'big')}})),Rr=P(((t,e)=>{var r=Mr(),i=Ir(),n=ge(),s=r.rotr64_hi,a=r.rotr64_lo,o=r.shr64_hi,h=r.shr64_lo,l=r.sum64,c=r.sum64_hi,u=r.sum64_lo,d=r.sum64_4_hi,f=r.sum64_4_lo,p=r.sum64_5_hi,m=r.sum64_5_lo,g=i.BlockHash,y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=y,this.W=new Array(160)}function b(t,e,r,i,n){var s=t&r^~t&n;return s<0&&(s+=4294967296),s}function _(t,e,r,i,n,s){var a=e&i^~e&s;return a<0&&(a+=4294967296),a}function w(t,e,r,i,n){var s=t&r^t&n^r&n;return s<0&&(s+=4294967296),s}function E(t,e,r,i,n,s){var a=e&i^e&s^i&s;return a<0&&(a+=4294967296),a}function A(t,e){var r=s(t,e,28)^s(e,t,2)^s(e,t,7);return r<0&&(r+=4294967296),r}function S(t,e){var r=a(t,e,28)^a(e,t,2)^a(e,t,7);return r<0&&(r+=4294967296),r}function T(t,e){var r=s(t,e,14)^s(t,e,18)^s(e,t,9);return r<0&&(r+=4294967296),r}function M(t,e){var r=a(t,e,14)^a(t,e,18)^a(e,t,9);return r<0&&(r+=4294967296),r}function I(t,e){var r=s(t,e,1)^s(t,e,8)^o(t,e,7);return r<0&&(r+=4294967296),r}function C(t,e){var r=a(t,e,1)^a(t,e,8)^h(t,e,7);return r<0&&(r+=4294967296),r}function O(t,e){var r=s(t,e,19)^s(e,t,29)^o(t,e,6);return r<0&&(r+=4294967296),r}function N(t,e){var r=a(t,e,19)^a(e,t,29)^h(t,e,6);return r<0&&(r+=4294967296),r}r.inherits(v,g),e.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i{var r=Mr(),i=Rr();function n(){if(!(this instanceof n))return new n;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}r.inherits(n,i),e.exports=n,n.blockSize=1024,n.outSize=384,n.hmacStrength=192,n.padLength=128,n.prototype._digest=function(t){return'hex'===t?r.toHex32(this.h.slice(0,12),'big'):r.split32(this.h.slice(0,12),'big')}})),Br=P((t=>{t.sha1=Or(),t.sha224=Lr(),t.sha256=Nr(),t.sha384=Pr(),t.sha512=Rr()})),kr=P((t=>{var e=Mr(),r=Ir(),i=e.rotl32,n=e.sum32,s=e.sum32_3,a=e.sum32_4,o=r.BlockHash;function h(){if(!(this instanceof h))return new h;o.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian='little'}function l(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function c(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function u(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}e.inherits(h,o),t.ripemd160=h,h.blockSize=512,h.outSize=160,h.hmacStrength=192,h.padLength=64,h.prototype._update=function(t,e){for(var r=this.h[0],o=this.h[1],h=this.h[2],g=this.h[3],y=this.h[4],v=r,b=o,_=h,w=g,E=y,A=0;A<80;A++){var S=n(i(a(r,l(A,o,h,g),t[d[A]+e],c(A)),p[A]),y);r=y,y=g,g=i(h,10),h=o,o=S,S=n(i(a(v,l(79-A,b,_,w),t[f[A]+e],u(A)),m[A]),E),v=E,E=w,w=i(_,10),_=b,b=S}S=s(this.h[1],h,w),this.h[1]=s(this.h[2],g,E),this.h[2]=s(this.h[3],y,v),this.h[3]=s(this.h[4],r,b),this.h[4]=s(this.h[0],o,_),this.h[0]=S},h.prototype._digest=function(t){return'hex'===t?e.toHex32(this.h,'little'):e.split32(this.h,'little')};var d=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],f=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],p=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],m=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]})),Dr=P(((t,e)=>{var r=Mr(),i=ge();function n(t,e,i){if(!(this instanceof n))return new n(t,e,i);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(e,i))}e.exports=n,n.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e{var e=t;e.utils=Mr(),e.common=Ir(),e.sha=Br(),e.ripemd=kr(),e.hmac=Dr(),e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160})),xr=P(((t,e)=>{e.exports={doubles:{step:4,points:[['e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a','f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821'],['8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508','11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf'],['175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739','d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695'],['363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640','4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9'],['8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c','4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36'],['723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda','96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f'],['eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa','5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999'],['100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0','cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09'],['e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d','9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d'],['feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d','e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088'],['da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1','9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d'],['53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0','5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8'],['8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047','10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a'],['385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862','283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453'],['6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7','7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160'],['3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd','56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0'],['85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83','7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6'],['948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a','53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589'],['6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8','bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17'],['e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d','4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda'],['e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725','7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd'],['213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754','4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2'],['4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c','17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6'],['fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6','6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f'],['76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39','c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01'],['c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891','893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3'],['d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b','febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f'],['b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03','2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7'],['e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d','eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78'],['a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070','7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1'],['90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4','e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150'],['8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da','662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82'],['e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11','1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc'],['8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e','efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b'],['e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41','2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51'],['b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef','67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45'],['d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8','db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120'],['324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d','648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84'],['4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96','35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d'],['9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd','ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d'],['6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5','9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8'],['a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266','40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8'],['7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71','34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac'],['928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac','c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f'],['85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751','1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962'],['ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e','493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907'],['827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241','c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec'],['eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3','be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d'],['e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f','4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414'],['1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19','aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd'],['146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be','b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0'],['fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9','6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811'],['da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2','8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1'],['a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13','7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c'],['174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c','ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73'],['959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba','2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd'],['d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151','e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405'],['64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073','d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589'],['8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458','38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e'],['13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b','69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27'],['bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366','d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1'],['8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa','40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482'],['8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0','620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945'],['dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787','7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573'],['f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e','ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82']]},naf:{wnd:7,points:[['f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9','388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672'],['2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4','d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6'],['5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc','6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da'],['acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe','cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37'],['774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb','d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b'],['f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8','ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81'],['d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e','581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58'],['defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34','4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77'],['2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c','85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a'],['352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5','321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c'],['2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f','2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67'],['9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714','73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402'],['daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729','a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55'],['c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db','2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482'],['6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4','e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82'],['1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5','b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396'],['605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479','2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49'],['62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d','80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf'],['80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f','1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a'],['7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb','d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7'],['d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9','eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933'],['49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963','758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a'],['77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74','958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6'],['f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530','e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37'],['463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b','5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e'],['f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247','cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6'],['caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1','cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476'],['2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120','4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40'],['7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435','91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61'],['754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18','673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683'],['e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8','59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5'],['186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb','3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b'],['df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f','55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417'],['5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143','efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868'],['290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba','e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a'],['af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45','f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6'],['766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a','744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996'],['59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e','c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e'],['f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8','e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d'],['7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c','30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2'],['948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519','e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e'],['7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab','100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437'],['3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca','ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311'],['d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf','8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4'],['1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610','68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575'],['733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4','f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d'],['15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c','d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d'],['a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940','edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629'],['e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980','a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06'],['311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3','66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374'],['34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf','9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee'],['f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63','4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1'],['d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448','fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b'],['32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf','5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661'],['7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5','8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6'],['ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6','8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e'],['16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5','5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d'],['eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99','f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc'],['78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51','f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4'],['494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5','42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c'],['a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5','204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b'],['c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997','4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913'],['841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881','73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154'],['5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5','39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865'],['36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66','d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc'],['336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726','ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224'],['8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede','6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e'],['1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94','60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6'],['85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31','3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511'],['29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51','b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b'],['a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252','ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2'],['4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5','cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c'],['d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b','6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3'],['ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4','322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d'],['af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f','6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700'],['e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889','2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4'],['591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246','b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196'],['11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984','998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4'],['3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a','b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257'],['cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030','bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13'],['c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197','6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096'],['c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593','c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38'],['a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef','21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f'],['347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38','60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448'],['da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a','49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a'],['c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111','5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4'],['4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502','7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437'],['3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea','be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7'],['cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26','8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d'],['b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986','39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a'],['d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e','62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54'],['48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4','25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77'],['dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda','ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517'],['6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859','cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10'],['e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f','f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125'],['eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c','6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e'],['13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942','fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1'],['ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a','1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2'],['b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80','5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423'],['ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d','438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8'],['8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1','cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758'],['52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63','c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375'],['e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352','6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d'],['7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193','ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec'],['5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00','9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0'],['32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58','ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c'],['e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7','d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4'],['8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8','c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f'],['4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e','67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649'],['3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d','cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826'],['674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b','299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5'],['d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f','f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87'],['30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6','462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b'],['be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297','62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc'],['93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a','7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c'],['b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c','ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f'],['d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52','4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a'],['d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb','bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46'],['463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065','bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f'],['7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917','603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03'],['74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9','cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08'],['30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3','553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8'],['9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57','712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373'],['176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66','ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3'],['75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8','9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8'],['809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721','9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1'],['1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180','4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9']]}}})),Fr=P((t=>{var e,r=t,i=Ur(),n=Tr(),s=_r().assert;function a(t){'short'===t.type?this.curve=new n.short(t):'edwards'===t.type?this.curve=new n.edwards(t):this.curve=new n.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,s(this.g.validate(),'Invalid curve'),s(this.g.mul(this.n).isInfinity(),'Invalid curve, G*N != O')}function o(t,e){Object.defineProperty(r,t,{configurable:!0,enumerable:!0,get:function(){var i=new a(e);return Object.defineProperty(r,t,{configurable:!0,enumerable:!0,value:i}),i}})}r.PresetCurve=a,o('p192',{type:'short',prime:'p192',p:'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff',a:'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc',b:'64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1',n:'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831',hash:i.sha256,gRed:!1,g:['188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012','07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811']}),o('p224',{type:'short',prime:'p224',p:'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001',a:'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe',b:'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4',n:'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d',hash:i.sha256,gRed:!1,g:['b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21','bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34']}),o('p256',{type:'short',prime:null,p:'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff',a:'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc',b:'5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b',n:'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551',hash:i.sha256,gRed:!1,g:['6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296','4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5']}),o('p384',{type:'short',prime:null,p:'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff',a:'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc',b:'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef',n:'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973',hash:i.sha384,gRed:!1,g:['aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7','3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f']}),o('p521',{type:'short',prime:null,p:'000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff',a:'000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc',b:'00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00',n:'000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409',hash:i.sha512,gRed:!1,g:['000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66','00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650']}),o('curve25519',{type:'mont',prime:'p25519',p:'7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',a:'76d06',b:'1',n:'1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',hash:i.sha256,gRed:!1,g:['9']}),o('ed25519',{type:'edwards',prime:'p25519',p:'7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed',a:'-1',c:'1',d:'52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3',n:'1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed',hash:i.sha256,gRed:!1,g:['216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a','6666666666666666666666666666666666666666666666666666666666666658']});try{e=xr()}catch{e=void 0}o('secp256k1',{type:'short',prime:'k256',p:'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',a:'0',b:'7',n:'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141',h:'1',hash:i.sha256,beta:'7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee',lambda:'5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72',basis:[{a:'3086d221a7d46bcde86c90e49284eb15',b:'-e4437ed6010e88286f547fa90abfe4c3'},{a:'114ca50f7a8e2f3f657c1108d9d44cfd8',b:'3086d221a7d46bcde86c90e49284eb15'}],gRed:!1,g:['79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798','483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',e]})})),Hr=P(((t,e)=>{var r=Ur(),i=br(),n=ge();function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||'hex'),r=i.toArray(t.nonce,t.nonceEnc||'hex'),a=i.toArray(t.pers,t.persEnc||'hex');n(e.length>=this.minEntropy/8,'Not enough entropy. Minimum is: '+this.minEntropy+' bits'),this._init(e,r,a)}e.exports=s,s.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,'Not enough entropy. Minimum is: '+this.minEntropy+' bits'),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error('Reseed is required');'string'!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||'hex'),this._update(r));for(var s=[];s.length{var r=vr(),i=_r().assert;function n(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=n,n.fromPublic=function(t,e,r){return e instanceof n?e:new n(t,{pub:e,pubEnc:r})},n.fromPrivate=function(t,e,r){return e instanceof n?e:new n(t,{priv:e,privEnc:r})},n.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:'Invalid public key'}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:'Public key * N != O'}:{result:!1,reason:'Public key is not a point'}},n.prototype.getPublic=function(t,e){return'string'==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},n.prototype.getPrivate=function(t){return'hex'===t?this.priv.toString(16,2):this.priv},n.prototype._importPrivate=function(t,e){this.priv=new r(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},n.prototype._importPublic=function(t,e){if(t.x||t.y)return'mont'===this.ec.curve.type?i(t.x,'Need x coordinate'):('short'===this.ec.curve.type||'edwards'===this.ec.curve.type)&&i(t.x&&t.y,'Need both x and y coordinate'),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},n.prototype.derive=function(t){return t.validate()||i(t.validate(),'public point not validated'),t.mul(this.priv).getX()},n.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},n.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},n.prototype.inspect=function(){return''}})),Vr=P(((t,e)=>{var r=vr(),i=_r(),n=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(n(t.r&&t.s,'Signature without r or s'),this.r=new r(t.r,16),this.s=new r(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(){this.place=0}function o(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,s=0,a=e.place;s>>=0;return!(n<=127)&&(e.place=a,n)}function h(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var n=new a;if(48!==t[n.place++])return!1;var s=o(t,n);if(!1===s||s+n.place!==t.length||2!==t[n.place++])return!1;var h=o(t,n);if(!1===h)return!1;var l=t.slice(n.place,h+n.place);if(n.place+=h,2!==t[n.place++])return!1;var c=o(t,n);if(!1===c||t.length!==c+n.place)return!1;var u=t.slice(n.place,c+n.place);if(0===l[0]){if(!(128&l[1]))return!1;l=l.slice(1)}if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}return this.r=new r(l),this.s=new r(u),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=h(e),r=h(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];l(n,e.length),(n=n.concat(e)).push(2),l(n,r.length);var s=n.concat(r),a=[48];return l(a,s.length),a=a.concat(s),i.encode(a,t)}})),Gr=P(((t,e)=>{var r=vr(),i=Hr(),n=_r(),s=Fr(),a=Ye(),o=n.assert,h=jr(),l=Vr();function c(t){if(!(this instanceof c))return new c(t);'string'==typeof t&&(o(Object.prototype.hasOwnProperty.call(s,t),'Unknown curve '+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=c,c.prototype.keyPair=function(t){return new h(this,t)},c.prototype.keyFromPrivate=function(t,e){return h.fromPrivate(this,t,e)},c.prototype.keyFromPublic=function(t,e){return h.fromPublic(this,t,e)},c.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||'utf8',entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||'utf8',nonce:this.n.toArray()}),n=this.n.byteLength(),s=this.n.sub(new r(2));;){var o=new r(e.generate(n));if(!(o.cmp(s)>0))return o.iaddn(1),this.keyFromPrivate(o)}},c.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},c.prototype.sign=function(t,e,n,s){'object'==typeof n&&(s=n,n=null),s||(s={}),e=this.keyFromPrivate(e,n),t=this._truncateToN(new r(t,16));for(var a=this.n.byteLength(),o=e.getPrivate().toArray('be',a),h=t.toArray('be',a),c=new i({hash:this.hash,entropy:o,nonce:h,pers:s.pers,persEnc:s.persEnc||'utf8'}),u=this.n.sub(new r(1)),d=0;;d++){var f=s.k?s.k(d):new r(c.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(u)>=0)){var p=this.g.mul(f);if(!p.isInfinity()){var m=p.getX(),g=m.umod(this.n);if(0!==g.cmpn(0)){var y=f.invm(this.n).mul(g.mul(e.getPrivate()).iadd(t));if(0!==(y=y.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==m.cmp(g)?2:0);return s.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y),v^=1),new l({r:g,s:y,recoveryParam:v})}}}}}},c.prototype.verify=function(t,e,i,n){t=this._truncateToN(new r(t,16)),i=this.keyFromPublic(i,n),e=new l(e,'hex');var{r:s,s:a}=e;if(s.cmpn(1)<0||s.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var o,h=a.invm(this.n),c=h.mul(t).umod(this.n),u=h.mul(s).umod(this.n);return this.curve._maxwellTrick?!(o=this.g.jmulAdd(c,i.getPublic(),u)).isInfinity()&&o.eqXToP(s):!(o=this.g.mulAdd(c,i.getPublic(),u)).isInfinity()&&0===o.getX().umod(this.n).cmp(s)},c.prototype.recoverPubKey=function(t,e,i,n){o((3&i)===i,'The recovery param is more than two bits'),e=new l(e,n);var s=this.n,a=new r(t),h=e.r,c=e.s,u=1&i,d=i>>1;if(h.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error('Unable to find sencond key candinate');h=d?this.curve.pointFromX(h.add(this.curve.n),u):this.curve.pointFromX(h,u);var f=e.r.invm(s),p=s.sub(a).mul(f).umod(s),m=c.mul(f).umod(s);return this.g.mulAdd(p,h,m)},c.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new l(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(t,e,n)}catch{continue}if(s.eq(r))return n}throw new Error('Unable to find valid recovery factor')}})),zr=P(((t,e)=>{var r=_r(),i=r.assert,n=r.parseBytes,s=r.cachedProperty;function a(t,e){this.eddsa=t,this._secret=n(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=n(e.pub)}a.fromPublic=function(t,e){return e instanceof a?e:new a(t,{pub:e})},a.fromSecret=function(t,e){return e instanceof a?e:new a(t,{secret:e})},a.prototype.secret=function(){return this._secret},s(a,'pubBytes',(function(){return this.eddsa.encodePoint(this.pub())})),s(a,'pub',(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),s(a,'privBytes',(function(){var t=this.eddsa,e=this.hash(),r=t.encodingLength-1,i=e.slice(0,t.encodingLength);return i[0]&=248,i[r]&=127,i[r]|=64,i})),s(a,'priv',(function(){return this.eddsa.decodeInt(this.privBytes())})),s(a,'hash',(function(){return this.eddsa.hash().update(this.secret()).digest()})),s(a,'messagePrefix',(function(){return this.hash().slice(this.eddsa.encodingLength)})),a.prototype.sign=function(t){return i(this._secret,'KeyPair can only verify'),this.eddsa.sign(t,this)},a.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},a.prototype.getSecret=function(t){return i(this._secret,'KeyPair is public only'),r.encode(this.secret(),t)},a.prototype.getPublic=function(t){return r.encode(this.pubBytes(),t)},e.exports=a})),Wr=P(((t,e)=>{var r=vr(),i=_r(),n=i.assert,s=i.cachedProperty,a=i.parseBytes;function o(t,e){this.eddsa=t,'object'!=typeof e&&(e=a(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),n(e.R&&e.S,'Signature without R or S'),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof r&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}s(o,'S',(function(){return this.eddsa.decodeInt(this.Sencoded())})),s(o,'R',(function(){return this.eddsa.decodePoint(this.Rencoded())})),s(o,'Rencoded',(function(){return this.eddsa.encodePoint(this.R())})),s(o,'Sencoded',(function(){return this.eddsa.encodeInt(this.S())})),o.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},o.prototype.toHex=function(){return i.encode(this.toBytes(),'hex').toUpperCase()},e.exports=o})),Kr=P(((t,e)=>{var r=Ur(),i=Fr(),n=_r(),s=n.assert,a=n.parseBytes,o=zr(),h=Wr();function l(t){if(s('ed25519'===t,'only tested with ed25519 so far'),!(this instanceof l))return new l(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=r.sha512}e.exports=l,l.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),i=this.hashInt(r.messagePrefix(),t),n=this.g.mul(i),s=this.encodePoint(n),o=this.hashInt(s,r.pubBytes(),t).mul(r.priv()),h=i.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:h,Rencoded:s})},l.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var i=this.keyFromPublic(r),n=this.hashInt(e.Rencoded(),i.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(i.pub().mul(n)).eq(s)},l.prototype.hashInt=function(){for(var t=this.hash(),e=0;e{var e=t;e.version=yr().version,e.utils=_r(),e.rand=Ye(),e.curve=Tr(),e.curves=Fr(),e.ec=Gr(),e.eddsa=Kr()})),Yr=P(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var s;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{s=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:ze().Buffer}catch{}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function o(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,s=Math.min(t.length,r),a=e;a=49?o-49+10:o>=17?o-17+10:o}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=a<>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);else if('le'===i)for(n=0,s=0;n>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=o(t,e,i)<=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,a=s%i,o=Math.min(s,s-a)+r,l=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?''};var l=['','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'],c=[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],u=[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 d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],a=n*s,o=67108863&a,h=a/67108864|0;r.words[0]=o;for(var l=1;l>>26,u=67108863&h,d=Math.min(l,e.length-1),f=Math.max(0,l-t.length+1);f<=d;f++){var p=l-f|0;c+=(a=(n=0|t.words[p])*(s=0|e.words[f])+u)/67108864|0,u=67108863&a}r.words[l]=0|u,h=0|c}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,s=0,a=0;a>>24-n&16777215)||a!==this.length-1?l[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,a--)}for(0!==s&&(i=s.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var d=c[t],f=u[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(f).toString(t);i=(p=p.idivn(f)).isZero()?m+i:l[d-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof s<'u'),this.toArrayLike(s,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),s=i||Math.max(1,n);r(n<=s,'byte array longer than desired length'),r(s>0,'Requested array length <= 0'),this.strip();var a,o,h='le'===e,l=new t(s),c=this.clone();if(h){for(o=0;!c.isZero();o++)a=c.andln(255),c.iushrn(8),l[o]=a;for(;o=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,a=0;a>26,this.words[a]=67108863&e;for(;0!==s&&a>26,this.words[a]=67108863&e;if(0===s&&a>>13,f=0|a[1],p=8191&f,m=f>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],_=8191&b,w=b>>>13,E=0|a[4],A=8191&E,S=E>>>13,T=0|a[5],M=8191&T,I=T>>>13,C=0|a[6],O=8191&C,N=C>>>13,L=0|a[7],R=8191&L,P=L>>>13,B=0|a[8],k=8191&B,D=B>>>13,U=0|a[9],x=8191&U,F=U>>>13,H=0|o[0],j=8191&H,V=H>>>13,G=0|o[1],z=8191&G,W=G>>>13,K=0|o[2],q=8191&K,Y=K>>>13,Z=0|o[3],$=8191&Z,X=Z>>>13,Q=0|o[4],J=8191&Q,tt=Q>>>13,et=0|o[5],rt=8191&et,it=et>>>13,nt=0|o[6],st=8191&nt,at=nt>>>13,ot=0|o[7],ht=8191&ot,lt=ot>>>13,ct=0|o[8],ut=8191&ct,dt=ct>>>13,ft=0|o[9],pt=8191&ft,mt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(i=Math.imul(u,j))|0)+((8191&(n=(n=Math.imul(u,V))+Math.imul(d,j)|0))<<13)|0;l=((s=Math.imul(d,V))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,j),n=(n=Math.imul(p,V))+Math.imul(m,j)|0,s=Math.imul(m,V);var yt=(l+(i=i+Math.imul(u,z)|0)|0)+((8191&(n=(n=n+Math.imul(u,W)|0)+Math.imul(d,z)|0))<<13)|0;l=((s=s+Math.imul(d,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,j),n=(n=Math.imul(y,V))+Math.imul(v,j)|0,s=Math.imul(v,V),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,z)|0,s=s+Math.imul(m,W)|0;var vt=(l+(i=i+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,Y)|0)+Math.imul(d,q)|0))<<13)|0;l=((s=s+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,j),n=(n=Math.imul(_,V))+Math.imul(w,j)|0,s=Math.imul(w,V),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(v,z)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,q)|0,s=s+Math.imul(m,Y)|0;var bt=(l+(i=i+Math.imul(u,$)|0)|0)+((8191&(n=(n=n+Math.imul(u,X)|0)+Math.imul(d,$)|0))<<13)|0;l=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(A,j),n=(n=Math.imul(A,V))+Math.imul(S,j)|0,s=Math.imul(S,V),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,z)|0,s=s+Math.imul(w,W)|0,i=i+Math.imul(y,q)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(v,q)|0,s=s+Math.imul(v,Y)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,$)|0,s=s+Math.imul(m,X)|0;var _t=(l+(i=i+Math.imul(u,J)|0)|0)+((8191&(n=(n=n+Math.imul(u,tt)|0)+Math.imul(d,J)|0))<<13)|0;l=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(M,j),n=(n=Math.imul(M,V))+Math.imul(I,j)|0,s=Math.imul(I,V),i=i+Math.imul(A,z)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(S,z)|0,s=s+Math.imul(S,W)|0,i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(w,q)|0,s=s+Math.imul(w,Y)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(v,$)|0,s=s+Math.imul(v,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var wt=(l+(i=i+Math.imul(u,rt)|0)|0)+((8191&(n=(n=n+Math.imul(u,it)|0)+Math.imul(d,rt)|0))<<13)|0;l=((s=s+Math.imul(d,it)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(O,j),n=(n=Math.imul(O,V))+Math.imul(N,j)|0,s=Math.imul(N,V),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(I,z)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(A,q)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(S,q)|0,s=s+Math.imul(S,Y)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,X)|0)+Math.imul(w,$)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Et=(l+(i=i+Math.imul(u,st)|0)|0)+((8191&(n=(n=n+Math.imul(u,at)|0)+Math.imul(d,st)|0))<<13)|0;l=((s=s+Math.imul(d,at)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(R,j),n=(n=Math.imul(R,V))+Math.imul(P,j)|0,s=Math.imul(P,V),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(N,z)|0,s=s+Math.imul(N,W)|0,i=i+Math.imul(M,q)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,Y)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(S,$)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(_,J)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,at)|0;var At=(l+(i=i+Math.imul(u,ht)|0)|0)+((8191&(n=(n=n+Math.imul(u,lt)|0)+Math.imul(d,ht)|0))<<13)|0;l=((s=s+Math.imul(d,lt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(k,j),n=(n=Math.imul(k,V))+Math.imul(D,j)|0,s=Math.imul(D,V),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(P,z)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(O,q)|0,n=(n=n+Math.imul(O,Y)|0)+Math.imul(N,q)|0,s=s+Math.imul(N,Y)|0,i=i+Math.imul(M,$)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,at)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(i=i+Math.imul(u,ut)|0)|0)+((8191&(n=(n=n+Math.imul(u,dt)|0)+Math.imul(d,ut)|0))<<13)|0;l=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(x,j),n=(n=Math.imul(x,V))+Math.imul(F,j)|0,s=Math.imul(F,V),i=i+Math.imul(k,z)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(D,z)|0,s=s+Math.imul(D,W)|0,i=i+Math.imul(R,q)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,Y)|0,i=i+Math.imul(O,$)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(N,$)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(_,st)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,ut)|0,s=s+Math.imul(m,dt)|0;var Tt=(l+(i=i+Math.imul(u,pt)|0)|0)+((8191&(n=(n=n+Math.imul(u,mt)|0)+Math.imul(d,pt)|0))<<13)|0;l=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(x,z),n=(n=Math.imul(x,W))+Math.imul(F,z)|0,s=Math.imul(F,W),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,Y)|0)+Math.imul(D,q)|0,s=s+Math.imul(D,Y)|0,i=i+Math.imul(R,$)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(P,$)|0,s=s+Math.imul(P,X)|0,i=i+Math.imul(O,J)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(A,st)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,lt)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,lt)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(v,ut)|0,s=s+Math.imul(v,dt)|0;var Mt=(l+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(x,q),n=(n=Math.imul(x,Y))+Math.imul(F,q)|0,s=Math.imul(F,Y),i=i+Math.imul(k,$)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(D,$)|0,s=s+Math.imul(D,X)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(M,st)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,at)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(w,ut)|0,s=s+Math.imul(w,dt)|0;var It=(l+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(x,$),n=(n=Math.imul(x,X))+Math.imul(F,$)|0,s=Math.imul(F,X),i=i+Math.imul(k,J)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(O,st)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,at)|0,i=i+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,lt)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,lt)|0,i=i+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,dt)|0)+Math.imul(S,ut)|0,s=s+Math.imul(S,dt)|0;var Ct=(l+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,mt)|0)+Math.imul(w,pt)|0))<<13)|0;l=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(x,J),n=(n=Math.imul(x,tt))+Math.imul(F,J)|0,s=Math.imul(F,tt),i=i+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,it)|0)+Math.imul(D,rt)|0,s=s+Math.imul(D,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,at)|0,i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(I,ut)|0,s=s+Math.imul(I,dt)|0;var Ot=(l+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(x,rt),n=(n=Math.imul(x,it))+Math.imul(F,rt)|0,s=Math.imul(F,it),i=i+Math.imul(k,st)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,at)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(N,ut)|0,s=s+Math.imul(N,dt)|0;var Nt=(l+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(I,pt)|0))<<13)|0;l=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(x,st),n=(n=Math.imul(x,at))+Math.imul(F,st)|0,s=Math.imul(F,at),i=i+Math.imul(k,ht)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(D,ht)|0,s=s+Math.imul(D,lt)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ut)|0,s=s+Math.imul(P,dt)|0;var Lt=(l+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,i=Math.imul(x,ht),n=(n=Math.imul(x,lt))+Math.imul(F,ht)|0,s=Math.imul(F,lt),i=i+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,dt)|0)+Math.imul(D,ut)|0,s=s+Math.imul(D,dt)|0;var Rt=(l+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(x,ut),n=(n=Math.imul(x,dt))+Math.imul(F,ut)|0,s=Math.imul(F,dt);var Pt=(l+(i=i+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,mt)|0)+Math.imul(D,pt)|0))<<13)|0;l=((s=s+Math.imul(D,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var Bt=(l+(i=Math.imul(x,pt))|0)+((8191&(n=(n=Math.imul(x,mt))+Math.imul(F,pt)|0))<<13)|0;return l=((s=Math.imul(F,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=_t,h[5]=wt,h[6]=Et,h[7]=At,h[8]=St,h[9]=Tt,h[10]=Mt,h[11]=It,h[12]=Ct,h[13]=Ot,h[14]=Nt,h[15]=Lt,h[16]=Rt,h[17]=Pt,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(f=d),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?f(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,a&=67108863}r.words[s]=o,i=a,a=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,s){for(var a=0;a>>=1)n++;return 1<>>=13,i[2*a+1]=8191&s,s>>>=13;for(a=2*e;a>=26,e+=n/67108864|0,e+=s>>>26,this.words[i]=67108863&s}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,s=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var s=t%26,a=Math.min((t-s)/26,this.length),o=67108863^67108863>>>s<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=n);l--){var u=0|this.words[l];this.words[l]=c<<26-s|u>>>s,c=u&o}return h&&0!==c&&(h.words[h.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&a}for(;n>26,this.words[n+i]=67108863&a;if(0===o)return this.strip();for(r(-1===o),o=0,n=0;n>26,this.words[n]=67108863&a;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,a=0|s.words[s.length-1];0!==(r=26-this._countBits(a))&&(s=s.ushln(r),i.iushln(r),a=0|s.words[s.length-1]);var o,h=i.length-s.length;if('mod'!==e){(o=new n(null)).length=h+1,o.words=new Array(o.length);for(var l=0;l=0;u--){var d=67108864*(0|i.words[s.length+u])+(0|i.words[s.length+u-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(s,d,u);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(s,1,u),i.isZero()||(i.negative^=1);o&&(o.words[u]=d)}return o&&o.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),'mod'!==e&&(s=o.div.neg()),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:s,mod:a}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),'mod'!==e&&(s=o.div.neg()),{div:s,mod:o.mod}):this.negative&t.negative?(o=this.neg().divmod(t.neg(),e),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:o.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var s,a,o},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),a=new n(0),o=new n(0),h=new n(1),l=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++l;for(var c=i.clone(),u=e.clone();!e.isZero();){for(var d=0,f=1;!(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||a.isOdd())&&(s.iadd(c),a.isub(u)),s.iushrn(1),a.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(c),h.isub(u)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o),a.isub(h)):(i.isub(e),o.isub(s),h.isub(a))}return{a:o,b:h,gcd:i.iushln(l)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,s=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var a=new n(1),o=new n(0),h=s.clone();i.cmpn(1)>0&&s.cmpn(1)>0;){for(var l=0,c=1;!(i.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(i.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var u=0,d=1;!(s.words[0]&d)&&u<26;++u,d<<=1);if(u>0)for(s.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);i.cmp(s)>=0?(i.isub(s),a.isub(o)):(s.isub(i),o.isub(a))}return(e=0===i.cmpn(1)?a:o).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,o&=67108863,this.words[a]=o}return 0!==s&&(this.words[a]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function _(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function w(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function E(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=a}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new _;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new w}return g[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},E.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),a=0;!s.isZero()&&0===s.andln(1);)a++,s.iushrn(1);r(!s.isZero());var o=new n(1).toRed(this),h=o.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);0!==this.pow(c,l).cmp(h);)c.redIAdd(h);for(var u=this.pow(c,s),d=this.pow(t,s.addn(1).iushrn(1)),f=this.pow(t,s),p=a;0!==f.cmp(o);){for(var m=f,g=0;0!==m.cmp(o);g++)m=m.redSqr();r(g=0;i--){for(var l=e.words[i],c=h-1;c>=0;c--){var u=l>>c&1;(s!==r[0]&&(s=this.sqr(s)),0!==u||0!==a)?(a<<=1,a|=u,(4===++o||0===i&&0===c)&&(s=this.mul(s,r[a]),o=0,a=0)):o=0}h=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),Zr=P(((t,e)=>{var r,i=j(),n=i.Buffer,s={};for(r in i)!i.hasOwnProperty(r)||'SlowBuffer'===r||'Buffer'===r||(s[r]=i[r]);var a=s.Buffer={};for(r in n)!n.hasOwnProperty(r)||'allocUnsafe'===r||'allocUnsafeSlow'===r||(a[r]=n[r]);if(s.Buffer.prototype=n.prototype,(!a.from||a.from===Uint8Array.from)&&(a.from=function(t,e,r){if('number'==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&typeof t.length>'u')throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type '+typeof t);return n(t,e,r)}),a.alloc||(a.alloc=function(t,e,r){if('number'!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var i=n(t);return e&&0!==e.length?'string'==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i}),!s.kStringMaxLength)try{s.kStringMaxLength=process.binding('buffer').kStringMaxLength}catch{}s.constants||(s.constants={MAX_LENGTH:s.kMaxLength},s.kStringMaxLength&&(s.constants.MAX_STRING_LENGTH=s.kStringMaxLength)),e.exports=s})),$r=P((t=>{var e=z();function r(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]}}function i(t,e){this.path=t,this.rethrow(e)}t.Reporter=r,r.prototype.isError=function(t){return t instanceof i},r.prototype.save=function(){let t=this._reporterState;return{obj:t.obj,pathLen:t.path.length}},r.prototype.restore=function(t){let e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen)},r.prototype.enterKey=function(t){return this._reporterState.path.push(t)},r.prototype.exitKey=function(t){let e=this._reporterState;e.path=e.path.slice(0,t-1)},r.prototype.leaveKey=function(t,e,r){let i=this._reporterState;this.exitKey(t),null!==i.obj&&(i.obj[e]=r)},r.prototype.path=function(){return this._reporterState.path.join('/')},r.prototype.enterObject=function(){let t=this._reporterState,e=t.obj;return t.obj={},e},r.prototype.leaveObject=function(t){let e=this._reporterState,r=e.obj;return e.obj=t,r},r.prototype.error=function(t){let e,r=this._reporterState,n=t instanceof i;if(e=n?t:new i(r.path.map((function(t){return'['+JSON.stringify(t)+']'})).join(''),t.message||t,t.stack),!r.options.partial)throw e;return n||r.errors.push(e),e},r.prototype.wrapResult=function(t){let e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t},e(i,Error),i.prototype.rethrow=function(t){if(this.message=t+' at: '+(this.path||'(shallow)'),Error.captureStackTrace&&Error.captureStackTrace(this,i),!this.stack)try{throw new Error(this.message)}catch(t){this.stack=t.stack}return this}})),Xr=P((t=>{var e=z(),r=$r().Reporter,i=Zr().Buffer;function n(t,e){r.call(this,e),i.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error('Input not Buffer')}function s(t,e){if(Array.isArray(t))this.length=0,this.value=t.map((function(t){return s.isEncoderBuffer(t)||(t=new s(t,e)),this.length+=t.length,t}),this);else if('number'==typeof t){if(!(0<=t&&t<=255))return e.error('non-byte EncoderBuffer value');this.value=t,this.length=1}else if('string'==typeof t)this.value=t,this.length=i.byteLength(t);else{if(!i.isBuffer(t))return e.error('Unsupported type: '+typeof t);this.value=t,this.length=t.length}}e(n,r),t.DecoderBuffer=n,n.isDecoderBuffer=function(t){return t instanceof n||'object'==typeof t&&i.isBuffer(t.base)&&'DecoderBuffer'===t.constructor.name&&'number'==typeof t.offset&&'number'==typeof t.length&&'function'==typeof t.save&&'function'==typeof t.restore&&'function'==typeof t.isEmpty&&'function'==typeof t.readUInt8&&'function'==typeof t.skip&&'function'==typeof t.raw},n.prototype.save=function(){return{offset:this.offset,reporter:r.prototype.save.call(this)}},n.prototype.restore=function(t){let e=new n(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,r.prototype.restore.call(this,t.reporter),e},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||'DecoderBuffer overrun')},n.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||'DecoderBuffer overrun');let r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+t,this.offset+=t,r},n.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length)},t.EncoderBuffer=s,s.isEncoderBuffer=function(t){return t instanceof s||'object'==typeof t&&'EncoderBuffer'===t.constructor.name&&'number'==typeof t.length&&'function'==typeof t.join},s.prototype.join=function(t,e){return t||(t=i.alloc(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(t,e),e+=r.length})):('number'==typeof this.value?t[e]=this.value:'string'==typeof this.value?t.write(this.value,e):i.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t}})),Qr=P(((t,e)=>{var r=$r().Reporter,i=Xr().EncoderBuffer,n=Xr().DecoderBuffer,s=ge(),a=['seq','seqof','set','setof','objid','bool','gentime','utctime','null_','enum','int','objDesc','bitstr','bmpstr','charstr','genstr','graphstr','ia5str','iso646str','numstr','octstr','printstr','t61str','unistr','utf8str','videostr'],o=['key','obj','use','optional','explicit','implicit','def','choice','any','contains'].concat(a);function h(t,e,r){let i={};this._baseState=i,i.name=r,i.enc=t,i.parent=e||null,i.children=null,i.tag=null,i.args=null,i.reverseArgs=null,i.choice=null,i.optional=!1,i.any=!1,i.obj=!1,i.use=null,i.useDecoder=null,i.key=null,i.default=null,i.explicit=null,i.implicit=null,i.contains=null,i.parent||(i.children=[],this._wrap())}e.exports=h;var l=['enc','parent','children','tag','args','reverseArgs','choice','optional','any','obj','use','alteredUse','key','default','explicit','implicit','contains'];h.prototype.clone=function(){let t=this._baseState,e={};l.forEach((function(r){e[r]=t[r]}));let r=new this.constructor(e.parent);return r._baseState=e,r},h.prototype._wrap=function(){let t=this._baseState;o.forEach((function(e){this[e]=function(){let r=new this.constructor(this);return t.children.push(r),r[e].apply(r,arguments)}}),this)},h.prototype._init=function(t){let e=this._baseState;s(null===e.parent),t.call(this),e.children=e.children.filter((function(t){return t._baseState.parent===this}),this),s.equal(e.children.length,1,'Root node can have only one child')},h.prototype._useArgs=function(t){let e=this._baseState,r=t.filter((function(t){return t instanceof this.constructor}),this);t=t.filter((function(t){return!(t instanceof this.constructor)}),this),0!==r.length&&(s(null===e.children),e.children=r,r.forEach((function(t){t._baseState.parent=this}),this)),0!==t.length&&(s(null===e.args),e.args=t,e.reverseArgs=t.map((function(t){if('object'!=typeof t||t.constructor!==Object)return t;let e={};return Object.keys(t).forEach((function(r){r==(0|r)&&(r|=0);let i=t[r];e[i]=r})),e})))},['_peekTag','_decodeTag','_use','_decodeStr','_decodeObjid','_decodeTime','_decodeNull','_decodeInt','_decodeBool','_decodeList','_encodeComposite','_encodeStr','_encodeObjid','_encodeTime','_encodeNull','_encodeInt','_encodeBool'].forEach((function(t){h.prototype[t]=function(){let e=this._baseState;throw new Error(t+' not implemented for encoding: '+e.enc)}})),a.forEach((function(t){h.prototype[t]=function(){let e=this._baseState,r=Array.prototype.slice.call(arguments);return s(null===e.tag),e.tag=t,this._useArgs(r),this}})),h.prototype.use=function(t){s(t);let e=this._baseState;return s(null===e.use),e.use=t,this},h.prototype.optional=function(){return this._baseState.optional=!0,this},h.prototype.def=function(t){let e=this._baseState;return s(null===e.default),e.default=t,e.optional=!0,this},h.prototype.explicit=function(t){let e=this._baseState;return s(null===e.explicit&&null===e.implicit),e.explicit=t,this},h.prototype.implicit=function(t){let e=this._baseState;return s(null===e.explicit&&null===e.implicit),e.implicit=t,this},h.prototype.obj=function(){let t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this},h.prototype.key=function(t){let e=this._baseState;return s(null===e.key),e.key=t,this},h.prototype.any=function(){return this._baseState.any=!0,this},h.prototype.choice=function(t){let e=this._baseState;return s(null===e.choice),e.choice=t,this._useArgs(Object.keys(t).map((function(e){return t[e]}))),this},h.prototype.contains=function(t){let e=this._baseState;return s(null===e.use),e.contains=t,this},h.prototype._decode=function(t,e){let r=this._baseState;if(null===r.parent)return t.wrapResult(r.children[0]._decode(t,e));let i,s=r.default,a=!0,o=null;if(null!==r.key&&(o=t.enterKey(r.key)),r.optional){let i=null;if(null!==r.explicit?i=r.explicit:null!==r.implicit?i=r.implicit:null!==r.tag&&(i=r.tag),null!==i||r.any){if(a=this._peekTag(t,i,r.any),t.isError(a))return a}else{let i=t.save();try{null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e),a=!0}catch{a=!1}t.restore(i)}}if(r.obj&&a&&(i=t.enterObject()),a){if(null!==r.explicit){let e=this._decodeTag(t,r.explicit);if(t.isError(e))return e;t=e}let i=t.offset;if(null===r.use&&null===r.choice){let e;r.any&&(e=t.save());let i=this._decodeTag(t,null!==r.implicit?r.implicit:r.tag,r.any);if(t.isError(i))return i;r.any?s=t.raw(e):t=i}if(e&&e.track&&null!==r.tag&&e.track(t.path(),i,t.length,'tagged'),e&&e.track&&null!==r.tag&&e.track(t.path(),t.offset,t.length,'content'),r.any||(s=null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e)),t.isError(s))return s;if(!r.any&&null===r.choice&&null!==r.children&&r.children.forEach((function(r){r._decode(t,e)})),r.contains&&('octstr'===r.tag||'bitstr'===r.tag)){let i=new n(s);s=this._getUse(r.contains,t._reporterState.obj)._decode(i,e)}}return r.obj&&a&&(s=t.leaveObject(i)),null===r.key||null===s&&!0!==a?null!==o&&t.exitKey(o):t.leaveKey(o,r.key,s),s},h.prototype._decodeGeneric=function(t,e,r){let i=this._baseState;return'seq'===t||'set'===t?null:'seqof'===t||'setof'===t?this._decodeList(e,t,i.args[0],r):/str$/.test(t)?this._decodeStr(e,t,r):'objid'===t&&i.args?this._decodeObjid(e,i.args[0],i.args[1],r):'objid'===t?this._decodeObjid(e,null,null,r):'gentime'===t||'utctime'===t?this._decodeTime(e,t,r):'null_'===t?this._decodeNull(e,r):'bool'===t?this._decodeBool(e,r):'objDesc'===t?this._decodeStr(e,t,r):'int'===t||'enum'===t?this._decodeInt(e,i.args&&i.args[0],r):null!==i.use?this._getUse(i.use,e._reporterState.obj)._decode(e,r):e.error('unknown tag: '+t)},h.prototype._getUse=function(t,e){let r=this._baseState;return r.useDecoder=this._use(t,e),s(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},h.prototype._decodeChoice=function(t,e){let r=this._baseState,i=null,n=!1;return Object.keys(r.choice).some((function(s){let a=t.save(),o=r.choice[s];try{let r=o._decode(t,e);if(t.isError(r))return!1;i={type:s,value:r},n=!0}catch{return t.restore(a),!1}return!0}),this),n?i:t.error('Choice not matched')},h.prototype._createEncoderBuffer=function(t){return new i(t,this.reporter)},h.prototype._encode=function(t,e,r){let i=this._baseState;if(null!==i.default&&i.default===t)return;let n=this._encodeValue(t,e,r);return void 0===n||this._skipDefault(n,e,r)?void 0:n},h.prototype._encodeValue=function(t,e,i){let n=this._baseState;if(null===n.parent)return n.children[0]._encode(t,e||new r);let s=null;if(this.reporter=e,n.optional&&void 0===t){if(null===n.default)return;t=n.default}let a=null,o=!1;if(n.any)s=this._createEncoderBuffer(t);else if(n.choice)s=this._encodeChoice(t,e);else if(n.contains)a=this._getUse(n.contains,i)._encode(t,e),o=!0;else if(n.children)a=n.children.map((function(r){if('null_'===r._baseState.tag)return r._encode(null,e,t);if(null===r._baseState.key)return e.error('Child should have a key');let i=e.enterKey(r._baseState.key);if('object'!=typeof t)return e.error('Child expected, but input is not object');let n=r._encode(t[r._baseState.key],e,t);return e.leaveKey(i),n}),this).filter((function(t){return t})),a=this._createEncoderBuffer(a);else if('seqof'===n.tag||'setof'===n.tag){if(!n.args||1!==n.args.length)return e.error('Too many args for : '+n.tag);if(!Array.isArray(t))return e.error('seqof/setof, but data is not Array');let r=this.clone();r._baseState.implicit=null,a=this._createEncoderBuffer(t.map((function(r){let i=this._baseState;return this._getUse(i.args[0],t)._encode(r,e)}),r))}else null!==n.use?s=this._getUse(n.use,i)._encode(t,e):(a=this._encodePrimitive(n.tag,t),o=!0);if(!n.any&&null===n.choice){let t=null!==n.implicit?n.implicit:n.tag,r=null===n.implicit?'universal':'context';null===t?null===n.use&&e.error('Tag could be omitted only for .use()'):null===n.use&&(s=this._encodeComposite(t,o,r,a))}return null!==n.explicit&&(s=this._encodeComposite(n.explicit,!1,'context',s)),s},h.prototype._encodeChoice=function(t,e){let r=this._baseState,i=r.choice[t.type];return i||s(!1,t.type+' not found in '+JSON.stringify(Object.keys(r.choice))),i._encode(t.value,e)},h.prototype._encodePrimitive=function(t,e){let r=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if('objid'===t&&r.args)return this._encodeObjid(e,r.reverseArgs[0],r.args[1]);if('objid'===t)return this._encodeObjid(e,null,null);if('gentime'===t||'utctime'===t)return this._encodeTime(e,t);if('null_'===t)return this._encodeNull();if('int'===t||'enum'===t)return this._encodeInt(e,r.args&&r.reverseArgs[0]);if('bool'===t)return this._encodeBool(e);if('objDesc'===t)return this._encodeStr(e,t);throw new Error('Unsupported tag: '+t)},h.prototype._isNumstr=function(t){return/^[0-9 ]*$/.test(t)},h.prototype._isPrintstr=function(t){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(t)}})),Jr=P((t=>{function e(t){let e={};return Object.keys(t).forEach((function(r){(0|r)==r&&(r|=0);let i=t[r];e[i]=r})),e}t.tagClass={0:'universal',1:'application',2:'context',3:'private'},t.tagClassByName=e(t.tagClass),t.tag={0:'end',1:'bool',2:'int',3:'bitstr',4:'octstr',5:'null_',6:'objid',7:'objDesc',8:'external',9:'real',10:'enum',11:'embed',12:'utf8str',13:'relativeOid',16:'seq',17:'set',18:'numstr',19:'printstr',20:'t61str',21:'videostr',22:'ia5str',23:'utctime',24:'gentime',25:'graphstr',26:'iso646str',27:'genstr',28:'unistr',29:'charstr',30:'bmpstr'},t.tagByName=e(t.tag)})),ti=P(((t,e)=>{var r=z(),i=Zr().Buffer,n=Qr(),s=Jr();function a(t){this.enc='der',this.name=t.name,this.entity=t,this.tree=new o,this.tree._init(t.body)}function o(t){n.call(this,'der',t)}function h(t){return t<10?'0'+t:t}e.exports=a,a.prototype.encode=function(t,e){return this.tree._encode(t,e).join()},r(o,n),o.prototype._encodeComposite=function(t,e,r,n){let a=function(t,e,r,i){let n;if('seqof'===t?t='seq':'setof'===t&&(t='set'),s.tagByName.hasOwnProperty(t))n=s.tagByName[t];else{if('number'!=typeof t||(0|t)!==t)return i.error('Unknown tag: '+t);n=t}return n>=31?i.error('Multi-octet tag encoding unsupported'):(e||(n|=32),n|=s.tagClassByName[r||'universal']<<6,n)}(t,e,r,this.reporter);if(n.length<128){let t=i.alloc(2);return t[0]=a,t[1]=n.length,this._createEncoderBuffer([t,n])}let o=1;for(let t=n.length;t>=256;t>>=8)o++;let h=i.alloc(2+o);h[0]=a,h[1]=128|o;for(let t=1+o,e=n.length;e>0;t--,e>>=8)h[t]=255&e;return this._createEncoderBuffer([h,n])},o.prototype._encodeStr=function(t,e){if('bitstr'===e)return this._createEncoderBuffer([0|t.unused,t.data]);if('bmpstr'===e){let e=i.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error('Second objid identifier OOB');t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}let s=i.alloc(n),a=s.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(s[a--]=127&r;(r>>=7)>0;)s[a--]=128|127&r}return this._createEncoderBuffer(s)},o.prototype._encodeTime=function(t,e){let r,i=new Date(t);return'gentime'===e?r=[h(i.getUTCFullYear()),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),'Z'].join(''):'utctime'===e?r=[h(i.getUTCFullYear()%100),h(i.getUTCMonth()+1),h(i.getUTCDate()),h(i.getUTCHours()),h(i.getUTCMinutes()),h(i.getUTCSeconds()),'Z'].join(''):this.reporter.error('Encoding '+e+' time is not supported yet'),this._encodeStr(r,'octstr')},o.prototype._encodeNull=function(){return this._createEncoderBuffer('')},o.prototype._encodeInt=function(t,e){if('string'==typeof t){if(!e)return this.reporter.error('String int or enum given, but no values map');if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if('number'!=typeof t&&!i.isBuffer(t)){let e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=i.from(e)}if(i.isBuffer(t)){let e=t.length;0===t.length&&e++;let r=i.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;let n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(i.from(n))},o.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},o.prototype._use=function(t,e){return'function'==typeof t&&(t=t(e)),t._getEncoder('der').tree},o.prototype._skipDefault=function(t,e,r){let i,n=this._baseState;if(null===n.default)return!1;let s=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),s.length!==n.defaultBuffer.length)return!1;for(i=0;i{var r=z(),i=ti();function n(t){i.call(this,t),this.enc='pem'}r(n,i),e.exports=n,n.prototype.encode=function(t,e){let r=i.prototype.encode.call(this,t).toString('base64'),n=['-----BEGIN '+e.label+'-----'];for(let t=0;t{var e=t;e.der=ti(),e.pem=ei()})),ii=P(((t,e)=>{var r=z(),i=Yr(),n=Xr().DecoderBuffer,s=Qr(),a=Jr();function o(t){this.enc='der',this.name=t.name,this.entity=t,this.tree=new h,this.tree._init(t.body)}function h(t){s.call(this,'der',t)}function l(t,e){let r=t.readUInt8(e);if(t.isError(r))return r;let i=a.tagClass[r>>6],n=!(32&r);if(31&~r)r&=31;else{let i=r;for(r=0;!(128&~i);){if(i=t.readUInt8(e),t.isError(i))return i;r<<=7,r|=127&i}}return{cls:i,primitive:n,tag:r,tagStr:a.tag[r]}}function c(t,e,r){let i=t.readUInt8(r);if(t.isError(i))return i;if(!e&&128===i)return null;if(!(128&i))return i;let n=127&i;if(n>4)return t.error('length octect is too long');i=0;for(let e=0;e{var r=z(),i=Zr().Buffer,n=ii();function s(t){n.call(this,t),this.enc='pem'}r(s,n),e.exports=s,s.prototype.decode=function(t,e){let r=t.toString().split(/[\r\n]+/g),s=e.label.toUpperCase(),a=/^-----(BEGIN|END) ([^-]+)-----$/,o=-1,h=-1;for(let t=0;t{var e=t;e.der=ii(),e.pem=ni()})),ai=P((t=>{var e=ri(),r=si(),i=z();function n(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={}}t.define=function(t,e){return new n(t,e)},n.prototype._createNamed=function(t){let e=this.name;function r(t){this._initNamed(t,e)}return i(r,t),r.prototype._initNamed=function(e,r){t.call(this,e,r)},new r(this)},n.prototype._getDecoder=function(t){return t=t||'der',this.decoders.hasOwnProperty(t)||(this.decoders[t]=this._createNamed(r[t])),this.decoders[t]},n.prototype.decode=function(t,e,r){return this._getDecoder(e).decode(t,r)},n.prototype._getEncoder=function(t){return t=t||'der',this.encoders.hasOwnProperty(t)||(this.encoders[t]=this._createNamed(e[t])),this.encoders[t]},n.prototype.encode=function(t,e,r){return this._getEncoder(e).encode(t,r)}})),oi=P((t=>{var e=t;e.Reporter=$r().Reporter,e.DecoderBuffer=Xr().DecoderBuffer,e.EncoderBuffer=Xr().EncoderBuffer,e.Node=Qr()})),hi=P((t=>{var e=t;e._reverse=function(t){let e={};return Object.keys(t).forEach((function(r){(0|r)==r&&(r|=0);let i=t[r];e[i]=r})),e},e.der=Jr()})),li=P((t=>{var e=t;e.bignum=Yr(),e.define=ai().define,e.base=oi(),e.constants=hi(),e.decoders=si(),e.encoders=ri()})),ci=P(((t,e)=>{var r=li(),i=r.define('Time',(function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})})),n=r.define('AttributeTypeValue',(function(){this.seq().obj(this.key('type').objid(),this.key('value').any())})),s=r.define('AlgorithmIdentifier',(function(){this.seq().obj(this.key('algorithm').objid(),this.key('parameters').optional(),this.key('curve').objid().optional())})),a=r.define('SubjectPublicKeyInfo',(function(){this.seq().obj(this.key('algorithm').use(s),this.key('subjectPublicKey').bitstr())})),o=r.define('RelativeDistinguishedName',(function(){this.setof(n)})),h=r.define('RDNSequence',(function(){this.seqof(o)})),l=r.define('Name',(function(){this.choice({rdnSequence:this.use(h)})})),c=r.define('Validity',(function(){this.seq().obj(this.key('notBefore').use(i),this.key('notAfter').use(i))})),u=r.define('Extension',(function(){this.seq().obj(this.key('extnID').objid(),this.key('critical').bool().def(!1),this.key('extnValue').octstr())})),d=r.define('TBSCertificate',(function(){this.seq().obj(this.key('version').explicit(0).int().optional(),this.key('serialNumber').int(),this.key('signature').use(s),this.key('issuer').use(l),this.key('validity').use(c),this.key('subject').use(l),this.key('subjectPublicKeyInfo').use(a),this.key('issuerUniqueID').implicit(1).bitstr().optional(),this.key('subjectUniqueID').implicit(2).bitstr().optional(),this.key('extensions').explicit(3).seqof(u).optional())})),f=r.define('X509Certificate',(function(){this.seq().obj(this.key('tbsCertificate').use(d),this.key('signatureAlgorithm').use(s),this.key('signatureValue').bitstr())}));e.exports=f})),ui=P((t=>{var e=li();t.certificate=ci();var r=e.define('RSAPrivateKey',(function(){this.seq().obj(this.key('version').int(),this.key('modulus').int(),this.key('publicExponent').int(),this.key('privateExponent').int(),this.key('prime1').int(),this.key('prime2').int(),this.key('exponent1').int(),this.key('exponent2').int(),this.key('coefficient').int())}));t.RSAPrivateKey=r;var i=e.define('RSAPublicKey',(function(){this.seq().obj(this.key('modulus').int(),this.key('publicExponent').int())}));t.RSAPublicKey=i;var n=e.define('SubjectPublicKeyInfo',(function(){this.seq().obj(this.key('algorithm').use(s),this.key('subjectPublicKey').bitstr())}));t.PublicKey=n;var s=e.define('AlgorithmIdentifier',(function(){this.seq().obj(this.key('algorithm').objid(),this.key('none').null_().optional(),this.key('curve').objid().optional(),this.key('params').seq().obj(this.key('p').int(),this.key('q').int(),this.key('g').int()).optional())})),a=e.define('PrivateKeyInfo',(function(){this.seq().obj(this.key('version').int(),this.key('algorithm').use(s),this.key('subjectPrivateKey').octstr())}));t.PrivateKey=a;var o=e.define('EncryptedPrivateKeyInfo',(function(){this.seq().obj(this.key('algorithm').seq().obj(this.key('id').objid(),this.key('decrypt').seq().obj(this.key('kde').seq().obj(this.key('id').objid(),this.key('kdeparams').seq().obj(this.key('salt').octstr(),this.key('iters').int())),this.key('cipher').seq().obj(this.key('algo').objid(),this.key('iv').octstr()))),this.key('subjectPrivateKey').octstr())}));t.EncryptedPrivateKey=o;var h=e.define('DSAPrivateKey',(function(){this.seq().obj(this.key('version').int(),this.key('p').int(),this.key('q').int(),this.key('g').int(),this.key('pub_key').int(),this.key('priv_key').int())}));t.DSAPrivateKey=h,t.DSAparam=e.define('DSAparam',(function(){this.int()}));var l=e.define('ECPrivateKey',(function(){this.seq().obj(this.key('version').int(),this.key('privateKey').octstr(),this.key('parameters').optional().explicit(0).use(c),this.key('publicKey').optional().explicit(1).bitstr())}));t.ECPrivateKey=l;var c=e.define('ECParameters',(function(){this.choice({namedCurve:this.objid()})}));t.signature=e.define('signature',(function(){this.seq().obj(this.key('r').int(),this.key('s').int())}))})),di=P(((t,e)=>{e.exports={'2.16.840.1.101.3.4.1.1':'aes-128-ecb','2.16.840.1.101.3.4.1.2':'aes-128-cbc','2.16.840.1.101.3.4.1.3':'aes-128-ofb','2.16.840.1.101.3.4.1.4':'aes-128-cfb','2.16.840.1.101.3.4.1.21':'aes-192-ecb','2.16.840.1.101.3.4.1.22':'aes-192-cbc','2.16.840.1.101.3.4.1.23':'aes-192-ofb','2.16.840.1.101.3.4.1.24':'aes-192-cfb','2.16.840.1.101.3.4.1.41':'aes-256-ecb','2.16.840.1.101.3.4.1.42':'aes-256-cbc','2.16.840.1.101.3.4.1.43':'aes-256-ofb','2.16.840.1.101.3.4.1.44':'aes-256-cfb'}})),fi=P(((t,e)=>{var r=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,i=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,n=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,s=xe(),a=je(),o=V().Buffer;e.exports=function(t,e){var h,l=t.toString(),c=l.match(r);if(c){var u='aes'+c[1],d=o.from(c[2],'hex'),f=o.from(c[3].replace(/[\r\n]/g,''),'base64'),p=s(e,d.slice(0,8),parseInt(c[1],10)).key,m=[],g=a.createDecipheriv(u,p,d);m.push(g.update(f)),m.push(g.final()),h=o.concat(m)}else{var y=l.match(n);h=o.from(y[2].replace(/[\r\n]/g,''),'base64')}return{tag:l.match(i)[1],data:h}}})),pi=P(((t,e)=>{var r=ui(),i=di(),n=fi(),s=je(),a=pe(),o=V().Buffer;function h(t){var e;'object'==typeof t&&!o.isBuffer(t)&&(e=t.passphrase,t=t.key),'string'==typeof t&&(t=o.from(t));var h,l,c=n(t,e),u=c.tag,d=c.data;switch(u){case'CERTIFICATE':l=r.certificate.decode(d,'der').tbsCertificate.subjectPublicKeyInfo;case'PUBLIC KEY':switch(l||(l=r.PublicKey.decode(d,'der')),h=l.algorithm.algorithm.join('.')){case'1.2.840.113549.1.1.1':return r.RSAPublicKey.decode(l.subjectPublicKey.data,'der');case'1.2.840.10045.2.1':return l.subjectPrivateKey=l.subjectPublicKey,{type:'ec',data:l};case'1.2.840.10040.4.1':return l.algorithm.params.pub_key=r.DSAparam.decode(l.subjectPublicKey.data,'der'),{type:'dsa',data:l.algorithm.params};default:throw new Error('unknown key id '+h)}case'ENCRYPTED PRIVATE KEY':d=function(t,e){var r=t.algorithm.decrypt.kde.kdeparams.salt,n=parseInt(t.algorithm.decrypt.kde.kdeparams.iters.toString(),10),h=i[t.algorithm.decrypt.cipher.algo.join('.')],l=t.algorithm.decrypt.cipher.iv,c=t.subjectPrivateKey,u=parseInt(h.split('-')[1],10)/8,d=a.pbkdf2Sync(e,r,n,u,'sha1'),f=s.createDecipheriv(h,d,l),p=[];return p.push(f.update(c)),p.push(f.final()),o.concat(p)}(d=r.EncryptedPrivateKey.decode(d,'der'),e);case'PRIVATE KEY':switch(h=(l=r.PrivateKey.decode(d,'der')).algorithm.algorithm.join('.')){case'1.2.840.113549.1.1.1':return r.RSAPrivateKey.decode(l.subjectPrivateKey,'der');case'1.2.840.10045.2.1':return{curve:l.algorithm.curve,privateKey:r.ECPrivateKey.decode(l.subjectPrivateKey,'der').privateKey};case'1.2.840.10040.4.1':return l.algorithm.params.priv_key=r.DSAparam.decode(l.subjectPrivateKey,'der'),{type:'dsa',params:l.algorithm.params};default:throw new Error('unknown key id '+h)}case'RSA PUBLIC KEY':return r.RSAPublicKey.decode(d,'der');case'RSA PRIVATE KEY':return r.RSAPrivateKey.decode(d,'der');case'DSA PRIVATE KEY':return{type:'dsa',params:r.DSAPrivateKey.decode(d,'der')};case'EC PRIVATE KEY':return{curve:(d=r.ECPrivateKey.decode(d,'der')).parameters.value,privateKey:d.privateKey};default:throw new Error('unknown key type '+u)}}e.exports=h,h.signature=r.signature})),mi=P(((t,e)=>{e.exports={'1.3.132.0.10':'secp256k1','1.3.132.0.33':'p224','1.2.840.10045.3.1.1':'p192','1.2.840.10045.3.1.7':'p256','1.3.132.0.34':'p384','1.3.132.0.35':'p521'}})),gi=P(((t,e)=>{var r=V().Buffer,i=ae(),n=gr(),s=qr().ec,a=mr(),o=pi(),h=mi();function l(t,e,n,s){if((t=r.from(t.toArray())).length0&&r.ishrn(i),r}function u(t,e,n){var s,a;do{for(s=r.alloc(0);8*s.length{var r=V().Buffer,i=mr(),n=qr().ec,s=pi(),a=mi();function o(t,e){if(t.cmpn(0)<=0)throw new Error('invalid sig');if(t.cmp(e)>=e)throw new Error('invalid sig')}e.exports=function(t,e,h,l,c){var u=s(h);if('ec'===u.type){if('ecdsa'!==l&&'ecdsa/rsa'!==l)throw new Error('wrong public key type');return function(t,e,r){var i=a[r.data.algorithm.curve.join('.')];if(!i)throw new Error('unknown curve '+r.data.algorithm.curve.join('.'));var s=new n(i),o=r.data.subjectPrivateKey.data;return s.verify(e,t,o)}(t,e,u)}if('dsa'===u.type){if('dsa'!==l)throw new Error('wrong public key type');return function(t,e,r){var n=r.data.p,a=r.data.q,h=r.data.g,l=r.data.pub_key,c=s.signature.decode(t,'der'),u=c.s,d=c.r;o(u,a),o(d,a);var f=i.mont(n),p=u.invm(a),m=h.toRed(f).redPow(new i(e).mul(p).mod(a)).fromRed().mul(l.toRed(f).redPow(d.mul(p).mod(a)).fromRed()).mod(n).mod(a);return 0===m.cmp(d)}(t,e,u)}if('rsa'!==l&&'ecdsa/rsa'!==l)throw new Error('wrong public key type');e=r.concat([c,e]);for(var d=u.modulus.byteLength(),f=[1],p=0;e.length+f.length+2{var r=V().Buffer,i=ie(),n=pr(),s=z(),a=gi(),o=yi(),h=oe();function l(t){n.Writable.call(this);var e=h[t];if(!e)throw new Error('Unknown message digest');this._hashType=e.hash,this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign}function c(t){n.Writable.call(this);var e=h[t];if(!e)throw new Error('Unknown message digest');this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign}function u(t){return new l(t)}function d(t){return new c(t)}Object.keys(h).forEach((function(t){h[t].id=r.from(h[t].id,'hex'),h[t.toLowerCase()]=h[t]})),s(l,n.Writable),l.prototype._write=function(t,e,r){this._hash.update(t),r()},l.prototype.update=function(t,e){return'string'==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},l.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),i=a(r,t,this._hashType,this._signType,this._tag);return e?i.toString(e):i},s(c,n.Writable),c.prototype._write=function(t,e,r){this._hash.update(t),r()},c.prototype.update=function(t,e){return'string'==typeof t&&(t=r.from(t,e)),this._hash.update(t),this},c.prototype.verify=function(t,e,i){'string'==typeof e&&(e=r.from(e,i)),this.end();var n=this._hash.digest();return o(e,n,t,this._signType,this._tag)},e.exports={Sign:u,Verify:d,createSign:u,createVerify:d}})),bi=P(((t,e)=>{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var s;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{s=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:ze().Buffer}catch{}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function o(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,s=Math.min(t.length,r),a=e;a=49?o-49+10:o>=17?o-17+10:o}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=a<>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);else if('le'===i)for(n=0,s=0;n>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=o(t,e,i)<=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,a=s%i,o=Math.min(s,s-a)+r,l=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?''};var l=['','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'],c=[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],u=[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 d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],a=n*s,o=67108863&a,h=a/67108864|0;r.words[0]=o;for(var l=1;l>>26,u=67108863&h,d=Math.min(l,e.length-1),f=Math.max(0,l-t.length+1);f<=d;f++){var p=l-f|0;c+=(a=(n=0|t.words[p])*(s=0|e.words[f])+u)/67108864|0,u=67108863&a}r.words[l]=0|u,h=0|c}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,s=0,a=0;a>>24-n&16777215)||a!==this.length-1?l[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,a--)}for(0!==s&&(i=s.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var d=c[t],f=u[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(f).toString(t);i=(p=p.idivn(f)).isZero()?m+i:l[d-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof s<'u'),this.toArrayLike(s,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),s=i||Math.max(1,n);r(n<=s,'byte array longer than desired length'),r(s>0,'Requested array length <= 0'),this.strip();var a,o,h='le'===e,l=new t(s),c=this.clone();if(h){for(o=0;!c.isZero();o++)a=c.andln(255),c.iushrn(8),l[o]=a;for(;o=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,a=0;a>26,this.words[a]=67108863&e;for(;0!==s&&a>26,this.words[a]=67108863&e;if(0===s&&a>>13,f=0|a[1],p=8191&f,m=f>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],_=8191&b,w=b>>>13,E=0|a[4],A=8191&E,S=E>>>13,T=0|a[5],M=8191&T,I=T>>>13,C=0|a[6],O=8191&C,N=C>>>13,L=0|a[7],R=8191&L,P=L>>>13,B=0|a[8],k=8191&B,D=B>>>13,U=0|a[9],x=8191&U,F=U>>>13,H=0|o[0],j=8191&H,V=H>>>13,G=0|o[1],z=8191&G,W=G>>>13,K=0|o[2],q=8191&K,Y=K>>>13,Z=0|o[3],$=8191&Z,X=Z>>>13,Q=0|o[4],J=8191&Q,tt=Q>>>13,et=0|o[5],rt=8191&et,it=et>>>13,nt=0|o[6],st=8191&nt,at=nt>>>13,ot=0|o[7],ht=8191&ot,lt=ot>>>13,ct=0|o[8],ut=8191&ct,dt=ct>>>13,ft=0|o[9],pt=8191&ft,mt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(i=Math.imul(u,j))|0)+((8191&(n=(n=Math.imul(u,V))+Math.imul(d,j)|0))<<13)|0;l=((s=Math.imul(d,V))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,j),n=(n=Math.imul(p,V))+Math.imul(m,j)|0,s=Math.imul(m,V);var yt=(l+(i=i+Math.imul(u,z)|0)|0)+((8191&(n=(n=n+Math.imul(u,W)|0)+Math.imul(d,z)|0))<<13)|0;l=((s=s+Math.imul(d,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,j),n=(n=Math.imul(y,V))+Math.imul(v,j)|0,s=Math.imul(v,V),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,z)|0,s=s+Math.imul(m,W)|0;var vt=(l+(i=i+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,Y)|0)+Math.imul(d,q)|0))<<13)|0;l=((s=s+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,j),n=(n=Math.imul(_,V))+Math.imul(w,j)|0,s=Math.imul(w,V),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(v,z)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,q)|0,s=s+Math.imul(m,Y)|0;var bt=(l+(i=i+Math.imul(u,$)|0)|0)+((8191&(n=(n=n+Math.imul(u,X)|0)+Math.imul(d,$)|0))<<13)|0;l=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(A,j),n=(n=Math.imul(A,V))+Math.imul(S,j)|0,s=Math.imul(S,V),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,z)|0,s=s+Math.imul(w,W)|0,i=i+Math.imul(y,q)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(v,q)|0,s=s+Math.imul(v,Y)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,$)|0,s=s+Math.imul(m,X)|0;var _t=(l+(i=i+Math.imul(u,J)|0)|0)+((8191&(n=(n=n+Math.imul(u,tt)|0)+Math.imul(d,J)|0))<<13)|0;l=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(M,j),n=(n=Math.imul(M,V))+Math.imul(I,j)|0,s=Math.imul(I,V),i=i+Math.imul(A,z)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(S,z)|0,s=s+Math.imul(S,W)|0,i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(w,q)|0,s=s+Math.imul(w,Y)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(v,$)|0,s=s+Math.imul(v,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var wt=(l+(i=i+Math.imul(u,rt)|0)|0)+((8191&(n=(n=n+Math.imul(u,it)|0)+Math.imul(d,rt)|0))<<13)|0;l=((s=s+Math.imul(d,it)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(O,j),n=(n=Math.imul(O,V))+Math.imul(N,j)|0,s=Math.imul(N,V),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(I,z)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(A,q)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(S,q)|0,s=s+Math.imul(S,Y)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,X)|0)+Math.imul(w,$)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Et=(l+(i=i+Math.imul(u,st)|0)|0)+((8191&(n=(n=n+Math.imul(u,at)|0)+Math.imul(d,st)|0))<<13)|0;l=((s=s+Math.imul(d,at)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(R,j),n=(n=Math.imul(R,V))+Math.imul(P,j)|0,s=Math.imul(P,V),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(N,z)|0,s=s+Math.imul(N,W)|0,i=i+Math.imul(M,q)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,Y)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(S,$)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(_,J)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,at)|0;var At=(l+(i=i+Math.imul(u,ht)|0)|0)+((8191&(n=(n=n+Math.imul(u,lt)|0)+Math.imul(d,ht)|0))<<13)|0;l=((s=s+Math.imul(d,lt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(k,j),n=(n=Math.imul(k,V))+Math.imul(D,j)|0,s=Math.imul(D,V),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(P,z)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(O,q)|0,n=(n=n+Math.imul(O,Y)|0)+Math.imul(N,q)|0,s=s+Math.imul(N,Y)|0,i=i+Math.imul(M,$)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,at)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(i=i+Math.imul(u,ut)|0)|0)+((8191&(n=(n=n+Math.imul(u,dt)|0)+Math.imul(d,ut)|0))<<13)|0;l=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(x,j),n=(n=Math.imul(x,V))+Math.imul(F,j)|0,s=Math.imul(F,V),i=i+Math.imul(k,z)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(D,z)|0,s=s+Math.imul(D,W)|0,i=i+Math.imul(R,q)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,Y)|0,i=i+Math.imul(O,$)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(N,$)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(_,st)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,ut)|0,s=s+Math.imul(m,dt)|0;var Tt=(l+(i=i+Math.imul(u,pt)|0)|0)+((8191&(n=(n=n+Math.imul(u,mt)|0)+Math.imul(d,pt)|0))<<13)|0;l=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(x,z),n=(n=Math.imul(x,W))+Math.imul(F,z)|0,s=Math.imul(F,W),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,Y)|0)+Math.imul(D,q)|0,s=s+Math.imul(D,Y)|0,i=i+Math.imul(R,$)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(P,$)|0,s=s+Math.imul(P,X)|0,i=i+Math.imul(O,J)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(A,st)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,lt)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,lt)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(v,ut)|0,s=s+Math.imul(v,dt)|0;var Mt=(l+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(x,q),n=(n=Math.imul(x,Y))+Math.imul(F,q)|0,s=Math.imul(F,Y),i=i+Math.imul(k,$)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(D,$)|0,s=s+Math.imul(D,X)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(M,st)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,at)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(w,ut)|0,s=s+Math.imul(w,dt)|0;var It=(l+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(x,$),n=(n=Math.imul(x,X))+Math.imul(F,$)|0,s=Math.imul(F,X),i=i+Math.imul(k,J)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(O,st)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,at)|0,i=i+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,lt)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,lt)|0,i=i+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,dt)|0)+Math.imul(S,ut)|0,s=s+Math.imul(S,dt)|0;var Ct=(l+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,mt)|0)+Math.imul(w,pt)|0))<<13)|0;l=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(x,J),n=(n=Math.imul(x,tt))+Math.imul(F,J)|0,s=Math.imul(F,tt),i=i+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,it)|0)+Math.imul(D,rt)|0,s=s+Math.imul(D,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,at)|0,i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(I,ut)|0,s=s+Math.imul(I,dt)|0;var Ot=(l+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(x,rt),n=(n=Math.imul(x,it))+Math.imul(F,rt)|0,s=Math.imul(F,it),i=i+Math.imul(k,st)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,at)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(N,ut)|0,s=s+Math.imul(N,dt)|0;var Nt=(l+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(I,pt)|0))<<13)|0;l=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(x,st),n=(n=Math.imul(x,at))+Math.imul(F,st)|0,s=Math.imul(F,at),i=i+Math.imul(k,ht)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(D,ht)|0,s=s+Math.imul(D,lt)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ut)|0,s=s+Math.imul(P,dt)|0;var Lt=(l+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,i=Math.imul(x,ht),n=(n=Math.imul(x,lt))+Math.imul(F,ht)|0,s=Math.imul(F,lt),i=i+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,dt)|0)+Math.imul(D,ut)|0,s=s+Math.imul(D,dt)|0;var Rt=(l+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(x,ut),n=(n=Math.imul(x,dt))+Math.imul(F,ut)|0,s=Math.imul(F,dt);var Pt=(l+(i=i+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,mt)|0)+Math.imul(D,pt)|0))<<13)|0;l=((s=s+Math.imul(D,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var Bt=(l+(i=Math.imul(x,pt))|0)+((8191&(n=(n=Math.imul(x,mt))+Math.imul(F,pt)|0))<<13)|0;return l=((s=Math.imul(F,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=_t,h[5]=wt,h[6]=Et,h[7]=At,h[8]=St,h[9]=Tt,h[10]=Mt,h[11]=It,h[12]=Ct,h[13]=Ot,h[14]=Nt,h[15]=Lt,h[16]=Rt,h[17]=Pt,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(f=d),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?f(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,a&=67108863}r.words[s]=o,i=a,a=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,s){for(var a=0;a>>=1)n++;return 1<>>=13,i[2*a+1]=8191&s,s>>>=13;for(a=2*e;a>=26,e+=n/67108864|0,e+=s>>>26,this.words[i]=67108863&s}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,s=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var s=t%26,a=Math.min((t-s)/26,this.length),o=67108863^67108863>>>s<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=n);l--){var u=0|this.words[l];this.words[l]=c<<26-s|u>>>s,c=u&o}return h&&0!==c&&(h.words[h.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&a}for(;n>26,this.words[n+i]=67108863&a;if(0===o)return this.strip();for(r(-1===o),o=0,n=0;n>26,this.words[n]=67108863&a;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,a=0|s.words[s.length-1];0!==(r=26-this._countBits(a))&&(s=s.ushln(r),i.iushln(r),a=0|s.words[s.length-1]);var o,h=i.length-s.length;if('mod'!==e){(o=new n(null)).length=h+1,o.words=new Array(o.length);for(var l=0;l=0;u--){var d=67108864*(0|i.words[s.length+u])+(0|i.words[s.length+u-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(s,d,u);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(s,1,u),i.isZero()||(i.negative^=1);o&&(o.words[u]=d)}return o&&o.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),'mod'!==e&&(s=o.div.neg()),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:s,mod:a}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),'mod'!==e&&(s=o.div.neg()),{div:s,mod:o.mod}):this.negative&t.negative?(o=this.neg().divmod(t.neg(),e),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:o.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var s,a,o},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),a=new n(0),o=new n(0),h=new n(1),l=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++l;for(var c=i.clone(),u=e.clone();!e.isZero();){for(var d=0,f=1;!(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||a.isOdd())&&(s.iadd(c),a.isub(u)),s.iushrn(1),a.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(c),h.isub(u)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o),a.isub(h)):(i.isub(e),o.isub(s),h.isub(a))}return{a:o,b:h,gcd:i.iushln(l)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,s=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var a=new n(1),o=new n(0),h=s.clone();i.cmpn(1)>0&&s.cmpn(1)>0;){for(var l=0,c=1;!(i.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(i.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var u=0,d=1;!(s.words[0]&d)&&u<26;++u,d<<=1);if(u>0)for(s.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);i.cmp(s)>=0?(i.isub(s),a.isub(o)):(s.isub(i),o.isub(a))}return(e=0===i.cmpn(1)?a:o).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,o&=67108863,this.words[a]=o}return 0!==s&&(this.words[a]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function _(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function w(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function E(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=a}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new _;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new w}return g[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},E.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),a=0;!s.isZero()&&0===s.andln(1);)a++,s.iushrn(1);r(!s.isZero());var o=new n(1).toRed(this),h=o.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);0!==this.pow(c,l).cmp(h);)c.redIAdd(h);for(var u=this.pow(c,s),d=this.pow(t,s.addn(1).iushrn(1)),f=this.pow(t,s),p=a;0!==f.cmp(o);){for(var m=f,g=0;0!==m.cmp(o);g++)m=m.redSqr();r(g=0;i--){for(var l=e.words[i],c=h-1;c>=0;c--){var u=l>>c&1;(s!==r[0]&&(s=this.sqr(s)),0!==u||0!==a)?(a<<=1,a|=u,(4===++o||0===i&&0===c)&&(s=this.mul(s,r[a]),o=0,a=0)):o=0}h=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),_i=P(((t,e)=>{var r=qr(),i=bi();e.exports=function(t){return new s(t)};var n={secp256k1:{name:'secp256k1',byteLength:32},secp224r1:{name:'p224',byteLength:28},prime256v1:{name:'p256',byteLength:32},prime192v1:{name:'p192',byteLength:24},ed25519:{name:'ed25519',byteLength:32},secp384r1:{name:'p384',byteLength:48},secp521r1:{name:'p521',byteLength:66}};function s(t){this.curveType=n[t],this.curveType||(this.curveType={name:t}),this.curve=new r.ec(this.curveType.name),this.keys=void 0}function a(t,e,r){Array.isArray(t)||(t=t.toArray());var i=new Buffer(t);if(r&&i.length{var r=ie(),i=V().Buffer;function n(t){var e=i.allocUnsafe(4);return e.writeUInt32BE(t,0),e}e.exports=function(t,e){for(var s,a=i.alloc(0),o=0;a.length{e.exports=function(t,e){for(var r=t.length,i=-1;++i{!function(t,e){function r(t,e){if(!t)throw new Error(e||'Assertion failed')}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&(('le'===e||'be'===e)&&(r=e,e=10),this._init(t||0,e||10,r||'be'))}var s;'object'==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{s=typeof window<'u'&&typeof window.Buffer<'u'?window.Buffer:ze().Buffer}catch{}function a(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function o(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,r,i){for(var n=0,s=Math.min(t.length,r),a=e;a=49?o-49+10:o>=17?o-17+10:o}return n}n.isBN=function(t){return t instanceof n||null!==t&&'object'==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if('number'==typeof t)return this._initNumber(t,e,i);if('object'==typeof t)return this._initArray(t,e,i);'hex'===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;'-'===(t=t.toString().replace(/\s+/g,''))[0]&&(n++,this.negative=1),n=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[s]|=a<>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);else if('le'===i)for(n=0,s=0;n>>26-o&67108863,(o+=24)>=26&&(o-=26,s++);return this.strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i=e;i-=2)n=o(t,e,i)<=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i=18?(s-=18,a+=1,this.words[a]|=n>>>26):s+=8;this.strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var s=t.length-r,a=s%i,o=Math.min(s,s-a)+r,l=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?''};var l=['','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'],c=[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],u=[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 d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],s=0|e.words[0],a=n*s,o=67108863&a,h=a/67108864|0;r.words[0]=o;for(var l=1;l>>26,u=67108863&h,d=Math.min(l,e.length-1),f=Math.max(0,l-t.length+1);f<=d;f++){var p=l-f|0;c+=(a=(n=0|t.words[p])*(s=0|e.words[f])+u)/67108864|0,u=67108863&a}r.words[l]=0|u,h=0|c}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||'hex'===t){i='';for(var n=0,s=0,a=0;a>>24-n&16777215)||a!==this.length-1?l[6-h.length]+h+i:h+i,(n+=2)>=26&&(n-=26,a--)}for(0!==s&&(i=s.toString(16)+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}if(t===(0|t)&&t>=2&&t<=36){var d=c[t],f=u[t];i='';var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(f).toString(t);i=(p=p.idivn(f)).isZero()?m+i:l[d-m.length]+m+i}for(this.isZero()&&(i='0'+i);i.length%e!=0;)i='0'+i;return 0!==this.negative&&(i='-'+i),i}r(!1,'Base should be between 2 and 36')},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,'Number can only safely store up to 53 bits'),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,e){return r(typeof s<'u'),this.toArrayLike(s,t,e)},n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},n.prototype.toArrayLike=function(t,e,i){var n=this.byteLength(),s=i||Math.max(1,n);r(n<=s,'byte array longer than desired length'),r(s>0,'Requested array length <= 0'),this.strip();var a,o,h='le'===e,l=new t(s),c=this.clone();if(h){for(o=0;!c.isZero();o++)a=c.andln(255),c.iushrn(8),l[o]=a;for(;o=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return!(8191&e)&&(r+=13,e>>>=13),!(127&e)&&(r+=7,e>>>=7),!(15&e)&&(r+=4,e>>>=4),!(3&e)&&(r+=2,e>>>=2),!(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;it.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r('number'==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-i),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r('number'==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<t.length?(r=this,i=t):(r=t,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var s=0,a=0;a>26,this.words[a]=67108863&e;for(;0!==s&&a>26,this.words[a]=67108863&e;if(0===s&&a>>13,f=0|a[1],p=8191&f,m=f>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],_=8191&b,w=b>>>13,E=0|a[4],A=8191&E,S=E>>>13,T=0|a[5],M=8191&T,I=T>>>13,C=0|a[6],O=8191&C,N=C>>>13,L=0|a[7],R=8191&L,P=L>>>13,B=0|a[8],k=8191&B,D=B>>>13,U=0|a[9],x=8191&U,F=U>>>13,H=0|o[0],j=8191&H,V=H>>>13,G=0|o[1],z=8191&G,W=G>>>13,K=0|o[2],q=8191&K,Y=K>>>13,Z=0|o[3],$=8191&Z,X=Z>>>13,Q=0|o[4],J=8191&Q,tt=Q>>>13,et=0|o[5],rt=8191&et,it=et>>>13,nt=0|o[6],st=8191&nt,at=nt>>>13,ot=0|o[7],ht=8191&ot,lt=ot>>>13,ct=0|o[8],ut=8191&ct,dt=ct>>>13,ft=0|o[9],pt=8191&ft,mt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(i=Math.imul(u,j))|0)+((8191&(n=(n=Math.imul(u,V))+Math.imul(d,j)|0))<<13)|0;l=((s=Math.imul(d,V))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,j),n=(n=Math.imul(p,V))+Math.imul(m,j)|0,s=Math.imul(m,V);var yt=(l+(i=i+Math.imul(u,z)|0)|0)+((8191&(n=(n=n+Math.imul(u,W)|0)+Math.imul(d,z)|0))<<13)|0;l=((s=s+Math.imul(d,W)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,j),n=(n=Math.imul(y,V))+Math.imul(v,j)|0,s=Math.imul(v,V),i=i+Math.imul(p,z)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(m,z)|0,s=s+Math.imul(m,W)|0;var vt=(l+(i=i+Math.imul(u,q)|0)|0)+((8191&(n=(n=n+Math.imul(u,Y)|0)+Math.imul(d,q)|0))<<13)|0;l=((s=s+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,j),n=(n=Math.imul(_,V))+Math.imul(w,j)|0,s=Math.imul(w,V),i=i+Math.imul(y,z)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(v,z)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,Y)|0)+Math.imul(m,q)|0,s=s+Math.imul(m,Y)|0;var bt=(l+(i=i+Math.imul(u,$)|0)|0)+((8191&(n=(n=n+Math.imul(u,X)|0)+Math.imul(d,$)|0))<<13)|0;l=((s=s+Math.imul(d,X)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(A,j),n=(n=Math.imul(A,V))+Math.imul(S,j)|0,s=Math.imul(S,V),i=i+Math.imul(_,z)|0,n=(n=n+Math.imul(_,W)|0)+Math.imul(w,z)|0,s=s+Math.imul(w,W)|0,i=i+Math.imul(y,q)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(v,q)|0,s=s+Math.imul(v,Y)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(m,$)|0,s=s+Math.imul(m,X)|0;var _t=(l+(i=i+Math.imul(u,J)|0)|0)+((8191&(n=(n=n+Math.imul(u,tt)|0)+Math.imul(d,J)|0))<<13)|0;l=((s=s+Math.imul(d,tt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(M,j),n=(n=Math.imul(M,V))+Math.imul(I,j)|0,s=Math.imul(I,V),i=i+Math.imul(A,z)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(S,z)|0,s=s+Math.imul(S,W)|0,i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(w,q)|0,s=s+Math.imul(w,Y)|0,i=i+Math.imul(y,$)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(v,$)|0,s=s+Math.imul(v,X)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,tt)|0;var wt=(l+(i=i+Math.imul(u,rt)|0)|0)+((8191&(n=(n=n+Math.imul(u,it)|0)+Math.imul(d,rt)|0))<<13)|0;l=((s=s+Math.imul(d,it)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(O,j),n=(n=Math.imul(O,V))+Math.imul(N,j)|0,s=Math.imul(N,V),i=i+Math.imul(M,z)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(I,z)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(A,q)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(S,q)|0,s=s+Math.imul(S,Y)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,X)|0)+Math.imul(w,$)|0,s=s+Math.imul(w,X)|0,i=i+Math.imul(y,J)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,it)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,it)|0;var Et=(l+(i=i+Math.imul(u,st)|0)|0)+((8191&(n=(n=n+Math.imul(u,at)|0)+Math.imul(d,st)|0))<<13)|0;l=((s=s+Math.imul(d,at)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(R,j),n=(n=Math.imul(R,V))+Math.imul(P,j)|0,s=Math.imul(P,V),i=i+Math.imul(O,z)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(N,z)|0,s=s+Math.imul(N,W)|0,i=i+Math.imul(M,q)|0,n=(n=n+Math.imul(M,Y)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,Y)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(S,$)|0,s=s+Math.imul(S,X)|0,i=i+Math.imul(_,J)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(w,J)|0,s=s+Math.imul(w,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,at)|0;var At=(l+(i=i+Math.imul(u,ht)|0)|0)+((8191&(n=(n=n+Math.imul(u,lt)|0)+Math.imul(d,ht)|0))<<13)|0;l=((s=s+Math.imul(d,lt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(k,j),n=(n=Math.imul(k,V))+Math.imul(D,j)|0,s=Math.imul(D,V),i=i+Math.imul(R,z)|0,n=(n=n+Math.imul(R,W)|0)+Math.imul(P,z)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(O,q)|0,n=(n=n+Math.imul(O,Y)|0)+Math.imul(N,q)|0,s=s+Math.imul(N,Y)|0,i=i+Math.imul(M,$)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,X)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(S,J)|0,s=s+Math.imul(S,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(w,rt)|0,s=s+Math.imul(w,it)|0,i=i+Math.imul(y,st)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,at)|0,i=i+Math.imul(p,ht)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(i=i+Math.imul(u,ut)|0)|0)+((8191&(n=(n=n+Math.imul(u,dt)|0)+Math.imul(d,ut)|0))<<13)|0;l=((s=s+Math.imul(d,dt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(x,j),n=(n=Math.imul(x,V))+Math.imul(F,j)|0,s=Math.imul(F,V),i=i+Math.imul(k,z)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(D,z)|0,s=s+Math.imul(D,W)|0,i=i+Math.imul(R,q)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,q)|0,s=s+Math.imul(P,Y)|0,i=i+Math.imul(O,$)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(N,$)|0,s=s+Math.imul(N,X)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,it)|0,i=i+Math.imul(_,st)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(w,st)|0,s=s+Math.imul(w,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,i=i+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,dt)|0)+Math.imul(m,ut)|0,s=s+Math.imul(m,dt)|0;var Tt=(l+(i=i+Math.imul(u,pt)|0)|0)+((8191&(n=(n=n+Math.imul(u,mt)|0)+Math.imul(d,pt)|0))<<13)|0;l=((s=s+Math.imul(d,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(x,z),n=(n=Math.imul(x,W))+Math.imul(F,z)|0,s=Math.imul(F,W),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,Y)|0)+Math.imul(D,q)|0,s=s+Math.imul(D,Y)|0,i=i+Math.imul(R,$)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(P,$)|0,s=s+Math.imul(P,X)|0,i=i+Math.imul(O,J)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(N,J)|0,s=s+Math.imul(N,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(I,rt)|0,s=s+Math.imul(I,it)|0,i=i+Math.imul(A,st)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,lt)|0)+Math.imul(w,ht)|0,s=s+Math.imul(w,lt)|0,i=i+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(v,ut)|0,s=s+Math.imul(v,dt)|0;var Mt=(l+(i=i+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(x,q),n=(n=Math.imul(x,Y))+Math.imul(F,q)|0,s=Math.imul(F,Y),i=i+Math.imul(k,$)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(D,$)|0,s=s+Math.imul(D,X)|0,i=i+Math.imul(R,J)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(O,rt)|0,n=(n=n+Math.imul(O,it)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,it)|0,i=i+Math.imul(M,st)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(I,st)|0,s=s+Math.imul(I,at)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,i=i+Math.imul(_,ut)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(w,ut)|0,s=s+Math.imul(w,dt)|0;var It=(l+(i=i+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(x,$),n=(n=Math.imul(x,X))+Math.imul(F,$)|0,s=Math.imul(F,X),i=i+Math.imul(k,J)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,tt)|0,i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(O,st)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,at)|0,i=i+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,lt)|0)+Math.imul(I,ht)|0,s=s+Math.imul(I,lt)|0,i=i+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,dt)|0)+Math.imul(S,ut)|0,s=s+Math.imul(S,dt)|0;var Ct=(l+(i=i+Math.imul(_,pt)|0)|0)+((8191&(n=(n=n+Math.imul(_,mt)|0)+Math.imul(w,pt)|0))<<13)|0;l=((s=s+Math.imul(w,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(x,J),n=(n=Math.imul(x,tt))+Math.imul(F,J)|0,s=Math.imul(F,tt),i=i+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,it)|0)+Math.imul(D,rt)|0,s=s+Math.imul(D,it)|0,i=i+Math.imul(R,st)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,at)|0,i=i+Math.imul(O,ht)|0,n=(n=n+Math.imul(O,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,i=i+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(I,ut)|0,s=s+Math.imul(I,dt)|0;var Ot=(l+(i=i+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(x,rt),n=(n=Math.imul(x,it))+Math.imul(F,rt)|0,s=Math.imul(F,it),i=i+Math.imul(k,st)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,at)|0,i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,i=i+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,dt)|0)+Math.imul(N,ut)|0,s=s+Math.imul(N,dt)|0;var Nt=(l+(i=i+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,mt)|0)+Math.imul(I,pt)|0))<<13)|0;l=((s=s+Math.imul(I,mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(x,st),n=(n=Math.imul(x,at))+Math.imul(F,st)|0,s=Math.imul(F,at),i=i+Math.imul(k,ht)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(D,ht)|0,s=s+Math.imul(D,lt)|0,i=i+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ut)|0,s=s+Math.imul(P,dt)|0;var Lt=(l+(i=i+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,i=Math.imul(x,ht),n=(n=Math.imul(x,lt))+Math.imul(F,ht)|0,s=Math.imul(F,lt),i=i+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,dt)|0)+Math.imul(D,ut)|0,s=s+Math.imul(D,dt)|0;var Rt=(l+(i=i+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(x,ut),n=(n=Math.imul(x,dt))+Math.imul(F,ut)|0,s=Math.imul(F,dt);var Pt=(l+(i=i+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,mt)|0)+Math.imul(D,pt)|0))<<13)|0;l=((s=s+Math.imul(D,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863;var Bt=(l+(i=Math.imul(x,pt))|0)+((8191&(n=(n=Math.imul(x,mt))+Math.imul(F,pt)|0))<<13)|0;return l=((s=Math.imul(F,mt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=_t,h[5]=wt,h[6]=Et,h[7]=At,h[8]=St,h[9]=Tt,h[10]=Mt,h[11]=It,h[12]=Ct,h[13]=Ot,h[14]=Nt,h[15]=Lt,h[16]=Rt,h[17]=Pt,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(f=d),n.prototype.mulTo=function(t,e){var r,i=this.length+t.length;return r=10===this.length&&10===t.length?f(this,t,e):i<63?d(this,t,e):i<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,a&=67108863}r.words[s]=o,i=a,a=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,t,e):p(this,t,e),r},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=n.prototype._countBits(t)-1,i=0;i>=1;return i},m.prototype.permute=function(t,e,r,i,n,s){for(var a=0;a>>=1)n++;return 1<>>=13,i[2*a+1]=8191&s,s>>>=13;for(a=2*e;a>=26,e+=n/67108864|0,e+=s>>>26,this.words[i]=67108863&s}return 0!==e&&(this.words[i]=e,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>n}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i=0);var e,i=t%26,n=(t-i)/26,s=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e=0),n=e?(e-e%26)/26:0;var s=t%26,a=Math.min((t-s)/26,this.length),o=67108863^67108863>>>s<a)for(this.length-=a,l=0;l=0&&(0!==c||l>=n);l--){var u=0|this.words[l];this.words[l]=c<<26-s|u>>>s,c=u&o}return h&&0!==c&&(h.words[h.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r('number'==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,'imaskn works only with positive numbers'),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r('number'==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[n+i]=67108863&a}for(;n>26,this.words[n+i]=67108863&a;if(0===o)return this.strip();for(r(-1===o),o=0,n=0;n>26,this.words[n]=67108863&a;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),s=t,a=0|s.words[s.length-1];0!==(r=26-this._countBits(a))&&(s=s.ushln(r),i.iushln(r),a=0|s.words[s.length-1]);var o,h=i.length-s.length;if('mod'!==e){(o=new n(null)).length=h+1,o.words=new Array(o.length);for(var l=0;l=0;u--){var d=67108864*(0|i.words[s.length+u])+(0|i.words[s.length+u-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(s,d,u);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(s,1,u),i.isZero()||(i.negative^=1);o&&(o.words[u]=d)}return o&&o.strip(),i.strip(),'div'!==e&&0!==r&&i.iushrn(r),{div:o||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),'mod'!==e&&(s=o.div.neg()),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:s,mod:a}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),'mod'!==e&&(s=o.div.neg()),{div:s,mod:o.mod}):this.negative&t.negative?(o=this.neg().divmod(t.neg(),e),'div'!==e&&(a=o.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:o.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?'div'===e?{div:this.divn(t.words[0]),mod:null}:'mod'===e?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,e);var s,a,o},n.prototype.div=function(t){return this.divmod(t,'div',!1).div},n.prototype.mod=function(t){return this.divmod(t,'mod',!1).mod},n.prototype.umod=function(t){return this.divmod(t,'mod',!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,i=0,n=this.length-1;n>=0;n--)i=(e*i+(0|this.words[n]))%t;return i},n.prototype.idivn=function(t){r(t<=67108863);for(var e=0,i=this.length-1;i>=0;i--){var n=(0|this.words[i])+67108864*e;this.words[i]=n/t|0,e=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var s=new n(1),a=new n(0),o=new n(0),h=new n(1),l=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++l;for(var c=i.clone(),u=e.clone();!e.isZero();){for(var d=0,f=1;!(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(s.isOdd()||a.isOdd())&&(s.iadd(c),a.isub(u)),s.iushrn(1),a.iushrn(1);for(var p=0,m=1;!(i.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(o.isOdd()||h.isOdd())&&(o.iadd(c),h.isub(u)),o.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),s.isub(o),a.isub(h)):(i.isub(e),o.isub(s),h.isub(a))}return{a:o,b:h,gcd:i.iushln(l)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e,i=this,s=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var a=new n(1),o=new n(0),h=s.clone();i.cmpn(1)>0&&s.cmpn(1)>0;){for(var l=0,c=1;!(i.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(i.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var u=0,d=1;!(s.words[0]&d)&&u<26;++u,d<<=1);if(u>0)for(s.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);i.cmp(s)>=0?(i.isub(s),a.isub(o)):(s.isub(i),o.isub(a))}return(e=0===i.cmpn(1)?a:o).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var s=e;e=r,r=s}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r('number'==typeof t);var e=t%26,i=(t-e)/26,n=1<>>26,o&=67108863,this.words[a]=o}return 0!==s&&(this.words[a]=s,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,'Number is too big');var n=0|this.words[0];e=n===t?0:nt.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){in&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,'Already a number in reduction context'),r(0===this.negative,'red works only with positives'),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,'fromRed works only with numbers in reduction context'),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,'Already a number in reduction context'),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,'redAdd works only with red numbers'),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,'redIAdd works only with red numbers'),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,'redSub works only with red numbers'),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,'redISub works only with red numbers'),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,'redShl works only with red numbers'),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,'redMul works only with red numbers'),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,'redSqr works only with red numbers'),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,'redISqr works only with red numbers'),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,'redSqrt works only with red numbers'),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,'redInvm works only with red numbers'),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,'redNeg works only with red numbers'),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,'redPow(normalNum)'),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f')}function b(){y.call(this,'p224','ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001')}function _(){y.call(this,'p192','ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff')}function w(){y.call(this,'25519','7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed')}function E(t){if('string'==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),'modulus must be greater than 1'),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(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)}y.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},i(v,y),v.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n>>22,s=a}s>>>=22,t.words[n-10]=s,0===s&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(g[t])return g[t];var e;if('k256'===t)e=new v;else if('p224'===t)e=new b;else if('p192'===t)e=new _;else{if('p25519'!==t)throw new Error('Unknown prime '+t);e=new w}return g[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,'red works only with positives'),r(t.red,'red works only with red numbers')},E.prototype._verify2=function(t,e){r(!(t.negative|e.negative),'red works only with positives'),r(t.red&&t.red===e.red,'red works only with red numbers')},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var s=this.m.subn(1),a=0;!s.isZero()&&0===s.andln(1);)a++,s.iushrn(1);r(!s.isZero());var o=new n(1).toRed(this),h=o.redNeg(),l=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);0!==this.pow(c,l).cmp(h);)c.redIAdd(h);for(var u=this.pow(c,s),d=this.pow(t,s.addn(1).iushrn(1)),f=this.pow(t,s),p=a;0!==f.cmp(o);){for(var m=f,g=0;0!==m.cmp(o);g++)m=m.redSqr();r(g=0;i--){for(var l=e.words[i],c=h-1;c>=0;c--){var u=l>>c&1;(s!==r[0]&&(s=this.sqr(s)),0!==u||0!==a)?(a<<=1,a|=u,(4===++o||0===i&&0===c)&&(s=this.mul(s,r[a]),o=0,a=0)):o=0}h=26}return s},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(i).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(typeof e>'u'||e,t)})),Si=P(((t,e)=>{var r=Ai(),i=V().Buffer;e.exports=function(t,e){return i.from(t.toRed(r.mont(e.modulus)).redPow(new r(e.publicExponent)).fromRed().toArray())}})),Ti=P(((t,e)=>{var r=pi(),i=G(),n=ie(),s=wi(),a=Ei(),o=Ai(),h=Si(),l=gr(),c=V().Buffer;e.exports=function(t,e,u){var d;d=t.padding?t.padding:u?1:4;var f,p=r(t);if(4===d)f=function(t,e){var r=t.modulus.byteLength(),h=e.length,l=n('sha1').update(c.alloc(0)).digest(),u=l.length,d=2*u;if(h>r-d-2)throw new Error('message too long');var f=c.alloc(r-h-d-2),p=r-u-1,m=i(u),g=a(c.concat([l,f,c.alloc(1,1),e],p),s(m,p)),y=a(m,s(g,u));return new o(c.concat([c.alloc(1),y,g],r))}(p,e);else if(1===d)f=function(t,e,r){var n,s=e.length,a=t.modulus.byteLength();if(s>a-11)throw new Error('message too long');return n=r?c.alloc(a-s-3,255):function(t){for(var e,r=c.allocUnsafe(t),n=0,s=i(2*t),a=0;n=0)throw new Error('data too long for modulus')}return u?l(f,p):h(f,p)}})),Mi=P(((t,e)=>{var r=pi(),i=wi(),n=Ei(),s=Ai(),a=gr(),o=ie(),h=Si(),l=V().Buffer;e.exports=function(t,e,c){var u;u=t.padding?t.padding:c?1:4;var d,f=r(t),p=f.modulus.byteLength();if(e.length>p||new s(e).cmp(f.modulus)>=0)throw new Error('decryption error');d=c?h(new s(e),f):a(e,f);var m=l.alloc(p-d.length);if(d=l.concat([m,d],p),4===u)return function(t,e){var r=t.modulus.byteLength(),s=o('sha1').update(l.alloc(0)).digest(),a=s.length;if(0!==e[0])throw new Error('decryption error');var h=e.slice(1,a+1),c=e.slice(a+1),u=n(h,i(c,a)),d=n(c,i(u,r-a-1));if(function(t,e){t=l.from(t),e=l.from(e);var r=0,i=t.length;t.length!==e.length&&(r++,i=Math.min(t.length,e.length));for(var n=-1;++n=e.length){s++;break}var a=e.slice(2,n-1);if(('0002'!==i.toString('hex')&&!r||'0001'!==i.toString('hex')&&r)&&s++,a.length<8&&s++,s)throw new Error('decryption error');return e.slice(n)}(0,d,c);if(3===u)return d;throw new Error('unknown padding')}})),Ii=P((t=>{t.publicEncrypt=Ti(),t.privateDecrypt=Mi(),t.privateEncrypt=function(e,r){return t.publicEncrypt(e,r,!0)},t.publicDecrypt=function(e,r){return t.privateDecrypt(e,r,!0)}})),Ci=P((t=>{function e(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var r=V(),i=(G(),r.Buffer),n=r.kMaxLength,s=global.crypto||global.msCrypto,a=Math.pow(2,32)-1;function o(t,e){if('number'!=typeof t||t!=t)throw new TypeError('offset must be a number');if(t>a||t<0)throw new TypeError('offset must be a uint32');if(t>n||t>e)throw new RangeError('offset out of range')}function h(t,e,r){if('number'!=typeof t||t!=t)throw new TypeError('size must be a number');if(t>a||t<0)throw new TypeError('size must be a uint32');if(t+e>r||t>n)throw new RangeError('buffer too small')}function l(t,e,r,i){var n=t.buffer,a=new Uint8Array(n,e,r);return s.getRandomValues(a),i?void process.nextTick((function(){i(null,t)})):t}s&&s.getRandomValues?(t.randomFill=function(t,e,r,n){if(!(i.isBuffer(t)||t instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if('function'==typeof e)n=e,e=0,r=t.length;else if('function'==typeof r)n=r,r=t.length-e;else if('function'!=typeof n)throw new TypeError('"cb" argument must be a function');return o(e,t.length),h(r,e,t.length),l(t,e,r,n)},t.randomFillSync=function(t,e,r){if(typeof e>'u'&&(e=0),!(i.isBuffer(t)||t instanceof global.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return o(e,t.length),void 0===r&&(r=t.length-e),h(r,e,t.length),l(t,e,r)}):(t.randomFill=e,t.randomFillSync=e)})),Oi=P((t=>{t.randomBytes=t.rng=t.pseudoRandomBytes=t.prng=G(),t.createHash=t.Hash=ie(),t.createHmac=t.Hmac=ae();var e=he(),r=Object.keys(e),i=['sha1','sha224','sha256','sha384','sha512','md5','rmd160'].concat(r);t.getHashes=function(){return i};var n=pe();t.pbkdf2=n.pbkdf2,t.pbkdf2Sync=n.pbkdf2Sync;var s=Ge();t.Cipher=s.Cipher,t.createCipher=s.createCipher,t.Cipheriv=s.Cipheriv,t.createCipheriv=s.createCipheriv,t.Decipher=s.Decipher,t.createDecipher=s.createDecipher,t.Decipheriv=s.Decipheriv,t.createDecipheriv=s.createDecipheriv,t.getCiphers=s.getCiphers,t.listCiphers=s.listCiphers;var a=Je();t.DiffieHellmanGroup=a.DiffieHellmanGroup,t.createDiffieHellmanGroup=a.createDiffieHellmanGroup,t.getDiffieHellman=a.getDiffieHellman,t.createDiffieHellman=a.createDiffieHellman,t.DiffieHellman=a.DiffieHellman;var o=vi();t.createSign=o.createSign,t.Sign=o.Sign,t.createVerify=o.createVerify,t.Verify=o.Verify,t.createECDH=_i();var h=Ii();t.publicEncrypt=h.publicEncrypt,t.privateEncrypt=h.privateEncrypt,t.publicDecrypt=h.publicDecrypt,t.privateDecrypt=h.privateDecrypt;var l=Ci();t.randomFill=l.randomFill,t.randomFillSync=l.randomFillSync,t.createCredentials=function(){throw new Error(['sorry, createCredentials is not implemented yet','we accept pull requests','https://github.com/crypto-browserify/crypto-browserify'].join("\n"))},t.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}})),B(Ni={},{DEFAULT_ENCODING:()=>Ri,default:()=>Hi,getCurves:()=>T,getRandomValues:()=>Pi,randomUUID:()=>Bi,scrypt:()=>xi,scryptSync:()=>Ui,timingSafeEqual:()=>Di,webcrypto:()=>Fi}),D(Ni,U(Oi())),Li=U(Oi()),Ri='buffer',Pi=t=>crypto.getRandomValues(t),Bi=()=>crypto.randomUUID(),ki=['p192','p224','p256','p384','p521','curve25519','ed25519','secp256k1','secp224r1','prime256v1','prime192v1','ed25519','secp384r1','secp521r1'],Di='timingSafeEqual'in crypto?(t,e)=>{let{byteLength:r}=t,{byteLength:i}=e;if('number'!=typeof r||'number'!=typeof i)throw new TypeError('Input must be an array buffer view');if(r!==i)throw new RangeError('Input buffers must have the same length');return crypto.timingSafeEqual(t,e)}:void 0,Ui='scryptSync'in crypto?(t,e,r,i)=>{let n=crypto.scryptSync(t,e,r,i);return'buffer'!==Ri?new Buffer(n).toString(Ri):new Buffer(n)}:void 0,xi='scryptSync'in crypto?function(t,e,r,i,n){if('function'==typeof i&&(n=i,i=void 0),'function'!=typeof n){var s=new TypeError('callback must be a function');throw s.code='ERR_INVALID_CALLBACK',s}try{let s=crypto.scryptSync(t,e,r,i);process.nextTick(n,null,'buffer'!==Ri?new Buffer(s).toString(Ri):new Buffer(s))}catch(t){throw t}}:void 0,Di&&(Object.defineProperty(Di,'name',{value:'::bunternal::'}),Object.defineProperty(xi,'name',{value:'::bunternal::'}),Object.defineProperty(Ui,'name',{value:'::bunternal::'})),Fi=crypto,Hi={...Li,getRandomValues:Pi,randomUUID:Bi,timingSafeEqual:Di,scryptSync:Ui,scrypt:xi,webcrypto:Fi,getCurves:T}})),hn=w(((t,e)=>{var r=Vi();Xi(),$i(),zi();var i,n=r.pkcs5=r.pkcs5||{};r.util.isNodejs&&!r.options.usePureJavaScript&&(on(),i=_(en)),e.exports=r.pbkdf2=n.pbkdf2=function(t,e,n,s,a,o){if('function'==typeof a&&(o=a,a=null),r.util.isNodejs&&!r.options.usePureJavaScript&&i.pbkdf2&&(null===a||'object'!=typeof a)&&(i.pbkdf2Sync.length>4||!a||'sha1'===a))return'string'!=typeof a&&(a='sha1'),t=Buffer.from(t,'binary'),e=Buffer.from(e,'binary'),o?4===i.pbkdf2Sync.length?i.pbkdf2(t,e,n,s,(function(t,e){if(t)return o(t);o(null,e.toString('binary'))})):i.pbkdf2(t,e,n,s,a,(function(t,e){if(t)return o(t);o(null,e.toString('binary'))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(t,e,n,s).toString('binary'):i.pbkdf2Sync(t,e,n,s,a).toString('binary');if(null==a&&(a='sha1'),'string'==typeof a){if(!(a in r.md.algorithms))throw new Error('Unknown hash algorithm: '+a);a=r.md[a].create()}var h=a.digestLength;if(s>4294967295*h){var l=new Error('Derived key is too long.');if(o)return o(l);throw l}var c=Math.ceil(s/h),u=s-(c-1)*h,d=r.hmac.create();d.start(a,t);var f,p,m,g='';if(!o){for(var y=1;y<=c;++y){d.start(null,null),d.update(e),d.update(r.util.int32ToBytes(y)),f=m=d.digest().getBytes();for(var v=2;v<=n;++v)d.start(null,null),d.update(m),p=d.digest().getBytes(),f=r.util.xorBytes(f,p,h),m=p;g+=yc)return o(null,g);d.start(null,null),d.update(e),d.update(r.util.int32ToBytes(y)),f=m=d.digest().getBytes(),v=2,_()}function _(){if(v<=n)return d.start(null,null),d.update(m),p=d.digest().getBytes(),f=r.util.xorBytes(f,p,h),m=p,++v,r.util.setImmediate(_);g+=y{var r=function(t,e,r){for(var i,n,s,a,h,l,c,u,d,f,p,m,g,y=r.length();y>=64;){for(h=0;h<16;++h)e[h]=r.getInt32();for(;h<64;++h)i=((i=e[h-2])>>>17|i<<15)^(i>>>19|i<<13)^i>>>10,n=((n=e[h-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,e[h]=i+e[h-7]+n+e[h-16]|0;for(l=t.h0,c=t.h1,u=t.h2,d=t.h3,f=t.h4,p=t.h5,m=t.h6,g=t.h7,h=0;h<64;++h)s=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),a=l&c|u&(l^c),i=g+((f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(m^f&(p^m))+o[h]+e[h],g=m,m=p,p=f,f=d+i>>>0,d=u,u=c,c=l,l=i+(n=s+a)>>>0;t.h0=t.h0+l|0,t.h1=t.h1+c|0,t.h2=t.h2+u|0,t.h3=t.h3+d|0,t.h4=t.h4+f|0,t.h5=t.h5+p|0,t.h6=t.h6+m|0,t.h7=t.h7+g|0,y-=64}},i=Vi();$i(),zi();var n=e.exports=i.sha256=i.sha256||{};i.md.sha256=i.md.algorithms.sha256=n,n.create=function(){a||(s=String.fromCharCode(128),s+=i.util.fillString(String.fromCharCode(0),64),o=[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],a=!0);var t=null,e=i.util.createBuffer(),n=new Array(64),h={algorithm:'sha256',blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){h.messageLength=0,h.fullMessageLength=h.messageLength64=[];for(var r=h.messageLengthSize/4,n=0;n>>0,o>>>0];for(var l=h.fullMessageLength.length-1;l>=0;--l)h.fullMessageLength[l]+=o[1],o[1]=o[0]+(h.fullMessageLength[l]/4294967296>>>0),h.fullMessageLength[l]=h.fullMessageLength[l]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(s),r(t,n,e),(e.read>2048||0===e.length())&&e.compact(),h},h.digest=function(){var a=i.util.createBuffer();a.putBytes(e.bytes());var o,l=h.fullMessageLength[h.fullMessageLength.length-1]+h.messageLengthSize&h.blockLength-1;a.putBytes(s.substr(0,h.blockLength-l));for(var c=8*h.fullMessageLength[0],u=0;u>>0,a.putInt32(c>>>0),c=o>>>0;a.putInt32(c);var d={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};r(d,n,a);var f=i.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f.putInt32(d.h5),f.putInt32(d.h6),f.putInt32(d.h7),f},h};var s=null,a=!1,o=null})),cn=w(((t,e)=>{var r=Vi();zi();var i=null;!r.util.isNodejs||r.options.usePureJavaScript||process.versions['node-webkit']||(on(),i=_(en)),(e.exports=r.prng=r.prng||{}).create=function(t){for(var e={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:''},n=t.md,s=new Array(32),a=0;a<32;++a)s[a]=n.create();function o(){if(e.pools[0].messageLength>=32)return h();var t=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(t)),h()}function h(){e.reseeds=4294967295===e.reseeds?0:e.reseeds+1;var t=e.plugin.md.create();t.update(e.keyBytes);for(var r=1,i=0;i<32;++i)e.reseeds%r==0&&(t.update(e.pools[i].digest().getBytes()),e.pools[i].start()),r<<=1;e.keyBytes=t.digest().getBytes(),t.start(),t.update(e.keyBytes);var n=t.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(n),e.generated=0}function l(t){var e=null,i=r.util.globalScope,n=i.crypto||i.msCrypto;n&&n.getRandomValues&&(e=function(t){return n.getRandomValues(t)});var s=r.util.createBuffer();if(e)for(;s.length()>16)))<<16,d=4294967295&(c=(2147483647&(c+=l>>15))+(c>>31));for(h=0;h<3;++h)u=d>>>(h<<3),u^=Math.floor(256*Math.random()),s.putByte(255&u)}return s.getBytes(t)}return e.pools=s,e.pool=0,e.generate=function(t,i){if(!i)return e.generateSync(t);var n=e.plugin.cipher,s=e.plugin.increment,a=e.plugin.formatKey,o=e.plugin.formatSeed,l=r.util.createBuffer();e.key=null,function c(u){if(u)return i(u);if(l.length()>=t)return i(null,l.getBytes(t));e.generated>1048575&&(e.key=null);if(null===e.key)return r.util.nextTick((function(){!function(t){if(e.pools[0].messageLength>=32)return h(),t();var r=32-e.pools[0].messageLength<<5;e.seedFile(r,(function(r,i){if(r)return t(r);e.collect(i),h(),t()}))}(c)}));var d=n(e.key,e.seed);e.generated+=d.length,l.putBytes(d),e.key=a(n(e.key,s(e.seed))),e.seed=o(n(e.key,e.seed)),r.util.setImmediate(c)}()},e.generateSync=function(t){var i=e.plugin.cipher,n=e.plugin.increment,s=e.plugin.formatKey,a=e.plugin.formatSeed;e.key=null;for(var h=r.util.createBuffer();h.length()1048575&&(e.key=null),null===e.key&&o();var l=i(e.key,e.seed);e.generated+=l.length,h.putBytes(l),e.key=s(i(e.key,n(e.seed))),e.seed=a(i(e.key,e.seed))}return h.getBytes(t)},i?(e.seedFile=function(t,e){i.randomBytes(t,(function(t,r){if(t)return e(t);e(null,r.toString())}))},e.seedFileSync=function(t){return i.randomBytes(t).toString()}):(e.seedFile=function(t,e){try{e(null,l(t))}catch(t){e(t)}},e.seedFileSync=l),e.collect=function(t){for(var r=t.length,i=0;i>n&255);e.collect(i)},e.registerWorker=function(t){if(t===self)e.seedFile=function(t,e){self.addEventListener('message',(function t(r){var i=r.data;i.forge&&i.forge.prng&&(self.removeEventListener('message',t),e(i.forge.prng.err,i.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:t}}})};else{t.addEventListener('message',(function(r){var i=r.data;i.forge&&i.forge.prng&&e.seedFile(i.forge.prng.needed,(function(e,r){t.postMessage({forge:{prng:{err:e,bytes:r}}})}))}))}},e}})),un=w(((t,e)=>{var r=Vi();qi(),ln(),cn(),zi(),r.random&&r.random.getBytes?e.exports=r.random:function(t){var i={},n=new Array(4),s=r.util.createBuffer();function a(){var t=r.prng.create(i);return t.getBytes=function(e,r){return t.generate(e,r)},t.getBytesSync=function(e){return t.generate(e)},t}i.formatKey=function(t){var e=r.util.createBuffer(t);return(t=new Array(4))[0]=e.getInt32(),t[1]=e.getInt32(),t[2]=e.getInt32(),t[3]=e.getInt32(),r.aes._expandKey(t,!1)},i.formatSeed=function(t){var e=r.util.createBuffer(t);return(t=new Array(4))[0]=e.getInt32(),t[1]=e.getInt32(),t[2]=e.getInt32(),t[3]=e.getInt32(),t},i.cipher=function(t,e){return r.aes._updateBlock(t,e,n,!1),s.putInt32(n[0]),s.putInt32(n[1]),s.putInt32(n[2]),s.putInt32(n[3]),s.getBytes()},i.increment=function(t){return++t[3],t},i.md=r.md.sha256;var o=a(),h=null,l=r.util.globalScope,c=l.crypto||l.msCrypto;if(c&&c.getRandomValues&&(h=function(t){return c.getRandomValues(t)}),r.options.usePureJavaScript||!r.util.isNodejs&&!h){if('undefined'==typeof window||window.document,o.collectInt(+new Date,32),'undefined'!=typeof navigator){var u='';for(var d in navigator)try{'string'==typeof navigator[d]&&(u+=navigator[d])}catch(t){}o.collect(u),u=null}t&&(t().mousemove((function(t){o.collectInt(t.clientX,16),o.collectInt(t.clientY,16)})),t().keypress((function(t){o.collectInt(t.charCode,8)})))}if(r.random)for(var d in o)r.random[d]=o[d];else r.random=o;r.random.createInstance=a,e.exports=r.random}('undefined'!=typeof jQuery?jQuery:null)})),dn=w(((t,e)=>{var r=Vi();zi();var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],n=[1,2,3,5],s=function(t,e){return t<>16-e},a=function(t,e){return(65535&t)>>e|t<<16-e&65535};e.exports=r.rc2=r.rc2||{},r.rc2.expandKey=function(t,e){'string'==typeof t&&(t=r.util.createBuffer(t)),e=e||128;var n,s=t,a=t.length(),o=e,h=Math.ceil(o/8),l=255>>(7&o);for(n=a;n<128;n++)s.putByte(i[s.at(n-1)+s.at(n-a)&255]);for(s.setAt(128-h,i[s.at(128-h)&l]),n=127-h;n>=0;n--)s.setAt(n,i[s.at(n+1)^s.at(n+h)]);return s};var o=function(t,e,i){var o,h,l,c,u=!1,d=null,f=null,p=null,m=[];for(t=r.rc2.expandKey(t,e),l=0;l<64;l++)m.push(t.getInt16Le());i?(o=function(t){for(l=0;l<4;l++)t[l]+=m[c]+(t[(l+3)%4]&t[(l+2)%4])+(~t[(l+3)%4]&t[(l+1)%4]),t[l]=s(t[l],n[l]),c++},h=function(t){for(l=0;l<4;l++)t[l]+=m[63&t[(l+3)%4]]}):(o=function(t){for(l=3;l>=0;l--)t[l]=a(t[l],n[l]),t[l]-=m[c]+(t[(l+3)%4]&t[(l+2)%4])+(~t[(l+3)%4]&t[(l+1)%4]),c--},h=function(t){for(l=3;l>=0;l--)t[l]-=m[63&t[(l+3)%4]]});var g=function(t){var e=[];for(l=0;l<4;l++){var r=d.getInt16Le();null!==p&&(i?r^=p.getInt16Le():p.putInt16Le(r)),e.push(65535&r)}c=i?0:63;for(var n=0;n=8;)g([[5,o],[1,h],[6,o],[1,h],[5,o]])},finish:function(t){var e=!0;if(i)if(t)e=t(8,d,!i);else{var r=8===d.length()?8:8-d.length();d.fillWithByte(r,r)}if(e&&(u=!0,y.update()),!i&&(e=0===d.length()))if(t)e=t(8,f,!i);else{var n=f.length(),s=f.at(n-1);s>n?e=!1:f.truncate(s)}return e}}};r.rc2.startEncrypting=function(t,e,i){var n=r.rc2.createEncryptionCipher(t,128);return n.start(e,i),n},r.rc2.createEncryptionCipher=function(t,e){return o(t,e,!0)},r.rc2.startDecrypting=function(t,e,i){var n=r.rc2.createDecryptionCipher(t,128);return n.start(e,i),n},r.rc2.createDecryptionCipher=function(t,e){return o(t,e,!1)}})),fn=w(((t,e)=>{var r,i=function(t,e,r){this.data=[],null!=t&&('number'==typeof t?this.fromNumber(t,e,r):null==e&&'string'!=typeof t?this.fromString(t,256):this.fromString(t,e))},n=function(){return new i(null)},s=function(t,e,r,i,n,s){for(var a=16383&e,o=e>>14;--s>=0;){var h=16383&this.data[t],l=this.data[t++]>>14,c=o*h+l*a;n=((h=a*h+((16383&c)<<14)+r.data[i]+n)>>28)+(c>>14)+o*l,r.data[i++]=268435455&h}return n},a=function(t){return T.charAt(t)},o=function(t,e){var r=M[t.charCodeAt(e)];return null==r?-1:r},h=function(t){var e=n();return e.fromInt(t),e},l=function(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r},c=function(t){this.m=t},u=function(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e},y=function(t){for(var e=0;0!=t;)t&=t-1,++e;return e},v=function(){},b=function(t){return t},_=function(t){this.r2=n(),this.q3=n(),i.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t},w=function(){return{nextBytes:function(t){for(var e=0;e>15;--s>=0;){var h=32767&this.data[t],l=this.data[t++]>>15,c=o*h+l*a;n=((h=a*h+((32767&c)<<15)+r.data[i]+(1073741823&n))>>>30)+(c>>>15)+o*l+(n>>>30),r.data[i++]=1073741823&h}return n},r=30):'Netscape'!=navigator.appName?(i.prototype.am=function(t,e,r,i,n,s){for(;--s>=0;){var a=e*this.data[t++]+r.data[i]+n;n=Math.floor(a/67108864),r.data[i++]=67108863&a}return n},r=26):(i.prototype.am=s,r=28),i.prototype.DB=r,i.prototype.DM=(1<=0?t.mod(this.m):t},c.prototype.revert=function(t){return t},c.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},c.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},c.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},u.prototype.convert=function(t){var e=n();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(i.ZERO)>0&&this.m.subTo(e,e),e},u.prototype.revert=function(t){var e=n();return t.copyTo(e),this.reduce(e),e},u.prototype.reduce=function(t){for(;t.t<=this.mt2;)t.data[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t.data[r]+=this.m.am(0,i,t,e,0,this.m.t);t.data[r]>=t.DV;)t.data[r]-=t.DV,t.data[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},u.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},u.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},i.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t.data[e]=this.data[e];t.t=this.t,t.s=this.s},i.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this.data[0]=t:t<-1?this.data[0]=t+this.DV:this.t=0},i.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,s=!1,a=0;--n>=0;){var h=8==r?255&t[n]:o(t,n);h<0?'-'==t.charAt(n)&&(s=!0):(s=!1,0==a?this.data[this.t++]=h:a+r>this.DB?(this.data[this.t-1]|=(h&(1<>this.DB-a):this.data[this.t-1]|=h<=this.DB&&(a-=this.DB))}8==r&&128&t[0]&&(this.s=-1,a>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==t;)--this.t},i.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e.data[r+t]=this.data[r];for(r=t-1;r>=0;--r)e.data[r]=0;e.t=this.t+t,e.s=this.s},i.prototype.drShiftTo=function(t,e){for(var r=t;r=0;--r)e.data[r+a+1]=this.data[r]>>n|o,o=(this.data[r]&s)<=0;--r)e.data[r]=0;e.data[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},i.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,n=this.DB-i,s=(1<>i;for(var a=r+1;a>i;i>0&&(e.data[this.t-r-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e.data[r++]=this.DV+i:i>0&&(e.data[r++]=i),e.t=r,e.clamp()},i.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),s=r.t;for(e.t=s+n.t;--s>=0;)e.data[s]=0;for(s=0;s=0;)t.data[r]=0;for(r=0;r=e.DV&&(t.data[r+e.t]-=e.DV,t.data[r+e.t+1]=1)}t.t>0&&(t.data[t.t-1]+=e.am(r,e.data[r],t,2*r,0,1)),t.s=0,t.clamp()},i.prototype.divRemTo=function(t,e,r){var s=t.abs();if(!(s.t<=0)){var a=this.abs();if(a.t0?(s.lShiftTo(u,o),a.lShiftTo(u,r)):(s.copyTo(o),a.copyTo(r));var d=o.t,f=o.data[d-1];if(0!=f){var p=f*(1<1?o.data[d-2]>>this.F2:0),m=this.FV/p,g=(1<=0&&(r.data[r.t++]=1,r.subTo(_,r)),i.ONE.dlShiftTo(d,_),_.subTo(o,o);o.t=0;){var w=r.data[--v]==f?this.DM:Math.floor(r.data[v]*m+(r.data[v-1]+y)*g);if((r.data[v]+=o.am(0,w,r,b,0,d))0&&r.rShiftTo(u,r),h<0&&i.ZERO.subTo(r,r)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var t=this.data[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},i.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},i.prototype.exp=function(t,e){if(t>4294967295||t<1)return i.ONE;var r=n(),s=n(),a=e.convert(this),o=l(t)-1;for(a.copyTo(r);--o>=0;)if(e.sqrTo(r,s),(t&1<0)e.mulTo(s,a,r);else{var h=r;r=s,s=h}return e.revert(r)},i.prototype.toString=function(t){if(this.s<0)return'-'+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<0)for(h>h)>0&&(n=!0,s=a(r));o>=0;)h>(h+=this.DB-e)):(r=this.data[o]>>(h-=e)&i,h<=0&&(h+=this.DB,--o)),r>0&&(n=!0),n&&(s+=a(r));return n?s:'0'},i.prototype.negate=function(){var t=n();return i.ZERO.subTo(this,t),t},i.prototype.abs=function(){return this.s<0?this.negate():this},i.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this.data[r]-t.data[r]))return e;return 0},i.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this.data[this.t-1]^this.s&this.DM)},i.prototype.mod=function(t){var e=n();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(i.ZERO)>0&&t.subTo(e,e),e},i.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new c(e):new u(e),this.exp(t,r)},i.ZERO=h(0),i.ONE=h(1),v.prototype.convert=b,v.prototype.revert=b,v.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},v.prototype.sqrTo=function(t,e){t.squareTo(e)},_.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=n();return t.copyTo(e),this.reduce(e),e},_.prototype.revert=function(t){return t},_.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},_.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var I=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],C=(1<<26)/I[I.length-1];i.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},i.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return'0';var e=this.chunkSize(t),r=Math.pow(t,e),i=h(r),s=n(),a=n(),o='';for(this.divRemTo(i,s,a);s.signum()>0;)o=(r+a.intValue()).toString(t).substr(1)+o,s.divRemTo(i,s,a);return a.intValue().toString(t)+o},i.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),s=!1,a=0,h=0,l=0;l=r&&(this.dMultiply(n),this.dAddOffset(h,0),a=0,h=0))}a>0&&(this.dMultiply(Math.pow(e,a)),this.dAddOffset(h,0)),s&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(t,e,r){if('number'==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(i.ONE.shiftLeft(t-1),f,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(i.ONE.shiftLeft(t-1),this);else{var n=new Array,s=7&t;n.length=1+(t>>3),e.nextBytes(n),s>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e.data[r++]=i:i<-1&&(e.data[r++]=this.DV+i),e.t=r,e.clamp()},i.prototype.dMultiply=function(t){this.data[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},i.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=t;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}},i.prototype.multiplyLowerTo=function(t,e,r){var i,n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;for(i=r.t-this.t;n=0;)r.data[i]=0;for(i=Math.max(e-this.t,0);i0)if(0==e)r=this.data[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this.data[i])%t;return r},i.prototype.millerRabin=function(t){var e=this.subtract(i.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n,s=e.shiftRight(r),a=w(),o=0;o=0);var h=n.modPow(s,this);if(0!=h.compareTo(i.ONE)&&0!=h.compareTo(e)){for(var l=1;l++>24},i.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},i.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},i.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i>i)!=(this.s&this.DM)>>i&&(e[n++]=r|this.s<=0;)i<8?(r=(this.data[t]&(1<>(i+=this.DB-8)):(r=this.data[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&r&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=r);return e},i.prototype.equals=function(t){return 0==this.compareTo(t)},i.prototype.min=function(t){return this.compareTo(t)<0?this:t},i.prototype.max=function(t){return this.compareTo(t)>0?this:t},i.prototype.and=function(t){var e=n();return this.bitwiseTo(t,d,e),e},i.prototype.or=function(t){var e=n();return this.bitwiseTo(t,f,e),e},i.prototype.xor=function(t){var e=n();return this.bitwiseTo(t,p,e),e},i.prototype.andNot=function(t){var e=n();return this.bitwiseTo(t,m,e),e},i.prototype.not=function(){for(var t=n(),e=0;e=this.t?0!=this.s:!!(this.data[e]&1<1){var m=n();for(i.sqrTo(o[1],m);d<=p;)o[d]=n(),i.mulTo(m,o[d-2],o[d]),d+=2}var g,y,v=t.t-1,b=!0,w=n();for(s=l(t.data[v])-1;v>=0;){for(s>=f?g=t.data[v]>>s-f&p:(g=(t.data[v]&(1<0&&(g|=t.data[v-1]>>this.DB+s-f)),d=r;!(1&g);)g>>=1,--d;if((s-=d)<0&&(s+=this.DB,--v),b)o[g].copyTo(a),b=!1;else{for(;d>1;)i.sqrTo(a,w),i.sqrTo(w,a),d-=2;d>0?i.sqrTo(a,w):(y=a,a=w,w=y),i.mulTo(w,o[g],a)}for(;v>=0&&!(t.data[v]&1<=0?(r.subTo(n,r),e&&s.subTo(o,s),a.subTo(l,a)):(n.subTo(r,n),e&&o.subTo(s,o),l.subTo(a,l))}return 0!=n.compareTo(i.ONE)?i.ZERO:l.compareTo(t)>=0?l.subtract(t):l.signum()<0?(l.addTo(t,l),l.signum()<0?l.add(t):l):l},i.prototype.pow=function(t){return this.exp(t,new v)},i.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var n=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(n0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},i.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r.data[0]<=I[I.length-1]){for(e=0;e{var r=function(t,e,r){for(var i,n,s,a,o,h,l,c=r.length();c>=64;){for(n=t.h0,s=t.h1,a=t.h2,o=t.h3,h=t.h4,l=0;l<16;++l)i=r.getInt32(),e[l]=i,i=(n<<5|n>>>27)+(o^s&(a^o))+h+1518500249+i,h=o,o=a,a=(s<<30|s>>>2)>>>0,s=n,n=i;for(;l<20;++l)i=(i=e[l-3]^e[l-8]^e[l-14]^e[l-16])<<1|i>>>31,e[l]=i,i=(n<<5|n>>>27)+(o^s&(a^o))+h+1518500249+i,h=o,o=a,a=(s<<30|s>>>2)>>>0,s=n,n=i;for(;l<32;++l)i=(i=e[l-3]^e[l-8]^e[l-14]^e[l-16])<<1|i>>>31,e[l]=i,i=(n<<5|n>>>27)+(s^a^o)+h+1859775393+i,h=o,o=a,a=(s<<30|s>>>2)>>>0,s=n,n=i;for(;l<40;++l)i=(i=e[l-6]^e[l-16]^e[l-28]^e[l-32])<<2|i>>>30,e[l]=i,i=(n<<5|n>>>27)+(s^a^o)+h+1859775393+i,h=o,o=a,a=(s<<30|s>>>2)>>>0,s=n,n=i;for(;l<60;++l)i=(i=e[l-6]^e[l-16]^e[l-28]^e[l-32])<<2|i>>>30,e[l]=i,i=(n<<5|n>>>27)+(s&a|o&(s^a))+h+2400959708+i,h=o,o=a,a=(s<<30|s>>>2)>>>0,s=n,n=i;for(;l<80;++l)i=(i=e[l-6]^e[l-16]^e[l-28]^e[l-32])<<2|i>>>30,e[l]=i,i=(n<<5|n>>>27)+(s^a^o)+h+3395469782+i,h=o,o=a,a=(s<<30|s>>>2)>>>0,s=n,n=i;t.h0=t.h0+n|0,t.h1=t.h1+s|0,t.h2=t.h2+a|0,t.h3=t.h3+o|0,t.h4=t.h4+h|0,c-=64}},i=Vi();$i(),zi();var n=e.exports=i.sha1=i.sha1||{};i.md.sha1=i.md.algorithms.sha1=n,n.create=function(){a||(s=String.fromCharCode(128),s+=i.util.fillString(String.fromCharCode(0),64),a=!0);var t=null,e=i.util.createBuffer(),n=new Array(80),o={algorithm:'sha1',blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){o.messageLength=0,o.fullMessageLength=o.messageLength64=[];for(var r=o.messageLengthSize/4,n=0;n>>0,h>>>0];for(var l=o.fullMessageLength.length-1;l>=0;--l)o.fullMessageLength[l]+=h[1],h[1]=h[0]+(o.fullMessageLength[l]/4294967296>>>0),o.fullMessageLength[l]=o.fullMessageLength[l]>>>0,h[0]=h[1]/4294967296>>>0;return e.putBytes(s),r(t,n,e),(e.read>2048||0===e.length())&&e.compact(),o},o.digest=function(){var a=i.util.createBuffer();a.putBytes(e.bytes());var h,l=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;a.putBytes(s.substr(0,o.blockLength-l));for(var c=8*o.fullMessageLength[0],u=0;u>>0,a.putInt32(c>>>0),c=h>>>0;a.putInt32(c);var d={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};r(d,n,a);var f=i.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f},o};var s=null,a=!1})),mn=w(((t,e)=>{var r=function(t,e,r){r||(r=i.md.sha1.create());for(var n='',s=Math.ceil(e/r.digestLength),a=0;a>24&255,a>>16&255,a>>8&255,255&a);r.start(),r.update(t+o),n+=r.digest().getBytes()}return n.substring(0,e)},i=Vi();zi(),un(),pn();var n=e.exports=i.pkcs1=i.pkcs1||{};n.encode_rsa_oaep=function(t,e,n){var s,a,o,h;'string'==typeof n?(s=n,a=arguments[3]||void 0,o=arguments[4]||void 0):n&&(s=n.label||void 0,a=n.seed||void 0,o=n.md||void 0,n.mgf1&&n.mgf1.md&&(h=n.mgf1.md)),o?o.start():o=i.md.sha1.create(),h||(h=o);var l=Math.ceil(t.n.bitLength()/8),c=l-2*o.digestLength-2;if(e.length>c)throw(g=new Error('RSAES-OAEP input message length is too long.')).length=e.length,g.maxLength=c,g;s||(s=''),o.update(s,'raw');for(var u=o.digest(),d='',f=c-e.length,p=0;p{var r=Vi();zi(),fn(),un(),function(){if(r.prime)e.exports=r.prime;else{var t=e.exports=r.prime=r.prime||{},i=r.jsbn.BigInteger,n=[6,4,2,4,2,4,6,2],s=new i(null);s.fromInt(30);var a=function(t,e){return t|e};t.generateProbablePrime=function(t,e,n){'function'==typeof e&&(n=e,e={});var s=(e=e||{}).algorithm||'PRIMEINC';'string'==typeof s&&(s={name:s}),s.options=s.options||{};var a=e.prng||r.random,h={nextBytes:function(t){for(var e=a.getBytesSync(t.length),r=0;rt&&(a=l(t,e));var f=a.toString(16);n.target.postMessage({hex:f,workLoad:c}),a.dAddOffset(u,0)}}}f()}(t,e,n,s);return o(t,e,n,s)}(t,h,s.options,n);throw new Error('Invalid prime generation algorithm: '+s.name)}}function o(t,e,r,i){var n=l(t,e),s=function(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}(n.bitLength());'millerRabinTests'in r&&(s=r.millerRabinTests);var a=10;'maxBlockTime'in r&&(a=r.maxBlockTime),h(n,t,e,0,s,a,i)}function h(t,e,i,s,a,o,c){var u=+new Date;do{if(t.bitLength()>e&&(t=l(e,i)),t.isProbablePrime(a))return c(null,t);t.dAddOffset(n[s++%8],0)}while(o<0||+new Date-u{var r,i=function(t,e,r){var i=u.util.createBuffer(),n=Math.ceil(e.n.bitLength()/8);if(t.length>n-11){var s=new Error('Message is too long for PKCS#1 v1.5 padding.');throw s.length=t.length,s.max=n-11,s}i.putByte(0),i.putByte(r);var a,o=n-3-t.length;if(0===r||1===r){a=0===r?0:255;for(var h=0;h0;){var l=0,c=u.random.getBytes(o);for(h=0;h1;){if(255!==s.getByte()){--s.read;break}++h}else if(2===o)for(h=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++h}if(0!==s.getByte()||h!==n-3-s.length())throw new Error('Encryption block is invalid.');return s.getBytes()},s=function(t){var e=t.toString(16);e[0]>='8'&&(e='00'+e);var r=u.util.hexToBytes(e);return!(r.length>1)||(0!==r.charCodeAt(0)||128&r.charCodeAt(1))&&(255!==r.charCodeAt(0)||128&~r.charCodeAt(1))?r:r.substr(1)},a=function(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2},o=function(t){return u.util.isNodejs&&'function'==typeof d[t]},h=function(t){return void 0!==p.globalScope&&'object'==typeof p.globalScope.crypto&&'object'==typeof p.globalScope.crypto.subtle&&'function'==typeof p.globalScope.crypto.subtle[t]},l=function(t){return void 0!==p.globalScope&&'object'==typeof p.globalScope.msCrypto&&'object'==typeof p.globalScope.msCrypto.subtle&&'function'==typeof p.globalScope.msCrypto.subtle[t]},c=function(t){for(var e=u.util.hexToBytes(t.toString(16)),r=new Uint8Array(e.length),i=0;i=0||!n.gcd(e.n).equals(r.ONE));for(var s=(t=t.multiply(n.modPow(e.e,e.n)).mod(e.n)).mod(e.p).modPow(e.dP,e.p),a=t.mod(e.q).modPow(e.dQ,e.q);s.compareTo(a)<0;)s=s.add(e.p);var o=s.subtract(a).multiply(e.qInv).mod(e.p).multiply(e.q).add(a);return o=o.multiply(n.modInverse(e.n)).mod(e.n)};m.rsa.encrypt=function(t,e,n){var s,a=n,o=Math.ceil(e.n.bitLength()/8);!1!==n&&!0!==n?(a=2===n,s=i(t,e,n)):(s=u.util.createBuffer()).putBytes(t);for(var h=new r(s.toHex(),16),l=S(h,e,a).toString(16),c=u.util.createBuffer(),d=o-Math.ceil(l.length/2);d>0;)c.putByte(0),--d;return c.putBytes(u.util.hexToBytes(l)),c.getBytes()},m.rsa.decrypt=function(t,e,i,s){var a=Math.ceil(e.n.bitLength()/8);if(t.length!==a){var o=new Error('Encrypted message length is invalid.');throw o.length=t.length,o.expected=a,o}var h=new r(u.util.createBuffer(t).toHex(),16);if(h.compareTo(e.n)>=0)throw new Error('Encrypted message is invalid.');for(var l=S(h,e,i).toString(16),c=u.util.createBuffer(),d=a-Math.ceil(l.length/2);d>0;)c.putByte(0),--d;return c.putBytes(u.util.hexToBytes(l)),!1!==s?n(c.getBytes(),e,i):c.getBytes()},m.rsa.createKeyPairGenerationState=function(t,e,i){'string'==typeof t&&(t=parseInt(t,10)),t=t||2048;var n,s=(i=i||{}).prng||u.random,a={nextBytes:function(t){for(var e=s.getBytesSync(t.length),r=0;r>1,pBits:t-(t>>1),pqState:0,num:null,keys:null}).e.fromInt(n.eInt),n},m.rsa.stepKeyPairGenerationState=function(t,e){'algorithm'in t||(t.algorithm='PRIMEINC');var i=new r(null);i.fromInt(30);for(var n,s=0,o=function(t,e){return t|e},h=+new Date,l=0;null===t.keys&&(e<=0||lc?t.pqState=0:t.num.isProbablePrime(a(t.num.bitLength()))?++t.pqState:t.num.dAddOffset(g[s++%8],0):2===t.pqState?t.pqState=0===t.num.subtract(r.ONE).gcd(t.e).compareTo(r.ONE)?3:0:3===t.pqState&&(t.pqState=0,null===t.p?t.p=t.num:t.q=t.num,null!==t.p&&null!==t.q&&++t.state,t.num=null)}else if(1===t.state)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(2===t.state)t.p1=t.p.subtract(r.ONE),t.q1=t.q.subtract(r.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(3===t.state)0===t.phi.gcd(t.e).compareTo(r.ONE)?++t.state:(t.p=null,t.q=null,t.state=0);else if(4===t.state)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(5===t.state){var d=t.e.modInverse(t.phi);t.keys={privateKey:m.rsa.setPrivateKey(t.n,t.e,d,t.p,t.q,d.mod(t.p1),d.mod(t.q1),t.q.modInverse(t.p)),publicKey:m.rsa.setPublicKey(t.n,t.e)}}l+=(n=+new Date)-h,h=n}return null!==t.keys},m.rsa.generateKeyPair=function(t,e,i,n){if(1===arguments.length?'object'==typeof t?(i=t,t=void 0):'function'==typeof t&&(n=t,t=void 0):2===arguments.length?'number'==typeof t?'function'==typeof e?(n=e,e=void 0):'number'!=typeof e&&(i=e,e=void 0):(i=t,n=e,t=void 0,e=void 0):3===arguments.length&&('number'==typeof e?'function'==typeof i&&(n=i,i=void 0):(n=i,i=e,e=void 0)),i=i||{},void 0===t&&(t=i.bits||2048),void 0===e&&(e=i.e||65537),!u.options.usePureJavaScript&&!i.prng&&t>=256&&t<=16384&&(65537===e||3===e))if(n){if(o('generateKeyPair'))return d.generateKeyPair('rsa',{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:'spki',format:'pem'},privateKeyEncoding:{type:'pkcs8',format:'pem'}},(function(t,e,r){if(t)return n(t);n(null,{privateKey:m.privateKeyFromPem(r),publicKey:m.publicKeyFromPem(e)})}));if(h('generateKey')&&h('exportKey'))return p.globalScope.crypto.subtle.generateKey({name:'RSASSA-PKCS1-v1_5',modulusLength:t,publicExponent:c(e),hash:{name:'SHA-256'}},!0,['sign','verify']).then((function(t){return p.globalScope.crypto.subtle.exportKey('pkcs8',t.privateKey)})).then(void 0,(function(t){n(t)})).then((function(t){if(t){var e=m.privateKeyFromAsn1(f.fromDer(u.util.createBuffer(t)));n(null,{privateKey:e,publicKey:m.setRsaPublicKey(e.n,e.e)})}}));if(l('generateKey')&&l('exportKey')){var s=p.globalScope.msCrypto.subtle.generateKey({name:'RSASSA-PKCS1-v1_5',modulusLength:t,publicExponent:c(e),hash:{name:'SHA-256'}},!0,['sign','verify']);return s.oncomplete=function(t){var e=t.target.result,r=p.globalScope.msCrypto.subtle.exportKey('pkcs8',e.privateKey);r.oncomplete=function(t){var e=t.target.result,r=m.privateKeyFromAsn1(f.fromDer(u.util.createBuffer(e)));n(null,{privateKey:r,publicKey:m.setRsaPublicKey(r.n,r.e)})},r.onerror=function(t){n(t)}},void(s.onerror=function(t){n(t)})}}else if(o('generateKeyPairSync')){var a=d.generateKeyPairSync('rsa',{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:'spki',format:'pem'},privateKeyEncoding:{type:'pkcs8',format:'pem'}});return{privateKey:m.privateKeyFromPem(a.privateKey),publicKey:m.publicKeyFromPem(a.publicKey)}}var g=m.rsa.createKeyPairGenerationState(t,e,i);if(!n)return m.rsa.stepKeyPairGenerationState(g,0),g.keys;!function(t,e,i){'function'==typeof e&&(i=e,e={});var n={algorithm:{name:(e=e||{}).algorithm||'PRIMEINC',options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};function s(){a(t.pBits,(function(e,r){return e?i(e):(t.p=r,null!==t.q?o(e,t.q):void a(t.qBits,o))}))}function a(t,e){u.prime.generateProbablePrime(t,n,e)}function o(e,n){if(e)return i(e);if(t.q=n,t.p.compareTo(t.q)<0){var h=t.p;t.p=t.q,t.q=h}if(0!==t.p.subtract(r.ONE).gcd(t.e).compareTo(r.ONE))return t.p=null,void s();if(0!==t.q.subtract(r.ONE).gcd(t.e).compareTo(r.ONE))return t.q=null,void a(t.qBits,o);if(t.p1=t.p.subtract(r.ONE),t.q1=t.q.subtract(r.ONE),t.phi=t.p1.multiply(t.q1),0!==t.phi.gcd(t.e).compareTo(r.ONE))return t.p=t.q=null,void s();if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits)return t.q=null,void a(t.qBits,o);var l=t.e.modInverse(t.phi);t.keys={privateKey:m.rsa.setPrivateKey(t.n,t.e,l,t.p,t.q,l.mod(t.p1),l.mod(t.q1),t.q.modInverse(t.p)),publicKey:m.rsa.setPublicKey(t.n,t.e)},i(null,t.keys)}'prng'in e&&(n.prng=e.prng),s()}(g,i,n)},m.setRsaPublicKey=m.rsa.setPublicKey=function(t,e){var r={n:t,e,encrypt:function(t,e,n){if('string'==typeof e?e=e.toUpperCase():void 0===e&&(e='RSAES-PKCS1-V1_5'),'RSAES-PKCS1-V1_5'===e)e={encode:function(t,e,r){return i(t,e,2).getBytes()}};else if('RSA-OAEP'===e||'RSAES-OAEP'===e)e={encode:function(t,e){return u.pkcs1.encode_rsa_oaep(e,t,n)}};else if(-1!==['RAW','NONE','NULL',null].indexOf(e))e={encode:function(t){return t}};else if('string'==typeof e)throw new Error('Unsupported encryption scheme: "'+e+'".');var s=e.encode(t,r,!0);return m.rsa.encrypt(s,r,!0)},verify:function(t,e,i,s){'string'==typeof i?i=i.toUpperCase():void 0===i&&(i='RSASSA-PKCS1-V1_5'),void 0===s&&(s={_parseAllDigestBytes:!0}),'_parseAllDigestBytes'in s||(s._parseAllDigestBytes=!0),'RSASSA-PKCS1-V1_5'===i?i={verify:function(t,e){e=n(e,r,!0);var i=f.fromDer(e,{parseAllBytes:s._parseAllDigestBytes}),a={},o=[];if(!f.validate(i,E,a,o))throw(h=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=o,h;var h,l=f.derToOid(a.algorithmIdentifier);if(l!==u.oids.md2&&l!==u.oids.md5&&l!==u.oids.sha1&&l!==u.oids.sha224&&l!==u.oids.sha256&&l!==u.oids.sha384&&l!==u.oids.sha512&&l!==u.oids['sha512-224']&&l!==u.oids['sha512-256'])throw(h=new Error('Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.')).oid=l,h;if((l===u.oids.md2||l===u.oids.md5)&&!('parameters'in a))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return t===a.digest}}:'NONE'!==i&&'NULL'!==i&&null!==i||(i={verify:function(t,e){return t===(e=n(e,r,!0))}});var a=m.rsa.decrypt(e,r,!0,!1);return i.verify(t,a,r.n.bitLength())}};return r},m.setRsaPrivateKey=m.rsa.setPrivateKey=function(t,e,r,i,s,a,o,h){var l={n:t,e,d:r,p:i,q:s,dP:a,dQ:o,qInv:h,decrypt:function(t,e,r){'string'==typeof e?e=e.toUpperCase():void 0===e&&(e='RSAES-PKCS1-V1_5');var i=m.rsa.decrypt(t,l,!1,!1);if('RSAES-PKCS1-V1_5'===e)e={decode:n};else if('RSA-OAEP'===e||'RSAES-OAEP'===e)e={decode:function(t,e){return u.pkcs1.decode_rsa_oaep(e,t,r)}};else{if(-1===['RAW','NONE','NULL',null].indexOf(e))throw new Error('Unsupported encryption scheme: "'+e+'".');e={decode:function(t){return t}}}return e.decode(i,l,!1)},sign:function(t,e){var r=!1;'string'==typeof e&&(e=e.toUpperCase()),void 0===e||'RSASSA-PKCS1-V1_5'===e?(e={encode:A},r=1):'NONE'!==e&&'NULL'!==e&&null!==e||(e={encode:function(){return t}},r=1);var i=e.encode(t,l.n.bitLength());return m.rsa.encrypt(i,l,r)}};return l},m.wrapRsaPrivateKey=function(t){return f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,f.integerToDer(0).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(m.oids.rsaEncryption).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.NULL,!1,'')]),f.create(f.Class.UNIVERSAL,f.Type.OCTETSTRING,!1,f.toDer(t).getBytes())])},m.privateKeyFromAsn1=function(t){var e,i,n,s,a,o,h,l,c={},d=[];if(f.validate(t,y,c,d)&&(t=f.fromDer(u.util.createBuffer(c.privateKey))),c={},d=[],!f.validate(t,v,c,d)){var p=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw p.errors=d,p}return e=u.util.createBuffer(c.privateKeyModulus).toHex(),i=u.util.createBuffer(c.privateKeyPublicExponent).toHex(),n=u.util.createBuffer(c.privateKeyPrivateExponent).toHex(),s=u.util.createBuffer(c.privateKeyPrime1).toHex(),a=u.util.createBuffer(c.privateKeyPrime2).toHex(),o=u.util.createBuffer(c.privateKeyExponent1).toHex(),h=u.util.createBuffer(c.privateKeyExponent2).toHex(),l=u.util.createBuffer(c.privateKeyCoefficient).toHex(),m.setRsaPrivateKey(new r(e,16),new r(i,16),new r(n,16),new r(s,16),new r(a,16),new r(o,16),new r(h,16),new r(l,16))},m.privateKeyToAsn1=m.privateKeyToRSAPrivateKey=function(t){return f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,f.integerToDer(0).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.n)),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.e)),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.d)),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.p)),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.q)),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.dP)),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.dQ)),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.qInv))])},m.publicKeyFromAsn1=function(t){var e={},i=[];if(f.validate(t,w,e,i)){var n,s=f.derToOid(e.publicKeyOid);if(s!==m.oids.rsaEncryption)throw(n=new Error('Cannot read public key. Unknown OID.')).oid=s,n;t=e.rsaPublicKey}if(i=[],!f.validate(t,b,e,i))throw(n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=i,n;var a=u.util.createBuffer(e.publicKeyModulus).toHex(),o=u.util.createBuffer(e.publicKeyExponent).toHex();return m.setRsaPublicKey(new r(a,16),new r(o,16))},m.publicKeyToAsn1=m.publicKeyToSubjectPublicKeyInfo=function(t){return f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(m.oids.rsaEncryption).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.NULL,!1,'')]),f.create(f.Class.UNIVERSAL,f.Type.BITSTRING,!1,[m.publicKeyToRSAPublicKey(t)])])},m.publicKeyToRSAPublicKey=function(t){return f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.n)),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,s(t.e))])}})),vn=w(((t,e)=>{var r,i=function(t,e){return t.start().update(e).digest().getBytes()},n=function(t){var e;if(t){if(!(e=h.oids[o.derToOid(t)])){var r=new Error('Unsupported PRF OID.');throw r.oid=t,r.supported=['hmacWithSHA1','hmacWithSHA224','hmacWithSHA256','hmacWithSHA384','hmacWithSHA512'],r}}else e='hmacWithSHA1';return s(e)},s=function(t){var e=a.md;switch(t){case'hmacWithSHA224':e=a.md.sha512;case'hmacWithSHA1':case'hmacWithSHA256':case'hmacWithSHA384':case'hmacWithSHA512':t=t.substr(8).toLowerCase();break;default:var r=new Error('Unsupported PRF algorithm.');throw r.algorithm=t,r.supported=['hmacWithSHA1','hmacWithSHA224','hmacWithSHA256','hmacWithSHA384','hmacWithSHA512'],r}if(!e||!(t in e))throw new Error('Unknown hash algorithm: '+t);return e[t].create()},a=Vi();qi(),Zi(),tn(),$i(),Yi(),hn(),Ji(),un(),dn(),yn(),zi(),void 0===r&&(r=a.jsbn.BigInteger);var o=a.asn1,h=a.pki=a.pki||{};e.exports=h.pbe=a.pbe=a.pbe||{};var l=h.oids,c={name:'EncryptedPrivateKeyInfo',tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedPrivateKeyInfo.encryptionAlgorithm',tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:'encryptionOid'},{name:'AlgorithmIdentifier.parameters',tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:'encryptionParams'}]},{name:'EncryptedPrivateKeyInfo.encryptedData',tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:'encryptedData'}]},u={name:'PBES2Algorithms',tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.keyDerivationFunc',tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.keyDerivationFunc.oid',tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:'kdfOid'},{name:'PBES2Algorithms.params',tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.params.salt',tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:'kdfSalt'},{name:'PBES2Algorithms.params.iterationCount',tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:'kdfIterationCount'},{name:'PBES2Algorithms.params.keyLength',tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,optional:!0,capture:'keyLength'},{name:'PBES2Algorithms.params.prf',tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:'PBES2Algorithms.params.prf.algorithm',tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:'prfOid'}]}]}]},{name:'PBES2Algorithms.encryptionScheme',tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.encryptionScheme.oid',tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:'encOid'},{name:'PBES2Algorithms.encryptionScheme.iv',tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:'encIv'}]}]},d={name:'pkcs-12PbeParams',tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:'pkcs-12PbeParams.salt',tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:'salt'},{name:'pkcs-12PbeParams.iterations',tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:'iterations'}]};h.encryptPrivateKeyInfo=function(t,e,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||'aes128',r.prfAlgorithm=r.prfAlgorithm||'sha1';var i,n,c,u=a.random.getBytesSync(r.saltSize),d=r.count,f=o.integerToDer(d);if(0===r.algorithm.indexOf('aes')||'des'===r.algorithm){var p,m,g;switch(r.algorithm){case'aes128':i=16,p=16,m=l['aes128-CBC'],g=a.aes.createEncryptionCipher;break;case'aes192':i=24,p=16,m=l['aes192-CBC'],g=a.aes.createEncryptionCipher;break;case'aes256':i=32,p=16,m=l['aes256-CBC'],g=a.aes.createEncryptionCipher;break;case'des':i=8,p=8,m=l.desCBC,g=a.des.createEncryptionCipher;break;default:throw(E=new Error('Cannot encrypt private key. Unknown encryption algorithm.')).algorithm=r.algorithm,E}var y='hmacWith'+r.prfAlgorithm.toUpperCase(),v=s(y),b=a.pkcs5.pbkdf2(e,u,d,i,v),_=a.random.getBytesSync(p);(A=g(b)).start(_),A.update(o.toDer(t)),A.finish(),c=A.output.getBytes();var w=function(t,e,r,i){var n=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,t),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,e.getBytes())]);return'hmacWithSHA1'!==i&&n.value.push(o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,a.util.hexToBytes(r.toString(16))),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(h.oids[i]).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,'')])),n}(u,f,i,y);n=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.pkcs5PBES2).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l.pkcs5PBKDF2).getBytes()),w]),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(m).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,_)])])])}else{var E;if('3des'!==r.algorithm)throw(E=new Error('Cannot encrypt private key. Unknown encryption algorithm.')).algorithm=r.algorithm,E;i=24;var A,S=new a.util.ByteBuffer(u);b=h.pbe.generatePkcs12Key(e,S,1,d,i),_=h.pbe.generatePkcs12Key(e,S,2,d,i);(A=a.des.createEncryptionCipher(b)).start(_),A.update(o.toDer(t)),A.finish(),c=A.output.getBytes(),n=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(l['pbeWithSHAAnd3-KeyTripleDES-CBC']).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,u),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,f.getBytes())])])}return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[n,o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,c)])},h.decryptPrivateKeyInfo=function(t,e){var r=null,i={},n=[];if(!o.validate(t,c,i,n)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}var l=o.derToOid(i.encryptionOid),u=h.pbe.getCipher(l,i.encryptionParams,e),d=a.util.createBuffer(i.encryptedData);return u.update(d),u.finish()&&(r=o.fromDer(u.output)),r},h.encryptedPrivateKeyToPem=function(t,e){var r={type:'ENCRYPTED PRIVATE KEY',body:o.toDer(t).getBytes()};return a.pem.encode(r,{maxline:e})},h.encryptedPrivateKeyFromPem=function(t){var e=a.pem.decode(t)[0];if('ENCRYPTED PRIVATE KEY'!==e.type){var r=new Error("Could not convert encrypted private key from PEM; PEM header type is \"ENCRYPTED PRIVATE KEY\".");throw r.headerType=e.type,r}if(e.procType&&'ENCRYPTED'===e.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return o.fromDer(e.body)},h.encryptRsaPrivateKey=function(t,e,r){if(!(r=r||{}).legacy){var i=h.wrapRsaPrivateKey(h.privateKeyToAsn1(t));return i=h.encryptPrivateKeyInfo(i,e,r),h.encryptedPrivateKeyToPem(i)}var n,s,l,c;switch(r.algorithm){case'aes128':n='AES-128-CBC',l=16,s=a.random.getBytesSync(16),c=a.aes.createEncryptionCipher;break;case'aes192':n='AES-192-CBC',l=24,s=a.random.getBytesSync(16),c=a.aes.createEncryptionCipher;break;case'aes256':n='AES-256-CBC',l=32,s=a.random.getBytesSync(16),c=a.aes.createEncryptionCipher;break;case'3des':n='DES-EDE3-CBC',l=24,s=a.random.getBytesSync(8),c=a.des.createEncryptionCipher;break;case'des':n='DES-CBC',l=8,s=a.random.getBytesSync(8),c=a.des.createEncryptionCipher;break;default:var u=new Error("Could not encrypt RSA private key; unsupported encryption algorithm \""+r.algorithm+'".');throw u.algorithm=r.algorithm,u}var d=c(a.pbe.opensslDeriveBytes(e,s.substr(0,8),l));d.start(s),d.update(o.toDer(h.privateKeyToAsn1(t))),d.finish();var f={type:'RSA PRIVATE KEY',procType:{version:'4',type:'ENCRYPTED'},dekInfo:{algorithm:n,parameters:a.util.bytesToHex(s).toUpperCase()},body:d.output.getBytes()};return a.pem.encode(f)},h.decryptRsaPrivateKey=function(t,e){var r=null,i=a.pem.decode(t)[0];if('ENCRYPTED PRIVATE KEY'!==i.type&&'PRIVATE KEY'!==i.type&&'RSA PRIVATE KEY'!==i.type)throw(l=new Error("Could not convert private key from PEM; PEM header type is not \"ENCRYPTED PRIVATE KEY\", \"PRIVATE KEY\", or \"RSA PRIVATE KEY\".")).headerType=l,l;if(i.procType&&'ENCRYPTED'===i.procType.type){var n,s;switch(i.dekInfo.algorithm){case'DES-CBC':n=8,s=a.des.createDecryptionCipher;break;case'DES-EDE3-CBC':n=24,s=a.des.createDecryptionCipher;break;case'AES-128-CBC':n=16,s=a.aes.createDecryptionCipher;break;case'AES-192-CBC':n=24,s=a.aes.createDecryptionCipher;break;case'AES-256-CBC':n=32,s=a.aes.createDecryptionCipher;break;case'RC2-40-CBC':n=5,s=function(t){return a.rc2.createDecryptionCipher(t,40)};break;case'RC2-64-CBC':n=8,s=function(t){return a.rc2.createDecryptionCipher(t,64)};break;case'RC2-128-CBC':n=16,s=function(t){return a.rc2.createDecryptionCipher(t,128)};break;default:var l;throw(l=new Error("Could not decrypt private key; unsupported encryption algorithm \""+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,l}var c=a.util.hexToBytes(i.dekInfo.parameters),u=s(a.pbe.opensslDeriveBytes(e,c.substr(0,8),n));if(u.start(c),u.update(a.util.createBuffer(i.body)),!u.finish())return r;r=u.output.getBytes()}else r=i.body;return null!==(r='ENCRYPTED PRIVATE KEY'===i.type?h.decryptPrivateKeyInfo(o.fromDer(r),e):o.fromDer(r))&&(r=h.privateKeyFromAsn1(r)),r},h.pbe.generatePkcs12Key=function(t,e,r,i,n,s){var o,h;if(null==s){if(!('sha1'in a.md))throw new Error('"sha1" hash algorithm unavailable.');s=a.md.sha1.create()}var l=s.digestLength,c=s.blockLength,u=new a.util.ByteBuffer,d=new a.util.ByteBuffer;if(null!=t){for(h=0;h=0;h--)O>>=8,O+=T.at(h)+C.at(h),C.setAt(h,255&O);I.putBuffer(C)}_=I,u.putBuffer(A)}return u.truncate(u.length()-n),u},h.pbe.getCipher=function(t,e,r){switch(t){case h.oids.pkcs5PBES2:return h.pbe.getCipherForPBES2(t,e,r);case h.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:case h.oids['pbewithSHAAnd40BitRC2-CBC']:return h.pbe.getCipherForPKCS12PBE(t,e,r);default:var i=new Error('Cannot read encrypted PBE data block. Unsupported OID.');throw i.oid=t,i.supportedOids=['pkcs5PBES2','pbeWithSHAAnd3-KeyTripleDES-CBC','pbewithSHAAnd40BitRC2-CBC'],i}},h.pbe.getCipherForPBES2=function(t,e,r){var i,s={},l=[];if(!o.validate(e,u,s,l))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=l,i;if((t=o.derToOid(s.kdfOid))!==h.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=t,i.supportedOids=['pkcs5PBKDF2'],i;if((t=o.derToOid(s.encOid))!==h.oids['aes128-CBC']&&t!==h.oids['aes192-CBC']&&t!==h.oids['aes256-CBC']&&t!==h.oids['des-EDE3-CBC']&&t!==h.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=t,i.supportedOids=['aes128-CBC','aes192-CBC','aes256-CBC','des-EDE3-CBC','desCBC'],i;var c,d,f=s.kdfSalt,p=a.util.createBuffer(s.kdfIterationCount);switch(p=p.getInt(p.length()<<3),h.oids[t]){case'aes128-CBC':c=16,d=a.aes.createDecryptionCipher;break;case'aes192-CBC':c=24,d=a.aes.createDecryptionCipher;break;case'aes256-CBC':c=32,d=a.aes.createDecryptionCipher;break;case'des-EDE3-CBC':c=24,d=a.des.createDecryptionCipher;break;case'desCBC':c=8,d=a.des.createDecryptionCipher}var m=n(s.prfOid),g=a.pkcs5.pbkdf2(r,f,p,c,m),y=s.encIv,v=d(g);return v.start(y),v},h.pbe.getCipherForPKCS12PBE=function(t,e,r){var i={},s=[];if(!o.validate(e,d,i,s))throw(m=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=s,m;var l,c,u,f=a.util.createBuffer(i.salt),p=a.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),t){case h.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:l=24,c=8,u=a.des.startDecrypting;break;case h.oids['pbewithSHAAnd40BitRC2-CBC']:l=5,c=8,u=function(t,e){var r=a.rc2.createDecryptionCipher(t,40);return r.start(e,null),r};break;default:var m;throw(m=new Error('Cannot read PKCS #12 PBE data block. Unsupported OID.')).oid=t,m}var g=n(i.prfOid),y=h.pbe.generatePkcs12Key(r,f,1,p,l,g);return g.start(),u(y,h.pbe.generatePkcs12Key(r,f,2,p,c,g))},h.pbe.opensslDeriveBytes=function(t,e,r,n){if(null==n){if(!('md5'in a.md))throw new Error('"md5" hash algorithm unavailable.');n=a.md.md5.create()}null===e&&(e='');for(var s=[i(n,t+e)],o=16,h=1;o{var r=Vi();Zi(),zi();var i=r.asn1,n=e.exports=r.pkcs7asn1=r.pkcs7asn1||{};r.pkcs7=r.pkcs7||{},r.pkcs7.asn1=n;var s={name:'ContentInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'ContentInfo.ContentType',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'contentType'},{name:'ContentInfo.content',tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:'content'}]};n.contentInfoValidator=s;var a={name:'EncryptedContentInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedContentInfo.contentType',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'contentType'},{name:'EncryptedContentInfo.contentEncryptionAlgorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedContentInfo.contentEncryptionAlgorithm.algorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'encAlgorithm'},{name:'EncryptedContentInfo.contentEncryptionAlgorithm.parameter',tagClass:i.Class.UNIVERSAL,captureAsn1:'encParameter'}]},{name:'EncryptedContentInfo.encryptedContent',tagClass:i.Class.CONTEXT_SPECIFIC,type:0,capture:'encryptedContent',captureAsn1:'encryptedContentAsn1'}]};n.envelopedDataValidator={name:'EnvelopedData',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'EnvelopedData.Version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'version'},{name:'EnvelopedData.RecipientInfos',tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:'recipientInfos'}].concat(a)},n.encryptedDataValidator={name:'EncryptedData',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedData.Version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'version'}].concat(a)};var o={name:'SignerInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'SignerInfo.version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1},{name:'SignerInfo.issuerAndSerialNumber',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'SignerInfo.issuerAndSerialNumber.issuer',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:'issuer'},{name:'SignerInfo.issuerAndSerialNumber.serialNumber',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'serial'}]},{name:'SignerInfo.digestAlgorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'SignerInfo.digestAlgorithm.algorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'digestAlgorithm'},{name:'SignerInfo.digestAlgorithm.parameter',tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:'digestParameter',optional:!0}]},{name:'SignerInfo.authenticatedAttributes',tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:'authenticatedAttributes'},{name:'SignerInfo.digestEncryptionAlgorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,capture:'signatureAlgorithm'},{name:'SignerInfo.encryptedDigest',tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:'signature'},{name:'SignerInfo.unauthenticatedAttributes',tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:'unauthenticatedAttributes'}]};n.signedDataValidator={name:'SignedData',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'SignedData.Version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'version'},{name:'SignedData.DigestAlgorithms',tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:'digestAlgorithms'},s,{name:'SignedData.Certificates',tagClass:i.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:'certificates'},{name:'SignedData.CertificateRevocationLists',tagClass:i.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:'crls'},{name:'SignedData.SignerInfos',tagClass:i.Class.UNIVERSAL,type:i.Type.SET,capture:'signerInfos',optional:!0,value:[o]}]},n.recipientInfoValidator={name:'RecipientInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'RecipientInfo.version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'version'},{name:'RecipientInfo.issuerAndSerial',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'RecipientInfo.issuerAndSerial.issuer',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:'issuer'},{name:'RecipientInfo.issuerAndSerial.serialNumber',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'serial'}]},{name:'RecipientInfo.keyEncryptionAlgorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'RecipientInfo.keyEncryptionAlgorithm.algorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'encAlgorithm'},{name:'RecipientInfo.keyEncryptionAlgorithm.parameter',tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:'encParameter',optional:!0}]},{name:'RecipientInfo.encryptedKey',tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:'encKey'}]}})),_n=w(((t,e)=>{var r=Vi();zi(),r.mgf=r.mgf||{},(e.exports=r.mgf.mgf1=r.mgf1=r.mgf1||{}).create=function(t){var e={generate:function(e,i){for(var n=new r.util.ByteBuffer,s=Math.ceil(i/t.digestLength),a=0;a{var r=Vi();_n(),e.exports=r.mgf=r.mgf||{},r.mgf.mgf1=r.mgf1})),En=w(((t,e)=>{var r=Vi();un(),zi(),(e.exports=r.pss=r.pss||{}).create=function(t){3===arguments.length&&(t={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var e,i=t.md,n=t.mgf,s=i.digestLength,a=t.salt||null;if('string'==typeof a&&(a=r.util.createBuffer(a)),'saltLength'in t)e=t.saltLength;else{if(null===a)throw new Error('Salt length not specified or specific salt not given.');e=a.length()}if(null!==a&&a.length()!==e)throw new Error('Given salt length does not match length of given salt.');var o=t.prng||r.random,h={encode:function(t,h){var l,c,u=h-1,d=Math.ceil(u/8),f=t.digest().getBytes();if(d>8*d-u&255;return(_=String.fromCharCode(_.charCodeAt(0)&~w)+_.substr(1))+m+String.fromCharCode(188)},verify:function(t,a,o){var h,l=o-1,c=Math.ceil(l/8);if(a=a.substr(-c),c>8*c-l&255;if(d.charCodeAt(0)&p)throw new Error('Bits beyond keysize not zero as expected.');var m=n.generate(f,u),g='';for(h=0;h{var r=function(t,e){'string'==typeof e&&(e={shortName:e});for(var r,i=null,n=0;null===i&&n128)throw new Error('Invalid "nsComment" content.');t.value=c.create(c.Class.UNIVERSAL,c.Type.IA5STRING,!1,t.comment)}else if('subjectKeyIdentifier'===t.name&&e.cert){var p=e.cert.generateSubjectKeyIdentifier();t.subjectKeyIdentifier=p.toHex(),t.value=c.create(c.Class.UNIVERSAL,c.Type.OCTETSTRING,!1,p.getBytes())}else if('authorityKeyIdentifier'===t.name&&e.cert){t.value=c.create(c.Class.UNIVERSAL,c.Type.SEQUENCE,!0,[]);o=t.value.value;if(t.keyIdentifier){var m=!0===t.keyIdentifier?e.cert.generateSubjectKeyIdentifier().getBytes():t.keyIdentifier;o.push(c.create(c.Class.CONTEXT_SPECIFIC,0,!1,m))}if(t.authorityCertIssuer){var g=[c.create(c.Class.CONTEXT_SPECIFIC,4,!0,[i(!0===t.authorityCertIssuer?e.cert.issuer:t.authorityCertIssuer)])];o.push(c.create(c.Class.CONTEXT_SPECIFIC,1,!0,g))}if(t.serialNumber){var y=l.util.hexToBytes(!0===t.serialNumber?e.cert.serialNumber:t.serialNumber);o.push(c.create(c.Class.CONTEXT_SPECIFIC,2,!1,y))}}else if('cRLDistributionPoints'===t.name){t.value=c.create(c.Class.UNIVERSAL,c.Type.SEQUENCE,!0,[]);o=t.value.value;var v,b=c.create(c.Class.UNIVERSAL,c.Type.SEQUENCE,!0,[]),_=c.create(c.Class.CONTEXT_SPECIFIC,0,!0,[]);for(f=0;f=E&&t2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(d.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(o.validity.notBefore=d[0],o.validity.notAfter=d[1],o.tbsCertificate=i.tbsCertificate,e){o.md=_({signatureOid:o.signatureOid,type:'certificate'});var f=c.toDer(o.tbsCertificate);o.md.update(f.getBytes())}var p=l.md.sha1.create(),g=c.toDer(i.certIssuer);p.update(g.getBytes()),o.issuer.getField=function(t){return r(o.issuer,t)},o.issuer.addField=function(t){n([t]),o.issuer.attributes.push(t)},o.issuer.attributes=u.RDNAttributesAsArray(i.certIssuer),i.certIssuerUniqueId&&(o.issuer.uniqueId=i.certIssuerUniqueId),o.issuer.hash=p.digest().toHex();var y=l.md.sha1.create(),v=c.toDer(i.certSubject);return y.update(v.getBytes()),o.subject.getField=function(t){return r(o.subject,t)},o.subject.addField=function(t){n([t]),o.subject.attributes.push(t)},o.subject.attributes=u.RDNAttributesAsArray(i.certSubject),i.certSubjectUniqueId&&(o.subject.uniqueId=i.certSubjectUniqueId),o.subject.hash=y.digest().toHex(),i.certExtensions?o.extensions=u.certificateExtensionsFromAsn1(i.certExtensions):o.extensions=[],o.publicKey=u.publicKeyFromAsn1(i.subjectPublicKeyInfo),o},u.certificateExtensionsFromAsn1=function(t){for(var e=[],r=0;r1&&(r=s.value.charCodeAt(1),i=s.value.length>2?s.value.charCodeAt(2):0),e.digitalSignature=!(128&~r),e.nonRepudiation=!(64&~r),e.keyEncipherment=!(32&~r),e.dataEncipherment=!(16&~r),e.keyAgreement=!(8&~r),e.keyCertSign=!(4&~r),e.cRLSign=!(2&~r),e.encipherOnly=!(1&~r),e.decipherOnly=!(128&~i)}else if('basicConstraints'===e.name){(s=c.fromDer(e.value)).value.length>0&&s.value[0].type===c.Type.BOOLEAN?e.cA=0!==s.value[0].value.charCodeAt(0):e.cA=!1;var n=null;s.value.length>0&&s.value[0].type===c.Type.INTEGER?n=s.value[0].value:s.value.length>1&&(n=s.value[1].value),null!==n&&(e.pathLenConstraint=c.derToInteger(n))}else if('extKeyUsage'===e.name)for(var s=c.fromDer(e.value),a=0;a1&&(r=s.value.charCodeAt(1)),e.client=!(128&~r),e.server=!(64&~r),e.email=!(32&~r),e.objsign=!(16&~r),e.reserved=!(8&~r),e.sslCA=!(4&~r),e.emailCA=!(2&~r),e.objCA=!(1&~r)}else if('subjectAltName'===e.name||'issuerAltName'===e.name){var h;e.altNames=[];s=c.fromDer(e.value);for(var u=0;u0&&n.value.push(u.certificateExtensionsToAsn1(t.extensions)),n},u.getCertificationRequestInfo=function(t){return c.create(c.Class.UNIVERSAL,c.Type.SEQUENCE,!0,[c.create(c.Class.UNIVERSAL,c.Type.INTEGER,!1,c.integerToDer(t.version).getBytes()),i(t.subject),u.publicKeyToAsn1(t.publicKey),o(t)])},u.distinguishedNameToAsn1=function(t){return i(t)},u.certificateToAsn1=function(t){var e=t.tbsCertificate||u.getTBSCertificate(t);return c.create(c.Class.UNIVERSAL,c.Type.SEQUENCE,!0,[e,c.create(c.Class.UNIVERSAL,c.Type.SEQUENCE,!0,[c.create(c.Class.UNIVERSAL,c.Type.OID,!1,c.oidToDer(t.signatureOid).getBytes()),a(t.signatureOid,t.signatureParameters)]),c.create(c.Class.UNIVERSAL,c.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])},u.certificateExtensionsToAsn1=function(t){var e=c.create(c.Class.CONTEXT_SPECIFIC,3,!0,[]),r=c.create(c.Class.UNIVERSAL,c.Type.SEQUENCE,!0,[]);e.value.push(r);for(var i=0;ih.validity.notAfter)&&(a={message:'Certificate is not valid yet or has expired.',error:u.certificateError.certificate_expired,notBefore:h.validity.notBefore,notAfter:h.validity.notAfter,now:n}),null===a){if(null===(c=e[0]||t.getIssuer(h))&&h.isIssuer(h)&&(d=!0,c=h),c){var f=c;l.util.isArray(f)||(f=[f]);for(var p=!1;!p&&f.length>0;){c=f.shift();try{p=c.verify(h)}catch(t){}}p||(a={message:'Certificate signature is invalid.',error:u.certificateError.bad_certificate})}null!==a||c&&!d||t.hasCertificate(h)||(a={message:'Certificate is not trusted.',error:u.certificateError.unknown_ca})}if(null===a&&c&&!h.isIssuer(c)&&(a={message:'Certificate issuer is invalid.',error:u.certificateError.bad_certificate}),null===a)for(var m={keyUsage:!0,basicConstraints:!0},g=0;null===a&&gv.pathLenConstraint&&(a={message:'Certificate basicConstraints pathLenConstraint violated.',error:u.certificateError.bad_certificate})}var _=null===a||a.error,w=r.verify?r.verify(_,o,i):_;if(!0!==w)throw!0===_&&(a={message:'The application rejected the certificate.',error:u.certificateError.bad_certificate}),(w||0===w)&&('object'!=typeof w||l.util.isArray(w)?'string'==typeof w&&(a.error=w):(w.message&&(a.message=w.message),w.error&&(a.error=w.error))),a;a=null,s=!1,++o}while(e.length>0);return!0}})),Sn=w(((t,e)=>{var r=function(t,e,r,i){for(var n=[],s=0;s=0&&n.push(o):n.push(o))}return n},i=function(t){if(t.composed||t.constructed){for(var e=o.util.createBuffer(),r=0;r0&&(n=h.create(h.Class.UNIVERSAL,h.Type.SET,!0,u));var d=[],f=[];null!==e&&(f=o.util.isArray(e)?e:[e]);for(var p=[],m=0;m0){var b=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,p),_=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(l.oids.data).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(b).getBytes())])]);d.push(_)}var w=null;if(null!==t){var E=l.wrapRsaPrivateKey(l.privateKeyToAsn1(t));w=null===r?h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(l.oids.keyBag).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[E]),n]):h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(l.oids.pkcs8ShroudedKeyBag).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[l.encryptPrivateKeyInfo(E,r,i)]),n]);var A=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[w]),S=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(l.oids.data).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(A).getBytes())])]);d.push(S)}var T,M=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,d);if(i.useMac){var I=o.md.sha1.create(),C=new o.util.ByteBuffer(o.random.getBytes(i.saltSize)),O=i.count,N=(t=c.generateKey(r,C,3,O,20),o.hmac.create());N.start(I,t),N.update(h.toDer(M).getBytes());var L=N.getMac();T=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(l.oids.sha1).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.NULL,!1,'')]),h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,L.getBytes())]),h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,C.getBytes()),h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(O).getBytes())])}return h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(3).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(l.oids.data).getBytes()),h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,h.toDer(M).getBytes())])]),T])},c.generateKey=o.pbe.generatePkcs12Key})),Tn=w(((t,e)=>{var r=Vi();Zi(),Yi(),vn(),Ji(),hn(),Sn(),En(),yn(),zi(),An();var i=r.asn1,n=e.exports=r.pki=r.pki||{};n.pemToDer=function(t){var e=r.pem.decode(t)[0];if(e.procType&&'ENCRYPTED'===e.procType.type)throw new Error('Could not convert PEM to DER; PEM is encrypted.');return r.util.createBuffer(e.body)},n.privateKeyFromPem=function(t){var e=r.pem.decode(t)[0];if('PRIVATE KEY'!==e.type&&'RSA PRIVATE KEY'!==e.type){var s=new Error("Could not convert private key from PEM; PEM header type is not \"PRIVATE KEY\" or \"RSA PRIVATE KEY\".");throw s.headerType=e.type,s}if(e.procType&&'ENCRYPTED'===e.procType.type)throw new Error('Could not convert private key from PEM; PEM is encrypted.');var a=i.fromDer(e.body);return n.privateKeyFromAsn1(a)},n.privateKeyToPem=function(t,e){var s={type:'RSA PRIVATE KEY',body:i.toDer(n.privateKeyToAsn1(t)).getBytes()};return r.pem.encode(s,{maxline:e})},n.privateKeyInfoToPem=function(t,e){var n={type:'PRIVATE KEY',body:i.toDer(t).getBytes()};return r.pem.encode(n,{maxline:e})}})),Mn=w(((t,e)=>{var r=Vi();Zi(),Xi(),Qi(),Ji(),Tn(),un(),pn(),zi();var i=function(t,e,i,n){var s=r.util.createBuffer(),a=t.length>>1,o=a+(1&t.length),h=t.substr(0,o),l=t.substr(a,o),c=r.util.createBuffer(),u=r.hmac.create();i=e+i;var d=Math.ceil(n/16),f=Math.ceil(n/20);u.start('MD5',h);var p=r.util.createBuffer();c.putBytes(i);for(var m=0;m0&&(h.queue(t,h.createAlert(t,{level:h.Alert.Level.warning,description:h.Alert.Description.no_renegotiation})),h.flush(t)),t.process()},h.parseHelloMessage=function(t,e,i){var n=null,s=t.entity===h.ConnectionEnd.client;if(i<38)t.error(t,{message:s?'Invalid ServerHello message. Message too short.':'Invalid ClientHello message. Message too short.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});else{var o=e.fragment,l=o.length();if(n={version:{major:o.getByte(),minor:o.getByte()},random:r.util.createBuffer(o.getBytes(32)),session_id:a(o,1),extensions:[]},s?(n.cipher_suite=o.getBytes(2),n.compression_method=o.getByte()):(n.cipher_suites=a(o,2),n.compression_methods=a(o,1)),(l=i-(l-o.length()))>0){for(var c=a(o,2);c.length()>0;)n.extensions.push({type:[c.getByte(),c.getByte()],data:a(c,2)});if(!s)for(var u=0;u0;){if(0!==f.getByte())break;t.session.extensions.server_name.serverNameList.push(a(f,2).getBytes())}}}if(t.session.version&&(n.version.major!==t.session.version.major||n.version.minor!==t.session.version.minor))return t.error(t,{message:'TLS version change is disallowed during renegotiation.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.protocol_version}});if(s)t.session.cipherSuite=h.getCipherSuite(n.cipher_suite);else for(var p=r.util.createBuffer(n.cipher_suites.bytes());p.length()>0&&(t.session.cipherSuite=h.getCipherSuite(p.getBytes(2)),null===t.session.cipherSuite););if(null===t.session.cipherSuite)return t.error(t,{message:'No cipher suites in common.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.handshake_failure},cipherSuite:r.util.bytesToHex(n.cipher_suite)});t.session.compressionMethod=s?n.compression_method:h.CompressionMethod.none}return n},h.createSecurityParameters=function(t,e){var r=t.entity===h.ConnectionEnd.client,i=e.random.bytes(),n=r?t.session.sp.client_random:i,s=r?i:h.createRandom().getBytes();t.session.sp={entity:t.entity,prf_algorithm:h.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:t.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:n,server_random:s}},h.handleServerHello=function(t,e,r){var i=h.parseHelloMessage(t,e,r);if(!t.fail){if(!(i.version.minor<=t.version.minor))return t.error(t,{message:'Incompatible TLS version.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.protocol_version}});t.version.minor=i.version.minor,t.session.version=t.version;var n=i.session_id.bytes();n.length>0&&n===t.session.id?(t.expect=f,t.session.resuming=!0,t.session.sp.server_random=i.random.bytes()):(t.expect=l,t.session.resuming=!1,h.createSecurityParameters(t,i)),t.session.id=n,t.process()}},h.handleClientHello=function(t,e,i){var n=h.parseHelloMessage(t,e,i);if(!t.fail){var s=n.session_id.bytes(),a=null;if(t.sessionCache&&(null===(a=t.sessionCache.getSession(s))?s='':(a.version.major!==n.version.major||a.version.minor>n.version.minor)&&(a=null,s='')),0===s.length&&(s=r.random.getBytes(32)),t.session.id=s,t.session.clientHelloVersion=n.version,t.session.sp={},a)t.version=t.session.version=a.version,t.session.sp=a.sp;else{for(var o,l=1;l0;)n=a(l.certificate_list,3),s=r.asn1.fromDer(n),n=r.pki.certificateFromAsn1(s,!0),u.push(n)}catch(e){return t.error(t,{message:'Could not parse certificate list.',cause:e,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_certificate}})}var d=t.entity===h.ConnectionEnd.client;!d&&!0!==t.verifyClient||0!==u.length?0===u.length?t.expect=d?c:v:(d?t.session.serverCertificate=u[0]:t.session.clientCertificate=u[0],h.verifyCertificateChain(t,u)&&(t.expect=d?c:v)):t.error(t,{message:d?'No server certificate provided.':'No client certificate provided.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}}),t.process()},h.handleServerKeyExchange=function(t,e,r){if(r>0)return t.error(t,{message:'Invalid key parameters. Only RSA is supported.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unsupported_certificate}});t.expect=u,t.process()},h.handleClientKeyExchange=function(t,e,i){if(i<48)return t.error(t,{message:'Invalid key parameters. Only RSA is supported.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.unsupported_certificate}});var n=e.fragment,s={enc_pre_master_secret:a(n,2).getBytes()},o=null;if(t.getPrivateKey)try{o=t.getPrivateKey(t,t.session.serverCertificate),o=r.pki.privateKeyFromPem(o)}catch(e){t.error(t,{message:'Could not get private key.',cause:e,send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}})}if(null===o)return t.error(t,{message:'No private key set.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}});try{var l=t.session.sp;l.pre_master_secret=o.decrypt(s.enc_pre_master_secret);var c=t.session.clientHelloVersion;if(c.major!==l.pre_master_secret.charCodeAt(0)||c.minor!==l.pre_master_secret.charCodeAt(1))throw new Error('TLS version rollback attack detected.')}catch(t){l.pre_master_secret=r.random.getBytes(48)}t.expect=_,null!==t.session.clientCertificate&&(t.expect=b),t.process()},h.handleCertificateRequest=function(t,e,r){if(r<3)return t.error(t,{message:'Invalid CertificateRequest. Message too short.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});var i=e.fragment,n={certificate_types:a(i,1),certificate_authorities:a(i,2)};t.session.certificateRequest=n,t.expect=d,t.process()},h.handleCertificateVerify=function(t,e,i){if(i<2)return t.error(t,{message:'Invalid CertificateVerify. Message too short.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});var n=e.fragment;n.read-=4;var s=n.bytes();n.read+=4;var o={signature:a(n,2).getBytes()},l=r.util.createBuffer();l.putBuffer(t.session.md5.digest()),l.putBuffer(t.session.sha1.digest()),l=l.getBytes();try{if(!t.session.clientCertificate.publicKey.verify(l,o.signature,'NONE'))throw new Error('CertificateVerify signature does not match.');t.session.md5.update(s),t.session.sha1.update(s)}catch(e){return t.error(t,{message:'Bad signature in CertificateVerify.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.handshake_failure}})}t.expect=_,t.process()},h.handleServerHelloDone=function(t,e,i){if(i>0)return t.error(t,{message:'Invalid ServerHelloDone message. Invalid length.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.record_overflow}});if(null===t.serverCertificate){var n={message:'No server certificate provided. Not enough security.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.insufficient_security}},s=t.verify(t,n.alert.description,0,[]);if(!0!==s)return(s||0===s)&&('object'!=typeof s||r.util.isArray(s)?'number'==typeof s&&(n.alert.description=s):(s.message&&(n.message=s.message),s.alert&&(n.alert.description=s.alert))),t.error(t,n)}null!==t.session.certificateRequest&&(e=h.createRecord(t,{type:h.ContentType.handshake,data:h.createCertificate(t)}),h.queue(t,e)),e=h.createRecord(t,{type:h.ContentType.handshake,data:h.createClientKeyExchange(t)}),h.queue(t,e),t.expect=g;var a=function(t,e){null!==t.session.certificateRequest&&null!==t.session.clientCertificate&&h.queue(t,h.createRecord(t,{type:h.ContentType.handshake,data:h.createCertificateVerify(t,e)})),h.queue(t,h.createRecord(t,{type:h.ContentType.change_cipher_spec,data:h.createChangeCipherSpec()})),t.state.pending=h.createConnectionState(t),t.state.current.write=t.state.pending.write,h.queue(t,h.createRecord(t,{type:h.ContentType.handshake,data:h.createFinished(t)})),t.expect=f,h.flush(t),t.process()};if(null===t.session.certificateRequest||null===t.session.clientCertificate)return a(t,null);h.getClientSignature(t,a)},h.handleChangeCipherSpec=function(t,e){if(1!==e.fragment.getByte())return t.error(t,{message:'Invalid ChangeCipherSpec message received.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.illegal_parameter}});var r=t.entity===h.ConnectionEnd.client;(t.session.resuming&&r||!t.session.resuming&&!r)&&(t.state.pending=h.createConnectionState(t)),t.state.current.read=t.state.pending.read,(!t.session.resuming&&r||t.session.resuming&&!r)&&(t.state.pending=null),t.expect=r?p:w,t.process()},h.handleFinished=function(t,e,n){var s=e.fragment;s.read-=4;var a=s.bytes();s.read+=4;var o=e.fragment.getBytes();(s=r.util.createBuffer()).putBuffer(t.session.md5.digest()),s.putBuffer(t.session.sha1.digest());var l=t.entity===h.ConnectionEnd.client,c=l?'server finished':'client finished',u=t.session.sp;if((s=i(u.master_secret,c,s.getBytes(),12)).getBytes()!==o)return t.error(t,{message:'Invalid verify_data in Finished message.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.decrypt_error}});t.session.md5.update(a),t.session.sha1.update(a),(t.session.resuming&&l||!t.session.resuming&&!l)&&(h.queue(t,h.createRecord(t,{type:h.ContentType.change_cipher_spec,data:h.createChangeCipherSpec()})),t.state.current.write=t.state.pending.write,t.state.pending=null,h.queue(t,h.createRecord(t,{type:h.ContentType.handshake,data:h.createFinished(t)}))),t.expect=l?m:E,t.handshaking=!1,++t.handshakes,t.peerCertificate=l?t.session.serverCertificate:t.session.clientCertificate,h.flush(t),t.isConnected=!0,t.connected(t),t.process()},h.handleAlert=function(t,e){var r,i=e.fragment,n={level:i.getByte(),description:i.getByte()};switch(n.description){case h.Alert.Description.close_notify:r='Connection closed.';break;case h.Alert.Description.unexpected_message:r='Unexpected message.';break;case h.Alert.Description.bad_record_mac:r='Bad record MAC.';break;case h.Alert.Description.decryption_failed:r='Decryption failed.';break;case h.Alert.Description.record_overflow:r='Record overflow.';break;case h.Alert.Description.decompression_failure:r='Decompression failed.';break;case h.Alert.Description.handshake_failure:r='Handshake failure.';break;case h.Alert.Description.bad_certificate:r='Bad certificate.';break;case h.Alert.Description.unsupported_certificate:r='Unsupported certificate.';break;case h.Alert.Description.certificate_revoked:r='Certificate revoked.';break;case h.Alert.Description.certificate_expired:r='Certificate expired.';break;case h.Alert.Description.certificate_unknown:r='Certificate unknown.';break;case h.Alert.Description.illegal_parameter:r='Illegal parameter.';break;case h.Alert.Description.unknown_ca:r='Unknown certificate authority.';break;case h.Alert.Description.access_denied:r='Access denied.';break;case h.Alert.Description.decode_error:r='Decode error.';break;case h.Alert.Description.decrypt_error:r='Decrypt error.';break;case h.Alert.Description.export_restriction:r='Export restriction.';break;case h.Alert.Description.protocol_version:r='Unsupported protocol version.';break;case h.Alert.Description.insufficient_security:r='Insufficient security.';break;case h.Alert.Description.internal_error:r='Internal error.';break;case h.Alert.Description.user_canceled:r='User canceled.';break;case h.Alert.Description.no_renegotiation:r='Renegotiation not supported.';break;default:r='Unknown error.'}if(n.description===h.Alert.Description.close_notify)return t.close();t.error(t,{message:r,send:!1,origin:t.entity===h.ConnectionEnd.client?'server':'client',alert:n}),t.process()},h.handleHandshake=function(t,e){var i=e.fragment,n=i.getByte(),s=i.getInt24();if(s>i.length())return t.fragmented=e,e.fragment=r.util.createBuffer(),i.read-=4,t.process();t.fragmented=null,i.read-=4;var a=i.bytes(s+4);i.read+=4,n in U[t.entity][t.expect]?(t.entity!==h.ConnectionEnd.server||t.open||t.fail||(t.handshaking=!0,t.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:r.md.md5.create(),sha1:r.md.sha1.create()}),n!==h.HandshakeType.hello_request&&n!==h.HandshakeType.certificate_verify&&n!==h.HandshakeType.finished&&(t.session.md5.update(a),t.session.sha1.update(a)),U[t.entity][t.expect][n](t,e,s)):h.handleUnexpected(t,e)},h.handleApplicationData=function(t,e){t.data.putBuffer(e.fragment),t.dataReady(t),t.process()},h.handleHeartbeat=function(t,e){var i=e.fragment,n=i.getByte(),s=i.getInt16(),a=i.getBytes(s);if(n===h.HeartbeatMessageType.heartbeat_request){if(t.handshaking||s>a.length)return t.process();h.queue(t,h.createRecord(t,{type:h.ContentType.heartbeat,data:h.createHeartbeat(h.HeartbeatMessageType.heartbeat_response,a)})),h.flush(t)}else if(n===h.HeartbeatMessageType.heartbeat_response){if(a!==t.expectedHeartbeatPayload)return t.process();t.heartbeatReceived&&t.heartbeatReceived(t,r.util.createBuffer(a))}t.process()};var l=1,c=2,u=3,d=4,f=5,p=6,m=7,g=8,y=1,v=2,b=3,_=4,w=5,E=6,A=h.handleUnexpected,S=h.handleChangeCipherSpec,T=h.handleAlert,M=h.handleHandshake,I=h.handleApplicationData,C=h.handleHeartbeat,O=[];O[h.ConnectionEnd.client]=[[A,T,M,A,C],[A,T,M,A,C],[A,T,M,A,C],[A,T,M,A,C],[A,T,M,A,C],[S,T,A,A,C],[A,T,M,A,C],[A,T,M,I,C],[A,T,M,A,C]],O[h.ConnectionEnd.server]=[[A,T,M,A,C],[A,T,M,A,C],[A,T,M,A,C],[A,T,M,A,C],[S,T,A,A,C],[A,T,M,A,C],[A,T,M,I,C],[A,T,M,A,C]];var N=h.handleHelloRequest,L=h.handleServerHello,R=h.handleCertificate,P=h.handleServerKeyExchange,B=h.handleCertificateRequest,k=h.handleServerHelloDone,D=h.handleFinished,U=[];U[h.ConnectionEnd.client]=[[A,A,L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[N,A,A,A,A,A,A,A,A,A,A,R,P,B,k,A,A,A,A,A,A],[N,A,A,A,A,A,A,A,A,A,A,A,P,B,k,A,A,A,A,A,A],[N,A,A,A,A,A,A,A,A,A,A,A,A,B,k,A,A,A,A,A,A],[N,A,A,A,A,A,A,A,A,A,A,A,A,A,k,A,A,A,A,A,A],[N,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[N,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,D],[N,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[N,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A]];var x=h.handleClientHello,F=h.handleClientKeyExchange,H=h.handleCertificateVerify;U[h.ConnectionEnd.server]=[[A,x,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,R,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,F,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,H,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,D],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A]],h.generateKeys=function(t,e){var r=i,n=e.client_random+e.server_random;t.session.resuming||(e.master_secret=r(e.pre_master_secret,'master secret',n,48).bytes(),e.pre_master_secret=null),n=e.server_random+e.client_random;var s=2*e.mac_key_length+2*e.enc_key_length,a=t.version.major===h.Versions.TLS_1_0.major&&t.version.minor===h.Versions.TLS_1_0.minor;a&&(s+=2*e.fixed_iv_length);var o=r(e.master_secret,'key expansion',n,s),l={client_write_MAC_key:o.getBytes(e.mac_key_length),server_write_MAC_key:o.getBytes(e.mac_key_length),client_write_key:o.getBytes(e.enc_key_length),server_write_key:o.getBytes(e.enc_key_length)};return a&&(l.client_write_IV=o.getBytes(e.fixed_iv_length),l.server_write_IV=o.getBytes(e.fixed_iv_length)),l},h.createConnectionState=function(t){var e=t.entity===h.ConnectionEnd.client,r=function(){var t={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(t){return!0},compressionState:null,compressFunction:function(t){return!0},updateSequenceNumber:function(){4294967295===t.sequenceNumber[1]?(t.sequenceNumber[1]=0,++t.sequenceNumber[0]):++t.sequenceNumber[1]}};return t},i={read:r(),write:r()};if(i.read.update=function(t,e){return i.read.cipherFunction(e,i.read)?i.read.compressFunction(t,e,i.read)||t.error(t,{message:'Could not decompress record.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.decompression_failure}}):t.error(t,{message:'Could not decrypt record or bad MAC.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.bad_record_mac}}),!t.fail},i.write.update=function(t,e){return i.write.compressFunction(t,e,i.write)?i.write.cipherFunction(e,i.write)||t.error(t,{message:'Could not encrypt record.',send:!1,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}}):t.error(t,{message:'Could not compress record.',send:!1,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.internal_error}}),!t.fail},t.session){var a=t.session.sp;switch(t.session.cipherSuite.initSecurityParameters(a),a.keys=h.generateKeys(t,a),i.read.macKey=e?a.keys.server_write_MAC_key:a.keys.client_write_MAC_key,i.write.macKey=e?a.keys.client_write_MAC_key:a.keys.server_write_MAC_key,t.session.cipherSuite.initConnectionState(i,t,a),a.compression_algorithm){case h.CompressionMethod.none:break;case h.CompressionMethod.deflate:i.read.compressFunction=s,i.write.compressFunction=n;break;default:throw new Error('Unsupported compression algorithm.')}}return i},h.createRandom=function(){var t=new Date,e=+t+6e4*t.getTimezoneOffset(),i=r.util.createBuffer();return i.putInt32(e),i.putBytes(r.random.getBytes(28)),i},h.createRecord=function(t,e){return e.data?{type:e.type,version:{major:t.version.major,minor:t.version.minor},length:e.data.length(),fragment:e.data}:null},h.createAlert=function(t,e){var i=r.util.createBuffer();return i.putByte(e.level),i.putByte(e.description),h.createRecord(t,{type:h.ContentType.alert,data:i})},h.createClientHello=function(t){t.session.clientHelloVersion={major:t.version.major,minor:t.version.minor};for(var e=r.util.createBuffer(),i=0;i0&&(p+=2);var m=t.session.id,g=m.length+1+2+4+28+2+s+1+l+p,y=r.util.createBuffer();return y.putByte(h.HandshakeType.client_hello),y.putInt24(g),y.putByte(t.version.major),y.putByte(t.version.minor),y.putBytes(t.session.sp.client_random),o(y,1,r.util.createBuffer(m)),o(y,2,e),o(y,1,a),p>0&&o(y,2,c),y},h.createServerHello=function(t){var e=t.session.id,i=e.length+1+2+4+28+2+1,n=r.util.createBuffer();return n.putByte(h.HandshakeType.server_hello),n.putInt24(i),n.putByte(t.version.major),n.putByte(t.version.minor),n.putBytes(t.session.sp.server_random),o(n,1,r.util.createBuffer(e)),n.putByte(t.session.cipherSuite.id[0]),n.putByte(t.session.cipherSuite.id[1]),n.putByte(t.session.compressionMethod),n},h.createCertificate=function(t){var e,i=t.entity===h.ConnectionEnd.client,n=null;t.getCertificate&&(e=i?t.session.certificateRequest:t.session.extensions.server_name.serverNameList,n=t.getCertificate(t,e));var s=r.util.createBuffer();if(null!==n)try{r.util.isArray(n)||(n=[n]);for(var a=null,l=0;lh.MaxFragment;)n.push(h.createRecord(t,{type:e.type,data:r.util.createBuffer(s.slice(0,h.MaxFragment))})),s=s.slice(h.MaxFragment);s.length>0&&n.push(h.createRecord(t,{type:e.type,data:r.util.createBuffer(s)}))}for(var a=0;a0&&(n=i.order[0]),null!==n&&n in i.cache)for(var s in e=i.cache[n],delete i.cache[n],i.order)if(i.order[s]===n){i.order.splice(s,1);break}return e},i.setSession=function(t,e){if(i.order.length===i.capacity){var n=i.order.shift();delete i.cache[n]}n=r.util.bytesToHex(t);i.order.push(n),i.cache[n]=e}}return i},h.createConnection=function(t){var e=null;e=t.caStore?r.util.isArray(t.caStore)?r.pki.createCaStore(t.caStore):t.caStore:r.pki.createCaStore();var i=t.cipherSuites||null;if(null===i)for(var n in i=[],h.CipherSuites)i.push(h.CipherSuites[n]);var s=t.server?h.ConnectionEnd.server:h.ConnectionEnd.client,a=t.sessionCache?h.createSessionCache(t.sessionCache):null,o={version:{major:h.Version.major,minor:h.Version.minor},entity:s,sessionId:t.sessionId,caStore:e,sessionCache:a,cipherSuites:i,connected:t.connected,virtualHost:t.virtualHost||null,verifyClient:t.verifyClient||!1,verify:t.verify||function(t,e,r,i){return e},verifyOptions:t.verifyOptions||{},getCertificate:t.getCertificate||null,getPrivateKey:t.getPrivateKey||null,getSignature:t.getSignature||null,input:r.util.createBuffer(),tlsData:r.util.createBuffer(),data:r.util.createBuffer(),tlsDataReady:t.tlsDataReady,dataReady:t.dataReady,heartbeatReceived:t.heartbeatReceived,closed:t.closed,error:function(e,r){r.origin=r.origin||(e.entity===h.ConnectionEnd.client?'client':'server'),r.send&&(h.queue(e,h.createAlert(e,r.alert)),h.flush(e));var i=!1!==r.fatal;i&&(e.fail=!0),t.error(e,r),i&&e.close(!1)},deflate:t.deflate||null,inflate:t.inflate||null,reset:function(t){o.version={major:h.Version.major,minor:h.Version.minor},o.record=null,o.session=null,o.peerCertificate=null,o.state={pending:null,current:null},o.expect=(o.entity,h.ConnectionEnd.client,0),o.fragmented=null,o.records=[],o.open=!1,o.handshakes=0,o.handshaking=!1,o.isConnected=!1,o.fail=!(t||void 0===t),o.input.clear(),o.tlsData.clear(),o.data.clear(),o.state.current=h.createConnectionState(o)}};o.reset();return o.handshake=function(t){if(o.entity!==h.ConnectionEnd.client)o.error(o,{message:'Cannot initiate handshake as a server.',fatal:!1});else if(o.handshaking)o.error(o,{message:'Handshake already in progress.',fatal:!1});else{o.fail&&!o.open&&0===o.handshakes&&(o.fail=!1),o.handshaking=!0;var e=null;(t=t||'').length>0&&(o.sessionCache&&(e=o.sessionCache.getSession(t)),null===e&&(t='')),0===t.length&&o.sessionCache&&null!==(e=o.sessionCache.getSession())&&(t=e.id),o.session={id:t,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:r.md.md5.create(),sha1:r.md.sha1.create()},e&&(o.version=e.version,o.session.sp=e.sp),o.session.sp.client_random=h.createRandom().getBytes(),o.open=!0,h.queue(o,h.createRecord(o,{type:h.ContentType.handshake,data:h.createClientHello(o)})),h.flush(o)}},o.process=function(t){var e,i,n,s,a=0;return t&&o.input.putBytes(t),o.fail||(null!==o.record&&o.record.ready&&o.record.fragment.isEmpty()&&(o.record=null),null===o.record&&(a=function(t){var e=0,i=t.input,n=i.length();if(n<5)e=5-n;else{t.record={type:i.getByte(),version:{major:i.getByte(),minor:i.getByte()},length:i.getInt16(),fragment:r.util.createBuffer(),ready:!1};var s=t.record.version.major===t.version.major;s&&t.session&&t.session.version&&(s=t.record.version.minor===t.version.minor),s||t.error(t,{message:'Incompatible TLS version.',send:!0,alert:{level:h.Alert.Level.fatal,description:h.Alert.Description.protocol_version}})}return e}(o)),o.fail||null===o.record||o.record.ready||(a=function(t){var e=0,r=t.input,i=r.length();return i{var r=function(t,e,r){var n=e.entity===h.tls.ConnectionEnd.client;t.read.cipherState={init:!1,cipher:h.cipher.createDecipher('AES-CBC',n?r.keys.server_write_key:r.keys.client_write_key),iv:n?r.keys.server_write_IV:r.keys.client_write_IV},t.write.cipherState={init:!1,cipher:h.cipher.createCipher('AES-CBC',n?r.keys.client_write_key:r.keys.server_write_key),iv:n?r.keys.client_write_IV:r.keys.server_write_IV},t.read.cipherFunction=a,t.write.cipherFunction=i,t.read.macLength=t.write.macLength=r.mac_length,t.read.macFunction=t.write.macFunction=l.hmac_sha1},i=function(t,e){var r,i=!1,s=e.macFunction(e.macKey,e.sequenceNumber,t);t.fragment.putBytes(s),e.updateSequenceNumber(),r=t.version.minor===l.Versions.TLS_1_0.minor?e.cipherState.init?null:e.cipherState.iv:h.random.getBytesSync(16),e.cipherState.init=!0;var a=e.cipherState.cipher;return a.start({iv:r}),t.version.minor>=l.Versions.TLS_1_1.minor&&a.output.putBytes(r),a.update(t.fragment),a.finish(n)&&(t.fragment=a.output,t.length=t.fragment.length(),i=!0),i},n=function(t,e,r){if(!r){var i=t-e.length()%t;e.fillWithByte(i-1,i)}return!0},s=function(t,e,r){var i=!0;if(r){for(var n=e.length(),s=e.last(),a=n-1-s;a=a?(t.fragment=n.output.getBytes(u-a),c=n.output.getBytes(a)):t.fragment=n.output.getBytes(),t.fragment=h.util.createBuffer(t.fragment),t.length=t.fragment.length();var d=e.macFunction(e.macKey,e.sequenceNumber,t);return e.updateSequenceNumber(),i=o(e.macKey,c,d)&&i},o=function(t,e,r){var i=h.hmac.create();return i.start('SHA1',t),i.update(e),e=i.digest().getBytes(),i.start(null,null),i.update(r),e===(r=i.digest().getBytes())},h=Vi();qi(),Mn();var l=e.exports=h.tls;l.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:'TLS_RSA_WITH_AES_128_CBC_SHA',initSecurityParameters:function(t){t.bulk_cipher_algorithm=l.BulkCipherAlgorithm.aes,t.cipher_type=l.CipherType.block,t.enc_key_length=16,t.block_length=16,t.fixed_iv_length=16,t.record_iv_length=16,t.mac_algorithm=l.MACAlgorithm.hmac_sha1,t.mac_length=20,t.mac_key_length=20},initConnectionState:r},l.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:'TLS_RSA_WITH_AES_256_CBC_SHA',initSecurityParameters:function(t){t.bulk_cipher_algorithm=l.BulkCipherAlgorithm.aes,t.cipher_type=l.CipherType.block,t.enc_key_length=32,t.block_length=16,t.fixed_iv_length=16,t.record_iv_length=16,t.mac_algorithm=l.MACAlgorithm.hmac_sha1,t.mac_length=20,t.mac_key_length=20},initConnectionState:r}})),Cn=w(((t,e)=>{var r=function(t,e,r){for(var i,n,s,a,o,l,c,u,d,f,p,m,g,y,v,b,_,w,E,A,S,T,M,I,C,O,N,L,R,P,B,k,D,U=r.length();U>=128;){for(N=0;N<16;++N)e[N][0]=r.getInt32()>>>0,e[N][1]=r.getInt32()>>>0;for(;N<80;++N)i=(((L=(P=e[N-2])[0])>>>19|(R=P[1])<<13)^(R>>>29|L<<3)^L>>>6)>>>0,n=((L<<13|R>>>19)^(R<<3|L>>>29)^(L<<26|R>>>6))>>>0,s=(((L=(k=e[N-15])[0])>>>1|(R=k[1])<<31)^(L>>>8|R<<24)^L>>>7)>>>0,a=((L<<31|R>>>1)^(L<<24|R>>>8)^(L<<25|R>>>7))>>>0,B=e[N-7],D=e[N-16],R=n+B[1]+a+D[1],e[N][0]=i+B[0]+s+D[0]+(R/4294967296>>>0)>>>0,e[N][1]=R>>>0;for(p=t[0][0],m=t[0][1],g=t[1][0],y=t[1][1],v=t[2][0],b=t[2][1],_=t[3][0],w=t[3][1],E=t[4][0],A=t[4][1],S=t[5][0],T=t[5][1],M=t[6][0],I=t[6][1],C=t[7][0],O=t[7][1],N=0;N<80;++N)c=((E>>>14|A<<18)^(E>>>18|A<<14)^(A>>>9|E<<23))>>>0,u=(M^E&(S^M))>>>0,o=((p>>>28|m<<4)^(m>>>2|p<<30)^(m>>>7|p<<25))>>>0,l=((p<<4|m>>>28)^(m<<30|p>>>2)^(m<<25|p>>>7))>>>0,d=(p&g|v&(p^g))>>>0,f=(m&y|b&(m^y))>>>0,R=O+(((E<<18|A>>>14)^(E<<14|A>>>18)^(A<<23|E>>>9))>>>0)+((I^A&(T^I))>>>0)+h[N][1]+e[N][1],i=C+c+u+h[N][0]+e[N][0]+(R/4294967296>>>0)>>>0,n=R>>>0,s=o+d+((R=l+f)/4294967296>>>0)>>>0,a=R>>>0,C=M,O=I,M=S,I=T,S=E,T=A,E=_+i+((R=w+n)/4294967296>>>0)>>>0,A=R>>>0,_=v,w=b,v=g,b=y,g=p,y=m,p=i+s+((R=n+a)/4294967296>>>0)>>>0,m=R>>>0;R=t[0][1]+m,t[0][0]=t[0][0]+p+(R/4294967296>>>0)>>>0,t[0][1]=R>>>0,R=t[1][1]+y,t[1][0]=t[1][0]+g+(R/4294967296>>>0)>>>0,t[1][1]=R>>>0,R=t[2][1]+b,t[2][0]=t[2][0]+v+(R/4294967296>>>0)>>>0,t[2][1]=R>>>0,R=t[3][1]+w,t[3][0]=t[3][0]+_+(R/4294967296>>>0)>>>0,t[3][1]=R>>>0,R=t[4][1]+A,t[4][0]=t[4][0]+E+(R/4294967296>>>0)>>>0,t[4][1]=R>>>0,R=t[5][1]+T,t[5][0]=t[5][0]+S+(R/4294967296>>>0)>>>0,t[5][1]=R>>>0,R=t[6][1]+I,t[6][0]=t[6][0]+M+(R/4294967296>>>0)>>>0,t[6][1]=R>>>0,R=t[7][1]+O,t[7][0]=t[7][0]+C+(R/4294967296>>>0)>>>0,t[7][1]=R>>>0,U-=128}},i=Vi();$i(),zi();var n=e.exports=i.sha512=i.sha512||{};i.md.sha512=i.md.algorithms.sha512=n;var s=i.sha384=i.sha512.sha384=i.sha512.sha384||{};s.create=function(){return n.create('SHA-384')},i.md.sha384=i.md.algorithms.sha384=s,i.sha512.sha256=i.sha512.sha256||{create:function(){return n.create('SHA-512/256')}},i.md['sha512/256']=i.md.algorithms['sha512/256']=i.sha512.sha256,i.sha512.sha224=i.sha512.sha224||{create:function(){return n.create('SHA-512/224')}},i.md['sha512/224']=i.md.algorithms['sha512/224']=i.sha512.sha224,n.create=function(t){if(o||(a=String.fromCharCode(128),a+=i.util.fillString(String.fromCharCode(0),128),h=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(l={})['SHA-512']=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],l['SHA-384']=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],l['SHA-512/256']=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],l['SHA-512/224']=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],o=!0),void 0===t&&(t='SHA-512'),!(t in l))throw new Error('Invalid SHA-512 algorithm: '+t);for(var e=l[t],n=null,s=i.util.createBuffer(),c=new Array(80),u=0;u<80;++u)c[u]=new Array(2);var d=64;switch(t){case'SHA-384':d=48;break;case'SHA-512/256':d=32;break;case'SHA-512/224':d=28}var f={algorithm:t.replace('-','').toLowerCase(),blockLength:128,digestLength:d,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){f.messageLength=0,f.fullMessageLength=f.messageLength128=[];for(var t=f.messageLengthSize/4,r=0;r>>0,a>>>0];for(var o=f.fullMessageLength.length-1;o>=0;--o)f.fullMessageLength[o]+=a[1],a[1]=a[0]+(f.fullMessageLength[o]/4294967296>>>0),f.fullMessageLength[o]=f.fullMessageLength[o]>>>0,a[0]=a[1]/4294967296>>>0;return s.putBytes(t),r(n,c,s),(s.read>2048||0===s.length())&&s.compact(),f},f.digest=function(){var e=i.util.createBuffer();e.putBytes(s.bytes());var o,h=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize&f.blockLength-1;e.putBytes(a.substr(0,f.blockLength-h));for(var l=8*f.fullMessageLength[0],u=0;u>>0,e.putInt32(l>>>0),l=o>>>0;e.putInt32(l);var d=new Array(n.length);for(u=0;u{var e=Vi();Zi();var r=e.asn1;t.privateKeyValidator={name:'PrivateKeyInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'PrivateKeyInfo.version',tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:'privateKeyVersion'},{name:'PrivateKeyInfo.privateKeyAlgorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'privateKeyOid'}]},{name:'PrivateKeyInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:'privateKey'}]},t.publicKeyValidator={name:'SubjectPublicKeyInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:'subjectPublicKeyInfo',value:[{name:'SubjectPublicKeyInfo.AlgorithmIdentifier',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'publicKeyOid'}]},{tagClass:r.Class.UNIVERSAL,type:r.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:'ed25519PublicKey'}]}})),Nn=w(((t,e)=>{var r=function(t){var e=t.message;if(e instanceof Uint8Array||e instanceof B)return e;var r=t.encoding;if(void 0===e){if(!t.md)throw new TypeError('"options.message" or "options.md" not specified.');e=t.md.digest().getBytes(),r='binary'}if('string'==typeof e&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if('string'==typeof e){if('undefined'!=typeof Buffer)return Buffer.from(e,r);e=new P(e,r)}else if(!(e instanceof P))throw new TypeError("\"options.message\" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with \"options.encoding\" specifying its encoding.");for(var i=new B(e.length()),n=0;n=32;--i){for(r=0,n=i-32,s=i-12;n>8,e[n]-=256*r;e[n]+=r,e[i]=0}for(r=0,n=0;n<32;++n)e[n]+=r-(e[31]>>4)*V[n],r=e[n]>>8,e[n]&=255;for(n=0;n<32;++n)e[n]-=r*V[n];for(i=0;i<32;++i)e[i+1]+=e[i]>>8,t[i]=255&e[i]},s=function(t){for(var e=new Float64Array(64),r=0;r<64;++r)e[r]=t[r],t[r]=0;n(t,e)},a=function(t,e){var r=A(),i=A(),n=A(),s=A(),a=A(),o=A(),h=A(),l=A(),c=A();T(r,t[1],t[0]),T(c,e[1],e[0]),I(r,r,c),S(i,t[0],t[1]),S(c,e[0],e[1]),I(i,i,c),I(n,t[3],e[3]),I(n,n,F),I(s,t[2],e[2]),S(s,s,s),T(a,i,r),T(o,s,n),S(h,s,n),S(l,i,r),I(t[0],a,o),I(t[1],l,h),I(t[2],h,o),I(t[3],a,l)},o=function(t,e,r){for(var i=0;i<4;++i)E(t[i],e[i],r)},h=function(t,e){var r=A(),i=A(),n=A();_(n,e[2]),I(r,e[0],n),I(i,e[1],n),l(t,i),t[31]^=g(r)<<7},l=function(t,e){var r,i,n,s=A(),a=A();for(r=0;r<16;++r)a[r]=e[r];for(w(a),w(a),w(a),i=0;i<2;++i){for(s[0]=a[0]-65517,r=1;r<15;++r)s[r]=a[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),n=s[15]>>16&1,s[14]&=65535,E(a,s,1-n)}for(r=0;r<16;r++)t[2*r]=255&a[r],t[2*r+1]=a[r]>>8},c=function(t,e){var r=A(),i=A(),n=A(),s=A(),a=A(),o=A(),h=A();return b(t[2],U),u(t[1],e),M(n,t[1]),I(s,n,x),T(n,n,t[2]),S(s,t[2],s),M(a,s),M(o,a),I(h,o,a),I(r,h,n),I(r,r,s),d(r,r),I(r,r,n),I(r,r,s),I(r,r,s),I(t[0],r,s),M(i,t[0]),I(i,i,s),f(i,n)&&I(t[0],t[0],G),M(i,t[0]),I(i,i,s),f(i,n)?-1:(g(t[0])===e[31]>>7&&T(t[0],D,t[0]),I(t[3],t[0],t[1]),0)},u=function(t,e){var r;for(r=0;r<16;++r)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767},d=function(t,e){var r,i=A();for(r=0;r<16;++r)i[r]=e[r];for(r=250;r>=0;--r)M(i,i),1!==r&&I(i,i,e);for(r=0;r<16;++r)t[r]=i[r]},f=function(t,e){var r=new B(32),i=new B(32);return l(r,t),l(i,e),p(r,0,i,0)},p=function(t,e,r,i){return m(t,e,r,i,32)},m=function(t,e,r,i,n){var s,a=0;for(s=0;s>>8)-1},g=function(t){var e=new B(32);return l(e,t),1&e[0]},y=function(t,e,r){var i,n;for(b(t[0],D),b(t[1],U),b(t[2],U),b(t[3],D),n=255;n>=0;--n)i=r[n/8|0]>>(7&n)&1,o(t,e,i),a(e,t),a(t,t),o(t,e,i)},v=function(t,e){var r=[A(),A(),A(),A()];b(r[0],H),b(r[1],j),b(r[2],U),I(r[3],H,j),y(t,r,e)},b=function(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]},_=function(t,e){var r,i=A();for(r=0;r<16;++r)i[r]=e[r];for(r=253;r>=0;--r)M(i,i),2!==r&&4!==r&&I(i,i,e);for(r=0;r<16;++r)t[r]=i[r]},w=function(t){var e,r,i=1;for(e=0;e<16;++e)r=t[e]+i+65535,i=Math.floor(r/65536),t[e]=r-65536*i;t[0]+=i-1+37*(i-1)},E=function(t,e,r){for(var i,n=~(r-1),s=0;s<16;++s)i=n&(t[s]^e[s]),t[s]^=i,e[s]^=i},A=function(t){var e,r=new Float64Array(16);if(t)for(e=0;e=0};var D=A(),U=A([1]),x=A([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),F=A([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),H=A([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),j=A([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),V=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]),G=A([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139])})),Ln=w(((t,e)=>{var r=function(t,e,r,n){t.generate=function(t,s){for(var a=new i.util.ByteBuffer,o=Math.ceil(s/n)+r,h=new i.util.ByteBuffer,l=r;l0&&(a=i.util.fillString(String.fromCharCode(0),h)+a),{encapsulation:e.encrypt(a,'NONE'),key:t.generate(a,s)}},decrypt:function(e,r,i){var n=e.decrypt(r,'NONE');return t.generate(n,i)}};return s},i.kem.kdf1=function(t,e){r(this,t,0,e||t.digestLength)},i.kem.kdf2=function(t,e){r(this,t,1,e||t.digestLength)}})),Rn=w(((t,e)=>{var r=Vi();zi(),e.exports=r.log=r.log||{},r.log.levels=['none','error','warning','info','debug','verbose','max'];var i,n,s,a,o,h,l,c={},u=[],d=null;for(r.log.LEVEL_LOCKED=2,r.log.NO_LEVEL_CHECK=4,r.log.INTERPOLATE=8,s=0;s{e.exports=$i(),Qi(),pn(),ln(),Cn()})),Bn=w(((t,e)=>{var r=function(t){var e={},r=[];if(!l.validate(t,c.asn1.recipientInfoValidator,e,r)){var i=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw i.errors=r,i}return{version:e.version.charCodeAt(0),issuer:h.pki.RDNAttributesAsArray(e.issuer),serialNumber:h.util.createBuffer(e.serial).toHex(),encryptedContent:{algorithm:l.derToOid(e.encAlgorithm),parameter:e.encParameter?e.encParameter.value:void 0,content:e.encKey}}},i=function(t){for(var e,r=[],i=0;i0){for(var r=l.create(l.Class.CONTEXT_SPECIFIC,1,!0,[]),i=0;i=r&&n0&&n.value[0].value.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!0,e)),i.length>0&&n.value[0].value.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,i)),n.value[0].value.push(l.create(l.Class.UNIVERSAL,l.Type.SET,!0,t.signerInfos)),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(t.type).getBytes()),n])},addSigner:function(e){var r=e.issuer,i=e.serialNumber;if(e.certificate){var n=e.certificate;'string'==typeof n&&(n=h.pki.certificateFromPem(n)),r=n.issuer.attributes,i=n.serialNumber}var s=e.key;if(!s)throw new Error('Could not add PKCS#7 signer; no private key specified.');'string'==typeof s&&(s=h.pki.privateKeyFromPem(s));var a=e.digestAlgorithm||h.pki.oids.sha1;switch(a){case h.pki.oids.sha1:case h.pki.oids.sha256:case h.pki.oids.sha384:case h.pki.oids.sha512:case h.pki.oids.md5:break;default:throw new Error('Could not add PKCS#7 signer; unknown message digest algorithm: '+a)}var o=e.authenticatedAttributes||[];if(o.length>0){for(var l=!1,c=!1,u=0;u{var r=function(t,e){var r=e.toString(16);r[0]>='8'&&(r='00'+r);var i=s.util.hexToBytes(r);t.putInt32(i.length),t.putBytes(i)},i=function(t,e){t.putInt32(e.length),t.putString(e)},n=function(){for(var t=s.md.sha1.create(),e=arguments.length,r=0;r{e.exports=Vi(),qi(),In(),Zi(),Wi(),tn(),Nn(),Xi(),Ln(),Rn(),Pn(),_n(),hn(),Ji(),mn(),Sn(),Bn(),Tn(),gn(),cn(),En(),un(),dn(),kn(),Mn(),zi()})),Un={};E(Un,{songs:()=>nn,serverMaps:()=>an,maps:()=>rn,jingles:()=>sn});var xn=A((()=>{rn=['m52_58','l50_57','l36_150','l48_50','m53_50','m51_147','l34_73','m43_73','l45_76','l41_149','l39_150','l50_153','l39_155','l42_144','m40_150','l47_58','l48_152','l47_62','m40_149','l48_62','m38_153','l47_150','m50_149','m37_152','m39_74','l48_156','m43_145','l36_73','l49_48','l48_52','l51_55','l45_57','l39_72','l36_154','l37_49','l41_47','m46_149','m41_75','l46_56','l52_60','l44_48','m37_150','l32_72','m46_53','l46_46','m34_70','m40_74','l49_58','m35_76','m37_54','l38_52','m39_45','m51_56','m41_151','l48_51','l36_74','m43_56','m44_53','l46_49','m51_61','l47_48','l47_50','l46_55','l43_55','l47_53','l45_60','m39_147','m36_154','m47_150','l50_152','l39_74','m48_48','m44_146','m50_59','l47_153','l47_54','m39_149','l44_46','l32_75','l52_49','m48_47','m33_71','l44_53','l50_62','l45_150','l38_155','m52_54','l36_153','m50_46','l52_51','m32_74','m41_146','m51_48','l44_55','l43_49','m50_53','l33_76','l43_51','l45_155','m46_152','m46_75','l49_62','m49_53','l37_72','m46_48','m39_48','m39_46','l39_151','l47_60','m42_73','l40_48','l49_153','m47_50','l43_52','m34_73','m53_49','m40_51','l48_53','l53_50','l49_154','l47_55','m37_51','m45_154','m32_75','m43_75','m49_62','l40_153','l42_55','l49_61','l51_50','m41_74','m47_53','l50_58','l44_49','l44_75','l40_54','m49_48','m44_148','m42_50','m40_53','m42_53','m35_75','l42_72','l38_54','m35_20','m45_145','m40_52','l34_72','l44_54','l40_45','l37_51','l49_59','l44_45','l51_54','l39_76','l46_48','l42_54','m50_153','l48_54','l45_152','m44_149','l47_149','m46_56','l37_152','m49_149','m50_60','m42_152','m37_75','l45_52','l43_50','l41_75','m41_54','m52_47','m44_145','l33_73','l51_154','m44_151','m49_47','l42_152','l38_55','m52_53','m47_49','m39_72','l43_54','m49_153','l47_56','m37_74','m49_52','m37_148','l32_70','m31_75','m44_155','l47_61','m41_72','l51_59','l36_146','l52_56','m41_51','m47_56','l48_59','l41_46','m44_49','l36_72','m49_51','l38_146','m41_56','m46_50','l48_154','l46_161','m37_49','l49_47','l40_148','m46_150','l42_52','l49_49','m45_75','m45_52','l37_149','m36_150','l37_150','m49_56','m38_149','l40_150','m51_53','l44_149','m48_156','l50_55','m29_75','m42_51','l38_154','l39_48','m47_153','m41_46','m45_60','l45_154','m44_75','l37_74','m47_55','m38_47','l45_59','m50_152','m36_54','m45_151','l51_48','m46_153','l50_52','l41_153','m40_45','m39_152','l44_152','l40_152','l52_154','l50_150','m45_74','l37_54','m47_57','m50_48','l39_148','m37_154','m45_58','m49_156','l44_144','l52_54','m42_54','m43_54','l45_58','l47_59','m48_57','m50_61','l51_52','m41_47','m39_47','l37_148','l36_76','m41_52','m45_47','l48_48','m50_49','m34_75','m46_46','m38_148','l34_70','l52_48','l39_153','m44_48','m42_74','l45_62','l46_154','l52_57','l49_50','m43_74','l41_53','m42_145','l45_55','l45_146','l44_50','l43_154','m38_155','m44_144','l33_72','l33_74','m39_76','l49_52','m49_50','l50_47','m40_54','m47_54','l41_151','l49_156','m38_150','l29_75','m44_50','m38_151','m48_154','m41_153','m38_45','l45_49','m43_53','l49_46','m38_154','l42_146','m32_71','m38_52','l45_74','m45_61','m47_161','l53_52','l46_152','m47_58','l36_149','m36_52','l49_148','m46_47','m50_55','m44_45','l50_50','m45_48','m46_58','l43_53','l38_147','l44_72','m37_53','l41_146','m48_61','l52_46','m45_56','l46_53','l47_52','l44_73','m45_57','m38_73','m39_49','l35_76','l39_147','m45_150','l45_54','m52_153','l46_61','m50_56','l41_72','l44_52','m46_55','l39_154','l46_50','l48_153','l50_48','m52_57','m44_152','m51_154','l51_47','l51_60','l47_57','m43_153','m39_53','l48_55','l36_54','m51_60','l46_51','m34_74','l40_52','l32_74','m53_52','m34_72','l40_53','m47_152','m44_52','m38_51','l45_50','m51_47','l46_58','l52_62','m49_154','l39_45','m42_75','m38_55','m42_72','l48_49','m49_61','l49_53','m50_54','l42_50','m33_70','m40_46','m49_155','m38_146','m52_46','m41_48','m45_59','l39_47','m44_47','m46_51','m36_72','m47_148','l38_47','m48_155','m43_51','m40_73','l40_50','l45_75','l43_56','l38_149','m43_46','l30_75','l40_75','m50_47','l40_72','m44_51','l42_73','m43_154','l46_75','l43_46','m44_74','m44_55','l46_57','m37_149','m45_46','l39_149','l38_73','m38_152','l40_55','m41_149','l37_50','m49_46','m46_62','m32_72','m47_62','m42_56','m48_153','m52_55','l40_46','l45_56','m48_59','m52_49','l46_59','l50_59','m42_146','m51_58','l38_53','m45_51','l44_150','m48_50','l51_62','m52_56','m45_54','m38_46','l35_20','m47_160','m49_49','l52_53','l43_153','l43_73','l51_46','l42_51','m48_58','m45_153','l49_60','m37_50','l34_76','l36_147','l47_148','m41_154','m46_57','m48_149','m52_51','l43_45','m45_49','m48_51','l32_73','l45_61','m39_154','m49_59','l47_161','l50_51','l36_52','m30_75','l46_149','m36_153','l38_150','l48_60','m51_49','m36_74','l38_46','l37_48','m53_51','m40_147','m36_149','l46_54','m52_61','m49_57','m36_147','m51_55','m46_161','m45_76','m39_75','l53_49','l42_153','m40_75','l33_70','m42_55','l50_54','l43_74','m48_52','m49_148','l51_56','m43_52','l51_58','l40_49','m45_45','l45_53','l46_52','l51_51','m42_153','m48_152','m38_54','l34_71','l47_160','m45_148','m52_59','m51_52','m37_146','l45_145','m39_50','l42_151','l43_72','l42_49','m40_49','l47_152','m37_48','m51_62','m46_60','l49_51','l42_75','m49_58','m34_76','l38_51','m51_54','l37_146','m41_55','m50_52','m39_55','l50_46','l42_74','l50_53','l46_45','l38_153','l41_73','m45_73','m39_51','m48_62','l32_71','l50_60','m47_60','m43_47','l47_51','m39_153','m46_59','m48_53','m50_57','m34_71','l37_73','m43_45','l45_48','m50_154','l48_61','l39_49','m42_151','m37_153','l52_152','m44_54','l41_154','l48_47','m37_151','m39_54','l46_153','m47_48','l48_148','l46_62','m43_144','l44_74','m47_61','l33_75','m40_47','l45_46','l44_151','m33_73','l38_72','m45_146','l39_53','m38_49','l53_51','m52_154','l50_149','m36_53','m42_49','m47_51','m42_144','l50_49','l49_55','l48_57','m37_72','m49_55','l44_155','l50_56','l52_47','m38_53','l50_61','l44_154','m44_153','m33_74','l48_58','l38_74','m40_151','m50_50','l44_47','l34_74','l31_75','m40_48','m41_152','l40_73','m50_58','l49_57','m43_48','m43_55','m51_57','m46_49','l41_74','m48_49','m44_154','l41_51','m40_55','m43_49','m40_148','m36_76','m51_51','l45_47','l45_153','l49_56','l34_75','m48_60','l51_147','l50_154','l35_75','l38_152','m36_73','m41_73','m47_52','m48_54','l38_148','m36_146','m41_50','l48_149','m37_52','l41_48','m41_53','m51_59','m52_62','m52_152','l38_49','m46_45','l37_53','l39_73','m41_45','l37_55','l46_60','l40_147','m33_76','m39_52','l43_144','l40_76','m44_46','l40_149','m46_154','l43_146','l41_55','m41_49','l40_51','l36_75','m40_76','m38_74','l45_151','l38_151','l36_148','l33_71','l52_55','m37_55','m47_75','l52_52','m42_52','m49_54','m53_53','l39_50','m52_52','l46_150','m43_72','m33_75','l41_52','l45_148','l52_50','l44_153','l53_53','l44_148','l37_75','l39_52','l52_58','m36_75','m50_51','l51_57','m44_72','l45_45','m50_150','l48_155','m48_148','l41_54','m32_73','m40_72','l42_145','m37_147','l41_50','m47_59','m33_72','m40_50','m39_155','l52_61','l52_59','l37_154','l38_50','m37_73','l41_152','m47_47','m46_52','m39_151','l41_45','m43_146','l44_145','l40_47','l47_75','l40_151','l39_152','l45_73','m36_148','l37_151','m50_62','l47_47','m45_152','m47_149','l49_54','l43_75','l49_149','m45_55','l42_53','l39_51','l43_48','m46_54','l37_52','l39_55','l39_46','m52_50','m45_53','m40_152','m44_73','l39_75','m39_148','l41_49','l37_147','m45_155','m39_73','m45_62','m49_60','m40_154','l38_45','l43_145','m51_50','l51_61','l52_153','l43_47','l51_53','m38_72','m46_61','l47_49','l40_74','m38_147','l49_155','l37_153','l48_56','m51_46','l36_53','m45_50','m32_70','l46_47','m48_55','l40_154','m52_60','l44_146','m38_50','m40_153','l39_54','l41_56','l42_56','m43_50','l38_48','m39_150','l51_49','m38_48','m44_150','l45_51','l44_51','m48_56','m52_48'],nn=['gnomeball.mid','scape_cave.mid','lullaby.mid','regal2.mid','emperor.mid','wilderness3.mid','moody.mid','in_the_manor.mid','wilderness4.mid','fanfare2.mid','reggae2.mid','talking_forest.mid','army_of_darkness.mid','sea_shanty.mid','mage_arena.mid','spooky_jungle.mid','undercurrent.mid','ambience_4.mid','sad_meadow.mid','arabique.mid','faerie.mid','gnome_king.mid','deep_wildy.mid','crystal_cave.mid','attack3.mid','organ_music_2.mid','fishing.mid','game_intro_1.mid','march2.mid','rune_essence.mid','legion.mid','knightly.mid','scape_sad1.mid','jolly-r.mid','splendour.mid','attention.mid','tribal2.mid','expedition.mid','intrepid.mid','ballad_of_enchantment.mid','shining.mid','understanding.mid','gnome_village.mid','fade_test.mid','tribal.mid','beyond.mid','al_kharid.mid','nomad.mid','start.mid','silence.mid','high_seas.mid','doorways.mid','lasting.mid','crystal_sword.mid','the_shadow.mid','ambience_3.mid','theme.mid','wander.mid','null.mid','spooky2.mid','garden.mid','scape_soft.mid','miles_away.mid','soundscape.mid','gnome_theme.mid','duel_arena.mid','cellar_song1.mid','dunjun.mid','autumn_voyage.mid','starlight.mid','arabian3.mid','cavern.mid','cursed.mid','lightness.mid','underground.mid','landlubber.mid','heart_and_mind.mid','gaol.mid','lightwalk.mid','zealot.mid','cave_background1.mid','trinity.mid','iban.mid','dream1.mid','the_tower.mid','still_night.mid','wonderous.mid','forever.mid','egypt.mid','voyage.mid','baroque.mid','greatness.mid','troubled.mid','newbie_melody.mid','long_way_home.mid','chompy_hunt.mid','fanfare3.mid','horizon.mid','miracle_dance.mid','dark2.mid','the_desert.mid','vision.mid','royale.mid','ice_melody.mid','spirit.mid','serenade.mid','gnome.mid','overture.mid','big_chords.mid','sea_shanty2.mid','adventure.mid','camelot.mid','arrival.mid','flute_salad.mid','venture.mid','attack4.mid','nightfall.mid','unknown_land.mid','book_of_spells.mid','parade.mid','monarch_waltz.mid','voodoo_cult.mid','inspiration.mid','jungly1.mid','reggae.mid','shine.mid','quest.mid','long_ago.mid','tribal_background.mid','attack5.mid','riverside.mid','scape_main.mid','mellow.mid','upcoming.mid','neverland.mid','organ_music_1.mid','alone.mid','oriental.mid','wonder.mid','chain_of_command.mid','trawler_minor.mid','escape.mid','expanse.mid','wilderness2.mid','harmony.mid','emotion.mid','serene.mid','yesteryear.mid','jungle_island.mid','forbidden.mid','upass1.mid','desert_voyage.mid','jungly2.mid','grumpy.mid','magic_dance.mid','dangerous.mid','fanfare.mid','tree_spirits.mid','tomorrow.mid','workshop.mid','attack2.mid','jungly3.mid','expecting.mid','medieval.mid','magical_journey.mid','harmony2.mid','arabian2.mid','ambient_jungle.mid','wolf_mountain.mid','attack1.mid','trawler.mid','waterfall.mid','gnome_village2.mid','close_quarters.mid','lonesome.mid','arabian.mid','background2.mid','witching.mid','attack6.mid','ambience_2.mid','scape_wild1.mid','venture2.mid'],sn=['dice lose.mid','advance crafting.mid','advance woodcutting2.mid','advance defense.mid','advance fletching.mid','advance magic2.mid','advance cooking2.mid','sailing journey.mid','advance attack2.mid','death2.mid','advance firemarking.mid','advance strength2.mid','advance prayer.mid','advance ranged.mid','dice win.mid','quest complete 2.mid','advance hitpoints2.mid','advance ranged2.mid','advance smithing2.mid','advance crafting2.mid','advance strength.mid','advance hitpoints.mid','advance herblaw.mid','death.mid','duel win2.mid','advance prayer2.mid','advance woodcutting.mid','duel start.mid','advance thieving2.mid','advance smithing.mid','advance fishing.mid','treasure hunt win.mid','advance fletching2.mid','advance fishing2.mid','advance attack.mid','quest complete 3.mid','advance mining.mid','advance agility.mid','advance thieving.mid','advance cooking.mid','advance mining2.mid','advance defense2.mid','advance runecraft2.mid','quest complete 1.mid','advance magic.mid','advance firemarking2.mid','advance herblaw2.mid','advance runecraft.mid'],an=['m52_58','m53_50','m51_147','m43_73','m40_150','m40_149','m38_153','m50_149','m37_152','m39_74','m43_145','m46_149','m41_75','m37_150','m46_53','m34_70','m40_74','m35_76','m37_54','m39_45','m51_56','m41_151','m43_56','m44_53','m51_61','m39_147','m36_154','m47_150','m48_48','m44_146','m50_59','m39_149','m48_47','m33_71','m52_54','m50_46','m32_74','m41_146','m51_48','m50_53','m46_152','m46_75','m49_53','m46_48','m39_48','m39_46','m42_73','m47_50','m34_73','m53_49','m40_51','m37_51','m45_154','m32_75','m43_75','m49_62','m41_74','m47_53','m49_48','m44_148','m42_50','m40_53','m42_53','m35_75','m35_20','m45_145','m40_52','m50_153','m44_149','m46_56','m49_149','m50_60','m42_152','m37_75','m41_54','m52_47','m44_145','m44_151','m49_47','m52_53','m47_49','m39_72','m49_153','m37_74','m49_52','m37_148','m31_75','m44_155','m41_72','m41_51','m47_56','m44_49','m49_51','m41_56','m46_50','m37_49','m46_150','m45_75','m45_52','m36_150','m49_56','m38_149','m51_53','m48_156','m29_75','m42_51','m47_153','m41_46','m45_60','m44_75','m47_55','m38_47','m50_152','m36_54','m45_151','m46_153','m40_45','m39_152','m45_74','m47_57','m50_48','m37_154','m45_58','m49_156','m42_54','m43_54','m48_57','m50_61','m41_47','m39_47','m41_52','m45_47','m50_49','m34_75','m46_46','m38_148','m44_48','m42_74','m43_74','m42_145','m38_155','m44_144','m39_76','m49_50','m40_54','m47_54','m38_150','m44_50','m38_151','m48_154','m41_153','m38_45','m43_53','m38_154','m32_71','m38_52','m45_61','m47_161','m47_58','m36_52','m46_47','m50_55','m44_45','m45_48','m46_58','m37_53','m48_61','m45_56','m45_57','m38_73','m39_49','m45_150','m52_153','m50_56','m46_55','m52_57','m44_152','m51_154','m43_153','m39_53','m51_60','m34_74','m53_52','m34_72','m47_152','m44_52','m38_51','m51_47','m49_154','m42_75','m38_55','m42_72','m49_61','m50_54','m33_70','m40_46','m49_155','m38_146','m52_46','m41_48','m45_59','m44_47','m46_51','m36_72','m47_148','m48_155','m43_51','m40_73','m43_46','m50_47','m44_51','m43_154','m44_74','m44_55','m37_149','m45_46','m38_152','m41_149','m49_46','m46_62','m32_72','m47_62','m42_56','m48_153','m52_55','m48_59','m52_49','m42_146','m51_58','m45_51','m48_50','m52_56','m45_54','m38_46','m47_160','m49_49','m48_58','m45_153','m37_50','m41_154','m46_57','m48_149','m52_51','m45_49','m48_51','m39_154','m49_59','m30_75','m36_153','m51_49','m36_74','m53_51','m40_147','m36_149','m52_61','m49_57','m36_147','m51_55','m46_161','m45_76','m39_75','m40_75','m42_55','m48_52','m49_148','m43_52','m45_45','m42_153','m48_152','m38_54','m45_148','m52_59','m51_52','m37_146','m39_50','m40_49','m37_48','m51_62','m46_60','m49_58','m34_76','m51_54','m41_55','m50_52','m39_55','m45_73','m39_51','m48_62','m47_60','m43_47','m39_153','m46_59','m48_53','m50_57','m34_71','m43_45','m50_154','m42_151','m37_153','m44_54','m37_151','m39_54','m47_48','m43_144','m47_61','m40_47','m33_73','m45_146','m38_49','m52_154','m36_53','m42_49','m47_51','m42_144','m37_72','m49_55','m38_53','m44_153','m33_74','m40_151','m50_50','m40_48','m41_152','m50_58','m43_48','m43_55','m51_57','m46_49','m48_49','m44_154','m40_55','m43_49','m40_148','m36_76','m51_51','m48_60','m36_73','m41_73','m47_52','m48_54','m36_146','m41_50','m37_52','m41_53','m51_59','m52_62','m52_152','m46_45','m41_45','m33_76','m39_52','m44_46','m46_154','m41_49','m40_76','m38_74','m37_55','m47_75','m42_52','m49_54','m53_53','m52_52','m43_72','m33_75','m36_75','m50_51','m44_72','m50_150','m48_148','m32_73','m40_72','m37_147','m47_59','m33_72','m40_50','m39_155','m37_73','m47_47','m46_52','m39_151','m43_146','m36_148','m50_62','m45_152','m47_149','m45_55','m46_54','m52_50','m45_53','m40_152','m44_73','m39_148','m45_155','m39_73','m45_62','m49_60','m40_154','m51_50','m38_72','m46_61','m38_147','m51_46','m45_50','m32_70','m48_55','m52_60','m38_50','m40_153','m43_50','m39_150','m38_48','m44_150','m48_56','m52_48']}));ji();var Fn,Hn,jn,Vn,{default:Gn}=()=>({}),zn=function(t,e){let r,i=0,n='',s='';for(;i=65&&i<=90?e+=BigInt(i+1-65):i>=97&&i<=122?e+=BigInt(i+1-97):i>=48&&i<=57&&(e+=BigInt(i+27-48))}return e}function $n(t){if(t<0n||t>=6582952005840035281n)return'invalid_name';if(t%37n===0n)return'invalid_name';let e=0;const r=Array(12);for(;0n!==t;){const i=t;t/=37n,r[11-e++]=Qn[Number(i-37n*t)]}return r.slice(12-e).join('')}function Xn(t){return e=function(t){return $n(Zn(t))}(t).replaceAll('_',' '),e.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()));var e}var Qn=['_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9'],{default:Jn}=()=>({});ji();var ts=((t,e,r)=>{r=null!=t?p(g(t)):{};const i=!e&&t&&t.__esModule?r:m(r,'default',{value:t,enumerable:!0});for(let e of y(t))b.call(i,e)||m(i,e,{get:()=>t[e],enumerable:!0});return i})(Dn(),1),{default:es}=()=>({});class rs{key;next;prev;constructor(){this.key=0n,this.next=this,this.prev=this}unlink(){this.prev&&this.next&&(this.prev.next=this.next,this.next.prev=this.prev,this.next=null,this.prev=null)}}class is{sentinel;cursor=null;constructor(){const t=new rs;t.next=t,t.prev=t,this.sentinel=t}addTail(t){t.prev&&t.unlink(),t.prev=this.sentinel.prev,t.next=this.sentinel,t.prev&&(t.prev.next=t),t.next.prev=t}addHead(t){t.prev&&t.unlink(),t.prev=this.sentinel,t.next=this.sentinel.next,t.prev.next=t,t.next&&(t.next.prev=t)}removeHead(){const t=this.sentinel.next;return t===this.sentinel?null:(t?.unlink(),t)}head(){const t=this.sentinel.next;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.next||null,t)}tail(){const t=this.sentinel.prev;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.prev||null,t)}next(){const t=this.cursor;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.next||null,t)}prev(){const t=this.cursor;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.prev||null,t)}clear(){for(;;){const t=this.sentinel.next;if(t===this.sentinel)return;t?.unlink()}}}class ns extends rs{nextHashable;prevHashable;constructor(){super(),this.nextHashable=this,this.prevHashable=this}uncache(){this.prevHashable&&this.nextHashable&&(this.prevHashable.nextHashable=this.nextHashable,this.nextHashable.prevHashable=this.prevHashable,this.nextHashable=null,this.prevHashable=null)}}ts.default.pki.rsa.PrivateKey;var ss=ts.default.jsbn.BigInteger;class as extends ns{static crctable=new Int32Array(256);static bitmask=new Uint32Array(33);static crc32b=3988292384;static{for(let t=0;t<32;t++)this.bitmask[t]=(1<>>=1:e=e>>>1^this.crc32b;this.crctable[t]=e}}static getcrc(t,e,r){let i=4294967295;for(let n=e;n>>8^this.crctable[255&(i^t[n])];return~i}static checkcrc(t,e,r,i=0){return as.getcrc(t,e,r)==i}static alloc(t){let e=null;return 0===t&&this.cacheMinCount>0?(e=this.cacheMin.removeHead(),this.cacheMinCount--):1===t&&this.cacheMidCount>0?(e=this.cacheMid.removeHead(),this.cacheMidCount--):2===t&&this.cacheMaxCount>0?(e=this.cacheMax.removeHead(),this.cacheMaxCount--):3===t&&this.cacheBigCount>0?(e=this.cacheBig.removeHead(),this.cacheBigCount--):4===t&&this.cacheHugeCount>0?(e=this.cacheHuge.removeHead(),this.cacheHugeCount--):5===t&&this.cacheUnimaginableCount>0&&(e=this.cacheUnimaginable.removeHead(),this.cacheUnimaginableCount--),null!==e?(e.pos=0,e.bitPos=0,e):new as(0===t?new Uint8Array(100):1===t?new Uint8Array(5e3):2===t?new Uint8Array(3e4):3===t?new Uint8Array(1e5):4===t?new Uint8Array(5e5):5===t?new Uint8Array(2e6):new Uint8Array(t))}static load(t,e=!1){const r=new as(new Uint8Array(es.readFileSync(t)));return e&&(r.pos=r.data.length),r}static async loadAsync(t,e=!1){const r=new as(new Uint8Array(await(await fetch(t)).arrayBuffer()));return e&&(r.pos=r.data.length),r}static cacheMinCount=0;static cacheMidCount=0;static cacheMaxCount=0;static cacheBigCount=0;static cacheHugeCount=0;static cacheUnimaginableCount=0;static cacheMin=new is;static cacheMid=new is;static cacheMax=new is;static cacheBig=new is;static cacheHuge=new is;static cacheUnimaginable=new is;data;#t;pos;bitPos;constructor(t){super(),this.data=t,this.#t=new DataView(this.data.buffer),this.pos=0,this.bitPos=0}get available(){return this.data.length-this.pos}get length(){return this.data.length}release(){this.pos=0,this.bitPos=0,100===this.data.length&&as.cacheMinCount<1e3?(as.cacheMin.addTail(this),as.cacheMinCount++):5e3===this.data.length&&as.cacheMidCount<250?(as.cacheMid.addTail(this),as.cacheMidCount++):3e4===this.data.length&&as.cacheMaxCount<50?(as.cacheMax.addTail(this),as.cacheMaxCount++):1e5===this.data.length&&as.cacheBigCount<10?(as.cacheBig.addTail(this),as.cacheBigCount++):5e5===this.data.length&&as.cacheHugeCount<5?(as.cacheHuge.addTail(this),as.cacheHugeCount++):2e6===this.data.length&&as.cacheUnimaginableCount<2&&(as.cacheUnimaginable.addTail(this),as.cacheUnimaginableCount++)}save(t,e=this.pos,r=0){if('undefined'!=typeof self){const i=new Blob([this.data.subarray(r,r+e)],{type:'application/octet-stream'}),n=URL.createObjectURL(i);self.postMessage({type:'save',value:n,path:t})}else{const i=f.dirname(t);es.existsSync(i)||es.mkdirSync(i,{recursive:!0}),es.writeFileSync(t,this.data.subarray(r,r+e))}}p1(t){this.#t.setUint8(this.pos++,t)}p2(t){this.#t.setUint16(this.pos,t),this.pos+=2}ip2(t){this.#t.setUint16(this.pos,t,!0),this.pos+=2}p3(t){this.#t.setUint8(this.pos++,t>>16),this.#t.setUint16(this.pos,t),this.pos+=2}p4(t){this.#t.setInt32(this.pos,t),this.pos+=4}ip4(t){this.#t.setInt32(this.pos,t,!0),this.pos+=4}p8(t){this.#t.setBigInt64(this.pos,t),this.pos+=8}pbool(t){this.p1(t?1:0)}pjstr(t,e=10){const r=t.length;for(let e=0;e=64)this.p1(t+64);else{if(!(t<16384&&t>=-16384))throw new Error('Error psmarts out of range: '+t);this.p2(t+49152)}}psmart(t){if(t>=0&&t<128)this.p1(t);else{if(!(t>=0&&t<32768))throw new Error('Error psmart out of range: '+t);this.p2(t+32768)}}g1(){return this.#t.getUint8(this.pos++)}g1b(){return this.#t.getInt8(this.pos++)}g2(){return this.pos+=2,this.#t.getUint16(this.pos-2)}g2s(){return this.pos+=2,this.#t.getInt16(this.pos-2)}ig2(){return this.pos+=2,this.#t.getUint16(this.pos-2,!0)}g3(){const t=this.#t.getUint8(this.pos++)<<16|this.#t.getUint16(this.pos);return this.pos+=2,t}g4(){return this.pos+=4,this.#t.getInt32(this.pos-4)}ig4(){return this.pos+=4,this.#t.getInt32(this.pos-4,!0)}g8(){return this.pos+=8,this.#t.getBigInt64(this.pos-8)}gbool(){return 1===this.g1()}gjstr(t=10){const e=this.data.length;let r,i='';for(;(r=this.#t.getUint8(this.pos++))!==t&&this.pos>>3}gBit(t){let e=this.bitPos>>>3,r=8-(7&this.bitPos),i=0;for(this.bitPos+=t;t>r;r=8)i+=(this.#t.getUint8(e++)&as.bitmask[r])<>>r-t&as.bitmask[t],i}pBit(t,e){const r=this.bitPos;this.bitPos+=t;let i=r>>>3,n=8-(7&r);const s=this.#t;for(;t>n;n=8){const r=(1<>>t-n&r),t-=n}const a=n-t,o=(1<0;){const e=t.g1();if(0===e)break;this.decode(e,t)}}}class hs extends os{static configNames=new Map;static configs=[];static load(t){if(!Jn.existsSync(`${t}/server/category.dat`))return void console.log('Warning: No category.dat found.');const e=as.load(`${t}/server/category.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/category.dat`)).ok)return void console.log('Warning: No category.dat found.');const e=await as.loadAsync(`${t}/server/category.dat`);this.parse(e)}static parse(t){hs.configNames=new Map,hs.configs=[];const e=t.g2();for(let r=0;r({}),{default:cs}=()=>({});class us{static INT=105;static AUTOINT=255;static STRING=115;static ENUM=103;static OBJ=111;static LOC=108;static COMPONENT=73;static NAMEDOBJ=79;static STRUCT=74;static BOOLEAN=49;static COORD=99;static CATEGORY=121;static SPOTANIM=116;static NPC=110;static INV=118;static SYNTH=80;static SEQ=65;static STAT=83;static VARP=86;static PLAYER_UID=112;static NPC_UID=78;static INTERFACE=97;static NPC_STAT=254;static IDKIT=75;static getType(t){switch(t){case us.INT:return'int';case us.STRING:return'string';case us.ENUM:return'enum';case us.OBJ:return'obj';case us.LOC:return'loc';case us.COMPONENT:return'component';case us.NAMEDOBJ:return'namedobj';case us.STRUCT:return'struct';case us.BOOLEAN:return'boolean';case us.COORD:return'coord';case us.CATEGORY:return'category';case us.SPOTANIM:return'spotanim';case us.NPC:return'npc';case us.INV:return'inv';case us.SYNTH:return'synth';case us.SEQ:return'seq';case us.STAT:return'stat';case us.AUTOINT:return'autoint';case us.VARP:return'varp';case us.PLAYER_UID:return'player_uid';case us.NPC_UID:return'npc_uid';case us.INTERFACE:return'interface';case us.NPC_STAT:return'npc_stat';case us.IDKIT:return'idkit';default:return'unknown'}}static getTypeChar(t){let e='i';switch(t){case'int':e='i';break;case'autoint':e='ÿ';break;case'string':e='s';break;case'enum':e='g';break;case'obj':e='o';break;case'loc':e='l';break;case'component':e='I';break;case'namedobj':e='O';break;case'struct':e='J';break;case'boolean':e='1';break;case'coord':e='c';break;case'category':e='y';break;case'spotanim':e='t';break;case'npc':e='n';break;case'inv':e='v';break;case'synth':e='P';break;case'seq':e='A';break;case'stat':e='S';break;case'varp':e='V';break;case'player_uid':e='p';break;case'npc_uid':e='N';break;case'interface':e='a';break;case'npc_stat':e='þ';break;case'idkit':e='K';break;default:return null}return e.charCodeAt(0)}static getDefault(t){return t===us.STRING?'':t===us.BOOLEAN?0:-1}}class ds extends os{static configNames=new Map;static configs=[];static load(t){if(!cs.existsSync(`${t}/server/dbtable.dat`))return void console.log('Warning: No dbtable.dat found.');const e=as.load(`${t}/server/dbtable.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/dbtable.dat`)).ok)return void console.log('Warning: No dbtable.dat found.');const e=await as.loadAsync(`${t}/server/dbtable.dat`);this.parse(e)}static parse(t){ds.configNames=new Map,ds.configs=[];const e=t.g2();for(let r=0;re.tableId===t))}tableId=0;types=[];columnValues=[];decode(t,e){if(3===t){const t=e.g1();this.types=new Array(t),this.columnValues=new Array(t);for(let t=e.g1();255!=t;t=e.g1()){const r=new Array(e.g1());for(let t=0;t({});class ms extends os{static configNames=new Map;static configs=[];static load(t){if(!ps.existsSync(`${t}/server/enum.dat`))return void console.log('Warning: No enum.dat found.');const e=as.load(`${t}/server/enum.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/enum.dat`)).ok)return void console.log('Warning: No enum.dat found.');const e=await as.loadAsync(`${t}/server/enum.dat`);this.parse(e)}static parse(t){ms.configNames=new Map,ms.configs=[];const e=t.g2();for(let r=0;r{r=t,i=e}));['_BZ2_bzBuffToBuffDecompress','_BZ2_bzBuffToBuffCompress','_malloc','_free','_memory','___indirect_function_table','onRuntimeInitialized'].forEach((t=>{Object.getOwnPropertyDescriptor(s,t)||Object.defineProperty(s,t,{get:()=>W('You are getting '+t+' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),set:()=>W('You are setting '+t+' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js')})}));var a='object'==typeof window,o='function'==typeof importScripts,h='object'==typeof process&&'object'==typeof process.versions&&'string'==typeof process.versions.node,l=!a&&!h&&!o;if(n.ENVIRONMENT)throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');if(h){const{createRequire:t}=await import('module');var c=t(import.meta.url)}var u,d,f,p=Object.assign({},n),m=(t,e)=>{throw e},g='';if(h){if('undefined'==typeof process||!process.release||'node'!==process.release.name)throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');var y=process.versions.node,v=y.split('.').slice(0,3);if((v=1e4*v[0]+100*v[1]+1*v[2].split('-')[0])<16e4)throw new Error('This emscripten-generated code requires node v16.0.0 (detected v'+y+')');var b=c('fs'),_=c('path');g=c('url').fileURLToPath(new URL('./',import.meta.url)),u=(t,e)=>(t=Z(t)?new URL(t):_.normalize(t),b.readFileSync(t,e?void 0:'utf8')),f=t=>{var e=u(t,!0);return e.buffer||(e=new Uint8Array(e)),B(e.buffer),e},d=(t,e,r,i=!0)=>{t=Z(t)?new URL(t):_.normalize(t),b.readFile(t,i?void 0:'utf8',((t,n)=>{t?r(t):e(i?n.buffer:n)}))},!n.thisProgram&&process.argv.length>1&&process.argv[1].replace(/\\/g,'/'),process.argv.slice(2),m=(t,e)=>{throw process.exitCode=t,e}}else if(l){if('object'==typeof process&&'function'==typeof c||'object'==typeof window||'function'==typeof importScripts)throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)')}else{if(!a&&!o)throw new Error('environment detection error');if(o?g=self.location.href:'undefined'!=typeof document&&document.currentScript&&(g=document.currentScript.src),gs&&(g=gs),g=g.startsWith('blob:')?'':g.substr(0,g.replace(/[?#].*/,'').lastIndexOf('/')+1),'object'!=typeof window&&'function'!=typeof importScripts)throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');u=t=>{var e=new XMLHttpRequest;return e.open('GET',t,!1),e.send(null),e.responseText},o&&(f=t=>{var e=new XMLHttpRequest;return e.open('GET',t,!1),e.responseType='arraybuffer',e.send(null),new Uint8Array(e.response)}),d=(t,e,r)=>{var i=new XMLHttpRequest;i.open('GET',t,!0),i.responseType='arraybuffer',i.onload=()=>{200==i.status||0==i.status&&i.response?e(i.response):r()},i.onerror=r,i.send(null)}}var w,E,A,S=n.print||console.log.bind(console),T=n.printErr||console.error.bind(console);Object.assign(n,p),p=null,w='fetchSettings',Object.getOwnPropertyDescriptor(n,w)&&W(`\`Module.${w}\` was supplied but \`${w}\` not included in INCOMING_MODULE_JS_API`),n.arguments&&n.arguments,tt('arguments','arguments_'),n.thisProgram&&n.thisProgram,tt('thisProgram','thisProgram'),n.quit&&(m=n.quit),tt('quit','quit_'),B(void 0===n.memoryInitializerPrefixURL,'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead'),B(void 0===n.pthreadMainPrefixURL,'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead'),B(void 0===n.cdInitializerPrefixURL,'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead'),B(void 0===n.filePackagePrefixURL,'Module.filePackagePrefixURL option was removed, use Module.locateFile instead'),B(void 0===n.read,'Module.read option was removed (modify read_ in JS)'),B(void 0===n.readAsync,'Module.readAsync option was removed (modify readAsync in JS)'),B(void 0===n.readBinary,'Module.readBinary option was removed (modify readBinary in JS)'),B(void 0===n.setWindowTitle,'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)'),B(void 0===n.TOTAL_MEMORY,'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY'),tt('asm','wasmExports'),tt('read','read_'),tt('readAsync','readAsync'),tt('readBinary','readBinary'),tt('setWindowTitle','setWindowTitle'),B(!l,'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.'),n.wasmBinary&&(E=n.wasmBinary),tt('wasmBinary','wasmBinary'),'object'!=typeof WebAssembly&&T('no native wasm support detected');var M,I,C,O,N,L,R,P=!1;function B(t,e){t||W('Assertion failed'+(e?': '+e:''))}function k(){var t=A.buffer;n.HEAP8=M=new Int8Array(t),n.HEAP16=C=new Int16Array(t),n.HEAPU8=I=new Uint8Array(t),n.HEAPU16=new Uint16Array(t),n.HEAP32=O=new Int32Array(t),n.HEAPU32=N=new Uint32Array(t),n.HEAPF32=L=new Float32Array(t),n.HEAPF64=R=new Float64Array(t)}function D(){if(!P){var t=Et();0==t&&(t+=4);var e=N[t>>2],r=N[t+4>>2];34821223==e&&2310721022==r||W(`Stack overflow! Stack cookie has been overwritten at ${ht(t)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ht(r)} ${ht(e)}`),1668509029!=N[0]&&W('Runtime error: The application has corrupted its heap memory area (address zero)!')}}B(!n.STACK_SIZE,'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time'),B('undefined'!=typeof Int32Array&&'undefined'!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,'JS engine does not provide full typed array support'),B(!n.wasmMemory,'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally'),B(!n.INITIAL_MEMORY,'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically'),function(){var t=new Int16Array(1),e=new Int8Array(t.buffer);if(t[0]=25459,115!==e[0]||99!==e[1])throw'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)'}();var U=[],x=[],F=[],H=!1;B(Math.imul,'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'),B(Math.fround,'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'),B(Math.clz32,'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'),B(Math.trunc,'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');var j=0,V=null,G=null,z={};function W(t){n.onAbort?.(t),T(t='Aborted('+t+')'),P=!0;var e=new WebAssembly.RuntimeError(t);throw i(e),e}var K={error(){W('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM')},init(){K.error()},createDataFile(){K.error()},createPreloadedFile(){K.error()},createLazyFile(){K.error()},open(){K.error()},mkdev(){K.error()},registerDevice(){K.error()},analyzePath(){K.error()},ErrnoError(){K.error()}};n.FS_createDataFile=K.createDataFile,n.FS_createPreloadedFile=K.createPreloadedFile;var q,Y=t=>t.startsWith("data:application/octet-stream;base64,"),Z=t=>t.startsWith('file://');function $(t,e){return(...r)=>{B(H,`native function \`${t}\` called before runtime initialization`);var i=bt[t];return B(i,`exported native function \`${t}\` not found`),B(r.length<=e,`native function \`${t}\` called with ${r.length} args but expects ${e}`),i(...r)}}function X(){if(n.locateFile){var t='bzip2.wasm';return Y(t)?t:(e=t,n.locateFile?n.locateFile(e,g):g+e)}var e;return new URL('bzip2.wasm',import.meta.url).href}function Q(t){if(t==q&&E)return new Uint8Array(E);if(f)return f(t);throw'both async and sync fetching of the wasm failed'}function J(t,e,r){return function(t){if(!E&&(a||o)){if('function'==typeof fetch&&!Z(t))return fetch(t,{credentials:'same-origin'}).then((e=>{if(!e.ok)throw`failed to load wasm binary file at '${t}'`;return e.arrayBuffer()})).catch((()=>Q(t)));if(d)return new Promise(((e,r)=>{d(t,(t=>e(new Uint8Array(t))),r)}))}return Promise.resolve().then((()=>Q(t)))}(t).then((t=>WebAssembly.instantiate(t,e))).then(r,(t=>{T(`failed to asynchronously prepare wasm: ${t}`),Z(q)&&T(`warning: Loading from a file URI (${q}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),W(t)}))}function tt(t,e,r=!0){Object.getOwnPropertyDescriptor(n,t)||Object.defineProperty(n,t,{configurable:!0,get(){W(`\`Module.${t}\` has been replaced by \`${e}\``+(r?' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)':''))}})}function et(t){return'FS_createPath'===t||'FS_createDataFile'===t||'FS_createPreloadedFile'===t||'FS_unlink'===t||'addRunDependency'===t||'FS_createLazyFile'===t||'FS_createDevice'===t||'removeRunDependency'===t}function rt(t,e){'undefined'!=typeof globalThis&&Object.defineProperty(globalThis,t,{configurable:!0,get(){lt(`\`${t}\` is not longer defined by emscripten. ${e}`)}})}function it(t){Object.getOwnPropertyDescriptor(n,t)||Object.defineProperty(n,t,{configurable:!0,get(){var e=`'${t}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;et(t)&&(e+='. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'),W(e)}})}function nt(t){this.name='ExitStatus',this.message=`Program terminated with exit(${t})`,this.status=t}rt('buffer','Please use HEAP8.buffer or wasmMemory.buffer'),rt('asm','Please use wasmExports instead');var st,at=t=>{for(;t.length>0;)t.shift()(n)},ot=n.noExitRuntime||!0,ht=t=>(B('number'==typeof t),'0x'+(t>>>=0).toString(16).padStart(8,'0')),lt=t=>{lt.shown||={},lt.shown[t]||(lt.shown[t]=1,h&&(t='warning: '+t),T(t))},ct=t=>{var e=A.buffer,r=(t-e.byteLength+65535)/65536;try{return A.grow(r),k(),1}catch(r){T(`growMemory: Attempted to grow heap from ${e.byteLength} bytes to ${t} bytes, but got error: ${r}`)}},ut=()=>ot||!1,dt=(t,e)=>{if(function(){var t=S,e=T,r=!1;S=T=t=>{r=!0};try{yt()}catch(t){}S=t,T=e,r&&(lt('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.'),lt('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)'))}(),ut()&&!e){var r=`program exited (with status: ${t}), but keepRuntimeAlive() is set (counter=0) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;i(r),T(r)}var s;s=t,ut()||(n.onExit?.(s),P=!0),m(s,new nt(s))},ft='undefined'!=typeof TextDecoder?new TextDecoder('utf8'):void 0,pt=(t,e,r)=>{for(var i=e+r,n=e;t[n]&&!(n>=i);)++n;if(n-e>16&&t.buffer&&ft)return ft.decode(t.subarray(e,n));for(var s='';e>10,56320|1023&l)}}else s+=String.fromCharCode((31&a)<<6|o)}else s+=String.fromCharCode(a)}return s},mt=[null,[],[]],gt=(t,e)=>{var r=mt[t];B(r),0===e||10===e?((1===t?S:T)(pt(r,0)),r.length=0):r.push(e)},yt=()=>{_t(0),mt[1].length&>(1,10),mt[2].length&>(2,10)},vt={_emscripten_memcpy_js:(t,e,r)=>I.copyWithin(t,e,e+r),emscripten_resize_heap:t=>{var e=I.length;B((t>>>=0)>e);var r=2147483648;if(t>r)return T(`Cannot enlarge memory, requested ${t} bytes, but the limit is 2147483648 bytes!`),!1;for(var i=(t,e)=>t+(e-t%e)%e,n=1;n<=4;n*=2){var s=e*(1+.2/n);s=Math.min(s,t+100663296);var a=Math.min(r,i(Math.max(t,s),65536));if(ct(a))return!0}return T(`Failed to grow the heap from ${e} bytes to ${a} bytes, not enough memory!`),!1},exit:dt,fd_close:t=>{W('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM')},fd_seek:function(t,e,r,i,n){var s,a;return a=r,B((s=e)==s>>>0||s==(0|s)),B(a===(0|a)),70},fd_write:(t,e,r,i)=>{for(var n=0,s=0;s>2],o=N[e+4>>2];e+=8;for(var h=0;h>2]=n,0}},bt=function(){var t,e={env:vt,wasi_snapshot_preview1:vt};function r(t,e){var r;return bt=t.exports,B(A=bt.memory,'memory not found in wasm exports'),k(),r=bt.__wasm_call_ctors,x.unshift(r),function(t){if(j--,n.monitorRunDependencies?.(j),t?(B(z[t]),delete z[t]):T('warning: run dependency removed without ID'),0==j&&(null!==V&&(clearInterval(V),V=null),G)){var e=G;G=null,e()}}('wasm-instantiate'),bt}t='wasm-instantiate',j++,n.monitorRunDependencies?.(j),t?(B(!z[t]),z[t]=1,null===V&&'undefined'!=typeof setInterval&&(V=setInterval((()=>{if(P)return clearInterval(V),void(V=null);var t=!1;for(var e in z)t||(t=!0,T('still waiting on run dependencies:')),T(`dependency: ${e}`);t&&T('(end of list)')}),1e4))):T('warning: run dependency added without ID');var s,a,o,l,c=n;if(n.instantiateWasm)try{return n.instantiateWasm(e,r)}catch(t){T(`Module.instantiateWasm callback failed with error: ${t}`),i(t)}return q||(q=X()),(s=E,a=q,o=e,l=function(t){B(n===c,'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?'),c=null,r(t.instance)},s||'function'!=typeof WebAssembly.instantiateStreaming||Y(a)||Z(a)||h||'function'!=typeof fetch?J(a,o,l):fetch(a,{credentials:'same-origin'}).then((t=>WebAssembly.instantiateStreaming(t,o).then(l,(function(t){return T(`wasm streaming compile failed: ${t}`),T('falling back to ArrayBuffer instantiation'),J(a,o,l)}))))).catch(i),{}}(),_t=($('__wasm_call_ctors',0),n._malloc=$('malloc',1),n._free=$('free',1),$('fflush',1)),wt=(n._BZ2_bzBuffToBuffCompress=$('BZ2_bzBuffToBuffCompress',7),n._BZ2_bzBuffToBuffDecompress=$('BZ2_bzBuffToBuffDecompress',6),()=>(wt=bt.emscripten_stack_init)()),Et=()=>(Et=bt.emscripten_stack_get_end)();function At(){var t;wt(),B(!(3&(t=Et()))),0==t&&(t+=4),N[t>>2]=34821223,N[t+4>>2]=2310721022,N[0]=1668509029}function St(){function t(){st||(st=!0,n.calledRun=!0,P||(B(!H),H=!0,D(),at(x),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),B(!n._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){if(D(),n.postRun)for('function'==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)t=n.postRun.shift(),F.unshift(t);var t;at(F)}()))}j>0||(At(),function(){if(n.preRun)for('function'==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)t=n.preRun.shift(),U.unshift(t);var t;at(U)}(),j>0||(n.setStatus?(n.setStatus('Running...'),setTimeout((function(){setTimeout((function(){n.setStatus('')}),1),t()}),1)):t(),D()))}if(n.dynCall_jiji=$('dynCall_jiji',5),n.setValue=function(t,e,r="i8"){switch(r.endsWith('*')&&(r='*'),r){case'i1':case'i8':M[t]=e;break;case'i16':C[t>>1]=e;break;case'i32':O[t>>2]=e;break;case'i64':W('to do setValue(i64) use WASM_BIGINT');case'float':L[t>>2]=e;break;case'double':R[t>>3]=e;break;case'*':N[t>>2]=e;break;default:W(`invalid type for setValue: ${r}`)}},n.getValue=function(t,e="i8"){switch(e.endsWith('*')&&(e='*'),e){case'i1':case'i8':return M[t];case'i16':return C[t>>1];case'i32':return O[t>>2];case'i64':W('to do getValue(i64) use WASM_BIGINT');case'float':return L[t>>2];case'double':return R[t>>3];case'*':return N[t>>2];default:W(`invalid type for getValue: ${e}`)}},['writeI53ToI64','writeI53ToI64Clamped','writeI53ToI64Signaling','writeI53ToU64Clamped','writeI53ToU64Signaling','readI53FromI64','readI53FromU64','convertI32PairToI53','convertU32PairToI53','stackAlloc','getTempRet0','setTempRet0','zeroMemory','isLeapYear','ydayFromDate','arraySum','addDays','inetPton4','inetNtop4','inetPton6','inetNtop6','readSockaddr','writeSockaddr','initRandomFill','randomFill','emscriptenLog','readEmAsmArgs','jstoi_q','getExecutableName','listenOnce','autoResumeAudioContext','dynCallLegacy','getDynCaller','dynCall','handleException','runtimeKeepalivePush','runtimeKeepalivePop','callUserCallback','maybeExit','asmjsMangle','asyncLoad','alignMemory','mmapAlloc','HandleAllocator','getNativeTypeSize','STACK_SIZE','STACK_ALIGN','POINTER_SIZE','ASSERTIONS','getCFunc','ccall','cwrap','uleb128Encode','sigToWasmTypes','generateFuncType','convertJsFunctionToWasm','getEmptyTableSlot','updateTableMap','getFunctionAddress','addFunction','removeFunction','reallyNegative','unSign','strLen','reSign','formatString','stringToUTF8Array','stringToUTF8','lengthBytesUTF8','intArrayFromString','intArrayToString','AsciiToString','stringToAscii','UTF16ToString','stringToUTF16','lengthBytesUTF16','UTF32ToString','stringToUTF32','lengthBytesUTF32','stringToNewUTF8','stringToUTF8OnStack','writeArrayToMemory','registerKeyEventCallback','maybeCStringToJsString','findEventTarget','getBoundingClientRect','fillMouseEventData','registerMouseEventCallback','registerWheelEventCallback','registerUiEventCallback','registerFocusEventCallback','fillDeviceOrientationEventData','registerDeviceOrientationEventCallback','fillDeviceMotionEventData','registerDeviceMotionEventCallback','screenOrientation','fillOrientationChangeEventData','registerOrientationChangeEventCallback','fillFullscreenChangeEventData','registerFullscreenChangeEventCallback','JSEvents_requestFullscreen','JSEvents_resizeCanvasForFullscreen','registerRestoreOldStyle','hideEverythingExceptGivenElement','restoreHiddenElements','setLetterbox','softFullscreenResizeWebGLRenderTarget','doRequestFullscreen','fillPointerlockChangeEventData','registerPointerlockChangeEventCallback','registerPointerlockErrorEventCallback','requestPointerLock','fillVisibilityChangeEventData','registerVisibilityChangeEventCallback','registerTouchEventCallback','fillGamepadEventData','registerGamepadEventCallback','registerBeforeUnloadEventCallback','fillBatteryEventData','battery','registerBatteryEventCallback','setCanvasElementSize','getCanvasElementSize','jsStackTrace','getCallstack','convertPCtoSourceLocation','getEnvStrings','checkWasiClock','wasiRightsToMuslOFlags','wasiOFlagsToMuslOFlags','createDyncallWrapper','safeSetTimeout','setImmediateWrapped','clearImmediateWrapped','polyfillSetImmediate','getPromise','makePromise','idsToPromises','makePromiseCallback','ExceptionInfo','findMatchingCatch','Browser_asyncPrepareDataCounter','setMainLoop','getSocketFromFD','getSocketAddress','FS_createPreloadedFile','FS_modeStringToFlags','FS_getMode','FS_stdin_getChar','FS_createDataFile','FS_unlink','FS_mkdirTree','_setNetworkCallback','heapObjectForWebGLType','toTypedArrayIndex','webgl_enable_ANGLE_instanced_arrays','webgl_enable_OES_vertex_array_object','webgl_enable_WEBGL_draw_buffers','webgl_enable_WEBGL_multi_draw','emscriptenWebGLGet','computeUnpackAlignedImageSize','colorChannelsInGlTextureFormat','emscriptenWebGLGetTexPixelData','emscriptenWebGLGetUniform','webglGetUniformLocation','webglPrepareUniformLocationsBeforeFirstUse','webglGetLeftBracePos','emscriptenWebGLGetVertexAttrib','__glGetActiveAttribOrUniform','writeGLArray','registerWebGlEventCallback','runAndAbortIfError','ALLOC_NORMAL','ALLOC_STACK','allocate','writeStringToMemory','writeAsciiToMemory','setErrNo','demangle','stackTrace'].forEach((function(t){'undefined'==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,t)||Object.defineProperty(globalThis,t,{configurable:!0,get(){var e=`\`${t}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`,r=t;r.startsWith('_')||(r='$'+t),e+=` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${r}')`,et(t)&&(e+='. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'),lt(e)}}),it(t)})),['run','addOnPreRun','addOnInit','addOnPreMain','addOnExit','addOnPostRun','addRunDependency','removeRunDependency','FS_createFolder','FS_createPath','FS_createLazyFile','FS_createLink','FS_createDevice','FS_readFile','out','err','callMain','abort','wasmMemory','wasmExports','writeStackCookie','checkStackCookie','convertI32PairToI53Checked','stackSave','stackRestore','ptrToString','exitJS','getHeapMax','growMemory','ENV','MONTH_DAYS_REGULAR','MONTH_DAYS_LEAP','MONTH_DAYS_REGULAR_CUMULATIVE','MONTH_DAYS_LEAP_CUMULATIVE','ERRNO_CODES','ERRNO_MESSAGES','DNS','Protocols','Sockets','timers','warnOnce','readEmAsmArgsArray','jstoi_s','keepRuntimeAlive','wasmTable','noExitRuntime','freeTableIndexes','functionsInTableMap','PATH','PATH_FS','UTF8Decoder','UTF8ArrayToString','UTF8ToString','UTF16Decoder','JSEvents','specialHTMLTargets','findCanvasEventTarget','currentFullscreenStrategy','restoreOldWindowedStyle','UNWIND_CACHE','ExitStatus','flush_NO_FILESYSTEM','promiseMap','uncaughtExceptionCount','exceptionLast','exceptionCaught','Browser','getPreloadedImageData__data','wget','SYSCALLS','preloadPlugins','FS_stdin_getChar_buffer','FS','MEMFS','TTY','PIPEFS','SOCKFS','tempFixedLengthArray','miniTempWebGLFloatBuffers','miniTempWebGLIntBuffers','GL','AL','GLUT','EGL','GLEW','IDBStore','SDL','SDL_gfx','allocateUTF8','allocateUTF8OnStack'].forEach(it),G=function t(){st||St(),st||(G=t)},n.preInit)for('function'==typeof n.preInit&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();St(),e=s;for(const e of Object.keys(n))e in t||Object.defineProperty(t,e,{configurable:!0,get(){W(`Access to module property ('${e}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return e}),vs=ys,bs={'-2':'BZ_PARAM_ERROR: incorrect parameters','-3':"BZ_MEM_ERROR: couldn't allocate enough memory",'-4':'BZ_DATA_ERROR: data integrity error when decompressing','-5':'BZ_DATA_ERROR_MAGIC: compressed data has incorrect header','-7':'BZ_UNEXPECTED_EOF: compressed data ends too early','-8':'BZ_OUTBUFF_FULL: destination buffer is full'};var _s=new class{constructor(){this.wasmModule=void 0}async init(){if(!this.wasmModule){if('undefined'!=typeof process){const{dirname:t}=await Promise.resolve().then((()=>(ji(),S))),{createRequire:e}=await import('module');globalThis.__dirname=t(import.meta.url),globalThis.require=e(import.meta.url)}this.wasmModule=await vs()}}ensureInitialized(){if(!this.wasmModule)throw new Error(`${this.constructor.name} not initalized. call .init()`)}handleError(t,e,r){if(0===t)return;this.wasmModule._free(e),this.wasmModule._free(r);const i=bs[t];if(i)throw new Error(i);throw new Error(`error code: ${t}`)}createWASMBuffers(t,e){const{_malloc:r,setValue:i,HEAPU8:n}=this.wasmModule,s=r(t.length);n.set(t,s);const a=r(e),o=r(e);return i(o,e,'i32'),{sourcePtr:s,destPtr:a,destLengthPtr:o}}createBuffer(t,e){const{_free:r,getValue:i,HEAPU8:n}=this.wasmModule,s=i(e,'i32'),a=new Uint8Array(s);return a.set(n.subarray(t,t+s)),r(t),r(e),a}decompress(t,e,r=!1,i=!1){if(i&&(e=t[0]<<24|t[1]<<16|t[2]<<8|t[3],t[0]='B'.charCodeAt(0),t[1]='Z'.charCodeAt(0),t[2]='h'.charCodeAt(0),t[3]='1'.charCodeAt(0),r=!1),r){const e=new Uint8Array(t.length+4);e[0]='B'.charCodeAt(0),e[1]='Z'.charCodeAt(0),e[2]='h'.charCodeAt(0),e[3]='1'.charCodeAt(0),e.set(t,4),t=e}this.ensureInitialized();const{sourcePtr:n,destPtr:s,destLengthPtr:a}=this.createWASMBuffers(t,e),o=this.wasmModule._BZ2_bzBuffToBuffDecompress(s,a,n,t.length,0,0);return this.wasmModule._free(n),this.handleError(o,s,a),this.createBuffer(s,a)}compress(t,e=!1,r=!1,i=1,n=0){if(this.ensureInitialized(),n||(n=t.length+1024),n<128&&(n=128),i<=0||i>9)throw new RangeError('blockSize should be between 1-9');const{sourcePtr:s,destPtr:a,destLengthPtr:o}=this.createWASMBuffers(t,n),h=this.wasmModule._BZ2_bzBuffToBuffCompress(a,o,s,t.length,i,0,30);this.wasmModule._free(s),this.handleError(h,a,o);const l=this.createBuffer(a,o);return e&&(l[0]=t.length>>24&255,l[1]=t.length>>16&255,l[2]=t.length>>8&255,l[3]=255&t.length),r?l.subarray(4):l}};await _s.init();var ws=_s;function Es(t){let e=0;t=t.toUpperCase();for(let r=0;rt===this.fileHash[e]));-1!==i&&(this.fileName[e]=Ss[i]),this.fileUnpackedSize[e]=t.g3(),this.filePackedSize[e]=t.g3(),this.filePos[e]=r,r+=this.filePackedSize[e]}}get(t){if(t<0||t>=this.fileCount)return null;if(null===this.data)throw new Error('Jagfile data is not loaded');const e=this.data.subarray(this.filePos[t],this.filePos[t]+this.filePackedSize[t]);return this.unpacked?new as(e):new as(ws.decompress(e,this.fileUnpackedSize[t],!0))}read(t){const e=Es(t);for(let t=0;tt===e.hash));if(e.write){if(-1===r&&(r=this.fileCount++,this.fileHash[r]=e.hash,this.fileName[r]=e.name),!e.data)throw new Error('Cannot write without data');this.fileUnpackedSize[r]=e.data.length,this.filePackedSize[r]=e.data.length,this.filePos[r]=-1,this.fileWrite[r]=e.data}if(e.delete&&-1!==r&&(this.fileHash.splice(r,1),this.fileName.splice(r,1),this.fileUnpackedSize.splice(r,1),this.filePackedSize.splice(r,1),this.filePos.splice(r,1),this.fileCount--),e.rename&&-1!==r){if(!e.newHash)throw new Error('Cannot rename without newHash');if(!e.newName)throw new Error('Cannot rename without newName');this.fileHash[r]=e.newHash,this.fileName[r]=e.newName}this.fileQueue.splice(t,1),t--}let i=1===this.fileCount;e&&i&&(i=!1),r.p2(this.fileCount);for(let t=0;t/?\\| ";for(let e=0;e<256;e++){let r=t.indexOf(String.fromCharCode(e));-1==r&&(r=74),Ms.CHAR_LOOKUP[e]=r}}static load(t){const e=As.load(`${t}/client/title`);Ms.instances[0]=new Ms(e,'p11'),Ms.instances[1]=new Ms(e,'p12'),Ms.instances[2]=new Ms(e,'b12'),Ms.instances[3]=new Ms(e,'q8')}static async loadAsync(t){const e=await As.loadAsync(`${t}/client/title`);Ms.instances[0]=new Ms(e,'p11'),Ms.instances[1]=new Ms(e,'p12'),Ms.instances[2]=new Ms(e,'b12'),Ms.instances[3]=new Ms(e,'q8')}static get(t){return Ms.instances[t]}static get count(){return this.instances.length}charMask=new Array(94);charMaskWidth=new Uint8Array(94);charMaskHeight=new Uint8Array(94);charOffsetX=new Uint8Array(94);charOffsetY=new Uint8Array(94);charAdvance=new Uint8Array(95);drawWidth=new Uint8Array(256);height=0;constructor(t,e){const r=t.read(`${e}.dat`),i=t.read('index.dat');if(!r||!i)return;i.pos=r.g2()+4;const n=i.g1();n>0&&(i.pos+=3*(n-1));for(let t=0;t<94;t++){this.charOffsetX[t]=i.g1(),this.charOffsetY[t]=i.g1();const e=this.charMaskWidth[t]=i.g2(),n=this.charMaskHeight[t]=i.g2(),s=i.g1(),a=e*n;if(this.charMask[t]=new Uint8Array(a),0==s)for(let e=0;ethis.height&&(this.height=n),this.charOffsetX[t]=1,this.charAdvance[t]=e+2;let o=0;for(let r=Math.floor(n/7);r0;){if(this.stringWidth(t)<=e&&-1===t.indexOf('|')){r.push(t);break}let i=t.length;for(let r=0;re)break;i=r}else if('|'===t[r]){i=r;break}r.push(t.substring(0,i)),t=t.substring(i+1)}return r}}var Is,Cs,{default:Os}=()=>({});(Cs=Is||={})[Cs.OFF=0]='OFF',Cs[Cs.OUTSIDE_WILDERNESS=1]='OUTSIDE_WILDERNESS';var Ns,Ls,Rs=Is;(Ls=Ns||={})[Ls.OFF=0]='OFF',Ls[Ls.PLAYER=1]='PLAYER',Ls[Ls.NPC=2]='NPC',Ls[Ls.OBJ=3]='OBJ',Ls[Ls.SCENERY=4]='SCENERY';var Ps,Bs,ks=Ns;(Bs=Ps||={})[Bs.KEEPHUNTING=0]='KEEPHUNTING',Bs[Bs.PAUSEHUNT=1]='PAUSEHUNT';var Ds,Us,xs=Ps;(Us=Ds||={})[Us.OFF=0]='OFF',Us[Us.LINEOFSIGHT=1]='LINEOFSIGHT',Us[Us.LINEOFWALK=2]='LINEOFWALK';var Fs,Hs,js=Ds;(Hs=Fs||={})[Hs.NULL=-1]='NULL',Hs[Hs.NONE=0]='NONE',Hs[Hs.WANDER=1]='WANDER',Hs[Hs.PATROL=2]='PATROL',Hs[Hs.PLAYERESCAPE=3]='PLAYERESCAPE',Hs[Hs.PLAYERFOLLOW=4]='PLAYERFOLLOW',Hs[Hs.PLAYERFACE=5]='PLAYERFACE',Hs[Hs.PLAYERFACECLOSE=6]='PLAYERFACECLOSE',Hs[Hs.OPPLAYER1=7]='OPPLAYER1',Hs[Hs.OPPLAYER2=8]='OPPLAYER2',Hs[Hs.OPPLAYER3=9]='OPPLAYER3',Hs[Hs.OPPLAYER4=10]='OPPLAYER4',Hs[Hs.OPPLAYER5=11]='OPPLAYER5',Hs[Hs.APPLAYER1=12]='APPLAYER1',Hs[Hs.APPLAYER2=13]='APPLAYER2',Hs[Hs.APPLAYER3=14]='APPLAYER3',Hs[Hs.APPLAYER4=15]='APPLAYER4',Hs[Hs.APPLAYER5=16]='APPLAYER5',Hs[Hs.OPLOC1=17]='OPLOC1',Hs[Hs.OPLOC2=18]='OPLOC2',Hs[Hs.OPLOC3=19]='OPLOC3',Hs[Hs.OPLOC4=20]='OPLOC4',Hs[Hs.OPLOC5=21]='OPLOC5',Hs[Hs.APLOC1=22]='APLOC1',Hs[Hs.APLOC2=23]='APLOC2',Hs[Hs.APLOC3=24]='APLOC3',Hs[Hs.APLOC4=25]='APLOC4',Hs[Hs.APLOC5=26]='APLOC5',Hs[Hs.OPOBJ1=27]='OPOBJ1',Hs[Hs.OPOBJ2=28]='OPOBJ2',Hs[Hs.OPOBJ3=29]='OPOBJ3',Hs[Hs.OPOBJ4=30]='OPOBJ4',Hs[Hs.OPOBJ5=31]='OPOBJ5',Hs[Hs.APOBJ1=32]='APOBJ1',Hs[Hs.APOBJ2=33]='APOBJ2',Hs[Hs.APOBJ3=34]='APOBJ3',Hs[Hs.APOBJ4=35]='APOBJ4',Hs[Hs.APOBJ5=36]='APOBJ5',Hs[Hs.OPNPC1=37]='OPNPC1',Hs[Hs.OPNPC2=38]='OPNPC2',Hs[Hs.OPNPC3=39]='OPNPC3',Hs[Hs.OPNPC4=40]='OPNPC4',Hs[Hs.OPNPC5=41]='OPNPC5',Hs[Hs.APNPC1=42]='APNPC1',Hs[Hs.APNPC2=43]='APNPC2',Hs[Hs.APNPC3=44]='APNPC3',Hs[Hs.APNPC4=45]='APNPC4',Hs[Hs.APNPC5=46]='APNPC5',Hs[Hs.QUEUE1=47]='QUEUE1',Hs[Hs.QUEUE2=48]='QUEUE2',Hs[Hs.QUEUE3=49]='QUEUE3',Hs[Hs.QUEUE4=50]='QUEUE4',Hs[Hs.QUEUE5=51]='QUEUE5',Hs[Hs.QUEUE6=52]='QUEUE6',Hs[Hs.QUEUE7=53]='QUEUE7',Hs[Hs.QUEUE8=54]='QUEUE8',Hs[Hs.QUEUE9=55]='QUEUE9',Hs[Hs.QUEUE10=56]='QUEUE10',Hs[Hs.QUEUE11=57]='QUEUE11',Hs[Hs.QUEUE12=58]='QUEUE12',Hs[Hs.QUEUE13=59]='QUEUE13',Hs[Hs.QUEUE14=60]='QUEUE14',Hs[Hs.QUEUE15=61]='QUEUE15',Hs[Hs.QUEUE16=62]='QUEUE16',Hs[Hs.QUEUE17=63]='QUEUE17',Hs[Hs.QUEUE18=64]='QUEUE18',Hs[Hs.QUEUE19=65]='QUEUE19',Hs[Hs.QUEUE20=66]='QUEUE20';var Vs=Fs;class Gs extends os{static configNames=new Map;static configs=[];static load(t){if(!Os.existsSync(`${t}/server/hunt.dat`))return void console.log('Warning: No hunt.dat found.');const e=as.load(`${t}/server/hunt.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/hunt.dat`)).ok)return void console.log('Warning: No hunt.dat found.');const e=await as.loadAsync(`${t}/server/hunt.dat`);this.parse(e)}static parse(t){Gs.configNames=new Map,Gs.configs=[];const e=t.g2();for(let r=0;r({});class Ws extends os{static configNames=new Map;static configs=[];static load(t){if(!zs.existsSync(`${t}/server/idk.dat`))return void console.log('Warning: No idk.dat found.');const e=as.load(`${t}/server/idk.dat`),r=As.load(`${t}/client/config`);this.parse(e,r)}static async loadAsync(t){if(!(await fetch(`${t}/server/idk.dat`)).ok)return void console.log('Warning: No idk.dat found.');const e=await as.loadAsync(`${t}/server/idk.dat`),r=await As.loadAsync(`${t}/client/config`);this.parse(e,r)}static parse(t,e){Ws.configNames=new Map,Ws.configs=[];const r=t.g2(),i=e.read('idk.dat');i.pos=2;for(let e=0;e=40&&t<50)this.recol_s[t-40]=e.g2();else if(t>=50&&t<60)this.recol_d[t-50]=e.g2();else if(t>=60&&t<70)this.heads[t-60]=e.g2();else{if(250!==t)throw new Error(`Unrecognized idk config code: ${t}`);this.debugname=e.gjstr()}}}var{default:Ks}=()=>({});class qs{static TYPE_LAYER=0;static TYPE_UNUSED=1;static TYPE_INVENTORY=2;static TYPE_RECT=3;static TYPE_TEXT=4;static TYPE_SPRITE=5;static TYPE_MODEL=6;static TYPE_INVENTORY_TEXT=7;static NO_BUTTON=0;static BUTTON=1;static TARGET_BUTTON=2;static CLOSE_BUTTON=3;static TOGGLE_BUTTON=4;static SELECT_BUTTON=5;static PAUSE_BUTTON=6;static componentNames=new Map;static components=[];static load(t){if(!Ks.existsSync(`${t}/server/interface.dat`))return void console.log('Warning: No interface.dat found.');const e=as.load(`${t}/server/interface.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/interface.dat`)).ok)return void console.log('Warning: No interface.dat found.');const e=await as.loadAsync(`${t}/server/interface.dat`);this.parse(e)}static parse(t){this.componentNames=new Map,this.components=[],t.g2();let e=-1;for(;t.available>0;){let r=t.g2();65535===r&&(e=t.g2(),r=t.g2());const i=new qs;i.id=r,i.rootLayer=e,i.comName=t.gjstr(),i.overlay=t.gbool(),i.type=t.g1(),i.buttonType=t.g1(),i.clientCode=t.g2(),i.width=t.g2(),i.height=t.g2(),i.overLayer=t.g1(),0==i.overLayer?i.overLayer=-1:i.overLayer=(i.overLayer-1<<8)+t.g1();const n=t.g1();if(n>0){i.scriptComparator=new Uint8Array(n).fill(0),i.scriptOperand=new Uint16Array(n).fill(0);for(let e=0;e0){i.scripts=new Array(s).fill(null);for(let e=0;e({});class Zs extends os{static configNames=new Map;static configs=[];static SCOPE_TEMP=0;static SCOPE_PERM=1;static SCOPE_SHARED=2;static INV=-1;static WORN=-1;static load(t){if(!Ys.existsSync(`${t}/server/inv.dat`))return void console.log('Warning: No inv.dat found.');const e=as.load(`${t}/server/inv.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/inv.dat`)).ok)return void console.log('Warning: No inv.dat found.');const e=await as.loadAsync(`${t}/server/inv.dat`);this.parse(e)}static parse(t){Zs.configNames=new Map,Zs.configs=[];const e=t.g2();for(let r=0;r({}),Xs=function(t,e,r){const i=e.params?.get(t);return'string'!=typeof i?r??'null':i},Qs=function(t,e,r){const i=e.params?.get(t);return'number'!=typeof i?r:i},Js=function(t){const e=t.g1(),r=new Map;for(let i=0;i0&&10===r.shapes[0]?1:0,r.op&&r.op.length>0&&(r.active=1)),ta.configs[e]=r,r.debugname&&ta.configNames.set(r.debugname,e)}}static get(t){return ta.configs[t]}static getId(t){return ta.configNames.get(t)??-1}static getByName(t){const e=this.getId(t);return void 0===e||-1===e?null:this.get(e)}static get count(){return this.configs.length}models=null;shapes=null;name=null;desc=null;recol_s=null;recol_d=null;width=1;length=1;blockwalk=!0;blockrange=!0;active=0;hillskew=!1;sharelight=!1;occlude=!1;anim=-1;hasalpha=!1;wallwidth=16;ambient=0;contrast=0;op=null;mapfunction=-1;mapscene=-1;mirror=!1;shadow=!0;resizex=128;resizey=128;resizez=128;forceapproach=0;xoff=0;yoff=0;zoff=0;forcedecor=!1;category=-1;params=new Map;decode(t,e){if(1===t){const t=e.g1();this.models=new Uint16Array(t),this.shapes=new Uint8Array(t);for(let r=0;r=30&&t<35)this.op||(this.op=new Array(5).fill(null)),this.op[t-30]=e.gjstr(),'hidden'===this.op[t-30]&&(this.op[t-30]=null);else if(40===t){const t=e.g1();this.recol_s=new Uint16Array(t),this.recol_d=new Uint16Array(t);for(let r=0;r({});class ra extends os{static configNames=new Map;static configs=[];static load(t){if(!ea.existsSync(`${t}/server/mesanim.dat`))return void console.log('Warning: No mesanim.dat found.');const e=as.load(`${t}/server/mesanim.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/mesanim.dat`)).ok)return void console.log('Warning: No mesanim.dat found.');const e=await as.loadAsync(`${t}/server/mesanim.dat`);this.parse(e)}static parse(t){ra.configNames=new Map,ra.configs=[];const e=t.g2();for(let r=0;r=1&&t<5)this.len[t-1]=e.g2();else{if(250!==t)throw new Error(`Unrecognized mesanim config code: ${t}`);this.debugname=e.gjstr()}}}var ia,na,{default:sa}=()=>({});(na=ia||={})[na.NONE=0]='NONE',na[na.NPC=1]='NPC',na[na.ALL=2]='ALL';var aa,oa,ha=ia;(oa=aa||={})[oa.NORMAL=0]='NORMAL',oa[oa.BLOCKED=1]='BLOCKED',oa[oa.BLOCKED_NORMAL=2]='BLOCKED_NORMAL',oa[oa.INDOORS=3]='INDOORS',oa[oa.OUTDOORS=4]='OUTDOORS',oa[oa.NOMOVE=5]='NOMOVE',oa[oa.PASSTHRU=6]='PASSTHRU';var la,ca,ua=aa;(ca=la||={})[ca.ATTACK=0]='ATTACK',ca[ca.DEFENCE=1]='DEFENCE',ca[ca.STRENGTH=2]='STRENGTH',ca[ca.HITPOINTS=3]='HITPOINTS',ca[ca.RANGED=4]='RANGED',ca[ca.MAGIC=5]='MAGIC';var da=la;class fa extends os{static configNames=new Map;static configs=[];static load(t){if(!sa.existsSync(`${t}/server/npc.dat`))return void console.log('Warning: No npc.dat found.');const e=as.load(`${t}/server/npc.dat`),r=As.load(`${t}/client/config`);this.parse(e,r)}static async loadAsync(t){if(!(await fetch(`${t}/server/npc.dat`)).ok)return void console.log('Warning: No npc.dat found.');const e=await as.loadAsync(`${t}/server/npc.dat`),r=await As.loadAsync(`${t}/client/config`);this.parse(e,r)}static parse(t,e){fa.configNames=new Map,fa.configs=[];const r=t.g2(),i=e.read('npc.dat');i.pos=2;for(let e=0;e=30&&t<40)this.op||(this.op=new Array(5).fill(null)),this.op[t-30]=e.gjstr(),'hidden'===this.op[t-30]&&(this.op[t-30]=null);else if(40===t){const t=e.g1();this.recol_s=new Uint16Array(t),this.recol_d=new Uint16Array(t);for(let r=0;r({}),{default:ma}=()=>({});class ga extends os{static configNames=new Map;static configs=[];static load(t){if(!ma.existsSync(`${t}/server/param.dat`))return void console.log('Warning: No param.dat found.');const e=as.load(`${t}/server/param.dat`);this.parse(e)}static async loadAsync(t){(await fetch(`${t}/server/param.dat`)).ok||console.log('Warning: No param.dat found.');const e=await as.loadAsync(`${t}/server/param.dat`);this.parse(e)}static parse(t){ga.configNames=new Map,ga.configs=[];const e=t.g2();for(let r=0;r{ga.get(r)?.autodisable&&e.params.delete(r)})))}}static get(t){return Aa.configs[t]}static getId(t){return Aa.configNames.get(t)??-1}static getByName(t){const e=this.getId(t);return-1===e?null:this.get(e)}static get count(){return this.configs.length}static getWearPosId(t){switch(t){case'hat':return 0;case'back':return 1;case'front':return 2;case'righthand':return 3;case'torso':return 4;case'lefthand':return 5;case'arms':return 6;case'legs':return 7;case'head':return 8;case'hands':return 9;case'feet':return 10;case'jaw':return 11;case'ring':return 12;case'quiver':return 13;default:return-1}}model=0;name=null;desc=null;recol_s=null;recol_d=null;zoom2d=2e3;xan2d=0;yan2d=0;zan2d=0;xof2d=0;yof2d=0;code9=!1;code10=-1;stackable=!1;cost=1;members=!1;op=null;iop=null;manwear=-1;manwear2=-1;manwearOffsetY=0;womanwear=-1;womanwear2=-1;womanwearOffsetY=0;manwear3=-1;womanwear3=-1;manhead=-1;manhead2=-1;womanhead=-1;womanhead2=-1;countobj=null;countco=null;certlink=-1;certtemplate=-1;wearpos=-1;wearpos2=-1;wearpos3=-1;weight=0;category=-1;dummyitem=0;tradeable=!1;respawnrate=100;params=new Map;decode(t,e){if(1===t)this.model=e.g2();else if(2===t)this.name=e.gjstr();else if(3===t)this.desc=e.gjstr();else if(4===t)this.zoom2d=e.g2();else if(5===t)this.xan2d=e.g2();else if(6===t)this.yan2d=e.g2();else if(7===t)this.xof2d=e.g2s();else if(8===t)this.yof2d=e.g2s();else if(9===t)this.code9=!0;else if(10===t)this.code10=e.g2();else if(11===t)this.stackable=!0;else if(12===t)this.cost=e.g4();else if(13===t)this.wearpos=e.g1();else if(14===t)this.wearpos2=e.g1();else if(16===t)this.members=!0;else if(23===t)this.manwear=e.g2(),this.manwearOffsetY=e.g1b();else if(24===t)this.manwear2=e.g2();else if(25===t)this.womanwear=e.g2(),this.womanwearOffsetY=e.g1b();else if(26===t)this.womanwear2=e.g2();else if(27===t)this.wearpos3=e.g1();else if(t>=30&&t<35)this.op||(this.op=new Array(5).fill(null)),this.op[t-30]=e.gjstr();else if(t>=35&&t<40)this.iop||(this.iop=new Array(5).fill(null)),this.iop[t-35]=e.gjstr();else if(40===t){const t=e.g1();this.recol_s=new Uint16Array(t),this.recol_d=new Uint16Array(t);for(let r=0;r=100&&t<110)this.countobj&&this.countco||(this.countobj=new Uint16Array(10),this.countco=new Uint16Array(10)),this.countobj[t-100]=e.g2(),this.countco[t-100]=e.g2();else if(200===t)this.tradeable=!0;else if(201===t)this.respawnrate=e.g2();else if(249===t)this.params=Js(e);else{if(250!==t)throw new Error(`Unrecognized obj config code: ${t}`);this.debugname=e.gjstr()}}toCertificate(){const t=Aa.get(this.certtemplate);this.model=t.model,this.zoom2d=t.zoom2d,this.xan2d=t.xan2d,this.yan2d=t.yan2d,this.zan2d=t.zan2d,this.xof2d=t.xof2d,this.yof2d=t.yof2d,this.recol_s=t.recol_s,this.recol_d=t.recol_d;const e=Aa.get(this.certlink);this.name=e.name,this.members=e.members,this.cost=e.cost,this.tradeable=e.tradeable;let r='a';const i=(e.name||'').toLowerCase().charAt(0);'a'!==i&&'e'!==i&&'i'!==i&&'o'!==i&&'u'!==i||(r='an'),this.desc=`Swap this note at any bank for ${r} ${e.name}.`,this.stackable=!0}}var{default:Sa}=()=>({});class Ta{static instances=[];static load(t){if(!Sa.existsSync(`${t}/server/frame_del.dat`))return void console.log('Warning: No frame_del.dat found.');const e=as.load(`${t}/server/frame_del.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/frame_del.dat`)).ok)return void console.log('Warning: No frame_del.dat found.');const e=await as.loadAsync(`${t}/server/frame_del.dat`);this.parse(e)}static parse(t){Ta.instances=[];for(let e=0;e({});class Ia extends os{static configNames=new Map;static configs=[];static load(t){if(!Ma.existsSync(`${t}/server/seq.dat`))return void console.log('Warning: No seq.dat found.');const e=as.load(`${t}/server/seq.dat`),r=As.load(`${t}/client/config`);this.parse(e,r)}static async loadAsync(t){if(!(await fetch(`${t}/server/seq.dat`)).ok)return void console.log('Warning: No seq.dat found.');const e=await as.loadAsync(`${t}/server/seq.dat`),r=await As.loadAsync(`${t}/client/config`);this.parse(e,r)}static parse(t,e){Ia.configNames=new Map,Ia.configs=[];const r=t.g2(),i=e.read('seq.dat');i.pos=2;for(let e=0;e({});class Oa extends os{static configNames=new Map;static configs=[];static load(t){if(!Ca.existsSync(`${t}/server/struct.dat`))return void console.log('Warning: No struct.dat found.');const e=as.load(`${t}/server/struct.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/struct.dat`)).ok)return void console.log('Warning: No struct.dat found.');const e=await as.loadAsync(`${t}/server/struct.dat`);this.parse(e)}static parse(t){Oa.configNames=new Map,Oa.configs=[];const e=t.g2();for(let r=0;r({});class La extends os{static configNames=new Map;static configs=[];static load(t){if(!Na.existsSync(`${t}/server/varn.dat`))return void console.log('Warning: No varn.dat found.');const e=as.load(`${t}/server/varn.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/varn.dat`)).ok)return void console.log('Warning: No varn.dat found.');const e=await as.loadAsync(`${t}/server/varn.dat`);this.parse(e)}static parse(t){La.configNames=new Map,La.configs=[];const e=t.g2();for(let r=0;r({});class Pa extends os{static configNames=new Map;static configs=[];static SCOPE_TEMP=0;static SCOPE_PERM=1;static PLAYER_RUN=-1;static TEMP_RUN=-1;static LASTCOMBAT=-1;static load(t){if(!Ra.existsSync(`${t}/server/varp.dat`))return void console.log('Warning: No varp.dat found.');const e=as.load(`${t}/server/varp.dat`),r=As.load(`${t}/client/config`);this.parse(e,r)}static async loadAsync(t){if(!(await fetch(`${t}/server/varp.dat`)).ok)return void console.log('Warning: No varp.dat found.');const e=await as.loadAsync(`${t}/server/varp.dat`),r=await As.loadAsync(`${t}/client/config`);this.parse(e,r)}static parse(t,e){Pa.configNames=new Map,Pa.configs=[];const r=t.g2(),i=e.read('varp.dat');i.pos=2;for(let e=0;e({});class ka extends os{static configNames=new Map;static configs=[];static load(t){if(!Ba.existsSync(`${t}/server/vars.dat`))return void console.log('Warning: No vars.dat found.');const e=as.load(`${t}/server/vars.dat`);this.parse(e)}static async loadAsync(t){if(!(await fetch(`${t}/server/vars.dat`)).ok)return void console.log('Warning: No vars.dat found.');const e=await as.loadAsync(`${t}/server/vars.dat`);this.parse(e)}static parse(t){ka.configNames=new Map,ka.configs=[];const e=t.g2();for(let r=0;r({});class Ua{fragments=[];filter(t){for(let e=0;e=0&&n6)return 0;let e=0;for(let r=0;r=0;r++)if(ja.isNumerical(t[r]))return r;return-1}indexOfNonNumber(t,e){for(let r=t;r=0;r++)if(!ja.isNumerical(e[r]))return r;return e.length}}class xa{wordEncFragments;bads=[];badCombinations=[];constructor(t){this.wordEncFragments=t}filter(t){for(let e=0;e<2;e++)for(let e=this.bads.length-1;e>=0;e--)this.filterBadCombinations(this.badCombinations[e],t,this.bads[e])}filterBadCombinations(t,e,r){if(!(r.length>e.length))for(let i=0;i<=e.length-r.length;i++){let n=i;const{currentIndex:s,badIndex:a,hasSymbol:o,hasNumber:h,hasDigit:l}=this.processBadCharacters(e,r,n);n=s;let c=e[n],u=n+1=r.length)||h&&l)continue;let d,f=!0;if(o){let t=!1,r=!1;if((i-1<0||ja.isSymbol(e[i-1])&&"'"!=e[i-1])&&(t=!0),(n>=e.length||ja.isSymbol(e[n])&&"'"!=e[n])&&(r=!0),!t||!r){let r=!1;for(d=i-2,t&&(d=i);!r&&d=0&&(!ja.isSymbol(e[d])||"'"==e[d])){const t=[];let i;for(i=0;i<3&&d+i=0&&(!ja.isSymbol(e[d-1])||"'"==e[d-1])&&(n=!1),n&&!this.wordEncFragments.isBadFragment(t)&&(r=!0)}d++}r||(f=!1)}}else{c=' ',i-1>=0&&(c=e[i-1]),u=' ',n=t.length||o&&h);){const l=t[i],c=i+10)1===u&&ja.isNumerical(l)&&(o=!0),2===u&&(ja.isNumerical(l)||ja.isNumerical(c))&&(o=!0),i+=u,n++;else{if(0===n)break;let t;if((t=this.getEmulatedBadCharLen(c,String.fromCharCode(e[n-1]),l))>0)i+=t;else{if(n>=e.length||!ja.isNotLowercaseAlpha(l))break;if(ja.isSymbol(l)&&"'"!==l&&(a=!0),ja.isNumerical(l)&&(h=!0),i++,s++,(100*s/(i-r)|0)>90)break}}}return{currentIndex:i,badIndex:n,hasSymbol:a,hasNumber:o,hasDigit:h}}getEmulatedBadCharLen(t,e,r){if(e==r)return 1;if(e>='a'&&e<='m'){if('a'==e)return'4'!=r&&'@'!=r&&'^'!=r?'/'==r&&'\\'==t?2:0:1;if('b'==e)return'6'!=r&&'8'!=r?'1'==r&&'3'==t?2:0:1;if('c'==e)return'('!=r&&'<'!=r&&'{'!=r&&'['!=r?0:1;if('d'==e)return'['==r&&')'==t?2:0;if('e'==e)return'3'!=r&&'€'!=r?0:1;if('f'==e)return'p'==r&&'h'==t?2:'£'==r?1:0;if('g'==e)return'9'!=r&&'6'!=r?0:1;if('h'==e)return'#'==r?1:0;if('i'==e)return'y'!=r&&'l'!=r&&'j'!=r&&'1'!=r&&'!'!=r&&':'!=r&&';'!=r&&'|'!=r?0:1;if('j'==e)return 0;if('k'==e)return 0;if('l'==e)return'1'!=r&&'|'!=r&&'i'!=r?0:1;if('m'==e)return 0}if(e>='n'&&e<='z'){if('n'==e)return 0;if('o'==e)return'0'!=r&&'*'!=r?'('==r&&')'==t||'['==r&&']'==t||'{'==r&&'}'==t||'<'==r&&'>'==t?2:0:1;if('p'==e)return 0;if('q'==e)return 0;if('r'==e)return 0;if('s'==e)return'5'!=r&&'z'!=r&&'$'!=r&&'2'!=r?0:1;if('t'==e)return'7'!=r&&'+'!=r?0:1;if('u'==e)return'v'==r?1:'\\'==r&&'/'==t||'\\'==r&&'|'==t||'|'==r&&'/'==t?2:0;if('v'==e)return'\\'==r&&'/'==t||'\\'==r&&'|'==t||'|'==r&&'/'==t?2:0;if('w'==e)return'v'==r&&'v'==t?2:0;if('x'==e)return')'==r&&'('==t||'}'==r&&'{'==t||']'==r&&'['==t||'>'==r&&'<'==t?2:0;if('y'==e)return 0;if('z'==e)return 0}return e>='0'&&e<='9'?'0'==e?'o'==r||'O'==r?1:'('==r&&')'==t||'{'==r&&'}'==t||'['==r&&']'==t?2:0:'1'==e&&'l'==r?1:0:','==e?'.'==r?1:0:'.'==e?','==r?1:0:'!'==e&&'i'==r?1:0}comboMatches(t,e,r){let i=0,n=e.length-1;for(;i<=n;){const s=(i+n)/2|0;if(e[s][0]===t&&e[s][1]===r)return!0;t=0;i--)this.filterDomain(r,e,this.domains[i],t)}getEmulatedDomainCharLen(t,e,r){return e==r||'o'==e&&'0'==r?1:'o'==e&&'('==r&&')'==t?2:'c'!=e||'('!=r&&'<'!=r&&'['!=r?'e'==e&&'€'==r||'s'==e&&'$'==r||'l'==e&&'i'==r?1:0:1}filterDomain(t,e,r,i){const n=r.length,s=i.length;for(let a=0;a<=s-n;a++){const{matched:n,currentIndex:s}=this.findMatchingDomain(a,r,i);if(!n)continue;const o=ja.prefixSymbolStatus(a,i,3,e,['@']),h=ja.suffixSymbolStatus(s-1,i,3,t,['.',',']);(o>2||h>2)&&ja.maskChars(a,s,i)}}findMatchingDomain(t,e,r){const i=e.length;let n=t,s=0;for(;n0)n+=h,s++;else{if(0===s)break;const r=this.getEmulatedDomainCharLen(o,String.fromCharCode(e[s-1]),a);if(r>0)n+=r,1===s&&t++;else{if(s>=i||!ja.isSymbol(a))break;n++}}}return{matched:s>=i,currentIndex:n}}}class Ha{wordEncBadWords;wordEncDomains;tlds=[];tldTypes=[];constructor(t,e){this.wordEncBadWords=t,this.wordEncDomains=e}filter(t){const e=[...t],r=[...t];this.wordEncBadWords.filterBadCombinations(null,e,ja.PERIOD),this.wordEncBadWords.filterBadCombinations(null,r,ja.SLASH);for(let i=0;ir.length))for(let s=0;s<=r.length-i.length;s++){const{currentIndex:a,tldIndex:o}=this.processTlds(r,i,s);if(o0&&c>0&&(h=!0),2==e&&(l>2&&c>0||l>0&&c>2)&&(h=!0),3==e&&l>0&&c>2&&(h=!0),!h)continue;let u,d=s,f=a-1,p=!1;if(l>2){if(4==l)for(p=!1,u=s-1;u>=0;u--)if(p){if('*'!=n[u])break;d=u}else'*'==n[u]&&(d=u,p=!0);for(p=!1,u=d-1;u>=0;u--)if(p){if(ja.isSymbol(r[u]))break;d=u}else ja.isSymbol(r[u])||(p=!0,d=u)}if(c>2){if(4==c)for(p=!1,u=f+1;u0)r+=a,i++;else{if(0===i)break;let t;if((t=this.wordEncDomains.getEmulatedDomainCharLen(s,String.fromCharCode(e[i-1]),n))>0)r+=t;else{if(!ja.isSymbol(n))break;r++}}}return{currentIndex:r,tldIndex:i}}}class ja{static PERIOD=new Uint16Array(['d','o','t'].join('').split('').map((t=>t.charCodeAt(0))));static AMPERSAT=new Uint16Array(['(','a',')'].join('').split('').map((t=>t.charCodeAt(0))));static SLASH=new Uint16Array(['s','l','a','s','h'].join('').split('').map((t=>t.charCodeAt(0))));static wordEncFragments=new Ua;static wordEncBadWords=new xa(this.wordEncFragments);static wordEncDomains=new Fa(this.wordEncBadWords);static wordEncTlds=new Ha(this.wordEncBadWords,this.wordEncDomains);static whitelist=['cook',"cook's",'cooks','seeks','sheet'];static async load(t){if(!Da.existsSync(`${t}/client/wordenc`))return void console.log('Warning: No wordenc found.');const e=As.load(`${t}/client/wordenc`);this.readAll(e)}static async loadAsync(t){if(!(await fetch(`${t}/client/wordenc`)).ok)return void console.log('Warning: No wordenc found.');const e=await As.loadAsync(`${t}/client/wordenc`);this.readAll(e)}static readAll(t){const e=t.read('fragmentsenc.txt');if(!e)return void console.log('Warning: No fragmentsenc found.');const r=t.read('badenc.txt');if(!r)return void console.log('Warning: No badenc found.');const i=t.read('domainenc.txt');if(!i)return void console.log('Warning: No domainenc found.');const n=t.read('tldlist.txt');n?(this.decodeBadEnc(r),this.decodeDomainEnc(i),this.decodeFragmentsEnc(e),this.decodeTldList(n)):console.log('Warning: No tldlist found.')}static filter(t){const e=[...t];this.format(e);const r=e.join('').trim(),i=r.toLowerCase(),n=[...i];this.wordEncTlds.filter(n),this.wordEncBadWords.filter(n),this.wordEncDomains.filter(n),this.wordEncFragments.filter(n);for(let t=0;t='0'&&t<='9'}static isLowercaseAlpha(t){return t>='a'&&t<='z'}static isUppercaseAlpha(t){return t>='A'&&t<='Z'}static isNumericalChars(t){for(let e=0;e=0&&ja.isSymbol(t[i]);i--)'*'===t[i]&&r++;return r}static maskedCountForwards(t,e){let r=0;for(let i=e+1;i=i?4:this.isSymbol(n?t[r-1]:t[r+1])?1:0}static prefixSymbolStatus(t,e,r,i,n){if(0===t)return 2;for(let r=t-1;r>=0&&ja.isSymbol(e[r]);r--)if(n.includes(e[r]))return 3;return ja.maskedCharsStatus(e,i,t,r,!0)}static suffixSymbolStatus(t,e,r,i,n){if(t+1===e.length)return 2;for(let r=t+1;rt.g1()))}static decodeBadEnc(t){const e=t.g4();for(let r=0;rt.g1()));const e=new Array(t.g1()).fill([]).map((()=>[t.g1b(),t.g1b()]));e.length>0&&(this.wordEncBadWords.badCombinations[r]=e)}}static decodeDomainEnc(t){const e=t.g4();for(let r=0;rt.g1()))}static decodeFragmentsEnc(t){const e=t.g4();for(let r=0;r=' '&&t<=''||' '==t||'\n'==t||'\t'==t||'£'==t||'€'==t}static replaceUppercases(t,e){for(let r=0;r({});class Ga extends os{static configNames=new Map;static configs=[];static load(t){if(!Va.existsSync(`${t}/server/spotanim.dat`))return void console.log('Warning: No spotanim.dat found.');const e=as.load(`${t}/server/spotanim.dat`),r=As.load(`${t}/client/config`);this.parse(e,r)}static async loadAsync(t){if(!(await fetch(`${t}/server/spotanim.dat`)).ok)return void console.log('Warning: No spotanim.dat found.');const e=await as.loadAsync(`${t}/server/spotanim.dat`),r=await As.loadAsync(`${t}/client/config`);this.parse(e,r)}static parse(t,e){Ga.configNames=new Map,Ga.configs=[];const r=t.g2(),i=e.read('spotanim.dat');i.pos=2;for(let e=0;e=40&&t<50)this.recol_s[t-40]=e.g2();else if(t>=50&&t<60)this.recol_d[t-50]=e.g2();else{if(250!==t)throw new Error(`Unrecognized spotanim config code: ${t}`);this.debugname=e.gjstr()}}}var za,Wa,{default:Ka}=()=>({});function qa(t,e){return function(r){'number'==typeof t?r.pointerCheck(t):r.pointerCheck(t[r.intOperand]),e(r)}}(Wa=za||={})[Wa.ActivePlayer=0]='ActivePlayer',Wa[Wa.ActivePlayer2=1]='ActivePlayer2',Wa[Wa.ProtectedActivePlayer=2]='ProtectedActivePlayer',Wa[Wa.ProtectedActivePlayer2=3]='ProtectedActivePlayer2',Wa[Wa.ActiveNpc=4]='ActiveNpc',Wa[Wa.ActiveNpc2=5]='ActiveNpc2',Wa[Wa.ActiveLoc=6]='ActiveLoc',Wa[Wa.ActiveLoc2=7]='ActiveLoc2',Wa[Wa.ActiveObj=8]='ActiveObj',Wa[Wa.ActiveObj2=9]='ActiveObj2',Wa[Wa._LAST=10]='_LAST';var Ya,Za,$a=[4,5],Xa=[6,7],Qa=[8,9],Ja=[0,1],to=[2,3],eo=za;ji(),(Za=Ya||={})[Za.PUSH_CONSTANT_INT=0]='PUSH_CONSTANT_INT',Za[Za.PUSH_VARP=1]='PUSH_VARP',Za[Za.POP_VARP=2]='POP_VARP',Za[Za.PUSH_CONSTANT_STRING=3]='PUSH_CONSTANT_STRING',Za[Za.PUSH_VARN=4]='PUSH_VARN',Za[Za.POP_VARN=5]='POP_VARN',Za[Za.BRANCH=6]='BRANCH',Za[Za.BRANCH_NOT=7]='BRANCH_NOT',Za[Za.BRANCH_EQUALS=8]='BRANCH_EQUALS',Za[Za.BRANCH_LESS_THAN=9]='BRANCH_LESS_THAN',Za[Za.BRANCH_GREATER_THAN=10]='BRANCH_GREATER_THAN',Za[Za.PUSH_VARS=11]='PUSH_VARS',Za[Za.POP_VARS=12]='POP_VARS',Za[Za.RETURN=21]='RETURN',Za[Za.GOSUB=22]='GOSUB',Za[Za.JUMP=23]='JUMP',Za[Za.SWITCH=24]='SWITCH',Za[Za.BRANCH_LESS_THAN_OR_EQUALS=31]='BRANCH_LESS_THAN_OR_EQUALS',Za[Za.BRANCH_GREATER_THAN_OR_EQUALS=32]='BRANCH_GREATER_THAN_OR_EQUALS',Za[Za.PUSH_INT_LOCAL=33]='PUSH_INT_LOCAL',Za[Za.POP_INT_LOCAL=34]='POP_INT_LOCAL',Za[Za.PUSH_STRING_LOCAL=35]='PUSH_STRING_LOCAL',Za[Za.POP_STRING_LOCAL=36]='POP_STRING_LOCAL',Za[Za.JOIN_STRING=37]='JOIN_STRING',Za[Za.POP_INT_DISCARD=38]='POP_INT_DISCARD',Za[Za.POP_STRING_DISCARD=39]='POP_STRING_DISCARD',Za[Za.GOSUB_WITH_PARAMS=40]='GOSUB_WITH_PARAMS',Za[Za.JUMP_WITH_PARAMS=41]='JUMP_WITH_PARAMS',Za[Za.DEFINE_ARRAY=44]='DEFINE_ARRAY',Za[Za.PUSH_ARRAY_INT=45]='PUSH_ARRAY_INT',Za[Za.POP_ARRAY_INT=46]='POP_ARRAY_INT',Za[Za.COORDX=1e3]='COORDX',Za[Za.COORDY=1001]='COORDY',Za[Za.COORDZ=1002]='COORDZ',Za[Za.DISTANCE=1003]='DISTANCE',Za[Za.HUNTALL=1004]='HUNTALL',Za[Za.HUNTNEXT=1005]='HUNTNEXT',Za[Za.INZONE=1006]='INZONE',Za[Za.LINEOFSIGHT=1007]='LINEOFSIGHT',Za[Za.LINEOFWALK=1008]='LINEOFWALK',Za[Za.MAP_BLOCKED=1009]='MAP_BLOCKED',Za[Za.MAP_INDOORS=1010]='MAP_INDOORS',Za[Za.MAP_CLOCK=1011]='MAP_CLOCK',Za[Za.MAP_LOCADDUNSAFE=1012]='MAP_LOCADDUNSAFE',Za[Za.MAP_MEMBERS=1013]='MAP_MEMBERS',Za[Za.MAP_PLAYERCOUNT=1014]='MAP_PLAYERCOUNT',Za[Za.MOVECOORD=1015]='MOVECOORD',Za[Za.PLAYERCOUNT=1016]='PLAYERCOUNT',Za[Za.PROJANIM_MAP=1017]='PROJANIM_MAP',Za[Za.PROJANIM_NPC=1018]='PROJANIM_NPC',Za[Za.PROJANIM_PL=1019]='PROJANIM_PL',Za[Za.SEQLENGTH=1020]='SEQLENGTH',Za[Za.SPLIT_GET=1021]='SPLIT_GET',Za[Za.SPLIT_GETANIM=1022]='SPLIT_GETANIM',Za[Za.SPLIT_INIT=1023]='SPLIT_INIT',Za[Za.SPLIT_LINECOUNT=1024]='SPLIT_LINECOUNT',Za[Za.SPLIT_PAGECOUNT=1025]='SPLIT_PAGECOUNT',Za[Za.SPOTANIM_MAP=1026]='SPOTANIM_MAP',Za[Za.STAT_RANDOM=1027]='STAT_RANDOM',Za[Za.STRUCT_PARAM=1028]='STRUCT_PARAM',Za[Za.WORLD_DELAY=1029]='WORLD_DELAY',Za[Za.NPCCOUNT=1030]='NPCCOUNT',Za[Za.ZONECOUNT=1031]='ZONECOUNT',Za[Za.LOCCOUNT=1032]='LOCCOUNT',Za[Za.OBJCOUNT=1033]='OBJCOUNT',Za[Za.ALLOWDESIGN=2e3]='ALLOWDESIGN',Za[Za.ANIM=2001]='ANIM',Za[Za.BAS_READYANIM=2002]='BAS_READYANIM',Za[Za.BAS_RUNNING=2003]='BAS_RUNNING',Za[Za.BAS_TURNONSPOT=2004]='BAS_TURNONSPOT',Za[Za.BAS_WALK_B=2005]='BAS_WALK_B',Za[Za.BAS_WALK_F=2006]='BAS_WALK_F',Za[Za.BAS_WALK_L=2007]='BAS_WALK_L',Za[Za.BAS_WALK_R=2008]='BAS_WALK_R',Za[Za.BUFFER_FULL=2009]='BUFFER_FULL',Za[Za.BUILDAPPEARANCE=2010]='BUILDAPPEARANCE',Za[Za.BUSY=2011]='BUSY',Za[Za.CAM_LOOKAT=2012]='CAM_LOOKAT',Za[Za.CAM_MOVETO=2013]='CAM_MOVETO',Za[Za.CAM_RESET=2014]='CAM_RESET',Za[Za.CAM_SHAKE=2015]='CAM_SHAKE',Za[Za.CLEARQUEUE=2016]='CLEARQUEUE',Za[Za.CLEARSOFTTIMER=2017]='CLEARSOFTTIMER',Za[Za.CLEARTIMER=2018]='CLEARTIMER',Za[Za.COORD=2019]='COORD',Za[Za.DAMAGE=2020]='DAMAGE',Za[Za.DISPLAYNAME=2021]='DISPLAYNAME',Za[Za.FACESQUARE=2022]='FACESQUARE',Za[Za.FINDUID=2023]='FINDUID',Za[Za.GENDER=2024]='GENDER',Za[Za.GETQUEUE=2025]='GETQUEUE',Za[Za.GIVEXP=2026]='GIVEXP',Za[Za.HEADICONS_GET=2027]='HEADICONS_GET',Za[Za.HEADICONS_SET=2028]='HEADICONS_SET',Za[Za.HEALENERGY=2029]='HEALENERGY',Za[Za.HINT_COORD=2030]='HINT_COORD',Za[Za.HINT_NPC=2031]='HINT_NPC',Za[Za.HINT_PLAYER=2032]='HINT_PLAYER',Za[Za.HINT_STOP=2033]='HINT_STOP',Za[Za.IF_CLOSE=2034]='IF_CLOSE',Za[Za.IF_CLOSESTICKY=2035]='IF_CLOSESTICKY',Za[Za.IF_MULTIZONE=2036]='IF_MULTIZONE',Za[Za.IF_OPENCHAT=2037]='IF_OPENCHAT',Za[Za.IF_OPENCHATSTICKY=2038]='IF_OPENCHATSTICKY',Za[Za.IF_OPENMAINMODAL=2039]='IF_OPENMAINMODAL',Za[Za.IF_OPENMAINMODALSIDEOVERLAY=2040]='IF_OPENMAINMODALSIDEOVERLAY',Za[Za.IF_OPENSIDEOVERLAY=2041]='IF_OPENSIDEOVERLAY',Za[Za.IF_SETANIM=2042]='IF_SETANIM',Za[Za.IF_SETCOLOUR=2043]='IF_SETCOLOUR',Za[Za.IF_SETHIDE=2044]='IF_SETHIDE',Za[Za.IF_SETMODEL=2045]='IF_SETMODEL',Za[Za.IF_SETRECOL=2046]='IF_SETRECOL',Za[Za.IF_SETNPCHEAD=2047]='IF_SETNPCHEAD',Za[Za.IF_SETOBJECT=2048]='IF_SETOBJECT',Za[Za.IF_SETPLAYERHEAD=2049]='IF_SETPLAYERHEAD',Za[Za.IF_SETPOSITION=2050]='IF_SETPOSITION',Za[Za.IF_SETRESUMEBUTTONS=2051]='IF_SETRESUMEBUTTONS',Za[Za.IF_SETTAB=2052]='IF_SETTAB',Za[Za.IF_SETTABACTIVE=2053]='IF_SETTABACTIVE',Za[Za.IF_SETTABFLASH=2054]='IF_SETTABFLASH',Za[Za.IF_SETTEXT=2055]='IF_SETTEXT',Za[Za.LAST_LOGIN_INFO=2056]='LAST_LOGIN_INFO',Za[Za.LAST_COM=2057]='LAST_COM',Za[Za.LAST_INT=2058]='LAST_INT',Za[Za.LAST_ITEM=2059]='LAST_ITEM',Za[Za.LAST_SLOT=2060]='LAST_SLOT',Za[Za.LAST_TARGETSLOT=2061]='LAST_TARGETSLOT',Za[Za.LAST_USEITEM=2062]='LAST_USEITEM',Za[Za.LAST_USESLOT=2063]='LAST_USESLOT',Za[Za.LONGQUEUE=2064]='LONGQUEUE',Za[Za.MES=2065]='MES',Za[Za.MIDI_JINGLE=2066]='MIDI_JINGLE',Za[Za.MIDI_SONG=2067]='MIDI_SONG',Za[Za.NAME=2068]='NAME',Za[Za.P_APRANGE=2069]='P_APRANGE',Za[Za.P_ARRIVEDELAY=2070]='P_ARRIVEDELAY',Za[Za.P_COUNTDIALOG=2071]='P_COUNTDIALOG',Za[Za.P_DELAY=2072]='P_DELAY',Za[Za.P_EXACTMOVE=2073]='P_EXACTMOVE',Za[Za.P_FINDUID=2074]='P_FINDUID',Za[Za.P_LOCMERGE=2075]='P_LOCMERGE',Za[Za.P_LOGOUT=2076]='P_LOGOUT',Za[Za.P_OPHELD=2077]='P_OPHELD',Za[Za.P_OPLOC=2078]='P_OPLOC',Za[Za.P_OPNPC=2079]='P_OPNPC',Za[Za.P_OPNPCT=2080]='P_OPNPCT',Za[Za.P_OPOBJ=2081]='P_OPOBJ',Za[Za.P_OPPLAYER=2082]='P_OPPLAYER',Za[Za.P_OPPLAYERT=2083]='P_OPPLAYERT',Za[Za.P_PAUSEBUTTON=2084]='P_PAUSEBUTTON',Za[Za.P_STOPACTION=2085]='P_STOPACTION',Za[Za.P_TELEJUMP=2086]='P_TELEJUMP',Za[Za.P_TELEPORT=2087]='P_TELEPORT',Za[Za.P_WALK=2088]='P_WALK',Za[Za.PLAYER_FINDALLZONE=2089]='PLAYER_FINDALLZONE',Za[Za.PLAYER_FINDNEXT=2090]='PLAYER_FINDNEXT',Za[Za.QUEUE=2091]='QUEUE',Za[Za.SAY=2092]='SAY',Za[Za.WALKTRIGGER=2093]='WALKTRIGGER',Za[Za.SETTIMER=2094]='SETTIMER',Za[Za.SOFTTIMER=2095]='SOFTTIMER',Za[Za.SOUND_SYNTH=2096]='SOUND_SYNTH',Za[Za.SPOTANIM_PL=2097]='SPOTANIM_PL',Za[Za.STAFFMODLEVEL=2098]='STAFFMODLEVEL',Za[Za.STAT=2099]='STAT',Za[Za.STAT_ADD=2100]='STAT_ADD',Za[Za.STAT_BASE=2101]='STAT_BASE',Za[Za.STAT_HEAL=2102]='STAT_HEAL',Za[Za.STAT_SUB=2103]='STAT_SUB',Za[Za.STRONGQUEUE=2104]='STRONGQUEUE',Za[Za.UID=2105]='UID',Za[Za.WEAKQUEUE=2106]='WEAKQUEUE',Za[Za.IF_OPENMAINOVERLAY=2107]='IF_OPENMAINOVERLAY',Za[Za.AFK_EVENT=2108]='AFK_EVENT',Za[Za.LOWMEMORY=2109]='LOWMEMORY',Za[Za.SETIDKIT=2110]='SETIDKIT',Za[Za.P_CLEARPENDINGACTION=2111]='P_CLEARPENDINGACTION',Za[Za.GETWALKTRIGGER=2112]='GETWALKTRIGGER',Za[Za.BUSY2=2113]='BUSY2',Za[Za.FINDHERO=2114]='FINDHERO',Za[Za.BOTH_HEROPOINTS=2115]='BOTH_HEROPOINTS',Za[Za.SETGENDER=2116]='SETGENDER',Za[Za.SETSKINCOLOUR=2117]='SETSKINCOLOUR',Za[Za.P_ANIMPROTECT=2118]='P_ANIMPROTECT',Za[Za.RUNENERGY=2119]='RUNENERGY',Za[Za.WEIGHT=2120]='WEIGHT',Za[Za.LAST_COORD=2121]='LAST_COORD',Za[Za.NPC_ADD=2500]='NPC_ADD',Za[Za.NPC_ANIM=2501]='NPC_ANIM',Za[Za.NPC_BASESTAT=2502]='NPC_BASESTAT',Za[Za.NPC_CATEGORY=2503]='NPC_CATEGORY',Za[Za.NPC_CHANGETYPE=2504]='NPC_CHANGETYPE',Za[Za.NPC_COORD=2505]='NPC_COORD',Za[Za.NPC_DAMAGE=2506]='NPC_DAMAGE',Za[Za.NPC_DEL=2507]='NPC_DEL',Za[Za.NPC_DELAY=2508]='NPC_DELAY',Za[Za.NPC_FACESQUARE=2509]='NPC_FACESQUARE',Za[Za.NPC_FIND=2510]='NPC_FIND',Za[Za.NPC_FINDALLANY=2511]='NPC_FINDALLANY',Za[Za.NPC_FINDEXACT=2512]='NPC_FINDEXACT',Za[Za.NPC_FINDHERO=2513]='NPC_FINDHERO',Za[Za.NPC_FINDALLZONE=2514]='NPC_FINDALLZONE',Za[Za.NPC_FINDNEXT=2515]='NPC_FINDNEXT',Za[Za.NPC_FINDUID=2516]='NPC_FINDUID',Za[Za.NPC_GETMODE=2517]='NPC_GETMODE',Za[Za.NPC_HEROPOINTS=2518]='NPC_HEROPOINTS',Za[Za.NPC_NAME=2519]='NPC_NAME',Za[Za.NPC_PARAM=2520]='NPC_PARAM',Za[Za.NPC_QUEUE=2521]='NPC_QUEUE',Za[Za.NPC_RANGE=2522]='NPC_RANGE',Za[Za.NPC_SAY=2523]='NPC_SAY',Za[Za.NPC_HUNTALL=2524]='NPC_HUNTALL',Za[Za.NPC_HUNTNEXT=2525]='NPC_HUNTNEXT',Za[Za.NPC_SETHUNT=2526]='NPC_SETHUNT',Za[Za.NPC_SETHUNTMODE=2527]='NPC_SETHUNTMODE',Za[Za.NPC_SETMODE=2528]='NPC_SETMODE',Za[Za.NPC_WALKTRIGGER=2529]='NPC_WALKTRIGGER',Za[Za.NPC_SETTIMER=2530]='NPC_SETTIMER',Za[Za.NPC_STAT=2531]='NPC_STAT',Za[Za.NPC_STATADD=2532]='NPC_STATADD',Za[Za.NPC_STATHEAL=2533]='NPC_STATHEAL',Za[Za.NPC_STATSUB=2534]='NPC_STATSUB',Za[Za.NPC_TELE=2535]='NPC_TELE',Za[Za.NPC_TYPE=2536]='NPC_TYPE',Za[Za.NPC_UID=2537]='NPC_UID',Za[Za.SPOTANIM_NPC=2538]='SPOTANIM_NPC',Za[Za.NPC_WALK=2539]='NPC_WALK',Za[Za.NPC_ATTACKRANGE=2540]='NPC_ATTACKRANGE',Za[Za.LOC_ADD=3e3]='LOC_ADD',Za[Za.LOC_ANGLE=3001]='LOC_ANGLE',Za[Za.LOC_ANIM=3002]='LOC_ANIM',Za[Za.LOC_CATEGORY=3003]='LOC_CATEGORY',Za[Za.LOC_CHANGE=3004]='LOC_CHANGE',Za[Za.LOC_COORD=3005]='LOC_COORD',Za[Za.LOC_DEL=3006]='LOC_DEL',Za[Za.LOC_FIND=3007]='LOC_FIND',Za[Za.LOC_FINDALLZONE=3008]='LOC_FINDALLZONE',Za[Za.LOC_FINDNEXT=3009]='LOC_FINDNEXT',Za[Za.LOC_NAME=3010]='LOC_NAME',Za[Za.LOC_PARAM=3011]='LOC_PARAM',Za[Za.LOC_SHAPE=3012]='LOC_SHAPE',Za[Za.LOC_TYPE=3013]='LOC_TYPE',Za[Za.OBJ_ADD=3500]='OBJ_ADD',Za[Za.OBJ_ADDALL=3501]='OBJ_ADDALL',Za[Za.OBJ_COORD=3502]='OBJ_COORD',Za[Za.OBJ_COUNT=3503]='OBJ_COUNT',Za[Za.OBJ_DEL=3504]='OBJ_DEL',Za[Za.OBJ_NAME=3505]='OBJ_NAME',Za[Za.OBJ_PARAM=3506]='OBJ_PARAM',Za[Za.OBJ_TAKEITEM=3507]='OBJ_TAKEITEM',Za[Za.OBJ_TYPE=3508]='OBJ_TYPE',Za[Za.NC_CATEGORY=4e3]='NC_CATEGORY',Za[Za.NC_DEBUGNAME=4001]='NC_DEBUGNAME',Za[Za.NC_DESC=4002]='NC_DESC',Za[Za.NC_NAME=4003]='NC_NAME',Za[Za.NC_OP=4004]='NC_OP',Za[Za.NC_PARAM=4005]='NC_PARAM',Za[Za.LC_CATEGORY=4100]='LC_CATEGORY',Za[Za.LC_DEBUGNAME=4101]='LC_DEBUGNAME',Za[Za.LC_DESC=4102]='LC_DESC',Za[Za.LC_NAME=4103]='LC_NAME',Za[Za.LC_OP=4104]='LC_OP',Za[Za.LC_PARAM=4105]='LC_PARAM',Za[Za.LC_WIDTH=4106]='LC_WIDTH',Za[Za.LC_LENGTH=4107]='LC_LENGTH',Za[Za.OC_CATEGORY=4200]='OC_CATEGORY',Za[Za.OC_CERT=4201]='OC_CERT',Za[Za.OC_COST=4202]='OC_COST',Za[Za.OC_DEBUGNAME=4203]='OC_DEBUGNAME',Za[Za.OC_DESC=4204]='OC_DESC',Za[Za.OC_IOP=4205]='OC_IOP',Za[Za.OC_MEMBERS=4206]='OC_MEMBERS',Za[Za.OC_NAME=4207]='OC_NAME',Za[Za.OC_OP=4208]='OC_OP',Za[Za.OC_PARAM=4209]='OC_PARAM',Za[Za.OC_STACKABLE=4210]='OC_STACKABLE',Za[Za.OC_TRADEABLE=4211]='OC_TRADEABLE',Za[Za.OC_UNCERT=4212]='OC_UNCERT',Za[Za.OC_WEARPOS2=4213]='OC_WEARPOS2',Za[Za.OC_WEARPOS3=4214]='OC_WEARPOS3',Za[Za.OC_WEARPOS=4215]='OC_WEARPOS',Za[Za.OC_WEIGHT=4216]='OC_WEIGHT',Za[Za.INV_ALLSTOCK=4300]='INV_ALLSTOCK',Za[Za.INV_SIZE=4301]='INV_SIZE',Za[Za.INV_STOCKBASE=4302]='INV_STOCKBASE',Za[Za.INV_ADD=4303]='INV_ADD',Za[Za.INV_CHANGESLOT=4304]='INV_CHANGESLOT',Za[Za.INV_CLEAR=4305]='INV_CLEAR',Za[Za.INV_DEL=4306]='INV_DEL',Za[Za.INV_DELSLOT=4307]='INV_DELSLOT',Za[Za.INV_DROPITEM=4308]='INV_DROPITEM',Za[Za.INV_DROPSLOT=4309]='INV_DROPSLOT',Za[Za.INV_FREESPACE=4310]='INV_FREESPACE',Za[Za.INV_GETNUM=4311]='INV_GETNUM',Za[Za.INV_GETOBJ=4312]='INV_GETOBJ',Za[Za.INV_ITEMSPACE=4313]='INV_ITEMSPACE',Za[Za.INV_ITEMSPACE2=4314]='INV_ITEMSPACE2',Za[Za.INV_MOVEFROMSLOT=4315]='INV_MOVEFROMSLOT',Za[Za.INV_MOVETOSLOT=4316]='INV_MOVETOSLOT',Za[Za.BOTH_MOVEINV=4317]='BOTH_MOVEINV',Za[Za.INV_MOVEITEM=4318]='INV_MOVEITEM',Za[Za.INV_MOVEITEM_CERT=4319]='INV_MOVEITEM_CERT',Za[Za.INV_MOVEITEM_UNCERT=4320]='INV_MOVEITEM_UNCERT',Za[Za.INV_SETSLOT=4321]='INV_SETSLOT',Za[Za.INV_TOTAL=4322]='INV_TOTAL',Za[Za.INV_TOTALCAT=4323]='INV_TOTALCAT',Za[Za.INV_TRANSMIT=4324]='INV_TRANSMIT',Za[Za.INVOTHER_TRANSMIT=4325]='INVOTHER_TRANSMIT',Za[Za.INV_STOPTRANSMIT=4326]='INV_STOPTRANSMIT',Za[Za.BOTH_DROPSLOT=4327]='BOTH_DROPSLOT',Za[Za.INV_DROPALL=4328]='INV_DROPALL',Za[Za.INV_TOTALPARAM=4329]='INV_TOTALPARAM',Za[Za.INV_TOTALPARAM_STACK=4330]='INV_TOTALPARAM_STACK',Za[Za.ENUM=4400]='ENUM',Za[Za.ENUM_GETOUTPUTCOUNT=4401]='ENUM_GETOUTPUTCOUNT',Za[Za.APPEND_NUM=4500]='APPEND_NUM',Za[Za.APPEND=4501]='APPEND',Za[Za.APPEND_SIGNNUM=4502]='APPEND_SIGNNUM',Za[Za.LOWERCASE=4503]='LOWERCASE',Za[Za.TEXT_GENDER=4504]='TEXT_GENDER',Za[Za.TOSTRING=4505]='TOSTRING',Za[Za.COMPARE=4506]='COMPARE',Za[Za.TEXT_SWITCH=4507]='TEXT_SWITCH',Za[Za.APPEND_CHAR=4508]='APPEND_CHAR',Za[Za.STRING_LENGTH=4509]='STRING_LENGTH',Za[Za.SUBSTRING=4510]='SUBSTRING',Za[Za.STRING_INDEXOF_CHAR=4511]='STRING_INDEXOF_CHAR',Za[Za.STRING_INDEXOF_STRING=4512]='STRING_INDEXOF_STRING',Za[Za.ADD=4600]='ADD',Za[Za.SUB=4601]='SUB',Za[Za.MULTIPLY=4602]='MULTIPLY',Za[Za.DIVIDE=4603]='DIVIDE',Za[Za.RANDOM=4604]='RANDOM',Za[Za.RANDOMINC=4605]='RANDOMINC',Za[Za.INTERPOLATE=4606]='INTERPOLATE',Za[Za.ADDPERCENT=4607]='ADDPERCENT',Za[Za.SETBIT=4608]='SETBIT',Za[Za.CLEARBIT=4609]='CLEARBIT',Za[Za.TESTBIT=4610]='TESTBIT',Za[Za.MODULO=4611]='MODULO',Za[Za.POW=4612]='POW',Za[Za.INVPOW=4613]='INVPOW',Za[Za.AND=4614]='AND',Za[Za.OR=4615]='OR',Za[Za.MIN=4616]='MIN',Za[Za.MAX=4617]='MAX',Za[Za.SCALE=4618]='SCALE',Za[Za.BITCOUNT=4619]='BITCOUNT',Za[Za.TOGGLEBIT=4620]='TOGGLEBIT',Za[Za.SETBIT_RANGE=4621]='SETBIT_RANGE',Za[Za.CLEARBIT_RANGE=4622]='CLEARBIT_RANGE',Za[Za.GETBIT_RANGE=4623]='GETBIT_RANGE',Za[Za.SETBIT_RANGE_TOINT=4624]='SETBIT_RANGE_TOINT',Za[Za.SIN_DEG=4625]='SIN_DEG',Za[Za.COS_DEG=4626]='COS_DEG',Za[Za.ATAN2_DEG=4627]='ATAN2_DEG',Za[Za.ABS=4628]='ABS',Za[Za.DB_FIND_WITH_COUNT=7500]='DB_FIND_WITH_COUNT',Za[Za.DB_FINDNEXT=7501]='DB_FINDNEXT',Za[Za.DB_GETFIELD=7502]='DB_GETFIELD',Za[Za.DB_GETFIELDCOUNT=7503]='DB_GETFIELDCOUNT',Za[Za.DB_LISTALL_WITH_COUNT=7504]='DB_LISTALL_WITH_COUNT',Za[Za.DB_GETROWTABLE=7505]='DB_GETROWTABLE',Za[Za.DB_FINDBYINDEX=7506]='DB_FINDBYINDEX',Za[Za.DB_FIND_REFINE_WITH_COUNT=7507]='DB_FIND_REFINE_WITH_COUNT',Za[Za.DB_FIND=7508]='DB_FIND',Za[Za.DB_FIND_REFINE=7509]='DB_FIND_REFINE',Za[Za.DB_LISTALL=7510]='DB_LISTALL',Za[Za.ERROR=1e4]='ERROR',Za[Za.MAP_PRODUCTION=10001]='MAP_PRODUCTION',Za[Za.MAP_LASTCLOCK=10002]='MAP_LASTCLOCK',Za[Za.MAP_LASTWORLD=10003]='MAP_LASTWORLD',Za[Za.MAP_LASTCLIENTIN=10004]='MAP_LASTCLIENTIN',Za[Za.MAP_LASTNPC=10005]='MAP_LASTNPC',Za[Za.MAP_LASTPLAYER=10006]='MAP_LASTPLAYER',Za[Za.MAP_LASTLOGOUT=10007]='MAP_LASTLOGOUT',Za[Za.MAP_LASTLOGIN=10008]='MAP_LASTLOGIN',Za[Za.MAP_LASTZONE=10009]='MAP_LASTZONE',Za[Za.MAP_LASTCLIENTOUT=10010]='MAP_LASTCLIENTOUT',Za[Za.MAP_LASTCLEANUP=10011]='MAP_LASTCLEANUP',Za[Za.MAP_LASTBANDWIDTHIN=10012]='MAP_LASTBANDWIDTHIN',Za[Za.MAP_LASTBANDWIDTHOUT=10013]='MAP_LASTBANDWIDTHOUT';var ro=Ya;class io{info={scriptName:'',sourceFilePath:'',lookupKey:-1,parameterTypes:[],pcs:[],lines:[]};id;intLocalCount=0;stringLocalCount=0;intArgCount=0;stringArgCount=0;switchTables=[];opcodes=[];intOperands=[];stringOperands=[];static isLargeOperand(t){if(t>100)return!1;switch(t){case ro.RETURN:case ro.POP_INT_DISCARD:case ro.POP_STRING_DISCARD:case ro.GOSUB:case ro.JUMP:return!1}return!0}static decode(t,e){const r=e.data.length;if(r<16)throw new Error('Invalid script file (minimum length)');e.pos=r-2;const i=r-e.g2()-12-2;if(i<0||i>=r)throw new Error('Invalid script file (bad trailer pos)');e.pos=i;const n=new io(t);e.g4();n.intLocalCount=e.g2(),n.stringLocalCount=e.g2(),n.intArgCount=e.g2(),n.stringArgCount=e.g2();const s=e.g1();for(let t=0;te.pos;){const t=e.g2();t===ro.PUSH_CONSTANT_STRING?n.stringOperands[h]=e.gjstr(0):io.isLargeOperand(t)?n.intOperands[h]=e.g4():n.intOperands[h]=e.g1(),n.opcodes[h++]=t}return n}constructor(t){this.id=t}get name(){return this.info.scriptName}get fileName(){return f.basename(this.info.sourceFilePath)}lineNumber(t){for(let e=0;et)return this.info.lines[e-1];return this.info.lines[this.info.lines.length-1]}}class no{static COMPILER_VERSION=18;static scripts=[];static scriptLookup=new Map;static scriptNames=new Map;static load(t){const e=as.load(`${t}/server/script.dat`),r=as.load(`${t}/server/script.idx`);return this.parse(e,r)}static async loadAsync(t){const e=await as.loadAsync(`${t}/server/script.dat`),r=await as.loadAsync(`${t}/server/script.idx`);return this.parse(e,r)}static parse(t,e){t.data.length&&e.data.length||(console.log('\nFatal: No script.dat or script.idx found. Please run the server:build script.'),process.exit(1));const r=t.g2();e.pos+=2;t.g4()!==no.COMPILER_VERSION&&(console.error('\nFatal: Scripts were compiled with an older RuneScript compiler. Please update it, try `npm run build` and then restart the server.'),process.exit(1));const i=new Array(r),n=new Map,s=new Map;let a=0;for(let o=0;o=0;r--)e[r]=this.popInt();return e}pushInt(t){this.intStack[this.isp++]=so(t)}popString(){return this.stringStack[--this.ssp]??''}popStrings(t){const e=Array(t);for(let r=t-1;r>=0;r--)e[r]=this.popString();return e}pushString(t){this.stringStack[this.ssp++]=t}reset(){this.pc=-1,this.frames=[],this.fp=0,this.intStack=[],this.isp=0,this.stringStack=[],this.ssp=0,this.intLocals=[],this.stringLocals=[],this.pointers=0}}class lo{requested=0;completed=0;items=[];constructor(t,e=0,r=[]){this.requested=t,this.completed=e,this.items=r}getLeftOver(){return this.requested-this.completed}hasSucceeded(){return this.completed==this.requested}hasFailed(){return!this.hasSucceeded()}revert(t){for(let e=0;ee&&e.id==t))}hasAt(t,e){const r=this.items[t];return r&&r.id==e}get nextFreeSlot(){return this.items.indexOf(null,0)}get freeSlotCount(){return this.items.filter((t=>null==t)).length}get occupiedSlotCount(){return this.items.filter((t=>null!=t)).length}get isFull(){return this.occupiedSlotCount==this.capacity}get isEmpty(){return 0==this.occupiedSlotCount}get hasAny(){return this.items.some((t=>null!=t))}get hasSpace(){return-1!=this.nextFreeSlot}get itemsFiltered(){return this.items.filter((t=>null!=t))}getItemCount(t){let e=0;for(let r=0;re&&e.id==t))}removeAll(){this.items.fill(null,0,this.capacity),this.update=!0}add(t,e=1,r=-1,i=!0,n=!1,s=!1){const a=Aa.get(t),o=!0===Zs.get(this.type).stockobj?.includes(t),h=!n&&this.stackType!=co.NEVER_STACK&&(a.stackable||this.stackType==co.ALWAYS_STACK);let l=0;if(h&&(l=this.getItemCount(t)),l==co.STACK_LIMIT)return new lo(e,0,[]);const c=this.freeSlotCount;if(0==c&&(!h||h&&0==l&&!o))return new lo(e,0,[]);if(i){if(h&&l>co.STACK_LIMIT-e)return new lo(e,0,[]);if(!h&&e>c)return new lo(e,0,[])}else{if(h&&l==co.STACK_LIMIT)return new lo(e,0,[]);if(!h&&0==c)return new lo(e,0,[])}let u=0;const d=[];if(h){let i=this.getItemIndex(t);if(-1==i&&(i=-1==r?this.nextFreeSlot:this.items.indexOf(null,r),-1==i))return new lo(e,u,[]);const n=this.get(i)?.count??0,a=Math.min(co.STACK_LIMIT,n+e),o={id:t,count:a};s||this.set(i,o),d.push({slot:i,item:o}),u=a-n}else{for(let i=Math.max(0,r);i=e)break}}return new lo(e,u,d)}remove(t,e=1,r=-1,i=!1){const n=this.getItemCount(t),s=!0===Zs.get(this.type).stockobj?.includes(t);if(i&&n=e)break}if(null!=h&&a=e)break}return a>0&&(this.update=!0),new lo(e,a,o)}delete(t){this.items[t]=null,this.update=!0}swap(t,e){const r=this.items[t];this.set(t,this.items[e]),this.set(e,r)}shift(){this.items.sort(((t,e)=>null===t||null===e?+(null===t)-+(null===e):+(t>e)||-(t=0&&t=0)&&(h={id:o.certlink,count:a});const l=t.add(h.id,h.count,i,!1);if(0==l.completed)return null;const c=this.remove(e.id,l.completed,r,!1);return 0==c.completed?null:c}}async function uo(t,e={}){const r={env:Object.assign(Object.create(globalThis),e.env||{},{abort(t,e,r,i){t=o(t>>>0),e=o(e>>>0),r>>>=0,i>>>=0,(()=>{throw Error(`${t} in ${e}:${r}:${i}`)})()},seed:()=>Date.now()*Math.random()})},{exports:i}=await WebAssembly.instantiate(t,r),n=i.memory||e.env.memory,s=Object.setPrototypeOf({findPath(t,e,r,n,s,a,o,l,u,d,f,p,m,g){return f=f?1:0,i.__setArgumentsLength(arguments.length),h(c,2,i.findPath(t,e,r,n,s,a,o,l,u,d,f,p,m,g)>>>0)},findNaivePath(t,e,r,n,s,a,o,l,u,d,f){return i.__setArgumentsLength(arguments.length),h(c,2,i.findNaivePath(t,e,r,n,s,a,o,l,u,d,f)>>>0)},changeFloor(t,e,r,n){n=n?1:0,i.changeFloor(t,e,r,n)},changeLoc(t,e,r,n,s,a,o,h){a=a?1:0,o=o?1:0,h=h?1:0,i.changeLoc(t,e,r,n,s,a,o,h)},changeNpc(t,e,r,n,s){s=s?1:0,i.changeNpc(t,e,r,n,s)},changePlayer(t,e,r,n,s){s=s?1:0,i.changePlayer(t,e,r,n,s)},changeRoof(t,e,r,n){n=n?1:0,i.changeRoof(t,e,r,n)},changeWall(t,e,r,n,s,a,o,h){a=a?1:0,o=o?1:0,h=h?1:0,i.changeWall(t,e,r,n,s,a,o,h)},allocateIfAbsent:(t,e,r)=>h(c,2,i.allocateIfAbsent(t,e,r)>>>0),isZoneAllocated:(t,e,r)=>0!=i.isZoneAllocated(t,e,r),isFlagged:(t,e,r,n)=>0!=i.isFlagged(t,e,r,n),canTravel(t,e,r,n,s,a,o,h){return i.__setArgumentsLength(arguments.length),0!=i.canTravel(t,e,r,n,s,a,o,h)},hasLineOfSight(t,e,r,n,s,a,o,h,l,c){return i.__setArgumentsLength(arguments.length),0!=i.hasLineOfSight(t,e,r,n,s,a,o,h,l,c)},hasLineOfWalk(t,e,r,n,s,a,o,h,l,c){return i.__setArgumentsLength(arguments.length),0!=i.hasLineOfWalk(t,e,r,n,s,a,o,h,l,c)},lineOfSight(t,e,r,n,s,a,o,l,u,d){return i.__setArgumentsLength(arguments.length),h(c,2,i.lineOfSight(t,e,r,n,s,a,o,l,u,d)>>>0)},lineOfWalk(t,e,r,n,s,a,o,l,u,d){return i.__setArgumentsLength(arguments.length),h(c,2,i.lineOfWalk(t,e,r,n,s,a,o,l,u,d)>>>0)},reached(t,e,r,n,s,a,o,h,l,c,u){return i.__setArgumentsLength(arguments.length),0!=i.reached(t,e,r,n,s,a,o,h,l,c,u)},__collides:(t,e,r,n,s,a,o,h)=>0!=i.__collides(t,e,r,n,s,a,o,h),__reachRectangle1:(t,e,r,n,s,a,o,h)=>0!=i.__reachRectangle1(t,e,r,n,s,a,o,h),__reachRectangleN:(t,e,r,n,s,a,o,h,l,c)=>0!=i.__reachRectangleN(t,e,r,n,s,a,o,h,l,c),__reachRectangle:(t,e,r,n,s,a,o,h,l,c)=>0!=i.__reachRectangle(t,e,r,n,s,a,o,h,l,c),__reachExclusiveRectangle:(t,e,r,n,s,a,o,h,l,c)=>0!=i.__reachExclusiveRectangle(t,e,r,n,s,a,o,h,l,c),CollisionFlag:(a={},a[a.NULL=i['CollisionFlag.NULL'].valueOf()]='NULL',a[a.OPEN=i['CollisionFlag.OPEN'].valueOf()]='OPEN',a[a.WALL_NORTH_WEST=i['CollisionFlag.WALL_NORTH_WEST'].valueOf()]='WALL_NORTH_WEST',a[a.WALL_NORTH=i['CollisionFlag.WALL_NORTH'].valueOf()]='WALL_NORTH',a[a.WALL_NORTH_EAST=i['CollisionFlag.WALL_NORTH_EAST'].valueOf()]='WALL_NORTH_EAST',a[a.WALL_EAST=i['CollisionFlag.WALL_EAST'].valueOf()]='WALL_EAST',a[a.WALL_SOUTH_EAST=i['CollisionFlag.WALL_SOUTH_EAST'].valueOf()]='WALL_SOUTH_EAST',a[a.WALL_SOUTH=i['CollisionFlag.WALL_SOUTH'].valueOf()]='WALL_SOUTH',a[a.WALL_SOUTH_WEST=i['CollisionFlag.WALL_SOUTH_WEST'].valueOf()]='WALL_SOUTH_WEST',a[a.WALL_WEST=i['CollisionFlag.WALL_WEST'].valueOf()]='WALL_WEST',a[a.LOC=i['CollisionFlag.LOC'].valueOf()]='LOC',a[a.WALL_NORTH_WEST_PROJ_BLOCKER=i['CollisionFlag.WALL_NORTH_WEST_PROJ_BLOCKER'].valueOf()]='WALL_NORTH_WEST_PROJ_BLOCKER',a[a.WALL_NORTH_PROJ_BLOCKER=i['CollisionFlag.WALL_NORTH_PROJ_BLOCKER'].valueOf()]='WALL_NORTH_PROJ_BLOCKER',a[a.WALL_NORTH_EAST_PROJ_BLOCKER=i['CollisionFlag.WALL_NORTH_EAST_PROJ_BLOCKER'].valueOf()]='WALL_NORTH_EAST_PROJ_BLOCKER',a[a.WALL_EAST_PROJ_BLOCKER=i['CollisionFlag.WALL_EAST_PROJ_BLOCKER'].valueOf()]='WALL_EAST_PROJ_BLOCKER',a[a.WALL_SOUTH_EAST_PROJ_BLOCKER=i['CollisionFlag.WALL_SOUTH_EAST_PROJ_BLOCKER'].valueOf()]='WALL_SOUTH_EAST_PROJ_BLOCKER',a[a.WALL_SOUTH_PROJ_BLOCKER=i['CollisionFlag.WALL_SOUTH_PROJ_BLOCKER'].valueOf()]='WALL_SOUTH_PROJ_BLOCKER',a[a.WALL_SOUTH_WEST_PROJ_BLOCKER=i['CollisionFlag.WALL_SOUTH_WEST_PROJ_BLOCKER'].valueOf()]='WALL_SOUTH_WEST_PROJ_BLOCKER',a[a.WALL_WEST_PROJ_BLOCKER=i['CollisionFlag.WALL_WEST_PROJ_BLOCKER'].valueOf()]='WALL_WEST_PROJ_BLOCKER',a[a.LOC_PROJ_BLOCKER=i['CollisionFlag.LOC_PROJ_BLOCKER'].valueOf()]='LOC_PROJ_BLOCKER',a[a.FLOOR_DECORATION=i['CollisionFlag.FLOOR_DECORATION'].valueOf()]='FLOOR_DECORATION',a[a.NPC=i['CollisionFlag.NPC'].valueOf()]='NPC',a[a.PLAYER=i['CollisionFlag.PLAYER'].valueOf()]='PLAYER',a[a.FLOOR=i['CollisionFlag.FLOOR'].valueOf()]='FLOOR',a[a.WALL_NORTH_WEST_ROUTE_BLOCKER=i['CollisionFlag.WALL_NORTH_WEST_ROUTE_BLOCKER'].valueOf()]='WALL_NORTH_WEST_ROUTE_BLOCKER',a[a.WALL_NORTH_ROUTE_BLOCKER=i['CollisionFlag.WALL_NORTH_ROUTE_BLOCKER'].valueOf()]='WALL_NORTH_ROUTE_BLOCKER',a[a.WALL_NORTH_EAST_ROUTE_BLOCKER=i['CollisionFlag.WALL_NORTH_EAST_ROUTE_BLOCKER'].valueOf()]='WALL_NORTH_EAST_ROUTE_BLOCKER',a[a.WALL_EAST_ROUTE_BLOCKER=i['CollisionFlag.WALL_EAST_ROUTE_BLOCKER'].valueOf()]='WALL_EAST_ROUTE_BLOCKER',a[a.WALL_SOUTH_EAST_ROUTE_BLOCKER=i['CollisionFlag.WALL_SOUTH_EAST_ROUTE_BLOCKER'].valueOf()]='WALL_SOUTH_EAST_ROUTE_BLOCKER',a[a.WALL_SOUTH_ROUTE_BLOCKER=i['CollisionFlag.WALL_SOUTH_ROUTE_BLOCKER'].valueOf()]='WALL_SOUTH_ROUTE_BLOCKER',a[a.WALL_SOUTH_WEST_ROUTE_BLOCKER=i['CollisionFlag.WALL_SOUTH_WEST_ROUTE_BLOCKER'].valueOf()]='WALL_SOUTH_WEST_ROUTE_BLOCKER',a[a.WALL_WEST_ROUTE_BLOCKER=i['CollisionFlag.WALL_WEST_ROUTE_BLOCKER'].valueOf()]='WALL_WEST_ROUTE_BLOCKER',a[a.LOC_ROUTE_BLOCKER=i['CollisionFlag.LOC_ROUTE_BLOCKER'].valueOf()]='LOC_ROUTE_BLOCKER',a[a.ROOF=i['CollisionFlag.ROOF'].valueOf()]='ROOF',a[a.FLOOR_BLOCKED=i['CollisionFlag.FLOOR_BLOCKED'].valueOf()]='FLOOR_BLOCKED',a[a.WALK_BLOCKED=i['CollisionFlag.WALK_BLOCKED'].valueOf()]='WALK_BLOCKED',a[a.BLOCK_WEST=i['CollisionFlag.BLOCK_WEST'].valueOf()]='BLOCK_WEST',a[a.BLOCK_EAST=i['CollisionFlag.BLOCK_EAST'].valueOf()]='BLOCK_EAST',a[a.BLOCK_SOUTH=i['CollisionFlag.BLOCK_SOUTH'].valueOf()]='BLOCK_SOUTH',a[a.BLOCK_NORTH=i['CollisionFlag.BLOCK_NORTH'].valueOf()]='BLOCK_NORTH',a[a.BLOCK_SOUTH_WEST=i['CollisionFlag.BLOCK_SOUTH_WEST'].valueOf()]='BLOCK_SOUTH_WEST',a[a.BLOCK_SOUTH_EAST=i['CollisionFlag.BLOCK_SOUTH_EAST'].valueOf()]='BLOCK_SOUTH_EAST',a[a.BLOCK_NORTH_WEST=i['CollisionFlag.BLOCK_NORTH_WEST'].valueOf()]='BLOCK_NORTH_WEST',a[a.BLOCK_NORTH_EAST=i['CollisionFlag.BLOCK_NORTH_EAST'].valueOf()]='BLOCK_NORTH_EAST',a[a.BLOCK_NORTH_AND_SOUTH_EAST=i['CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST'].valueOf()]='BLOCK_NORTH_AND_SOUTH_EAST',a[a.BLOCK_NORTH_AND_SOUTH_WEST=i['CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST'].valueOf()]='BLOCK_NORTH_AND_SOUTH_WEST',a[a.BLOCK_NORTH_EAST_AND_WEST=i['CollisionFlag.BLOCK_NORTH_EAST_AND_WEST'].valueOf()]='BLOCK_NORTH_EAST_AND_WEST',a[a.BLOCK_SOUTH_EAST_AND_WEST=i['CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST'].valueOf()]='BLOCK_SOUTH_EAST_AND_WEST',a[a.BLOCK_WEST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_WEST_ROUTE_BLOCKER',a[a.BLOCK_EAST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_EAST_ROUTE_BLOCKER'].valueOf()]='BLOCK_EAST_ROUTE_BLOCKER',a[a.BLOCK_SOUTH_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_SOUTH_ROUTE_BLOCKER'].valueOf()]='BLOCK_SOUTH_ROUTE_BLOCKER',a[a.BLOCK_NORTH_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_NORTH_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_ROUTE_BLOCKER',a[a.BLOCK_SOUTH_WEST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_SOUTH_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_SOUTH_WEST_ROUTE_BLOCKER',a[a.BLOCK_SOUTH_EAST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_SOUTH_EAST_ROUTE_BLOCKER'].valueOf()]='BLOCK_SOUTH_EAST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_WEST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_NORTH_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_WEST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_EAST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_NORTH_EAST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_EAST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER',a[a.BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER=i['CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER',a),LocShape:(t=>(t[t.WALL_STRAIGHT=i['LocShape.WALL_STRAIGHT'].valueOf()]='WALL_STRAIGHT',t[t.WALL_DIAGONAL_CORNER=i['LocShape.WALL_DIAGONAL_CORNER'].valueOf()]='WALL_DIAGONAL_CORNER',t[t.WALL_L=i['LocShape.WALL_L'].valueOf()]='WALL_L',t[t.WALL_SQUARE_CORNER=i['LocShape.WALL_SQUARE_CORNER'].valueOf()]='WALL_SQUARE_CORNER',t[t.WALLDECOR_STRAIGHT_NOOFFSET=i['LocShape.WALLDECOR_STRAIGHT_NOOFFSET'].valueOf()]='WALLDECOR_STRAIGHT_NOOFFSET',t[t.WALLDECOR_STRAIGHT_OFFSET=i['LocShape.WALLDECOR_STRAIGHT_OFFSET'].valueOf()]='WALLDECOR_STRAIGHT_OFFSET',t[t.WALLDECOR_DIAGONAL_OFFSET=i['LocShape.WALLDECOR_DIAGONAL_OFFSET'].valueOf()]='WALLDECOR_DIAGONAL_OFFSET',t[t.WALLDECOR_DIAGONAL_NOOFFSET=i['LocShape.WALLDECOR_DIAGONAL_NOOFFSET'].valueOf()]='WALLDECOR_DIAGONAL_NOOFFSET',t[t.WALLDECOR_DIAGONAL_BOTH=i['LocShape.WALLDECOR_DIAGONAL_BOTH'].valueOf()]='WALLDECOR_DIAGONAL_BOTH',t[t.WALL_DIAGONAL=i['LocShape.WALL_DIAGONAL'].valueOf()]='WALL_DIAGONAL',t[t.CENTREPIECE_STRAIGHT=i['LocShape.CENTREPIECE_STRAIGHT'].valueOf()]='CENTREPIECE_STRAIGHT',t[t.CENTREPIECE_DIAGONAL=i['LocShape.CENTREPIECE_DIAGONAL'].valueOf()]='CENTREPIECE_DIAGONAL',t[t.ROOF_STRAIGHT=i['LocShape.ROOF_STRAIGHT'].valueOf()]='ROOF_STRAIGHT',t[t.ROOF_DIAGONAL_WITH_ROOFEDGE=i['LocShape.ROOF_DIAGONAL_WITH_ROOFEDGE'].valueOf()]='ROOF_DIAGONAL_WITH_ROOFEDGE',t[t.ROOF_DIAGONAL=i['LocShape.ROOF_DIAGONAL'].valueOf()]='ROOF_DIAGONAL',t[t.ROOF_L_CONCAVE=i['LocShape.ROOF_L_CONCAVE'].valueOf()]='ROOF_L_CONCAVE',t[t.ROOF_L_CONVEX=i['LocShape.ROOF_L_CONVEX'].valueOf()]='ROOF_L_CONVEX',t[t.ROOF_FLAT=i['LocShape.ROOF_FLAT'].valueOf()]='ROOF_FLAT',t[t.ROOFEDGE_STRAIGHT=i['LocShape.ROOFEDGE_STRAIGHT'].valueOf()]='ROOFEDGE_STRAIGHT',t[t.ROOFEDGE_DIAGONAL_CORNER=i['LocShape.ROOFEDGE_DIAGONAL_CORNER'].valueOf()]='ROOFEDGE_DIAGONAL_CORNER',t[t.ROOFEDGE_L=i['LocShape.ROOFEDGE_L'].valueOf()]='ROOFEDGE_L',t[t.ROOFEDGE_SQUARE_CORNER=i['LocShape.ROOFEDGE_SQUARE_CORNER'].valueOf()]='ROOFEDGE_SQUARE_CORNER',t[t.GROUND_DECOR=i['LocShape.GROUND_DECOR'].valueOf()]='GROUND_DECOR',t))({}),LocAngle:(t=>(t[t.WEST=i['LocAngle.WEST'].valueOf()]='WEST',t[t.NORTH=i['LocAngle.NORTH'].valueOf()]='NORTH',t[t.EAST=i['LocAngle.EAST'].valueOf()]='EAST',t[t.SOUTH=i['LocAngle.SOUTH'].valueOf()]='SOUTH',t))({}),CollisionType:(t=>(t[t.NORMAL=i['CollisionType.NORMAL'].valueOf()]='NORMAL',t[t.BLOCKED=i['CollisionType.BLOCKED'].valueOf()]='BLOCKED',t[t.INDOORS=i['CollisionType.INDOORS'].valueOf()]='INDOORS',t[t.OUTDOORS=i['CollisionType.OUTDOORS'].valueOf()]='OUTDOORS',t[t.LINE_OF_SIGHT=i['CollisionType.LINE_OF_SIGHT'].valueOf()]='LINE_OF_SIGHT',t))({}),LocLayer:(t=>(t[t.WALL=i['LocLayer.WALL'].valueOf()]='WALL',t[t.WALL_DECOR=i['LocLayer.WALL_DECOR'].valueOf()]='WALL_DECOR',t[t.GROUND=i['LocLayer.GROUND'].valueOf()]='GROUND',t[t.GROUND_DECOR=i['LocLayer.GROUND_DECOR'].valueOf()]='GROUND_DECOR',t))({}),BlockAccessFlag:(t=>(t[t.BLOCK_NORTH=i['BlockAccessFlag.BLOCK_NORTH'].valueOf()]='BLOCK_NORTH',t[t.BLOCK_EAST=i['BlockAccessFlag.BLOCK_EAST'].valueOf()]='BLOCK_EAST',t[t.BLOCK_SOUTH=i['BlockAccessFlag.BLOCK_SOUTH'].valueOf()]='BLOCK_SOUTH',t[t.BLOCK_WEST=i['BlockAccessFlag.BLOCK_WEST'].valueOf()]='BLOCK_WEST',t))({})},i);var a;function o(t){if(!t)return null;const e=t+new Uint32Array(n.buffer)[t-4>>>2]>>>1,r=new Uint16Array(n.buffer);let i=t>>>1,s='';for(;e-i>1024;)s+=String.fromCharCode(...r.subarray(i,i+=1024));return s+String.fromCharCode(...r.subarray(i,e))}function h(t,e,r){if(!r)return null;const i=function(t){try{return l.getUint32(t,!0)}catch{return l=new DataView(n.buffer),l.getUint32(t,!0)}}(r-4)>>>e,s=new Array(i);for(let n=0;n>>0));return s}let l=new DataView(n.buffer);function c(t){try{return l.getInt32(t,!0)}catch{return l=new DataView(n.buffer),l.getInt32(t,!0)}}return s}var fo,po,{memory:mo,findPath:go,findNaivePath:yo,changeFloor:vo,changeLoc:bo,changeNpc:_o,changePlayer:wo,changeRoof:Eo,changeWall:Ao,allocateIfAbsent:So,deallocateIfPresent:To,isZoneAllocated:Mo,isFlagged:Io,canTravel:Co,hasLineOfSight:Oo,hasLineOfWalk:No,lineOfSight:Lo,lineOfWalk:Ro,reached:Po,locShapeLayer:Bo,__get:ko,__set:Do,__add:Uo,__remove:xo,__rotate:Fo,__rotateFlags:Ho,__collides:jo,__reachRectangle1:Vo,__reachRectangleN:Go,__alteredRotation:zo,__reachRectangle:Wo,__reachExclusiveRectangle:Ko,CollisionFlag:qo,LocShape:Yo,LocAngle:Zo,CollisionType:$o,LocLayer:Xo,BlockAccessFlag:Qo}=await(async t=>uo(await(async()=>{try{return await globalThis.WebAssembly.compileStreaming(globalThis.fetch(t))}catch{return globalThis.WebAssembly.compile(await(await import('node:fs/promises')).readFile(t))}})(),{}))(new URL('rsmod-pathfinder.wasm',import.meta.url)),Jo=0,th=1,eh=2,rh=3,ih=4,nh=5,sh=6,ah=7,oh={zone:t=>t>>3,zoneCenter:t=>oh.zone(t)-6,zoneOrigin:t=>oh.zoneCenter(t)<<3,mapsquare:t=>t>>6,local:(t,e)=>t-(oh.zoneCenter(e)<<3),face:(t,e,r,i)=>t!=r?t>r?e>i?nh:ei?ah:ei?sh:et+oh.deltaX(e),moveZ:(t,e)=>t+oh.deltaZ(e),distanceTo(t,e){const r=oh.closest(t,e),i=oh.closest(e,t);return Math.max(Math.abs(r.x-i.x),Math.abs(r.z-i.z))},closest(t,e){const r=t.x+t.width-1,i=t.z+t.length-1;return{x:e.x<=t.x?t.x:e.x>=r?r:e.x,z:e.z<=t.z?t.z:e.z>=i?i:e.z}},distanceToSW(t,e){const r=Math.abs(t.x-e.x),i=Math.abs(t.z-e.z);return Math.max(r,i)},isWithinDistanceSW:(t,e,r)=>!(Math.abs(t.x-e.x)>r||Math.abs(t.z-e.z)>r),deltaX(t){switch(t){case ah:case eh:case ih:return 1;case nh:case Jo:case rh:return-1}return 0},deltaZ(t){switch(t){case Jo:case eh:case th:return 1;case nh:case ah:case sh:return-1}return 0},unpackCoord:t=>({level:t>>28&3,x:t>>14&16383,z:16383&t}),packCoord:(t,e,r)=>16383&r|(16383&e)<<14|(3&t)<<28,packZoneCoord:(t,e)=>(7&t)<<4|7&e,intersects:(t,e,r,i,n,s,a,o)=>!(n>=t+r||n+a<=t||s>=e+i||s+o<=e),formatString:(t,e,r,i="_")=>t+i+(e>>6)+i+(r>>6)+i+(63&e)+i+(63&r)};(po=fo||={})[po.BLOCK=0]='BLOCK',po[po.DAMAGE=1]='DAMAGE',po[po.POISON=2]='POISON';var hh,lh,ch=fo;(lh=hh||={})[lh.ATTACK=0]='ATTACK',lh[lh.DEFENCE=1]='DEFENCE',lh[lh.STRENGTH=2]='STRENGTH',lh[lh.HITPOINTS=3]='HITPOINTS',lh[lh.RANGED=4]='RANGED',lh[lh.PRAYER=5]='PRAYER',lh[lh.MAGIC=6]='MAGIC',lh[lh.COOKING=7]='COOKING',lh[lh.WOODCUTTING=8]='WOODCUTTING',lh[lh.FLETCHING=9]='FLETCHING',lh[lh.FISHING=10]='FISHING',lh[lh.FIREMAKING=11]='FIREMAKING',lh[lh.CRAFTING=12]='CRAFTING',lh[lh.SMITHING=13]='SMITHING',lh[lh.MINING=14]='MINING',lh[lh.HERBLORE=15]='HERBLORE',lh[lh.AGILITY=16]='AGILITY',lh[lh.THIEVING=17]='THIEVING',lh[lh.STAT18=18]='STAT18',lh[lh.STAT19=19]='STAT19',lh[lh.RUNECRAFT=20]='RUNECRAFT';var uh=hh;function dh(t,e){return e.validate(t)}class fh{type;count;name;constructor(t,e,r){this.type=t,this.count=e,this.name=r}validate(t){if(this.count(t))return this.type(t);throw new Error(`An input for a ${this.name} type was not valid to use. Input was ${t}.`)}}class ph{min;max;name;constructor(t,e,r){this.min=t,this.max=e,this.name=r}validate(t){if(t>=this.min&&t<=this.max)return t;throw new Error(`An input for a ${this.name} was out of range. Range should be: ${this.min} to ${this.max}. Input was ${t}.`)}}var mh,gh,yh=new class{validate(t){if(-1!==t)return t;throw Error('An input number was null(-1).')}},vh=new class{validate(t){if(t.length>0)return t;throw Error('An input string was null(-1).')}},bh=new fh(ta.get,(t=>t>=0&&t=this.min&&t<=this.max)return oh.unpackCoord(t);throw new Error(`An input for a ${this.name} was out of range. Range should be: ${this.min} to ${this.max}. Input was ${t}.`)}}(0,2147483647,'Coord'),Sh=new fh(ga.get,(t=>t>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&tt>=0&&t=50)throw new Error('stack overflow');t.frames[t.fp++]={script:t.script,pc:t.pc,intLocals:t.intLocals,stringLocals:t.stringLocals};const r=no.get(e);if(!r)throw new Error(`unable to find proc ${r}`);Jh(t,r)},Qh=function(t,e){const r=no.get(e);if(!r)throw new Error(`unable to find label ${e}`);t.debugFrames[t.debugFp++]={script:t.script,pc:t.pc},Jh(t,r),t.fp=0,t.frames=[]},Jh=function(t,e){t.script=e,t.pc=-1,t.intLocals=t.popInts(e.intArgCount),t.stringLocals=t.popStrings(e.stringArgCount)},tl={[ro.PUSH_CONSTANT_INT]:t=>{t.pushInt(t.intOperand)},[ro.PUSH_CONSTANT_STRING]:t=>{t.pushString(t.stringOperand)},[ro.PUSH_VARP]:t=>{const e=t.intOperand>>16&1;if(e&&!t._activePlayer2)throw new Error('No secondary active_player.');if(!e&&!t._activePlayer)throw new Error('No active_player.');const r=dh(65535&t.intOperand,jh);r.type===us.STRING?t.pushString(e?t._activePlayer2.getVar(r.id):t._activePlayer.getVar(r.id)):t.pushInt(e?t._activePlayer2.getVar(r.id):t._activePlayer.getVar(r.id))},[ro.POP_VARP]:t=>{const e=t.intOperand>>16&1;if(e&&!t._activePlayer2)throw new Error('No secondary active_player.');if(!e&&!t._activePlayer)throw new Error('No active_player.');const r=dh(65535&t.intOperand,jh);if(!t.pointerGet(to[e])&&r.protect)throw new Error(`%${r.debugname} requires protected access`);if(r.type===us.STRING){const i=t.popString();e?t._activePlayer2.setVar(r.id,i):t._activePlayer.setVar(r.id,i)}else{const i=t.popInt();e?t._activePlayer2.setVar(r.id,i):t._activePlayer.setVar(r.id,i)}},[ro.PUSH_VARN]:t=>{const e=t.intOperand>>16&1;if(e&&!t._activeNpc2)throw new Error('No secondary active_npc.');if(!e&&!t._activeNpc)throw new Error('No active_npc.');const r=dh(65535&t.intOperand,Vh);r.type===us.STRING?t.pushString(e?t._activeNpc2.getVar(r.id):t._activeNpc.getVar(r.id)):t.pushInt(e?t._activeNpc2.getVar(r.id):t._activeNpc.getVar(r.id))},[ro.POP_VARN]:t=>{const e=t.intOperand>>16&1;if(e&&!t._activeNpc2)throw new Error('No secondary active_npc.');if(!e&&!t._activeNpc)throw new Error('No active_npc.');const r=dh(65535&t.intOperand,Vh);if(r.type===us.STRING){const i=t.popInt();e?t._activeNpc2.setVar(r.id,i):t._activeNpc.setVar(r.id,i)}else{const i=t.popInt();e?t._activeNpc2.setVar(r.id,i):t._activeNpc.setVar(r.id,i)}},[ro.PUSH_INT_LOCAL]:t=>{t.pushInt(t.intLocals[t.intOperand])},[ro.POP_INT_LOCAL]:t=>{t.intLocals[t.intOperand]=t.popInt()},[ro.PUSH_STRING_LOCAL]:t=>{t.pushString(t.stringLocals[t.intOperand])},[ro.POP_STRING_LOCAL]:t=>{t.stringLocals[t.intOperand]=t.popString()},[ro.BRANCH]:t=>{t.pc+=t.intOperand},[ro.BRANCH_NOT]:t=>{const e=t.popInt();t.popInt()!==e&&(t.pc+=t.intOperand)},[ro.BRANCH_EQUALS]:t=>{const e=t.popInt();t.popInt()===e&&(t.pc+=t.intOperand)},[ro.BRANCH_LESS_THAN]:t=>{const e=t.popInt();t.popInt(){const e=t.popInt();t.popInt()>e&&(t.pc+=t.intOperand)},[ro.BRANCH_LESS_THAN_OR_EQUALS]:t=>{const e=t.popInt();t.popInt()<=e&&(t.pc+=t.intOperand)},[ro.BRANCH_GREATER_THAN_OR_EQUALS]:t=>{const e=t.popInt();t.popInt()>=e&&(t.pc+=t.intOperand)},[ro.POP_INT_DISCARD]:t=>{t.isp--},[ro.POP_STRING_DISCARD]:t=>{t.ssp--},[ro.RETURN]:t=>{if(0===t.fp)return void(t.execution=ho.FINISHED);const e=t.frames[--t.fp];t.pc=e.pc,t.script=e.script,t.intLocals=e.intLocals,t.stringLocals=e.stringLocals},[ro.JOIN_STRING]:t=>{const e=t.intOperand,r=[];for(let i=0;i{Xh(t,t.popInt())},[ro.GOSUB_WITH_PARAMS]:t=>{Xh(t,t.intOperand)},[ro.JUMP]:t=>{Qh(t,t.popInt())},[ro.JUMP_WITH_PARAMS]:t=>{Qh(t,t.intOperand)},[ro.DEFINE_ARRAY]:t=>{throw new Error('unimplemented')},[ro.PUSH_ARRAY_INT]:t=>{throw new Error('unimplemented')},[ro.POP_ARRAY_INT]:t=>{throw new Error('unimplemented')},[ro.SWITCH]:t=>{const e=t.popInt(),r=t.script.switchTables[t.intOperand];if(void 0===r)return;const i=r[e];i&&(t.pc+=i)},[ro.PUSH_VARS]:t=>{const e=dh(65535&t.intOperand,Gh);e.type===us.STRING?t.pushString(Lm.varsString[e.id]??''):t.pushInt(Lm.vars[e.id])},[ro.POP_VARS]:t=>{const e=dh(65535&t.intOperand,Gh);e.type===us.STRING?Lm.varsString[e.id]=t.popString():Lm.vars[e.id]=t.popInt()}},el=tl,rl={[ro.DB_FIND_WITH_COUNT]:t=>{throw new Error('unimplemented')},[ro.DB_FINDNEXT]:t=>{if(!t.dbTable)throw new Error('No table selected');t.dbRow+1>=t.dbRowQuery.length?t.pushInt(-1):(t.dbRow++,t.pushInt(dh(t.dbRowQuery[t.dbRow],qh).id))},[ro.DB_GETFIELD]:t=>{const[e,r,i]=t.popInts(3),n=r>>12&65535,s=r>>4&127,a=dh(e,qh),o=dh(n,Yh);let h;h=a.tableId!==n?o.getDefault(s):a.getValue(s,i);const l=o.types[s];for(let e=0;e{const[e,r]=t.popInts(2),i=r>>12&65535,n=r>>4&127,s=dh(e,qh),a=dh(i,Yh);s.tableId===i?t.pushInt(s.columnValues[n].length/a.types[n].length):t.pushInt(0)},[ro.DB_LISTALL_WITH_COUNT]:t=>{throw new Error('unimplemented')},[ro.DB_GETROWTABLE]:t=>{t.pushInt(dh(t.popInt(),qh).tableId)},[ro.DB_FINDBYINDEX]:t=>{throw new Error('unimplemented')},[ro.DB_FIND_REFINE_WITH_COUNT]:t=>{throw new Error('unimplemented')},[ro.DB_FIND]:t=>{const e=2==t.popInt()?t.popString():t.popInt(),r=t.popInt(),i=r>>12&65535,n=r>>4&127;t.dbTable=dh(i,Yh),t.dbRow=-1,t.dbRowQuery=[];const s=fs.getInTable(i);for(let r=0;r{const e=2==t.popInt()?t.popString():t.popInt(),r=t.popInt(),i=r>>12&65535,n=r>>4&127,s=[],a=fs.getInTable(i);for(let t=0;t{throw new Error('unimplemented')}},il=rl;(gh=mh||={})[gh.CYCLE=0]='CYCLE',gh[gh.WORLD=1]='WORLD',gh[gh.CLIENT_IN=2]='CLIENT_IN',gh[gh.NPC=3]='NPC',gh[gh.PLAYER=4]='PLAYER',gh[gh.LOGOUT=5]='LOGOUT',gh[gh.LOGIN=6]='LOGIN',gh[gh.ZONE=7]='ZONE',gh[gh.CLIENT_OUT=8]='CLIENT_OUT',gh[gh.CLEANUP=9]='CLEANUP',gh[gh.BANDWIDTH_IN=10]='BANDWIDTH_IN',gh[gh.BANDWIDTH_OUT=11]='BANDWIDTH_OUT';var nl,sl,al=mh,ol={[ro.ERROR]:t=>{throw new Error(t.popString())},[ro.MAP_PRODUCTION]:t=>{t.pushInt(Ea.NODE_PRODUCTION?1:0)},[ro.MAP_LASTCLOCK]:t=>{t.pushInt(Lm.lastCycleStats[al.CYCLE])},[ro.MAP_LASTWORLD]:t=>{t.pushInt(Lm.lastCycleStats[al.WORLD])},[ro.MAP_LASTCLIENTIN]:t=>{t.pushInt(Lm.lastCycleStats[al.CLIENT_IN])},[ro.MAP_LASTNPC]:t=>{t.pushInt(Lm.lastCycleStats[al.NPC])},[ro.MAP_LASTPLAYER]:t=>{t.pushInt(Lm.lastCycleStats[al.PLAYER])},[ro.MAP_LASTLOGOUT]:t=>{t.pushInt(Lm.lastCycleStats[al.LOGOUT])},[ro.MAP_LASTLOGIN]:t=>{t.pushInt(Lm.lastCycleStats[al.LOGIN])},[ro.MAP_LASTZONE]:t=>{t.pushInt(Lm.lastCycleStats[al.ZONE])},[ro.MAP_LASTCLIENTOUT]:t=>{t.pushInt(Lm.lastCycleStats[al.CLIENT_OUT])},[ro.MAP_LASTCLEANUP]:t=>{t.pushInt(Lm.lastCycleStats[al.CLEANUP])},[ro.MAP_LASTBANDWIDTHIN]:t=>{t.pushInt(Lm.lastCycleStats[al.BANDWIDTH_IN])},[ro.MAP_LASTBANDWIDTHOUT]:t=>{t.pushInt(Lm.lastCycleStats[al.BANDWIDTH_OUT])}},hl={[ro.ENUM]:t=>{const[e,r,i,n]=t.popInts(4),s=dh(i,Ph);if(s.inputtype!==e||s.outputtype!==r)throw new Error(`Type validation error: ${s.debugname} key: ${n}. Expected input: ${e} got: ${s.inputtype}. Expected output: ${r} got: ${s.outputtype}`);const a=s.values.get(n);'string'==typeof a?t.pushString(a??s.defaultString):t.pushInt(a??s.defaultInt)},[ro.ENUM_GETOUTPUTCOUNT]:t=>{t.pushInt(dh(t.popInt(),Ph).values.size)}},ll=hl;(sl=nl||={})[sl.FOREVER=0]='FOREVER',sl[sl.RESPAWN=1]='RESPAWN',sl[sl.DESPAWN=2]='DESPAWN';var cl=nl;class ul{level;x;z;width;length;lifecycle;lifecycleTick=-1;lastLifecycleTick=-1;constructor(t,e,r,i,n,s){this.level=t,this.x=e,this.z=r,this.width=i,this.length=n,this.lifecycle=s}updateLifeCycle(t){return this.lifecycleTick===t&&this.lifecycle!==cl.FOREVER}checkLifeCycle(t){return this.lifecycle===cl.FOREVER||(this.lifecycle===cl.RESPAWN?this.lifecycleTickt)}setLifeCycle(t){this.lifecycleTick=t,this.lastLifecycleTick=Lm.currentTick}}class dl extends ul{resetEntity(t){}}class fl extends dl{type;count;receiverId=-1;reveal=-1;constructor(t,e,r,i,n,s){super(t,e,r,1,1,i),this.type=n,this.count=s}}var pl,ml,gl={[ro.INV_ALLSTOCK]:t=>{const e=dh(t.popInt(),Dh);t.pushInt(e.allstock?1:0)},[ro.INV_SIZE]:t=>{const e=dh(t.popInt(),Dh);t.pushInt(e.size)},[ro.INV_STOCKBASE]:t=>{const[e,r]=t.popInts(2),i=dh(e,Dh),n=dh(r,Bh);if(!i.stockobj||!i.stockcount)return void t.pushInt(-1);const s=i.stockobj.indexOf(n.id);t.pushInt(s>=0?i.stockcount[s]:-1)},[ro.INV_ADD]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3),n=dh(e,Dh),s=dh(r,Bh);if(dh(i,kh),!t.pointerGet(to[t.intOperand])&&n.protect&&n.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);if(!n.dummyinv&&0!==s.dummyitem)throw new Error(`dummyitem in non-dummyinv: ${s.debugname} -> ${n.debugname}`);const a=t.activePlayer,o=i-a.invAdd(n.id,s.id,i,!1);if(o>0)if(s.stackable&&1!==o)Lm.addObj(new fl(a.level,a.x,a.z,cl.DESPAWN,s.id,o),a.pid,200);else for(let t=0;t{const[e,r,i,n]=t.popInts(4);throw new Error('unimplemented')})),[ro.INV_CLEAR]:qa(Ja,(t=>{const e=dh(t.popInt(),Dh);if(!t.pointerGet(to[t.intOperand])&&e.protect&&e.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${e.debugname}`);t.activePlayer.invClear(e.id)})),[ro.INV_DEL]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3),n=dh(e,Dh),s=dh(r,Bh);if(dh(i,kh),!t.pointerGet(to[t.intOperand])&&n.protect&&n.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);t.activePlayer.invDel(n.id,s.id,i)})),[ro.INV_DELSLOT]:qa(Ja,(t=>{const[e,r]=t.popInts(2),i=dh(e,Dh);if(!t.pointerGet(to[t.intOperand])&&i.protect&&i.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${i.debugname}`);t.activePlayer.invGetSlot(i.id,r)&&t.activePlayer.invDelSlot(i.id,r)})),[ro.INV_DROPITEM]:qa(Ja,(t=>{const[e,r,i,n,s]=t.popInts(5),a=dh(e,Dh),o=dh(r,Ah),h=dh(i,Bh);if(dh(n,kh),dh(s,Eh),!t.pointerGet(to[t.intOperand])&&a.protect&&a.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);const l=t.activePlayer,c=l.invDel(a.id,h.id,n);if(0==c)return;l.playerLog('Dropped item from',a.debugname,h.debugname);const u=new fl(o.level,o.x,o.z,cl.DESPAWN,h.id,c);Lm.addObj(u,l.pid,s),t.activeObj=u,t.pointerAdd(Qa[t.intOperand])})),[ro.INV_DROPSLOT]:qa(Ja,(t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Dh);dh(n,Eh);const a=dh(r,Ah);if(!t.pointerGet(to[t.intOperand])&&s.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);const o=t.activePlayer.invGetSlot(s.id,i);if(!o)throw new Error('$slot is empty');const h=t.activePlayer,l=h.invDel(s.id,o.id,o.count,i);if(0===l)return;const c=Aa.get(o.id);if(h.playerLog('Dropped item from',s.debugname,c.debugname),c.stackable&&1!==l){const e=new fl(a.level,a.x,a.z,cl.DESPAWN,o.id,l);Lm.addObj(e,h.pid,n),t.activeObj=e,t.pointerAdd(Qa[t.intOperand])}else for(let e=0;e{const e=dh(t.popInt(),Dh);t.pushInt(t.activePlayer.invFreeSpace(e.id))})),[ro.INV_GETNUM]:qa(Ja,(t=>{const[e,r]=t.popInts(2),i=dh(e,Dh);t.pushInt(t.activePlayer.invGetSlot(i.id,r)?.count??0)})),[ro.INV_GETOBJ]:qa(Ja,(t=>{const[e,r]=t.popInts(2),i=dh(e,Dh);t.pushInt(t.activePlayer.invGetSlot(i.id,r)?.id??-1)})),[ro.INV_ITEMSPACE]:qa(Ja,(t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Dh),a=dh(r,Bh);if(dh(i,kh),n<0||n>s.size)throw new Error(`$count is out of range: ${i}`);t.pushInt(0===t.activePlayer.invItemSpace(s.id,a.id,i,n)?1:0)})),[ro.INV_ITEMSPACE2]:qa(Ja,(t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Dh),a=dh(r,Bh);dh(i,kh),t.pushInt(t.activePlayer.invItemSpace(s.id,a.id,i,n))})),[ro.INV_MOVEFROMSLOT]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3),n=dh(e,Dh),s=dh(r,Dh);if(!t.pointerGet(to[t.intOperand])&&n.protect&&n.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);if(!t.pointerGet(to[t.intOperand])&&s.protect&&n.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);const a=t.activePlayer,{overflow:o,fromObj:h}=a.invMoveFromSlot(n.id,s.id,i);if(o>0){if(Aa.get(h).stackable&&1!==o)Lm.addObj(new fl(a.level,a.x,a.z,cl.DESPAWN,h,o),a.pid,200);else for(let t=0;t{const[e,r,i,n]=t.popInts(4),s=dh(e,Dh),a=dh(r,Dh);if(!t.pointerGet(to[t.intOperand])&&s.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);if(!t.pointerGet(to[t.intOperand])&&a.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);t.activePlayer.invMoveToSlot(s.id,a.id,i,n)})),[ro.BOTH_MOVEINV]:qa(Ja,(t=>{const[e,r]=t.popInts(2),i=dh(e,Dh),n=dh(r,Dh),s=1==t.intOperand,a=s?t._activePlayer2:t._activePlayer,o=s?t._activePlayer:t._activePlayer2;if(!a||!o)throw new Error('player is null');if(!t.pointerGet(to[s?1:0])&&i.protect&&i.scope!==Zs.SCOPE_SHARED)throw new Error(`$from_inv requires protected access: ${i.debugname}`);if(!t.pointerGet(to[s?0:1])&&n.protect&&i.scope!==Zs.SCOPE_SHARED)throw new Error(`$to_inv requires protected access: ${n.debugname}`);const h=a.getInventory(e),l=o.getInventory(r);if(!h||!l)throw new Error('inv is null');for(let t=0;t{const[e,r,i,n]=t.popInts(4),s=dh(e,Dh),a=dh(r,Dh),o=dh(i,Bh);if(dh(n,kh),!t.pointerGet(to[t.intOperand])&&s.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);if(!t.pointerGet(to[t.intOperand])&&a.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);const h=t.activePlayer,l=h.invDel(s.id,o.id,n);if(0==l)return;const c=n-h.invAdd(a.id,o.id,l,!1);if(c>0)if(o.stackable&&1!==c)Lm.addObj(new fl(h.level,h.x,h.z,cl.DESPAWN,o.id,c),h.pid,200);else for(let t=0;t{const[e,r,i,n]=t.popInts(4),s=dh(e,Dh),a=dh(r,Dh),o=dh(i,Bh);if(dh(n,kh),!t.pointerGet(to[t.intOperand])&&s.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);if(!t.pointerGet(to[t.intOperand])&&a.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);const h=t.activePlayer,l=h.invDel(s.id,o.id,n);if(0==l)return;let c=o.id;-1===o.certtemplate&&o.certlink>=0&&(c=o.certlink);const u=n-h.invAdd(a.id,c,l,!1);u>0&&Lm.addObj(new fl(h.level,h.x,h.z,cl.DESPAWN,c,u),h.pid,200)})),[ro.INV_MOVEITEM_UNCERT]:qa(Ja,(t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Dh),a=dh(r,Dh),o=dh(i,Bh);if(dh(n,kh),!t.pointerGet(to[t.intOperand])&&s.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);if(!t.pointerGet(to[t.intOperand])&&a.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);const h=t.activePlayer,l=h.invDel(s.id,o.id,n);0!=l&&(o.certtemplate>=0&&o.certlink>=0?h.invAdd(a.id,o.certlink,l):h.invAdd(a.id,o.id,l))})),[ro.INV_SETSLOT]:qa(Ja,(t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Dh),a=dh(i,Bh);if(dh(n,kh),!t.pointerGet(to[t.intOperand])&&s.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);if(!s.dummyinv&&0!==a.dummyitem)throw new Error(`dummyitem in non-dummyinv: ${a.debugname} -> ${s.debugname}`);t.activePlayer.invSet(s.id,a.id,n,r)})),[ro.INV_TOTAL]:qa(Ja,(t=>{const[e,r]=t.popInts(2),i=dh(e,Dh);-1!==r?t.pushInt(t.activePlayer.invTotal(i.id,r)):t.pushInt(0)})),[ro.INV_TOTALCAT]:qa(Ja,(t=>{const[e,r]=t.popInts(2),i=dh(e,Dh),n=dh(r,Uh);t.pushInt(t.activePlayer.invTotalCat(i.id,n.id))})),[ro.INV_TRANSMIT]:qa(Ja,(t=>{const[e,r]=t.popInts(2),i=dh(e,Dh);dh(r,yh),t.activePlayer.invListenOnCom(i.id,r,t.activePlayer.uid)})),[ro.INVOTHER_TRANSMIT]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3);dh(e,yh);const n=dh(r,Dh);dh(i,yh),t.activePlayer.invListenOnCom(n.id,i,e)})),[ro.INV_STOPTRANSMIT]:qa(Ja,(t=>{const e=dh(t.popInt(),yh);t.activePlayer.invStopListenOnCom(e)})),[ro.BOTH_DROPSLOT]:qa(Ja,(t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Dh);dh(n,Eh);const a=dh(r,Ah),o=1==t.intOperand,h=o?t._activePlayer2:t._activePlayer,l=o?t._activePlayer:t._activePlayer2;if(!h||!l)throw new Error('player is null');if(!t.pointerGet(to[o?1:0])&&s.protect&&s.scope!==Zs.SCOPE_SHARED)throw new Error(`inv requires protected access: ${s.debugname}`);const c=h.invGetSlot(s.id,i);if(!c)throw new Error('$slot is empty');const u=h.invDel(s.id,c.id,c.count,i);if(0===u)return;const d=Aa.get(c.id);h.playerLog('Dropped item from',s.debugname,d.debugname),d.tradeable&&Lm.addObj(new fl(a.level,a.x,a.z,cl.DESPAWN,c.id,u),l.pid,n)})),[ro.INV_DROPALL]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3),n=dh(e,Dh);dh(i,Eh);const s=dh(r,Ah);if(!t.pointerGet(to[t.intOperand])&&n.protect&&n.scope!==Zs.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);const a=t.activePlayer.getInventory(n.id);if(a)for(let t=0;t{const[e,r]=t.popInts(2);t.pushInt(t.activePlayer.invTotalParam(e,r))})),[ro.INV_TOTALPARAM_STACK]:qa(Ja,(t=>{const[e,r]=t.popInts(2);t.pushInt(t.activePlayer.invTotalParamStack(e,r))}))},yl=gl;(ml=pl||={})[ml.ZONE=0]='ZONE',ml[ml.DISTANCE=1]='DISTANCE';var vl=pl;class bl{iterator;tick;constructor(t){this.iterator=this.generator(),this.tick=t}[Symbol.iterator](){return this.iterator}next(){return this.iterator.next()}}class _l extends bl{x;z;level;minX;maxX;minZ;maxZ;distance;checkVis;checkType;checkCategory;type;constructor(t,e,r,i,n,s,a,o,h){super(t);const l=oh.zone(r),c=oh.zone(i),u=1+n/8|0;this.x=r,this.z=i,this.level=e,this.maxX=l+u,this.minX=l-u,this.maxZ=c+u,this.minZ=c-u,this.distance=n,this.checkVis=s,this.checkType=a,this.checkCategory=o,this.type=h}*generator(){for(let t=this.maxX;t>=this.minX;t--){const e=t<<3;for(let t=this.maxZ;t>=this.minZ;t--){const r=t<<3;if(this.type===ks.PLAYER)for(const t of Lm.getZone(e,r,this.level).getAllPlayersSafe()){if(Lm.currentTick>this.tick)throw new Error('[HuntIterator] tried to use an old iterator. Create a new iterator instead.');oh.distanceToSW({x:this.x,z:this.z},t)>this.distance||(this.checkVis!==js.LINEOFSIGHT||Oo(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(this.checkVis!==js.LINEOFWALK||No(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(yield t)}else if(this.type===ks.NPC)for(const t of Lm.getZone(e,r,this.level).getAllNpcsSafe()){if(Lm.currentTick>this.tick)throw new Error('[HuntIterator] tried to use an old iterator. Create a new iterator instead.');if(-1!==this.checkType&&t.type!==this.checkType)continue;const e=fa.get(t.type);-1!==this.checkCategory&&e.category!==this.checkCategory||e.op&&e.op[1]&&(oh.distanceToSW({x:this.x,z:this.z},t)>this.distance||(this.checkVis!==js.LINEOFSIGHT||Oo(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(this.checkVis!==js.LINEOFWALK||No(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(yield t))}else if(this.type===ks.OBJ)for(const t of Lm.getZone(e,r,this.level).getAllObjsSafe()){if(Lm.currentTick>this.tick)throw new Error('[HuntIterator] tried to use an old iterator. Create a new iterator instead.');if(-1!==this.checkType&&t.type!==this.checkType)continue;const e=Aa.get(t.type);-1!==this.checkCategory&&e.category!==this.checkCategory||(oh.distanceToSW({x:this.x,z:this.z},t)>this.distance||(this.checkVis!==js.LINEOFSIGHT||Oo(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(this.checkVis!==js.LINEOFWALK||No(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(yield t))}else if(this.type===ks.SCENERY)for(const t of Lm.getZone(e,r,this.level).getAllLocsSafe()){if(Lm.currentTick>this.tick)throw new Error('[HuntIterator] tried to use an old iterator. Create a new iterator instead.');if(-1!==this.checkType&&t.type!==this.checkType)continue;const e=ta.get(t.type);-1!==this.checkCategory&&e.category!==this.checkCategory||(oh.distanceToSW({x:this.x,z:this.z},t)>this.distance||(this.checkVis!==js.LINEOFSIGHT||Oo(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(this.checkVis!==js.LINEOFWALK||No(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(yield t))}}}}}class wl extends bl{level;x;z;minX;maxX;minZ;maxZ;distance;checkVis;type;constructor(t,e,r,i,n,s,a){super(t);const o=oh.zone(r),h=oh.zone(i),l=1+n/8|0;this.x=r,this.z=i,this.level=e,this.maxX=o+l,this.minX=o-l,this.maxZ=h+l,this.minZ=h-l,this.distance=n,this.checkVis=s,this.type=a}*generator(){if(this.type===vl.ZONE)for(const t of Lm.getZone(this.x,this.z,this.level).getAllNpcsSafe()){if(Lm.currentTick>this.tick)throw new Error('[NpcIterator] tried to use an old iterator. Create a new iterator instead.');yield t}else if(this.type===vl.DISTANCE)for(let t=this.maxX;t>=this.minX;t--){const e=t<<3;for(let t=this.maxZ;t>=this.minZ;t--){const r=t<<3;for(const t of Lm.getZone(e,r,this.level).getAllNpcsSafe()){if(Lm.currentTick>this.tick)throw new Error('[NpcIterator] tried to use an old iterator. Create a new iterator instead.');oh.distanceToSW({x:this.x,z:this.z},t)>this.distance||(this.checkVis!==js.LINEOFSIGHT||Oo(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(this.checkVis!==js.LINEOFWALK||No(this.level,this.x,this.z,t.x,t.z,1,1,1,1))&&(yield t)}}}}}class El extends bl{level;x;z;constructor(t,e,r,i){super(t),this.level=e,this.x=r,this.z=i}*generator(){for(const t of Lm.getZone(this.x,this.z,this.level).getAllLocsSafe()){if(Lm.currentTick>this.tick)throw new Error('[LocIterator] tried to use an old iterator. Create a new iterator instead.');yield t}}}class Al extends dl{info;constructor(t,e,r,i,n,s,a,o,h){super(t,e,r,i,n,s),this.info=16383&a|(31&o)<<14|(3&h)<<19}get type(){return 16383&this.info}get shape(){return this.info>>14&31}get angle(){return this.info>>19&3}}var Sl,Tl,Ml={[ro.LOC_ADD]:t=>{const[e,r,i,n,s]=t.popInts(5),a=dh(e,Ah),o=dh(r,bh),h=dh(i,_h),l=dh(n,wh);dh(s,Eh);const c=new Al(a.level,a.x,a.z,o.width,o.length,cl.DESPAWN,o.id,l,h),u=Lm.getZone(a.x,a.z,a.level).getLocsUnsafe(oh.packZoneCoord(a.x,a.z));for(const t of u)if(t!==c&&t.angle===h&&t.shape===l){Lm.removeLoc(t,s);break}Lm.addLoc(c,s),t.activeLoc=c,t.pointerAdd(Xa[t.intOperand])},[ro.LOC_ANGLE]:qa(Xa,(t=>{t.pushInt(dh(t.activeLoc.angle,_h))})),[ro.LOC_ANIM]:qa(Xa,(t=>{const e=dh(t.popInt(),Hh);Lm.animLoc(t.activeLoc,e.id)})),[ro.LOC_CATEGORY]:qa(Xa,(t=>{t.pushInt(dh(t.activeLoc.type,bh).category)})),[ro.LOC_CHANGE]:qa(Xa,(t=>{const[e,r]=t.popInts(2),i=dh(e,bh);dh(r,Eh),Lm.removeLoc(t.activeLoc,r);const{level:n,x:s,z:a,angle:o,shape:h}=t.activeLoc,l=new Al(n,s,a,i.width,i.length,cl.DESPAWN,i.id,h,o),c=Lm.getZone(s,a,n).getLocsUnsafe(oh.packZoneCoord(s,a));for(const t of c)if(t!==l&&t.angle===o&&t.shape===h){Lm.removeLoc(t,r);break}Lm.addLoc(l,r),t.activeLoc=l,t.pointerAdd(Xa[t.intOperand])})),[ro.LOC_COORD]:qa(Xa,(t=>{const e=t.activeLoc;t.pushInt(oh.packCoord(e.level,e.x,e.z))})),[ro.LOC_DEL]:qa(Xa,(t=>{const e=dh(t.popInt(),Eh),{level:r,x:i,z:n,angle:s,shape:a}=t.activeLoc,o=Lm.getZone(i,n,r).getLocsUnsafe(oh.packZoneCoord(i,n));for(const r of o)if(r!==t.activeLoc&&r.angle===s&&r.shape===a){Lm.removeLoc(r,e);break}Lm.removeLoc(t.activeLoc,e)})),[ro.LOC_FIND]:t=>{const[e,r]=t.popInts(2),i=dh(r,bh),n=dh(e,Ah),s=Lm.getLoc(n.x,n.z,n.level,i.id);s?(t.activeLoc=s,t.pointerAdd(Xa[t.intOperand]),t.pushInt(1)):t.pushInt(0)},[ro.LOC_FINDALLZONE]:t=>{const e=dh(t.popInt(),Ah);t.locIterator=new El(Lm.currentTick,e.level,e.x,e.z),t._activeLoc&&(t._activeLoc2=t._activeLoc,t.pointerAdd(eo.ActiveLoc2))},[ro.LOC_FINDNEXT]:t=>{const e=t.locIterator?.next();e&&!e.done?(t.activeLoc=e.value,t.pointerAdd(Xa[t.intOperand]),t.pushInt(1)):t.pushInt(0)},[ro.LOC_PARAM]:qa(Xa,(t=>{const e=dh(t.popInt(),Sh),r=dh(t.activeLoc.type,bh);e.isString()?t.pushString(Xs(e.id,r,e.defaultString)):t.pushInt(Qs(e.id,r,e.defaultInt))})),[ro.LOC_TYPE]:qa(Xa,(t=>{t.pushInt(dh(t.activeLoc.type,bh).id)})),[ro.LOC_NAME]:qa(Xa,(t=>{t.pushString(dh(t.activeLoc.type,bh).name??'null')})),[ro.LOC_SHAPE]:qa(Xa,(t=>{t.pushInt(dh(t.activeLoc.shape,wh))}))},Il=Ml,Cl={[ro.LC_NAME]:t=>{const e=dh(t.popInt(),bh);t.pushString(e.name??e.debugname??'null')},[ro.LC_PARAM]:t=>{const[e,r]=t.popInts(2),i=dh(e,bh),n=dh(r,Sh);n.isString()?t.pushString(Xs(n.id,i,n.defaultString)):t.pushInt(Qs(n.id,i,n.defaultInt))},[ro.LC_CATEGORY]:t=>{t.pushInt(dh(t.popInt(),bh).category)},[ro.LC_DESC]:t=>{t.pushString(dh(t.popInt(),bh).desc??'null')},[ro.LC_DEBUGNAME]:t=>{t.pushString(dh(t.popInt(),bh).debugname??'null')},[ro.LC_WIDTH]:t=>{t.pushInt(dh(t.popInt(),bh).width)},[ro.LC_LENGTH]:t=>{t.pushInt(dh(t.popInt(),bh).length)}};(Tl=Sl||={})[Tl.PROC=0]='PROC',Tl[Tl.LABEL=1]='LABEL',Tl[Tl.DEBUGPROC=2]='DEBUGPROC',Tl[Tl.APNPC1=3]='APNPC1',Tl[Tl.APNPC2=4]='APNPC2',Tl[Tl.APNPC3=5]='APNPC3',Tl[Tl.APNPC4=6]='APNPC4',Tl[Tl.APNPC5=7]='APNPC5',Tl[Tl.APNPCU=8]='APNPCU',Tl[Tl.APNPCT=9]='APNPCT',Tl[Tl.OPNPC1=10]='OPNPC1',Tl[Tl.OPNPC2=11]='OPNPC2',Tl[Tl.OPNPC3=12]='OPNPC3',Tl[Tl.OPNPC4=13]='OPNPC4',Tl[Tl.OPNPC5=14]='OPNPC5',Tl[Tl.OPNPCU=15]='OPNPCU',Tl[Tl.OPNPCT=16]='OPNPCT',Tl[Tl.AI_APNPC1=17]='AI_APNPC1',Tl[Tl.AI_APNPC2=18]='AI_APNPC2',Tl[Tl.AI_APNPC3=19]='AI_APNPC3',Tl[Tl.AI_APNPC4=20]='AI_APNPC4',Tl[Tl.AI_APNPC5=21]='AI_APNPC5',Tl[Tl.AI_OPNPC1=24]='AI_OPNPC1',Tl[Tl.AI_OPNPC2=25]='AI_OPNPC2',Tl[Tl.AI_OPNPC3=26]='AI_OPNPC3',Tl[Tl.AI_OPNPC4=27]='AI_OPNPC4',Tl[Tl.AI_OPNPC5=28]='AI_OPNPC5',Tl[Tl.APOBJ1=31]='APOBJ1',Tl[Tl.APOBJ2=32]='APOBJ2',Tl[Tl.APOBJ3=33]='APOBJ3',Tl[Tl.APOBJ4=34]='APOBJ4',Tl[Tl.APOBJ5=35]='APOBJ5',Tl[Tl.APOBJU=36]='APOBJU',Tl[Tl.APOBJT=37]='APOBJT',Tl[Tl.OPOBJ1=38]='OPOBJ1',Tl[Tl.OPOBJ2=39]='OPOBJ2',Tl[Tl.OPOBJ3=40]='OPOBJ3',Tl[Tl.OPOBJ4=41]='OPOBJ4',Tl[Tl.OPOBJ5=42]='OPOBJ5',Tl[Tl.OPOBJU=43]='OPOBJU',Tl[Tl.OPOBJT=44]='OPOBJT',Tl[Tl.AI_APOBJ1=45]='AI_APOBJ1',Tl[Tl.AI_APOBJ2=46]='AI_APOBJ2',Tl[Tl.AI_APOBJ3=47]='AI_APOBJ3',Tl[Tl.AI_APOBJ4=48]='AI_APOBJ4',Tl[Tl.AI_APOBJ5=49]='AI_APOBJ5',Tl[Tl.AI_OPOBJ1=52]='AI_OPOBJ1',Tl[Tl.AI_OPOBJ2=53]='AI_OPOBJ2',Tl[Tl.AI_OPOBJ3=54]='AI_OPOBJ3',Tl[Tl.AI_OPOBJ4=55]='AI_OPOBJ4',Tl[Tl.AI_OPOBJ5=56]='AI_OPOBJ5',Tl[Tl.APLOC1=59]='APLOC1',Tl[Tl.APLOC2=60]='APLOC2',Tl[Tl.APLOC3=61]='APLOC3',Tl[Tl.APLOC4=62]='APLOC4',Tl[Tl.APLOC5=63]='APLOC5',Tl[Tl.APLOCU=64]='APLOCU',Tl[Tl.APLOCT=65]='APLOCT',Tl[Tl.OPLOC1=66]='OPLOC1',Tl[Tl.OPLOC2=67]='OPLOC2',Tl[Tl.OPLOC3=68]='OPLOC3',Tl[Tl.OPLOC4=69]='OPLOC4',Tl[Tl.OPLOC5=70]='OPLOC5',Tl[Tl.OPLOCU=71]='OPLOCU',Tl[Tl.OPLOCT=72]='OPLOCT',Tl[Tl.AI_APLOC1=73]='AI_APLOC1',Tl[Tl.AI_APLOC2=74]='AI_APLOC2',Tl[Tl.AI_APLOC3=75]='AI_APLOC3',Tl[Tl.AI_APLOC4=76]='AI_APLOC4',Tl[Tl.AI_APLOC5=77]='AI_APLOC5',Tl[Tl.AI_OPLOC1=80]='AI_OPLOC1',Tl[Tl.AI_OPLOC2=81]='AI_OPLOC2',Tl[Tl.AI_OPLOC3=82]='AI_OPLOC3',Tl[Tl.AI_OPLOC4=83]='AI_OPLOC4',Tl[Tl.AI_OPLOC5=84]='AI_OPLOC5',Tl[Tl.APPLAYER1=87]='APPLAYER1',Tl[Tl.APPLAYER2=88]='APPLAYER2',Tl[Tl.APPLAYER3=89]='APPLAYER3',Tl[Tl.APPLAYER4=90]='APPLAYER4',Tl[Tl.APPLAYER5=91]='APPLAYER5',Tl[Tl.APPLAYERU=92]='APPLAYERU',Tl[Tl.APPLAYERT=93]='APPLAYERT',Tl[Tl.OPPLAYER1=94]='OPPLAYER1',Tl[Tl.OPPLAYER2=95]='OPPLAYER2',Tl[Tl.OPPLAYER3=96]='OPPLAYER3',Tl[Tl.OPPLAYER4=97]='OPPLAYER4',Tl[Tl.OPPLAYER5=98]='OPPLAYER5',Tl[Tl.OPPLAYERU=99]='OPPLAYERU',Tl[Tl.OPPLAYERT=100]='OPPLAYERT',Tl[Tl.AI_APPLAYER1=101]='AI_APPLAYER1',Tl[Tl.AI_APPLAYER2=102]='AI_APPLAYER2',Tl[Tl.AI_APPLAYER3=103]='AI_APPLAYER3',Tl[Tl.AI_APPLAYER4=104]='AI_APPLAYER4',Tl[Tl.AI_APPLAYER5=105]='AI_APPLAYER5',Tl[Tl.AI_OPPLAYER1=108]='AI_OPPLAYER1',Tl[Tl.AI_OPPLAYER2=109]='AI_OPPLAYER2',Tl[Tl.AI_OPPLAYER3=110]='AI_OPPLAYER3',Tl[Tl.AI_OPPLAYER4=111]='AI_OPPLAYER4',Tl[Tl.AI_OPPLAYER5=112]='AI_OPPLAYER5',Tl[Tl.QUEUE=116]='QUEUE',Tl[Tl.AI_QUEUE1=117]='AI_QUEUE1',Tl[Tl.AI_QUEUE2=118]='AI_QUEUE2',Tl[Tl.AI_QUEUE3=119]='AI_QUEUE3',Tl[Tl.AI_QUEUE4=120]='AI_QUEUE4',Tl[Tl.AI_QUEUE5=121]='AI_QUEUE5',Tl[Tl.AI_QUEUE6=122]='AI_QUEUE6',Tl[Tl.AI_QUEUE7=123]='AI_QUEUE7',Tl[Tl.AI_QUEUE8=124]='AI_QUEUE8',Tl[Tl.AI_QUEUE9=125]='AI_QUEUE9',Tl[Tl.AI_QUEUE10=126]='AI_QUEUE10',Tl[Tl.AI_QUEUE11=127]='AI_QUEUE11',Tl[Tl.AI_QUEUE12=128]='AI_QUEUE12',Tl[Tl.AI_QUEUE13=129]='AI_QUEUE13',Tl[Tl.AI_QUEUE14=130]='AI_QUEUE14',Tl[Tl.AI_QUEUE15=131]='AI_QUEUE15',Tl[Tl.AI_QUEUE16=132]='AI_QUEUE16',Tl[Tl.AI_QUEUE17=133]='AI_QUEUE17',Tl[Tl.AI_QUEUE18=134]='AI_QUEUE18',Tl[Tl.AI_QUEUE19=135]='AI_QUEUE19',Tl[Tl.AI_QUEUE20=136]='AI_QUEUE20',Tl[Tl.SOFTTIMER=137]='SOFTTIMER',Tl[Tl.TIMER=138]='TIMER',Tl[Tl.AI_TIMER=139]='AI_TIMER',Tl[Tl.OPHELD1=140]='OPHELD1',Tl[Tl.OPHELD2=141]='OPHELD2',Tl[Tl.OPHELD3=142]='OPHELD3',Tl[Tl.OPHELD4=143]='OPHELD4',Tl[Tl.OPHELD5=144]='OPHELD5',Tl[Tl.OPHELDU=145]='OPHELDU',Tl[Tl.OPHELDT=146]='OPHELDT',Tl[Tl.IF_BUTTON=147]='IF_BUTTON',Tl[Tl.INV_BUTTON1=148]='INV_BUTTON1',Tl[Tl.INV_BUTTON2=149]='INV_BUTTON2',Tl[Tl.INV_BUTTON3=150]='INV_BUTTON3',Tl[Tl.INV_BUTTON4=151]='INV_BUTTON4',Tl[Tl.INV_BUTTON5=152]='INV_BUTTON5',Tl[Tl.INV_BUTTOND=153]='INV_BUTTOND',Tl[Tl.IF_CLOSE=154]='IF_CLOSE',Tl[Tl.LOGIN=155]='LOGIN',Tl[Tl.LOGOUT=156]='LOGOUT',Tl[Tl.TUTORIAL_CLICKSIDE=157]='TUTORIAL_CLICKSIDE',Tl[Tl.MOVE=158]='MOVE',Tl[Tl.WALKTRIGGER=159]='WALKTRIGGER',Tl[Tl.AI_WALKTRIGGER=160]='AI_WALKTRIGGER',Tl[Tl.LEVELUP=161]='LEVELUP',(t=>{t.toString=function(e){return t[e].toLowerCase()}})(Sl||={});var Ol,Nl,Ll=Sl;(Nl=Ol||={})[Nl.SCRIPT=0]='SCRIPT',Nl[Nl.ENGINE=1]='ENGINE';var Rl=Ol,Pl={[ro.NPC_FINDUID]:t=>{const e=t.popInt(),r=65535&e,i=e>>16&65535,n=Lm.getNpc(r);n&&n.type===i?(t.activeNpc=n,t.pointerAdd($a[t.intOperand]),t.pushInt(1)):t.pushInt(0)},[ro.NPC_ADD]:t=>{const[e,r,i]=t.popInts(3),n=dh(e,Ah),s=dh(r,Th);dh(i,Eh);const a=new hm(n.level,n.x,n.z,s.size,s.size,cl.DESPAWN,Lm.getNextNid(),s.id,s.moverestrict,s.blockwalk);Lm.addNpc(a,i),t.activeNpc=a,t.pointerAdd($a[t.intOperand])},[ro.NPC_ANIM]:qa($a,(t=>{const e=dh(t.popInt(),yh),r=t.popInt();t.activeNpc.playAnimation(r,e)})),[ro.NPC_BASESTAT]:qa($a,(t=>{const e=dh(t.popInt(),Mh);t.pushInt(t.activeNpc.baseLevels[e])})),[ro.NPC_CATEGORY]:qa($a,(t=>{t.pushInt(dh(t.activeNpc.type,Th).category)})),[ro.NPC_COORD]:qa($a,(t=>{const e=t.activeNpc;t.pushInt(oh.packCoord(e.level,e.x,e.z))})),[ro.NPC_DEL]:qa($a,(t=>{Lm.removeNpc(t.activeNpc,dh(t.activeNpc.type,Th).respawnrate)})),[ro.NPC_DELAY]:qa($a,(t=>{t.activeNpc.delay=Lm.currentTick+dh(t.popInt(),yh)+1,t.execution=ho.NPC_SUSPENDED})),[ro.NPC_FACESQUARE]:qa($a,(t=>{const e=dh(t.popInt(),Ah);t.activeNpc.faceSquare(e.x,e.z)})),[ro.NPC_FINDEXACT]:t=>{const[e,r]=t.popInts(2),i=dh(e,Ah),n=dh(r,Th);t.npcIterator=new wl(Lm.currentTick,i.level,i.x,i.z,0,0,vl.ZONE);for(const e of t.npcIterator)if(e.type===n.id&&e.x===i.x&&e.level===i.level&&e.z===i.z)return t.activeNpc=e,t.pointerAdd($a[t.intOperand]),void t.pushInt(1);t.pushInt(0)},[ro.NPC_FINDHERO]:qa($a,(t=>{const e=t.activeNpc.findHero();if(-1===e)return void t.pushInt(0);const r=Lm.getPlayerByUid(e);r?(t.activePlayer=r,t.pointerAdd(eo.ActivePlayer),t.pushInt(1)):t.pushInt(0)})),[ro.NPC_PARAM]:qa($a,(t=>{const e=dh(t.popInt(),Sh),r=dh(t.activeNpc.type,Th);e.isString()?t.pushString(Xs(e.id,r,e.defaultString)):t.pushInt(Qs(e.id,r,e.defaultInt))})),[ro.NPC_QUEUE]:qa($a,(t=>{const e=dh(t.popInt(),yh),r=t.popInt(),i=dh(t.popInt(),Ch),n=dh(t.activeNpc.type,Th),s=no.getByTrigger(Ll.AI_QUEUE1+i-1,n.id,n.category);s&&t.activeNpc.enqueueScript(s,e,r)})),[ro.NPC_RANGE]:qa($a,(t=>{const e=dh(t.popInt(),Ah),r=t.activeNpc;e.level!==r.level?t.pushInt(-1):t.pushInt(oh.distanceTo(r,{x:e.x,z:e.z,width:1,length:1}))})),[ro.NPC_SAY]:qa($a,(t=>{t.activeNpc.say(t.popString())})),[ro.NPC_SETHUNT]:qa($a,(t=>{t.activeNpc.huntrange=dh(t.popInt(),yh)})),[ro.NPC_SETHUNTMODE]:qa($a,(t=>{t.activeNpc.huntMode=dh(t.popInt(),Oh).id})),[ro.NPC_SETMODE]:qa($a,(t=>{const e=dh(t.popInt(),Nh);if(t.activeNpc.clearWaypoints(),e===Vs.NULL||e===Vs.NONE||e===Vs.WANDER||e===Vs.PATROL)return t.activeNpc.clearInteraction(),void(t.activeNpc.targetOp=e);let r;t.activeNpc.targetOp=e,r=e>=Vs.OPNPC1?t._activeNpc2:e>=Vs.OPOBJ1?t._activeObj:e>=Vs.OPLOC1?t._activeLoc:t._activePlayer,r?r instanceof hm||r instanceof fl||r instanceof Al?t.activeNpc.setInteraction(Rl.SCRIPT,r,e,{type:r.type,com:-1}):t.activeNpc.setInteraction(Rl.SCRIPT,r,e):t.activeNpc.noMode()})),[ro.NPC_STAT]:qa($a,(t=>{const e=dh(t.popInt(),Mh);t.pushInt(t.activeNpc.levels[e])})),[ro.NPC_STATHEAL]:qa($a,(t=>{const[e,r,i]=t.popInts(3);dh(e,Mh),dh(r,yh),dh(i,yh);const n=t.activeNpc,s=n.baseLevels[e],a=n.levels[e],o=a+(r+a*i/100);n.levels[e]=Math.min(o,s),0===e&&n.levels[e]===n.baseLevels[e]&&n.resetHeroPoints()})),[ro.NPC_TYPE]:qa($a,(t=>{t.pushInt(dh(t.activeNpc.type,Th).id)})),[ro.NPC_DAMAGE]:qa($a,(t=>{const e=dh(t.popInt(),yh),r=dh(t.popInt(),Lh);t.activeNpc.applyDamage(e,r)})),[ro.NPC_NAME]:qa($a,(t=>{t.pushString(dh(t.activeNpc.type,Th).name??'null')})),[ro.NPC_UID]:qa($a,(t=>{t.pushInt(t.activeNpc.uid)})),[ro.NPC_SETTIMER]:qa($a,(t=>{t.activeNpc.setTimer(dh(t.popInt(),yh))})),[ro.SPOTANIM_NPC]:qa($a,(t=>{const e=dh(t.popInt(),yh),r=dh(t.popInt(),yh),i=dh(t.popInt(),Rh);t.activeNpc.spotanim(i.id,r,e)})),[ro.NPC_FIND]:t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Ah),a=dh(r,Th);dh(i,yh);const o=dh(n,Fh);let h,l=i;const c=new wl(Lm.currentTick,s.level,s.x,s.z,i,o,vl.DISTANCE);for(const t of c)if(t&&t.type===a.id){const e=oh.distanceToSW(s,t);e<=l&&(h=t,l=e)}h?(t.activeNpc=h,t.pointerAdd($a[t.intOperand]),t.pushInt(1)):t.pushInt(0)},[ro.NPC_FINDALLANY]:t=>{const[e,r,i]=t.popInts(3),n=dh(e,Ah);dh(r,yh);const s=dh(i,Fh);t.npcIterator=new wl(Lm.currentTick,n.level,n.x,n.z,r,s,vl.DISTANCE),t._activeNpc&&(t._activeNpc2=t._activeNpc,t.pointerAdd(eo.ActiveNpc2))},[ro.NPC_FINDALLZONE]:t=>{const e=dh(t.popInt(),Ah);t.npcIterator=new wl(Lm.currentTick,e.level,e.x,e.z,0,0,vl.ZONE),t._activeNpc&&(t._activeNpc2=t._activeNpc,t.pointerAdd(eo.ActiveNpc2))},[ro.NPC_FINDNEXT]:t=>{const e=t.npcIterator?.next();e&&!e.done?(t.activeNpc=e.value,t.pointerAdd($a[t.intOperand]),t.pushInt(1)):t.pushInt(0)},[ro.NPC_TELE]:qa($a,(t=>{const e=dh(t.popInt(),Ah);t.activeNpc.teleport(e.x,e.z,e.level)})),[ro.NPC_WALK]:qa($a,(t=>{const e=dh(t.popInt(),Ah);t.activeNpc.queueWaypoint(e.x,e.z)})),[ro.NPC_CHANGETYPE]:qa($a,(t=>{t.activeNpc.changeType(dh(t.popInt(),Th).id)})),[ro.NPC_GETMODE]:qa($a,(t=>{t.pushInt(t.activeNpc.targetOp)})),[ro.NPC_HEROPOINTS]:qa([eo.ActivePlayer,...$a],(t=>{t.activeNpc.addHero(t.activePlayer.uid,dh(t.popInt(),yh))})),[ro.NPC_WALKTRIGGER]:qa($a,(t=>{const[e,r]=t.popInts(2);dh(e,Ch),t.activeNpc.walktrigger=e-1,t.activeNpc.walktriggerArg=r})),[ro.NPC_STATADD]:qa($a,(t=>{const[e,r,i]=t.popInts(3);dh(e,Mh),dh(r,yh),dh(i,yh);const n=t.activeNpc,s=n.levels[e],a=s+(r+s*i/100);n.levels[e]=Math.min(a,255),0===e&&n.levels[e]>=n.baseLevels[e]&&n.resetHeroPoints()})),[ro.NPC_STATSUB]:qa($a,(t=>{const[e,r,i]=t.popInts(3);dh(e,Mh),dh(r,yh),dh(i,yh);const n=t.activeNpc,s=n.levels[e],a=s-(r+s*i/100);n.levels[e]=Math.max(a,0)})),[ro.NPC_ATTACKRANGE]:qa($a,(t=>{t.pushInt(dh(t.activeNpc.type,Th).attackrange)}))},Bl={[ro.NC_NAME]:t=>{const e=dh(t.popInt(),Th);t.pushString(e.name??e.debugname??'null')},[ro.NC_PARAM]:t=>{const[e,r]=t.popInts(2),i=dh(e,Th),n=dh(r,Sh);n.isString()?t.pushString(Xs(r,i,n.defaultString)):t.pushInt(Qs(r,i,n.defaultInt))},[ro.NC_CATEGORY]:t=>{t.pushInt(dh(t.popInt(),Th).category)},[ro.NC_DESC]:t=>{t.pushString(dh(t.popInt(),Th).desc??'null')},[ro.NC_DEBUGNAME]:t=>{t.pushString(dh(t.popInt(),Th).debugname??'null')},[ro.NC_OP]:t=>{const[e,r]=t.popInts(2),i=dh(e,Th);dh(r,yh),i.op?t.pushString(i.op[r-1]??''):t.pushString('')}};class kl{static _sin=new Int32Array(16384);static _cos=new Int32Array(16384);static{const t=.0003834951969714103;for(let e=0;e<16384;e++)this._sin[e]=16384*Math.sin(e*t)|0,this._cos[e]=16384*Math.cos(e*t)|0}static radians(t){return(16383&t)/16384*6.283185307179586}static atan2(t,e){return 16383&Math.round(2607.5945876176133*Math.atan2(t,e))}static sin(t){return this._sin[16383&t]}static cos(t){return this._cos[16383&t]}}var Dl={[ro.ADD]:t=>{const e=t.popInt(),r=t.popInt();t.pushInt(r+e)},[ro.SUB]:t=>{const e=t.popInt(),r=t.popInt();t.pushInt(r-e)},[ro.MULTIPLY]:t=>{const e=t.popInt(),r=t.popInt();t.pushInt(r*e)},[ro.DIVIDE]:t=>{const e=t.popInt(),r=t.popInt();t.pushInt(r/e)},[ro.RANDOM]:t=>{const e=t.popInt();t.pushInt(Math.random()*e)},[ro.RANDOMINC]:t=>{const e=t.popInt();t.pushInt(Math.random()*(e+1))},[ro.INTERPOLATE]:t=>{const[e,r,i,n,s]=t.popInts(5),a=Math.floor((r-e)/(n-i))*(s-i)+e;t.pushInt(a)},[ro.ADDPERCENT]:t=>{const[e,r]=t.popInts(2);t.pushInt(e*r/100+e|0)},[ro.SETBIT]:t=>{const[e,r]=t.popInts(2);t.pushInt(e|1<{const[e,r]=t.popInts(2);t.pushInt(e&~(1<{const[e,r]=t.popInts(2);t.pushInt(e&1<{const[e,r]=t.popInts(2);t.pushInt(e%r)},[ro.POW]:t=>{const[e,r]=t.popInts(2);t.pushInt(Math.pow(e,r))},[ro.INVPOW]:t=>{const[e,r]=t.popInts(2);if(0===e||0===r)t.pushInt(0);else switch(r){case 1:return void t.pushInt(e);case 2:return void t.pushInt(Math.sqrt(e));case 3:return void t.pushInt(Math.cbrt(e));case 4:return void t.pushInt(Math.sqrt(Math.sqrt(e)));default:return void t.pushInt(Math.pow(e,1/r))}},[ro.AND]:t=>{const[e,r]=t.popInts(2);t.pushInt(e&r)},[ro.OR]:t=>{const[e,r]=t.popInts(2);t.pushInt(e|r)},[ro.MIN]:t=>{const[e,r]=t.popInts(2);t.pushInt(Math.min(e,r))},[ro.MAX]:t=>{const[e,r]=t.popInts(2);t.pushInt(Math.max(e,r))},[ro.SCALE]:t=>{const[e,r,i]=t.popInts(3);t.pushInt(e*i/r)},[ro.BITCOUNT]:t=>{var e;t.pushInt((e=t.popInt(),16843009*((e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135)>>24))},[ro.TOGGLEBIT]:t=>{const[e,r]=t.popInts(2);t.pushInt(e^1<{const[e,r,i]=t.popInts(3);t.pushInt(function(t,e,r){return t|oo[r-e+1]<{const[e,r,i]=t.popInts(3);t.pushInt(ao(e,r,i))},[ro.GETBIT_RANGE]:t=>{const[e,r,i]=t.popInts(3),n=31-i;t.pushInt(e<>>r+n)},[ro.SETBIT_RANGE_TOINT]:t=>{const[e,r,i,n]=t.popInts(4),s=ao(e,i,n),a=oo[n-i+1];let o=r;r>a&&(o=a),t.pushInt(s|o<{t.pushInt(kl.sin(t.popInt()))},[ro.COS_DEG]:t=>{t.pushInt(kl.cos(t.popInt()))},[ro.ATAN2_DEG]:t=>{t.pushInt(kl.atan2(t.popInt(),t.popInt()))},[ro.ABS]:t=>{t.pushInt(Math.abs(t.popInt()))}},Ul=Dl,xl={[ro.OBJ_ADD]:t=>{const[e,r,i,n]=t.popInts(4);if(-1===r||-1===i)return;const s=dh(r,Bh);dh(n,Eh);const a=dh(e,Ah);if(dh(i,kh),0!==s.dummyitem)throw new Error(`attempted to add dummy item: ${s.debugname}`);if(!s.members||Ea.NODE_MEMBERS)if(s.stackable&&1!==i){const e=new fl(a.level,a.x,a.z,cl.DESPAWN,r,i);Lm.addObj(e,t.activePlayer.pid,n),t.activeObj=e,t.pointerAdd(Qa[t.intOperand])}else for(let e=0;e{const[e,r,i,n]=t.popInts(4);if(-1===r||-1===i)return;const s=dh(r,Bh);dh(n,Eh);const a=dh(e,Ah);if(dh(i,kh),0!==s.dummyitem)throw new Error(`attempted to add dummy item: ${s.debugname}`);if(!s.members||Ea.NODE_MEMBERS)if(s.stackable&&1!==i){const e=new fl(a.level,a.x,a.z,cl.DESPAWN,r,i);Lm.addObj(e,-1,n),t.activeObj=e,t.pointerAdd(Qa[t.intOperand])}else for(let e=0;e{const e=dh(t.popInt(),Sh),r=dh(t.activeObj.type,Bh);e.isString()?t.pushString(Xs(e.id,r,e.defaultString)):t.pushInt(Qs(e.id,r,e.defaultInt))},[ro.OBJ_NAME]:t=>{const e=dh(t.activeObj.type,Bh);t.pushString(e.name??e.debugname??'null')},[ro.OBJ_DEL]:t=>{const e=Aa.get(t.activeObj.type).respawnrate;t.pointerGet(Ja[t.intOperand]),Lm.removeObj(t.activeObj,e)},[ro.OBJ_COUNT]:t=>{t.pushInt(dh(t.activeObj.count,kh))},[ro.OBJ_TYPE]:t=>{t.pushInt(dh(t.activeObj.type,Bh).id)},[ro.OBJ_TAKEITEM]:t=>{const e=dh(t.popInt(),Dh),r=t.activeObj,i=Aa.get(r.type),n=Lm.getZone(r.x,r.z,r.level);for(const s of n.getObjsSafe(oh.packZoneCoord(r.x,r.z)))if(s.type===r.type&&s.count===r.count&&(-1===s.receiverId||s.receiverId===t.activePlayer.pid)){if(t.activePlayer.playerLog('Picked up item',i.debugname),t.activePlayer.invAdd(e.id,r.type,r.count),r.lifecycle===cl.RESPAWN){Lm.removeObj(r,i.respawnrate);break}if(r.lifecycle===cl.DESPAWN){Lm.removeObj(r,0);break}}},[ro.OBJ_COORD]:t=>{const e=t.activeObj;t.pushInt(oh.packCoord(e.level,e.x,e.z))}},Fl=xl,Hl={[ro.OC_NAME]:t=>{const e=dh(t.popInt(),Bh);t.pushString(e.name??e.debugname??'null')},[ro.OC_PARAM]:t=>{const[e,r]=t.popInts(2),i=dh(e,Bh),n=dh(r,Sh);n.isString()?t.pushString(Xs(n.id,i,n.defaultString)):t.pushInt(Qs(n.id,i,n.defaultInt))},[ro.OC_CATEGORY]:t=>{t.pushInt(dh(t.popInt(),Bh).category)},[ro.OC_DESC]:t=>{t.pushString(dh(t.popInt(),Bh).desc??'null')},[ro.OC_MEMBERS]:t=>{t.pushInt(dh(t.popInt(),Bh).members?1:0)},[ro.OC_WEIGHT]:t=>{t.pushInt(dh(t.popInt(),Bh).weight)},[ro.OC_WEARPOS]:t=>{t.pushInt(dh(t.popInt(),Bh).wearpos)},[ro.OC_WEARPOS2]:t=>{t.pushInt(dh(t.popInt(),Bh).wearpos2)},[ro.OC_WEARPOS3]:t=>{t.pushInt(dh(t.popInt(),Bh).wearpos3)},[ro.OC_COST]:t=>{t.pushInt(dh(t.popInt(),Bh).cost)},[ro.OC_TRADEABLE]:t=>{t.pushInt(dh(t.popInt(),Bh).tradeable?1:0)},[ro.OC_DEBUGNAME]:t=>{t.pushString(dh(t.popInt(),Bh).debugname??'null')},[ro.OC_CERT]:t=>{const e=dh(t.popInt(),Bh);-1==e.certtemplate&&e.certlink>=0?t.pushInt(e.certlink):t.pushInt(e.id)},[ro.OC_UNCERT]:t=>{const e=dh(t.popInt(),Bh);e.certtemplate>=0&&e.certlink>=0?t.pushInt(e.certlink):t.pushInt(e.id)},[ro.OC_STACKABLE]:t=>{t.pushInt(dh(t.popInt(),Bh).stackable?1:0)}};class jl extends rs{type;script;args;delay;lastInt=0;constructor(t,e,r,i){super(),this.type=t,this.script=e,this.args=r,this.delay=i}}class Vl extends rs{script;delay;constructor(t,e){super(),this.script=t,this.delay=e}}var Gl,zl,{default:Wl}=()=>({});class Kl{id;length;static all=[];static byId=[];static IF_OPENCHATMODAL=new Kl(14,2);static IF_OPENMAINSIDEMODAL=new Kl(28,4);static IF_CLOSE=new Kl(129,0);static IF_OPENSIDEOVERLAY=new Kl(167,3);static IF_OPENMAINMODAL=new Kl(168,2);static IF_OPENSIDEMODAL=new Kl(195,2);static IF_SETCOLOUR=new Kl(2,4);static IF_SETHIDE=new Kl(26,3);static IF_SETOBJECT=new Kl(46,6);static IF_SHOWSIDE=new Kl(84,1);static IF_SETMODEL=new Kl(87,4);static IF_SETRECOL=new Kl(103,6);static IF_SETANIM=new Kl(146,4);static IF_SETPLAYERHEAD=new Kl(197,2);static IF_SETTEXT=new Kl(201,-2);static IF_SETNPCHEAD=new Kl(204,4);static IF_SETPOSITION=new Kl(209,6);static TUTORIAL_FLASHSIDE=new Kl(126,1);static TUTORIAL_OPENCHAT=new Kl(185,2);static UPDATE_INV_STOP_TRANSMIT=new Kl(15,2);static UPDATE_INV_FULL=new Kl(98,-2);static UPDATE_INV_PARTIAL=new Kl(213,-2);static CAM_LOOKAT=new Kl(74,6);static CAM_SHAKE=new Kl(13,4);static CAM_MOVETO=new Kl(3,6);static CAM_RESET=new Kl(239,0);static NPC_INFO=new Kl(1,-2);static PLAYER_INFO=new Kl(184,-2);static FINISH_TRACKING=new Kl(133,0);static ENABLE_TRACKING=new Kl(226,0);static MESSAGE_GAME=new Kl(4,-1);static UPDATE_IGNORELIST=new Kl(21,-2);static CHAT_FILTER_SETTINGS=new Kl(32,3);static MESSAGE_PRIVATE=new Kl(41,-1);static UPDATE_FRIENDLIST=new Kl(152,9);static UNSET_MAP_FLAG=new Kl(19,0);static UPDATE_RUNWEIGHT=new Kl(22,2);static HINT_ARROW=new Kl(25,6);static UPDATE_REBOOT_TIMER=new Kl(43,2);static UPDATE_STAT=new Kl(44,6);static UPDATE_RUNENERGY=new Kl(68,1);static RESET_ANIMS=new Kl(136,0);static UPDATE_UID192=new Kl(139,2);static LAST_LOGIN_INFO=new Kl(140,9);static LOGOUT=new Kl(142,0);static P_COUNTDIALOG=new Kl(243,0);static SET_MULTIWAY=new Kl(254,1);static DATA_LOC_DONE=new Kl(20,2);static DATA_LAND_DONE=new Kl(80,2);static DATA_LAND=new Kl(132,-2);static DATA_LOC=new Kl(220,-2);static REBUILD_NORMAL=new Kl(237,-2);static VARP_SMALL=new Kl(150,3);static VARP_LARGE=new Kl(175,6);static RESET_CLIENT_VARCACHE=new Kl(193,0);static SYNTH_SOUND=new Kl(12,5);static MIDI_SONG=new Kl(54,-1);static MIDI_JINGLE=new Kl(212,-2);static UPDATE_ZONE_PARTIAL_FOLLOWS=new Kl(7,2);static UPDATE_ZONE_FULL_FOLLOWS=new Kl(135,2);static UPDATE_ZONE_PARTIAL_ENCLOSED=new Kl(162,-2);constructor(t,e){this.id=t,this.length=e,Kl.all.push(this),Kl.byId[t]=this}}(zl=Gl||={})[zl.STATIONARY=0]='STATIONARY',zl[zl.CRAWL=1]='CRAWL',zl[zl.WALK=2]='WALK',zl[zl.RUN=3]='RUN',zl[zl.INSTANT=4]='INSTANT';var ql,Yl,Zl=Gl;(Yl=ql||={})[Yl.SMART=0]='SMART',Yl[Yl.NAIVE=1]='NAIVE',Yl[Yl.FLY=2]='FLY';var $l=ql;class Xl extends ul{moveRestrict;blockWalk;moveStrategy;coordmask;entitymask;moveSpeed=Zl.INSTANT;walkDir=-1;runDir=-1;waypointIndex=-1;waypoints=new Int32Array(25);lastX=-1;lastZ=-1;lastLevel=-1;tele=!1;jump=!1;lastStepX=-1;lastStepZ=-1;stepsTaken=0;lastInt=-1;lastCrawl=!1;walktrigger=-1;walktriggerArg=0;interacted=!1;repathed=!1;target=null;targetOp=-1;targetSubject={type:-1,com:-1};targetX=-1;targetZ=-1;apRange=10;apRangeCalled=!1;alreadyFacedEntity=!1;mask=0;exactStartX=-1;exactStartZ=-1;exactEndX=-1;exactEndZ=-1;exactMoveStart=-1;exactMoveEnd=-1;exactMoveDirection=-1;faceX=-1;faceZ=-1;orientationX=-1;orientationZ=-1;faceEntity=-1;damageTaken=-1;damageType=-1;animId=-1;animDelay=-1;chat=null;graphicId=-1;graphicHeight=-1;graphicDelay=-1;constructor(t,e,r,i,n,s,a,o,h,l,c){super(t,e,r,i,n,s),this.moveRestrict=a,this.blockWalk=o,this.moveStrategy=h,this.coordmask=l,this.entitymask=c,this.lastStepX=e-1,this.lastStepZ=r}processMovement(){return!(!this.hasWaypoints()||this.moveSpeed===Zl.STATIONARY||this.moveSpeed===Zl.INSTANT)&&(this.moveSpeed===Zl.CRAWL?(this.lastCrawl=!this.lastCrawl,this.lastCrawl&&-1===this.walkDir&&(this.walkDir=this.validateAndAdvanceStep()),!0):(-1===this.walkDir&&(this.walkDir=this.validateAndAdvanceStep(),this.moveSpeed===Zl.RUN&&-1!==this.walkDir&&-1===this.runDir&&(this.runDir=this.validateAndAdvanceStep())),!0))}refreshZonePresence(t,e,r){if(this.x!=t||this.z!==e||this.level!==r){switch(this.blockWalk){case ha.NPC:Lm.gameMap.changeNpcCollision(this.width,t,e,r,!1),Lm.gameMap.changeNpcCollision(this.width,this.x,this.z,this.level,!0);break;case ha.ALL:Lm.gameMap.changeNpcCollision(this.width,t,e,r,!1),Lm.gameMap.changeNpcCollision(this.width,this.x,this.z,this.level,!0),Lm.gameMap.changePlayerCollision(this.width,t,e,r,!1),Lm.gameMap.changePlayerCollision(this.width,this.x,this.z,this.level,!0)}this.lastStepX=t,this.lastStepZ=e}oh.zone(t)===oh.zone(this.x)&&oh.zone(e)===oh.zone(this.z)&&r==this.level||(Lm.getZone(t,e,r).leave(this),Lm.getZone(this.x,this.z,this.level).enter(this))}validateAndAdvanceStep(){const t=this.takeStep();if(null===t)return-1;if(-1===t)return this.waypointIndex--,-1!=this.waypointIndex?this.validateAndAdvanceStep():-1;const e=this.x,r=this.z;return this.x=oh.moveX(this.x,t),this.z=oh.moveZ(this.z,t),this.orientationX=2*oh.moveX(this.x,t)+1,this.orientationZ=2*oh.moveZ(this.z,t)+1,this.stepsTaken++,this.refreshZonePresence(e,r,this.level),t}queueWaypoint(t,e){this.waypoints[0]=oh.packCoord(0,t,e),this.waypointIndex=0}queueWaypoints(t){let e=-1;for(let r=t.length-1,i=0;r>=0&&i2&&(this.jump=!0)}convertMovementDir(){let t=this.walkDir,e=this.runDir,r=this.moveSpeed===Zl.INSTANT;const i=oh.distanceTo(this,{x:this.lastX,z:this.lastZ,width:this.width,length:this.length});if(r&&!this.jump&&i<=2){if(2===i){const r=(this.x+this.lastX)/2|0,i=(this.z+this.lastZ)/2|0;t=oh.face(this.lastX,this.lastZ,r,i),e=oh.face(r,i,this.x,this.z)}else t=oh.face(this.lastX,this.lastZ,this.x,this.z),e=-1;r=!1}this.walkDir=t,this.runDir=e,this.tele=r}hasWaypoints(){return-1!==this.waypointIndex}isLastOrNoWaypoint(){return this.waypointIndex<=0}inOperableDistance(t){if(t.level!==this.level)return!1;if(t instanceof Xl)return Po(this.level,this.x,this.z,t.x,t.z,t.width,t.length,this.width,-1,-2);if(t instanceof Al){const e=ta.get(t.type).forceapproach;return Po(this.level,this.x,this.z,t.x,t.z,t.width,t.length,this.width,t.angle,t.shape,e)}const e=Po(this.level,this.x,this.z,t.x,t.z,t.width,t.length,this.width,0,-2);return Io(t.x,t.z,t.level,qo.WALK_BLOCKED)?e:!(this.hasWaypoints()||!e)||Po(this.level,this.x,this.z,t.x,t.z,t.width,t.length,this.width,0,-1)}inApproachDistance(t,e){return e.level===this.level&&(!(e instanceof Xl&&oh.intersects(this.x,this.z,this.width,this.length,e.x,e.z,e.width,e.length))&&(oh.distanceTo(this,e)<=t&&Oo(this.level,this.x,this.z,e.x,e.z,this.width,this.length,e.width,e.length,qo.PLAYER)))}pathToMoveClick(t,e){if(this.moveStrategy===$l.SMART)if(e){const{x:e,z:r}=oh.unpackCoord(t[0]);this.queueWaypoints(go(this.level,this.x,this.z,e,r))}else this.queueWaypoints(t);else{const{x:e,z:r}=oh.unpackCoord(t[t.length-1]);this.queueWaypoint(e,r)}}pathToPathingTarget(){this.target&&this.target instanceof Xl&&this.isLastOrNoWaypoint()&&(this.targetOp!==Ll.APPLAYER3&&this.targetOp!==Ll.OPPLAYER3?this.pathToTarget():this.queueWaypoint(this.target.lastStepX,this.target.lastStepZ))}pathToTarget(){if(!this.target)return;this.targetX=this.target.x,this.targetZ=this.target.z;const t=2*this.target.x+this.target.width,e=2*this.target.z+this.target.length;if(this.orientationX=t,this.orientationZ=e,this.moveStrategy===$l.SMART)if(this.target instanceof Xl)this.queueWaypoints(go(this.level,this.x,this.z,this.target.x,this.target.z,this.width,this.target.width,this.target.length,0,-2));else if(this.target instanceof Al){const t=ta.get(this.target.type).forceapproach;this.queueWaypoints(go(this.level,this.x,this.z,this.target.x,this.target.z,this.width,this.target.width,this.target.length,this.target.angle,this.target.shape,!0,t))}else this.queueWaypoints(go(this.level,this.x,this.z,this.target.x,this.target.z));else if(this.moveStrategy===$l.NAIVE){const t=this.getCollisionStrategy();if(null===t)return;const e=this.blockWalkFlag();if(e===qo.NULL)return;this.target instanceof Xl?this.queueWaypoints(yo(this.level,this.x,this.z,this.target.x,this.target.z,this.width,this.length,this.target.width,this.target.length,e,t)):this.queueWaypoint(this.target.x,this.target.z)}else{if(null===this.getCollisionStrategy())return;if(this.blockWalkFlag()===qo.NULL)return;this.queueWaypoint(this.target.x,this.target.z)}}setInteraction(t,e,r,i){this.target=e,this.targetOp=r,this.targetSubject=i??{type:-1,com:-1},this.targetX=e.x,this.targetZ=e.z,this.apRange=10,this.apRangeCalled=!1;const n=2*e.x+e.width,s=2*e.z+e.length;if(this.orientationX=n,this.orientationZ=s,e instanceof af){const t=e.pid+32768;this.faceEntity!==t&&(this.faceEntity=t,this.mask|=this.entitymask)}else if(e instanceof hm){const t=e.nid;this.faceEntity!==t&&(this.faceEntity=t,this.mask|=this.entitymask)}else this.faceX===n&&this.faceZ===s||(this.faceX=n,this.faceZ=s,this.mask|=this.coordmask);t===Rl.SCRIPT&&this.pathToTarget()}clearInteraction(){this.target=null,this.targetOp=-1,this.targetSubject={type:-1,com:-1},this.targetX=-1,this.targetZ=-1,this.apRange=10,this.apRangeCalled=!1,this.alreadyFacedEntity=!0}getCollisionStrategy(){return this.moveRestrict===ua.NORMAL?$o.NORMAL:this.moveRestrict===ua.BLOCKED?$o.BLOCKED:this.moveRestrict===ua.BLOCKED_NORMAL?$o.LINE_OF_SIGHT:this.moveRestrict===ua.INDOORS?$o.INDOORS:this.moveRestrict===ua.OUTDOORS?$o.OUTDOORS:this.moveRestrict===ua.NOMOVE?null:this.moveRestrict===ua.PASSTHRU?$o.NORMAL:null}resetPathingEntity(){this.moveSpeed=this.defaultMoveSpeed(),this.walkDir=-1,this.runDir=-1,this.jump=!1,this.tele=!1,this.lastX=this.x,this.lastZ=this.z,this.lastLevel=this.level,this.stepsTaken=0,this.interacted=!1,this.apRangeCalled=!1,this.mask=0,this.exactStartX=-1,this.exactStartZ=-1,this.exactEndX=-1,this.exactEndZ=-1,this.exactMoveStart=-1,this.exactMoveEnd=-1,this.exactMoveDirection=-1,this.animId=-1,this.animDelay=-1,this.animId=-1,this.animDelay=-1,this.chat=null,this.damageTaken=-1,this.damageType=-1,this.graphicId=-1,this.graphicHeight=-1,this.graphicDelay=-1,this.alreadyFacedEntity&&!this.target&&-1!==this.faceEntity&&(this.mask|=this.entitymask,this.faceEntity=-1,this.alreadyFacedEntity=!1)}takeStep(){if(-1===this.waypointIndex)return null;const t=this.x,e=this.z,{x:r,z:i}=oh.unpackCoord(this.waypoints[this.waypointIndex]),n=oh.face(t,e,r,i),s=oh.deltaX(n),a=oh.deltaZ(n);if(0==s&&0==a)return-1;const o=this.getCollisionStrategy();if(null===o)return-1;const h=this.blockWalkFlag();return h===qo.NULL?-1:this.moveStrategy===$l.FLY||Co(this.level,this.x,this.z,s,a,this.width,h,o)?n:0!=s&&Co(this.level,this.x,this.z,s,0,this.width,h,o)?oh.face(t,e,r,e):0!=a&&Co(this.level,this.x,this.z,0,a,this.width,h,o)?oh.face(t,e,t,i):null}}class Ql{sentinel;cursor=null;constructor(){const t=new ns;t.nextHashable=t,t.prevHashable=t,this.sentinel=t}push(t){t.prevHashable&&t.uncache(),t.prevHashable=this.sentinel.prevHashable,t.nextHashable=this.sentinel,t.prevHashable&&(t.prevHashable.nextHashable=t),t.nextHashable.prevHashable=t}pop(){const t=this.sentinel.nextHashable;return t===this.sentinel?null:(t?.uncache(),t)}head(){const t=this.sentinel.nextHashable;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.nextHashable||null,t)}next(){const t=this.cursor;return t===this.sentinel?(this.cursor=null,null):(this.cursor=t?.nextHashable||null,t)}clear(){for(;;){const t=this.sentinel.next;if(t==this.sentinel)return;t&&t.unlink()}}}var{default:Jl}=()=>({});var tc,ec,rc=new Map,ic=new Map;class nc extends ns{}class sc{static LOW=new sc;static HIGH=new sc}class ac extends nc{priority=sc.LOW}class oc extends nc{uid;priority=sc.HIGH;constructor(t){super(),this.uid=t}}class hc extends nc{priority=sc.HIGH}class lc extends nc{priority=sc.HIGH}class cc extends nc{component;priority=sc.LOW;constructor(t){super(),this.component=t}}class uc extends nc{component;priority=sc.HIGH;constructor(t){super(),this.component=t}}class dc extends nc{varp;value;priority=sc.HIGH;constructor(t,e){super(),this.varp=t,this.value=e}}class fc extends nc{varp;value;priority=sc.HIGH;constructor(t,e){super(),this.varp=t,this.value=e}}class pc extends nc{name;crc;length;priority=sc.LOW;constructor(t,e,r){super(),this.name=t,this.crc=e,this.length=r}}class mc extends nc{delay;data;priority=sc.LOW;constructor(t,e){super(),this.delay=t,this.data=e}}class gc extends nc{component;tab;priority=sc.LOW;constructor(t,e){super(),this.component=t,this.tab=e}}class yc extends nc{priority=sc.HIGH}class vc extends nc{type;nid;pid;x;z2;y3;priority=sc.LOW;constructor(t,e,r,i,n,s){super(),this.type=t,this.nid=e,this.pid=r,this.x=i,this.z=n,this.y=s}}class bc extends nc{lastLoginIp;daysSinceLogin;daysSinceRecoveryChange;unreadMessageCount;priority=sc.LOW;constructor(t,e,r,i){super(),this.lastLoginIp=t,this.daysSinceLogin=e,this.daysSinceRecoveryChange=r,this.unreadMessageCount=i}}class _c extends nc{msg;priority=sc.HIGH;constructor(t){super(),this.msg=t}}class wc{type;receiverId;message;constructor(t,e,r){this.type=t,this.receiverId=e,this.message=r}}(ec=tc||={})[ec.ENCLOSED=0]='ENCLOSED',ec[ec.FOLLOWS=1]='FOLLOWS';var Ec=tc;class Ac extends nc{zoneX;zoneZ;originX;originZ;data;priority=sc.HIGH;constructor(t,e,r,i,n){super(),this.zoneX=t,this.zoneZ=e,this.originX=r,this.originZ=i,this.data=n}}class Sc extends nc{zoneX;zoneZ;originX;originZ;priority=sc.HIGH;constructor(t,e,r,i){super(),this.zoneX=t,this.zoneZ=e,this.originX=r,this.originZ=i}}class Tc extends nc{zoneX;zoneZ;originX;originZ;priority=sc.HIGH;constructor(t,e,r,i){super(),this.zoneX=t,this.zoneZ=e,this.originX=r,this.originZ=i}}class Mc extends nc{coord;priority=sc.HIGH;constructor(t){super(),this.coord=t}}class Ic extends Mc{coord;obj;count;constructor(t,e,r){super(t),this.coord=t,this.obj=e,this.count=r}}class Cc extends Mc{coord;loc;shape;angle;constructor(t,e,r,i){super(t),this.coord=t,this.loc=e,this.shape=r,this.angle=i}}class Oc extends Mc{coord;shape;angle;constructor(t,e,r){super(t),this.coord=t,this.shape=e,this.angle=r}}class Nc extends Mc{srcX;srcZ;dstX;dstZ;target;spotanim;srcHeight;dstHeight;startDelay;endDelay;peak;arc;constructor(t,e,r,i,n,s,a,o,h,l,c,u){super(oh.packZoneCoord(t,e)),this.srcX=t,this.srcZ=e,this.dstX=r,this.dstZ=i,this.target=n,this.spotanim=s,this.srcHeight=a,this.dstHeight=o,this.startDelay=h,this.endDelay=l,this.peak=c,this.arc=u}}class Lc extends Mc{coord;spotanim;height;delay;constructor(t,e,r,i){super(t),this.coord=t,this.spotanim=e,this.height=r,this.delay=i}}class Rc extends Mc{coord;obj;constructor(t,e){super(t),this.coord=t,this.obj=e}}class Pc extends Mc{coord;obj;oldCount;newCount;constructor(t,e,r,i){super(t),this.coord=t,this.obj=e,this.oldCount=r,this.newCount=i}}class Bc extends Mc{coord;obj;count;receiverId;constructor(t,e,r,i){super(t),this.coord=t,this.obj=e,this.count=r,this.receiverId=i}}class kc extends Mc{coord;shape;angle;seq;constructor(t,e,r,i){super(t),this.coord=t,this.shape=e,this.angle=r,this.seq=i}}class Dc extends Mc{srcX;srcZ;shape;angle;locId;startCycle;endCycle;pid;east;south;west;north;constructor(t,e,r,i,n,s,a,o,h,l,c,u){super(oh.packZoneCoord(t,e)),this.srcX=t,this.srcZ=e,this.shape=r,this.angle=i,this.locId=n,this.startCycle=s,this.endCycle=a,this.pid=o,this.east=h,this.south=l,this.west=c,this.north=u}}class Uc{test(t){return this.prot.length}}class xc extends Uc{prot=Kl.IF_OPENCHATMODAL;encode(t,e){t.p2(e.component)}}class Fc extends nc{component;priority=sc.LOW;constructor(t){super(),this.component=t}}class Hc extends nc{buildArea;level;x;z2;originX;originZ;uid;mask;tele;jump2;walkDir;runDir;deltaX;deltaZ;changedLevel;priority=sc.HIGH;accumulator=0;constructor(t,e,r,i,n,s,a,o,h,l,c,u,d,f,p){super(),this.buildArea=t,this.level=e,this.x=r,this.z=i,this.originX=n,this.originZ=s,this.uid=a,this.mask=o,this.tele=h,this.jump=l,this.walkDir=c,this.runDir=u,this.deltaX=d,this.deltaZ=f,this.changedLevel=p}}class jc extends Uc{static BITS_NEW=23;static BITS_IDLE=1;static BITS_RUN=10;static BITS_WALK=7;static BITS_EXTENDED=3;static BYTES_LIMIT=4997;prot=Kl.PLAYER_INFO;encode(t,e){const r=e.buildArea;e.changedLevel||e.deltaX>r.viewDistance||e.deltaZ>r.viewDistance?(r.players.clear(),r.lastResize=0,r.viewDistance=tf.PREFERRED_VIEW_DISTANCE):r.resize(),this.writeLocalPlayer(t,e),this.writePlayers(t,e),this.writeNewPlayers(t,e);const i=r.extendedInfo;if(i.size>0)for(const r of i){const i=Lm.getPlayerByUid(r.id);i?this.writeExtendedInfo(i,e,t,r.id===e.uid,r.added):t.p1(0)}r.clearExtended()}test(t){return jc.BYTES_LIMIT}willFit(t,e,r,i){return(e.bitPos+r+7>>>3)+(t.accumulator+i)<=jc.BYTES_LIMIT}writeLocalPlayer(t,e){const{buildArea:r,uid:i,level:n,x:s,z:a,tele:o,jump:h,walkDir:l,runDir:c}=e,u=Lm.getPlayerByUid(i);if(!u)return;const d=this.calculateExtendedInfo(u,e,!0,!1),f=d>0;t.bits(),t.pBit(1,o||-1!==c||-1!==l||f?1:0),o?(t.pBit(2,3),t.pBit(2,n),t.pBit(7,oh.local(s,u.originX)),t.pBit(7,oh.local(a,u.originZ)),t.pBit(1,h?1:0),t.pBit(1,f?1:0)):-1!==c?(t.pBit(2,2),t.pBit(3,l),t.pBit(3,c),t.pBit(1,f?1:0)):-1!==l?(t.pBit(2,1),t.pBit(3,l),t.pBit(1,f?1:0)):f&&t.pBit(2,0),f&&(r.extendedInfo.add({id:i,added:!1}),e.accumulator+=d)}writePlayers(t,e){const r=e.buildArea;t.pBit(8,r.players.size);for(const i of r.players){const n=Lm.getPlayerByUid(i);if(!n||n.tele||n.level!==e.level||!oh.isWithinDistanceSW(e,n,r.viewDistance)||!n.checkLifeCycle(Lm.currentTick)){t.pBit(1,1),t.pBit(2,3),r.players.delete(i);continue}const s=this.calculateExtendedInfo(n,e,!1,!1);let a=s>0;const{walkDir:o,runDir:h}=n;let l=jc.BITS_IDLE;-1!==h?l=jc.BITS_RUN:-1!==o?l=jc.BITS_WALK:a&&(l=jc.BITS_EXTENDED),this.willFit(e,t,l,s)||(a=!1),t.pBit(1,-1!==h||-1!==o||a?1:0),-1!==h?(t.pBit(2,2),t.pBit(3,o),t.pBit(3,h),t.pBit(1,a?1:0)):-1!==o?(t.pBit(2,1),t.pBit(3,o),t.pBit(1,a?1:0)):a&&t.pBit(2,0),a&&(r.extendedInfo.add({id:i,added:!1}),e.accumulator+=s)}}writeNewPlayers(t,e){const r=e.buildArea;for(const i of r.getNearbyPlayers(e.uid,e.x,e.z,e.originX,e.originZ)){const n=this.calculateExtendedInfo(i,e,!1,!0),s=n>0;if(!this.willFit(e,t,jc.BITS_NEW+11,n))break;t.pBit(11,i.pid),t.pBit(5,i.x-e.x),t.pBit(5,i.z-e.z),t.pBit(1,i.jump?1:0),t.pBit(1,s?1:0),s&&(r.extendedInfo.add({id:i.uid,added:!0}),e.accumulator+=n),r.players.add(i.uid)}r.extendedInfo.size>0&&t.pBit(11,2047),t.bytes()}writeExtendedInfo(t,e,r,i=!1,n=!1){let s=t.mask;n&&(-1===t.orientationX&&-1===t.faceX||(s|=af.FACE_COORD),-1!==t.faceEntity&&(s|=af.FACE_ENTITY)),i&&s&af.CHAT&&(s&=~af.CHAT),e.buildArea.hasAppearance(t.uid,t.lastAppearance)||!t.appearance?s&=~af.APPEARANCE:s|=af.APPEARANCE,s>255&&(s|=af.BIG_UPDATE),r.p1(255&s),s&af.BIG_UPDATE&&r.p1(s>>8),s&af.APPEARANCE&&(r.p1(t.appearance.length),r.pdata(t.appearance,0,t.appearance.length),e.buildArea.saveAppearance(t.uid,t.lastAppearance)),s&af.ANIM&&(r.p2(t.animId),r.p1(t.animDelay)),s&af.FACE_ENTITY&&(-1!==t.faceEntity&&(t.alreadyFacedEntity=!0),r.p2(t.faceEntity)),s&af.SAY&&r.pjstr(t.chat??''),s&af.DAMAGE&&(r.p1(t.damageTaken),r.p1(t.damageType),r.p1(t.levels[uh.HITPOINTS]),r.p1(t.baseLevels[uh.HITPOINTS])),s&af.FACE_COORD&&(n&&-1!==t.orientationX?(r.p2(t.orientationX),r.p2(t.orientationZ)):(r.p2(t.faceX),r.p2(t.faceZ))),s&af.CHAT&&(r.p1(t.messageColor),r.p1(t.messageEffect),r.p1(t.messageType),r.p1(t.message.length),r.pdata(t.message,0,t.message.length)),s&af.SPOTANIM&&(r.p2(t.graphicId),r.p2(t.graphicHeight),r.p2(t.graphicDelay)),s&af.EXACT_MOVE&&(r.p1(t.exactStartX-oh.zoneOrigin(e.originX)),r.p1(t.exactStartZ-oh.zoneOrigin(e.originZ)),r.p1(t.exactEndX-oh.zoneOrigin(e.originX)),r.p1(t.exactEndZ-oh.zoneOrigin(e.originZ)),r.p2(t.exactMoveStart),r.p2(t.exactMoveEnd),r.p1(t.exactMoveDirection))}calculateExtendedInfo(t,e,r=!1,i=!1){let n=0,s=t.mask;return i&&(-1===t.orientationX&&-1===t.faceX||(s|=af.FACE_COORD),-1!==t.faceEntity&&(s|=af.FACE_ENTITY)),r&&s&af.CHAT&&(s&=~af.CHAT),e.buildArea.hasAppearance(t.uid,t.lastAppearance)||!t.appearance?s&=~af.APPEARANCE:s|=af.APPEARANCE,s>255&&(s|=af.BIG_UPDATE),0===s?0:(n+=1,s&af.BIG_UPDATE&&(n+=1),s&af.APPEARANCE&&(n+=1+t.appearance.length),s&af.ANIM&&(n+=3),s&af.FACE_ENTITY&&(n+=2),s&af.SAY&&(n+=1+t.chat.length),s&af.DAMAGE&&(n+=4),s&af.FACE_COORD&&(n+=4),s&af.CHAT&&(n+=4+t.message.length),s&af.SPOTANIM&&(n+=6),s&af.EXACT_MOVE&&(n+=9),n)}}class Vc extends nc{zoneX;zoneZ;priority=sc.HIGH;constructor(t,e){super(),this.zoneX=t,this.zoneZ=e}get mapsquares(){const t=this.zoneX-6,e=this.zoneX+6,r=this.zoneZ-6,i=this.zoneZ+6,n=new Set;for(let s=t;s<=e;s++){const t=oh.mapsquare(s<<3);for(let e=r;e<=i;e++){const r=oh.mapsquare(e<<3);n.add(t<<8|r)}}return n}}class Gc extends Uc{prot=Kl.REBUILD_NORMAL;encode(t,e){t.p2(e.zoneX),t.p2(e.zoneZ);for(const r of e.mapsquares){const e=r>>8,i=255&r;t.p1(e),t.p1(i),t.p4(ic.get(`m${e}_${i}`)??0),t.p4(ic.get(`l${e}_${i}`)??0)}}test(t){return 4+10*t.mapsquares.size}}class zc extends nc{x;z2;offset;length;data;priority=sc.HIGH;constructor(t,e,r,i,n){super(),this.x=t,this.z=e,this.offset=r,this.length=i,this.data=n}}class Wc extends Uc{prot=Kl.DATA_LAND;encode(t,e){t.p1(e.x),t.p1(e.z),t.p2(e.offset),t.p2(e.length),t.pdata(e.data,0,e.data.length)}test(t){return 6+t.data.length}}class Kc extends nc{x;z2;priority=sc.HIGH;constructor(t,e){super(),this.x=t,this.z=e}}class qc extends Uc{prot=Kl.DATA_LAND_DONE;encode(t,e){t.p1(e.x),t.p1(e.z)}}class Yc extends nc{x;z2;offset;length;data;priority=sc.HIGH;constructor(t,e,r,i,n){super(),this.x=t,this.z=e,this.offset=r,this.length=i,this.data=n}}class Zc extends Uc{prot=Kl.DATA_LOC;encode(t,e){t.p1(e.x),t.p1(e.z),t.p2(e.offset),t.p2(e.length),t.pdata(e.data,0,e.data.length)}test(t){return 6+t.data.length}}class $c extends nc{x;z2;priority=sc.HIGH;constructor(t,e){super(),this.x=t,this.z=e}}class Xc extends Uc{prot=Kl.DATA_LOC_DONE;encode(t,e){t.p1(e.x),t.p1(e.z)}}class Qc extends nc{x;z2;height;speed;multiplier;priority=sc.LOW;constructor(t,e,r,i,n){super(),this.x=t,this.z=e,this.height=r,this.speed=i,this.multiplier=n}}class Jc extends Uc{prot=Kl.CAM_LOOKAT;encode(t,e){t.p1(e.x),t.p1(e.z),t.p2(e.height),t.p1(e.speed),t.p1(e.multiplier)}}class tu extends nc{x;z2;height;speed;multiplier;priority=sc.LOW;constructor(t,e,r,i,n){super(),this.x=t,this.z=e,this.height=r,this.speed=i,this.multiplier=n}}class eu extends Uc{prot=Kl.CAM_MOVETO;encode(t,e){t.p1(e.x),t.p1(e.z),t.p2(e.height),t.p1(e.speed),t.p1(e.multiplier)}}class ru extends nc{priority=sc.LOW}class iu extends Uc{prot=Kl.CAM_RESET;encode(t,e){}}class nu extends nc{type;jitter;amplitude;frequency;priority=sc.LOW;constructor(t,e,r,i){super(),this.type=t,this.jitter=e,this.amplitude=r,this.frequency=i}}class su extends Uc{prot=Kl.CAM_SHAKE;encode(t,e){t.p1(e.type),t.p1(e.jitter),t.p1(e.amplitude),t.p1(e.frequency)}}class au extends nc{publicChat;privateChat;tradeDuel;priority=sc.HIGH;constructor(t,e,r){super(),this.publicChat=t,this.privateChat=e,this.tradeDuel=r}}class ou extends Uc{prot=Kl.CHAT_FILTER_SETTINGS;encode(t,e){t.p1(e.publicChat),t.p1(e.privateChat),t.p1(e.tradeDuel)}}class hu extends nc{priority=sc.LOW}class lu extends Uc{prot=Kl.ENABLE_TRACKING;encode(t,e){}}class cu extends nc{priority=sc.LOW}class uu extends Uc{prot=Kl.FINISH_TRACKING;encode(t,e){}}class du extends Uc{prot=Kl.HINT_ARROW;encode(t,e){const{type:r,nid:i,pid:n,x:s,z:a,y:o}=e;1===r?(t.p1(r),t.p2(i),t.p2(0),t.p1(0)):r>=2&&r<=6?(t.p1(r),t.p2(s),t.p2(a),t.p1(o)):10===r?(t.p1(r),t.p2(n),t.p2(0),t.p1(0)):-1===r&&(t.p1(-1),t.p2(0),t.p2(0),t.p1(0))}}class fu extends Uc{prot=Kl.IF_CLOSE;encode(t,e){}}class pu extends nc{component;priority=sc.LOW;constructor(t){super(),this.component=t}}class mu extends Uc{prot=Kl.IF_OPENMAINMODAL;encode(t,e){t.p2(e.component)}}class gu extends nc{main;side;priority=sc.LOW;constructor(t,e){super(),this.main=t,this.side=e}}class yu extends Uc{prot=Kl.IF_OPENMAINSIDEMODAL;encode(t,e){t.p2(e.main),t.p2(e.side)}}class vu extends nc{component;priority=sc.LOW;constructor(t){super(),this.component=t}}class bu extends Uc{prot=Kl.IF_OPENSIDEMODAL;encode(t,e){t.p2(e.component)}}class _u extends Uc{prot=Kl.IF_OPENSIDEOVERLAY;encode(t,e){t.p2(e.component),t.p1(e.tab)}}class wu extends nc{component;seq;priority=sc.LOW;constructor(t,e){super(),this.component=t,this.seq=e}}class Eu extends Uc{prot=Kl.IF_SETANIM;encode(t,e){t.p2(e.component),t.p2(e.seq)}}class Au extends nc{component;colour;priority=sc.LOW;constructor(t,e){super(),this.component=t,this.colour=e}}class Su extends Uc{prot=Kl.IF_SETCOLOUR;encode(t,e){t.p2(e.component),t.p2(e.colour)}}class Tu extends nc{component;hidden;priority=sc.LOW;constructor(t,e){super(),this.component=t,this.hidden=e}}class Mu extends Uc{prot=Kl.IF_SETHIDE;encode(t,e){t.p2(e.component),t.pbool(e.hidden)}}class Iu extends nc{component;model;priority=sc.LOW;constructor(t,e){super(),this.component=t,this.model=e}}class Cu extends Uc{prot=Kl.IF_SETMODEL;encode(t,e){t.p2(e.component),t.p2(e.model)}}class Ou extends nc{component;npc;priority=sc.LOW;constructor(t,e){super(),this.component=t,this.npc=e}}class Nu extends Uc{prot=Kl.IF_SETNPCHEAD;encode(t,e){t.p2(e.component),t.p2(e.npc)}}class Lu extends nc{component;obj;scale;priority=sc.LOW;constructor(t,e,r){super(),this.component=t,this.obj=e,this.scale=r}}class Ru extends Uc{prot=Kl.IF_SETOBJECT;encode(t,e){t.p2(e.component),t.p2(e.obj),t.p2(e.scale)}}class Pu extends nc{component;priority=sc.LOW;constructor(t){super(),this.component=t}}class Bu extends Uc{prot=Kl.IF_SETPLAYERHEAD;encode(t,e){t.p2(e.component)}}class ku extends nc{component;x;y3;priority=sc.LOW;constructor(t,e,r){super(),this.component=t,this.x=e,this.y=r}}class Du extends Uc{prot=Kl.IF_SETPOSITION;encode(t,e){t.p2(e.component),t.p2(e.x),t.p2(e.y)}}class Uu extends nc{component;src;dst;priority=sc.LOW;constructor(t,e,r){super(),this.component=t,this.src=e,this.dst=r}}class xu extends Uc{prot=Kl.IF_SETRECOL;encode(t,e){t.p2(e.component),t.p2(e.src),t.p2(e.dst)}}class Fu extends nc{component;text;priority=sc.LOW;constructor(t,e){super(),this.component=t,this.text=e}}class Hu extends Uc{prot=Kl.IF_SETTEXT;encode(t,e){t.p2(e.component),t.pjstr(e.text)}test(t){return 3+t.text.length}}class ju extends nc{tab;priority=sc.LOW;constructor(t){super(),this.tab=t}}class Vu extends Uc{prot=Kl.IF_SHOWSIDE;encode(t,e){t.p1(e.tab)}}class Gu extends Uc{prot=Kl.LAST_LOGIN_INFO;encode(t,e){t.p4(e.lastLoginIp),t.p2(e.daysSinceLogin),t.p1(e.daysSinceRecoveryChange),t.p2(e.unreadMessageCount)}}class zu extends Kl{static LOC_MERGE=new zu(23,14);static LOC_ANIM=new zu(42,4);static OBJ_DEL=new zu(49,3);static OBJ_REVEAL=new zu(50,7);static LOC_ADD_CHANGE=new zu(59,4);static MAP_PROJANIM=new zu(69,15);static LOC_DEL=new zu(76,2);static OBJ_COUNT=new zu(151,7);static MAP_ANIM=new zu(191,6);static OBJ_ADD=new zu(223,5)}class Wu extends Uc{enclose(t){const e=new as(new Uint8Array(1+this.prot.length));return e.p1(this.prot.id),this.encode(e,t),e.data}}class Ku extends Wu{prot=zu.LOC_ADD_CHANGE;encode(t,e){t.p1(e.coord),t.p1(e.shape<<2|3&e.angle),t.p2(e.loc)}}class qu extends Wu{prot=zu.LOC_ANIM;encode(t,e){t.p1(e.coord),t.p1(e.shape<<2|3&e.angle),t.p2(e.seq)}}class Yu extends Wu{prot=zu.LOC_DEL;encode(t,e){t.p1(e.coord),t.p1(e.shape<<2|3&e.angle)}}class Zu extends Wu{prot=zu.LOC_MERGE;encode(t,e){t.p1(e.coord),t.p1(e.shape<<2|3&e.angle),t.p2(e.locId),t.p2(e.startCycle),t.p2(e.endCycle),t.p2(e.pid),t.p1(e.east-e.srcX),t.p1(e.south-e.srcZ),t.p1(e.west-e.srcX),t.p1(e.north-e.srcZ)}}class $u extends nc{priority=sc.HIGH}class Xu extends Uc{prot=Kl.LOGOUT;encode(t,e){}}class Qu extends Wu{prot=zu.MAP_ANIM;encode(t,e){t.p1(e.coord),t.p2(e.spotanim),t.p1(e.height),t.p2(e.delay)}}class Ju extends Wu{prot=zu.MAP_PROJANIM;encode(t,e){t.p1(e.coord),t.p1(e.dstX-e.srcX),t.p1(e.dstZ-e.srcZ),t.p2(e.target),t.p2(e.spotanim),t.p1(e.srcHeight),t.p1(e.dstHeight),t.p2(e.startDelay),t.p2(e.endDelay),t.p1(e.peak),t.p1(e.arc)}}class td extends Uc{prot=Kl.MESSAGE_GAME;encode(t,e){t.pjstr(e.msg)}test(t){return 1+t.msg.length}}class ed{static CHAR_LOOKUP=[' ','e','t','a','o','i','h','n','s','r','d','l','u','m','w','c','y','f','g','p','b','v','k','x','j','q','z','0','1','2','3','4','5','6','7','8','9',' ','!','?','.',',',':',';','(',')','-','&','*','\\',"'",'@','#','+','=','£','$','%','"','[',']'];static unpack(t,e){const r=[];let i,n=0,s=-1;for(let a=0;a>4&15,-1!==s?(r[n++]=this.CHAR_LOOKUP[(s<<4)+i-195],s=-1):i<13?r[n++]=this.CHAR_LOOKUP[i]:s=i,i=15&e,-1!=s?(r[n++]=this.CHAR_LOOKUP[(s<<4)+i-195],s=-1):i<13?r[n++]=this.CHAR_LOOKUP[i]:s=i}return this.toSentenceCase(r.slice(0,n).join(''))}static pack(t,e){e.length>80&&(e=e.substring(0,80)),e=e.toLowerCase();let r=-1;for(let i=0;i12&&(s+=195),-1==r?s<13?r=s:t.p1(s):s<13?(t.p1((r<<4)+s),r=-1):(t.p1((r<<4)+(s>>4)),r=15&s)}-1!=r&&t.p1(r<<4)}static toSentenceCase(t){const e=[...t.toLowerCase()];let r=!0;for(let t=0;t='a'&&i<='z'&&(e[t]=i.toUpperCase(),r=!1),'.'!==i&&'!'!==i||(r=!0)}return e.join('')}}class rd extends Uc{prot=Kl.MESSAGE_PRIVATE;encode(t,e){t.p8(e.from),t.p4(e.messageId),t.p1(e.staffModLevel),ed.pack(t,ja.filter(e.msg))}test(t){return 14+t.msg.length}}class id extends nc{from;messageId;staffModLevel;msg;priority=sc.HIGH;constructor(t,e,r,i){super(),this.from=t,this.messageId=e,this.staffModLevel=r,this.msg=i}}class nd extends Uc{prot=Kl.MIDI_JINGLE;encode(t,e){t.p2(e.delay),t.p4(e.data.length),t.pdata(e.data,0,e.data.length)}test(t){return 6+t.data.length}}class sd extends Uc{prot=Kl.MIDI_SONG;encode(t,e){t.pjstr(e.name),t.p4(e.crc),t.p4(e.length)}test(t){return 1+t.name.length+4+4}}class ad extends Wu{prot=zu.OBJ_ADD;encode(t,e){t.p1(e.coord),t.p2(e.obj),t.p2(Math.min(e.count,65535))}}class od extends Wu{prot=zu.OBJ_COUNT;encode(t,e){t.p1(e.coord),t.p2(e.obj),t.p2(Math.min(e.oldCount,65535)),t.p2(Math.min(e.newCount,65535))}}class hd extends Wu{prot=zu.OBJ_DEL;encode(t,e){t.p1(e.coord),t.p2(e.obj)}}class ld extends Wu{prot=zu.OBJ_REVEAL;encode(t,e){t.p1(e.coord),t.p2(e.obj),t.p2(Math.min(e.count,65535)),t.p2(e.receiverId)}}class cd extends nc{priority=sc.LOW}class ud extends Uc{prot=Kl.P_COUNTDIALOG;encode(t,e){}}class dd extends Uc{prot=Kl.RESET_ANIMS;encode(t,e){}}class fd extends Uc{prot=Kl.RESET_CLIENT_VARCACHE;encode(t,e){}}class pd extends nc{hidden;priority=sc.LOW;constructor(t){super(),this.hidden=t}}class md extends Uc{prot=Kl.SET_MULTIWAY;encode(t,e){t.pbool(e.hidden)}}class gd extends nc{synth;loops;delay;priority=sc.LOW;constructor(t,e,r){super(),this.synth=t,this.loops=e,this.delay=r}}class yd extends Uc{prot=Kl.SYNTH_SOUND;encode(t,e){t.p2(e.synth),t.p1(e.loops),t.p2(e.delay)}}class vd extends nc{tab;priority=sc.LOW;constructor(t){super(),this.tab=t}}class bd extends Uc{prot=Kl.TUTORIAL_FLASHSIDE;encode(t,e){t.p1(e.tab)}}class _d extends Uc{prot=Kl.TUTORIAL_OPENCHAT;encode(t,e){t.p2(e.component)}}class wd extends Uc{prot=Kl.UNSET_MAP_FLAG;encode(t,e){}}class Ed extends nc{name;nodeId;priority=sc.LOW;constructor(t,e){super(),this.name=t,this.nodeId=e}}class Ad extends Uc{prot=Kl.UPDATE_FRIENDLIST;encode(t,e){t.p8(e.name),t.p1(e.nodeId)}}class Sd extends nc{names;priority=sc.LOW;constructor(t){super(),this.names=t}}class Td extends Uc{prot=Kl.UPDATE_IGNORELIST;encode(t,e){for(const r of e.names)t.p8(r)}test(t){return 8*t.names.length}}class Md extends nc{component;inv;priority=sc.HIGH;constructor(t,e){super(),this.component=t,this.inv=e}}class Id extends Uc{prot=Kl.UPDATE_INV_FULL;encode(t,e){const{component:r,inv:i}=e,n=qs.get(r),s=Math.min(i.capacity,n.width*n.height);t.p2(r),t.p1(s);for(let e=0;e=255?(t.p1(255),t.p4(r.count)):t.p1(r.count)):(t.p2(0),t.p1(0))}}test(t){const{component:e,inv:r}=t,i=qs.get(e),n=Math.min(r.capacity,i.width*i.height);let s=0;s+=3;for(let t=0;t=255?s+=5:s+=1):s+=3}return s}}class Cd extends nc{component;inv;priority=sc.HIGH;slots;constructor(t,e,...r){super(),this.component=t,this.inv=e,this.slots=r}}class Od extends Uc{prot=Kl.UPDATE_INV_PARTIAL;encode(t,e){const{component:r,inv:i}=e;t.p2(r);for(const r of e.slots){const e=i.get(r);t.p1(r),e?(t.p2(e.id+1),e.count>=255?(t.p1(255),t.p4(e.count)):t.p1(e.count)):(t.p2(0),t.p1(0))}}test(t){const{inv:e}=t;let r=0;r+=2;for(const i of t.slots){const t=e.get(i);r+=1,t?(r+=2,t.count>=255?r+=5:r+=1):r+=3}return r}}class Nd extends Uc{prot=Kl.UPDATE_INV_STOP_TRANSMIT;encode(t,e){t.p2(e.component)}}class Ld extends nc{energy;priority=sc.LOW;constructor(t){super(),this.energy=t}}class Rd extends Uc{prot=Kl.UPDATE_RUNENERGY;encode(t,e){t.p1(e.energy/100|0)}}class Pd extends nc{kg;priority=sc.LOW;constructor(t){super(),this.kg=t}}class Bd extends Uc{prot=Kl.UPDATE_RUNWEIGHT;encode(t,e){t.p2(e.kg)}}class kd extends nc{stat;exp;level;priority=sc.LOW;constructor(t,e,r){super(),this.stat=t,this.exp=e,this.level=r}}class Dd extends Uc{prot=Kl.UPDATE_STAT;encode(t,e){t.p1(e.stat),t.p4(e.exp/10|0),t.p1(e.level)}}class Ud extends Uc{prot=Kl.UPDATE_UID192;encode(t,e){t.p2(e.uid)}}class xd extends Uc{prot=Kl.UPDATE_ZONE_FULL_FOLLOWS;encode(t,e){t.p1((e.zoneX<<3)-oh.zoneOrigin(e.originX)),t.p1((e.zoneZ<<3)-oh.zoneOrigin(e.originZ))}}class Fd extends Uc{prot=Kl.UPDATE_ZONE_PARTIAL_FOLLOWS;encode(t,e){t.p1((e.zoneX<<3)-oh.zoneOrigin(e.originX)),t.p1((e.zoneZ<<3)-oh.zoneOrigin(e.originZ))}}class Hd extends Uc{prot=Kl.UPDATE_ZONE_PARTIAL_ENCLOSED;encode(t,e){t.p1((e.zoneX<<3)-oh.zoneOrigin(e.originX)),t.p1((e.zoneZ<<3)-oh.zoneOrigin(e.originZ)),t.pdata(e.data,0,e.data.length)}test(t){return 2+t.data.length}}class jd extends Uc{prot=Kl.VARP_LARGE;encode(t,e){t.p2(e.varp),t.p4(e.value)}}class Vd extends Uc{prot=Kl.VARP_SMALL;encode(t,e){t.p2(e.varp),t.p1(e.value)}}class Gd extends nc{buildArea;level;x;z2;originX;originZ;deltaX;deltaZ;changedLevel;priority=sc.HIGH;accumulator=0;constructor(t,e,r,i,n,s,a,o,h){super(),this.buildArea=t,this.level=e,this.x=r,this.z=i,this.originX=n,this.originZ=s,this.deltaX=a,this.deltaZ=o,this.changedLevel=h}}class zd extends Uc{static BITS_NEW=35;static BITS_IDLE=1;static BITS_RUN=10;static BITS_WALK=7;static BITS_EXTENDED=3;static BYTES_LIMIT=4997;prot=Kl.NPC_INFO;encode(t,e){const r=e.buildArea;(e.changedLevel||e.deltaX>r.viewDistance||e.deltaZ>r.viewDistance)&&r.npcs.clear(),this.writeNpcs(t,e),this.writeNewNpcs(t,e);const i=r.extendedInfo;if(i.size>0)for(const e of i){const r=Lm.getNpc(e.id);r?this.writeExtendedInfo(r,t,e.added):t.p1(0)}r.clearExtended()}test(t){return zd.BYTES_LIMIT}willFit(t,e,r,i){return(e.bitPos+r+7>>>3)+(t.accumulator+i)<=zd.BYTES_LIMIT}writeNpcs(t,e){const r=e.buildArea;t.bits(),t.pBit(8,r.npcs.size);for(const i of r.npcs){const n=Lm.getNpc(i);if(!n||n.tele||n.level!==e.level||!oh.isWithinDistanceSW(e,n,15)||!n.checkLifeCycle(Lm.currentTick)){t.pBit(1,1),t.pBit(2,3),r.npcs.delete(i);continue}const s=this.calculateExtendedInfo(n,!1);let a=s>0;const{walkDir:o,runDir:h}=n;let l=zd.BITS_IDLE;-1!==h?l=zd.BITS_RUN:-1!==o?l=zd.BITS_WALK:a&&(l=zd.BITS_EXTENDED),this.willFit(e,t,l,s)||(a=!1),t.pBit(1,-1!==h||-1!==o||a?1:0),-1!==h?(t.pBit(2,2),t.pBit(3,o),t.pBit(3,h),t.pBit(1,a?1:0)):-1!==o?(t.pBit(2,1),t.pBit(3,o),t.pBit(1,a?1:0)):a&&t.pBit(2,0),a&&(r.extendedInfo.add({id:i,added:!1}),e.accumulator+=s)}}writeNewNpcs(t,e){const r=e.buildArea;for(const i of r.getNearbyNpcs(e.x,e.z,e.originX,e.originZ)){const n=this.calculateExtendedInfo(i,!0),s=n>0;if(!this.willFit(e,t,zd.BITS_NEW+13,n))break;t.pBit(13,i.nid),t.pBit(11,i.type),t.pBit(5,i.x-e.x),t.pBit(5,i.z-e.z),t.pBit(1,s?1:0),s&&(r.extendedInfo.add({id:i.nid,added:!0}),e.accumulator+=n),r.npcs.add(i.nid)}r.extendedInfo.size>0&&t.pBit(13,8191),t.bytes()}writeExtendedInfo(t,e,r){let i=t.mask;r&&(-1===t.orientationX&&-1===t.faceX||(i|=hm.FACE_COORD),-1!==t.faceEntity&&(i|=hm.FACE_ENTITY)),e.p1(i),i&hm.ANIM&&(e.p2(t.animId),e.p1(t.animDelay)),i&hm.FACE_ENTITY&&(-1!==t.faceEntity&&(t.alreadyFacedEntity=!0),e.p2(t.faceEntity)),i&hm.SAY&&e.pjstr(t.chat??''),i&hm.DAMAGE&&(e.p1(t.damageTaken),e.p1(t.damageType),e.p1(t.levels[da.HITPOINTS]),e.p1(t.baseLevels[da.HITPOINTS])),i&hm.CHANGE_TYPE&&e.p2(t.type),i&hm.SPOTANIM&&(e.p2(t.graphicId),e.p2(t.graphicHeight),e.p2(t.graphicDelay)),i&hm.FACE_COORD&&(r&&-1!=t.orientationX?(e.p2(t.orientationX),e.p2(t.orientationZ)):(e.p2(t.faceX),e.p2(t.faceZ)))}calculateExtendedInfo(t,e){let r=0,i=t.mask;return e&&(-1===t.orientationX&&-1===t.faceX||(i|=hm.FACE_COORD),-1!==t.faceEntity&&(i|=hm.FACE_ENTITY)),0===i?0:(r+=1,i&hm.ANIM&&(r+=3),i&hm.FACE_ENTITY&&(r+=2),i&hm.SAY&&(r+=1+t.chat.length),i&hm.DAMAGE&&(r+=4),i&hm.CHANGE_TYPE&&(r+=2),i&hm.SPOTANIM&&(r+=6),i&hm.FACE_COORD&&(r+=4),r)}}class Wd extends nc{ticks;priority=sc.LOW;constructor(t){super(),this.ticks=t}}class Kd extends Uc{prot=Kl.UPDATE_REBOOT_TIMER;encode(t,e){t.p2(e.ticks)}}var qd=new class{encoders=new Map;bind(t,e){if(this.encoders.has(t))throw new Error(`[ServerProtRepository] Already defines a ${t.name}.`);this.encoders.set(t,e)}constructor(){this.bind(Qc,new Jc),this.bind(tu,new eu),this.bind(ru,new iu),this.bind(nu,new su),this.bind(au,new ou),this.bind(zc,new Wc),this.bind(Kc,new qc),this.bind(Yc,new Zc),this.bind($c,new Xc),this.bind(hu,new lu),this.bind(cu,new uu),this.bind(vc,new du),this.bind(ac,new fu),this.bind(Fc,new xc),this.bind(pu,new mu),this.bind(gu,new yu),this.bind(vu,new bu),this.bind(gc,new _u),this.bind(wu,new Eu),this.bind(Au,new Su),this.bind(Tu,new Mu),this.bind(Iu,new Cu),this.bind(Ou,new Nu),this.bind(Lu,new Ru),this.bind(Pu,new Bu),this.bind(ku,new Du),this.bind(Uu,new xu),this.bind(Fu,new Hu),this.bind(ju,new Vu),this.bind(bc,new Gu),this.bind(Cc,new Ku),this.bind(kc,new qu),this.bind(Oc,new Yu),this.bind(Dc,new Zu),this.bind($u,new Xu),this.bind(Lc,new Qu),this.bind(Nc,new Ju),this.bind(_c,new td),this.bind(id,new rd),this.bind(mc,new nd),this.bind(pc,new sd),this.bind(Gd,new zd),this.bind(Ic,new ad),this.bind(Pc,new od),this.bind(Rc,new hd),this.bind(Bc,new ld),this.bind(cd,new ud),this.bind(Hc,new jc),this.bind(Vc,new Gc),this.bind(hc,new dd),this.bind(lc,new fd),this.bind(pd,new md),this.bind(gd,new yd),this.bind(vd,new bd),this.bind(cc,new _d),this.bind(yc,new wd),this.bind(Ed,new Ad),this.bind(Sd,new Td),this.bind(Md,new Id),this.bind(Cd,new Od),this.bind(uc,new Nd),this.bind(Ld,new Rd),this.bind(Pd,new Bd),this.bind(Wd,new Kd),this.bind(kd,new Dd),this.bind(oc,new Ud),this.bind(Sc,new xd),this.bind(Ac,new Hd),this.bind(Tc,new Fd),this.bind(fc,new jd),this.bind(dc,new Vd)}getEncoder(t){return this.encoders.get(t.constructor)}getZoneEncoder(t){return this.encoders.get(t.constructor)}};class Yd extends Array{capacity;onFilled;constructor(t,e){super(),this.capacity=t,this.onFilled=e}*stack(t){const e=this[t];if(void 0!==e)for(let t=0;t=0;t--)yield r[t];else for(let t=0;ti&&(i=e,r=t)}return r}nextBottomAll(){let t,e=Number.POSITIVE_INFINITY;for(let r=0;ri&&(i=n,r=t)}return r}nextBottomAll(){let t,e=Number.POSITIVE_INFINITY;for(let r=0;r>3,this.z=e.z>>3,this.level=e.level,this.events=new Set,this.players=new Set,this.npcs=new Set,this.locs=new Zd(Xd.LOCS,(t=>Lm.removeLoc(t,100))),this.objs=new $d(Xd.OBJS,(t=>Lm.removeObj(t,100))),this.entityEvents=new Map}enter(t){t instanceof af?(this.players.add(t.uid),Lm.getZoneGrid(this.level).flag(this.x,this.z)):t instanceof hm&&this.npcs.add(t.nid)}leave(t){t instanceof af?(this.players.delete(t.uid),0===this.players.size&&Lm.getZoneGrid(this.level).unflag(this.x,this.z)):t instanceof hm&&this.npcs.delete(t.nid)}tick(t){let e;do{e=!1;for(const r of this.getAllObjsUnsafe())r.updateLifeCycle(t)&&r.lastLifecycleTick!==t&&(r.lifecycle===cl.DESPAWN?-1!==r.receiverId?Lm.revealObj(r):(Lm.removeObj(r,0),e=!0):r.lifecycle===cl.RESPAWN&&(Lm.addObj(r,-1,0),e=!0));for(const r of this.getAllLocsUnsafe())r.updateLifeCycle(t)&&r.lastLifecycleTick!==t&&(r.lifecycle===cl.DESPAWN?(Lm.removeLoc(r,0),e=!0):r.lifecycle===cl.RESPAWN&&(Lm.addLoc(r,0),e=!0))}while(e)}computeShared(){this.shared=null;let t=0;const e=[];for(const r of this.events.values()){if(r.type!==Ec.ENCLOSED)continue;const i=qd.getZoneEncoder(r.message);if(void 0===i)continue;const n=i.enclose(r.message);e.push(n),t+=n.length}if(0===e.length||0===t)return;const r=new Uint8Array(t);let i=0;for(const t of e)r.set(t,i),i+=t.length;this.shared=r}writeFullFollows(t){t.write(new Sc(this.x,this.z,t.originX,t.originZ));for(const e of this.getAllObjsUnsafe(!0))-1!==e.receiverId&&e.receiverId!==t.pid||(t.write(new Tc(this.x,this.z,t.originX,t.originZ)),(e.lifecycle===cl.DESPAWN&&e.checkLifeCycle(Lm.currentTick)||e.lifecycle===cl.RESPAWN&&e.checkLifeCycle(Lm.currentTick))&&t.write(new Ic(oh.packZoneCoord(e.x,e.z),e.type,e.count)));for(const e of this.getAllLocsUnsafe(!0))e.lifecycle===cl.DESPAWN&&e.checkLifeCycle(Lm.currentTick)?t.write(new Cc(oh.packZoneCoord(e.x,e.z),e.type,e.shape,e.angle)):e.lifecycle!==cl.RESPAWN||e.checkLifeCycle(Lm.currentTick)||t.write(new Oc(oh.packZoneCoord(e.x,e.z),e.shape,e.angle))}writePartialEncloses(t){this.shared&&t.write(new Ac(this.x,this.z,t.originX,t.originZ,this.shared))}writePartialFollows(t){if(0!==this.events.size){t.write(new Tc(this.x,this.z,t.originX,t.originZ));for(const e of this.events)e.type===Ec.FOLLOWS&&(-1!==e.receiverId&&e.receiverId!==t.pid||t.write(e.message))}}reset(){this.events.clear(),this.entityEvents.clear()}addStaticLoc(t){const e=oh.packZoneCoord(t.x,t.z);this.locs.addLast(e,t,!0),this.totalLocs++,this.locs.sortStack(e,!0)}addStaticObj(t){const e=oh.packZoneCoord(t.x,t.z);this.objs.addLast(e,t,!0),this.totalObjs++,this.objs.sortStack(e,!0)}appendEvent(t,e){this.events.add(e);const r=this.entityEvents.get(t);void 0!==r?this.entityEvents.set(t,r.concat(e)):this.entityEvents.set(t,[e])}addLoc(t){const e=oh.packZoneCoord(t.x,t.z);t.lifecycle===cl.DESPAWN&&(this.locs.addLast(e,t),this.totalLocs++),this.locs.sortStack(e),this.appendEvent(t,new wc(Ec.ENCLOSED,-1,new Cc(e,t.type,t.shape,t.angle)))}removeLoc(t){const e=oh.packZoneCoord(t.x,t.z);t.lifecycle===cl.DESPAWN&&(this.locs.remove(e,t),this.totalLocs--),this.locs.sortStack(e);const r=this.entityEvents.get(t);if(void 0!==r){for(let t=0;t>this.INT_BITS);grid;constructor(t=Qd.DEFAULT_GRID_SIZE){this.grid=new Int32Array(t)}index(t,e){return t<>>Qd.INT_BITS}flag(t,e){this.grid[this.index(t,e)]|=1<<(e&Qd.INT_BITS_FLAG)}unflag(t,e){this.grid[this.index(t,e)]&=~(1<<(e&Qd.INT_BITS_FLAG))}isFlagged(t,e,r){const i=Math.max(0,t-r),n=Math.min(Qd.GRID_SIZE-1,t+r),s=Math.max(0,e-r),a=Math.min(Qd.GRID_SIZE-1,e+r),o=Qd.INT_BITS_FLAG,h=s&~o,l=a>>>Qd.INT_BITS<a&&(n=i&(1<>>s-e),0!==h)return!0}return!1}}class Jd{static zoneIndex(t,e,r){return t>>3&2047|(e>>3&2047)<<11|(3&r)<<22}static unpackIndex(t){return{x:(2047&t)<<3,z:(t>>11&2047)<<3,level:t>>22}}zones;grids;constructor(){this.zones=new Map,this.grids=new Map}zone(t,e,r){const i=Jd.zoneIndex(t,e,r);let n=this.zones.get(i);return void 0===n&&(n=new Xd(i),this.zones.set(i,n)),n}zoneByIndex(t){let e=this.zones.get(t);return void 0===e&&(e=new Xd(t),this.zones.set(t,e)),e}grid(t){let e=this.grids.get(t);return void 0===e&&(e=new Qd,this.grids.set(t,e)),e}zoneCount(){return this.zones.size}locCount(){let t=0;for(const e of this.zones.values())t+=e.totalLocs;return t}objCount(){let t=0;for(const e of this.zones.values())t+=e.totalObjs;return t}}class tf{static INTERVAL=10;static PREFERRED_PLAYERS=250;static PREFERRED_NPCS=255;static PREFERRED_VIEW_DISTANCE=15;npcs;players;loadedZones;activeZones;extendedInfo;appearances;forceViewDistance=!1;viewDistance=tf.PREFERRED_VIEW_DISTANCE;lastResize=0;constructor(){this.npcs=new Set,this.players=new Set,this.loadedZones=new Set,this.activeZones=new Set,this.extendedInfo=new Set,this.appearances=new Map}resize(){if(!this.forceViewDistance)return this.players.size>=tf.PREFERRED_PLAYERS?(this.viewDistance>1&&this.viewDistance--,void(this.lastResize=0)):void(++this.lastResize>=tf.INTERVAL&&(this.viewDistance=tf.PREFERRED_PLAYERS)break t;this.players.has(a.uid)||a.uid!==t&&(yield a)}}*getNearbyNpcs(t,e,r,i){t:for(const n of this.proximitySort(t,e,this.activeZones))for(const s of this.getNearby(Lm.getZoneIndex(n).getAllNpcsSafe(),t,e,r,i,15)){if(this.npcs.size>=tf.PREFERRED_NPCS)break t;this.npcs.has(s.nid)||(yield s)}}*getNearby(t,e,r,i,n,s){const a=i-48,o=i+48,h=n+48,l=n-48;for(const i of t)i.x<=a||i.x>=o||i.z>=h||i.z<=l||oh.isWithinDistanceSW({x:e,z:r},i,s)&&(yield i)}proximitySort(t,e,r){return Array.from(r.values()).map((r=>this.zoneToDistance(r,t,e))).sort(((t,e)=>t.distance-e.distance)).map((({zoneIndex:t})=>t))}zoneToDistance(t,e,r){const i=Jd.unpackIndex(t);return{zoneIndex:t,distance:Math.abs(i.x-e)+Math.abs(i.z-r)}}}function ef(t){for(let e=98;e>=0;e--)if(t>=nf[e])return Math.min(e+2,99);return 1}function rf(t){return nf[t-2]}var nf=new Int32Array(99),sf=0;for(let t=0;t<99;t++){const e=t+1;sf+=Math.floor(e+300*Math.pow(2,e/7)),nf[t]=10*Math.floor(sf/4)}class af extends Xl{static APPEARANCE=1;static ANIM=2;static FACE_ENTITY=4;static SAY=8;static DAMAGE=16;static FACE_COORD=32;static CHAT=64;static BIG_UPDATE=128;static SPOTANIM=256;static EXACT_MOVE=512;static SKILLS=['attack','defence','strength','hitpoints','ranged','prayer','magic','cooking','woodcutting','fletching','fishing','firemaking','crafting','smithing','mining','herblore','agility','thieving','stat18','stat19','runecraft'];static DESIGN_BODY_COLORS=[[6798,107,10283,16,4797,7744,5799,4634,33697,22433,2983,54193],[8741,12,64030,43162,7735,8404,1701,38430,24094,10153,56621,4783,1341,16578,35003,25239],[25238,8742,12,64030,43162,7735,8404,1701,38430,24094,10153,56621,4783,1341,16578,35003],[4626,11146,6439,12,4758,10270],[4550,4537,5681,5673,5790,6806,8076,4574]];save(){const t=as.alloc(1);t.p2(8196),t.p2(3),t.p2(this.x),t.p2(this.z),t.p1(this.level);for(let e=0;e<7;e++)t.p1(this.body[e]);for(let e=0;e<5;e++)t.p1(this.colors[e]);t.p1(this.gender),t.p2(this.runenergy),t.p4(this.playtime);for(let e=0;e<21;e++)t.p4(this.stats[e]),t.p1(this.levels[e]);t.p2(this.vars.length);for(let e=0;e=255?(t.p1(255),t.p4(r.count)):t.p1(r.count)):t.p2(0)}e++}}t.data[r]=e,t.p1(this.afkZones.length);for(let e=0;ee&&e.uid===t));if(-1!==r)return void(this.heroPoints[r].points+=e);const i=this.heroPoints.findIndex((t=>t&&-1===t.uid));-1===i||(this.heroPoints[i]={uid:t,points:e})}findHero(){return this.heroPoints.sort(((t,e)=>e.points-t.points)),this.heroPoints[0]?.uid??-1}resetEntity(t){t&&(this.faceX=-1,this.faceZ=-1,this.orientationX=-1,this.orientationZ=-1),super.resetPathingEntity(),this.repathed=!1,this.protect=!1,this.messageColor=null,this.messageEffect=null,this.messageType=null,this.message=null}onLogin(){this.playerLog('Logging in'),this.write(new ac),this.write(new oc(this.pid)),this.unsetMapFlag(),this.write(new hc),this.resetHeroPoints(),this.write(new lc);for(let t=0;t1){const t=Math.floor(this.runweight/1e3),e=67+67*Math.min(Math.max(t,0),64)/64|0;this.runenergy=Math.max(this.runenergy-e,0)}}recoverEnergy(t){if(!this.delayed()&&(!t||this.moveSpeed!==Zl.RUN)&&this.runenergy<1e4){const t=8+(this.baseLevels[uh.AGILITY]/9|0);this.runenergy=Math.min(this.runenergy+t,1e4)}}blockWalkFlag(){return qo.PLAYER}defaultMoveSpeed(){return this.getVar(Pa.PLAYER_RUN)?Zl.RUN:Zl.WALK}closeSticky(){if(-1!==this.modalSticky){const t=no.getByTrigger(Ll.IF_CLOSE,this.modalSticky);t&&this.enqueueScript(t,1),this.modalSticky=-1,this.write(new cc(-1))}}closeModal(){if(this.receivedFirstClose){if(this.weakQueue.clear(),this.delayed()||(this.protect=!1),0!==this.modalState){if(-1!==this.modalTop){const t=no.getByTrigger(Ll.IF_CLOSE,this.modalTop);t&&this.enqueueScript(t,1),this.modalTop=-1}if(-1!==this.modalBottom){const t=no.getByTrigger(Ll.IF_CLOSE,this.modalBottom);t&&this.enqueueScript(t,1),this.modalBottom=-1}if(-1!==this.modalSidebar){const t=no.getByTrigger(Ll.IF_CLOSE,this.modalSidebar);t&&this.enqueueScript(t,1),this.modalSidebar=-1}this.modalState=0,this.refreshModalClose=!0}}else this.receivedFirstClose=!0}delayed(){return this.delay>Lm.currentTick}containsModalInterface(){return!(1&~this.modalState&&2&~this.modalState&&16&~this.modalState)}busy(){return this.delayed()||this.containsModalInterface()}canAccess(){return!this.protect&&!this.busy()}enqueueScript(t,e=0,r=0,i=[]){const n=new jl(e,t,i,r);1===e?(n.delay=0,this.engineQueue.addTail(n)):2===e?this.weakQueue.addTail(n):this.queue.addTail(n)}processQueues(){let t=!1;for(let e=this.queue.head();null!==e;e=this.queue.next())if(3===e.type){t=!0;break}t&&this.closeModal(),this.processQueue(),this.processWeakQueue()}processQueue(){for(let t=this.queue.head();null!==t;t=this.queue.next()){3===t.type&&this.closeModal();const e=t.delay--;if(this.canAccess()&&e<=0){const e=om.init(t.script,this,null,t.args);this.executeScript(e,!0),t.unlink()}}}processWeakQueue(){for(let t=this.weakQueue.head();null!==t;t=this.weakQueue.next()){const e=t.delay--;if(this.canAccess()&&e<=0){const e=om.init(t.script,this,null,t.args);this.executeScript(e,!0),t.unlink()}}}setTimer(t,e,r=[],i){const n=e.id,s={type:t,script:e,args:r,interval:i,clock:i};this.timers.set(n,s)}clearTimer(t){this.timers.delete(t)}processTimers(t){for(const e of this.timers.values())if(t===e.type&&--e.clock<=0&&(1===e.type||this.canAccess())){e.clock=e.interval;const t=om.init(e.script,this,null,e.args);this.runScript(t,0===e.type)}}stopAction(){this.clearPendingAction(),this.unsetMapFlag()}clearPendingAction(){this.clearInteraction(),this.closeModal()}hasInteraction(){return null!==this.target}getOpTrigger(){if(!this.target)return null;let t=-1,e=-1;if(this.target instanceof hm||this.target instanceof Al||this.target instanceof fl){const r=this.target instanceof hm?fa.get(this.target.type):this.target instanceof Al?ta.get(this.target.type):Aa.get(this.target.type);t=r.id,e=r.category}return-1!==this.targetSubject.type&&(t=this.targetSubject.type),-1!==this.targetSubject.com&&(t=this.targetSubject.com),no.getByTrigger(this.targetOp+7,t,e)??null}getApTrigger(){if(!this.target)return null;let t=-1,e=-1;if(this.target instanceof hm||this.target instanceof Al||this.target instanceof fl){const r=this.target instanceof hm?fa.get(this.target.type):this.target instanceof Al?ta.get(this.target.type):Aa.get(this.target.type);t=r.id,e=r.category}return-1!==this.targetSubject.type&&(t=this.targetSubject.type),-1!==this.targetSubject.com&&(t=this.targetSubject.com),no.getByTrigger(this.targetOp,t,e)??null}processInteraction(){if(null===this.target||!this.canAccess())return void this.updateMovement();if(this.target.level!==this.level)return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof hm&&(void 0===Lm.getNpc(this.target.nid)||this.target.delayed()))return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof hm&&-1!==this.targetSubject.type&&null===Lm.getNpcByUid(this.targetSubject.type<<16|this.target.nid))return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof fl&&null===Lm.getObj(this.target.x,this.target.z,this.level,this.target.type,this.pid))return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof Al&&null===Lm.getLoc(this.target.x,this.target.z,this.level,this.target.type))return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof af&&null===Lm.getPlayerByUid(this.target.uid))return this.clearInteraction(),void this.unsetMapFlag();if(this.targetOp===Ll.APPLAYER3||this.targetOp===Ll.OPPLAYER3){return void(this.updateMovement(!1)&&(this.alreadyFacedEntity=!1,this.lastMovement=Lm.currentTick+1))}const t=this.getOpTrigger(),e=this.getApTrigger();if(t&&this.target instanceof Xl&&this.inOperableDistance(this.target)){const e=this.target;this.target=null,this.executeScript(om.init(t,this,e),!0),null===this.target&&this.unsetMapFlag(),this.interacted=!0,this.clearWaypoints()}else if(e&&this.inApproachDistance(this.apRange,this.target)){const t=this.target;this.target=null,this.executeScript(om.init(e,this,t),!0),this.apRangeCalled?this.target=t:(this.clearWaypoints(),this.interacted=!0),null===this.target&&this.unsetMapFlag()}else if(this.target instanceof Xl&&this.inOperableDistance(this.target)){if(Ea.NODE_DEBUG&&!t&&!e){let t='_';this.target instanceof hm?t=-1!==this.targetSubject.com&&this.targetOp===Ll.APNPCT||this.targetOp===Ll.OPNPCT?qs.get(this.targetSubject.com)?.comName??this.targetSubject.toString():fa.get(this.target.type)?.debugname??this.target.type.toString():this.target instanceof Al?t=ta.get(this.target.type)?.debugname??this.target.type.toString():this.target instanceof fl?t=Aa.get(this.target.type)?.debugname??this.target.type.toString():-1!==this.targetSubject.com&&this.targetOp===Ll.APNPCT||this.targetOp===Ll.APPLAYERT||this.targetOp===Ll.APLOCT||this.targetOp===Ll.APOBJT?t=qs.get(this.targetSubject.com)?.comName??this.targetSubject.toString():-1!==this.targetSubject.type&&(t=Aa.get(this.targetSubject.type)?.debugname??this.targetSubject.toString()),this.messageGame(`No trigger for [${Ll[this.targetOp+7].toLowerCase()},${t}]`)}this.target=null,this.messageGame('Nothing interesting happens.'),this.interacted=!0,this.clearWaypoints()}const r=this.updateMovement();if(r&&(this.alreadyFacedEntity=!1,this.lastMovement=Lm.currentTick+1),this.target&&(!this.interacted||this.apRangeCalled))if(this.interacted=!1,t&&(this.target instanceof Xl||!r)&&this.inOperableDistance(this.target)){const e=this.target;this.target=null,this.executeScript(om.init(t,this,e),!0),null===this.target&&this.unsetMapFlag(),this.interacted=!0,this.clearWaypoints()}else if(e&&this.inApproachDistance(this.apRange,this.target)){this.apRangeCalled=!1;const t=this.target;this.target=null,this.executeScript(om.init(e,this,t),!0),this.apRangeCalled?this.target=t:(this.clearWaypoints(),this.interacted=!0),null===this.target&&this.unsetMapFlag()}else if((this.target instanceof Xl||!r)&&this.inOperableDistance(this.target)){if(!Ea.NODE_PRODUCTION&&!t&&!e){let t='_';this.target instanceof hm?t=fa.get(this.target.type)?.debugname??this.target.type.toString():this.target instanceof Al?t=ta.get(this.target.type)?.debugname??this.target.type.toString():this.target instanceof fl?t=Aa.get(this.target.type)?.debugname??this.target.type.toString():-1!==this.targetSubject.com&&this.targetOp===Ll.APNPCT||this.targetOp===Ll.APPLAYERT||this.targetOp===Ll.APLOCT||this.targetOp===Ll.APOBJT?t=qs.get(this.targetSubject.com)?.comName??this.targetSubject.toString():-1!==this.targetSubject.type&&(t=Aa.get(this.targetSubject.type)?.debugname??this.targetSubject.toString()),this.messageGame(`No trigger for [${Ll[this.targetOp+7].toLowerCase()},${t}]`)}this.target=null,this.messageGame('Nothing interesting happens.'),this.interacted=!0,this.clearWaypoints()}if(!this.interactWalkTrigger&&-1!==this.walktrigger&&!this.protect&&!this.delayed()){const t=no.get(this.walktrigger);if(this.walktrigger=-1,t){const e=om.init(t,this);this.interactWalkTrigger=!0,this.unsetMapFlag(),this.runScript(e,!0)}}this.interacted||this.hasWaypoints()||r||(this.messageGame("I can't reach that!"),this.clearInteraction()),this.interacted&&!this.apRangeCalled&&null===this.target&&this.clearInteraction()}getAppearanceInSlot(t){let e=-1;return 8===t?e=this.body[0]:11===t?e=this.body[1]:4===t?e=this.body[2]:6===t?e=this.body[3]:9===t?e=this.body[4]:7===t?e=this.body[5]:10===t&&(e=this.body[6]),-1===e?0:256+e}getCombatLevel(){const t=.25*(this.baseLevels[uh.DEFENCE]+this.baseLevels[uh.HITPOINTS]+Math.floor(this.baseLevels[uh.PRAYER]/2)),e=.325*(this.baseLevels[uh.ATTACK]+this.baseLevels[uh.STRENGTH]),r=.325*(Math.floor(this.baseLevels[uh.RANGED]/2)+this.baseLevels[uh.RANGED]),i=.325*(Math.floor(this.baseLevels[uh.MAGIC]/2)+this.baseLevels[uh.MAGIC]);return Math.floor(t+Math.max(e,r,i))}generateAppearance(t){const e=as.alloc(0);e.p1(this.gender),e.p1(this.headicons);const r=[];let i=this.getInventory(t);i||(i=new co(Zs.WORN,0));for(let t=0;tr.type===t&&r.com===e)))return;Zs.get(t).scope===Zs.SCOPE_SHARED&&(r=-1),this.invListeners.push({type:t,com:e,source:r,firstSeen:!0})}invStopListenOnCom(t){const e=this.invListeners.findIndex((e=>e.com===t));-1!==e&&(this.invListeners.splice(e,1),this.write(new uc(t)))}invGetSlot(t,e){const r=this.getInventory(t);if(!r)throw new Error('invGetSlot: Invalid inventory type: '+t);if(!r.validSlot(e))throw new Error('invGetSlot: Invalid slot: '+e);return r.get(e)}invClear(t){const e=this.getInventory(t);if(!e)throw new Error('invClear: Invalid inventory type: '+t);e.removeAll()}invAdd(t,e,r,i=!0){const n=this.getInventory(t);if(!n)throw new Error('invAdd: Invalid inventory type: '+t);return n.add(e,r,-1,i).completed}invSet(t,e,r,i){const n=this.getInventory(t);if(!n)throw new Error('invSet: Invalid inventory type: '+t);if(!n.validSlot(i))throw new Error('invSet: Invalid slot: '+i);n.set(i,{id:e,count:r})}invDel(t,e,r,i=-1){const n=this.getInventory(t);if(!n)throw new Error('invDel: Invalid inventory type: '+t);if(i<-1||i>=this.invSize(t))throw new Error('invDel: Invalid beginSlot: '+i);return n.remove(e,r,i).completed}invDelSlot(t,e){const r=this.getInventory(t);if(!r)throw new Error('invDelSlot: Invalid inventory type: '+t);if(!r.validSlot(e))throw new Error('invDelSlot: Invalid slot: '+e);r.delete(e)}invSize(t){const e=this.getInventory(t);if(!e)throw new Error('invSize: Invalid inventory type: '+t);return e.capacity}invTotal(t,e){const r=this.getInventory(t);if(!r)throw new Error('invTotal: Invalid inventory type: '+t);return r.getItemCount(e)}invFreeSpace(t){const e=this.getInventory(t);if(!e)throw new Error('invFreeSpace: Invalid inventory type: '+t);return e.freeSlotCount}invItemSpace(t,e,r,i){const n=this.getInventory(t);if(!n)throw new Error('invItemSpace: Invalid inventory type: '+t);const s=Aa.get(e);let a=e;if(s.certtemplate>=0&&s.certlink>=0&&(a=s.certlink),s.stackable||a!=e||n.stackType==co.ALWAYS_STACK){const i=!0===Zs.get(t).stockobj?.includes(e);return 0!=this.invTotal(t,e)||0!=this.invFreeSpace(t)||i?Math.max(0,r-(co.STACK_LIMIT-this.invTotal(t,e))):r}return Math.max(0,r-(this.invFreeSpace(t)-(this.invSize(t)-i)))}invMoveToSlot(t,e,r,i){const n=this.getInventory(t);if(!n)throw new Error('invMoveToSlot: Invalid inventory type: '+t);if(!n.validSlot(r))throw new Error('invMoveToSlot: Invalid from slot: '+r);const s=this.getInventory(e);if(!s)throw new Error('invMoveToSlot: Invalid inventory type: '+e);if(!s.validSlot(i))throw new Error('invMoveToSlot: Invalid to slot: '+i);const a=this.invGetSlot(t,r);if(!a)throw new Error(`invMoveToSlot: Invalid from obj was null. This means the obj does not exist at this slot: ${r}`);const o=this.invGetSlot(e,i);this.invSet(e,a.id,a.count,i),o?this.invSet(t,o.id,o.count,r):this.invDelSlot(t,r)}invMoveFromSlot(t,e,r){const i=this.getInventory(t);if(!i)throw new Error('invMoveFromSlot: Invalid inventory type: '+t);if(!this.getInventory(e))throw new Error('invMoveFromSlot: Invalid inventory type: '+e);if(!i.validSlot(r))throw new Error('invMoveFromSlot: Invalid from slot: '+r);const n=this.invGetSlot(t,r);if(!n)throw new Error(`invMoveFromSlot: Invalid from obj was null. This means the obj does not exist at this slot: ${r}`);return this.invDelSlot(t,r),{overflow:n.count-this.invAdd(e,n.id,n.count,!1),fromObj:n.id}}invTotalCat(t,e){const r=this.getInventory(t);if(!r)throw new Error('invTotalCat: Invalid inventory type: '+t);return r.itemsFiltered.filter((t=>Aa.get(t.id).category==e)).reduce(((t,e)=>t+e.count),0)}_invTotalParam(t,e,r){const i=this.getInventory(t);if(!i)throw new Error('invTotalParam: Invalid inventory type: '+t);const n=ga.get(e);let s=0;for(let t=0;t=Aa.count)continue;const a=Aa.get(e.id),o=Qs(n.id,a,n.defaultInt);s+=r?e.count*o:o}return s}invTotalParam(t,e){return this._invTotalParam(t,e,!1)}invTotalParamStack(t,e){return this._invTotalParam(t,e,!0)}getVar(t){const e=Pa.get(t);return e.type===us.STRING?this.varsString[e.id]:this.vars[e.id]}setVar(t,e){const r=Pa.get(t);r.type===us.STRING&&'string'==typeof e?this.varsString[r.id]=e:'number'==typeof e&&(this.vars[r.id]=e,r.transmit&&this.writeVarp(t,e))}writeVarp(t,e){e>=-128&&e<=127?this.write(new dc(t,e)):this.write(new fc(t,e))}addXp(t,e){if(e<0)throw new Error(`Invalid xp parameter for addXp call: Stat was: ${t}, Exp was: ${e}`);if(0==e)return;const r=Number(Ea.NODE_XPRATE)||1;this.stats[t]+=e*r,this.stats[t]>2e9&&(this.stats[t]=2e9);const i=this.baseLevels[t];if(this.levels[t]===this.baseLevels[t]&&(this.levels[t]=ef(this.stats[t])),this.baseLevels[t]=ef(this.stats[t]),this.baseLevels[t]>i){this.levels[t]=Ia.count||this.animProtect||(-1==t||-1==this.animId||Ia.get(t).priority>Ia.get(this.animId).priority||0===Ia.get(this.animId).priority)&&(this.animId=t,this.animDelay=e,this.mask|=af.ANIM)}spotanim(t,e,r){this.graphicId=t,this.graphicHeight=e,this.graphicDelay=r,this.mask|=af.SPOTANIM}applyDamage(t,e){this.damageTaken=t,this.damageType=e;const r=this.levels[uh.HITPOINTS];r-t<=0?(this.levels[uh.HITPOINTS]=0,this.damageTaken=r):this.levels[uh.HITPOINTS]=r-t,this.mask|=af.DAMAGE}say(t){this.chat=t,this.mask|=af.SAY}faceSquare(t,e){this.faceX=2*t+1,this.faceZ=2*e+1,this.orientationX=this.faceX,this.orientationZ=this.faceZ,this.mask|=af.FACE_COORD}playSong(t){if(!(t=t.toLowerCase().replaceAll(' ','_')))return;const e=rc.get(t+'.mid'),r=ic.get(t+'.mid');if(e&&r){const i=e.length;this.write(new pc(t,r,i))}}playJingle(t,e){if(!(e=e.toLowerCase().replaceAll('_',' ')))return;const r=rc.get(e+'.mid');r&&this.write(new mc(t,r))}openMainModal(t){4&this.modalState&&(this.write(new ac),this.modalState&=-5,this.modalSidebar=-1),this.modalState|=1,this.modalTop=t,this.refreshModal=!0}openChat(t){this.modalState|=2,this.modalBottom=t,this.refreshModal=!0}openSideOverlay(t){this.modalState|=4,this.modalSidebar=t,this.refreshModal=!0}openChatSticky(t){this.write(new cc(t)),this.modalState|=8,this.modalSticky=t}openMainModalSideOverlay(t,e){this.modalState|=1,this.modalTop=t,this.modalState|=4,this.modalSidebar=e,this.refreshModal=!0}exactMove(t,e,r,i,n,s,a){this.exactStartX=t,this.exactStartZ=e,this.exactEndX=r,this.exactEndZ=i,this.exactMoveStart=n,this.exactMoveEnd=s,this.exactMoveDirection=a,this.mask|=af.EXACT_MOVE,this.x=r,this.z=i,this.lastStepX=this.x-1,this.lastStepZ=this.z}setTab(t,e){this.overlaySide[e]=t,this.write(new gc(t,e))}isComponentVisible(t){return this.modalTop===t.rootLayer||this.modalBottom===t.rootLayer||this.modalSidebar===t.rootLayer||-1!==this.overlaySide.findIndex((e=>e===t.rootLayer))||this.modalSticky===t.rootLayer}updateAfkZones(){if(this.lastAfkZone=Math.min(1e3,this.lastAfkZone+1),this.withinAfkZone())return;const t=oh.packCoord(0,this.x-10,this.z-10);this.moveSpeed===Zl.INSTANT&&this.jump?this.afkZones[1]=t:this.afkZones[1]=this.afkZones[0],this.afkZones[0]=t,this.lastAfkZone=0}zonesAfk(){return 1e3===this.lastAfkZone}withinAfkZone(){for(let t=0;t=2944&&this.x<3392&&this.z>=3520&&this.z<6400||this.x>=2944&&this.x<3392&&this.z>=9920&&this.z<12800}runScript(t,e=!1,r=!1){if(!r&&e&&(this.protect||this.delayed()))return-1;e&&(t.pointerAdd(eo.ProtectedActivePlayer),this.protect=!0);const i=om.execute(t);return e&&(this.protect=!1),t.pointerGet(eo.ProtectedActivePlayer)&&t._activePlayer&&(t.pointerRemove(eo.ProtectedActivePlayer),t._activePlayer.protect=!1),t.pointerGet(eo.ProtectedActivePlayer2)&&t._activePlayer2&&(t.pointerRemove(eo.ProtectedActivePlayer2),t._activePlayer2.protect=!1),i}executeScript(t,e=!1,r=!1){const i=this.runScript(t,e,r);-1!==i&&(i!==ho.FINISHED&&i!==ho.ABORTED?i===ho.WORLD_SUSPENDED?Lm.enqueueScript(t,t.popInt()):i===ho.NPC_SUSPENDED?t.activeNpc.activeScript=t:(t.activePlayer.activeScript=t,t.activePlayer.protect=e):t===this.activeScript&&(this.activeScript=null,1&this.modalState||this.closeModal()))}wrappedMessageGame(t){const e=Ms.get(1).split(t,456);for(const t of e)this.messageGame(t)}write(t){t.priority===sc.HIGH?this.highPriorityOut.push(t):this.lowPriorityOut.push(t)}unsetMapFlag(){this.clearWaypoints(),this.write(new yc)}hintNpc(t){this.write(new vc(1,t,0,0,0,0))}hintTile(t,e,r,i){this.write(new vc(t,0,0,e,r,i))}hintPlayer(t){this.write(new vc(10,0,t,0,0,0))}stopHint(){this.write(new vc(-1,0,0,0,0,0))}lastLoginInfo(t,e,r,i){this.write(new bc(t,e,r,i)),this.modalState|=16}logout(){}terminate(){}messageGame(t){this.write(new _c(t))}}class of{index;id;length;static all=[];static byId=[];static REBUILD_GETMAPS=new of(4,150,-1);static NO_TIMEOUT=new of(6,108,0);static IDLE_TIMER=new of(30,70,0);static EVENT_TRACKING=new of(34,81,-2);static EVENT_CAMERA_POSITION=new of(35,189,6);static ANTICHEAT_OPLOGIC1=new of(60,7,4);static ANTICHEAT_OPLOGIC2=new of(61,88,4);static ANTICHEAT_OPLOGIC3=new of(62,30,3);static ANTICHEAT_OPLOGIC4=new of(63,176,2);static ANTICHEAT_OPLOGIC5=new of(64,220,0);static ANTICHEAT_OPLOGIC6=new of(65,66,4);static ANTICHEAT_OPLOGIC7=new of(66,17,4);static ANTICHEAT_OPLOGIC8=new of(67,2,2);static ANTICHEAT_OPLOGIC9=new of(68,238,1);static ANTICHEAT_CYCLELOGIC1=new of(70,233,1);static ANTICHEAT_CYCLELOGIC2=new of(71,146,-1);static ANTICHEAT_CYCLELOGIC3=new of(74,215,3);static ANTICHEAT_CYCLELOGIC4=new of(72,236,4);static ANTICHEAT_CYCLELOGIC5=new of(75,85,0);static ANTICHEAT_CYCLELOGIC6=new of(73,219,-1);static OPOBJ1=new of(80,140,6);static OPOBJ2=new of(81,40,6);static OPOBJ3=new of(82,200,6);static OPOBJ4=new of(83,178,6);static OPOBJ5=new of(84,247,6);static OPOBJT=new of(88,138,8);static OPOBJU=new of(89,239,12);static OPNPC1=new of(100,194,2);static OPNPC2=new of(101,8,2);static OPNPC3=new of(102,27,2);static OPNPC4=new of(103,113,2);static OPNPC5=new of(104,100,2);static OPNPCT=new of(108,134,4);static OPNPCU=new of(109,202,8);static OPLOC1=new of(120,245,6);static OPLOC2=new of(121,172,6);static OPLOC3=new of(122,96,6);static OPLOC4=new of(123,97,6);static OPLOC5=new of(124,116,6);static OPLOCT=new of(128,9,8);static OPLOCU=new of(129,75,12);static OPPLAYER1=new of(140,164,2);static OPPLAYER2=new of(141,53,2);static OPPLAYER3=new of(142,185,2);static OPPLAYER4=new of(143,206,2);static OPPLAYERT=new of(148,177,4);static OPPLAYERU=new of(149,248,8);static OPHELD1=new of(160,195,6);static OPHELD2=new of(161,71,6);static OPHELD3=new of(162,133,6);static OPHELD4=new of(163,157,6);static OPHELD5=new of(164,211,6);static OPHELDT=new of(168,48,8);static OPHELDU=new of(169,130,12);static INV_BUTTON1=new of(190,31,6);static INV_BUTTON2=new of(191,59,6);static INV_BUTTON3=new of(192,212,6);static INV_BUTTON4=new of(193,38,6);static INV_BUTTON5=new of(194,6,6);static IF_BUTTON=new of(200,155,2);static RESUME_PAUSEBUTTON=new of(201,235,2);static CLOSE_MODAL=new of(202,231,0);static RESUME_P_COUNTDIALOG=new of(203,237,4);static TUTORIAL_CLICKSIDE=new of(204,175,1);static MOVE_OPCLICK=new of(242,93,-1);static BUG_REPORT=new of(243,190,10);static MOVE_MINIMAPCLICK=new of(244,165,-1);static INV_BUTTOND=new of(245,159,6);static IGNORELIST_DEL=new of(246,171,8);static IGNORELIST_ADD=new of(247,79,8);static IF_PLAYERDESIGN=new of(248,52,13);static CHAT_SETMODE=new of(249,244,3);static MESSAGE_PRIVATE=new of(250,148,-1);static FRIENDLIST_DEL=new of(251,11,8);static FRIENDLIST_ADD=new of(252,118,8);static CLIENT_CHEAT=new of(253,4,-1);static MESSAGE_PUBLIC=new of(254,158,-1);static MOVE_GAMECLICK=new of(255,181,-1);constructor(t,e,r){this.index=t,this.id=e,this.length=r,of.all[t]=this,of.byId[e]=this}}class hf{}class lf{}class cf{id;limit;static CLIENT_EVENT=new cf(0,20);static USER_EVENT=new cf(1,5);constructor(t,e){this.id=t,this.limit=e}}class uf extends lf{input;category=cf.USER_EVENT;constructor(t){super(),this.input=t}}class df extends hf{prot=of.CLIENT_CHEAT;decode(t){const e=t.gjstr();return new uf(e)}}class ff extends lf{category=cf.USER_EVENT}class pf extends hf{prot=of.CLOSE_MODAL;decode(){return new ff}}class mf extends lf{category=cf.CLIENT_EVENT}class gf extends hf{prot=of.IDLE_TIMER;decode(){return new mf}}class yf extends lf{component;category=cf.USER_EVENT;constructor(t){super(),this.component=t}}class vf extends hf{prot=of.IF_BUTTON;decode(t){const e=t.g2();return new yf(e)}}class bf extends lf{gender;idkit;color;category=cf.USER_EVENT;constructor(t,e,r){super(),this.gender=t,this.idkit=e,this.color=r}}class _f extends hf{prot=of.IF_PLAYERDESIGN;decode(t){const e=t.g1(),r=[];for(let e=0;e<7;e++)r[e]=t.g1(),255===r[e]&&(r[e]=-1);const i=[];for(let e=0;e<5;e++)i[e]=t.g1();return new bf(e,r,i)}}class wf extends lf{op;obj;slot;component;category=cf.USER_EVENT;constructor(t,e,r,i){super(),this.op=t,this.obj=e,this.slot=r,this.component=i}}class Ef extends hf{prot;op;constructor(t,e){super(),this.prot=t,this.op=e}decode(t){const e=t.g2(),r=t.g2(),i=t.g2();return new wf(this.op,e,r,i)}}class Af extends lf{component;slot;targetSlot;category=cf.USER_EVENT;constructor(t,e,r){super(),this.component=t,this.slot=e,this.targetSlot=r}}class Sf extends hf{prot=of.INV_BUTTOND;decode(t){const e=t.g2(),r=t.g2(),i=t.g2();return new Af(e,r,i)}}class Tf extends lf{username;input;category=cf.USER_EVENT;constructor(t,e){super(),this.username=t,this.input=e}}class Mf extends hf{prot=of.MESSAGE_PRIVATE;decode(t){const e=t.g8(),r=ed.unpack(t,t.length-8);return new Tf(e,r)}}class If extends lf{input;color;effect;category=cf.USER_EVENT;constructor(t,e,r){super(),this.input=t,this.color=e,this.effect=r}}class Cf extends hf{prot=of.MESSAGE_PUBLIC;decode(t){const e=t.g1(),r=t.g1(),i=ed.unpack(t,t.length-2);return new If(i,e,r)}}class Of extends lf{op;obj;slot;component;category=cf.USER_EVENT;constructor(t,e,r,i){super(),this.op=t,this.obj=e,this.slot=r,this.component=i}}class Nf extends hf{prot;op;constructor(t,e){super(),this.prot=t,this.op=e}decode(t){const e=t.g2(),r=t.g2(),i=t.g2();return new Of(this.op,e,r,i)}}class Lf extends lf{obj;slot;component;spellComponent;category=cf.USER_EVENT;constructor(t,e,r,i){super(),this.obj=t,this.slot=e,this.component=r,this.spellComponent=i}}class Rf extends hf{prot=of.OPHELDT;decode(t){const e=t.g2(),r=t.g2(),i=t.g2(),n=t.g2();return new Lf(e,r,i,n)}}class Pf extends lf{obj;slot;component;useObj;useSlot;useComponent;category=cf.USER_EVENT;constructor(t,e,r,i,n,s){super(),this.obj=t,this.slot=e,this.component=r,this.useObj=i,this.useSlot=n,this.useComponent=s}}class Bf extends hf{prot=of.OPHELDU;decode(t){const e=t.g2(),r=t.g2(),i=t.g2(),n=t.g2(),s=t.g2(),a=t.g2();return new Pf(e,r,i,n,s,a)}}class kf extends lf{op;x;z2;loc;category=cf.USER_EVENT;constructor(t,e,r,i){super(),this.op=t,this.x=e,this.z=r,this.loc=i}}class Df extends hf{prot;op;constructor(t,e){super(),this.prot=t,this.op=e}decode(t){const e=t.g2(),r=t.g2(),i=t.g2();return new kf(this.op,e,r,i)}}class Uf extends lf{x;z2;loc;spellComponent;category=cf.USER_EVENT;constructor(t,e,r,i){super(),this.x=t,this.z=e,this.loc=r,this.spellComponent=i}}class xf extends hf{prot=of.OPLOCT;decode(t){const e=t.g2(),r=t.g2(),i=t.g2(),n=t.g2();return new Uf(e,r,i,n)}}class Ff extends lf{x;z2;loc;useObj;useSlot;useComponent;category=cf.USER_EVENT;constructor(t,e,r,i,n,s){super(),this.x=t,this.z=e,this.loc=r,this.useObj=i,this.useSlot=n,this.useComponent=s}}class Hf extends hf{prot=of.OPLOCU;decode(t){const e=t.g2(),r=t.g2(),i=t.g2(),n=t.g2(),s=t.g2(),a=t.g2();return new Ff(e,r,i,n,s,a)}}class jf extends lf{op;nid;category=cf.USER_EVENT;constructor(t,e){super(),this.op=t,this.nid=e}}class Vf extends hf{prot;op;constructor(t,e){super(),this.prot=t,this.op=e}decode(t){const e=t.g2();return new jf(this.op,e)}}class Gf extends lf{nid;spellComponent;category=cf.USER_EVENT;constructor(t,e){super(),this.nid=t,this.spellComponent=e}}class zf extends hf{prot=of.OPNPCT;decode(t){const e=t.g2(),r=t.g2();return new Gf(e,r)}}class Wf extends lf{nid;useObj;useSlot;useComponent;category=cf.USER_EVENT;constructor(t,e,r,i){super(),this.nid=t,this.useObj=e,this.useSlot=r,this.useComponent=i}}class Kf extends hf{prot=of.OPNPCU;decode(t){const e=t.g2(),r=t.g2(),i=t.g2(),n=t.g2();return new Wf(e,r,i,n)}}class qf extends lf{op;x;z2;obj;category=cf.USER_EVENT;constructor(t,e,r,i){super(),this.op=t,this.x=e,this.z=r,this.obj=i}}class Yf extends hf{prot;op;constructor(t,e){super(),this.prot=t,this.op=e}decode(t){const e=t.g2(),r=t.g2(),i=t.g2();return new qf(this.op,e,r,i)}}class Zf extends lf{x;z2;obj;spellComponent;category=cf.USER_EVENT;constructor(t,e,r,i){super(),this.x=t,this.z=e,this.obj=r,this.spellComponent=i}}class $f extends hf{prot=of.OPOBJT;decode(t){const e=t.g2(),r=t.g2(),i=t.g2(),n=t.g2();return new Zf(e,r,i,n)}}class Xf extends lf{x;z2;obj;useObj;useSlot;useComponent;category=cf.USER_EVENT;constructor(t,e,r,i,n,s){super(),this.x=t,this.z=e,this.obj=r,this.useObj=i,this.useSlot=n,this.useComponent=s}}class Qf extends hf{prot=of.OPOBJU;decode(t){const e=t.g2(),r=t.g2(),i=t.g2(),n=t.g2(),s=t.g2(),a=t.g2();return new Xf(e,r,i,n,s,a)}}class Jf extends lf{op;pid;category=cf.USER_EVENT;constructor(t,e){super(),this.op=t,this.pid=e}}class tp extends hf{prot;op;constructor(t,e){super(),this.prot=t,this.op=e}decode(t){const e=t.g2();return new Jf(this.op,e)}}class ep extends lf{pid;spellComponent;category=cf.USER_EVENT;constructor(t,e){super(),this.pid=t,this.spellComponent=e}}class rp extends hf{prot=of.OPPLAYERT;decode(t){const e=t.g2(),r=t.g2();return new ep(e,r)}}class ip extends lf{pid;useObj;useSlot;useComponent;category=cf.USER_EVENT;constructor(t,e,r,i){super(),this.pid=t,this.useObj=e,this.useSlot=r,this.useComponent=i}}class np extends hf{prot=of.OPPLAYERU;decode(t){const e=t.g2(),r=t.g2(),i=t.g2(),n=t.g2();return new ip(e,r,i,n)}}class sp extends lf{maps2;category=cf.USER_EVENT;constructor(t){super(),this.maps=t}}class ap extends hf{prot=of.REBUILD_GETMAPS;decode(t){const e=[],r=t.length/3;for(let i=0;it.com===s));if(!o)return!1;const h=e.getInventoryFromListener(o);if(!h||!h.validSlot(n)||!h.hasAt(n,i))return!1;if(e.delayed())return!1;let l;e.lastItem=i,e.lastSlot=n,l=1===r?Ll.INV_BUTTON1:2===r?Ll.INV_BUTTON2:3===r?Ll.INV_BUTTON3:4===r?Ll.INV_BUTTON4:Ll.INV_BUTTON5;const c=no.getByTrigger(l,s,-1);if(c){const t=qs.get(a.rootLayer);e.executeScript(om.init(c,e),0==t.overlay)}else Ea.NODE_DEBUG&&e.messageGame(`No trigger for [${Ll.toString(l)},${a.comName}]`);return!0}}class mp{static TCP=0;static WEBSOCKET=1;socket=null;type=-1;state=-1;remoteAddress;totalBytesRead=0;totalBytesWritten=0;uniqueId='undefined'!=typeof self?'https:'===self.location.protocol?self.crypto.randomUUID():'0':Bi();encryptor=null;decryptor=null;in=new Uint8Array(5e3);inOffset=0;inCount=new Uint8Array(256);out=new as(new Uint8Array(5e3));player=null;constructor(t,e,r=mp.TCP,i=-1){this.socket=t,this.remoteAddress=e,this.type=r,this.state=i}isTCP(){return this.type===mp.TCP}isWebSocket(){return this.type===mp.WEBSOCKET}send(t){if('undefined'!=typeof self)this.totalBytesWritten+=t.length,self.postMessage(t);else{if(!this.socket)return;this.totalBytesWritten+=t.length,this.isTCP()?this.socket.write(t):this.isWebSocket()&&this.socket.send(t)}}close(){if('undefined'!=typeof self)setTimeout((()=>{self.close()}),100);else{if(!this.socket)return;setTimeout((()=>{this.isTCP()?this.socket.end():this.isWebSocket()&&this.socket.close()}),100)}}terminate(){if('undefined'!=typeof self)self.close();else{if(!this.socket)return;this.isTCP()?this.socket.destroy():this.isWebSocket()&&this.socket.terminate()}}reset(){this.inOffset=0,this.inCount.fill(0)}writeImmediate(t){this.send(t)}flush(){const t=this.out;0!==t.pos&&(this.send(t.data.subarray(0,t.pos)),t.pos=0)}}class gp extends mp{constructor(){super(null,'')}isTCP(){return this.type===mp.TCP}isWebSocket(){return this.type===mp.WEBSOCKET}send(t){this.socket}close(){this.socket}terminate(){this.socket}reset(){this.inOffset=0,this.inCount.fill(0)}}var{default:yp}=()=>({});class vp{static loadFromFile(t){const e=$n(Zn(t));let r;return r=yp.existsSync(`data/players/${e}.sav`)?as.load(`data/players/${e}.sav`):new as(new Uint8Array),vp.load(t,r,null)}static load(t,e,r){const i=Zn(t),n=$n(i),s=r?new Xp(n,i,r):new af(n,i);if(Ea.NODE_PRODUCTION?void 0!==Ea.NODE_STAFF.find((t=>t===n))&&(s.staffModLevel=3):s.staffModLevel=3,e.data.length<2){for(let t=0;t<21;t++)s.stats[t]=0,s.baseLevels[t]=1,s.levels[t]=1;return s.stats[uh.HITPOINTS]=rf(10),s.baseLevels[uh.HITPOINTS]=10,s.levels[uh.HITPOINTS]=10,s}if(8196!==e.g2())throw new Error('Invalid player save');const a=e.g2();if(a>3)throw new Error('Unsupported player save format');e.pos=e.data.length-4;if(e.g4()!=as.getcrc(e.data,0,e.data.length-4))throw new Error('Player save corrupted');e.pos=4,s.x=e.g2(),s.z=e.g2(),s.level=e.g1();for(let t=0;t<7;t++)s.body[t]=e.g1(),255===s.body[t]&&(s.body[t]=-1);for(let t=0;t<5;t++)s.colors[t]=e.g1();s.gender=e.g1(),s.runenergy=e.g2(),s.playtime=a>=2?e.g4():e.g2();for(let t=0;t<21;t++)s.stats[t]=e.g4(),s.baseLevels[t]=ef(s.stats[t]),s.levels[t]=e.g1();const o=e.g2();for(let t=0;t=3){const t=e.g1();for(let r=0;r80)return!1;const{input:r}=t,i=r.toLowerCase().split(' '),n=i.shift();if(void 0===n||n.length<=0)return!1;if(e.playerLog('Cheat ran',r),e.staffModLevel>=3)if('reload'!==n||'undefined'!=typeof self||Ea.NODE_PRODUCTION)if('rebuild'!==n||Ea.NODE_PRODUCTION){if('serverdrop'===n)e.terminate();else if('bench'===n){const t=Date.now();for(let t=0;t<1e5;t++)go(e.level,e.x,e.z,e.x,e.z+10);const r=Date.now();console.log(`took = ${r-t} ms`)}else if('bots'===n){e.messageGame('Adding bots');for(let t=0;t<1999;t++){const e=vp.load(`bot${t}`,new as(new Uint8Array),new gp);Lm.addPlayer(e)}}else if('lightbots'===n){e.messageGame('Adding lightweight bots');for(let t=0;t<1999;t++){const e=vp.load(`bot${t}`,new as(new Uint8Array),null);Lm.addPlayer(e)}}else if('teleall'===n){e.messageGame('Teleporting all players');for(const t of Lm.players){t.closeModal();do{const e=Math.floor(64*Math.random())+3200,r=Math.floor(64*Math.random())+3200;t.teleJump(e+Math.floor(64*Math.random())-32,r+Math.floor(64*Math.random())-32,0)}while(Io(t.x,t.z,t.level,qo.WALK_BLOCKED))}}else if('moveall'===n){e.messageGame('Moving all players'),console.time('moveall');for(const t of Lm.players)t.closeModal(),t.queueWaypoints(go(t.level,t.x,t.z,32+(t.x>>>6<<6),32+(t.z>>>6<<6)));console.timeEnd('moveall')}else if('speed'===n){if(i.length<1)return e.messageGame('Usage: ::speed '),!1;const t=va(i.shift(),20);if(t<20)return e.messageGame('::speed input was too low.'),!1;e.messageGame(`World speed was changed to ${t}ms`),Lm.tickRate=t}else if('fly'===n)e.moveStrategy===$l.FLY?e.moveStrategy=$l.SMART:e.moveStrategy=$l.FLY,e.messageGame(`Fly is on? ${e.moveStrategy===$l.FLY}`);else if('naive'===n)e.moveStrategy===$l.NAIVE?e.moveStrategy=$l.SMART:e.moveStrategy=$l.NAIVE,e.messageGame(`Naive is on? ${e.moveStrategy===$l.NAIVE}`);else if('teleto'===n){if(i.length<1)return!1;const t=Lm.getPlayerByUsername(i[0]);if(!t)return e.messageGame(`${i[0]} is not logged in.`),!1;e.teleJump(t.x,t.z,t.level)}else if('teleother'===n){if(i.length<1)return!1;const t=Lm.getPlayerByUsername(i[0]);if(!t)return e.messageGame(`${i[0]} is not logged in.`),!1;t.teleJump(e.x,e.z,e.level)}else if('setvarother'===n){if(i.length<3)return!1;const t=Lm.getPlayerByUsername(i[0]);if(!t)return e.messageGame(`${i[0]} is not logged in.`),!1;const r=Pa.getId(i[1]),n=Math.max(-2147483648,Math.min(va(i[2],0),2147483647));if(-1===r)return!1;t.setVar(r,n),e.messageGame('set '+i[1]+': to '+n+' on '+t.username)}else if('shutdown'===n){if(i.length<1)return!1;Lm.rebootTimer(va(i[0],50))}}else Lm.devThread.postMessage({type:'pack'});else{Lm.reload();const t=no.load('data/pack');e.messageGame(`Reloaded ${t} scripts.`)}if(Ea.NODE_ALLOW_CHEATS||e.staffModLevel>=2)if('tele'===n){if(i.length<1)return!1;if('up'===i[0])e.teleJump(e.x,e.z,e.level+1),e.messageGame('::tele '+oh.formatString(e.level,e.x,e.z,','));else if('down'===i[0])e.teleJump(e.x,e.z,e.level-1),e.messageGame('::tele '+oh.formatString(e.level,e.x,e.z,','));else if(-1===i[0].indexOf(','))e.teleJump(va(i[0],3200),va(i[1],3200),va(i[2],e.level));else{const t=i[0].split(',');if(5!==t.length)return!1;const r=va(t[0],0),n=va(t[1],50),s=va(t[2],50),a=va(t[3],0),o=va(t[4],0);if(r<0||r>3||n<0||n>255||s<0||s>255||a<0||a>63||o<0||o>63)return!1;e.teleJump((n<<6)+a,(s<<6)+o,r)}}else if('setvar'===n){if(i.length<2)return!1;const t=Pa.getId(i[0]),r=Math.max(-2147483648,Math.min(va(i[1],0),2147483647));if(-1===t)return!1;e.setVar(t,r),e.messageGame('set '+i[0]+': to '+r)}else if('random'===n)e.afkEventReady=!0;else if('minme'===n)for(let t=0;t '),!1;const t=af.SKILLS.indexOf(i[0]);if(-1===t)return e.messageGame(`Unknown stat ${i[0]}`),!1;const r=10*parseInt(i[1]);e.stats[t]=r}else if('setstat'===n){if(i.length<2)return!1;const t=af.SKILLS.indexOf(i[0]);if(-1===t)return!1;e.setLevel(t,parseInt(i[1]))}else if('advancestat'===n){if(i.length<1)return!1;const t=af.SKILLS.indexOf(i[0]),r=Math.min(99,Math.max(1,va(i[1],1)));if(-1===t)return!1;e.setLevel(t,e.baseLevels[t]+r)}else if('getvar'===n){if(i.length<1)return!1;const t=Pa.getId(i[0]);if(-1===t)return!1;const r=e.getVar(t);e.messageGame('get '+i[0]+': '+r)}else if('give'===n){if(i.length<1)return!1;const t=Aa.getId(i[0]),r=Math.max(1,Math.min(va(i[1],1),2147483647));if(-1===t)return!1;e.invAdd(Zs.INV,t,r,!1)}if((Ea.NODE_ALLOW_CHEATS||e.staffModLevel>=1)&&'getcoord'===n&&e.messageGame(oh.formatString(e.level,e.x,e.z,'_')),Ea.NODE_ALLOW_CHEATS||e.staffModLevel>=2){const t=no.getByName(`[debugproc,${n}]`);if(!t)return!1;const s=new Array(t.info.parameterTypes.length).fill(-1);for(let e=0;e1)return!1;let s=!0;for(let t=0;t<7;t++){let e=t;if(1===r&&(e+=7),8==e&&-1===i[t])continue;const n=Ws.get(i[t]);if(!n||n.disable||n.type!=e){s=!1;break}}if(!s)return!1;for(let t=0;t<5;t++)if(n[t]>=af.DESIGN_BODY_COLORS[t].length){s=!1;break}return!!s&&(e.gender=r,e.body=i,e.colors=n,e.generateAppearance(Zs.WORN),!0)}}class Sp extends fp{handle(t,e){const{component:r,slot:i,targetSlot:n}=t,s=qs.get(r);if(void 0===s||!e.isComponentVisible(s))return!1;const a=e.invListeners.find((t=>t.com===r));if(!a)return!1;const o=e.getInventoryFromListener(a);if(!(o&&o.validSlot(i)&&o.get(i)&&o.validSlot(n)))return!1;if(e.delayed())return e.write(new Cd(r,o,i,n)),!1;e.lastSlot=i,e.lastTargetSlot=n;const h=no.getByTrigger(Ll.INV_BUTTOND,r);if(h){const t=qs.get(s.rootLayer);e.executeScript(om.init(h,e),0==t.overlay)}else Ea.NODE_DEBUG&&e.messageGame(`No trigger for [inv_buttond,${s.comName}]`);return!0}}class Tp extends fp{handle(t,e){return!0}}class Mp extends fp{handle(t,e){const{color:r,effect:i,input:n}=t;if(r<0||r>11||i<0||i>2||n.length>100)return!1;e.messageColor=r,e.messageEffect=i,e.messageType=0;const s=as.alloc(0);return ed.pack(s,ja.filter(n)),e.message=new Uint8Array(s.pos),s.pos=0,s.gdata(e.message,0,e.message.length),s.release(),e.mask|=af.CHAT,!0}}class Ip extends fp{handle(t,e){const{obj:r,slot:i,component:n}=t,s=qs.get(n);if(void 0===s||!e.isComponentVisible(s))return!1;const a=Aa.get(r);if(5!==t.op&&(a.iop&&!a.iop[t.op-1]||!a.iop))return!1;const o=e.invListeners.find((t=>t.com===n));if(!o)return!1;const h=e.getInventoryFromListener(o);if(!h||!h.validSlot(i)||!h.hasAt(i,r))return!1;if(e.delayed())return!1;let l;e.lastItem=r,e.lastSlot=i,e.clearInteraction(),e.closeModal(),l=1===t.op?Ll.OPHELD1:2===t.op?Ll.OPHELD2:3===t.op?Ll.OPHELD3:4===t.op?Ll.OPHELD4:Ll.OPHELD5;const c=no.getByTrigger(l,a.id,a.category);return c?e.executeScript(om.init(c,e),!0):Ea.NODE_DEBUG&&e.messageGame(`No trigger for [${Ll.toString(l)},${a.debugname}]`),!0}}class Cp extends fp{handle(t,e){const{obj:r,slot:i,component:n,spellComponent:s}=t,a=qs.get(n);if(void 0===a||!e.isComponentVisible(a))return e.unsetMapFlag(),!1;const o=qs.get(n);if(void 0===o||!e.isComponentVisible(o))return e.unsetMapFlag(),!1;const h=e.invListeners.find((t=>t.com===n));if(!h)return e.unsetMapFlag(),!1;const l=e.getInventoryFromListener(h);if(!l||!l.validSlot(i)||!l.hasAt(i,r))return e.unsetMapFlag(),!1;if(e.delayed())return e.unsetMapFlag(),!1;e.lastItem=r,e.lastSlot=i,e.clearInteraction(),e.closeModal();const c=no.getByTrigger(Ll.OPHELDT,s,-1);return c?e.executeScript(om.init(c,e),!0):(Ea.NODE_DEBUG&&e.messageGame(`No trigger for [opheldt,${o.comName}]`),e.messageGame('Nothing interesting happens.')),!0}}class Op extends fp{handle(t,e){const{obj:r,slot:i,component:n,useObj:s,useSlot:a,useComponent:o}=t,h=qs.get(n);if(void 0===h||!e.isComponentVisible(h))return e.unsetMapFlag(),!1;const l=qs.get(n);if(void 0===l||!e.isComponentVisible(l))return e.unsetMapFlag(),!1;{const t=e.invListeners.find((t=>t.com===n));if(!t)return e.unsetMapFlag(),!1;const s=e.getInventoryFromListener(t);if(!s||!s.validSlot(i)||!s.hasAt(i,r))return e.unsetMapFlag(),!1}{const t=e.invListeners.find((t=>t.com===o));if(!t)return e.unsetMapFlag(),!1;const r=e.getInventoryFromListener(t);if(!r||!r.validSlot(a)||!r.hasAt(a,s))return e.unsetMapFlag(),!1}if(e.delayed())return e.unsetMapFlag(),!1;e.lastItem=r,e.lastSlot=i,e.lastUseItem=s,e.lastUseSlot=a;const c=Aa.get(e.lastItem),u=Aa.get(e.lastUseItem);if((c.members||u.members)&&!Ea.NODE_MEMBERS)return e.messageGame("To use this item please login to a members' server."),e.unsetMapFlag(),!1;let d=no.getByTriggerSpecific(Ll.OPHELDU,c.id,-1);d||(d=no.getByTriggerSpecific(Ll.OPHELDU,u.id,-1),[e.lastItem,e.lastUseItem]=[e.lastUseItem,e.lastItem],[e.lastSlot,e.lastUseSlot]=[e.lastUseSlot,e.lastSlot]);const f=-1!==c.category?hs.get(c.category):null;!d&&f&&(d=no.getByTriggerSpecific(Ll.OPHELDU,-1,f.id));const p=-1!==u.category?hs.get(u.category):null;return!d&&p&&(d=no.getByTriggerSpecific(Ll.OPHELDU,-1,p.id),[e.lastItem,e.lastUseItem]=[e.lastUseItem,e.lastItem],[e.lastSlot,e.lastUseSlot]=[e.lastUseSlot,e.lastSlot]),e.clearInteraction(),e.closeModal(),d?e.executeScript(om.init(d,e),!0):(Ea.NODE_DEBUG&&e.messageGame(`No trigger for [opheldu,${c.debugname}]`),e.messageGame('Nothing interesting happens.')),!0}}class Np extends fp{handle(t,e){const{x:r,z:i,loc:n}=t;if(e.delayed())return e.unsetMapFlag(),!1;const s=e.originX-52,a=e.originX+52,o=e.originZ+52,h=e.originZ-52;if(ra||io)return!1;const l=Lm.getLoc(r,i,e.level,n);if(!l)return e.unsetMapFlag(),!1;const c=ta.get(l.type);if(!c.op||!c.op[t.op-1])return e.unsetMapFlag(),!1;let u;return u=1===t.op?Ll.APLOC1:2===t.op?Ll.APLOC2:3===t.op?Ll.APLOC3:4===t.op?Ll.APLOC4:Ll.APLOC5,e.clearPendingAction(),e.setInteraction(Rl.ENGINE,l,u),e.opcalled=!0,!0}}class Lp extends fp{handle(t,e){const{x:r,z:i,loc:n,spellComponent:s}=t;if(e.delayed())return e.unsetMapFlag(),!1;const a=qs.get(s);if(void 0===a||!e.isComponentVisible(a))return e.unsetMapFlag(),!1;const o=e.originX-52,h=e.originX+52,l=e.originZ+52,c=e.originZ-52;if(rh||il)return e.unsetMapFlag(),!1;const u=Lm.getLoc(r,i,e.level,n);return u?(e.clearPendingAction(),e.setInteraction(Rl.ENGINE,u,Ll.APLOCT,{type:u.type,com:s}),e.opcalled=!0,!0):(e.unsetMapFlag(),!1)}}class Rp extends fp{handle(t,e){const{x:r,z:i,loc:n,useObj:s,useSlot:a,useComponent:o}=t;if(e.delayed())return e.unsetMapFlag(),!1;const h=qs.get(o);if(void 0===h||!e.isComponentVisible(h))return e.unsetMapFlag(),!1;const l=e.originX-52,c=e.originX+52,u=e.originZ+52,d=e.originZ-52;if(rc||iu)return e.unsetMapFlag(),!1;const f=e.invListeners.find((t=>t.com===o));if(!f)return e.unsetMapFlag(),!1;const p=e.getInventoryFromListener(f);if(!p||!p.validSlot(a)||!p.hasAt(a,s))return e.unsetMapFlag(),!1;const m=Lm.getLoc(r,i,e.level,n);return m?Aa.get(s).members&&!Ea.NODE_MEMBERS?(e.messageGame("To use this item please login to a members' server."),e.unsetMapFlag(),!1):(e.lastUseItem=s,e.lastUseSlot=a,e.clearPendingAction(),e.setInteraction(Rl.ENGINE,m,Ll.APLOCU),e.opcalled=!0,!0):(e.unsetMapFlag(),!1)}}class Pp extends fp{handle(t,e){const{nid:r}=t;if(e.delayed())return e.unsetMapFlag(),!1;const i=Lm.getNpc(r);if(!i||i.delayed())return e.unsetMapFlag(),!1;if(!e.buildArea.npcs.has(i.nid))return e.unsetMapFlag(),!1;const n=fa.get(i.type);if(!n.op||!n.op[t.op-1])return e.unsetMapFlag(),!1;let s;return s=1===t.op?Ll.APNPC1:2===t.op?Ll.APNPC2:3===t.op?Ll.APNPC3:4===t.op?Ll.APNPC4:Ll.APNPC5,e.clearPendingAction(),e.setInteraction(Rl.ENGINE,i,s,{type:i.type,com:-1}),e.opcalled=!0,!0}}class Bp extends fp{handle(t,e){const{nid:r,spellComponent:i}=t;if(e.delayed())return e.unsetMapFlag(),!1;const n=qs.get(i);if(void 0===n||!e.isComponentVisible(n))return e.unsetMapFlag(),!1;const s=Lm.getNpc(r);return!s||s.delayed()?(e.unsetMapFlag(),!1):e.buildArea.npcs.has(s.nid)?(e.clearPendingAction(),e.setInteraction(Rl.ENGINE,s,Ll.APNPCT,{type:s.type,com:i}),e.opcalled=!0,!0):(e.unsetMapFlag(),!1)}}class kp extends fp{handle(t,e){const{nid:r,useObj:i,useSlot:n,useComponent:s}=t;if(e.delayed())return e.unsetMapFlag(),!1;const a=qs.get(s);if(void 0===a||!e.isComponentVisible(a))return e.unsetMapFlag(),!1;const o=e.invListeners.find((t=>t.com===s));if(!o)return e.unsetMapFlag(),!1;const h=e.getInventoryFromListener(o);if(!h||!h.validSlot(n)||!h.hasAt(n,i))return e.unsetMapFlag(),!1;const l=Lm.getNpc(r);return!l||l.delayed()?(e.unsetMapFlag(),!1):e.buildArea.npcs.has(l.nid)?Aa.get(i).members&&!Ea.NODE_MEMBERS?(e.messageGame("To use this item please login to a members' server."),e.unsetMapFlag(),!1):(e.lastUseItem=i,e.lastUseSlot=n,e.clearPendingAction(),e.setInteraction(Rl.ENGINE,l,Ll.APNPCU,{type:l.type,com:-1}),e.opcalled=!0,!0):(e.unsetMapFlag(),!1)}}class Dp extends fp{handle(t,e){const{x:r,z:i,obj:n}=t;if(e.delayed())return e.unsetMapFlag(),!1;const s=e.originX-52,a=e.originX+52,o=e.originZ+52,h=e.originZ-52;if(ra||io)return e.unsetMapFlag(),!1;const l=Lm.getObj(r,i,e.level,n,e.pid);if(!l)return e.unsetMapFlag(),!1;const c=Aa.get(l.type);if(1===t.op&&(c.op&&!c.op[0]||!c.op)||4===t.op&&(c.op&&!c.op[3]||!c.op))return e.unsetMapFlag(),!1;let u;return u=1===t.op?Ll.APOBJ1:2===t.op?Ll.APOBJ2:3===t.op?Ll.APOBJ3:4===t.op?Ll.APOBJ4:Ll.APOBJ5,e.clearPendingAction(),e.setInteraction(Rl.ENGINE,l,u),e.opcalled=!0,!0}}class Up extends fp{handle(t,e){const{x:r,z:i,obj:n,spellComponent:s}=t;if(e.delayed())return e.unsetMapFlag(),!1;const a=qs.get(s);if(void 0===a||!e.isComponentVisible(a))return e.unsetMapFlag(),!1;const o=e.originX-52,h=e.originX+52,l=e.originZ+52,c=e.originZ-52;if(rh||il)return e.unsetMapFlag(),!1;const u=Lm.getObj(r,i,e.level,n,e.pid);return u?(e.clearPendingAction(),e.setInteraction(Rl.ENGINE,u,Ll.APOBJT,{type:u.type,com:s}),e.opcalled=!0,!0):(e.unsetMapFlag(),!1)}}class xp extends fp{handle(t,e){const{x:r,z:i,obj:n,useObj:s,useSlot:a,useComponent:o}=t;if(e.delayed())return e.unsetMapFlag(),!1;const h=qs.get(o);if(void 0===h||!e.isComponentVisible(h))return e.unsetMapFlag(),!1;const l=e.originX-52,c=e.originX+52,u=e.originZ+52,d=e.originZ-52;if(rc||iu)return e.unsetMapFlag(),!1;const f=e.invListeners.find((t=>t.com===o));if(!f)return e.unsetMapFlag(),!1;const p=e.getInventoryFromListener(f);if(!p||!p.validSlot(a)||!p.hasAt(a,s))return e.unsetMapFlag(),!1;const m=Lm.getObj(r,i,e.level,n,e.pid);return m?Aa.get(s).members&&!Ea.NODE_MEMBERS?(e.messageGame("To use this item please login to a members' server."),e.unsetMapFlag(),!1):(e.lastUseItem=s,e.lastUseSlot=a,e.clearPendingAction(),e.setInteraction(Rl.ENGINE,m,Ll.APOBJU),e.opcalled=!0,!0):(e.unsetMapFlag(),!1)}}class Fp extends fp{handle(t,e){const{pid:r}=t;if(e.delayed())return e.unsetMapFlag(),!1;const i=Lm.getPlayer(r);if(!i)return e.unsetMapFlag(),!1;if(!e.buildArea.players.has(i.uid))return e.unsetMapFlag(),!1;let n;return n=1===t.op?Ll.APPLAYER1:2===t.op?Ll.APPLAYER2:3===t.op?Ll.APPLAYER3:Ll.APPLAYER4,e.clearPendingAction(),e.setInteraction(Rl.ENGINE,i,n),e.opcalled=!0,!0}}class Hp extends fp{handle(t,e){const{pid:r,spellComponent:i}=t;if(e.delayed())return e.unsetMapFlag(),!1;const n=qs.get(i);if(void 0===n||!e.isComponentVisible(n))return e.unsetMapFlag(),!1;const s=Lm.getPlayer(r);return s&&e.buildArea.players.has(s.uid)?(e.clearPendingAction(),e.setInteraction(Rl.ENGINE,s,Ll.APPLAYERT,{type:-1,com:i}),e.opcalled=!0,!0):(e.unsetMapFlag(),!1)}}class jp extends fp{handle(t,e){const{pid:r,useObj:i,useSlot:n,useComponent:s}=t;if(e.delayed())return e.unsetMapFlag(),!1;const a=qs.get(s);if(void 0===a||!e.isComponentVisible(a))return e.unsetMapFlag(),!1;const o=e.invListeners.find((t=>t.com===s));if(!o)return e.unsetMapFlag(),!1;const h=e.getInventoryFromListener(o);if(!h||!h.validSlot(n)||!h.hasAt(n,i))return e.unsetMapFlag(),!1;const l=Lm.getPlayer(r);return l&&e.buildArea.players.has(l.uid)?Aa.get(i).members&&!Ea.NODE_MEMBERS?(e.messageGame("To use this item please login to a members' server."),e.unsetMapFlag(),!1):(e.lastUseSlot=n,e.clearPendingAction(),e.setInteraction(Rl.ENGINE,l,Ll.APPLAYERU,{type:i,com:-1}),e.opcalled=!0,!0):(e.unsetMapFlag(),!1)}}class Vp extends fp{handle(t,e){const{maps:r}=t;for(let t=0;t13)return!1;const i=no.getByTriggerSpecific(Ll.TUTORIAL_CLICKSIDE,-1,-1);return i&&e.executeScript(om.init(i,e),!0),!0}}class Kp extends lf{path;ctrlHeld;opClick;category=cf.USER_EVENT;constructor(t,e,r){super(),this.path=t,this.ctrlHeld=e,this.opClick=r}}class qp extends hf{prot;constructor(t){super(),this.prot=t}decode(t){const e=t.g1(),r=t.g2(),i=t.g2(),n=this.prot===of.MOVE_MINIMAPCLICK?14:0,s=t.available-n>>1,a=[{x:r,z:i}];for(let e=1;e<=s&&e<25;e++)a.push({x:r+t.g1b(),z:i+t.g1b()});return new Kp(a,e,this.prot===of.MOVE_OPCLICK)}}class Yp extends fp{handle(t,e){const r=t.path[0];if(e.delayed()||t.ctrlHeld<0||t.ctrlHeld>1||oh.distanceToSW(e,{x:r.x,z:r.z})>104)return e.unsetMapFlag(),e.userPath=[],!1;if(Ea.NODE_CLIENT_ROUTEFINDER){e.userPath=[];for(let r=0;rt;){const e=of.byId[this.client.in[t++]];let r=e.length;-1==r?r=this.client.in[t++]:-2==r&&(r=this.client.in[t++]<<8|this.client.in[t++]);const i=new as(this.client.in.slice(t,t+r));t+=r;const n=Zp.getDecoder(e);if(n){const t=n.decode(i),r=Zp.getHandler(e);r&&r.handle(t,this)}}this.client?.reset()}encodeOut(){if(this.client){(this.modalTop!==this.lastModalTop||this.modalBottom!==this.lastModalBottom||this.modalSidebar!==this.lastModalSidebar||this.refreshModalClose)&&(this.refreshModalClose&&this.write(new ac),this.refreshModalClose=!1,this.lastModalTop=this.modalTop,this.lastModalBottom=this.modalBottom,this.lastModalSidebar=this.modalSidebar),this.refreshModal&&(1&~this.modalState||4&~this.modalState?1&~this.modalState?2&~this.modalState?4&~this.modalState||this.write(new vu(this.modalSidebar)):this.write(new Fc(this.modalBottom)):this.write(new pu(this.modalTop)):this.write(new gu(this.modalTop,this.modalSidebar)),this.refreshModal=!1);for(let t=this.highPriorityOut.head();t;t=this.highPriorityOut.next())this.writeInner(t),t.uncache();for(let t=this.lowPriorityOut.head();t;t=this.lowPriorityOut.next())this.writeInner(t),t.uncache();this.client.flush()}}writeInner(t){const e=this.client;if(!e)return;const r=qd.getEncoder(t);if(!r)return void console.error('No encoder for message',t);const i=r.prot,n=e.out,s=1+(-1===i.length?1:-2===i.length?2:0)+r.test(t);n.pos+s>=n.length&&e.flush();const a=n.pos;n.p1(i.id),-1===i.length?n.pos+=1:-2===i.length&&(n.pos+=2);const o=n.pos;r.encode(n,t),-1===i.length?n.psize1(n.pos-o):-2===i.length&&n.psize2(n.pos-o),e.encryptor&&(n.data[a]=n.data[a]+e.encryptor.nextInt()&255),Lm.cycleStats[al.BANDWIDTH_OUT]+=n.pos-a}logout(){this.writeInner(new $u),this.client?.flush()}terminate(){this.client?.terminate(),this.client=null}playerLog(t,...e){'undefined'==typeof self&&(e.length>0?Wl.appendFileSync(`data/players/${this.username}.log`,`[${(new Date).toISOString().split('T')[0]} ${this.client?.remoteAddress}]: ${t} ${e.join(' ')}\n`):Wl.appendFileSync(`data/players/${this.username}.log`,`[${(new Date).toISOString().split('T')[0]} ${this.client?.remoteAddress}]: ${t}\n`))}updateMap(){const t=this.buildArea.loadedZones,e=this.buildArea.activeZones,r=oh.zone(this.originX)-4<<3,i=oh.zone(this.originX)+5<<3,n=oh.zone(this.originZ)+5<<3,s=oh.zone(this.originZ)-4<<3;(this.xi-1||this.z>n-1)&&(this.write(new Vc(oh.zone(this.x),oh.zone(this.z))),this.originX=this.x,this.originZ=this.z,t.clear());for(let t=this.cameraPackets.head();null!==t;t=this.cameraPackets.next()){const e=t.camX-oh.zoneOrigin(this.originX),r=t.camZ-oh.zoneOrigin(this.originZ);t.type===Kl.CAM_MOVETO?this.write(new tu(e,r,t.height,t.rotationSpeed,t.rotationMultiplier)):t.type===Kl.CAM_LOOKAT&&this.write(new Qc(e,r,t.height,t.rotationSpeed,t.rotationMultiplier)),t.unlink()}this.moveSpeed===Zl.INSTANT&&this.jump&&t.clear(),e.clear();const a=oh.zone(this.x),o=oh.zone(this.z),h=oh.zone(this.originX)-6,l=oh.zone(this.originX)+6,c=oh.zone(this.originZ)+6,u=oh.zone(this.originZ)-6;for(let t=a-3;t<=a+3;t++)for(let r=o-3;r<=o+3;r++)tl||r>c||r243?e>>=4:r>217?e>>=3:r>192?e>>=2:r>179&&(e>>=1),((255&t)>>2<<10)+(e>>5<<7)+(r>>1)}static rgb15to24(t){return((t>>10&31)<<3<<16)+((t>>5&31)<<3<<8)+((31&t)<<3)}static rgb15toHsl16(t){const e=(t>>10&31)/31,r=(t>>5&31)/31,i=(31&t)/31;return Jp.rgbToHsl(e,r,i)}static rgb24to15(t){return((t>>16&255)>>3<<10)+((t>>8&255)>>3<<5)+((255&t)>>3)}static rgb24toHsl16(t){const e=(t>>16&255)/256,r=(t>>8&255)/256,i=(255&t)/256;return Jp.rgbToHsl(e,r,i)}static rgbToHsl(t,e,r){let i=t;en&&(n=e),r>n&&(n=r);let s=0,a=0;const o=(i+n)/2;i!==n&&(o<.5?a=(n-i)/(n+i):o>=.5&&(a=(n-i)/(2-n-i)),t===n?s=(e-r)/(n-i):e===n?s=(r-t)/(n-i)+2:r===n&&(s=(t-e)/(n-i)+4)),s/=6;const h=256*s|0;let l=256*a|0,c=256*o|0;return l<0?l=0:l>255&&(l=255),c<0?c=0:c>255&&(c=255),Jp.hsl24to16(h,l,c)}static RGB15_HSL16=new Int32Array(32768);static{for(let t=0;t<32768;t++)Jp.RGB15_HSL16[t]=Jp.rgb15toHsl16(t)}static reverseHsl(t){const e=[];for(let r=0;r<32768;r++)Jp.RGB15_HSL16[r]===t&&e.push(r);return e}}var tm=function(t){const e=t.popString(),r=[];for(let i=e.length-1;i>=0;i--){const n=e.charAt(i);r[i]='s'===n?t.popString():t.popInt()}return r},em={[ro.FINDUID]:t=>{const e=t.popInt(),r=Lm.getPlayerByUid(e);r?(t.activePlayer=r,t.pointerAdd(Ja[t.intOperand]),t.pushInt(1)):t.pushInt(0)},[ro.P_FINDUID]:t=>{const e=t.popInt()>>>0,r=Lm.getPlayerByUid(e);t.pointerGet(to[t.intOperand])&&t.activePlayer.uid===e?t.pushInt(1):r&&r.canAccess()?(t.activePlayer=r,t.pointerAdd(Ja[t.intOperand]),t.pointerAdd(to[t.intOperand]),t.pushInt(1)):t.pushInt(0)},[ro.STRONGQUEUE]:qa(Ja,(t=>{const e=tm(t),r=dh(t.popInt(),yh),i=t.popInt(),n=no.get(i);if(!n)throw new Error(`Unable to find queue script: ${i}`);t.activePlayer.enqueueScript(n,3,r,e)})),[ro.WEAKQUEUE]:qa(Ja,(t=>{const e=tm(t),r=dh(t.popInt(),yh),i=t.popInt(),n=no.get(i);if(!n)throw new Error(`Unable to find queue script: ${i}`);t.activePlayer.enqueueScript(n,2,r,e)})),[ro.QUEUE]:qa(Ja,(t=>{const e=tm(t),r=dh(t.popInt(),yh),i=t.popInt(),n=no.get(i);if(!n)throw new Error(`Unable to find queue script: ${i}`);t.activePlayer.enqueueScript(n,0,r,e)})),[ro.ANIM]:qa(Ja,(t=>{const e=t.popInt(),r=t.popInt();t.activePlayer.playAnimation(r,e)})),[ro.BUFFER_FULL]:qa(Ja,(t=>{throw new Error('unimplemented')})),[ro.BUILDAPPEARANCE]:qa(Ja,(t=>{t.activePlayer.generateAppearance(dh(t.popInt(),Dh).id)})),[ro.CAM_LOOKAT]:qa(Ja,(t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Ah);t.activePlayer.cameraPackets.addTail(new Qp(Kl.CAM_LOOKAT,s.x,s.z,r,i,n))})),[ro.CAM_MOVETO]:qa(Ja,(t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Ah);t.activePlayer.cameraPackets.addTail(new Qp(Kl.CAM_MOVETO,s.x,s.z,r,i,n))})),[ro.CAM_SHAKE]:qa(Ja,(t=>{const[e,r,i,n]=t.popInts(4);t.activePlayer.write(new nu(e,r,i,n))})),[ro.CAM_RESET]:qa(Ja,(t=>{t.activePlayer.write(new ru)})),[ro.COORD]:qa(Ja,(t=>{const e=t.activePlayer;t.pushInt(oh.packCoord(e.level,e.x,e.z))})),[ro.DISPLAYNAME]:qa(Ja,(t=>{t.pushString(t.activePlayer.displayName)})),[ro.FACESQUARE]:qa(Ja,(t=>{const e=dh(t.popInt(),Ah);t.activePlayer.faceSquare(e.x,e.z)})),[ro.IF_CLOSE]:qa(Ja,(t=>{t.activePlayer.closeModal()})),[ro.LAST_COM]:t=>{t.pushInt(t.activePlayer.lastCom)},[ro.LAST_INT]:t=>{t.pushInt(t.lastInt)},[ro.LAST_ITEM]:t=>{if(![Ll.OPHELD1,Ll.OPHELD2,Ll.OPHELD3,Ll.OPHELD4,Ll.OPHELD5,Ll.OPHELDU,Ll.OPHELDT,Ll.INV_BUTTON1,Ll.INV_BUTTON2,Ll.INV_BUTTON3,Ll.INV_BUTTON4,Ll.INV_BUTTON5].includes(t.trigger))throw new Error('is not safe to use in this trigger');t.pushInt(t.activePlayer.lastItem)},[ro.LAST_SLOT]:t=>{if(![Ll.OPHELD1,Ll.OPHELD2,Ll.OPHELD3,Ll.OPHELD4,Ll.OPHELD5,Ll.OPHELDU,Ll.OPHELDT,Ll.INV_BUTTON1,Ll.INV_BUTTON2,Ll.INV_BUTTON3,Ll.INV_BUTTON4,Ll.INV_BUTTON5,Ll.INV_BUTTOND].includes(t.trigger))throw new Error('is not safe to use in this trigger');t.pushInt(t.activePlayer.lastSlot)},[ro.LAST_USEITEM]:t=>{if(![Ll.OPHELDU,Ll.APOBJU,Ll.APLOCU,Ll.APNPCU,Ll.APPLAYERU,Ll.OPOBJU,Ll.OPLOCU,Ll.OPNPCU,Ll.OPPLAYERU].includes(t.trigger))throw new Error('is not safe to use in this trigger');t.pushInt(t.activePlayer.lastUseItem)},[ro.LAST_USESLOT]:t=>{if(![Ll.OPHELDU,Ll.APOBJU,Ll.APLOCU,Ll.APNPCU,Ll.APPLAYERU,Ll.OPOBJU,Ll.OPLOCU,Ll.OPNPCU,Ll.OPPLAYERU].includes(t.trigger))throw new Error('is not safe to use in this trigger');t.pushInt(t.activePlayer.lastUseSlot)},[ro.MES]:qa(Ja,(t=>{const e=t.popString();t.activePlayer.messageGame(e)})),[ro.NAME]:qa(Ja,(t=>{t.pushString(t.activePlayer.username)})),[ro.P_APRANGE]:qa(to,(t=>{t.activePlayer.apRange=dh(t.popInt(),yh),t.activePlayer.apRangeCalled=!0})),[ro.P_ARRIVEDELAY]:qa(to,(t=>{t.activePlayer.lastMovement{t.activePlayer.write(new cd),t.execution=ho.COUNTDIALOG})),[ro.P_DELAY]:qa(to,(t=>{t.activePlayer.delay=Lm.currentTick+dh(t.popInt(),yh)+1,t.execution=ho.SUSPENDED})),[ro.P_OPHELD]:qa(to,(t=>{throw new Error('unimplemented')})),[ro.P_OPLOC]:qa(to,(t=>{const e=dh(t.popInt(),yh)-1;if(e<0||e>=5)throw new Error(`Invalid oploc: ${e+1}`);t.activePlayer.stopAction(),t.activePlayer.setInteraction(Rl.SCRIPT,t.activeLoc,Ll.APLOC1+e)})),[ro.P_OPNPC]:qa(to,(t=>{const e=dh(t.popInt(),yh)-1;if(e<0||e>=5)throw new Error(`Invalid opnpc: ${e+1}`);t.activePlayer.stopAction(),t.activePlayer.setInteraction(Rl.SCRIPT,t.activeNpc,Ll.APNPC1+e,{type:t.activeNpc.type,com:-1})})),[ro.P_OPNPCT]:qa(to,(t=>{const e=dh(t.popInt(),yh);t.activePlayer.stopAction(),t.activePlayer.setInteraction(Rl.SCRIPT,t.activeNpc,Ll.APNPCT,{type:t.activeNpc.type,com:e})})),[ro.P_PAUSEBUTTON]:qa(to,(t=>{t.execution=ho.PAUSEBUTTON})),[ro.P_STOPACTION]:qa(to,(t=>{t.activePlayer.stopAction()})),[ro.P_CLEARPENDINGACTION]:qa(to,(t=>{t.activePlayer.clearPendingAction()})),[ro.P_TELEJUMP]:qa(to,(t=>{const e=dh(t.popInt(),Ah);t.activePlayer.teleJump(e.x,e.z,e.level)})),[ro.P_TELEPORT]:qa(to,(t=>{const e=dh(t.popInt(),Ah);t.activePlayer.teleport(e.x,e.z,e.level)})),[ro.P_WALK]:qa(to,(t=>{const e=dh(t.popInt(),Ah),r=t.activePlayer;r.queueWaypoints(go(r.level,r.x,r.z,e.x,e.z,r.width,r.width,r.length)),r.updateMovement(!1)})),[ro.SAY]:qa(Ja,(t=>{t.activePlayer.say(t.popString())})),[ro.SOUND_SYNTH]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3);t.activePlayer.write(new gd(e,r,i))})),[ro.STAFFMODLEVEL]:qa(Ja,(t=>{t.pushInt(t.activePlayer.staffModLevel)})),[ro.STAT]:qa(Ja,(t=>{const e=dh(t.popInt(),Ih);t.pushInt(t.activePlayer.levels[e])})),[ro.STAT_BASE]:qa(Ja,(t=>{const e=dh(t.popInt(),Ih);t.pushInt(t.activePlayer.baseLevels[e])})),[ro.STAT_ADD]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3);dh(e,Ih),dh(r,yh),dh(i,yh);const n=t.activePlayer,s=n.levels[e],a=s+(r+s*i/100);n.levels[e]=Math.min(a,255),3===e&&n.levels[3]>=n.baseLevels[3]&&n.resetHeroPoints()})),[ro.STAT_SUB]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3);dh(e,Ih),dh(r,yh),dh(i,yh);const n=t.activePlayer,s=n.levels[e],a=s-(r+s*i/100);n.levels[e]=Math.max(a,0)})),[ro.SPOTANIM_PL]:qa(Ja,(t=>{const e=dh(t.popInt(),yh),r=t.popInt(),i=dh(t.popInt(),Rh);t.activePlayer.spotanim(i.id,r,e)})),[ro.STAT_HEAL]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3);dh(e,Ih),dh(r,yh),dh(i,yh);const n=t.activePlayer,s=n.baseLevels[e],a=n.levels[e],o=a+(r+a*i/100);n.levels[e]=Math.max(Math.min(o,s),a),3===e&&n.levels[3]>=n.baseLevels[3]&&n.resetHeroPoints()})),[ro.UID]:qa(Ja,(t=>{t.pushInt(t.activePlayer.uid)})),[ro.P_LOGOUT]:qa(to,(t=>{t.activePlayer.logoutRequested=!0})),[ro.IF_SETCOLOUR]:qa(Ja,(t=>{const[e,r]=t.popInts(2);dh(e,yh),dh(r,yh),t.activePlayer.write(new Au(e,Jp.rgb24to15(r)))})),[ro.IF_OPENCHAT]:qa(Ja,(t=>{t.activePlayer.openChat(dh(t.popInt(),yh))})),[ro.IF_OPENMAINMODALSIDEOVERLAY]:qa(Ja,(t=>{const[e,r]=t.popInts(2);dh(e,yh),dh(r,yh),t.activePlayer.openMainModalSideOverlay(e,r)})),[ro.IF_SETHIDE]:qa(Ja,(t=>{const[e,r]=t.popInts(2);dh(e,yh),dh(r,yh),t.activePlayer.write(new Tu(e,1===r))})),[ro.IF_SETOBJECT]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3);dh(e,yh),dh(r,Bh),dh(i,yh),t.activePlayer.write(new Lu(e,r,i))})),[ro.IF_SETTABACTIVE]:qa(Ja,(t=>{t.activePlayer.write(new ju(dh(t.popInt(),yh)))})),[ro.IF_SETMODEL]:qa(Ja,(t=>{const[e,r]=t.popInts(2);dh(e,yh),dh(r,yh),t.activePlayer.write(new Iu(e,r))})),[ro.IF_SETRECOL]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3);dh(e,yh),t.activePlayer.write(new Uu(e,r,i))})),[ro.IF_SETTABFLASH]:qa(Ja,(t=>{t.activePlayer.write(new vd(dh(t.popInt(),yh)))})),[ro.IF_SETANIM]:qa(Ja,(t=>{const[e,r]=t.popInts(2);dh(e,yh),-1!==r&&t.activePlayer.write(new wu(e,r))})),[ro.IF_SETTAB]:qa(Ja,(t=>{const[e,r]=t.popInts(2);dh(r,yh),t.activePlayer.setTab(e,r)})),[ro.IF_OPENMAINMODAL]:qa(Ja,(t=>{t.activePlayer.openMainModal(dh(t.popInt(),yh))})),[ro.IF_OPENCHATSTICKY]:qa(Ja,(t=>{t.activePlayer.openChatSticky(dh(t.popInt(),yh))})),[ro.IF_OPENSIDEOVERLAY]:qa(Ja,(t=>{t.activePlayer.openSideOverlay(dh(t.popInt(),yh))})),[ro.IF_SETPLAYERHEAD]:qa(Ja,(t=>{t.activePlayer.write(new Pu(dh(t.popInt(),yh)))})),[ro.IF_SETTEXT]:qa(Ja,(t=>{const e=t.popString(),r=dh(t.popInt(),yh);t.activePlayer.write(new Fu(r,e))})),[ro.IF_SETNPCHEAD]:qa(Ja,(t=>{const[e,r]=t.popInts(2);dh(e,yh),dh(r,Th),t.activePlayer.write(new Ou(e,r))})),[ro.IF_SETPOSITION]:qa(Ja,(t=>{const[e,r,i]=t.popInts(3);dh(e,yh),t.activePlayer.write(new ku(e,r,i))})),[ro.IF_MULTIZONE]:qa(Ja,(t=>{t.activePlayer.write(new pd(1===dh(t.popInt(),yh)))})),[ro.GIVEXP]:qa(to,(t=>{const[e,r]=t.popInts(2);dh(e,yh),dh(r,yh),t.activePlayer.addXp(e,r)})),[ro.DAMAGE]:t=>{const e=dh(t.popInt(),yh),r=dh(t.popInt(),Lh),i=dh(t.popInt(),yh),n=Lm.getPlayerByUid(i);n&&n.applyDamage(e,r)},[ro.IF_SETRESUMEBUTTONS]:qa(Ja,(t=>{const[e,r,i,n,s]=t.popInts(5);t.activePlayer.resumeButtons=[e,r,i,n,s]})),[ro.TEXT_GENDER]:qa(Ja,(t=>{const[e,r]=t.popStrings(2);0==t.activePlayer.gender?t.pushString(e):t.pushString(r)})),[ro.MIDI_SONG]:t=>{t.activePlayer.playSong(dh(t.popString(),vh))},[ro.MIDI_JINGLE]:t=>{const e=dh(t.popInt(),yh),r=dh(t.popString(),vh);t.activePlayer.playJingle(e,r)},[ro.SOFTTIMER]:qa(Ja,(t=>{const e=tm(t),r=t.popInt(),i=t.popInt(),n=no.get(i);if(!n)throw new Error(`Unable to find timer script: ${i}`);t.activePlayer.setTimer(1,n,e,r)})),[ro.CLEARSOFTTIMER]:qa(Ja,(t=>{t.activePlayer.clearTimer(t.popInt())})),[ro.SETTIMER]:qa(Ja,(t=>{const e=tm(t),r=t.popInt(),i=t.popInt(),n=no.get(i);if(!n)throw new Error(`Unable to find timer script: ${i}`);t.activePlayer.setTimer(0,n,e,r)})),[ro.CLEARTIMER]:qa(Ja,(t=>{t.activePlayer.clearTimer(t.popInt())})),[ro.HINT_COORD]:t=>{const[e,r,i]=t.popInts(3),n=dh(r,Ah);t.activePlayer.hintTile(e,n.x,n.z,i)},[ro.HINT_STOP]:t=>{t.activePlayer.stopHint()},[ro.IF_CLOSESTICKY]:t=>{t.activePlayer.closeSticky()},[ro.P_EXACTMOVE]:qa(to,(t=>{const[e,r,i,n,s]=t.popInts(5),a=dh(e,Ah),o=dh(r,Ah);t.activePlayer.unsetMapFlag(),t.activePlayer.exactMove(a.x,a.z,o.x,o.z,i,n,s)})),[ro.BUSY]:t=>{t.pushInt(t.activePlayer.busy()?1:0)},[ro.BUSY2]:t=>{t.pushInt(t.activePlayer.hasInteraction()||t.activePlayer.hasWaypoints()?1:0)},[ro.GETQUEUE]:t=>{const e=t.popInt();let r=0;for(let i=t.activePlayer.queue.head();null!==i;i=t.activePlayer.queue.next())i.script.id===e&&r++;for(let i=t.activePlayer.weakQueue.head();null!==i;i=t.activePlayer.weakQueue.next())i.script.id===e&&r++;t.pushInt(r)},[ro.P_LOCMERGE]:qa(to,(t=>{const[e,r,i,n]=t.popInts(4),s=dh(i,Ah),a=dh(n,Ah);Lm.mergeLoc(t.activeLoc,t.activePlayer,e,r,s.z,s.x,a.z,a.x)})),[ro.LAST_LOGIN_INFO]:t=>{const e=t.activePlayer;if(!$p(e)||null===e.client)return;const r=e.client.remoteAddress;if(null==r)return;const i=new Uint32Array(new Uint8Array(r.split('.').map((t=>parseInt(t)))).reverse().buffer)[0];e.lastLoginInfo(i,0,201,0)},[ro.BAS_READYANIM]:t=>{t.activePlayer.basReadyAnim=dh(t.popInt(),Hh).id},[ro.BAS_TURNONSPOT]:t=>{t.activePlayer.basTurnOnSpot=dh(t.popInt(),Hh).id},[ro.BAS_WALK_F]:t=>{t.activePlayer.basWalkForward=dh(t.popInt(),Hh).id},[ro.BAS_WALK_B]:t=>{t.activePlayer.basWalkBackward=dh(t.popInt(),Hh).id},[ro.BAS_WALK_L]:t=>{t.activePlayer.basWalkLeft=dh(t.popInt(),Hh).id},[ro.BAS_WALK_R]:t=>{t.activePlayer.basWalkRight=dh(t.popInt(),Hh).id},[ro.BAS_RUNNING]:t=>{const e=t.popInt();t.activePlayer.basRunning=-1!==e?dh(e,Hh).id:-1},[ro.GENDER]:t=>{t.pushInt(t.activePlayer.gender)},[ro.HINT_NPC]:t=>{t.activePlayer.hintNpc(dh(t.popInt(),yh))},[ro.HINT_PLAYER]:t=>{const e=dh(t.popInt(),yh),r=Lm.getPlayerByUid(e);r&&t.activePlayer.hintPlayer(r.pid)},[ro.HEADICONS_GET]:t=>{t.pushInt(t.activePlayer.headicons)},[ro.HEADICONS_SET]:t=>{t.activePlayer.headicons=dh(t.popInt(),yh)},[ro.P_OPOBJ]:qa(to,(t=>{const e=dh(t.popInt(),yh)-1;if(e<0||e>=5)throw new Error(`Invalid opobj: ${e+1}`);t.activePlayer.stopAction(),t.activePlayer.setInteraction(Rl.SCRIPT,t.activeObj,Ll.APOBJ1+e)})),[ro.P_OPPLAYER]:qa(to,(t=>{const e=dh(t.popInt(),yh)-1;if(e<0||e>=5)throw new Error(`Invalid opplayer: ${e+1}`);const r=t._activePlayer2;r&&(t.activePlayer.stopAction(),t.activePlayer.setInteraction(Rl.SCRIPT,r,Ll.APPLAYER1+e))})),[ro.ALLOWDESIGN]:t=>{t.activePlayer.allowDesign=1===dh(t.popInt(),yh)},[ro.LAST_TARGETSLOT]:t=>{if(![Ll.INV_BUTTOND].includes(t.trigger))throw new Error('is not safe to use in this trigger');t.pushInt(t.activePlayer.lastTargetSlot)},[ro.WALKTRIGGER]:t=>{t.activePlayer.walktrigger=t.popInt()},[ro.GETWALKTRIGGER]:t=>{t.pushInt(t.activePlayer.walktrigger)},[ro.CLEARQUEUE]:t=>{const e=t.popInt();for(let r=t.activePlayer.queue.head();null!==r;r=t.activePlayer.queue.next())r.script.id===e&&r.unlink();for(let r=t.activePlayer.weakQueue.head();null!==r;r=t.activePlayer.weakQueue.next())r.script.id===e&&r.unlink()},[ro.HEALENERGY]:t=>{const e=dh(t.popInt(),yh),r=t.activePlayer;r.runenergy=Math.min(Math.max(r.runenergy+e,0),1e4)},[ro.AFK_EVENT]:t=>{t.pushInt(t.activePlayer.afkEventReady?1:0),t.activePlayer.afkEventReady=!1},[ro.LOWMEMORY]:t=>{t.pushInt(t.activePlayer.lowMemory?1:0)},[ro.SETIDKIT]:t=>{const[e,r]=t.popInts(2),i=dh(e,xh);let n=i.type;1===t.activePlayer.gender&&(n-=7),t.activePlayer.body[n]=i.id;let s=i.type;1===t.activePlayer.gender&&(s-=7);let a=-1;0===s||1===s?a=0:2===s||3===s?a=1:4===s||(5===s?a=2:6===s&&(a=3)),-1!==a&&(t.activePlayer.colors[a]=r)},[ro.SETGENDER]:t=>{const e=dh(t.popInt(),Zh);for(let r=0;r<7;r++){t.activePlayer.body[r]=-1;for(let i=0;i{const e=dh(t.popInt(),$h);t.activePlayer.colors[4]=e},[ro.P_OPPLAYERT]:qa(to,(t=>{const e=dh(t.popInt(),yh),r=t._activePlayer2;r&&(t.activePlayer.stopAction(),t.activePlayer.setInteraction(Rl.SCRIPT,r,Ll.APPLAYERT,{type:-1,com:e}))})),[ro.FINDHERO]:qa(Ja,(t=>{const e=t.activePlayer.findHero();if(-1===e)return void t.pushInt(0);const r=Lm.getPlayerByUid(e);r?(t._activePlayer2=r,t.pointerAdd(eo.ActivePlayer2),t.pushInt(1)):t.pushInt(0)})),[ro.BOTH_HEROPOINTS]:qa(Ja,(t=>{const e=dh(t.popInt(),yh),r=1===t.intOperand,i=r?t._activePlayer2:t._activePlayer,n=r?t._activePlayer:t._activePlayer2;if(!i||!n)throw new Error('player is null');n.addHero(i.uid,e)})),[ro.P_ANIMPROTECT]:qa(to,(t=>{t.activePlayer.animProtect=dh(t.popInt(),yh)})),[ro.RUNENERGY]:qa(Ja,(t=>{const e=t.activePlayer;t.pushInt(e.runenergy)})),[ro.WEIGHT]:qa(to,(t=>{t.pushInt(t.activePlayer.runweight)})),[ro.LAST_COORD]:qa(Ja,(t=>{t.pushInt(oh.packCoord(t.activePlayer.level,t.activePlayer.lastX,t.activePlayer.lastZ))}))},rm=em,im={[ro.MAP_CLOCK]:t=>{t.pushInt(Lm.currentTick)},[ro.MAP_MEMBERS]:t=>{t.pushInt(Ea.NODE_MEMBERS?1:0)},[ro.MAP_PLAYERCOUNT]:t=>{const[e,r]=t.popInts(2),i=dh(e,Ah),n=dh(r,Ah);let s=0;for(let t=Math.floor(i.x/8);t<=Math.ceil(n.x/8);t++)for(let e=Math.floor(i.z/8);e<=Math.ceil(n.z/8);e++)for(const r of Lm.getZone(t<<3,e<<3,i.level).getAllPlayersSafe())r.x>=i.x&&r.x<=n.x&&r.z>=i.z&&r.z<=n.z&&s++;t.pushInt(s)},[ro.HUNTALL]:t=>{const[e,r,i]=t.popInts(3),n=dh(e,Ah);dh(r,yh);const s=dh(i,Fh);t.huntIterator=new _l(Lm.currentTick,n.level,n.x,n.z,r,s,-1,-1,ks.PLAYER)},[ro.HUNTNEXT]:t=>{const e=t.huntIterator?.next();if(e&&!e.done){if(!(e.value instanceof af))throw new Error('[ServerOps] huntnext command must result instance of Player.');t.activePlayer=e.value,t.pointerAdd(Ja[t.intOperand]),t.pushInt(1)}else t.pushInt(0)},[ro.NPC_HUNTALL]:t=>{const[e,r,i]=t.popInts(3),n=dh(e,Ah);dh(r,yh);const s=dh(i,Fh);t.huntIterator=new _l(Lm.currentTick,n.level,n.x,n.z,r,s,-1,-1,ks.NPC)},[ro.NPC_HUNTNEXT]:t=>{const e=t.huntIterator?.next();if(e&&!e.done){if(!(e.value instanceof hm))throw new Error('[ServerOps] npc_huntnext command must result instance of Npc.');t.activeNpc=e.value,t.pointerAdd($a[t.intOperand]),t.pushInt(1)}else t.pushInt(0)},[ro.INZONE]:t=>{const[e,r,i]=t.popInts(3),n=dh(e,Ah),s=dh(r,Ah),a=dh(i,Ah);a.xs.x||a.levels.level||a.zs.z?t.pushInt(0):t.pushInt(1)},[ro.LINEOFWALK]:t=>{const[e,r]=t.popInts(2),i=dh(e,Ah),n=dh(r,Ah);i.level===n.level?t.pushInt(No(i.level,i.x,i.z,n.x,n.z,1,1,1,1)?1:0):t.pushInt(0)},[ro.STAT_RANDOM]:t=>{const[e,r,i]=t.popInts(3),n=Math.floor(r*(99-e)/98)+Math.floor(i*(e-1)/98)+1,s=Math.floor(256*Math.random());t.pushInt(n>s?1:0)},[ro.SPOTANIM_MAP]:t=>{const[e,r,i,n]=t.popInts(4),s=dh(r,Ah),a=dh(e,Rh);Lm.animMap(s.level,s.x,s.z,a.id,i,n)},[ro.DISTANCE]:t=>{const[e,r]=t.popInts(2),i=dh(e,Ah),n=dh(r,Ah);t.pushInt(oh.distanceToSW(i,n))},[ro.MOVECOORD]:t=>{const[e,r,i,n]=t.popInts(4),s=dh(e,Ah);t.pushInt(oh.packCoord(s.level+i,s.x+r,s.z+n))},[ro.SEQLENGTH]:t=>{t.pushInt(dh(t.popInt(),Hh).duration)},[ro.SPLIT_INIT]:t=>{const[e,r,i]=t.popInts(3);let n=t.popString();const s=dh(i,zh);if(n.startsWith('')){const e=n.substring(3,n.indexOf('>'));t.splitMesanim=ra.getId(e),n=n.substring(n.indexOf('>')+1)}else t.splitMesanim=-1;t.splitPages=[];const a=s.split(n,e);for(;a.length>0;)t.splitPages.push(a.splice(0,r))},[ro.SPLIT_GET]:t=>{const[e,r]=t.popInts(2);t.pushString(t.splitPages[e][r])},[ro.SPLIT_PAGECOUNT]:t=>{t.pushInt(t.splitPages.length)},[ro.SPLIT_LINECOUNT]:t=>{const e=t.popInt();t.pushInt(t.splitPages[e].length)},[ro.SPLIT_GETANIM]:t=>{const e=t.popInt();-1!==t.splitMesanim?t.pushInt(dh(t.splitMesanim,Wh).len[t.splitPages[e].length-1]):t.pushInt(-1)},[ro.STRUCT_PARAM]:t=>{const[e,r]=t.popInts(2),i=dh(r,Sh),n=dh(e,Kh);i.isString()?t.pushString(Xs(i.id,n,i.defaultString)):t.pushInt(Qs(i.id,n,i.defaultInt))},[ro.COORDX]:t=>{t.pushInt(dh(t.popInt(),Ah).x)},[ro.COORDY]:t=>{t.pushInt(dh(t.popInt(),Ah).level)},[ro.COORDZ]:t=>{t.pushInt(dh(t.popInt(),Ah).z)},[ro.PLAYERCOUNT]:t=>{t.pushInt(Lm.getTotalPlayers())},[ro.MAP_BLOCKED]:t=>{const e=dh(t.popInt(),Ah);t.pushInt(Io(e.x,e.z,e.level,qo.WALK_BLOCKED)?1:0)},[ro.MAP_INDOORS]:t=>{const e=dh(t.popInt(),Ah);t.pushInt(Io(e.x,e.z,e.level,qo.ROOF)?1:0)},[ro.LINEOFSIGHT]:t=>{const[e,r]=t.popInts(2),i=dh(e,Ah),n=dh(r,Ah);i.level===n.level?t.pushInt(Oo(i.level,i.x,i.z,n.x,n.z,1,1,1,1)?1:0):t.pushInt(0)},[ro.WORLD_DELAY]:t=>{t.execution=ho.WORLD_SUSPENDED},[ro.PROJANIM_PL]:t=>{const[e,r,i,n,s,a,o,h,l]=t.popInts(9),c=dh(e,Ah),u=dh(i,Rh),d=Lm.getPlayerByUid(r);if(!d)throw new Error(`attempted to use invalid player uid: ${r}`);Lm.mapProjAnim(c.level,c.x,c.z,d.x,d.z,-d.pid-1,u.id,n+100,s+100,a,o,h,l)},[ro.PROJANIM_NPC]:t=>{const[e,r,i,n,s,a,o,h,l]=t.popInts(9),c=dh(e,Ah),u=dh(i,Rh),d=65535&r,f=Lm.getNpc(d);if(!f)throw new Error(`attempted to use invalid npc uid: ${r}`);Lm.mapProjAnim(c.level,c.x,c.z,f.x,f.z,f.nid+1,u.id,n+100,s+100,a,o,h,l)},[ro.PROJANIM_MAP]:t=>{const[e,r,i,n,s,a,o,h,l]=t.popInts(9),c=dh(i,Rh),u=dh(e,Ah),d=dh(r,Ah);Lm.mapProjAnim(u.level,u.x,u.z,d.x,d.z,0,c.id,n+100,s,a,o,h,l)},[ro.MAP_LOCADDUNSAFE]:t=>{const e=dh(t.popInt(),Ah);for(const r of Lm.getZone(e.x,e.z,e.level).getAllLocsUnsafe()){if(1!==dh(r.type,bh).active)continue;const i=Bo(r.shape);if(r.checkLifeCycle(Lm.currentTick)||i!==Xo.WALL)if(i===Xo.WALL){if(r.x===e.x&&r.z===e.z)return void t.pushInt(1)}else if(i===Xo.GROUND){const i=r.angle===Zo.NORTH||r.angle===Zo.SOUTH?r.length:r.width,n=r.angle===Zo.NORTH||r.angle===Zo.SOUTH?r.width:r.length;for(let s=0;s{t.pushInt(Lm.getTotalNpcs())},[ro.ZONECOUNT]:t=>{t.pushInt(Lm.getTotalZones())},[ro.LOCCOUNT]:t=>{t.pushInt(Lm.getTotalLocs())},[ro.OBJCOUNT]:t=>{t.pushInt(Lm.getTotalObjs())}},nm=im,sm={[ro.APPEND_NUM]:t=>{const e=t.popString(),r=t.popInt();t.pushString(e+r)},[ro.APPEND]:t=>{const[e,r]=t.popStrings(2);t.pushString(e+r)},[ro.APPEND_SIGNNUM]:t=>{const e=t.popString(),r=t.popInt();r>=0?t.pushString(`${e}+${r}`):t.pushString(e+r)},[ro.LOWERCASE]:t=>{t.pushString(t.popString().toLowerCase())},[ro.TOSTRING]:t=>{t.pushString(t.popInt().toString())},[ro.COMPARE]:t=>{const[e,r]=t.popStrings(2);t.pushInt(function(t,e){const r=t.length,i=e.length,n=Math.min(r,i);let s=0;for(;s{const e=t.popInt(),[r,i]=t.popStrings(2);t.pushString(1===e?r:i)},[ro.APPEND_CHAR]:t=>{const e=t.popString(),r=t.popInt();t.pushString(e+String.fromCharCode(r))},[ro.STRING_LENGTH]:t=>{t.pushInt(t.popString().length)},[ro.SUBSTRING]:t=>{const e=t.popString(),[r,i]=t.popInts(2);t.pushString(e.substring(r,i))},[ro.STRING_INDEXOF_CHAR]:t=>{const e=t.popString(),r=String.fromCharCode(t.popInt());t.pushInt(e.indexOf(r))},[ro.STRING_INDEXOF_STRING]:t=>{const e=t.popString(),r=t.popString();t.pushInt(e.indexOf(r))}},am=sm;class om{static HANDLERS={...el,...nm,...rm,...Pl,...Il,...Fl,...Bl,...Cl,...Hl,...yl,...ll,...am,...Ul,...il,...ol};static init(t,e=null,r=null,i=[]){const n=new ho(t,i);return n.self=e,e instanceof af?(n._activePlayer=e,n.pointerAdd(eo.ActivePlayer)):e instanceof hm?(n._activeNpc=e,n.pointerAdd(eo.ActiveNpc)):e instanceof Al?(n._activeLoc=e,n.pointerAdd(eo.ActiveLoc)):e instanceof fl&&(n._activeObj=e,n.pointerAdd(eo.ActiveObj)),r instanceof af?e instanceof af?(n._activePlayer2=r,n.pointerAdd(eo.ActivePlayer2)):(n._activePlayer=r,n.pointerAdd(eo.ActivePlayer)):r instanceof hm?e instanceof hm?(n._activeNpc2=r,n.pointerAdd(eo.ActiveNpc2)):(n._activeNpc=r,n.pointerAdd(eo.ActiveNpc)):r instanceof Al?e instanceof Al?(n._activeLoc2=r,n.pointerAdd(eo.ActiveLoc2)):(n._activeLoc=r,n.pointerAdd(eo.ActiveLoc)):r instanceof fl&&(e instanceof fl?(n._activeObj2=r,n.pointerAdd(eo.ActiveObj2)):(n._activeObj=r,n.pointerAdd(eo.ActiveObj))),n}static execute(t,e=!1,r=!1){if(!t||!t.script||!t.script.info)return ho.ABORTED;try{e&&t.reset(),t.execution!==ho.RUNNING&&t.executionHistory.push(t.execution),t.execution=ho.RUNNING;const i=1e3*performance.now();for(;t.execution===ho.RUNNING;){if(t.pc>=t.script.opcodes.length||t.pc<-1)throw new Error('Invalid program counter: '+t.pc+', max expected: '+t.script.opcodes.length);if(!r&&t.opcount>5e5)throw new Error('Too many instructions');t.opcount++,om.executeInner(t,t.script.opcodes[++t.pc])}const n=1e3*performance.now()-i|0;if(Ea.NODE_DEBUG_PROFILE&&n>1e3){const e=`Warning [cpu time]: Script: ${t.script.info.scriptName}, time: ${n}us, opcount: ${t.opcount}`;t.self instanceof af?t.self.wrappedMessageGame(e):console.warn(e)}}catch(e){if(t.pc>=0&&t.pc>16&1:r<=ro.POP_ARRAY_INT&&(i=0),e.message=ro[r].toLowerCase()+' '+e.message,i&&(e.message='.'+e.message)}if(t.self instanceof af){t.self.wrappedMessageGame(`script error: ${e.message}`),t.self.wrappedMessageGame(`file: ${f.basename(t.script.info.sourceFilePath)}`),t.self.wrappedMessageGame(''),t.self.wrappedMessageGame('stack backtrace:'),t.self.wrappedMessageGame(` 1: ${t.script.name} - ${t.script.fileName}:${t.script.lineNumber(t.pc)}`);let r=1;for(let e=t.fp;e>0;e--){const i=t.frames[e];i&&(r++,t.self.wrappedMessageGame(` ${r}: ${i.script.name} - ${i.script.fileName}:${i.script.lineNumber(i.pc)}`))}for(let e=t.debugFp;e>=0;e--){const i=t.debugFrames[e];i&&(r++,t.self.wrappedMessageGame(` ${r}: ${i.script.name} - ${i.script.fileName}:${i.script.lineNumber(i.pc)}`))}}console.error(`script error: ${e.message}`),console.error(`file: ${f.basename(t.script.info.sourceFilePath)}`),console.error(''),console.error('stack backtrace:'),console.error(` 1: ${t.script.name} - ${t.script.fileName}:${t.script.lineNumber(t.pc)}`);let r=1;for(let e=t.fp;e>0;e--){const i=t.frames[e];i&&(r++,console.error(` ${r}: ${i.script.name} - ${i.script.fileName}:${i.script.lineNumber(i.pc)}`))}for(let e=t.debugFp;e>=0;e--){const i=t.debugFrames[e];i&&(r++,console.error(` ${r}: ${i.script.name} - ${i.script.fileName}:${i.script.lineNumber(i.pc)}`))}t.execution=ho.ABORTED}return t.execution}static executeInner(t,e){const r=om.HANDLERS[e];if(!r)throw new Error(`Unknown opcode ${e}`);r(t)}}class hm extends Xl{static ANIM=2;static FACE_ENTITY=4;static SAY=8;static DAMAGE=16;static CHANGE_TYPE=32;static SPOTANIM=64;static FACE_COORD=128;nid;type;uid;origType;startX;startZ;levels=new Uint8Array(6);baseLevels=new Uint8Array(6);vars;varsString;activeScript=null;delay=0;queue=new is;timerInterval=0;timerClock=0;huntMode=-1;nextHuntTick=-1;huntrange=5;nextPatrolTick=-1;nextPatrolPoint=0;delayedPatrol=!1;heroPoints=new Array(16);constructor(t,e,r,i,n,s,a,o,h,l){super(t,e,r,i,n,s,h,l,$l.NAIVE,hm.FACE_COORD,hm.FACE_ENTITY),this.nid=a,this.type=o,this.uid=o<<16|a,this.startX=this.x,this.startZ=this.z,this.origType=o;const c=fa.get(o);for(let t=0;te&&e.uid===t));if(-1!==r)return void(this.heroPoints[r].points+=e);const i=this.heroPoints.findIndex((t=>t&&-1===t.uid));-1===i||(this.heroPoints[i]={uid:t,points:e})}findHero(){return this.heroPoints.sort(((t,e)=>e.points-t.points)),this.heroPoints[0]?.uid??-1}getVar(t){const e=La.get(t);return e.type===us.STRING?this.varsString[e.id]:this.vars[e.id]}setVar(t,e){const r=La.get(t);r.type===us.STRING&&'string'==typeof e?this.varsString[r.id]=e:'number'==typeof e&&(this.vars[r.id]=e)}resetEntity(t){if(t){this.type=this.origType,this.uid=this.type<<16|this.nid,this.faceX=-1,this.faceZ=-1,this.orientationX=-1,this.orientationZ=-1;for(let t=0;te.maxrange&&t>e.maxrange)return!1}if(this.targetOp>=Vs.OPPLAYER1&&this.targetOp<=Vs.OPPLAYER5){const t=Math.abs(this.target.x-this.startX),r=Math.abs(this.target.z-this.startZ);if(Math.max(t,r)>e.maxrange+1)return this.defaultMode(),!1;if(t===e.maxrange+1&&r===e.maxrange+1)return this.defaultMode(),!1}else if(this.targetOp>=Vs.APPLAYER1&&this.targetOp<=Vs.APPLAYER5&&oh.distanceToSW(this.target,{x:this.startX,z:this.startZ})>e.maxrange+e.attackrange)return this.defaultMode(),!1}if(t&&this.target instanceof Xl&&!this.interacted&&-1===this.walktrigger&&this.pathToPathingTarget(),-1!==this.walktrigger){const t=fa.get(this.type),e=no.getByTrigger(Ll.AI_QUEUE1+this.walktrigger,t.id,t.category);if(this.walktrigger=-1,e){const t=om.init(e,this,null,[this.walktriggerArg]);om.execute(t)}}return this.moveSpeed!==Zl.INSTANT&&(this.moveSpeed=this.defaultMoveSpeed()),super.processMovement()}blockWalkFlag(){return this.moveRestrict===ua.NORMAL?qo.NPC:this.moveRestrict===ua.BLOCKED?qo.OPEN:this.moveRestrict===ua.BLOCKED_NORMAL||this.moveRestrict===ua.INDOORS||this.moveRestrict===ua.OUTDOORS?qo.NPC:this.moveRestrict===ua.NOMOVE?qo.NULL:this.moveRestrict===ua.PASSTHRU?qo.OPEN:qo.NULL}defaultMoveSpeed(){return Zl.WALK}delayed(){return this.delay>Lm.currentTick}setTimer(t){this.timerInterval=t,this.timerClock=0}executeScript(t){if(!t)return;const e=om.execute(t);e!==ho.FINISHED&&e!==ho.ABORTED?e===ho.WORLD_SUSPENDED?Lm.enqueueScript(t,t.popInt()):e===ho.NPC_SUSPENDED?t.activeNpc.activeScript=t:t.activePlayer.activeScript=t:t===this.activeScript&&(this.activeScript=null),t.pointerGet(eo.ProtectedActivePlayer)&&t._activePlayer&&(t._activePlayer.protect=!1,t.pointerRemove(eo.ProtectedActivePlayer)),t.pointerGet(eo.ProtectedActivePlayer2)&&t._activePlayer2&&(t._activePlayer2.protect=!1,t.pointerRemove(eo.ProtectedActivePlayer2))}processTimers(){if(0!==this.timerInterval&&++this.timerClock>=this.timerInterval){this.timerClock=0;const t=fa.get(this.type),e=no.getByTrigger(Ll.AI_TIMER,t.id,t.category);e&&this.executeScript(om.init(e,this))}}processQueue(){for(let t=this.queue.head();null!==t;t=this.queue.next())if(this.delayed()||t.delay--,!this.delayed()&&t.delay<=0){const e=om.init(t.script,this,null,t.args);e.lastInt=t.lastInt,this.executeScript(e),t.unlink()}}enqueueScript(t,e=0,r=0){const i=new jl(0,t,[],e);i.lastInt=r,this.queue.addTail(i)}randomWalk(t){const e=Math.round(Math.random()*(2*t)-t),r=Math.round(Math.random()*(2*t)-t),i=this.startX+e,n=this.startZ+r;i===this.x&&n===this.z||this.queueWaypoint(i,n)}processNpcModes(){this.targetOp===Vs.NULL?this.defaultMode():this.targetOp===Vs.NONE?this.noMode():this.targetOp===Vs.WANDER?this.wanderMode():this.targetOp===Vs.PATROL?this.patrolMode():this.targetOp===Vs.PLAYERESCAPE?this.playerEscapeMode():this.targetOp===Vs.PLAYERFOLLOW?this.playerFollowMode():this.targetOp===Vs.PLAYERFACE?this.playerFaceMode():this.targetOp===Vs.PLAYERFACECLOSE?this.playerFaceCloseMode():this.aiMode()}noMode(){this.clearInteraction(),this.updateMovement(!1),this.targetOp=Vs.NONE}defaultMode(){this.clearInteraction(),this.updateMovement(!1);const t=fa.get(this.type);this.targetOp=t.defaultmode}wanderMode(){const t=fa.get(this.type);t.moverestrict!==ua.NOMOVE&&Math.random()<.125&&this.randomWalk(t.wanderrange),this.updateMovement(!1)}patrolMode(){const t=fa.get(this.type),e=t.patrolCoord,r=t.patrolDelay[this.nextPatrolPoint];let i=oh.unpackCoord(e[this.nextPatrolPoint]);this.updateMovement(!1),this.hasWaypoints()||this.target||this.queueWaypoint(i.x,i.z),(this.x!==i.x||this.z!==i.z)&&Lm.currentTick>=this.nextPatrolTick&&this.teleport(i.x,i.z,i.level),this.x!==i.x||this.z!==i.z||this.delayedPatrol||(this.nextPatrolTick=Lm.currentTick+r,this.delayedPatrol=!0),this.nextPatrolTick>Lm.currentTick||(this.nextPatrolPoint=(this.nextPatrolPoint+1)%e.length,this.nextPatrolTick=Lm.currentTick+30,this.delayedPatrol=!1,i=oh.unpackCoord(e[this.nextPatrolPoint]),this.queueWaypoint(i.x,i.z))}playerEscapeMode(){if(!this.target)return void this.defaultMode();if(!(this.target instanceof af))throw new Error('[Npc] Target must be a Player for playerescape mode.');if(null===Lm.getPlayerByUid(this.target.uid))return void this.defaultMode();if(oh.distanceToSW(this,this.target)>25)return void this.defaultMode();let t,e;this.target.x>=this.x&&this.target.z>=this.z?(t=nh,e=qo.WALL_SOUTH|qo.WALL_WEST):this.target.x>=this.x&&this.target.z=this.z?(t=ah,e=qo.WALL_SOUTH|qo.WALL_EAST):(t=eh,e=qo.WALL_NORTH|qo.WALL_EAST);const r=oh.moveX(this.x,t),i=oh.moveZ(this.z,t);if(Io(r,i,this.level,e))return void this.defaultMode();const n={x:r,z:i,level:this.level};if(oh.distanceToSW(n,{x:this.startX,z:this.startZ})t.maxrange?this.defaultMode():this.updateMovement(!1)}playerFaceCloseMode(){if(this.target){if(!(this.target instanceof af))throw new Error('[Npc] Target must be a Player for playerfaceclose mode.');null!=Lm.getPlayerByUid(this.target.uid)&&this.level===this.target.level?oh.distanceTo(this,this.target)>1?this.defaultMode():this.updateMovement(!1):this.defaultMode()}else this.defaultMode()}aiMode(){if(this.delayed()||!this.target)return void this.defaultMode();if(this.target.level!==this.level)return void this.defaultMode();if(this.target instanceof hm&&(void 0===Lm.getNpc(this.target.nid)||this.target.delayed()))return void this.defaultMode();if(this.target instanceof hm&&-1!==this.targetSubject.type&&null===Lm.getNpcByUid(this.targetSubject.type<<16|this.target.nid))return void this.defaultMode();if(this.target instanceof fl&&null===Lm.getObj(this.target.x,this.target.z,this.level,this.target.type,-1))return void this.defaultMode();if(this.target instanceof Al&&null===Lm.getLoc(this.target.x,this.target.z,this.level,this.target.type))return void this.defaultMode();if(this.target instanceof af&&null===Lm.getPlayerByUid(this.target.uid))return void this.defaultMode();const t=fa.get(this.type),e=this.targetOp>=Vs.APNPC1&&this.targetOp<=Vs.APNPC5||this.targetOp>=Vs.APPLAYER1&&this.targetOp<=Vs.APPLAYER5||this.targetOp>=Vs.APLOC1&&this.targetOp<=Vs.APLOC5||this.targetOp>=Vs.APOBJ1&&this.targetOp<=Vs.APOBJ5,r=!e,i=this.getTrigger();i&&r&&this.inOperableDistance(this.target)&&this.target instanceof Xl||i&&e&&this.inApproachDistance(t.attackrange,this.target)?(this.executeScript(om.init(i,this,this.target)),this.interacted=!0,this.clearWaypoints()):this.inOperableDistance(this.target)&&this.target instanceof Xl&&(this.target=null,this.interacted=!0,this.clearWaypoints());const n=this.updateMovement();n&&(this.alreadyFacedEntity=!1),this.target&&!this.interacted&&(this.interacted=!1,i&&r&&this.inOperableDistance(this.target)&&(this.target instanceof Xl||!n)||i&&e&&this.inApproachDistance(t.attackrange,this.target)?(this.executeScript(om.init(i,this,this.target)),this.interacted=!0,this.clearWaypoints()):this.inOperableDistance(this.target)&&(this.target instanceof Xl||!n)&&(this.target=null,this.interacted=!0,this.clearWaypoints()))}getTrigger(){const t=this.getTriggerForMode(this.targetOp);return t?no.getByTrigger(t,this.type,-1)??null:null}getTriggerForMode(t){return t===Vs.OPPLAYER1?Ll.AI_OPPLAYER1:t===Vs.OPPLAYER2?Ll.AI_OPPLAYER2:t===Vs.OPPLAYER3?Ll.AI_OPPLAYER3:t===Vs.OPPLAYER4?Ll.AI_OPPLAYER4:t===Vs.OPPLAYER5?Ll.AI_OPPLAYER5:t===Vs.APPLAYER1?Ll.AI_APPLAYER1:t===Vs.APPLAYER2?Ll.AI_APPLAYER2:t===Vs.APPLAYER3?Ll.AI_APPLAYER3:t===Vs.APPLAYER4?Ll.AI_APPLAYER4:t===Vs.APPLAYER5?Ll.AI_APPLAYER5:t===Vs.OPLOC1?Ll.AI_OPLOC1:t===Vs.OPLOC2?Ll.AI_OPLOC2:t===Vs.OPLOC3?Ll.AI_OPLOC3:t===Vs.OPLOC4?Ll.AI_OPLOC4:t===Vs.OPLOC5?Ll.AI_OPLOC5:t===Vs.APLOC1?Ll.AI_APLOC1:t===Vs.APLOC2?Ll.AI_APLOC2:t===Vs.APLOC3?Ll.AI_APLOC3:t===Vs.APLOC4?Ll.AI_APLOC4:t===Vs.APLOC5?Ll.AI_APLOC5:t===Vs.OPOBJ1?Ll.AI_OPOBJ1:t===Vs.OPOBJ2?Ll.AI_OPOBJ2:t===Vs.OPOBJ3?Ll.AI_OPOBJ3:t===Vs.OPOBJ4?Ll.AI_OPOBJ4:t===Vs.OPOBJ5?Ll.AI_OPOBJ5:t===Vs.APOBJ1?Ll.AI_APOBJ1:t===Vs.APOBJ2?Ll.AI_APOBJ2:t===Vs.APOBJ3?Ll.AI_APOBJ3:t===Vs.APOBJ4?Ll.AI_APOBJ4:t===Vs.APOBJ5?Ll.AI_APOBJ5:t===Vs.OPNPC1?Ll.AI_OPNPC1:t===Vs.OPNPC2?Ll.AI_OPNPC2:t===Vs.OPNPC3?Ll.AI_OPNPC3:t===Vs.OPNPC4?Ll.AI_OPNPC4:t===Vs.OPNPC5?Ll.AI_OPNPC5:t===Vs.APNPC1?Ll.AI_APNPC1:t===Vs.APNPC2?Ll.AI_APNPC2:t===Vs.APNPC3?Ll.AI_APNPC3:t===Vs.APNPC4?Ll.AI_APNPC4:t===Vs.APNPC5?Ll.AI_APNPC5:t===Vs.QUEUE1?Ll.AI_QUEUE1:t===Vs.QUEUE2?Ll.AI_QUEUE2:t===Vs.QUEUE3?Ll.AI_QUEUE3:t===Vs.QUEUE4?Ll.AI_QUEUE4:t===Vs.QUEUE5?Ll.AI_QUEUE5:t===Vs.QUEUE6?Ll.AI_QUEUE6:t===Vs.QUEUE7?Ll.AI_QUEUE7:t===Vs.QUEUE8?Ll.AI_QUEUE8:t===Vs.QUEUE9?Ll.AI_QUEUE9:t===Vs.QUEUE10?Ll.AI_QUEUE10:t===Vs.QUEUE11?Ll.AI_QUEUE11:t===Vs.QUEUE12?Ll.AI_QUEUE12:t===Vs.QUEUE13?Ll.AI_QUEUE13:t===Vs.QUEUE14?Ll.AI_QUEUE14:t===Vs.QUEUE15?Ll.AI_QUEUE15:t===Vs.QUEUE16?Ll.AI_QUEUE16:t===Vs.QUEUE17?Ll.AI_QUEUE17:t===Vs.QUEUE18?Ll.AI_QUEUE18:t===Vs.QUEUE19?Ll.AI_QUEUE19:t===Vs.QUEUE20?Ll.AI_QUEUE20:null}huntAll(){if(this.nextHuntTick>Lm.currentTick)return;const t=Gs.get(this.huntMode);if(t.type===ks.OFF)return;if(t.nobodyNear===xs.PAUSEHUNT&&!Lm.getZoneGrid(this.level).isFlagged(oh.zone(this.x),oh.zone(this.z),5))return;if(!t.findKeepHunting&&null!==this.target)return;let e;if(e=t.type===ks.PLAYER?this.huntPlayers(t):t.type===ks.NPC?this.huntNpcs(t):t.type===ks.OBJ?this.huntObjs(t):this.huntLocs(t),e.length>0){const r=e[Math.floor(Math.random()*e.length)];this.setInteraction(Rl.SCRIPT,r,t.findNewMode)}this.nextHuntTick=Lm.currentTick+t.rate}huntPlayers(t){const e=fa.get(this.type),r=[],i=new _l(Lm.currentTick,this.level,this.x,this.z,this.huntrange,t.checkVis,-1,-1,ks.PLAYER),n=t.findNewMode>=Vs.OPPLAYER1&&t.findNewMode<=Vs.OPPLAYER5;for(const s of i){if(!(s instanceof af))throw new Error('[Npc] huntAll must be of type Player here.');if(n){const t=Math.abs(s.x-this.startX),r=Math.abs(s.z-this.startZ);if(Math.max(t,r)>e.maxrange+1)continue;if(t===e.maxrange+1&&r===e.maxrange+1)continue}else if(oh.distanceToSW(s,{x:this.startX,z:this.startZ})>e.maxrange+e.attackrange)continue;if((!t.checkAfk||!s.zonesAfk())&&((t.checkNotTooStrong!==Rs.OUTSIDE_WILDERNESS||s.isInWilderness()||!(s.combatLevel>2*e.vislevel))&&!(-1!==t.checkNotCombat&&s.getVar(t.checkNotCombat)+8>Lm.currentTick||-1!==t.checkNotCombatSelf&&this.getVar(t.checkNotCombatSelf)>=Lm.currentTick))){if(-1!==t.checkInv){let e=0;if(-1!==t.checkObj?e=s.invTotal(t.checkInv,t.checkObj):-1!==t.checkObjParam&&(e=s.invTotalParam(t.checkInv,t.checkObjParam)),et.checkInvMaxQuantity)continue}t.checkNotBusy&&s.busy()||r.push(s)}}return r}huntNpcs(t){return Array.from(new _l(Lm.currentTick,this.level,this.x,this.z,this.huntrange,t.checkVis,t.checkNpc,t.checkCategory,ks.NPC))}huntObjs(t){return Array.from(new _l(Lm.currentTick,this.level,this.x,this.z,this.huntrange,t.checkVis,t.checkObj,t.checkCategory,ks.OBJ))}huntLocs(t){return Array.from(new _l(Lm.currentTick,this.level,this.x,this.z,this.huntrange,t.checkVis,t.checkLoc,t.checkCategory,ks.SCENERY))}playAnimation(t,e){t>=Ia.count||(-1==t||-1==this.animId||Ia.get(t).priority>Ia.get(this.animId).priority||0===Ia.get(this.animId).priority)&&(this.animId=t,this.animDelay=e,this.mask|=hm.ANIM)}spotanim(t,e,r){this.graphicId=t,this.graphicHeight=e,this.graphicDelay=r,this.mask|=hm.SPOTANIM}applyDamage(t,e){this.damageTaken=t,this.damageType=e;const r=this.levels[da.HITPOINTS];r-t<=0?(this.levels[da.HITPOINTS]=0,this.damageTaken=r):this.levels[da.HITPOINTS]=r-t,this.mask|=hm.DAMAGE}say(t){t&&(this.chat=t,this.mask|=hm.SAY)}faceSquare(t,e){this.faceX=2*t+1,this.faceZ=2*e+1,this.orientationX=this.faceX,this.orientationZ=this.faceZ,this.mask|=hm.FACE_COORD}changeType(t){this.type=t,this.mask|=hm.CHANGE_TYPE,this.uid=t<<16|this.nid;const e=fa.get(t);this.setTimer(e.timer)}}class lm{static OPEN=0;static BLOCKED=1;static BRIDGE=2;static ROOF=4;static WALL=8;static LOWMEMORY=16;static Y=4;static X=64;static Z=64;static MAPSQUARE=lm.X*lm.Y*lm.Z;init(t){console.time('Loading game map');const e='data/pack/server/maps/',r=Ka.readdirSync(e).filter((t=>'m'===t[0]));for(let i=0;i(xn(),Un))),i=r;for(let r=0;r0;){const{x:i,z:n,level:s}=this.unpackCoord(t.g2()),a=e+i,o=r+n,h=t.g1();for(let e=0;e0;){const{x:n,z:s,level:a}=this.unpackCoord(t.g2()),o=e+n,h=r+s,l=t.g1();for(let e=0;e>2,y=3&u,v=a+r,b=l+i;n.zone(v,b,d).addStaticLoc(new Al(d,v,b,p,m,cl.RESPAWN,s,g,y)),f.blockwalk&&this.changeLocCollision(g,y,f.blockrange,m,p,f.active,v,b,d,!0)}a=e.gsmart()}}packCoord(t,e,r){return 63&e|(63&t)<<6|(3&r)<<12}unpackCoord(t){return{x:t>>6&63,z:63&t,level:t>>12&3}}}class cm{count=0;rsl=new Int32Array(256);mem=new Int32Array(256);a=0;b=0;c=0;constructor(t=[0,0,0,0]){for(let e=0;e>>2,n+=e,r+=i,r^=i<<8,s+=r,i+=n,i^=n>>>16,a+=i,n+=s,n^=s<<10,o+=n,s+=a,s^=a>>>4,t+=s,a+=o,a^=o<<8,e+=a,o+=t,o^=t>>>9,r+=o,t+=e;for(let h=0;h<256;h+=8)t+=this.rsl[h],e+=this.rsl[h+1],r+=this.rsl[h+2],i+=this.rsl[h+3],n+=this.rsl[h+4],s+=this.rsl[h+5],a+=this.rsl[h+6],o+=this.rsl[h+7],t^=e<<11,i+=t,e+=r,e^=r>>>2,n+=e,r+=i,r^=i<<8,s+=r,i+=n,i^=n>>>16,a+=i,n+=s,n^=s<<10,o+=n,s+=a,s^=a>>>4,t+=s,a+=o,a^=o<<8,e+=a,o+=t,o^=t>>>9,r+=o,t+=e,this.mem[h]=t,this.mem[h+1]=e,this.mem[h+2]=r,this.mem[h+3]=i,this.mem[h+4]=n,this.mem[h+5]=s,this.mem[h+6]=a,this.mem[h+7]=o;for(let h=0;h<256;h+=8)t+=this.mem[h],e+=this.mem[h+1],r+=this.mem[h+2],i+=this.mem[h+3],n+=this.mem[h+4],s+=this.mem[h+5],a+=this.mem[h+6],o+=this.mem[h+7],t^=e<<11,i+=t,e+=r,e^=r>>>2,n+=e,r+=i,r^=i<<8,s+=r,i+=n,i^=n>>>16,a+=i,n+=s,n^=s<<10,o+=n,s+=a,s^=a>>>4,t+=s,a+=o,a^=o<<8,e+=a,o+=t,o^=t>>>9,r+=o,t+=e,this.mem[h]=t,this.mem[h+1]=e,this.mem[h+2]=r,this.mem[h+3]=i,this.mem[h+4]=n,this.mem[h+5]=s,this.mem[h+6]=a,this.mem[h+7]=o;this.isaac(),this.count=256}isaac(){this.c++,this.b+=this.c;for(let t=0;t<256;t++){const e=this.mem[t];switch(3&t){case 0:this.a^=this.a<<13;break;case 1:this.a^=this.a>>>6;break;case 2:this.a^=this.a<<2;break;case 3:this.a^=this.a>>>16}let r;this.a+=this.mem[t+128&255],this.mem[t]=r=this.mem[e>>>2&255]+this.a+this.b,this.rsl[t]=this.b=this.mem[r>>>8>>>2&255]+e}}nextInt(){return 0==this.count--&&(this.isaac(),this.count=255),this.rsl[this.count]}}var{Worker:um}=()=>({});function dm(t){return'undefined'!=typeof self?new Worker(t,{type:'module'}):new um(t)}var{default:fm}=()=>({}),{default:pm}=()=>({}),mm='(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])',gm=`(?:${mm}\\.){3}${mm}`,ym=(new RegExp(`^${gm}$`),'(?:[0-9a-fA-F]{1,4})');new RegExp(`^(?:(?:${ym}:){7}(?:${ym}|:)|(?:${ym}:){6}(?:${gm}|:${ym}|:)|(?:${ym}:){5}(?::${gm}|(?::${ym}){1,2}|:)|(?:${ym}:){4}(?:(?::${ym}){0,1}:${gm}|(?::${ym}){1,3}|:)|(?:${ym}:){3}(?:(?::${ym}){0,2}:${gm}|(?::${ym}){1,4}|:)|(?:${ym}:){2}(?:(?::${ym}){0,3}:${gm}|(?::${ym}){1,5}|:)|(?:${ym}:){1}(?:(?::${ym}){0,4}:${gm}|(?::${ym}){1,6}|:)|(?::(?:(?::${ym}){0,5}:${gm}|(?::${ym}){1,7}|:)))(?:%[0-9a-zA-Z-.:]{1,})?$`);class vm{static SUCCESSFUL=Uint8Array.from([2]);static INVALID_USER_OR_PASS=Uint8Array.from([3]);static ACCOUNT_DISABLED=Uint8Array.from([4]);static LOGGED_IN=Uint8Array.from([5]);static SERVER_UPDATED=Uint8Array.from([6]);static WORLD_FULL=Uint8Array.from([7]);static LOGIN_SERVER_OFFLINE=Uint8Array.from([8]);static LOGIN_LIMIT_EXCEEDED=Uint8Array.from([9]);static UNABLE_TO_CONNECT=Uint8Array.from([10]);static LOGIN_REJECTED=Uint8Array.from([11]);static NEED_MEMBERS_ACCOUNT=Uint8Array.from([12]);static COULD_NOT_COMPLETE=Uint8Array.from([13]);static SERVER_UPDATING=Uint8Array.from([14]);static RECONNECTING=Uint8Array.from([15]);static LOGIN_ATTEMPTS_EXCEEDED=Uint8Array.from([16]);static STANDING_IN_MEMBERS=Uint8Array.from([17]);static STAFF_MOD_LEVEL=Uint8Array.from([18])}var{default:bm}=()=>({}),_m=function(t){if(!bm.existsSync(t))return;const e=as.load(t),r=as.getcrc(e.data,0,e.data.length);Sm.push(r),Am.p4(r)};function wm(){Sm=[],Am.pos=0,Am.p4(0),_m('data/pack/client/title'),_m('data/pack/client/config'),_m('data/pack/client/interface'),_m('data/pack/client/media'),_m('data/pack/client/models'),_m('data/pack/client/textures'),_m('data/pack/client/wordenc'),_m('data/pack/client/sounds'),Tm=as.getcrc(Am.data,0,Am.data.length)}async function Em(t){if(!(await fetch(t)).ok)return;const e=await as.loadAsync(t),r=as.getcrc(e.data,0,e.data.length);Sm.push(r),Am.p4(r)}var Am=new as(new Uint8Array(36)),Sm=[],Tm=0;'undefined'==typeof self?bm.existsSync('data/pack/client/')&&wm():(await fetch('data/pack/client')).ok&&await async function(){Sm=[],Am.pos=0,Am.p4(0),await Em('data/pack/client/title'),await Em('data/pack/client/config'),await Em('data/pack/client/interface'),await Em('data/pack/client/media'),await Em('data/pack/client/models'),await Em('data/pack/client/textures'),await Em('data/pack/client/wordenc'),await Em('data/pack/client/sounds'),Tm=as.getcrc(Am.data,0,Am.data.length)}();var Mm=new class{loginThread=dm('undefined'!=typeof self?'LoginThread.js':'./src/lostcity/server/LoginThread.ts');loginRequests=new Map;logoutRequests=new Set;constructor(){const t=t=>{try{this.onMessage(t)}catch(t){console.error('Login Thread:',t)}};'undefined'!=typeof self?this.loginThread instanceof Worker&&(this.loginThread.onmessage=t):this.loginThread instanceof NodeWorker2&&this.loginThread.on('message',t)}async readIn(t,e){const r=e.g1();if(16===r){const i=e.g1();if(e.available=2e3)return i.writeImmediate(vm.WORLD_FULL),void i.close();if(Lm.shutdownTick>-1&&Lm.currentTick-Lm.shutdownTick>0)return i.writeImmediate(vm.SERVER_UPDATING),void i.close();if(!Ea.LOGIN_KEY)for(const t of Lm.players)if(t.username===a)return i.writeImmediate(vm.LOGGED_IN),void i.close();i.decryptor=new cm(s);for(let t=0;t<4;t++)s[t]+=50;i.encryptor=new cm(s);const h=vp.load(a,new as(o),i);h.lowMemory=!!(1&n),h.webClient=i.isWebSocket(),Lm.addPlayer(h);break}case'logoutreply':{const{username:e}=t,r=Lm.getPlayerByUsername(e);r&&(Lm.getZone(r.x,r.z,r.level).leave(r),Lm.players.remove(r.pid),r.pid=-1,r.terminate(),this.logoutRequests.delete(r.username37));break}default:throw new Error('Unknown message type: '+t.type)}else switch(t.data.type){case'loginreply':{const{status:e,socket:r}=t.data,i=this.loginRequests.get(r);if(!i)return;if(this.loginRequests.delete(r),2!==e[0])return i.writeImmediate(e),void i.close();const{info:n,seed:s,username:a,save:o}=t.data;if(Lm.getTotalPlayers()>=2e3)return i.writeImmediate(vm.WORLD_FULL),void i.close();if(Lm.shutdownTick>-1&&Lm.currentTick-Lm.shutdownTick>0)return i.writeImmediate(vm.SERVER_UPDATING),void i.close();if(!Ea.LOGIN_KEY)for(const t of Lm.players)if(t.username===a)return i.writeImmediate(vm.LOGGED_IN),void i.close();i.decryptor=new cm(s);for(let t=0;t<4;t++)s[t]+=50;i.encryptor=new cm(s);const h=vp.load(a,new as(o),i);h.lowMemory=!!(1&n),h.webClient=!0,Lm.addPlayer(h);break}case'logoutreply':{const{username:e}=t.data,r=Lm.getPlayerByUsername(e);r&&(Lm.getZone(r.x,r.z,r.level).leave(r),Lm.players.remove(r.pid),r.pid=-1,r.terminate(),this.logoutRequests.delete(r.username37));break}default:throw new Error('Unknown message type: '+t.data.type)}}};class Im extends Array{free;indexPadding;ids;lastUsedIndex=0;constructor(t,e){super(t),this.ids=new Int32Array(t).fill(-1),this.free=new Set(Array.from({length:t},((t,e)=>e))),this.indexPadding=e}next(t=!1,e=this.lastUsedIndex+1){const r=this.ids.length;for(let t=e;t(xn(),Un))),i=e;for(let t=0;t{'done'===t.type&&(this.devRebuilding=!1,this.reload())})),this.devThread.on('exit',(()=>{this.devRebuilding=!1,this.stopDevWatcher(),-1===this.shutdownTick&&(this.broadcastMes('Error while rebuilding - see console for more info.'),this.startDevWatcher())})),this.devWatcher=new Watcher('./data/src',{recursive:!0}),this.devWatcher.on('add',(t=>{if(t.endsWith('.pack'))return;const e=Gn.statSync(t);this.devMTime.set(t,e.mtimeMs)})),this.devWatcher.on('change',(t=>{if(t.endsWith('.pack'))return;const e=Gn.statSync(t),r=this.devMTime.get(t);r&&r>=e.mtimeMs||(this.devMTime.set(t,e.mtimeMs),this.devRebuilding||(console.log('dev:',f.basename(t),'was edited'),this.devRebuilding=!0,this.broadcastMes('Rebuilding, please wait...'),this.devThread||(this.devThread=dm('./src/lostcity/server/DevThread.ts')),this.devThread.postMessage({type:'pack'})))}))}stopDevWatcher(){this.devWatcher&&this.devWatcher.close(),this.devThread&&(this.devThread.terminate(),this.devThread=null)}rebootTimer(t){this.shutdownTick=this.currentTick+t,this.stopDevWatcher();for(const t of this.players)t.write(new Wd(this.shutdownTick-this.currentTick))}async cycle(t=!0){const e=Date.now();this.processWorld(),await this.processClientsIn(),this.processNpcs(),await this.processPlayers(),await this.processLogouts(),await this.processLogins(),this.processZones(),this.processMovementDirections(),await this.processClientsOut(),this.processCleanup();const r=this.currentTick;r%Nm.LOGIN_PINGRATE==0&&this.heartbeat(),this.shutdownTick>-1&&r>=this.shutdownTick&&await this.processShutdown(),r%Nm.PLAYER_SAVERATE==0&&r>0&&this.savePlayers(),this.currentTick++,this.cycleStats[al.CYCLE]=Date.now()-e,this.lastCycleStats[al.CYCLE]=this.cycleStats[al.CYCLE],this.lastCycleStats[al.WORLD]=this.cycleStats[al.WORLD],this.lastCycleStats[al.CLIENT_IN]=this.cycleStats[al.CLIENT_IN],this.lastCycleStats[al.NPC]=this.cycleStats[al.NPC],this.lastCycleStats[al.PLAYER]=this.cycleStats[al.PLAYER],this.lastCycleStats[al.LOGOUT]=this.cycleStats[al.LOGOUT],this.lastCycleStats[al.LOGIN]=this.cycleStats[al.LOGIN],this.lastCycleStats[al.ZONE]=this.cycleStats[al.ZONE],this.lastCycleStats[al.CLIENT_OUT]=this.cycleStats[al.CLIENT_OUT],this.lastCycleStats[al.CLEANUP]=this.cycleStats[al.CLEANUP],this.lastCycleStats[al.BANDWIDTH_IN]=this.cycleStats[al.BANDWIDTH_IN],this.lastCycleStats[al.BANDWIDTH_OUT]=this.cycleStats[al.BANDWIDTH_OUT],t&&setTimeout(this.cycle.bind(this),this.tickRate-this.cycleStats[al.CYCLE]),Ea.NODE_DEBUG_PROFILE&&(console.log(`tick ${this.currentTick} took ${this.cycleStats[al.CYCLE]}ms: ${this.getTotalPlayers()} players`),console.log(`${this.cycleStats[al.WORLD]} ms world | ${this.cycleStats[al.CLIENT_IN]} ms client in | ${this.cycleStats[al.NPC]} ms npcs | ${this.cycleStats[al.PLAYER]} ms players | ${this.cycleStats[al.LOGOUT]} ms logout | ${this.cycleStats[al.LOGIN]} ms login | ${this.cycleStats[al.ZONE]} ms zones | ${this.cycleStats[al.CLIENT_OUT]} ms client out | ${this.cycleStats[al.CLEANUP]} ms cleanup`),console.log('----'))}processWorld(){const t=Date.now(),e=this.currentTick;for(let t=this.queue.head();t;t=this.queue.next()){if(t.delay-- >0)continue;const e=t.script;try{const r=om.execute(e);t.unlink(),r===ho.SUSPENDED?e.activePlayer.activeScript=e:r===ho.NPC_SUSPENDED?e.activeNpc.activeScript=e:r===ho.WORLD_SUSPENDED&&this.enqueueScript(e,e.popInt())}catch(t){console.error(t)}}if(e%Nm.AFK_EVENTRATE==0)for(const t of this.players)t.afkEventReady=Math.random()<(t.zonesAfk()?.1666:.0833);for(const t of this.npcs)t.updateLifeCycle(e)&&(t.lifecycle===cl.RESPAWN?this.addNpc(t,-1):t.lifecycle===cl.DESPAWN&&this.removeNpc(t,-1));for(const t of this.npcs)t.checkLifeCycle(e)&&!t.delayed()&&-1!==t.huntMode&&t.huntAll();this.cycleStats[al.WORLD]=Date.now()-t}async processClientsIn(){const t=Date.now();this.cycleStats[al.BANDWIDTH_IN]=0;for(const t of this.players)if($p(t))try{t.decodeIn()}catch(e){console.error(e),await this.removePlayer(t)}for(const t of this.players)if($p(t)){if(t.userPath.length>0||t.opcalled){if(t.delayed()){t.unsetMapFlag();continue}if((!t.target||t.target instanceof Al||t.target instanceof fl)&&-1!==t.faceEntity&&(t.faceEntity=-1,t.mask|=af.FACE_ENTITY),t.opcalled&&(0===t.userPath.length||!Ea.NODE_CLIENT_ROUTEFINDER)){t.pathToTarget();continue}t.pathToMoveClick(t.userPath,!Ea.NODE_CLIENT_ROUTEFINDER)}t.target instanceof af&&(t.targetOp===Ll.APPLAYER3||t.targetOp===Ll.OPPLAYER3)&&(oh.distanceToSW(t,t.target)<=25?t.pathToPathingTarget():t.clearWaypoints())}this.cycleStats[al.CLIENT_IN]=Date.now()-t}processNpcs(){const t=Date.now();for(const t of this.npcs)if(t.checkLifeCycle(this.currentTick))try{if(t.delayed())continue;if(t.activeScript&&t.executeScript(t.activeScript),!t.checkLifeCycle(this.currentTick))continue;t.processTimers(),t.processQueue(),t.processNpcModes(),t.validateDistanceWalked()}catch(e){console.error(e),this.removeNpc(t,-1)}this.cycleStats[al.NPC]=Date.now()-t}async processPlayers(){const t=Date.now();for(const t of this.players)try{t.playtime++,t.activeScript&&!t.delayed()&&t.activeScript.execution===ho.SUSPENDED&&t.executeScript(t.activeScript,!0),t.processQueues(),t.processTimers(0),t.processTimers(1),t.processEngineQueue(),t.processInteraction(),t.mask&af.EXACT_MOVE||t.validateDistanceWalked(),this.shutdownTick=Nm.TIMEOUT_IDLE_TICKS&&(t.logoutRequested=!0),t.logoutRequested&&t.closeModal()}catch(e){console.error(e),await this.removePlayer(t)}this.cycleStats[al.PLAYER]=Date.now()-t}async processLogouts(){const t=Date.now();for(const t of this.players)if(Ea.NODE_SOCKET_TIMEOUT&&this.currentTick-t.lastResponse>=Nm.TIMEOUT_LOGOUT_TICKS&&(t.queue.clear(),t.weakQueue.clear(),t.engineQueue.clear(),t.clearInteraction(),t.closeModal(),t.unsetMapFlag(),t.logoutRequested=!0,t.setVar(Pa.LASTCOMBAT,0)),t.logoutRequested)if(null===t.queue.head()){const e=no.getByTriggerSpecific(Ll.LOGOUT,-1,-1);if(!e){console.error('LOGOUT TRIGGER IS BROKEN!');continue}const r=om.init(e,t);r.pointerAdd(eo.ProtectedActivePlayer),om.execute(r);0===r.popInt()&&(t.logoutRequested=!1),t.logoutRequested&&await this.removePlayer(t)}else t.messageGame('[DEBUG]: Waiting for queue to empty before logging out.');this.cycleStats[al.LOGOUT]=Date.now()-t}async processLogins(){const t=Date.now();t:for(const t of this.newPlayers){for(const e of this.players)if(t.username===e.username){$p(t)&&t.client&&(t.client.send(vm.LOGGED_IN),t.client.close());continue t}let e;try{e=this.getNextPid($p(t)?t.client:null)}catch(e){$p(t)&&(t.client?.send(vm.WORLD_FULL),t.client?.close());continue}this.players.set(e,t),t.pid=e,t.uid=(Number(0x1fffffn&t.username37)<<11|t.pid)>>>0,t.tele=!0,this.getZone(t.x,t.z,t.level).enter(t),t.onLogin(),this.shutdownTick>-1&&t.write(new Wd(this.shutdownTick-this.currentTick)),$p(t)&&t.client&&(t.client.state=1,t.staffModLevel>=2?t.client.send(vm.STAFF_MOD_LEVEL):t.client.send(vm.SUCCESSFUL))}this.newPlayers.clear(),this.cycleStats[al.LOGIN]=Date.now()-t}processZones(){const t=Date.now(),e=this.currentTick,r=this.zonesTracking.get(e);if(void 0!==r)for(const t of r)t.tick(e);this.computeSharedEvents(),this.cycleStats[al.ZONE]=Date.now()-t}processMovementDirections(){for(const t of this.players)t.convertMovementDir();for(const t of this.npcs)t.convertMovementDir()}async processClientsOut(){const t=Date.now();this.cycleStats[al.BANDWIDTH_OUT]=0;for(const t of this.players)if($p(t))try{t.updateMap(),t.updatePlayers(),t.updateNpcs(),t.updateZones(),t.updateInvs(),t.updateStats(),t.updateAfkZones(),t.encodeOut()}catch(e){console.error(e),await this.removePlayer(t)}else t.highPriorityOut.clear(),t.lowPriorityOut.clear();this.cycleStats[al.CLIENT_OUT]=Date.now()-t}processCleanup(){const t=Date.now(),e=this.currentTick,r=this.zonesTracking.get(e);if(void 0!==r)for(const t of r)t.reset();this.zonesTracking.delete(e);for(const t of this.players){t.resetEntity(!1);for(const e of t.invs.values())e&&(e.update=!1)}for(const t of this.npcs)t.checkLifeCycle(e)&&t.resetEntity(!1);for(const t of this.invs){t.update=!1;const r=Zs.get(t.type);if(r.restock&&r.stockcount&&r.stockrate)for(let i=0;ir.stockcount[i]&&e%r.stockrate[i]==0||r.allstock&&!r.stockcount[i]&&e%Nm.INV_STOCKRATE==0)&&(t.remove(n?.id,1,i,!0),t.update=!0))}}this.cycleStats[al.CLEANUP]=Date.now()-t}heartbeat(){const t=[];for(const e of this.players)t.push(e.username37);Mm.loginThread.postMessage({type:'heartbeat',players:t})}async processShutdown(){const t=this.currentTick-this.shutdownTick;if(this.getTotalPlayers()){for(const e of this.players)e.logoutRequested=!0,$p(e)&&(e.logout(),e.client&&t>2&&e.client.close());if(this.npcs.reset(),t>2){if(console.log('Super fast shutdown initiated...'),this.tickRate>Nm.SHUTDOWN_TICKRATE&&(this.tickRate=Nm.SHUTDOWN_TICKRATE),t>Nm.SHUTDOWN_TICKS){for(const t of this.players)await this.removePlayer(t);this.tickRate=Nm.NORMAL_TICKRATE}Ea.NODE_PRODUCTION||process.exit(0)}}else process.exit(0)}savePlayers(){if('undefined'==typeof self)for(const t of this.players)t.save().release()}enqueueScript(t,e=0){this.queue.addTail(new Vl(t,e+1))}getInventory(t){if(-1===t)return null;for(const e of this.invs)if(e.type===t)return e;const e=co.fromType(t);return this.invs.add(e),e}getZone(t,e,r){return this.zoneMap.zone(t,e,r)}getZoneIndex(t){return this.zoneMap.zoneByIndex(t)}getZoneGrid(t){return this.zoneMap.grid(t)}computeSharedEvents(){const t=new Set;for(const e of this.players)if($p(e))for(const r of e.buildArea.loadedZones)t.add(r);for(const e of t)this.getZoneIndex(e).computeShared()}addNpc(t,e){this.npcs.set(t.nid,t),t.x=t.startX,t.z=t.startZ;switch(this.getZone(t.x,t.z,t.level).enter(t),t.blockWalk){case ha.NPC:this.gameMap.changeNpcCollision(t.width,t.x,t.z,t.level,!0);break;case ha.ALL:this.gameMap.changeNpcCollision(t.width,t.x,t.z,t.level,!0),this.gameMap.changePlayerCollision(t.width,t.x,t.z,t.level,!0)}t.resetEntity(!0),t.playAnimation(-1,0),t.setLifeCycle(this.currentTick+e)}removeNpc(t,e){switch(this.getZone(t.x,t.z,t.level).leave(t),t.blockWalk){case ha.NPC:this.gameMap.changeNpcCollision(t.width,t.x,t.z,t.level,!1);break;case ha.ALL:this.gameMap.changeNpcCollision(t.width,t.x,t.z,t.level,!1),this.gameMap.changePlayerCollision(t.width,t.x,t.z,t.level,!1)}t.lifecycle===cl.DESPAWN?this.npcs.remove(t.nid):t.lifecycle===cl.RESPAWN&&t.setLifeCycle(this.currentTick+e)}getLoc(t,e,r,i){return this.getZone(t,e,r).getLoc(t,e,i)}getObj(t,e,r,i,n){return this.getZone(t,e,r).getObj(t,e,i,n)}trackZone(t,e){let r;const i=this.zonesTracking.get(t);r=i||new Set,r.add(e),this.zonesTracking.set(t,r)}addLoc(t,e){const r=ta.get(t.type);r.blockwalk&&this.gameMap.changeLocCollision(t.shape,t.angle,r.blockrange,r.length,r.width,r.active,t.x,t.z,t.level,!0);const i=this.getZone(t.x,t.z,t.level);i.addLoc(t),t.setLifeCycle(this.currentTick+e),this.trackZone(this.currentTick+e,i),this.trackZone(this.currentTick,i)}mergeLoc(t,e,r,i,n,s,a,o){const h=this.getZone(t.x,t.z,t.level);h.mergeLoc(t,e,r,i,n,s,a,o),this.trackZone(this.currentTick,h)}animLoc(t,e){const r=this.getZone(t.x,t.z,t.level);r.animLoc(t,e),this.trackZone(this.currentTick,r)}removeLoc(t,e){const r=ta.get(t.type);r.blockwalk&&this.gameMap.changeLocCollision(t.shape,t.angle,r.blockrange,r.length,r.width,r.active,t.x,t.z,t.level,!1);const i=this.getZone(t.x,t.z,t.level);i.removeLoc(t),t.setLifeCycle(this.currentTick+e),this.trackZone(this.currentTick+e,i),this.trackZone(this.currentTick,i)}addObj(t,e,r){const i=Aa.get(t.type),n=this.getObj(t.x,t.z,t.level,t.type,e);if(n&&n.lifecycle===cl.DESPAWN&&t.lifecycle===cl.DESPAWN){const r=t.count+n.count;if(i.stackable&&r<=co.STACK_LIMIT)return void this.changeObj(n,e,r)}const s=this.getZone(t.x,t.z,t.level);s.addObj(t,e),-1!==e&&i.tradeable?(t.setLifeCycle(this.currentTick+100),this.trackZone(this.currentTick+100,s),this.trackZone(this.currentTick,s),t.receiverId=e,t.reveal=r):(t.setLifeCycle(this.currentTick+r),this.trackZone(this.currentTick+r,s),this.trackZone(this.currentTick,s))}revealObj(t){const e=t.reveal,r=this.getZone(t.x,t.z,t.level);r.revealObj(t,t.receiverId),t.setLifeCycle(this.currentTick+e),this.trackZone(this.currentTick+e,r),this.trackZone(this.currentTick,r)}changeObj(t,e,r){const i=this.getZone(t.x,t.z,t.level);i.changeObj(t,e,t.count,r),this.trackZone(this.currentTick,i)}removeObj(t,e){const r=this.getZone(t.x,t.z,t.level);r.removeObj(t),t.setLifeCycle(this.currentTick+e),this.trackZone(this.currentTick+e,r),this.trackZone(this.currentTick,r)}animMap(t,e,r,i,n,s){const a=this.getZone(e,r,t);a.animMap(e,r,i,n,s),this.trackZone(this.currentTick,a)}mapProjAnim(t,e,r,i,n,s,a,o,h,l,c,u,d){const f=this.getZone(e,r,t);f.mapProjAnim(e,r,i,n,s,a,o,h,l,c,u,d),this.trackZone(this.currentTick,f)}async readIn(t,e){for(;e.available>0;){const r=e.pos;let i=e.g1();if(t.decryptor&&(i=i-t.decryptor.nextInt()&255,e.data[r]=i),void 0===of.byId[i])return t.state=-1,void t.close();let n=of.byId[i].length;if(-1===n?n=e.g1():-2===n&&(n=e.g2()),e.available5)continue;const s=new Uint8Array(e.pos-r),a=e.pos;e.pos=r,e.gdata(s,0,s.length),e.pos=a,t.in.set(s,t.inOffset),t.inOffset+=e.pos-r}}addPlayer(t){this.newPlayers.add(t)}async removePlayer(t){-1!==t.pid&&(t.playerLog('Logging out'),$p(t)&&(t.logout(),t.client.close(),t.client=null),Mm.logout(t))}getPlayer(t){return this.players.get(t)}getPlayerByUid(t){const e=2047&t,r=t>>11&2097151,i=this.getPlayer(e);return i?Number(0x1fffffn&i.username37)!==r?null:i:null}getPlayerByUsername(t){const e=Zn(t);for(const t of this.players)if(t.username37===e)return t;for(const t of this.newPlayers)if(t.username37===e)return t}getTotalPlayers(){return this.players.count}getTotalNpcs(){return this.npcs.count}getTotalZones(){return this.zoneMap.zoneCount()}getTotalLocs(){return this.zoneMap.locCount()}getTotalObjs(){return this.zoneMap.objCount()}getNpc(t){return this.npcs.get(t)}getNpcByUid(t){const e=65535&t,r=t>>16&65535,i=this.getNpc(e);return i&&i.type===r?i:null}getNextNid(){return this.npcs.next()}getNextPid(t=null){if(t){const e=t.remoteAddress.split('.'),r=parseInt(e[3])%20*100;return this.players.next(!0,r)}return this.players.next()}}var Lm=new Nm;await Lm.start(),(new class{socket=new mp(null,'127.0.0.1');constructor(){}start(){const t=new as(new Uint8Array(8));t.p4(Math.floor(4294967295*Math.random())),t.p4(Math.floor(4294967295*Math.random())),this.socket.send(t.data),self.onmessage=async t=>{const e=new as(new Uint8Array(t.data));t.data.type;try{1===this.socket.state?await Lm.readIn(this.socket,e):await Mm.readIn(this.socket,e)}catch(t){this.socket.close()}}}}).start(); \ No newline at end of file +var e,t,i,r,s=Object.create,n=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,h=(e=>'undefined'!=typeof require?require:'undefined'!=typeof Proxy?new Proxy(e,{get:(e,t)=>('undefined'!=typeof require?require:e)[t]}):e)((function(e){if('undefined'!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')})),d=(e,t)=>function(){return t||(0,e[o(e)[0]])((t={exports:{}}).exports,t),t.exports},u=d({'node_modules/node-forge/lib/forge.js'(e,t){t.exports={options:{usePureJavaScript:!1}}}}),p=d({'node_modules/node-forge/lib/baseN.js'(e,t){var i={};t.exports=i;var r={};i.encode=function(e,t,i){if('string'!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==i&&'number'!=typeof i)throw new TypeError('"maxline" must be a number.');var r='';if(e instanceof Uint8Array){var s=0,n=t.length,a=t.charAt(0),o=[0];for(s=0;s0;)o.push(l%n),l=l/n|0}for(s=0;0===e[s]&&s=0;--s)r+=t[o[s]]}else r=function(e,t){var i=0,r=t.length,s=t.charAt(0),n=[0];for(i=0;i0;)n.push(o%r),o=o/r|0}var c='';for(i=0;0===e.at(i)&&i=0;--i)c+=t[n[i]];return c}(e,t);if(i){var h=new RegExp('.{1,'+i+'}','g');r=r.match(h).join('\r\n')}return r},i.decode=function(e,t){if('string'!=typeof e)throw new TypeError('"input" must be a string.');if('string'!=typeof t)throw new TypeError('"alphabet" must be a string.');var i=r[t];if(!i){i=r[t]=[];for(var s=0;s>=8;for(;h>0;)o.push(255&h),h>>=8}for(var d=0;e[d]===a&&d15?(i=Date.now(),a(e)):(t.push(e),1===t.length&&n.setAttribute('a',r=!r))}}s.nextTick=s.setImmediate}(),s.isNodejs='undefined'!=typeof process&&process.versions&&process.versions.node,s.globalScope=s.isNodejs?global:'undefined'==typeof self?window:self,s.isArray=Array.isArray||function(e){return'[object Array]'===Object.prototype.toString.call(e)},s.isArrayBuffer=function(e){return'undefined'!=typeof ArrayBuffer&&e instanceof ArrayBuffer},s.isArrayBufferView=function(e){return e&&s.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},s.ByteBuffer=a,s.ByteStringBuffer=a;s.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},s.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},s.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},s.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},s.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var i=this.data;t>0;)1&t&&(i+=e),(t>>>=1)>0&&(e+=e);return this.data=i,this._optimizeConstructedString(t),this},s.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},s.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(s.encodeUtf8(e))},s.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},s.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},s.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},s.ByteStringBuffer.prototype.putInt=function(e,t){n(t);var i='';do{t-=8,i+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(i)},s.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},s.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),i=2<=i&&(t-=i<<1),t},s.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t='':(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},s.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},s.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},s.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},s.ByteStringBuffer.prototype.copy=function(){var e=s.createBuffer(this.data);return e.read=this.read,e},s.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},s.ByteStringBuffer.prototype.clear=function(){return this.data='',this.read=0,this},s.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},s.ByteStringBuffer.prototype.toHex=function(){for(var e='',t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var i=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),r=new Uint8Array(this.length()+t);return r.set(i),this.data=new DataView(r.buffer),this},s.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},s.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var i=0;i>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},s.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},s.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},s.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},s.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},s.DataBuffer.prototype.putInt=function(e,t){n(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},s.DataBuffer.prototype.putSignedInt=function(e,t){return n(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},s.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),i=2<=i&&(t-=i<<1),t},s.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t='':(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},s.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},s.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},s.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},s.DataBuffer.prototype.copy=function(){return new s.DataBuffer(this)},s.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},s.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},s.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},s.DataBuffer.prototype.toHex=function(){for(var e='',t=this.read;t0;)1&t&&(i+=e),(t>>>=1)>0&&(e+=e);return i},s.xorBytes=function(e,t,i){for(var r='',s='',n='',a=0,o=0;i>0;--i,++a)s=e.charCodeAt(a)^t.charCodeAt(a),o>=10&&(r+=n,n='',o=0),n+=String.fromCharCode(s),++o;return r+=n},s.hexToBytes=function(e){var t='',i=0;for(!0&e.length&&(i=1,t+=String.fromCharCode(parseInt(e[0],16)));i>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',c=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],l='123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';s.encode64=function(e,t){for(var i,r,s,n='',a='',c=0;c>2),n+=o.charAt((3&i)<<4|r>>4),isNaN(r)?n+='==':(n+=o.charAt((15&r)<<2|s>>6),n+=isNaN(s)?'=':o.charAt(63&s)),t&&n.length>t&&(a+=n.substr(0,t)+'\r\n',n=n.substr(t));return a+=n},s.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,'');for(var t,i,r,s,n='',a=0;a>4),64!==r&&(n+=String.fromCharCode((15&i)<<4|r>>2),64!==s&&(n+=String.fromCharCode((3&r)<<6|s)));return n},s.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},s.decodeUtf8=function(e){return decodeURIComponent(escape(e))},s.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:r.encode,decode:r.decode}},s.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},s.binary.raw.decode=function(e,t,i){var r=t;r||(r=new Uint8Array(e.length));for(var s=i=i||0,n=0;n>2),n+=o.charAt((3&i)<<4|r>>4),isNaN(r)?n+='==':(n+=o.charAt((15&r)<<2|s>>6),n+=isNaN(s)?'=':o.charAt(63&s)),t&&n.length>t&&(a+=n.substr(0,t)+'\r\n',n=n.substr(t));return a+=n},s.binary.base64.decode=function(e,t,i){var r,s,n,a,o=t;o||(o=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,'');for(var l=0,h=i=i||0;l>4,64!==n&&(o[h++]=(15&s)<<4|n>>2,64!==a&&(o[h++]=(3&n)<<6|a));return t?h-i:o.subarray(0,h)},s.binary.base58.encode=function(e,t){return s.binary.baseN.encode(e,l,t)},s.binary.base58.decode=function(e,t){return s.binary.baseN.decode(e,l,t)},s.text={utf8:{},utf16:{}},s.text.utf8.encode=function(e,t,i){e=s.encodeUtf8(e);var r=t;r||(r=new Uint8Array(e.length));for(var n=i=i||0,a=0;a0&&n.push(i),a=r.lastIndex;var o=t[0][1];switch(o){case's':case'o':s');break;case'%':n.push('%');break;default:n.push('<%'+o+'?>')}}return n.push(e.substring(a)),n.join('')},s.formatNumber=function(e,t,i,r){var s=e,n=isNaN(t=Math.abs(t))?2:t,a=void 0===i?',':i,o=void 0===r?'.':r,c=s<0?'-':'',l=parseInt(s=Math.abs(+s||0).toFixed(n),10)+'',h=l.length>3?l.length%3:0;return c+(h?l.substr(0,h)+o:'')+l.substr(h).replace(/(\d{3})(?=\d)/g,'$1'+o)+(n?a+Math.abs(s-l).toFixed(n).slice(2):'')},s.formatSize=function(e){return e=e>=1073741824?s.formatNumber(e/1073741824,2,'.','')+' GiB':e>=1048576?s.formatNumber(e/1048576,2,'.','')+' MiB':e>=1024?s.formatNumber(e/1024,0)+' KiB':s.formatNumber(e,0)+' bytes'},s.bytesFromIP=function(e){return-1!==e.indexOf('.')?s.bytesFromIPv4(e):-1!==e.indexOf(':')?s.bytesFromIPv6(e):null},s.bytesFromIPv4=function(e){if(4!==(e=e.split('.')).length)return null;for(var t=s.createBuffer(),i=0;ii[r].end-i[r].start&&(r=i.length-1)):i.push({start:c,end:c})}t.push(a)}if(i.length>0){var l=i[r];l.end-l.start>0&&(t.splice(l.start,l.end-l.start+1,''),0===l.start&&t.unshift(''),7===l.end&&t.push(''))}return t.join(':')},s.estimateCores=function(e,t){if('function'==typeof e&&(t=e,e={}),e=e||{},'cores'in s&&!e.update)return t(null,s.cores);if('undefined'!=typeof navigator&&'hardwareConcurrency'in navigator&&navigator.hardwareConcurrency>0)return s.cores=navigator.hardwareConcurrency,t(null,s.cores);if('undefined'==typeof Worker)return s.cores=1,t(null,s.cores);if('undefined'==typeof Blob)return s.cores=2,t(null,s.cores);var i=URL.createObjectURL(new Blob(['(',function(){self.addEventListener('message',(function(e){for(var t=Date.now(),i=t+4;Date.now()o.st&&s.sts.st&&o.st4){var r=e;e=i.util.createBuffer();for(var s=0;s0))return!0;for(var r=0;r0))return!0;for(var r=0;r0)return!1;var i=e.length(),r=e.at(i-1);return!(r>this.blockSize<<2)&&(e.truncate(r),!0)},r.cbc=function(e){e=e||{},this.name='CBC',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},r.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error('Invalid IV parameter.');this._iv=this._prev.slice(0)}else{if(!('iv'in e))throw new Error('Invalid IV parameter.');this._iv=s(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},r.cbc.prototype.encrypt=function(e,t,i){if(e.length()0))return!0;for(var r=0;r0))return!0;for(var r=0;r0)return!1;var i=e.length(),r=e.at(i-1);return!(r>this.blockSize<<2)&&(e.truncate(r),!0)},r.cfb=function(e){e=e||{},this.name='CFB',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=i.util.createBuffer(),this._partialBytes=0},r.cfb.prototype.start=function(e){if(!('iv'in e))throw new Error('Invalid IV parameter.');this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},r.cfb.prototype.encrypt=function(e,t,i){var r=e.length();if(0===r)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&r>=this.blockSize)for(var s=0;s0&&(n=this.blockSize-n),this._partialOutput.clear();for(s=0;s0)e.read-=this.blockSize;else for(s=0;s0&&this._partialOutput.getBytes(this._partialBytes),n>0&&!i)return t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=n,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}},r.cfb.prototype.decrypt=function(e,t,i){var r=e.length();if(0===r)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&r>=this.blockSize)for(var s=0;s0&&(n=this.blockSize-n),this._partialOutput.clear();for(s=0;s0)e.read-=this.blockSize;else for(s=0;s0&&this._partialOutput.getBytes(this._partialBytes),n>0&&!i)return t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=n,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}},r.ofb=function(e){e=e||{},this.name='OFB',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=i.util.createBuffer(),this._partialBytes=0},r.ofb.prototype.start=function(e){if(!('iv'in e))throw new Error('Invalid IV parameter.');this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},r.ofb.prototype.encrypt=function(e,t,i){var r=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&r>=this.blockSize)for(var s=0;s0&&(n=this.blockSize-n),this._partialOutput.clear();for(s=0;s0)e.read-=this.blockSize;else for(s=0;s0&&this._partialOutput.getBytes(this._partialBytes),n>0&&!i)return t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=n,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}},r.ofb.prototype.decrypt=r.ofb.prototype.encrypt,r.ctr=function(e){e=e||{},this.name='CTR',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=i.util.createBuffer(),this._partialBytes=0},r.ctr.prototype.start=function(e){if(!('iv'in e))throw new Error('Invalid IV parameter.');this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},r.ctr.prototype.encrypt=function(e,t,i){var r=e.length();if(0===r)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&r>=this.blockSize)for(var s=0;s0&&(a=this.blockSize-a),this._partialOutput.clear();for(s=0;s0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!i)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}n(this._inBlock)},r.ctr.prototype.decrypt=r.ctr.prototype.encrypt,r.gcm=function(e){e=e||{},this.name='GCM',this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=i.util.createBuffer(),this._partialBytes=0,this._R=3774873600},r.gcm.prototype.start=function(e){if(!('iv'in e))throw new Error('Invalid IV parameter.');var t,r=i.util.createBuffer(e.iv);if(this._cipherLength=0,t='additionalData'in e?i.util.createBuffer(e.additionalData):i.util.createBuffer(),this._tagLength='tagLength'in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=i.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error('Authentication tag does not match tag length.');this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var s=r.length();if(12===s)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*s)))}this._inBlock=this._j0.slice(0),n(this._inBlock),this._partialBytes=0,t=i.util.createBuffer(t),this._aDataLength=a(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},r.gcm.prototype.encrypt=function(e,t,i){var r=e.length();if(0===r)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&r>=this.blockSize){for(var s=0;s0&&(a=this.blockSize-a),this._partialOutput.clear();for(s=0;s0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!i)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),n(this._inBlock)},r.gcm.prototype.decrypt=function(e,t,i){var r=e.length();if(r0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),n(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var s=0;s0;--r)t[r]=e[r]>>>1|(1&e[r-1])<<31;t[0]=e[0]>>>1,i&&(t[0]^=this._R)},r.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],i=0;i<32;++i){var r=e[i/8|0]>>>4*(7-i%8)&15,s=this._m[i][r];t[0]^=s[0],t[1]^=s[1],t[2]^=s[2],t[3]^=s[3]}return t},r.gcm.prototype.ghash=function(e,t,i){return t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3],this.tableMultiply(t)},r.gcm.prototype.generateHashTable=function(e,t){for(var i=8/t,r=4*i,s=16*i,n=new Array(s),a=0;a>>1,s=new Array(i);s[r]=e.slice(0);for(var n=r>>>1;n>0;)this.pow(s[2*n],s[n]=[]),n>>=1;for(n=2;n>>=2;for(s=0;s>8^255&d^99,s[g]=d,n[d]=g,p=(u=e[d])<<24^d<<16^d<<8^d^u,f=((i=e[g])^(r=e[i])^(h=e[r]))<<24^(g^h)<<16^(g^r^h)<<8^g^i^h;for(var y=0;y<4;++y)o[y][g]=p,c[y][d]=f,p=p<<24|p>>>8,f=f<<24|f>>>8;0===g?g=m=1:(g=i^e[e[e[i^h]]],m^=e[e[m]])}}function d(e,t){for(var i,r=e.slice(0),n=1,o=r.length,l=4*(o+6+1),h=o;h>>16&255]<<24^s[i>>>8&255]<<16^s[255&i]<<8^s[i>>>24]^a[n]<<24,n++):o>6&&h%o==4&&(i=s[i>>>24]<<24^s[i>>>16&255]<<16^s[i>>>8&255]<<8^s[255&i]),r[h]=r[h-o]^i;if(t){for(var d,u=c[0],p=c[1],f=c[2],g=c[3],m=r.slice(0),y=(h=0,(l=r.length)-4);h>>24]]^p[s[d>>>16&255]]^f[s[d>>>8&255]]^g[s[255&d]];r=m}return r}function p(e,t,i,r){var a,l,h,d,u,p,f,g,m,y,E,_,A=e.length/4-1;r?(a=c[0],l=c[1],h=c[2],d=c[3],u=n):(a=o[0],l=o[1],h=o[2],d=o[3],u=s),p=t[0]^e[0],f=t[r?3:1]^e[1],g=t[2]^e[2],m=t[r?1:3]^e[3];for(var v=3,T=1;T>>24]^l[f>>>16&255]^h[g>>>8&255]^d[255&m]^e[++v],E=a[f>>>24]^l[g>>>16&255]^h[m>>>8&255]^d[255&p]^e[++v],_=a[g>>>24]^l[m>>>16&255]^h[p>>>8&255]^d[255&f]^e[++v],m=a[m>>>24]^l[p>>>16&255]^h[f>>>8&255]^d[255&g]^e[++v],p=y,f=E,g=_;i[0]=u[p>>>24]<<24^u[f>>>16&255]<<16^u[g>>>8&255]<<8^u[255&m]^e[++v],i[r?3:1]=u[f>>>24]<<24^u[g>>>16&255]<<16^u[m>>>8&255]<<8^u[255&p]^e[++v],i[2]=u[g>>>24]<<24^u[m>>>16&255]<<16^u[p>>>8&255]<<8^u[255&f]^e[++v],i[r?1:3]=u[m>>>24]<<24^u[p>>>16&255]<<16^u[f>>>8&255]<<8^u[255&g]^e[++v]}function y(e){var t,r='AES-'+((e=e||{}).mode||'CBC').toUpperCase(),s=(t=e.decrypt?i.cipher.createDecipher(r,e.key):i.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var n=null;r instanceof i.util.ByteBuffer&&(n=r,r={}),(r=r||{}).output=n,r.iv=e,s.call(t,r)},t}}}),E=d({'node_modules/node-forge/lib/oids.js'(e,t){var i=u();i.pki=i.pki||{};var r=t.exports=i.pki.oids=i.oids=i.oids||{};function s(e,t){r[e]=t,r[t]=e}function n(e,t){r[e]=t}s('1.2.840.113549.1.1.1','rsaEncryption'),s('1.2.840.113549.1.1.4','md5WithRSAEncryption'),s('1.2.840.113549.1.1.5','sha1WithRSAEncryption'),s('1.2.840.113549.1.1.7','RSAES-OAEP'),s('1.2.840.113549.1.1.8','mgf1'),s('1.2.840.113549.1.1.9','pSpecified'),s('1.2.840.113549.1.1.10','RSASSA-PSS'),s('1.2.840.113549.1.1.11','sha256WithRSAEncryption'),s('1.2.840.113549.1.1.12','sha384WithRSAEncryption'),s('1.2.840.113549.1.1.13','sha512WithRSAEncryption'),s('1.3.101.112','EdDSA25519'),s('1.2.840.10040.4.3','dsa-with-sha1'),s('1.3.14.3.2.7','desCBC'),s('1.3.14.3.2.26','sha1'),s('1.3.14.3.2.29','sha1WithRSASignature'),s('2.16.840.1.101.3.4.2.1','sha256'),s('2.16.840.1.101.3.4.2.2','sha384'),s('2.16.840.1.101.3.4.2.3','sha512'),s('2.16.840.1.101.3.4.2.4','sha224'),s('2.16.840.1.101.3.4.2.5','sha512-224'),s('2.16.840.1.101.3.4.2.6','sha512-256'),s('1.2.840.113549.2.2','md2'),s('1.2.840.113549.2.5','md5'),s('1.2.840.113549.1.7.1','data'),s('1.2.840.113549.1.7.2','signedData'),s('1.2.840.113549.1.7.3','envelopedData'),s('1.2.840.113549.1.7.4','signedAndEnvelopedData'),s('1.2.840.113549.1.7.5','digestedData'),s('1.2.840.113549.1.7.6','encryptedData'),s('1.2.840.113549.1.9.1','emailAddress'),s('1.2.840.113549.1.9.2','unstructuredName'),s('1.2.840.113549.1.9.3','contentType'),s('1.2.840.113549.1.9.4','messageDigest'),s('1.2.840.113549.1.9.5','signingTime'),s('1.2.840.113549.1.9.6','counterSignature'),s('1.2.840.113549.1.9.7','challengePassword'),s('1.2.840.113549.1.9.8','unstructuredAddress'),s('1.2.840.113549.1.9.14','extensionRequest'),s('1.2.840.113549.1.9.20','friendlyName'),s('1.2.840.113549.1.9.21','localKeyId'),s('1.2.840.113549.1.9.22.1','x509Certificate'),s('1.2.840.113549.1.12.10.1.1','keyBag'),s('1.2.840.113549.1.12.10.1.2','pkcs8ShroudedKeyBag'),s('1.2.840.113549.1.12.10.1.3','certBag'),s('1.2.840.113549.1.12.10.1.4','crlBag'),s('1.2.840.113549.1.12.10.1.5','secretBag'),s('1.2.840.113549.1.12.10.1.6','safeContentsBag'),s('1.2.840.113549.1.5.13','pkcs5PBES2'),s('1.2.840.113549.1.5.12','pkcs5PBKDF2'),s('1.2.840.113549.1.12.1.1','pbeWithSHAAnd128BitRC4'),s('1.2.840.113549.1.12.1.2','pbeWithSHAAnd40BitRC4'),s('1.2.840.113549.1.12.1.3','pbeWithSHAAnd3-KeyTripleDES-CBC'),s('1.2.840.113549.1.12.1.4','pbeWithSHAAnd2-KeyTripleDES-CBC'),s('1.2.840.113549.1.12.1.5','pbeWithSHAAnd128BitRC2-CBC'),s('1.2.840.113549.1.12.1.6','pbewithSHAAnd40BitRC2-CBC'),s('1.2.840.113549.2.7','hmacWithSHA1'),s('1.2.840.113549.2.8','hmacWithSHA224'),s('1.2.840.113549.2.9','hmacWithSHA256'),s('1.2.840.113549.2.10','hmacWithSHA384'),s('1.2.840.113549.2.11','hmacWithSHA512'),s('1.2.840.113549.3.7','des-EDE3-CBC'),s('2.16.840.1.101.3.4.1.2','aes128-CBC'),s('2.16.840.1.101.3.4.1.22','aes192-CBC'),s('2.16.840.1.101.3.4.1.42','aes256-CBC'),s('2.5.4.3','commonName'),s('2.5.4.4','surname'),s('2.5.4.5','serialNumber'),s('2.5.4.6','countryName'),s('2.5.4.7','localityName'),s('2.5.4.8','stateOrProvinceName'),s('2.5.4.9','streetAddress'),s('2.5.4.10','organizationName'),s('2.5.4.11','organizationalUnitName'),s('2.5.4.12','title'),s('2.5.4.13','description'),s('2.5.4.15','businessCategory'),s('2.5.4.17','postalCode'),s('2.5.4.42','givenName'),s('1.3.6.1.4.1.311.60.2.1.2','jurisdictionOfIncorporationStateOrProvinceName'),s('1.3.6.1.4.1.311.60.2.1.3','jurisdictionOfIncorporationCountryName'),s('2.16.840.1.113730.1.1','nsCertType'),s('2.16.840.1.113730.1.13','nsComment'),n('2.5.29.1','authorityKeyIdentifier'),n('2.5.29.2','keyAttributes'),n('2.5.29.3','certificatePolicies'),n('2.5.29.4','keyUsageRestriction'),n('2.5.29.5','policyMapping'),n('2.5.29.6','subtreesConstraint'),n('2.5.29.7','subjectAltName'),n('2.5.29.8','issuerAltName'),n('2.5.29.9','subjectDirectoryAttributes'),n('2.5.29.10','basicConstraints'),n('2.5.29.11','nameConstraints'),n('2.5.29.12','policyConstraints'),n('2.5.29.13','basicConstraints'),s('2.5.29.14','subjectKeyIdentifier'),s('2.5.29.15','keyUsage'),n('2.5.29.16','privateKeyUsagePeriod'),s('2.5.29.17','subjectAltName'),s('2.5.29.18','issuerAltName'),s('2.5.29.19','basicConstraints'),n('2.5.29.20','cRLNumber'),n('2.5.29.21','cRLReason'),n('2.5.29.22','expirationDate'),n('2.5.29.23','instructionCode'),n('2.5.29.24','invalidityDate'),n('2.5.29.25','cRLDistributionPoints'),n('2.5.29.26','issuingDistributionPoint'),n('2.5.29.27','deltaCRLIndicator'),n('2.5.29.28','issuingDistributionPoint'),n('2.5.29.29','certificateIssuer'),n('2.5.29.30','nameConstraints'),s('2.5.29.31','cRLDistributionPoints'),s('2.5.29.32','certificatePolicies'),n('2.5.29.33','policyMappings'),n('2.5.29.34','policyConstraints'),s('2.5.29.35','authorityKeyIdentifier'),n('2.5.29.36','policyConstraints'),s('2.5.29.37','extKeyUsage'),n('2.5.29.46','freshestCRL'),n('2.5.29.54','inhibitAnyPolicy'),s('1.3.6.1.4.1.11129.2.4.2','timestampList'),s('1.3.6.1.5.5.7.1.1','authorityInfoAccess'),s('1.3.6.1.5.5.7.3.1','serverAuth'),s('1.3.6.1.5.5.7.3.2','clientAuth'),s('1.3.6.1.5.5.7.3.3','codeSigning'),s('1.3.6.1.5.5.7.3.4','emailProtection'),s('1.3.6.1.5.5.7.3.8','timeStamping')}}),_=d({'node_modules/node-forge/lib/asn1.js'(e,t){var i=u();f(),E();var r=t.exports=i.asn1=i.asn1||{};function s(e,t,i){if(i>t){var r=new Error('Too few bytes to parse DER.');throw r.available=e.length(),r.remaining=t,r.requested=i,r}}r.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},r.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},r.create=function(e,t,s,n,a){if(i.util.isArray(n)){for(var o=[],c=0;ct){if(a.strict){var f=new Error('Too few bytes to read ASN.1 value.');throw f.available=e.length(),f.remaining=t,f.requested=p,f}p=t}var g=!(32&~c);if(g)if(d=[],void 0===p)for(;;){if(s(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}o=e.length(),d.push(n(e,t,i+1,a)),t-=o-e.length()}else for(;p>0;)o=e.length(),d.push(n(e,p,i+1,a)),t-=o-e.length(),p-=o-e.length();if(void 0===d&&l===r.Class.UNIVERSAL&&h===r.Type.BITSTRING&&(u=e.bytes(p)),void 0===d&&a.decodeBitStrings&&l===r.Class.UNIVERSAL&&h===r.Type.BITSTRING&&p>1){var m=e.read,y=t,E=0;if(h===r.Type.BITSTRING&&(s(e,t,1),E=e.getByte(),t--),0===E)try{o=e.length();var _=n(e,t,i+1,{strict:!0,decodeBitStrings:!0}),A=o-e.length();t-=A,h==r.Type.BITSTRING&&A++;var v=_.tagClass;A!==p||v!==r.Class.UNIVERSAL&&v!==r.Class.CONTEXT_SPECIFIC||(d=[_])}catch(e){}void 0===d&&(e.read=m,t=y)}if(void 0===d){if(void 0===p){if(a.strict)throw new Error('Non-constructed ASN.1 object of indefinite length.');p=t}if(h===r.Type.BMPSTRING)for(d='';p>0;p-=2)s(e,t,2),d+=String.fromCharCode(e.getInt16()),t-=2;else d=e.getBytes(p),t-=p}var T=void 0===u?null:{bitStringContents:u};return r.create(l,h,g,d,T)}r.fromDer=function(e,t){void 0===t&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),'boolean'==typeof t&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),'strict'in t||(t.strict=!0),'parseAllBytes'in t||(t.parseAllBytes=!0),'decodeBitStrings'in t||(t.decodeBitStrings=!0),'string'==typeof e&&(e=i.util.createBuffer(e));var r=e.length(),s=n(e,e.length(),0,t);if(t.parseAllBytes&&0!==e.length()){var a=new Error('Unparsed DER bytes remain after ASN.1 parsing.');throw a.byteCount=r,a.remaining=e.length(),a}return s},r.toDer=function(e){var t=i.util.createBuffer(),s=e.tagClass|e.type,n=i.util.createBuffer(),a=!1;if('bitStringContents'in e&&(a=!0,e.original&&(a=r.equals(e,e.original))),a)n.putBytes(e.bitStringContents);else if(e.composed){e.constructed?s|=32:n.putByte(0);for(var o=0;o1)||(0!==e.value.charCodeAt(0)||128&e.value.charCodeAt(1))&&(255!==e.value.charCodeAt(0)||128&~e.value.charCodeAt(1))?n.putBytes(e.value):n.putBytes(e.value.substr(1));if(t.putByte(s),n.length()<=127)t.putByte(127&n.length());else{var c=n.length(),l='';do{l+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|l.length);for(o=l.length-1;o>=0;--o)t.putByte(l.charCodeAt(o))}return t.putBuffer(n),t},r.oidToDer=function(e){var t,r,s,n,a=e.split('.'),o=i.util.createBuffer();o.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var c=2;c>>=7,t||(n|=128),r.push(n),t=!1}while(s>0);for(var l=r.length-1;l>=0;--l)o.putByte(r[l])}return o},r.derToOid=function(e){var t;'string'==typeof e&&(e=i.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+'.'+r%40;for(var s=0;e.length()>0;)s<<=7,128&(r=e.getByte())?s+=127&r:(t+='.'+(s+r),s=0);return t},r.utcTimeToDate=function(e){var t=new Date,i=parseInt(e.substr(0,2),10);i=i>=50?1900+i:2e3+i;var r=parseInt(e.substr(2,2),10)-1,s=parseInt(e.substr(4,2),10),n=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var c=e.charAt(10),l=10;'+'!==c&&'-'!==c&&(o=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(i,r,s),t.setUTCHours(n,a,o,0),l&&('+'===(c=e.charAt(l))||'-'===c)){var h=60*parseInt(e.substr(l+1,2),10)+parseInt(e.substr(l+4,2),10);h*=6e4,'+'===c?t.setTime(+t-h):t.setTime(+t+h)}return t},r.generalizedTimeToDate=function(e){var t=new Date,i=parseInt(e.substr(0,4),10),r=parseInt(e.substr(4,2),10)-1,s=parseInt(e.substr(6,2),10),n=parseInt(e.substr(8,2),10),a=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),c=0,l=0,h=!1;'Z'===e.charAt(e.length-1)&&(h=!0);var d=e.length-5,u=e.charAt(d);'+'!==u&&'-'!==u||(l=60*parseInt(e.substr(d+1,2),10)+parseInt(e.substr(d+4,2),10),l*=6e4,'+'===u&&(l*=-1),h=!0);return'.'===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),h?(t.setUTCFullYear(i,r,s),t.setUTCHours(n,a,o,c),t.setTime(+t+l)):(t.setFullYear(i,r,s),t.setHours(n,a,o,c)),t},r.dateToUtcTime=function(e){if('string'==typeof e)return e;var t='',i=[];i.push((''+e.getUTCFullYear()).substr(2)),i.push(''+(e.getUTCMonth()+1)),i.push(''+e.getUTCDate()),i.push(''+e.getUTCHours()),i.push(''+e.getUTCMinutes()),i.push(''+e.getUTCSeconds());for(var r=0;r=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error('Integer too large; max is 32-bits.');throw r.integer=e,r},r.derToInteger=function(e){'string'==typeof e&&(e=i.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error('Integer too large; max is 32-bits.');return e.getSignedInt(t)},r.validate=function(e,t,s,n){var a=!1;if(e.tagClass!==t.tagClass&&void 0!==t.tagClass||e.type!==t.type&&void 0!==t.type)n&&(e.tagClass!==t.tagClass&&n.push('['+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&n.push('['+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||void 0===t.constructed){if(a=!0,t.value&&i.util.isArray(t.value))for(var o=0,c=0;a&&c0&&(n+='\n');for(var o='',c=0;c1?n+='0x'+i.util.bytesToHex(e.value.slice(1)):n+='(none)',e.value.length>0){var u=e.value.charCodeAt(0);1==u?n+=' (1 unused bit shown)':u>1&&(n+=' ('+u+' unused bits shown)')}}else if(e.type===r.Type.OCTETSTRING)a.test(e.value)||(n+='('+e.value+') '),n+='0x'+i.util.bytesToHex(e.value);else if(e.type===r.Type.UTF8)try{n+=i.util.decodeUtf8(e.value)}catch(t){if('URI malformed'!==t.message)throw t;n+='0x'+i.util.bytesToHex(e.value)+' (malformed UTF8)'}else e.type===r.Type.PRINTABLESTRING||e.type===r.Type.IA5String?n+=e.value:a.test(e.value)?n+='0x'+i.util.bytesToHex(e.value):0===e.value.length?n+='[null]':n+=e.value}return n}}}),A=d({'node_modules/node-forge/lib/md.js'(e,t){var i=u();t.exports=i.md=i.md||{},i.md.algorithms=i.md.algorithms||{}}}),v=d({'node_modules/node-forge/lib/hmac.js'(e,t){var i=u();A(),f(),(t.exports=i.hmac=i.hmac||{}).create=function(){var e=null,t=null,r=null,s=null,n={start:function(n,a){if(null!==n)if('string'==typeof n){if(!((n=n.toLowerCase())in i.md.algorithms))throw new Error('Unknown hash algorithm "'+n+'"');t=i.md.algorithms[n].create()}else t=n;if(null===a)a=e;else{if('string'==typeof a)a=i.util.createBuffer(a);else if(i.util.isArray(a)){var o=a;a=i.util.createBuffer();for(var c=0;ct.blockLength&&(t.start(),t.update(a.bytes()),a=t.digest()),r=i.util.createBuffer(),s=i.util.createBuffer(),l=a.length();for(c=0;c>>0,a>>>0];for(var o=h.fullMessageLength.length-1;o>=0;--o)h.fullMessageLength[o]+=a[1],a[1]=a[0]+(h.fullMessageLength[o]/4294967296>>>0),h.fullMessageLength[o]=h.fullMessageLength[o]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(s),l(e,r,t),(t.read>2048||0===t.length())&&t.compact(),h},h.digest=function(){var n=i.util.createBuffer();n.putBytes(t.bytes());var a=h.fullMessageLength[h.fullMessageLength.length-1]+h.messageLengthSize&h.blockLength-1;n.putBytes(s.substr(0,h.blockLength-a));for(var o,c=0,d=h.fullMessageLength.length-1;d>=0;--d)c=(o=8*h.fullMessageLength[d]+c)/4294967296>>>0,n.putInt32Le(o>>>0);var u={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};l(u,r,n);var p=i.util.createBuffer();return p.putInt32Le(u.h0),p.putInt32Le(u.h1),p.putInt32Le(u.h2),p.putInt32Le(u.h3),p},h};var s=null,n=null,a=null,o=null,c=!1;function l(e,t,i){for(var r,s,c,l,h,d,u,p=i.length();p>=64;){for(s=e.h0,c=e.h1,l=e.h2,h=e.h3,u=0;u<16;++u)t[u]=i.getInt32Le(),r=s+(h^c&(l^h))+o[u]+t[u],s=h,h=l,l=c,c+=r<<(d=a[u])|r>>>32-d;for(;u<32;++u)r=s+(l^h&(c^l))+o[u]+t[n[u]],s=h,h=l,l=c,c+=r<<(d=a[u])|r>>>32-d;for(;u<48;++u)r=s+(c^l^h)+o[u]+t[n[u]],s=h,h=l,l=c,c+=r<<(d=a[u])|r>>>32-d;for(;u<64;++u)r=s+(l^(c|~h))+o[u]+t[n[u]],s=h,h=l,l=c,c+=r<<(d=a[u])|r>>>32-d;e.h0=e.h0+s|0,e.h1=e.h1+c|0,e.h2=e.h2+l|0,e.h3=e.h3+h|0,p-=64}}}}),C=d({'node_modules/node-forge/lib/pem.js'(e,t){var i=u();f();var r=t.exports=i.pem=i.pem||{};function s(e){for(var t=e.name+': ',i=[],r=function(e,t){return' '+t},s=0;s65&&-1!==a){var o=t[a];','===o?(++a,t=t.substr(0,a)+'\r\n '+t.substr(a)):t=t.substr(0,a)+'\r\n'+o+t.substr(a+1),n=s-a-1,a=-1,++s}else' '!==t[s]&&'\t'!==t[s]&&','!==t[s]||(a=s);return t}function n(e){return e.replace(/^\s+/,'')}r.encode=function(e,t){t=t||{};var r,n='-----BEGIN '+e.type+'-----\r\n';if(e.procType&&(n+=s(r={name:'Proc-Type',values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(n+=s(r={name:'Content-Domain',values:[e.contentDomain]})),e.dekInfo&&(r={name:'DEK-Info',values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),n+=s(r)),e.headers)for(var a=0;a8?3:1,y=[],E=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],_=0,A=0;A>>4^T))<<4,v^=t=65535&((T^=t)>>>-16^v),v^=(t=858993459&(v>>>2^(T^=t<<-16)))<<2,v^=t=65535&((T^=t)>>>-16^v),v^=(t=1431655765&(v>>>1^(T^=t<<-16)))<<1,v^=t=16711935&((T^=t)>>>8^v),t=(v^=(t=1431655765&(v>>>1^(T^=t<<8)))<<1)<<8|(T^=t)>>>20&240,v=T<<24|T<<8&16711680|T>>>8&65280|T>>>24&240,T=t;for(var C=0;C>>26,T=T<<2|T>>>26):(v=v<<1|v>>>27,T=T<<1|T>>>27),T&=-15;var I=i[(v&=-15)>>>28]|r[v>>>24&15]|s[v>>>20&15]|n[v>>>16&15]|a[v>>>12&15]|o[v>>>8&15]|c[v>>>4&15],S=l[T>>>28]|h[T>>>24&15]|d[T>>>20&15]|u[T>>>16&15]|p[T>>>12&15]|f[T>>>8&15]|g[T>>>4&15];t=65535&(S>>>16^I),y[_++]=I^t,y[_++]=S^t<<16}}return y}(t),this._init=!0}},r('DES-ECB',i.cipher.modes.ecb),r('DES-CBC',i.cipher.modes.cbc),r('DES-CFB',i.cipher.modes.cfb),r('DES-OFB',i.cipher.modes.ofb),r('DES-CTR',i.cipher.modes.ctr),r('3DES-ECB',i.cipher.modes.ecb),r('3DES-CBC',i.cipher.modes.cbc),r('3DES-CFB',i.cipher.modes.cfb),r('3DES-OFB',i.cipher.modes.ofb),r('3DES-CTR',i.cipher.modes.ctr);var 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],n=[-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],a=[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],o=[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],c=[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],l=[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],h=[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],d=[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];function p(e,t,i,r){var u,p,f=32===e.length?3:9;u=3===f?r?[30,-2,-2]:[0,32,2]:r?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var g=t[0],m=t[1];g^=(p=252645135&(g>>>4^m))<<4,g^=(p=65535&(g>>>16^(m^=p)))<<16,g^=p=858993459&((m^=p)>>>2^g),g^=p=16711935&((m^=p<<2)>>>8^g),g=(g^=(p=1431655765&(g>>>1^(m^=p<<8)))<<1)<<1|g>>>31,m=(m^=p)<<1|m>>>31;for(var y=0;y>>4|m<<28)^e[A+1];p=g,g=m,m=p^(n[v>>>24&63]|o[v>>>16&63]|l[v>>>8&63]|d[63&v]|s[T>>>24&63]|a[T>>>16&63]|c[T>>>8&63]|h[63&T])}p=g,g=m,m=p}m=m>>>1|m<<31,m^=p=1431655765&((g=g>>>1|g<<31)>>>1^m),m^=(p=16711935&(m>>>8^(g^=p<<1)))<<8,m^=(p=858993459&(m>>>2^(g^=p)))<<2,m^=p=65535&((g^=p)>>>16^m),m^=p=252645135&((g^=p<<16)>>>4^m),g^=p<<4,i[0]=g,i[1]=m}function y(e){var t,r='DES-'+((e=e||{}).mode||'CBC').toUpperCase(),s=(t=e.decrypt?i.cipher.createDecipher(r,e.key):i.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var n=null;r instanceof i.util.ByteBuffer&&(n=r,r={}),(r=r||{}).output=n,r.iv=e,s.call(t,r)},t}}}),S=d({'node_modules/node-forge/lib/pbkdf2.js'(e,t){var i=u();v(),A(),f();var r,s=i.pkcs5=i.pkcs5||{};i.util.isNodejs&&!i.options.usePureJavaScript&&(r=h('crypto')),t.exports=i.pbkdf2=s.pbkdf2=function(e,t,s,n,a,o){if('function'==typeof a&&(o=a,a=null),i.util.isNodejs&&!i.options.usePureJavaScript&&r.pbkdf2&&(null===a||'object'!=typeof a)&&(r.pbkdf2Sync.length>4||!a||'sha1'===a))return'string'!=typeof a&&(a='sha1'),e=Buffer.from(e,'binary'),t=Buffer.from(t,'binary'),o?4===r.pbkdf2Sync.length?r.pbkdf2(e,t,s,n,(function(e,t){if(e)return o(e);o(null,t.toString('binary'))})):r.pbkdf2(e,t,s,n,a,(function(e,t){if(e)return o(e);o(null,t.toString('binary'))})):4===r.pbkdf2Sync.length?r.pbkdf2Sync(e,t,s,n).toString('binary'):r.pbkdf2Sync(e,t,s,n,a).toString('binary');if(null==a&&(a='sha1'),'string'==typeof a){if(!(a in i.md.algorithms))throw new Error('Unknown hash algorithm: '+a);a=i.md[a].create()}var c=a.digestLength;if(n>4294967295*c){var l=new Error('Derived key is too long.');if(o)return o(l);throw l}var h=Math.ceil(n/c),d=n-(h-1)*c,u=i.hmac.create();u.start(a,e);var p,f,g,m='';if(!o){for(var y=1;y<=h;++y){u.start(null,null),u.update(t),u.update(i.util.int32ToBytes(y)),p=g=u.digest().getBytes();for(var E=2;E<=s;++E)u.start(null,null),u.update(g),f=u.digest().getBytes(),p=i.util.xorBytes(p,f,c),g=f;m+=yh)return o(null,m);u.start(null,null),u.update(t),u.update(i.util.int32ToBytes(y)),p=g=u.digest().getBytes(),E=2,A()}function A(){if(E<=s)return u.start(null,null),u.update(g),f=u.digest().getBytes(),p=i.util.xorBytes(p,f,c),g=f,++E,i.util.setImmediate(A);m+=y>>0,a>>>0];for(var l=c.fullMessageLength.length-1;l>=0;--l)c.fullMessageLength[l]+=a[1],a[1]=a[0]+(c.fullMessageLength[l]/4294967296>>>0),c.fullMessageLength[l]=c.fullMessageLength[l]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(s),o(e,r,t),(t.read>2048||0===t.length())&&t.compact(),c},c.digest=function(){var n=i.util.createBuffer();n.putBytes(t.bytes());var a,l=c.fullMessageLength[c.fullMessageLength.length-1]+c.messageLengthSize&c.blockLength-1;n.putBytes(s.substr(0,c.blockLength-l));for(var h=8*c.fullMessageLength[0],d=0;d>>0,n.putInt32(h>>>0),h=a>>>0;n.putInt32(h);var u={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};o(u,r,n);var p=i.util.createBuffer();return p.putInt32(u.h0),p.putInt32(u.h1),p.putInt32(u.h2),p.putInt32(u.h3),p.putInt32(u.h4),p.putInt32(u.h5),p.putInt32(u.h6),p.putInt32(u.h7),p},c};var s=null,n=!1,a=null;function o(e,t,i){for(var r,s,n,o,c,l,h,d,u,p,f,g,m,y=i.length();y>=64;){for(c=0;c<16;++c)t[c]=i.getInt32();for(;c<64;++c)r=((r=t[c-2])>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,s=((s=t[c-15])>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,t[c]=r+t[c-7]+s+t[c-16]|0;for(l=e.h0,h=e.h1,d=e.h2,u=e.h3,p=e.h4,f=e.h5,g=e.h6,m=e.h7,c=0;c<64;++c)n=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),o=l&h|d&(l^h),r=m+((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(g^p&(f^g))+a[c]+t[c],m=g,g=f,f=p,p=u+r>>>0,u=d,d=h,h=l,l=r+(s=n+o)>>>0;e.h0=e.h0+l|0,e.h1=e.h1+h|0,e.h2=e.h2+d|0,e.h3=e.h3+u|0,e.h4=e.h4+p|0,e.h5=e.h5+f|0,e.h6=e.h6+g|0,e.h7=e.h7+m|0,y-=64}}}}),N=d({'node_modules/node-forge/lib/prng.js'(e,t){var i=u();f();var r=null;!i.util.isNodejs||i.options.usePureJavaScript||process.versions['node-webkit']||(r=h('crypto')),(t.exports=i.prng=i.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:''},s=e.md,n=new Array(32),a=0;a<32;++a)n[a]=s.create();function o(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var i=1,r=0;r<32;++r)t.reseeds%i==0&&(e.update(t.pools[r].digest().getBytes()),t.pools[r].start()),i<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var s=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(s),t.generated=0}function l(e){var t=null,r=i.util.globalScope,s=r.crypto||r.msCrypto;s&&s.getRandomValues&&(t=function(e){return s.getRandomValues(e)});var n=i.util.createBuffer();if(t)for(;n.length()>16)))<<16,u=4294967295&(h=(2147483647&(h+=l>>15))+(h>>31));for(c=0;c<3;++c)d=u>>>(c<<3),d^=Math.floor(256*Math.random()),n.putByte(255&d)}return n.getBytes(e)}return t.pools=n,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var s=t.plugin.cipher,n=t.plugin.increment,a=t.plugin.formatKey,o=t.plugin.formatSeed,l=i.util.createBuffer();t.key=null,function h(d){if(d)return r(d);if(l.length()>=e)return r(null,l.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return i.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var i=32-t.pools[0].messageLength<<5;t.seedFile(i,(function(i,r){if(i)return e(i);t.collect(r),c(),e()}))}(h)}));var u=s(t.key,t.seed);t.generated+=u.length,l.putBytes(u),t.key=a(s(t.key,n(t.seed))),t.seed=o(s(t.key,t.seed)),i.util.setImmediate(h)}()},t.generateSync=function(e){var r=t.plugin.cipher,s=t.plugin.increment,n=t.plugin.formatKey,a=t.plugin.formatSeed;t.key=null;for(var c=i.util.createBuffer();c.length()1048575&&(t.key=null),null===t.key&&o();var l=r(t.key,t.seed);t.generated+=l.length,c.putBytes(l),t.key=n(r(t.key,s(t.seed))),t.seed=a(r(t.key,t.seed))}return c.getBytes(e)},r?(t.seedFile=function(e,t){r.randomBytes(e,(function(e,i){if(e)return t(e);t(null,i.toString())}))},t.seedFileSync=function(e){return r.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,l(e))}catch(e){t(e)}},t.seedFileSync=l),t.collect=function(e){for(var i=e.length,r=0;r>s&255);t.collect(r)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener('message',(function e(i){var r=i.data;r.forge&&r.forge.prng&&(self.removeEventListener('message',e),t(r.forge.prng.err,r.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener('message',(function(i){var r=i.data;r.forge&&r.forge.prng&&t.seedFile(r.forge.prng.needed,(function(t,i){e.postMessage({forge:{prng:{err:t,bytes:i}}})}))}))}},t}}}),L=d({'node_modules/node-forge/lib/random.js'(e,t){var i=u();y(),O(),N(),f(),i.random&&i.random.getBytes?t.exports=i.random:function(e){var r={},s=new Array(4),n=i.util.createBuffer();function a(){var e=i.prng.create(r);return e.getBytes=function(t,i){return e.generate(t,i)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=i.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),i.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=i.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return i.aes._updateBlock(e,t,s,!1),n.putInt32(s[0]),n.putInt32(s[1]),n.putInt32(s[2]),n.putInt32(s[3]),n.getBytes()},r.increment=function(e){return++e[3],e},r.md=i.md.sha256;var o=a(),c=null,l=i.util.globalScope,h=l.crypto||l.msCrypto;if(h&&h.getRandomValues&&(c=function(e){return h.getRandomValues(e)}),i.options.usePureJavaScript||!i.util.isNodejs&&!c){if('undefined'==typeof window||window.document,o.collectInt(+new Date,32),'undefined'!=typeof navigator){var d='';for(var u in navigator)try{'string'==typeof navigator[u]&&(d+=navigator[u])}catch(e){}o.collect(d),d=null}e&&(e().mousemove((function(e){o.collectInt(e.clientX,16),o.collectInt(e.clientY,16)})),e().keypress((function(e){o.collectInt(e.charCode,8)})))}if(i.random)for(var u in o)i.random[u]=o[u];else i.random=o;i.random.createInstance=a,t.exports=i.random}('undefined'!=typeof jQuery?jQuery:null)}}),P=d({'node_modules/node-forge/lib/rc2.js'(e,t){var i=u();f();var r=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],s=[1,2,3,5],n=function(e,t){return e<>16-t},a=function(e,t){return(65535&e)>>t|e<<16-t&65535};t.exports=i.rc2=i.rc2||{},i.rc2.expandKey=function(e,t){'string'==typeof e&&(e=i.util.createBuffer(e)),t=t||128;var s,n=e,a=e.length(),o=t,c=Math.ceil(o/8),l=255>>(7&o);for(s=a;s<128;s++)n.putByte(r[n.at(s-1)+n.at(s-a)&255]);for(n.setAt(128-c,r[n.at(128-c)&l]),s=127-c;s>=0;s--)n.setAt(s,r[n.at(s+1)^n.at(s+c)]);return n};var o=function(e,t,r){var o,c,l,h,d=!1,u=null,p=null,f=null,g=[];for(e=i.rc2.expandKey(e,t),l=0;l<64;l++)g.push(e.getInt16Le());r?(o=function(e){for(l=0;l<4;l++)e[l]+=g[h]+(e[(l+3)%4]&e[(l+2)%4])+(~e[(l+3)%4]&e[(l+1)%4]),e[l]=n(e[l],s[l]),h++},c=function(e){for(l=0;l<4;l++)e[l]+=g[63&e[(l+3)%4]]}):(o=function(e){for(l=3;l>=0;l--)e[l]=a(e[l],s[l]),e[l]-=g[h]+(e[(l+3)%4]&e[(l+2)%4])+(~e[(l+3)%4]&e[(l+1)%4]),h--},c=function(e){for(l=3;l>=0;l--)e[l]-=g[63&e[(l+3)%4]]});var m=function(e){var t=[];for(l=0;l<4;l++){var i=u.getInt16Le();null!==f&&(r?i^=f.getInt16Le():f.putInt16Le(i)),t.push(65535&i)}h=r?0:63;for(var s=0;s=8;)m([[5,o],[1,c],[6,o],[1,c],[5,o]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,u,!r);else{var i=8===u.length()?8:8-u.length();u.fillWithByte(i,i)}if(t&&(d=!0,y.update()),!r&&(t=0===u.length()))if(e)t=e(8,p,!r);else{var s=p.length(),n=p.at(s-1);n>s?t=!1:p.truncate(n)}return t}}};i.rc2.startEncrypting=function(e,t,r){var s=i.rc2.createEncryptionCipher(e,128);return s.start(t,r),s},i.rc2.createEncryptionCipher=function(e,t){return o(e,t,!0)},i.rc2.startDecrypting=function(e,t,r){var s=i.rc2.createDecryptionCipher(e,128);return s.start(t,r),s},i.rc2.createDecryptionCipher=function(e,t){return o(e,t,!1)}}}),w=d({'node_modules/node-forge/lib/jsbn.js'(e,t){var i,r=u();t.exports=r.jsbn=r.jsbn||{};function s(e,t,i){this.data=[],null!=e&&('number'==typeof e?this.fromNumber(e,t,i):null==t&&'string'!=typeof e?this.fromString(e,256):this.fromString(e,t))}function n(){return new s(null)}function a(e,t,i,r,s,n){for(var a=16383&t,o=t>>14;--n>=0;){var c=16383&this.data[e],l=this.data[e++]>>14,h=o*c+l*a;s=((c=a*c+((16383&h)<<14)+i.data[r]+s)>>28)+(h>>14)+o*l,i.data[r++]=268435455&c}return s}r.jsbn.BigInteger=s,'undefined'==typeof navigator?(s.prototype.am=a,i=28):'Microsoft Internet Explorer'==navigator.appName?(s.prototype.am=function(e,t,i,r,s,n){for(var a=32767&t,o=t>>15;--n>=0;){var c=32767&this.data[e],l=this.data[e++]>>15,h=o*c+l*a;s=((c=a*c+((32767&h)<<15)+i.data[r]+(1073741823&s))>>>30)+(h>>>15)+o*l+(s>>>30),i.data[r++]=1073741823&c}return s},i=30):'Netscape'!=navigator.appName?(s.prototype.am=function(e,t,i,r,s,n){for(;--n>=0;){var a=t*this.data[e++]+i.data[r]+s;s=Math.floor(a/67108864),i.data[r++]=67108863&a}return s},i=26):(s.prototype.am=a,i=28),s.prototype.DB=i,s.prototype.DM=(1<>>16)&&(e=t,i+=16),0!=(t=e>>8)&&(e=t,i+=8),0!=(t=e>>4)&&(e=t,i+=4),0!=(t=e>>2)&&(e=t,i+=2),0!=(t=e>>1)&&(e=t,i+=1),i}function g(e){this.m=e}function m(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function T(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function C(){}function I(e){return e}function S(e){this.r2=n(),this.q3=n(),s.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}g.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},g.prototype.revert=function(e){return e},g.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},g.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i),this.reduce(i)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},m.prototype.convert=function(e){var t=n();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(s.ZERO)>0&&this.m.subTo(t,t),t},m.prototype.revert=function(e){var t=n();return e.copyTo(t),this.reduce(t),t},m.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(i=t+this.m.t,e.data[i]+=this.m.am(0,r,e,t,0,this.m.t);e.data[i]>=e.DV;)e.data[i]-=e.DV,e.data[++i]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},m.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i),this.reduce(i)},m.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},s.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},s.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},s.prototype.fromString=function(e,t){var i;if(16==t)i=4;else if(8==t)i=3;else if(256==t)i=8;else if(2==t)i=1;else if(32==t)i=5;else{if(4!=t)return void this.fromRadix(e,t);i=2}this.t=0,this.s=0;for(var r=e.length,n=!1,a=0;--r>=0;){var o=8==i?255&e[r]:d(e,r);o<0?'-'==e.charAt(r)&&(n=!0):(n=!1,0==a?this.data[this.t++]=o:a+i>this.DB?(this.data[this.t-1]|=(o&(1<>this.DB-a):this.data[this.t-1]|=o<=this.DB&&(a-=this.DB))}8==i&&128&e[0]&&(this.s=-1,a>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},s.prototype.dlShiftTo=function(e,t){var i;for(i=this.t-1;i>=0;--i)t.data[i+e]=this.data[i];for(i=e-1;i>=0;--i)t.data[i]=0;t.t=this.t+e,t.s=this.s},s.prototype.drShiftTo=function(e,t){for(var i=e;i=0;--i)t.data[i+a+1]=this.data[i]>>s|o,o=(this.data[i]&n)<=0;--i)t.data[i]=0;t.data[a]=o,t.t=this.t+a+1,t.s=this.s,t.clamp()},s.prototype.rShiftTo=function(e,t){t.s=this.s;var i=Math.floor(e/this.DB);if(i>=this.t)t.t=0;else{var r=e%this.DB,s=this.DB-r,n=(1<>r;for(var a=i+1;a>r;r>0&&(t.data[this.t-i-1]|=(this.s&n)<>=this.DB;if(e.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t.data[i++]=this.DV+r:r>0&&(t.data[i++]=r),t.t=i,t.clamp()},s.prototype.multiplyTo=function(e,t){var i=this.abs(),r=e.abs(),n=i.t;for(t.t=n+r.t;--n>=0;)t.data[n]=0;for(n=0;n=0;)e.data[i]=0;for(i=0;i=t.DV&&(e.data[i+t.t]-=t.DV,e.data[i+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(i,t.data[i],e,2*i,0,1)),e.s=0,e.clamp()},s.prototype.divRemTo=function(e,t,i){var r=e.abs();if(!(r.t<=0)){var a=this.abs();if(a.t0?(r.lShiftTo(h,o),a.lShiftTo(h,i)):(r.copyTo(o),a.copyTo(i));var d=o.t,u=o.data[d-1];if(0!=u){var p=u*(1<1?o.data[d-2]>>this.F2:0),g=this.FV/p,m=(1<=0&&(i.data[i.t++]=1,i.subTo(A,i)),s.ONE.dlShiftTo(d,A),A.subTo(o,o);o.t=0;){var v=i.data[--E]==u?this.DM:Math.floor(i.data[E]*g+(i.data[E-1]+y)*m);if((i.data[E]+=o.am(0,v,i,_,0,d))0&&i.rShiftTo(h,i),c<0&&s.ZERO.subTo(i,i)}}},s.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},s.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},s.prototype.exp=function(e,t){if(e>4294967295||e<1)return s.ONE;var i=n(),r=n(),a=t.convert(this),o=f(e)-1;for(a.copyTo(i);--o>=0;)if(t.sqrTo(i,r),(e&1<0)t.mulTo(r,a,i);else{var c=i;i=r,r=c}return t.revert(i)},s.prototype.toString=function(e){if(this.s<0)return'-'+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var i,r=(1<0)for(o>o)>0&&(s=!0,n=h(i));a>=0;)o>(o+=this.DB-t)):(i=this.data[a]>>(o-=t)&r,o<=0&&(o+=this.DB,--a)),i>0&&(s=!0),s&&(n+=h(i));return s?n:'0'},s.prototype.negate=function(){var e=n();return s.ZERO.subTo(this,e),e},s.prototype.abs=function(){return this.s<0?this.negate():this},s.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var i=this.t;if(0!=(t=i-e.t))return this.s<0?-t:t;for(;--i>=0;)if(0!=(t=this.data[i]-e.data[i]))return t;return 0},s.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+f(this.data[this.t-1]^this.s&this.DM)},s.prototype.mod=function(e){var t=n();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(s.ZERO)>0&&e.subTo(t,t),t},s.prototype.modPowInt=function(e,t){var i;return i=e<256||t.isEven()?new g(t):new m(t),this.exp(e,i)},s.ZERO=p(0),s.ONE=p(1),C.prototype.convert=I,C.prototype.revert=I,C.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i)},C.prototype.sqrTo=function(e,t){e.squareTo(t)},S.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=n();return e.copyTo(t),this.reduce(t),t},S.prototype.revert=function(e){return e},S.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},S.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i),this.reduce(i)},S.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var O=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],N=(1<<26)/O[O.length-1];s.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},s.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return'0';var t=this.chunkSize(e),i=Math.pow(e,t),r=p(i),s=n(),a=n(),o='';for(this.divRemTo(r,s,a);s.signum()>0;)o=(i+a.intValue()).toString(e).substr(1)+o,s.divRemTo(r,s,a);return a.intValue().toString(e)+o},s.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var i=this.chunkSize(t),r=Math.pow(t,i),n=!1,a=0,o=0,c=0;c=i&&(this.dMultiply(r),this.dAddOffset(o,0),a=0,o=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(o,0)),n&&s.ZERO.subTo(this,this)},s.prototype.fromNumber=function(e,t,i){if('number'==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,i),this.testBit(e-1)||this.bitwiseTo(s.ONE.shiftLeft(e-1),E,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(s.ONE.shiftLeft(e-1),this);else{var r=new Array,n=7&e;r.length=1+(e>>3),t.nextBytes(r),n>0?r[0]&=(1<>=this.DB;if(e.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t.data[i++]=r:r<-1&&(t.data[i++]=this.DV+r),t.t=i,t.clamp()},s.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},s.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},s.prototype.multiplyLowerTo=function(e,t,i){var r,s=Math.min(this.t+e.t,t);for(i.s=0,i.t=s;s>0;)i.data[--s]=0;for(r=i.t-this.t;s=0;)i.data[r]=0;for(r=Math.max(t-this.t,0);r0)if(0==t)i=this.data[0]%e;else for(var r=this.t-1;r>=0;--r)i=(t*i+this.data[r])%e;return i},s.prototype.millerRabin=function(e){var t=this.subtract(s.ONE),i=t.getLowestSetBit();if(i<=0)return!1;for(var r,n=t.shiftRight(i),a={nextBytes:function(e){for(var t=0;t=0);var c=r.modPow(n,this);if(0!=c.compareTo(s.ONE)&&0!=c.compareTo(t)){for(var l=1;l++>24},s.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},s.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},s.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var i,r=this.DB-e*this.DB%8,s=0;if(e-- >0)for(r>r)!=(this.s&this.DM)>>r&&(t[s++]=i|this.s<=0;)r<8?(i=(this.data[e]&(1<>(r+=this.DB-8)):(i=this.data[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),128&i&&(i|=-256),0==s&&(128&this.s)!=(128&i)&&++s,(s>0||i!=this.s)&&(t[s++]=i);return t},s.prototype.equals=function(e){return 0==this.compareTo(e)},s.prototype.min=function(e){return this.compareTo(e)<0?this:e},s.prototype.max=function(e){return this.compareTo(e)>0?this:e},s.prototype.and=function(e){var t=n();return this.bitwiseTo(e,y,t),t},s.prototype.or=function(e){var t=n();return this.bitwiseTo(e,E,t),t},s.prototype.xor=function(e){var t=n();return this.bitwiseTo(e,_,t),t},s.prototype.andNot=function(e){var t=n();return this.bitwiseTo(e,A,t),t},s.prototype.not=function(){for(var e=n(),t=0;t=this.t?0!=this.s:!!(this.data[t]&1<1){var d=n();for(r.sqrTo(o[1],d);c<=h;)o[c]=n(),r.mulTo(d,o[c-2],o[c]),c+=2}var u,y,E=e.t-1,_=!0,A=n();for(s=f(e.data[E])-1;E>=0;){for(s>=l?u=e.data[E]>>s-l&h:(u=(e.data[E]&(1<0&&(u|=e.data[E-1]>>this.DB+s-l)),c=i;!(1&u);)u>>=1,--c;if((s-=c)<0&&(s+=this.DB,--E),_)o[u].copyTo(a),_=!1;else{for(;c>1;)r.sqrTo(a,A),r.sqrTo(A,a),c-=2;c>0?r.sqrTo(a,A):(y=a,a=A,A=y),r.mulTo(A,o[u],a)}for(;E>=0&&!(e.data[E]&1<=0?(i.subTo(r,i),t&&n.subTo(o,n),a.subTo(c,a)):(r.subTo(i,r),t&&o.subTo(n,o),c.subTo(a,c))}return 0!=r.compareTo(s.ONE)?s.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},s.prototype.pow=function(e){return this.exp(e,new C)},s.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),i=e.s<0?e.negate():e.clone();if(t.compareTo(i)<0){var r=t;t=i,i=r}var s=t.getLowestSetBit(),n=i.getLowestSetBit();if(n<0)return t;for(s0&&(t.rShiftTo(n,t),i.rShiftTo(n,i));t.signum()>0;)(s=t.getLowestSetBit())>0&&t.rShiftTo(s,t),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),t.compareTo(i)>=0?(t.subTo(i,t),t.rShiftTo(1,t)):(i.subTo(t,i),i.rShiftTo(1,i));return n>0&&i.lShiftTo(n,i),i},s.prototype.isProbablePrime=function(e){var t,i=this.abs();if(1==i.t&&i.data[0]<=O[O.length-1]){for(t=0;t>>0,c>>>0];for(var l=o.fullMessageLength.length-1;l>=0;--l)o.fullMessageLength[l]+=c[1],c[1]=c[0]+(o.fullMessageLength[l]/4294967296>>>0),o.fullMessageLength[l]=o.fullMessageLength[l]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(s),a(e,r,t),(t.read>2048||0===t.length())&&t.compact(),o},o.digest=function(){var n=i.util.createBuffer();n.putBytes(t.bytes());var c,l=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;n.putBytes(s.substr(0,o.blockLength-l));for(var h=8*o.fullMessageLength[0],d=0;d>>0,n.putInt32(h>>>0),h=c>>>0;n.putInt32(h);var u={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(u,r,n);var p=i.util.createBuffer();return p.putInt32(u.h0),p.putInt32(u.h1),p.putInt32(u.h2),p.putInt32(u.h3),p.putInt32(u.h4),p},o};var s=null,n=!1;function a(e,t,i){for(var r,s,n,a,o,c,l,h=i.length();h>=64;){for(s=e.h0,n=e.h1,a=e.h2,o=e.h3,c=e.h4,l=0;l<16;++l)r=i.getInt32(),t[l]=r,r=(s<<5|s>>>27)+(o^n&(a^o))+c+1518500249+r,c=o,o=a,a=(n<<30|n>>>2)>>>0,n=s,s=r;for(;l<20;++l)r=(r=t[l-3]^t[l-8]^t[l-14]^t[l-16])<<1|r>>>31,t[l]=r,r=(s<<5|s>>>27)+(o^n&(a^o))+c+1518500249+r,c=o,o=a,a=(n<<30|n>>>2)>>>0,n=s,s=r;for(;l<32;++l)r=(r=t[l-3]^t[l-8]^t[l-14]^t[l-16])<<1|r>>>31,t[l]=r,r=(s<<5|s>>>27)+(n^a^o)+c+1859775393+r,c=o,o=a,a=(n<<30|n>>>2)>>>0,n=s,s=r;for(;l<40;++l)r=(r=t[l-6]^t[l-16]^t[l-28]^t[l-32])<<2|r>>>30,t[l]=r,r=(s<<5|s>>>27)+(n^a^o)+c+1859775393+r,c=o,o=a,a=(n<<30|n>>>2)>>>0,n=s,s=r;for(;l<60;++l)r=(r=t[l-6]^t[l-16]^t[l-28]^t[l-32])<<2|r>>>30,t[l]=r,r=(s<<5|s>>>27)+(n&a|o&(n^a))+c+2400959708+r,c=o,o=a,a=(n<<30|n>>>2)>>>0,n=s,s=r;for(;l<80;++l)r=(r=t[l-6]^t[l-16]^t[l-28]^t[l-32])<<2|r>>>30,t[l]=r,r=(s<<5|s>>>27)+(n^a^o)+c+3395469782+r,c=o,o=a,a=(n<<30|n>>>2)>>>0,n=s,s=r;e.h0=e.h0+s|0,e.h1=e.h1+n|0,e.h2=e.h2+a|0,e.h3=e.h3+o|0,e.h4=e.h4+c|0,h-=64}}}}),R=d({'node_modules/node-forge/lib/pkcs1.js'(e,t){var i=u();f(),L(),b();var r=t.exports=i.pkcs1=i.pkcs1||{};function s(e,t,r){r||(r=i.md.sha1.create());for(var s='',n=Math.ceil(t/r.digestLength),a=0;a>24&255,a>>16&255,a>>8&255,255&a);r.start(),r.update(e+o),s+=r.digest().getBytes()}return s.substring(0,t)}r.encode_rsa_oaep=function(e,t,r){var n,a,o,c;'string'==typeof r?(n=r,a=arguments[3]||void 0,o=arguments[4]||void 0):r&&(n=r.label||void 0,a=r.seed||void 0,o=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),o?o.start():o=i.md.sha1.create(),c||(c=o);var l=Math.ceil(e.n.bitLength()/8),h=l-2*o.digestLength-2;if(t.length>h)throw(m=new Error('RSAES-OAEP input message length is too long.')).length=t.length,m.maxLength=h,m;n||(n=''),o.update(n,'raw');for(var d=o.digest(),u='',p=h-t.length,f=0;fe&&(a=l(e,t));var p=a.toString(16);s.target.postMessage({hex:p,workLoad:h}),a.dAddOffset(d,0)}}}p()}(e,t,s,n);return o(e,t,s,n)}(e,c,n.options,s);throw new Error('Invalid prime generation algorithm: '+n.name)}}function o(e,t,i,r){var s=l(e,t),n=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(s.bitLength());'millerRabinTests'in i&&(n=i.millerRabinTests);var a=10;'maxBlockTime'in i&&(a=i.maxBlockTime),c(s,e,t,0,n,a,r)}function c(e,t,r,n,a,o,h){var d=+new Date;do{if(e.bitLength()>t&&(e=l(t,r)),e.isProbablePrime(a))return h(null,e);e.dAddOffset(s[n++%8],0)}while(o<0||+new Date-d=0||!n.gcd(t.n).equals(i.ONE));for(var a=(e=e.multiply(n.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),o=e.mod(t.q).modPow(t.dQ,t.q);a.compareTo(o)<0;)a=a.add(t.p);var c=a.subtract(o).multiply(t.qInv).mod(t.p).multiply(t.q).add(o);return c=c.multiply(n.modInverse(t.n)).mod(t.n)};function v(e,t,i){var s=r.util.createBuffer(),n=Math.ceil(t.n.bitLength()/8);if(e.length>n-11){var a=new Error('Message is too long for PKCS#1 v1.5 padding.');throw a.length=e.length,a.max=n-11,a}s.putByte(0),s.putByte(i);var o,c=n-3-e.length;if(0===i||1===i){o=0===i?0:255;for(var l=0;l0;){var h=0,d=r.random.getBytes(c);for(l=0;l1;){if(255!==a.getByte()){--a.read;break}++l}else if(2===c)for(l=0;a.length()>1;){if(0===a.getByte()){--a.read;break}++l}if(0!==a.getByte()||l!==n-3-a.length())throw new Error('Encryption block is invalid.');return a.getBytes()}function C(e){var t=e.toString(16);t[0]>='8'&&(t='00'+t);var i=r.util.hexToBytes(t);return!(i.length>1)||(0!==i.charCodeAt(0)||128&i.charCodeAt(1))&&(255!==i.charCodeAt(0)||128&~i.charCodeAt(1))?i:i.substr(1)}function I(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function S(e){return r.util.isNodejs&&'function'==typeof s[e]}function O(e){return void 0!==a.globalScope&&'object'==typeof a.globalScope.crypto&&'object'==typeof a.globalScope.crypto.subtle&&'function'==typeof a.globalScope.crypto.subtle[e]}function N(e){return void 0!==a.globalScope&&'object'==typeof a.globalScope.msCrypto&&'object'==typeof a.globalScope.msCrypto.subtle&&'function'==typeof a.globalScope.msCrypto.subtle[e]}function P(e){for(var t=r.util.hexToBytes(e.toString(16)),i=new Uint8Array(t.length),s=0;s0;)h.putByte(0),--d;return h.putBytes(r.util.hexToBytes(l)),h.getBytes()},o.rsa.decrypt=function(e,t,s,n){var a=Math.ceil(t.n.bitLength()/8);if(e.length!==a){var o=new Error('Encrypted message length is invalid.');throw o.length=e.length,o.expected=a,o}var c=new i(r.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error('Encrypted message is invalid.');for(var l=A(c,t,s).toString(16),h=r.util.createBuffer(),d=a-Math.ceil(l.length/2);d>0;)h.putByte(0),--d;return h.putBytes(r.util.hexToBytes(l)),!1!==n?T(h.getBytes(),t,s):h.getBytes()},o.rsa.createKeyPairGenerationState=function(e,t,s){'string'==typeof e&&(e=parseInt(e,10)),e=e||2048;var n,a=(s=s||{}).prng||r.random,o={nextBytes:function(e){for(var t=a.getBytesSync(e.length),i=0;i>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(n.eInt),n},o.rsa.stepKeyPairGenerationState=function(e,t){'algorithm'in e||(e.algorithm='PRIMEINC');var r=new i(null);r.fromInt(30);for(var s,n=0,a=function(e,t){return e|t},l=+new Date,h=0;null===e.keys&&(t<=0||hd?e.pqState=0:e.num.isProbablePrime(I(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(c[n++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(i.ONE).gcd(e.e).compareTo(i.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(i.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var p=e.e.modInverse(e.phi);e.keys={privateKey:o.rsa.setPrivateKey(e.n,e.e,p,e.p,e.q,p.mod(e.p1),p.mod(e.q1),e.q.modInverse(e.p)),publicKey:o.rsa.setPublicKey(e.n,e.e)}}h+=(s=+new Date)-l,l=s}return null!==e.keys},o.rsa.generateKeyPair=function(e,t,c,l){if(1===arguments.length?'object'==typeof e?(c=e,e=void 0):'function'==typeof e&&(l=e,e=void 0):2===arguments.length?'number'==typeof e?'function'==typeof t?(l=t,t=void 0):'number'!=typeof t&&(c=t,t=void 0):(c=e,l=t,e=void 0,t=void 0):3===arguments.length&&('number'==typeof t?'function'==typeof c&&(l=c,c=void 0):(l=c,c=t,t=void 0)),c=c||{},void 0===e&&(e=c.bits||2048),void 0===t&&(t=c.e||65537),!r.options.usePureJavaScript&&!c.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(l){if(S('generateKeyPair'))return s.generateKeyPair('rsa',{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:'spki',format:'pem'},privateKeyEncoding:{type:'pkcs8',format:'pem'}},(function(e,t,i){if(e)return l(e);l(null,{privateKey:o.privateKeyFromPem(i),publicKey:o.publicKeyFromPem(t)})}));if(O('generateKey')&&O('exportKey'))return a.globalScope.crypto.subtle.generateKey({name:'RSASSA-PKCS1-v1_5',modulusLength:e,publicExponent:P(t),hash:{name:'SHA-256'}},!0,['sign','verify']).then((function(e){return a.globalScope.crypto.subtle.exportKey('pkcs8',e.privateKey)})).then(void 0,(function(e){l(e)})).then((function(e){if(e){var t=o.privateKeyFromAsn1(n.fromDer(r.util.createBuffer(e)));l(null,{privateKey:t,publicKey:o.setRsaPublicKey(t.n,t.e)})}}));if(N('generateKey')&&N('exportKey')){var h=a.globalScope.msCrypto.subtle.generateKey({name:'RSASSA-PKCS1-v1_5',modulusLength:e,publicExponent:P(t),hash:{name:'SHA-256'}},!0,['sign','verify']);return h.oncomplete=function(e){var t=e.target.result,i=a.globalScope.msCrypto.subtle.exportKey('pkcs8',t.privateKey);i.oncomplete=function(e){var t=e.target.result,i=o.privateKeyFromAsn1(n.fromDer(r.util.createBuffer(t)));l(null,{privateKey:i,publicKey:o.setRsaPublicKey(i.n,i.e)})},i.onerror=function(e){l(e)}},void(h.onerror=function(e){l(e)})}}else if(S('generateKeyPairSync')){var d=s.generateKeyPairSync('rsa',{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:'spki',format:'pem'},privateKeyEncoding:{type:'pkcs8',format:'pem'}});return{privateKey:o.privateKeyFromPem(d.privateKey),publicKey:o.publicKeyFromPem(d.publicKey)}}var u=o.rsa.createKeyPairGenerationState(e,t,c);if(!l)return o.rsa.stepKeyPairGenerationState(u,0),u.keys;!function(e,t,s){'function'==typeof t&&(s=t,t={});t=t||{};var n={algorithm:{name:t.algorithm||'PRIMEINC',options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};'prng'in t&&(n.prng=t.prng);function a(){c(e.pBits,(function(t,i){return t?s(t):(e.p=i,null!==e.q?l(t,e.q):void c(e.qBits,l))}))}function c(e,t){r.prime.generateProbablePrime(e,n,t)}function l(t,r){if(t)return s(t);if(e.q=r,e.p.compareTo(e.q)<0){var n=e.p;e.p=e.q,e.q=n}if(0!==e.p.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.p=null,void a();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void c(e.qBits,l);if(e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(i.ONE))return e.p=e.q=null,void a();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void c(e.qBits,l);var h=e.e.modInverse(e.phi);e.keys={privateKey:o.rsa.setPrivateKey(e.n,e.e,h,e.p,e.q,h.mod(e.p1),h.mod(e.q1),e.q.modInverse(e.p)),publicKey:o.rsa.setPublicKey(e.n,e.e)},s(null,e.keys)}a()}(u,c,l)},o.setRsaPublicKey=o.rsa.setPublicKey=function(e,t){var i={n:e,e:t,encrypt:function(e,t,s){if('string'==typeof t?t=t.toUpperCase():void 0===t&&(t='RSAES-PKCS1-V1_5'),'RSAES-PKCS1-V1_5'===t)t={encode:function(e,t,i){return v(e,t,2).getBytes()}};else if('RSA-OAEP'===t||'RSAES-OAEP'===t)t={encode:function(e,t){return r.pkcs1.encode_rsa_oaep(t,e,s)}};else if(-1!==['RAW','NONE','NULL',null].indexOf(t))t={encode:function(e){return e}};else if('string'==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var n=t.encode(e,i,!0);return o.rsa.encrypt(n,i,!0)},verify:function(e,t,s,a){'string'==typeof s?s=s.toUpperCase():void 0===s&&(s='RSASSA-PKCS1-V1_5'),void 0===a&&(a={_parseAllDigestBytes:!0}),'_parseAllDigestBytes'in a||(a._parseAllDigestBytes=!0),'RSASSA-PKCS1-V1_5'===s?s={verify:function(e,t){t=T(t,i,!0);var s=n.fromDer(t,{parseAllBytes:a._parseAllDigestBytes}),o={},c=[];if(!n.validate(s,m,o,c))throw(l=new Error('ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.')).errors=c,l;var l,h=n.derToOid(o.algorithmIdentifier);if(h!==r.oids.md2&&h!==r.oids.md5&&h!==r.oids.sha1&&h!==r.oids.sha224&&h!==r.oids.sha256&&h!==r.oids.sha384&&h!==r.oids.sha512&&h!==r.oids['sha512-224']&&h!==r.oids['sha512-256'])throw(l=new Error('Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.')).oid=h,l;if((h===r.oids.md2||h===r.oids.md5)&&!('parameters'in o))throw new Error('ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.');return e===o.digest}}:'NONE'!==s&&'NULL'!==s&&null!==s||(s={verify:function(e,t){return e===(t=T(t,i,!0))}});var c=o.rsa.decrypt(t,i,!0,!1);return s.verify(e,c,i.n.bitLength())}};return i},o.setRsaPrivateKey=o.rsa.setPrivateKey=function(e,t,i,s,n,a,c,l){var h={n:e,e:t,d:i,p:s,q:n,dP:a,dQ:c,qInv:l,decrypt:function(e,t,i){'string'==typeof t?t=t.toUpperCase():void 0===t&&(t='RSAES-PKCS1-V1_5');var s=o.rsa.decrypt(e,h,!1,!1);if('RSAES-PKCS1-V1_5'===t)t={decode:T};else if('RSA-OAEP'===t||'RSAES-OAEP'===t)t={decode:function(e,t){return r.pkcs1.decode_rsa_oaep(t,e,i)}};else{if(-1===['RAW','NONE','NULL',null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(s,h,!1)},sign:function(e,t){var i=!1;'string'==typeof t&&(t=t.toUpperCase()),void 0===t||'RSASSA-PKCS1-V1_5'===t?(t={encode:y},i=1):'NONE'!==t&&'NULL'!==t&&null!==t||(t={encode:function(){return e}},i=1);var r=t.encode(e,h.n.bitLength());return o.rsa.encrypt(r,h,i)}};return h},o.wrapRsaPrivateKey=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,n.integerToDer(0).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(o.oids.rsaEncryption).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.NULL,!1,'')]),n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,n.toDer(e).getBytes())])},o.privateKeyFromAsn1=function(e){var t,s,a,c,h,u,p,f,g={},m=[];if(n.validate(e,l,g,m)&&(e=n.fromDer(r.util.createBuffer(g.privateKey))),g={},m=[],!n.validate(e,d,g,m)){var y=new Error('Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.');throw y.errors=m,y}return t=r.util.createBuffer(g.privateKeyModulus).toHex(),s=r.util.createBuffer(g.privateKeyPublicExponent).toHex(),a=r.util.createBuffer(g.privateKeyPrivateExponent).toHex(),c=r.util.createBuffer(g.privateKeyPrime1).toHex(),h=r.util.createBuffer(g.privateKeyPrime2).toHex(),u=r.util.createBuffer(g.privateKeyExponent1).toHex(),p=r.util.createBuffer(g.privateKeyExponent2).toHex(),f=r.util.createBuffer(g.privateKeyCoefficient).toHex(),o.setRsaPrivateKey(new i(t,16),new i(s,16),new i(a,16),new i(c,16),new i(h,16),new i(u,16),new i(p,16),new i(f,16))},o.privateKeyToAsn1=o.privateKeyToRSAPrivateKey=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,n.integerToDer(0).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.n)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.e)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.d)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.p)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.q)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.dP)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.dQ)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.qInv))])},o.publicKeyFromAsn1=function(e){var t={},s=[];if(n.validate(e,g,t,s)){var a,c=n.derToOid(t.publicKeyOid);if(c!==o.oids.rsaEncryption)throw(a=new Error('Cannot read public key. Unknown OID.')).oid=c,a;e=t.rsaPublicKey}if(s=[],!n.validate(e,p,t,s))throw(a=new Error('Cannot read public key. ASN.1 object does not contain an RSAPublicKey.')).errors=s,a;var l=r.util.createBuffer(t.publicKeyModulus).toHex(),h=r.util.createBuffer(t.publicKeyExponent).toHex();return o.setRsaPublicKey(new i(l,16),new i(h,16))},o.publicKeyToAsn1=o.publicKeyToSubjectPublicKeyInfo=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(o.oids.rsaEncryption).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.NULL,!1,'')]),n.create(n.Class.UNIVERSAL,n.Type.BITSTRING,!1,[o.publicKeyToRSAPublicKey(e)])])},o.publicKeyToRSAPublicKey=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.n)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,C(e.e))])}}}),D=d({'node_modules/node-forge/lib/pbe.js'(e,t){var i,r=u();y(),_(),I(),A(),E(),S(),C(),L(),P(),U(),f(),void 0===i&&(i=r.jsbn.BigInteger);var s=r.asn1,n=r.pki=r.pki||{};t.exports=n.pbe=r.pbe=r.pbe||{};var a=n.oids,o={name:'EncryptedPrivateKeyInfo',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'EncryptedPrivateKeyInfo.encryptionAlgorithm',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:'encryptionOid'},{name:'AlgorithmIdentifier.parameters',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,captureAsn1:'encryptionParams'}]},{name:'EncryptedPrivateKeyInfo.encryptedData',tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:'encryptedData'}]},c={name:'PBES2Algorithms',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.keyDerivationFunc',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.keyDerivationFunc.oid',tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:'kdfOid'},{name:'PBES2Algorithms.params',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.params.salt',tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:'kdfSalt'},{name:'PBES2Algorithms.params.iterationCount',tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:'kdfIterationCount'},{name:'PBES2Algorithms.params.keyLength',tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,optional:!0,capture:'keyLength'},{name:'PBES2Algorithms.params.prf',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:'PBES2Algorithms.params.prf.algorithm',tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:'prfOid'}]}]}]},{name:'PBES2Algorithms.encryptionScheme',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'PBES2Algorithms.encryptionScheme.oid',tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:'encOid'},{name:'PBES2Algorithms.encryptionScheme.iv',tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:'encIv'}]}]},l={name:'pkcs-12PbeParams',tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:'pkcs-12PbeParams.salt',tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:'salt'},{name:'pkcs-12PbeParams.iterations',tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:'iterations'}]};function h(e,t){return e.start().update(t).digest().getBytes()}function d(e){var t;if(e){if(!(t=n.oids[s.derToOid(e)])){var i=new Error('Unsupported PRF OID.');throw i.oid=e,i.supported=['hmacWithSHA1','hmacWithSHA224','hmacWithSHA256','hmacWithSHA384','hmacWithSHA512'],i}}else t='hmacWithSHA1';return p(t)}function p(e){var t=r.md;switch(e){case'hmacWithSHA224':t=r.md.sha512;case'hmacWithSHA1':case'hmacWithSHA256':case'hmacWithSHA384':case'hmacWithSHA512':e=e.substr(8).toLowerCase();break;default:var i=new Error('Unsupported PRF algorithm.');throw i.algorithm=e,i.supported=['hmacWithSHA1','hmacWithSHA224','hmacWithSHA256','hmacWithSHA384','hmacWithSHA512'],i}if(!t||!(e in t))throw new Error('Unknown hash algorithm: '+e);return t[e].create()}n.encryptPrivateKeyInfo=function(e,t,i){(i=i||{}).saltSize=i.saltSize||8,i.count=i.count||2048,i.algorithm=i.algorithm||'aes128',i.prfAlgorithm=i.prfAlgorithm||'sha1';var o,c,l,h=r.random.getBytesSync(i.saltSize),d=i.count,u=s.integerToDer(d);if(0===i.algorithm.indexOf('aes')||'des'===i.algorithm){var f,g,m;switch(i.algorithm){case'aes128':o=16,f=16,g=a['aes128-CBC'],m=r.aes.createEncryptionCipher;break;case'aes192':o=24,f=16,g=a['aes192-CBC'],m=r.aes.createEncryptionCipher;break;case'aes256':o=32,f=16,g=a['aes256-CBC'],m=r.aes.createEncryptionCipher;break;case'des':o=8,f=8,g=a.desCBC,m=r.des.createEncryptionCipher;break;default:throw(T=new Error('Cannot encrypt private key. Unknown encryption algorithm.')).algorithm=i.algorithm,T}var y='hmacWith'+i.prfAlgorithm.toUpperCase(),E=p(y),_=r.pkcs5.pbkdf2(t,h,d,o,E),A=r.random.getBytesSync(f);(C=m(_)).start(A),C.update(s.toDer(e)),C.finish(),l=C.output.getBytes();var v=function(e,t,i,a){var o=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,e),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,t.getBytes())]);'hmacWithSHA1'!==a&&o.value.push(s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,r.util.hexToBytes(i.toString(16))),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(n.oids[a]).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,'')]));return o}(h,u,o,y);c=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a.pkcs5PBES2).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a.pkcs5PBKDF2).getBytes()),v]),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(g).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,A)])])])}else{var T;if('3des'!==i.algorithm)throw(T=new Error('Cannot encrypt private key. Unknown encryption algorithm.')).algorithm=i.algorithm,T;o=24;var C,I=new r.util.ByteBuffer(h);_=n.pbe.generatePkcs12Key(t,I,1,d,o),A=n.pbe.generatePkcs12Key(t,I,2,d,o);(C=r.des.createEncryptionCipher(_)).start(A),C.update(s.toDer(e)),C.finish(),l=C.output.getBytes(),c=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a['pbeWithSHAAnd3-KeyTripleDES-CBC']).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,h),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,u.getBytes())])])}return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[c,s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,l)])},n.decryptPrivateKeyInfo=function(e,t){var i=null,a={},c=[];if(!s.validate(e,o,a,c)){var l=new Error('Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.');throw l.errors=c,l}var h=s.derToOid(a.encryptionOid),d=n.pbe.getCipher(h,a.encryptionParams,t),u=r.util.createBuffer(a.encryptedData);return d.update(u),d.finish()&&(i=s.fromDer(d.output)),i},n.encryptedPrivateKeyToPem=function(e,t){var i={type:'ENCRYPTED PRIVATE KEY',body:s.toDer(e).getBytes()};return r.pem.encode(i,{maxline:t})},n.encryptedPrivateKeyFromPem=function(e){var t=r.pem.decode(e)[0];if('ENCRYPTED PRIVATE KEY'!==t.type){var i=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw i.headerType=t.type,i}if(t.procType&&'ENCRYPTED'===t.procType.type)throw new Error('Could not convert encrypted private key from PEM; PEM is encrypted.');return s.fromDer(t.body)},n.encryptRsaPrivateKey=function(e,t,i){if(!(i=i||{}).legacy){var a=n.wrapRsaPrivateKey(n.privateKeyToAsn1(e));return a=n.encryptPrivateKeyInfo(a,t,i),n.encryptedPrivateKeyToPem(a)}var o,c,l,h;switch(i.algorithm){case'aes128':o='AES-128-CBC',l=16,c=r.random.getBytesSync(16),h=r.aes.createEncryptionCipher;break;case'aes192':o='AES-192-CBC',l=24,c=r.random.getBytesSync(16),h=r.aes.createEncryptionCipher;break;case'aes256':o='AES-256-CBC',l=32,c=r.random.getBytesSync(16),h=r.aes.createEncryptionCipher;break;case'3des':o='DES-EDE3-CBC',l=24,c=r.random.getBytesSync(8),h=r.des.createEncryptionCipher;break;case'des':o='DES-CBC',l=8,c=r.random.getBytesSync(8),h=r.des.createEncryptionCipher;break;default:var d=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+i.algorithm+'".');throw d.algorithm=i.algorithm,d}var u=h(r.pbe.opensslDeriveBytes(t,c.substr(0,8),l));u.start(c),u.update(s.toDer(n.privateKeyToAsn1(e))),u.finish();var p={type:'RSA PRIVATE KEY',procType:{version:'4',type:'ENCRYPTED'},dekInfo:{algorithm:o,parameters:r.util.bytesToHex(c).toUpperCase()},body:u.output.getBytes()};return r.pem.encode(p)},n.decryptRsaPrivateKey=function(e,t){var i=null,a=r.pem.decode(e)[0];if('ENCRYPTED PRIVATE KEY'!==a.type&&'PRIVATE KEY'!==a.type&&'RSA PRIVATE KEY'!==a.type)throw(l=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=l,l;if(a.procType&&'ENCRYPTED'===a.procType.type){var o,c;switch(a.dekInfo.algorithm){case'DES-CBC':o=8,c=r.des.createDecryptionCipher;break;case'DES-EDE3-CBC':o=24,c=r.des.createDecryptionCipher;break;case'AES-128-CBC':o=16,c=r.aes.createDecryptionCipher;break;case'AES-192-CBC':o=24,c=r.aes.createDecryptionCipher;break;case'AES-256-CBC':o=32,c=r.aes.createDecryptionCipher;break;case'RC2-40-CBC':o=5,c=function(e){return r.rc2.createDecryptionCipher(e,40)};break;case'RC2-64-CBC':o=8,c=function(e){return r.rc2.createDecryptionCipher(e,64)};break;case'RC2-128-CBC':o=16,c=function(e){return r.rc2.createDecryptionCipher(e,128)};break;default:var l;throw(l=new Error('Could not decrypt private key; unsupported encryption algorithm "'+a.dekInfo.algorithm+'".')).algorithm=a.dekInfo.algorithm,l}var h=r.util.hexToBytes(a.dekInfo.parameters),d=c(r.pbe.opensslDeriveBytes(t,h.substr(0,8),o));if(d.start(h),d.update(r.util.createBuffer(a.body)),!d.finish())return i;i=d.output.getBytes()}else i=a.body;return null!==(i='ENCRYPTED PRIVATE KEY'===a.type?n.decryptPrivateKeyInfo(s.fromDer(i),t):s.fromDer(i))&&(i=n.privateKeyFromAsn1(i)),i},n.pbe.generatePkcs12Key=function(e,t,i,s,n,a){var o,c;if(null==a){if(!('sha1'in r.md))throw new Error('"sha1" hash algorithm unavailable.');a=r.md.sha1.create()}var l=a.digestLength,h=a.blockLength,d=new r.util.ByteBuffer,u=new r.util.ByteBuffer;if(null!=e){for(c=0;c=0;c--)P>>=8,P+=S.at(c)+L.at(c),L.setAt(c,255&P);N.putBuffer(L)}A=N,d.putBuffer(C)}return d.truncate(d.length()-n),d},n.pbe.getCipher=function(e,t,i){switch(e){case n.oids.pkcs5PBES2:return n.pbe.getCipherForPBES2(e,t,i);case n.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:case n.oids['pbewithSHAAnd40BitRC2-CBC']:return n.pbe.getCipherForPKCS12PBE(e,t,i);default:var r=new Error('Cannot read encrypted PBE data block. Unsupported OID.');throw r.oid=e,r.supportedOids=['pkcs5PBES2','pbeWithSHAAnd3-KeyTripleDES-CBC','pbewithSHAAnd40BitRC2-CBC'],r}},n.pbe.getCipherForPBES2=function(e,t,i){var a,o={},l=[];if(!s.validate(t,c,o,l))throw(a=new Error('Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.')).errors=l,a;if((e=s.derToOid(o.kdfOid))!==n.oids.pkcs5PBKDF2)throw(a=new Error('Cannot read encrypted private key. Unsupported key derivation function OID.')).oid=e,a.supportedOids=['pkcs5PBKDF2'],a;if((e=s.derToOid(o.encOid))!==n.oids['aes128-CBC']&&e!==n.oids['aes192-CBC']&&e!==n.oids['aes256-CBC']&&e!==n.oids['des-EDE3-CBC']&&e!==n.oids.desCBC)throw(a=new Error('Cannot read encrypted private key. Unsupported encryption scheme OID.')).oid=e,a.supportedOids=['aes128-CBC','aes192-CBC','aes256-CBC','des-EDE3-CBC','desCBC'],a;var h,u,p=o.kdfSalt,f=r.util.createBuffer(o.kdfIterationCount);switch(f=f.getInt(f.length()<<3),n.oids[e]){case'aes128-CBC':h=16,u=r.aes.createDecryptionCipher;break;case'aes192-CBC':h=24,u=r.aes.createDecryptionCipher;break;case'aes256-CBC':h=32,u=r.aes.createDecryptionCipher;break;case'des-EDE3-CBC':h=24,u=r.des.createDecryptionCipher;break;case'desCBC':h=8,u=r.des.createDecryptionCipher}var g=d(o.prfOid),m=r.pkcs5.pbkdf2(i,p,f,h,g),y=o.encIv,E=u(m);return E.start(y),E},n.pbe.getCipherForPKCS12PBE=function(e,t,i){var a={},o=[];if(!s.validate(t,l,a,o))throw(g=new Error('Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.')).errors=o,g;var c,h,u,p=r.util.createBuffer(a.salt),f=r.util.createBuffer(a.iterations);switch(f=f.getInt(f.length()<<3),e){case n.oids['pbeWithSHAAnd3-KeyTripleDES-CBC']:c=24,h=8,u=r.des.startDecrypting;break;case n.oids['pbewithSHAAnd40BitRC2-CBC']:c=5,h=8,u=function(e,t){var i=r.rc2.createDecryptionCipher(e,40);return i.start(t,null),i};break;default:var g;throw(g=new Error('Cannot read PKCS #12 PBE data block. Unsupported OID.')).oid=e,g}var m=d(a.prfOid),y=n.pbe.generatePkcs12Key(i,p,1,f,c,m);return m.start(),u(y,n.pbe.generatePkcs12Key(i,p,2,f,h,m))},n.pbe.opensslDeriveBytes=function(e,t,i,s){if(null==s){if(!('md5'in r.md))throw new Error('"md5" hash algorithm unavailable.');s=r.md.md5.create()}null===t&&(t='');for(var n=[h(s,e+t)],a=16,o=1;a>8*u-d&255;return(A=String.fromCharCode(A.charCodeAt(0)&~v)+A.substr(1))+g+String.fromCharCode(188)},verify:function(e,a,o){var c,l=o-1,h=Math.ceil(l/8);if(a=a.substr(-h),h>8*h-l&255;if(u.charCodeAt(0)&f)throw new Error('Bits beyond keysize not zero as expected.');var g=s.generate(p,d),m='';for(c=0;c128)throw new Error('Invalid "nsComment" content.');e.value=r.create(r.Class.UNIVERSAL,r.Type.IA5STRING,!1,e.comment)}else if('subjectKeyIdentifier'===e.name&&t.cert){var p=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=p.toHex(),e.value=r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,p.getBytes())}else if('authorityKeyIdentifier'===e.name&&t.cert){e.value=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);h=e.value.value;if(e.keyIdentifier){var f=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;h.push(r.create(r.Class.CONTEXT_SPECIFIC,0,!1,f))}if(e.authorityCertIssuer){var g=[r.create(r.Class.CONTEXT_SPECIFIC,4,!0,[T(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];h.push(r.create(r.Class.CONTEXT_SPECIFIC,1,!0,g))}if(e.serialNumber){var m=i.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);h.push(r.create(r.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if('cRLDistributionPoints'===e.name){e.value=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);h=e.value.value;var y,E=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]),_=r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[]);for(u=0;u2)throw new Error('Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.');if(d.length<2)throw new Error('Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.');if(l.validity.notBefore=d[0],l.validity.notAfter=d[1],l.tbsCertificate=n.tbsCertificate,t){l.md=m({signatureOid:l.signatureOid,type:'certificate'});var u=r.toDer(l.tbsCertificate);l.md.update(u.getBytes())}var f=i.md.sha1.create(),y=r.toDer(n.certIssuer);f.update(y.getBytes()),l.issuer.getField=function(e){return p(l.issuer,e)},l.issuer.addField=function(e){S([e]),l.issuer.attributes.push(e)},l.issuer.attributes=s.RDNAttributesAsArray(n.certIssuer),n.certIssuerUniqueId&&(l.issuer.uniqueId=n.certIssuerUniqueId),l.issuer.hash=f.digest().toHex();var E=i.md.sha1.create(),_=r.toDer(n.certSubject);return E.update(_.getBytes()),l.subject.getField=function(e){return p(l.subject,e)},l.subject.addField=function(e){S([e]),l.subject.attributes.push(e)},l.subject.attributes=s.RDNAttributesAsArray(n.certSubject),n.certSubjectUniqueId&&(l.subject.uniqueId=n.certSubjectUniqueId),l.subject.hash=E.digest().toHex(),n.certExtensions?l.extensions=s.certificateExtensionsFromAsn1(n.certExtensions):l.extensions=[],l.publicKey=s.publicKeyFromAsn1(n.subjectPublicKeyInfo),l},s.certificateExtensionsFromAsn1=function(e){for(var t=[],i=0;i1&&(s=c.value.charCodeAt(1),a=c.value.length>2?c.value.charCodeAt(2):0),t.digitalSignature=!(128&~s),t.nonRepudiation=!(64&~s),t.keyEncipherment=!(32&~s),t.dataEncipherment=!(16&~s),t.keyAgreement=!(8&~s),t.keyCertSign=!(4&~s),t.cRLSign=!(2&~s),t.encipherOnly=!(1&~s),t.decipherOnly=!(128&~a)}else if('basicConstraints'===t.name){(c=r.fromDer(t.value)).value.length>0&&c.value[0].type===r.Type.BOOLEAN?t.cA=0!==c.value[0].value.charCodeAt(0):t.cA=!1;var o=null;c.value.length>0&&c.value[0].type===r.Type.INTEGER?o=c.value[0].value:c.value.length>1&&(o=c.value[1].value),null!==o&&(t.pathLenConstraint=r.derToInteger(o))}else if('extKeyUsage'===t.name)for(var c=r.fromDer(t.value),l=0;l1&&(s=c.value.charCodeAt(1)),t.client=!(128&~s),t.server=!(64&~s),t.email=!(32&~s),t.objsign=!(16&~s),t.reserved=!(8&~s),t.sslCA=!(4&~s),t.emailCA=!(2&~s),t.objCA=!(1&~s)}else if('subjectAltName'===t.name||'issuerAltName'===t.name){var d;t.altNames=[];c=r.fromDer(t.value);for(var u=0;u=P&&e0&&a.value.push(s.certificateExtensionsToAsn1(e.extensions)),a},s.getCertificationRequestInfo=function(e){return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(e.version).getBytes()),T(e.subject),s.publicKeyToAsn1(e.publicKey),L(e)])},s.distinguishedNameToAsn1=function(e){return T(e)},s.certificateToAsn1=function(e){var t=e.tbsCertificate||s.getTBSCertificate(e);return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[t,r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.signatureOid).getBytes()),N(e.signatureOid,e.signatureParameters)]),r.create(r.Class.UNIVERSAL,r.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},s.certificateExtensionsToAsn1=function(e){var t=r.create(r.Class.CONTEXT_SPECIFIC,3,!0,[]),i=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[]);t.value.push(i);for(var n=0;nh.validity.notAfter)&&(c={message:'Certificate is not valid yet or has expired.',error:s.certificateError.certificate_expired,notBefore:h.validity.notBefore,notAfter:h.validity.notAfter,now:a}),null===c){if(null===(d=t[0]||e.getIssuer(h))&&h.isIssuer(h)&&(u=!0,d=h),d){var p=d;i.util.isArray(p)||(p=[p]);for(var f=!1;!f&&p.length>0;){d=p.shift();try{f=d.verify(h)}catch(e){}}f||(c={message:'Certificate signature is invalid.',error:s.certificateError.bad_certificate})}null!==c||d&&!u||e.hasCertificate(h)||(c={message:'Certificate is not trusted.',error:s.certificateError.unknown_ca})}if(null===c&&d&&!h.isIssuer(d)&&(c={message:'Certificate issuer is invalid.',error:s.certificateError.bad_certificate}),null===c)for(var g={keyUsage:!0,basicConstraints:!0},m=0;null===c&&mE.pathLenConstraint&&(c={message:'Certificate basicConstraints pathLenConstraint violated.',error:s.certificateError.bad_certificate})}var A=null===c||c.error,v=r.verify?r.verify(A,l,n):A;if(!0!==v)throw!0===A&&(c={message:'The application rejected the certificate.',error:s.certificateError.bad_certificate}),(v||0===v)&&('object'!=typeof v||i.util.isArray(v)?'string'==typeof v&&(c.error=v):(v.message&&(c.message=v.message),v.error&&(c.error=v.error))),c;c=null,o=!1,++l}while(t.length>0);return!0}}}),V=d({'node_modules/node-forge/lib/pkcs12.js'(e,t){var i=u();_(),v(),E(),k(),D(),L(),U(),b(),f(),H();var r=i.asn1,s=i.pki,n=t.exports=i.pkcs12=i.pkcs12||{},a={name:'ContentInfo',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'ContentInfo.contentType',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'contentType'},{name:'ContentInfo.content',tagClass:r.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:'content'}]},o={name:'PFX',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'PFX.version',tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:'version'},a,{name:'PFX.macData',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:'mac',value:[{name:'PFX.macData.mac',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'PFX.macData.mac.digestAlgorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'PFX.macData.mac.digestAlgorithm.algorithm',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'macAlgorithm'},{name:'PFX.macData.mac.digestAlgorithm.parameters',tagClass:r.Class.UNIVERSAL,captureAsn1:'macAlgorithmParameters'}]},{name:'PFX.macData.mac.digest',tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:'macDigest'}]},{name:'PFX.macData.macSalt',tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:'macSalt'},{name:'PFX.macData.iterations',tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,optional:!0,capture:'macIterations'}]}]},c={name:'SafeBag',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'SafeBag.bagId',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'bagId'},{name:'SafeBag.bagValue',tagClass:r.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:'bagValue'},{name:'SafeBag.bagAttributes',tagClass:r.Class.UNIVERSAL,type:r.Type.SET,constructed:!0,optional:!0,capture:'bagAttributes'}]},l={name:'Attribute',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'Attribute.attrId',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'oid'},{name:'Attribute.attrValues',tagClass:r.Class.UNIVERSAL,type:r.Type.SET,constructed:!0,capture:'values'}]},h={name:'CertBag',tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:'CertBag.certId',tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:'certId'},{name:'CertBag.certValue',tagClass:r.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:'CertBag.certValue[0]',tagClass:r.Class.UNIVERSAL,type:r.Class.OCTETSTRING,constructed:!1,capture:'cert'}]}]};function d(e,t,i,r){for(var s=[],n=0;n=0&&s.push(o):s.push(o))}return s}function p(e){if(e.composed||e.constructed){for(var t=i.util.createBuffer(),r=0;r0&&(c=r.create(r.Class.UNIVERSAL,r.Type.SET,!0,d));var u=[],p=[];null!==t&&(p=i.util.isArray(t)?t:[t]);for(var f=[],g=0;g0){var _=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,f),A=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(s.oids.data).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,r.toDer(_).getBytes())])]);u.push(A)}var v=null;if(null!==e){var T=s.wrapRsaPrivateKey(s.privateKeyToAsn1(e));v=null===a?r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(s.oids.keyBag).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[T]),c]):r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(s.oids.pkcs8ShroudedKeyBag).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[s.encryptPrivateKeyInfo(T,a,o)]),c]);var C=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[v]),I=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(s.oids.data).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,r.toDer(C).getBytes())])]);u.push(I)}var S,O=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,u);if(o.useMac){var N=i.md.sha1.create(),L=new i.util.ByteBuffer(i.random.getBytes(o.saltSize)),P=o.count,w=(e=n.generateKey(a,L,3,P,20),i.hmac.create());w.start(N,e),w.update(r.toDer(O).getBytes());var b=w.getMac();S=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(s.oids.sha1).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,'')]),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,b.getBytes())]),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,L.getBytes()),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(P).getBytes())])}return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,r.integerToDer(3).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(s.oids.data).getBytes()),r.create(r.Class.CONTEXT_SPECIFIC,0,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,r.toDer(O).getBytes())])]),S])},n.generateKey=i.pbe.generatePkcs12Key}}),G=d({'node_modules/node-forge/lib/pki.js'(e,t){var i=u();_(),E(),D(),C(),S(),V(),F(),U(),f(),H();var r=i.asn1,s=t.exports=i.pki=i.pki||{};s.pemToDer=function(e){var t=i.pem.decode(e)[0];if(t.procType&&'ENCRYPTED'===t.procType.type)throw new Error('Could not convert PEM to DER; PEM is encrypted.');return i.util.createBuffer(t.body)},s.privateKeyFromPem=function(e){var t=i.pem.decode(e)[0];if('PRIVATE KEY'!==t.type&&'RSA PRIVATE KEY'!==t.type){var n=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw n.headerType=t.type,n}if(t.procType&&'ENCRYPTED'===t.procType.type)throw new Error('Could not convert private key from PEM; PEM is encrypted.');var a=r.fromDer(t.body);return s.privateKeyFromAsn1(a)},s.privateKeyToPem=function(e,t){var n={type:'RSA PRIVATE KEY',body:r.toDer(s.privateKeyToAsn1(e)).getBytes()};return i.pem.encode(n,{maxline:t})},s.privateKeyInfoToPem=function(e,t){var s={type:'PRIVATE KEY',body:r.toDer(e).getBytes()};return i.pem.encode(s,{maxline:t})}}}),W=d({'node_modules/node-forge/lib/tls.js'(e,t){var i=u();_(),v(),T(),C(),G(),L(),b(),f();var r=function(e,t,r,s){var n=i.util.createBuffer(),a=e.length>>1,o=a+(1&e.length),c=e.substr(0,o),l=e.substr(a,o),h=i.util.createBuffer(),d=i.hmac.create();r=t+r;var u=Math.ceil(s/16),p=Math.ceil(s/20);d.start('MD5',c);var f=i.util.createBuffer();h.putBytes(r);for(var g=0;g0&&(c.queue(e,c.createAlert(e,{level:c.Alert.Level.warning,description:c.Alert.Description.no_renegotiation})),c.flush(e)),e.process()},c.parseHelloMessage=function(e,t,r){var s=null,n=e.entity===c.ConnectionEnd.client;if(r<38)e.error(e,{message:n?'Invalid ServerHello message. Message too short.':'Invalid ClientHello message. Message too short.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});else{var o=t.fragment,l=o.length();if(s={version:{major:o.getByte(),minor:o.getByte()},random:i.util.createBuffer(o.getBytes(32)),session_id:a(o,1),extensions:[]},n?(s.cipher_suite=o.getBytes(2),s.compression_method=o.getByte()):(s.cipher_suites=a(o,2),s.compression_methods=a(o,1)),(l=r-(l-o.length()))>0){for(var h=a(o,2);h.length()>0;)s.extensions.push({type:[h.getByte(),h.getByte()],data:a(h,2)});if(!n)for(var d=0;d0;){if(0!==p.getByte())break;e.session.extensions.server_name.serverNameList.push(a(p,2).getBytes())}}}if(e.session.version&&(s.version.major!==e.session.version.major||s.version.minor!==e.session.version.minor))return e.error(e,{message:'TLS version change is disallowed during renegotiation.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}});if(n)e.session.cipherSuite=c.getCipherSuite(s.cipher_suite);else for(var f=i.util.createBuffer(s.cipher_suites.bytes());f.length()>0&&(e.session.cipherSuite=c.getCipherSuite(f.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:'No cipher suites in common.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.handshake_failure},cipherSuite:i.util.bytesToHex(s.cipher_suite)});e.session.compressionMethod=n?s.compression_method:c.CompressionMethod.none}return s},c.createSecurityParameters=function(e,t){var i=e.entity===c.ConnectionEnd.client,r=t.random.bytes(),s=i?e.session.sp.client_random:r,n=i?r:c.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:c.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:s,server_random:n}},c.handleServerHello=function(e,t,i){var r=c.parseHelloMessage(e,t,i);if(!e.fail){if(!(r.version.minor<=e.version.minor))return e.error(e,{message:'Incompatible TLS version.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}});e.version.minor=r.version.minor,e.session.version=e.version;var s=r.session_id.bytes();s.length>0&&s===e.session.id?(e.expect=g,e.session.resuming=!0,e.session.sp.server_random=r.random.bytes()):(e.expect=l,e.session.resuming=!1,c.createSecurityParameters(e,r)),e.session.id=s,e.process()}},c.handleClientHello=function(e,t,r){var s=c.parseHelloMessage(e,t,r);if(!e.fail){var n=s.session_id.bytes(),a=null;if(e.sessionCache&&(null===(a=e.sessionCache.getSession(n))?n='':(a.version.major!==s.version.major||a.version.minor>s.version.minor)&&(a=null,n='')),0===n.length&&(n=i.random.getBytes(32)),e.session.id=n,e.session.clientHelloVersion=s.version,e.session.sp={},a)e.version=e.session.version=a.version,e.session.sp=a.sp;else{for(var o,l=1;l0;)s=a(l.certificate_list,3),n=i.asn1.fromDer(s),s=i.pki.certificateFromAsn1(n,!0),d.push(s)}catch(t){return e.error(e,{message:'Could not parse certificate list.',cause:t,send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.bad_certificate}})}var u=e.entity===c.ConnectionEnd.client;!u&&!0!==e.verifyClient||0!==d.length?0===d.length?e.expect=u?h:I:(u?e.session.serverCertificate=d[0]:e.session.clientCertificate=d[0],c.verifyCertificateChain(e,d)&&(e.expect=u?h:I)):e.error(e,{message:u?'No server certificate provided.':'No client certificate provided.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}}),e.process()},c.handleServerKeyExchange=function(e,t,i){if(i>0)return e.error(e,{message:'Invalid key parameters. Only RSA is supported.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.unsupported_certificate}});e.expect=d,e.process()},c.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:'Invalid key parameters. Only RSA is supported.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.unsupported_certificate}});var s=t.fragment,n={enc_pre_master_secret:a(s,2).getBytes()},o=null;if(e.getPrivateKey)try{o=e.getPrivateKey(e,e.session.serverCertificate),o=i.pki.privateKeyFromPem(o)}catch(t){e.error(e,{message:'Could not get private key.',cause:t,send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}})}if(null===o)return e.error(e,{message:'No private key set.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}});try{var l=e.session.sp;l.pre_master_secret=o.decrypt(n.enc_pre_master_secret);var h=e.session.clientHelloVersion;if(h.major!==l.pre_master_secret.charCodeAt(0)||h.minor!==l.pre_master_secret.charCodeAt(1))throw new Error('TLS version rollback attack detected.')}catch(e){l.pre_master_secret=i.random.getBytes(48)}e.expect=O,null!==e.session.clientCertificate&&(e.expect=S),e.process()},c.handleCertificateRequest=function(e,t,i){if(i<3)return e.error(e,{message:'Invalid CertificateRequest. Message too short.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var r=t.fragment,s={certificate_types:a(r,1),certificate_authorities:a(r,2)};e.session.certificateRequest=s,e.expect=p,e.process()},c.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:'Invalid CertificateVerify. Message too short.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var s=t.fragment;s.read-=4;var n=s.bytes();s.read+=4;var o={signature:a(s,2).getBytes()},l=i.util.createBuffer();l.putBuffer(e.session.md5.digest()),l.putBuffer(e.session.sha1.digest()),l=l.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(l,o.signature,'NONE'))throw new Error('CertificateVerify signature does not match.');e.session.md5.update(n),e.session.sha1.update(n)}catch(t){return e.error(e,{message:'Bad signature in CertificateVerify.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.handshake_failure}})}e.expect=O,e.process()},c.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:'Invalid ServerHelloDone message. Invalid length.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.record_overflow}});if(null===e.serverCertificate){var s={message:'No server certificate provided. Not enough security.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.insufficient_security}},n=e.verify(e,s.alert.description,0,[]);if(!0!==n)return(n||0===n)&&('object'!=typeof n||i.util.isArray(n)?'number'==typeof n&&(s.alert.description=n):(n.message&&(s.message=n.message),n.alert&&(s.alert.description=n.alert))),e.error(e,s)}null!==e.session.certificateRequest&&(t=c.createRecord(e,{type:c.ContentType.handshake,data:c.createCertificate(e)}),c.queue(e,t)),t=c.createRecord(e,{type:c.ContentType.handshake,data:c.createClientKeyExchange(e)}),c.queue(e,t),e.expect=E;var a=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createCertificateVerify(e,t)})),c.queue(e,c.createRecord(e,{type:c.ContentType.change_cipher_spec,data:c.createChangeCipherSpec()})),e.state.pending=c.createConnectionState(e),e.state.current.write=e.state.pending.write,c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createFinished(e)})),e.expect=g,c.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return a(e,null);c.getClientSignature(e,a)},c.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:'Invalid ChangeCipherSpec message received.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var i=e.entity===c.ConnectionEnd.client;(e.session.resuming&&i||!e.session.resuming&&!i)&&(e.state.pending=c.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&i||e.session.resuming&&!i)&&(e.state.pending=null),e.expect=i?m:N,e.process()},c.handleFinished=function(e,t,s){var n=t.fragment;n.read-=4;var a=n.bytes();n.read+=4;var o=t.fragment.getBytes();(n=i.util.createBuffer()).putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var l=e.entity===c.ConnectionEnd.client,h=l?'server finished':'client finished',d=e.session.sp;if((n=r(d.master_secret,h,n.getBytes(),12)).getBytes()!==o)return e.error(e,{message:'Invalid verify_data in Finished message.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.decrypt_error}});e.session.md5.update(a),e.session.sha1.update(a),(e.session.resuming&&l||!e.session.resuming&&!l)&&(c.queue(e,c.createRecord(e,{type:c.ContentType.change_cipher_spec,data:c.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createFinished(e)}))),e.expect=l?y:P,e.handshaking=!1,++e.handshakes,e.peerCertificate=l?e.session.serverCertificate:e.session.clientCertificate,c.flush(e),e.isConnected=!0,e.connected(e),e.process()},c.handleAlert=function(e,t){var i,r=t.fragment,s={level:r.getByte(),description:r.getByte()};switch(s.description){case c.Alert.Description.close_notify:i='Connection closed.';break;case c.Alert.Description.unexpected_message:i='Unexpected message.';break;case c.Alert.Description.bad_record_mac:i='Bad record MAC.';break;case c.Alert.Description.decryption_failed:i='Decryption failed.';break;case c.Alert.Description.record_overflow:i='Record overflow.';break;case c.Alert.Description.decompression_failure:i='Decompression failed.';break;case c.Alert.Description.handshake_failure:i='Handshake failure.';break;case c.Alert.Description.bad_certificate:i='Bad certificate.';break;case c.Alert.Description.unsupported_certificate:i='Unsupported certificate.';break;case c.Alert.Description.certificate_revoked:i='Certificate revoked.';break;case c.Alert.Description.certificate_expired:i='Certificate expired.';break;case c.Alert.Description.certificate_unknown:i='Certificate unknown.';break;case c.Alert.Description.illegal_parameter:i='Illegal parameter.';break;case c.Alert.Description.unknown_ca:i='Unknown certificate authority.';break;case c.Alert.Description.access_denied:i='Access denied.';break;case c.Alert.Description.decode_error:i='Decode error.';break;case c.Alert.Description.decrypt_error:i='Decrypt error.';break;case c.Alert.Description.export_restriction:i='Export restriction.';break;case c.Alert.Description.protocol_version:i='Unsupported protocol version.';break;case c.Alert.Description.insufficient_security:i='Insufficient security.';break;case c.Alert.Description.internal_error:i='Internal error.';break;case c.Alert.Description.user_canceled:i='User canceled.';break;case c.Alert.Description.no_renegotiation:i='Renegotiation not supported.';break;default:i='Unknown error.'}if(s.description===c.Alert.Description.close_notify)return e.close();e.error(e,{message:i,send:!1,origin:e.entity===c.ConnectionEnd.client?'server':'client',alert:s}),e.process()},c.handleHandshake=function(e,t){var r=t.fragment,s=r.getByte(),n=r.getInt24();if(n>r.length())return e.fragmented=t,t.fragment=i.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var a=r.bytes(n+4);r.read+=4,s in j[e.entity][e.expect]?(e.entity!==c.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:i.md.md5.create(),sha1:i.md.sha1.create()}),s!==c.HandshakeType.hello_request&&s!==c.HandshakeType.certificate_verify&&s!==c.HandshakeType.finished&&(e.session.md5.update(a),e.session.sha1.update(a)),j[e.entity][e.expect][s](e,t,n)):c.handleUnexpected(e,t)},c.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},c.handleHeartbeat=function(e,t){var r=t.fragment,s=r.getByte(),n=r.getInt16(),a=r.getBytes(n);if(s===c.HeartbeatMessageType.heartbeat_request){if(e.handshaking||n>a.length)return e.process();c.queue(e,c.createRecord(e,{type:c.ContentType.heartbeat,data:c.createHeartbeat(c.HeartbeatMessageType.heartbeat_response,a)})),c.flush(e)}else if(s===c.HeartbeatMessageType.heartbeat_response){if(a!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,i.util.createBuffer(a))}e.process()};var l=1,h=2,d=3,p=4,g=5,m=6,y=7,E=8,A=1,I=2,S=3,O=4,N=5,P=6,w=c.handleUnexpected,R=c.handleChangeCipherSpec,B=c.handleAlert,U=c.handleHandshake,D=c.handleApplicationData,k=c.handleHeartbeat,M=[];M[c.ConnectionEnd.client]=[[w,B,U,w,k],[w,B,U,w,k],[w,B,U,w,k],[w,B,U,w,k],[w,B,U,w,k],[R,B,w,w,k],[w,B,U,w,k],[w,B,U,D,k],[w,B,U,w,k]],M[c.ConnectionEnd.server]=[[w,B,U,w,k],[w,B,U,w,k],[w,B,U,w,k],[w,B,U,w,k],[R,B,w,w,k],[w,B,U,w,k],[w,B,U,D,k],[w,B,U,w,k]];var x=c.handleHelloRequest,F=c.handleServerHello,H=c.handleCertificate,V=c.handleServerKeyExchange,W=c.handleCertificateRequest,K=c.handleServerHelloDone,z=c.handleFinished,j=[];j[c.ConnectionEnd.client]=[[w,w,F,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],[x,w,w,w,w,w,w,w,w,w,w,H,V,W,K,w,w,w,w,w,w],[x,w,w,w,w,w,w,w,w,w,w,w,V,W,K,w,w,w,w,w,w],[x,w,w,w,w,w,w,w,w,w,w,w,w,W,K,w,w,w,w,w,w],[x,w,w,w,w,w,w,w,w,w,w,w,w,w,K,w,w,w,w,w,w],[x,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],[x,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,z],[x,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],[x,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w]];var Y=c.handleClientHello,q=c.handleClientKeyExchange,Q=c.handleCertificateVerify;j[c.ConnectionEnd.server]=[[w,Y,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],[w,w,w,w,w,w,w,w,w,w,w,H,w,w,w,w,w,w,w,w,w],[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,q,w,w,w,w],[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,Q,w,w,w,w,w],[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,z],[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w],[w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w,w]],c.generateKeys=function(e,t){var i=r,s=t.client_random+t.server_random;e.session.resuming||(t.master_secret=i(t.pre_master_secret,'master secret',s,48).bytes(),t.pre_master_secret=null),s=t.server_random+t.client_random;var n=2*t.mac_key_length+2*t.enc_key_length,a=e.version.major===c.Versions.TLS_1_0.major&&e.version.minor===c.Versions.TLS_1_0.minor;a&&(n+=2*t.fixed_iv_length);var o=i(t.master_secret,'key expansion',s,n),l={client_write_MAC_key:o.getBytes(t.mac_key_length),server_write_MAC_key:o.getBytes(t.mac_key_length),client_write_key:o.getBytes(t.enc_key_length),server_write_key:o.getBytes(t.enc_key_length)};return a&&(l.client_write_IV=o.getBytes(t.fixed_iv_length),l.server_write_IV=o.getBytes(t.fixed_iv_length)),l},c.createConnectionState=function(e){var t=e.entity===c.ConnectionEnd.client,i=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},r={read:i(),write:i()};if(r.read.update=function(e,t){return r.read.cipherFunction(t,r.read)?r.read.compressFunction(e,t,r.read)||e.error(e,{message:'Could not decompress record.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.decompression_failure}}):e.error(e,{message:'Could not decrypt record or bad MAC.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.bad_record_mac}}),!e.fail},r.write.update=function(e,t){return r.write.compressFunction(e,t,r.write)?r.write.cipherFunction(t,r.write)||e.error(e,{message:'Could not encrypt record.',send:!1,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}}):e.error(e,{message:'Could not compress record.',send:!1,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}}),!e.fail},e.session){var a=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(a),a.keys=c.generateKeys(e,a),r.read.macKey=t?a.keys.server_write_MAC_key:a.keys.client_write_MAC_key,r.write.macKey=t?a.keys.client_write_MAC_key:a.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(r,e,a),a.compression_algorithm){case c.CompressionMethod.none:break;case c.CompressionMethod.deflate:r.read.compressFunction=n,r.write.compressFunction=s;break;default:throw new Error('Unsupported compression algorithm.')}}return r},c.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=i.util.createBuffer();return r.putInt32(t),r.putBytes(i.random.getBytes(28)),r},c.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},c.createAlert=function(e,t){var r=i.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),c.createRecord(e,{type:c.ContentType.alert,data:r})},c.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=i.util.createBuffer(),r=0;r0&&(f+=2);var g=e.session.id,m=g.length+1+2+4+28+2+n+1+l+f,y=i.util.createBuffer();return y.putByte(c.HandshakeType.client_hello),y.putInt24(m),y.putByte(e.version.major),y.putByte(e.version.minor),y.putBytes(e.session.sp.client_random),o(y,1,i.util.createBuffer(g)),o(y,2,t),o(y,1,a),f>0&&o(y,2,h),y},c.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,s=i.util.createBuffer();return s.putByte(c.HandshakeType.server_hello),s.putInt24(r),s.putByte(e.version.major),s.putByte(e.version.minor),s.putBytes(e.session.sp.server_random),o(s,1,i.util.createBuffer(t)),s.putByte(e.session.cipherSuite.id[0]),s.putByte(e.session.cipherSuite.id[1]),s.putByte(e.session.compressionMethod),s},c.createCertificate=function(e){var t,r=e.entity===c.ConnectionEnd.client,s=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,s=e.getCertificate(e,t));var n=i.util.createBuffer();if(null!==s)try{i.util.isArray(s)||(s=[s]);for(var a=null,l=0;lc.MaxFragment;)s.push(c.createRecord(e,{type:t.type,data:i.util.createBuffer(n.slice(0,c.MaxFragment))})),n=n.slice(c.MaxFragment);n.length>0&&s.push(c.createRecord(e,{type:t.type,data:i.util.createBuffer(n)}))}for(var a=0;a0&&(s=r.order[0]),null!==s&&s in r.cache)for(var n in t=r.cache[s],delete r.cache[s],r.order)if(r.order[n]===s){r.order.splice(n,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var s=r.order.shift();delete r.cache[s]}s=i.util.bytesToHex(e);r.order.push(s),r.cache[s]=t}}return r},c.createConnection=function(e){var t=null;t=e.caStore?i.util.isArray(e.caStore)?i.pki.createCaStore(e.caStore):e.caStore:i.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var s in r=[],c.CipherSuites)r.push(c.CipherSuites[s]);var n=e.server?c.ConnectionEnd.server:c.ConnectionEnd.client,a=e.sessionCache?c.createSessionCache(e.sessionCache):null,o={version:{major:c.Version.major,minor:c.Version.minor},entity:n,sessionId:e.sessionId,caStore:t,sessionCache:a,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,i,r){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:i.util.createBuffer(),tlsData:i.util.createBuffer(),data:i.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,i){i.origin=i.origin||(t.entity===c.ConnectionEnd.client?'client':'server'),i.send&&(c.queue(t,c.createAlert(t,i.alert)),c.flush(t));var r=!1!==i.fatal;r&&(t.fail=!0),e.error(t,i),r&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){o.version={major:c.Version.major,minor:c.Version.minor},o.record=null,o.session=null,o.peerCertificate=null,o.state={pending:null,current:null},o.expect=(o.entity,c.ConnectionEnd.client,0),o.fragmented=null,o.records=[],o.open=!1,o.handshakes=0,o.handshaking=!1,o.isConnected=!1,o.fail=!(e||void 0===e),o.input.clear(),o.tlsData.clear(),o.data.clear(),o.state.current=c.createConnectionState(o)}};o.reset();return o.handshake=function(e){if(o.entity!==c.ConnectionEnd.client)o.error(o,{message:'Cannot initiate handshake as a server.',fatal:!1});else if(o.handshaking)o.error(o,{message:'Handshake already in progress.',fatal:!1});else{o.fail&&!o.open&&0===o.handshakes&&(o.fail=!1),o.handshaking=!0;var t=null;(e=e||'').length>0&&(o.sessionCache&&(t=o.sessionCache.getSession(e)),null===t&&(e='')),0===e.length&&o.sessionCache&&null!==(t=o.sessionCache.getSession())&&(e=t.id),o.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:i.md.md5.create(),sha1:i.md.sha1.create()},t&&(o.version=t.version,o.session.sp=t.sp),o.session.sp.client_random=c.createRandom().getBytes(),o.open=!0,c.queue(o,c.createRecord(o,{type:c.ContentType.handshake,data:c.createClientHello(o)})),c.flush(o)}},o.process=function(e){var t,r,s,n,a=0;return e&&o.input.putBytes(e),o.fail||(null!==o.record&&o.record.ready&&o.record.fragment.isEmpty()&&(o.record=null),null===o.record&&(a=function(e){var t=0,r=e.input,s=r.length();if(s<5)t=5-s;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:i.util.createBuffer(),ready:!1};var n=e.record.version.major===e.version.major;n&&e.session&&e.session.version&&(n=e.record.version.minor===e.version.minor),n||e.error(e,{message:'Incompatible TLS version.',send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}})}return t}(o)),o.fail||null===o.record||o.record.ready||(a=function(e){var t=0,i=e.input,r=i.length();return r=r.Versions.TLS_1_1.minor&&c.output.putBytes(s),c.update(e.fragment),c.finish(a)&&(e.fragment=c.output,e.length=e.fragment.length(),n=!0),n}function a(e,t,i){if(!i){var r=e-t.length()%e;t.fillWithByte(r-1,r)}return!0}function o(e,t,i){var r=!0;if(i){for(var s=t.length(),n=t.last(),a=s-1-n;a=c?(e.fragment=a.output.getBytes(h-c),l=a.output.getBytes(c)):e.fragment=a.output.getBytes(),e.fragment=i.util.createBuffer(e.fragment),e.length=e.fragment.length();var d=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),n=function(e,t,r){var s=i.hmac.create();return s.start('SHA1',e),s.update(t),t=s.digest().getBytes(),s.start(null,null),s.update(r),r=s.digest().getBytes(),t===r}(t.macKey,l,d)&&n,n}r.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:'TLS_RSA_WITH_AES_128_CBC_SHA',initSecurityParameters:function(e){e.bulk_cipher_algorithm=r.BulkCipherAlgorithm.aes,e.cipher_type=r.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=r.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:s},r.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:'TLS_RSA_WITH_AES_256_CBC_SHA',initSecurityParameters:function(e){e.bulk_cipher_algorithm=r.BulkCipherAlgorithm.aes,e.cipher_type=r.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=r.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:s}}}),z=d({'node_modules/node-forge/lib/sha512.js'(e,t){var i=u();A(),f();var r=t.exports=i.sha512=i.sha512||{};i.md.sha512=i.md.algorithms.sha512=r;var s=i.sha384=i.sha512.sha384=i.sha512.sha384||{};s.create=function(){return r.create('SHA-384')},i.md.sha384=i.md.algorithms.sha384=s,i.sha512.sha256=i.sha512.sha256||{create:function(){return r.create('SHA-512/256')}},i.md['sha512/256']=i.md.algorithms['sha512/256']=i.sha512.sha256,i.sha512.sha224=i.sha512.sha224||{create:function(){return r.create('SHA-512/224')}},i.md['sha512/224']=i.md.algorithms['sha512/224']=i.sha512.sha224,r.create=function(e){if(a||(n=String.fromCharCode(128),n+=i.util.fillString(String.fromCharCode(0),128),o=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(c={})['SHA-512']=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c['SHA-384']=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c['SHA-512/256']=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c['SHA-512/224']=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),void 0===e&&(e='SHA-512'),!(e in c))throw new Error('Invalid SHA-512 algorithm: '+e);for(var t=c[e],r=null,s=i.util.createBuffer(),h=new Array(80),d=0;d<80;++d)h[d]=new Array(2);var u=64;switch(e){case'SHA-384':u=48;break;case'SHA-512/256':u=32;break;case'SHA-512/224':u=28}var p={algorithm:e.replace('-','').toLowerCase(),blockLength:128,digestLength:u,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){p.messageLength=0,p.fullMessageLength=p.messageLength128=[];for(var e=p.messageLengthSize/4,n=0;n>>0,n>>>0];for(var a=p.fullMessageLength.length-1;a>=0;--a)p.fullMessageLength[a]+=n[1],n[1]=n[0]+(p.fullMessageLength[a]/4294967296>>>0),p.fullMessageLength[a]=p.fullMessageLength[a]>>>0,n[0]=n[1]/4294967296>>>0;return s.putBytes(e),l(r,h,s),(s.read>2048||0===s.length())&&s.compact(),p},p.digest=function(){var t=i.util.createBuffer();t.putBytes(s.bytes());var a,o=p.fullMessageLength[p.fullMessageLength.length-1]+p.messageLengthSize&p.blockLength-1;t.putBytes(n.substr(0,p.blockLength-o));for(var c=8*p.fullMessageLength[0],d=0;d>>0,t.putInt32(c>>>0),c=a>>>0;t.putInt32(c);var u=new Array(r.length);for(d=0;d=128;){for(w=0;w<16;++w)t[w][0]=i.getInt32()>>>0,t[w][1]=i.getInt32()>>>0;for(;w<80;++w)r=(((b=(B=t[w-2])[0])>>>19|(R=B[1])<<13)^(R>>>29|b<<3)^b>>>6)>>>0,s=((b<<13|R>>>19)^(R<<3|b>>>29)^(b<<26|R>>>6))>>>0,n=(((b=(D=t[w-15])[0])>>>1|(R=D[1])<<31)^(b>>>8|R<<24)^b>>>7)>>>0,a=((b<<31|R>>>1)^(b<<24|R>>>8)^(b<<25|R>>>7))>>>0,U=t[w-7],k=t[w-16],R=s+U[1]+a+k[1],t[w][0]=r+U[0]+n+k[0]+(R/4294967296>>>0)>>>0,t[w][1]=R>>>0;for(f=e[0][0],g=e[0][1],m=e[1][0],y=e[1][1],E=e[2][0],_=e[2][1],A=e[3][0],v=e[3][1],T=e[4][0],C=e[4][1],I=e[5][0],S=e[5][1],O=e[6][0],N=e[6][1],L=e[7][0],P=e[7][1],w=0;w<80;++w)h=((T>>>14|C<<18)^(T>>>18|C<<14)^(C>>>9|T<<23))>>>0,d=(O^T&(I^O))>>>0,c=((f>>>28|g<<4)^(g>>>2|f<<30)^(g>>>7|f<<25))>>>0,l=((f<<4|g>>>28)^(g<<30|f>>>2)^(g<<25|f>>>7))>>>0,u=(f&m|E&(f^m))>>>0,p=(g&y|_&(g^y))>>>0,R=P+(((T<<18|C>>>14)^(T<<14|C>>>18)^(C<<23|T>>>9))>>>0)+((N^C&(S^N))>>>0)+o[w][1]+t[w][1],r=L+h+d+o[w][0]+t[w][0]+(R/4294967296>>>0)>>>0,s=R>>>0,n=c+u+((R=l+p)/4294967296>>>0)>>>0,a=R>>>0,L=O,P=N,O=I,N=S,I=T,S=C,T=A+r+((R=v+s)/4294967296>>>0)>>>0,C=R>>>0,A=E,v=_,E=m,_=y,m=f,y=g,f=r+n+((R=s+a)/4294967296>>>0)>>>0,g=R>>>0;R=e[0][1]+g,e[0][0]=e[0][0]+f+(R/4294967296>>>0)>>>0,e[0][1]=R>>>0,R=e[1][1]+y,e[1][0]=e[1][0]+m+(R/4294967296>>>0)>>>0,e[1][1]=R>>>0,R=e[2][1]+_,e[2][0]=e[2][0]+E+(R/4294967296>>>0)>>>0,e[2][1]=R>>>0,R=e[3][1]+v,e[3][0]=e[3][0]+A+(R/4294967296>>>0)>>>0,e[3][1]=R>>>0,R=e[4][1]+C,e[4][0]=e[4][0]+T+(R/4294967296>>>0)>>>0,e[4][1]=R>>>0,R=e[5][1]+S,e[5][0]=e[5][0]+I+(R/4294967296>>>0)>>>0,e[5][1]=R>>>0,R=e[6][1]+N,e[6][0]=e[6][0]+O+(R/4294967296>>>0)>>>0,e[6][1]=R>>>0,R=e[7][1]+P,e[7][0]=e[7][0]+L+(R/4294967296>>>0)>>>0,e[7][1]=R>>>0,M-=128}}}}),j=d({'node_modules/node-forge/lib/asn1-validator.js'(e){var t=u();_();var i=t.asn1;e.privateKeyValidator={name:'PrivateKeyInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'PrivateKeyInfo.version',tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:'privateKeyVersion'},{name:'PrivateKeyInfo.privateKeyAlgorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'privateKeyOid'}]},{name:'PrivateKeyInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:'privateKey'}]},e.publicKeyValidator={name:'SubjectPublicKeyInfo',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:'subjectPublicKeyInfo',value:[{name:'SubjectPublicKeyInfo.AlgorithmIdentifier',tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:'AlgorithmIdentifier.algorithm',tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:'publicKeyOid'}]},{tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:'ed25519PublicKey'}]}}}),Y=d({'node_modules/node-forge/lib/ed25519.js'(e,t){var i=u();w(),L(),z(),f();var r,s=j(),n=s.publicKeyValidator,a=s.privateKeyValidator;void 0===r&&(r=i.jsbn.BigInteger);var o=i.util.ByteBuffer,c='undefined'==typeof Buffer?Uint8Array:Buffer;i.pki=i.pki||{},t.exports=i.pki.ed25519=i.ed25519=i.ed25519||{};var l=i.ed25519;function h(e){var t=e.message;if(t instanceof Uint8Array||t instanceof c)return t;var i=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),i='binary'}if('string'==typeof t&&!i)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if('string'==typeof t){if('undefined'!=typeof Buffer)return Buffer.from(t,i);t=new o(t,i)}else if(!(t instanceof o))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var r=new c(t.length()),s=0;s=0;--i)V(r,r),1!==i&&G(r,r,t);for(i=0;i<16;++i)e[i]=r[i]}(i,i),G(i,i,s),G(i,i,n),G(i,i,n),G(e[0],i,n),V(r,e[0]),G(r,r,n),P(r,s)&&G(e[0],e[0],A);if(V(r,e[0]),G(r,r,n),P(r,s))return-1;R(e[0])===t[31]>>7&&H(e[0],d,e[0]);return G(e[3],e[0],e[1]),0}(o,r))return-1;for(s=0;s=0};var d=x(),p=x([1]),g=x([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),m=x([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),y=x([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),E=x([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),_=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]),A=x([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function v(e,t){var r=i.md.sha512.create(),s=new o(e);r.update(s.getBytes(t),'binary');var n=r.digest().getBytes();if('undefined'!=typeof Buffer)return Buffer.from(n,'binary');for(var a=new c(l.constants.HASH_BYTE_LENGTH),h=0;h<64;++h)a[h]=n.charCodeAt(h);return a}function T(e,t){var i,r,s,n;for(r=63;r>=32;--r){for(i=0,s=r-32,n=r-12;s>8,t[s]-=256*i;t[s]+=i,t[r]=0}for(i=0,s=0;s<32;++s)t[s]+=i-(t[31]>>4)*_[s],i=t[s]>>8,t[s]&=255;for(s=0;s<32;++s)t[s]-=i*_[s];for(r=0;r<32;++r)t[r+1]+=t[r]>>8,e[r]=255&t[r]}function C(e){for(var t=new Float64Array(64),i=0;i<64;++i)t[i]=e[i],e[i]=0;T(e,t)}function I(e,t){var i=x(),r=x(),s=x(),n=x(),a=x(),o=x(),c=x(),l=x(),h=x();H(i,e[1],e[0]),H(h,t[1],t[0]),G(i,i,h),F(r,e[0],e[1]),F(h,t[0],t[1]),G(r,r,h),G(s,e[3],t[3]),G(s,s,m),G(n,e[2],t[2]),F(n,n,n),H(a,r,i),H(o,n,s),F(c,n,s),F(l,r,i),G(e[0],a,o),G(e[1],l,c),G(e[2],c,o),G(e[3],a,l)}function S(e,t,i){for(var r=0;r<4;++r)M(e[r],t[r],i)}function O(e,t){var i=x(),r=x(),s=x();!function(e,t){var i,r=x();for(i=0;i<16;++i)r[i]=t[i];for(i=253;i>=0;--i)V(r,r),2!==i&&4!==i&&G(r,r,t);for(i=0;i<16;++i)e[i]=r[i]}(s,t[2]),G(i,t[0],s),G(r,t[1],s),N(e,r),e[31]^=R(i)<<7}function N(e,t){var i,r,s,n=x(),a=x();for(i=0;i<16;++i)a[i]=t[i];for(k(a),k(a),k(a),r=0;r<2;++r){for(n[0]=a[0]-65517,i=1;i<15;++i)n[i]=a[i]-65535-(n[i-1]>>16&1),n[i-1]&=65535;n[15]=a[15]-32767-(n[14]>>16&1),s=n[15]>>16&1,n[14]&=65535,M(a,n,1-s)}for(i=0;i<16;i++)e[2*i]=255&a[i],e[2*i+1]=a[i]>>8}function P(e,t){var i=new c(32),r=new c(32);return N(i,e),N(r,t),b(i,0,r,0)}function b(e,t,i,r){return function(e,t,i,r,s){var n,a=0;for(n=0;n>>8)-1}(e,t,i,r,32)}function R(e){var t=new c(32);return N(t,e),1&t[0]}function B(e,t,i){var r,s;for(D(e[0],d),D(e[1],p),D(e[2],p),D(e[3],d),s=255;s>=0;--s)S(e,t,r=i[s/8|0]>>(7&s)&1),I(t,e),I(e,e),S(e,t,r)}function U(e,t){var i=[x(),x(),x(),x()];D(i[0],y),D(i[1],E),D(i[2],p),G(i[3],y,E),B(e,i,t)}function D(e,t){var i;for(i=0;i<16;i++)e[i]=0|t[i]}function k(e){var t,i,r=1;for(t=0;t<16;++t)i=e[t]+r+65535,r=Math.floor(i/65536),e[t]=i-65536*r;e[0]+=r-1+37*(r-1)}function M(e,t,i){for(var r,s=~(i-1),n=0;n<16;++n)r=s&(e[n]^t[n]),e[n]^=r,t[n]^=r}function x(e){var t,i=new Float64Array(16);if(e)for(t=0;t0&&(a=i.util.fillString(String.fromCharCode(0),c)+a),{encapsulation:t.encrypt(a,'NONE'),key:e.generate(a,n)}},decrypt:function(t,i,r){var s=t.decrypt(i,'NONE');return e.generate(s,r)}};return n},i.kem.kdf1=function(e,t){s(this,e,0,t||e.digestLength)},i.kem.kdf2=function(e,t){s(this,e,1,t||e.digestLength)}}}),Q=d({'node_modules/node-forge/lib/log.js'(e,t){var i=u();f(),t.exports=i.log=i.log||{},i.log.levels=['none','error','warning','info','debug','verbose','max'];var r,s,n,a,o,c,l,h={},d=[],p=null;for(i.log.LEVEL_LOCKED=2,i.log.NO_LEVEL_CHECK=4,i.log.INTERPOLATE=8,n=0;n0){for(var s=r.create(r.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n=s&&a0&&a.value[0].value.push(r.create(r.Class.CONTEXT_SPECIFIC,0,!0,t)),n.length>0&&a.value[0].value.push(r.create(r.Class.CONTEXT_SPECIFIC,1,!0,n)),a.value[0].value.push(r.create(r.Class.UNIVERSAL,r.Type.SET,!0,e.signerInfos)),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(e.type).getBytes()),a])},addSigner:function(t){var r=t.issuer,s=t.serialNumber;if(t.certificate){var n=t.certificate;'string'==typeof n&&(n=i.pki.certificateFromPem(n)),r=n.issuer.attributes,s=n.serialNumber}var a=t.key;if(!a)throw new Error('Could not add PKCS#7 signer; no private key specified.');'string'==typeof a&&(a=i.pki.privateKeyFromPem(a));var o=t.digestAlgorithm||i.pki.oids.sha1;switch(o){case i.pki.oids.sha1:case i.pki.oids.sha256:case i.pki.oids.sha384:case i.pki.oids.sha512:case i.pki.oids.md5:break;default:throw new Error('Could not add PKCS#7 signer; unknown message digest algorithm: '+o)}var c=t.authenticatedAttributes||[];if(c.length>0){for(var l=!1,h=!1,d=0;d='8'&&(r='00'+r);var s=i.util.hexToBytes(r);e.putInt32(s.length),e.putBytes(s)}function n(e,t){e.putInt32(t.length),e.putString(t)}function a(){for(var e=i.md.sha1.create(),t=arguments.length,r=0;r{for(var i in t)n(e,i,{get:t[i],enumerable:!0})})(ee,{jingles:()=>i,maps:()=>e,serverMaps:()=>r,songs:()=>t});var te,ie,re,se,ne,ae,oe=(te={'src/lostcity/server/PreloadedDirs.ts'(){e=['l29_75','l30_75','l31_75','l32_70','l32_71','l32_72','l32_73','l32_74','l32_75','l33_70','l33_71','l33_72','l33_73','l33_74','l33_75','l33_76','l34_70','l34_71','l34_72','l34_73','l34_74','l34_75','l34_76','l35_20','l35_75','l35_76','l36_146','l36_147','l36_148','l36_149','l36_150','l36_153','l36_154','l36_52','l36_53','l36_54','l36_72','l36_73','l36_74','l36_75','l36_76','l37_146','l37_147','l37_148','l37_149','l37_150','l37_151','l37_152','l37_153','l37_154','l37_48','l37_49','l37_50','l37_51','l37_52','l37_53','l37_54','l37_55','l37_72','l37_73','l37_74','l37_75','l38_146','l38_147','l38_148','l38_149','l38_150','l38_151','l38_152','l38_153','l38_154','l38_155','l38_45','l38_46','l38_47','l38_48','l38_49','l38_50','l38_51','l38_52','l38_53','l38_54','l38_55','l38_72','l38_73','l38_74','l39_147','l39_148','l39_149','l39_150','l39_151','l39_152','l39_153','l39_154','l39_155','l39_45','l39_46','l39_47','l39_48','l39_49','l39_50','l39_51','l39_52','l39_53','l39_54','l39_55','l39_72','l39_73','l39_74','l39_75','l39_76','l40_147','l40_148','l40_149','l40_150','l40_151','l40_152','l40_153','l40_154','l40_45','l40_46','l40_47','l40_48','l40_49','l40_50','l40_51','l40_52','l40_53','l40_54','l40_55','l40_72','l40_73','l40_74','l40_75','l40_76','l41_146','l41_149','l41_151','l41_152','l41_153','l41_154','l41_45','l41_46','l41_47','l41_48','l41_49','l41_50','l41_51','l41_52','l41_53','l41_54','l41_55','l41_56','l41_72','l41_73','l41_74','l41_75','l42_144','l42_145','l42_146','l42_151','l42_152','l42_153','l42_49','l42_50','l42_51','l42_52','l42_53','l42_54','l42_55','l42_56','l42_72','l42_73','l42_74','l42_75','l43_144','l43_145','l43_146','l43_153','l43_154','l43_45','l43_46','l43_47','l43_48','l43_49','l43_50','l43_51','l43_52','l43_53','l43_54','l43_55','l43_56','l43_72','l43_73','l43_74','l43_75','l44_144','l44_145','l44_146','l44_148','l44_149','l44_150','l44_151','l44_152','l44_153','l44_154','l44_155','l44_45','l44_46','l44_47','l44_48','l44_49','l44_50','l44_51','l44_52','l44_53','l44_54','l44_55','l44_72','l44_73','l44_74','l44_75','l45_145','l45_146','l45_148','l45_150','l45_151','l45_152','l45_153','l45_154','l45_155','l45_45','l45_46','l45_47','l45_48','l45_49','l45_50','l45_51','l45_52','l45_53','l45_54','l45_55','l45_56','l45_57','l45_58','l45_59','l45_60','l45_61','l45_62','l45_73','l45_74','l45_75','l45_76','l46_149','l46_150','l46_152','l46_153','l46_154','l46_161','l46_45','l46_46','l46_47','l46_48','l46_49','l46_50','l46_51','l46_52','l46_53','l46_54','l46_55','l46_56','l46_57','l46_58','l46_59','l46_60','l46_61','l46_62','l46_75','l47_148','l47_149','l47_150','l47_152','l47_153','l47_160','l47_161','l47_47','l47_48','l47_49','l47_50','l47_51','l47_52','l47_53','l47_54','l47_55','l47_56','l47_57','l47_58','l47_59','l47_60','l47_61','l47_62','l47_75','l48_148','l48_149','l48_152','l48_153','l48_154','l48_155','l48_156','l48_47','l48_48','l48_49','l48_50','l48_51','l48_52','l48_53','l48_54','l48_55','l48_56','l48_57','l48_58','l48_59','l48_60','l48_61','l48_62','l49_148','l49_149','l49_153','l49_154','l49_155','l49_156','l49_46','l49_47','l49_48','l49_49','l49_50','l49_51','l49_52','l49_53','l49_54','l49_55','l49_56','l49_57','l49_58','l49_59','l49_60','l49_61','l49_62','l50_149','l50_150','l50_152','l50_153','l50_154','l50_46','l50_47','l50_48','l50_49','l50_50','l50_51','l50_52','l50_53','l50_54','l50_55','l50_56','l50_57','l50_58','l50_59','l50_60','l50_61','l50_62','l51_147','l51_154','l51_46','l51_47','l51_48','l51_49','l51_50','l51_51','l51_52','l51_53','l51_54','l51_55','l51_56','l51_57','l51_58','l51_59','l51_60','l51_61','l51_62','l52_152','l52_153','l52_154','l52_46','l52_47','l52_48','l52_49','l52_50','l52_51','l52_52','l52_53','l52_54','l52_55','l52_56','l52_57','l52_58','l52_59','l52_60','l52_61','l52_62','l53_49','l53_50','l53_51','l53_52','l53_53','m29_75','m30_75','m31_75','m32_70','m32_71','m32_72','m32_73','m32_74','m32_75','m33_70','m33_71','m33_72','m33_73','m33_74','m33_75','m33_76','m34_70','m34_71','m34_72','m34_73','m34_74','m34_75','m34_76','m35_20','m35_75','m35_76','m36_146','m36_147','m36_148','m36_149','m36_150','m36_153','m36_154','m36_52','m36_53','m36_54','m36_72','m36_73','m36_74','m36_75','m36_76','m37_146','m37_147','m37_148','m37_149','m37_150','m37_151','m37_152','m37_153','m37_154','m37_48','m37_49','m37_50','m37_51','m37_52','m37_53','m37_54','m37_55','m37_72','m37_73','m37_74','m37_75','m38_146','m38_147','m38_148','m38_149','m38_150','m38_151','m38_152','m38_153','m38_154','m38_155','m38_45','m38_46','m38_47','m38_48','m38_49','m38_50','m38_51','m38_52','m38_53','m38_54','m38_55','m38_72','m38_73','m38_74','m39_147','m39_148','m39_149','m39_150','m39_151','m39_152','m39_153','m39_154','m39_155','m39_45','m39_46','m39_47','m39_48','m39_49','m39_50','m39_51','m39_52','m39_53','m39_54','m39_55','m39_72','m39_73','m39_74','m39_75','m39_76','m40_147','m40_148','m40_149','m40_150','m40_151','m40_152','m40_153','m40_154','m40_45','m40_46','m40_47','m40_48','m40_49','m40_50','m40_51','m40_52','m40_53','m40_54','m40_55','m40_72','m40_73','m40_74','m40_75','m40_76','m41_146','m41_149','m41_151','m41_152','m41_153','m41_154','m41_45','m41_46','m41_47','m41_48','m41_49','m41_50','m41_51','m41_52','m41_53','m41_54','m41_55','m41_56','m41_72','m41_73','m41_74','m41_75','m42_144','m42_145','m42_146','m42_151','m42_152','m42_153','m42_49','m42_50','m42_51','m42_52','m42_53','m42_54','m42_55','m42_56','m42_72','m42_73','m42_74','m42_75','m43_144','m43_145','m43_146','m43_153','m43_154','m43_45','m43_46','m43_47','m43_48','m43_49','m43_50','m43_51','m43_52','m43_53','m43_54','m43_55','m43_56','m43_72','m43_73','m43_74','m43_75','m44_144','m44_145','m44_146','m44_148','m44_149','m44_150','m44_151','m44_152','m44_153','m44_154','m44_155','m44_45','m44_46','m44_47','m44_48','m44_49','m44_50','m44_51','m44_52','m44_53','m44_54','m44_55','m44_72','m44_73','m44_74','m44_75','m45_145','m45_146','m45_148','m45_150','m45_151','m45_152','m45_153','m45_154','m45_155','m45_45','m45_46','m45_47','m45_48','m45_49','m45_50','m45_51','m45_52','m45_53','m45_54','m45_55','m45_56','m45_57','m45_58','m45_59','m45_60','m45_61','m45_62','m45_73','m45_74','m45_75','m45_76','m46_149','m46_150','m46_152','m46_153','m46_154','m46_161','m46_45','m46_46','m46_47','m46_48','m46_49','m46_50','m46_51','m46_52','m46_53','m46_54','m46_55','m46_56','m46_57','m46_58','m46_59','m46_60','m46_61','m46_62','m46_75','m47_148','m47_149','m47_150','m47_152','m47_153','m47_160','m47_161','m47_47','m47_48','m47_49','m47_50','m47_51','m47_52','m47_53','m47_54','m47_55','m47_56','m47_57','m47_58','m47_59','m47_60','m47_61','m47_62','m47_75','m48_148','m48_149','m48_152','m48_153','m48_154','m48_155','m48_156','m48_47','m48_48','m48_49','m48_50','m48_51','m48_52','m48_53','m48_54','m48_55','m48_56','m48_57','m48_58','m48_59','m48_60','m48_61','m48_62','m49_148','m49_149','m49_153','m49_154','m49_155','m49_156','m49_46','m49_47','m49_48','m49_49','m49_50','m49_51','m49_52','m49_53','m49_54','m49_55','m49_56','m49_57','m49_58','m49_59','m49_60','m49_61','m49_62','m50_149','m50_150','m50_152','m50_153','m50_154','m50_46','m50_47','m50_48','m50_49','m50_50','m50_51','m50_52','m50_53','m50_54','m50_55','m50_56','m50_57','m50_58','m50_59','m50_60','m50_61','m50_62','m51_147','m51_154','m51_46','m51_47','m51_48','m51_49','m51_50','m51_51','m51_52','m51_53','m51_54','m51_55','m51_56','m51_57','m51_58','m51_59','m51_60','m51_61','m51_62','m52_152','m52_153','m52_154','m52_46','m52_47','m52_48','m52_49','m52_50','m52_51','m52_52','m52_53','m52_54','m52_55','m52_56','m52_57','m52_58','m52_59','m52_60','m52_61','m52_62','m53_49','m53_50','m53_51','m53_52','m53_53'],t=['adventure.mid','al_kharid.mid','alone.mid','ambience_2.mid','ambience_3.mid','ambience_4.mid','ambient_jungle.mid','arabian.mid','arabian2.mid','arabian3.mid','arabique.mid','army_of_darkness.mid','arrival.mid','attack1.mid','attack2.mid','attack3.mid','attack4.mid','attack5.mid','attack6.mid','attention.mid','autumn_voyage.mid','background2.mid','ballad_of_enchantment.mid','baroque.mid','beyond.mid','big_chords.mid','book_of_spells.mid','camelot.mid','cave_background1.mid','cavern.mid','cellar_song1.mid','chain_of_command.mid','chompy_hunt.mid','close_quarters.mid','crystal_cave.mid','crystal_sword.mid','cursed.mid','dangerous.mid','dark2.mid','deep_wildy.mid','desert_voyage.mid','doorways.mid','dream1.mid','duel_arena.mid','dunjun.mid','egypt.mid','emotion.mid','emperor.mid','escape.mid','expanse.mid','expecting.mid','expedition.mid','fade_test.mid','faerie.mid','fanfare.mid','fanfare2.mid','fanfare3.mid','fishing.mid','flute_salad.mid','forbidden.mid','forever.mid','game_intro_1.mid','gaol.mid','garden.mid','gnome.mid','gnome_king.mid','gnome_theme.mid','gnome_village.mid','gnome_village2.mid','gnomeball.mid','greatness.mid','grumpy.mid','harmony.mid','harmony2.mid','heart_and_mind.mid','high_seas.mid','horizon.mid','iban.mid','ice_melody.mid','in_the_manor.mid','inspiration.mid','intrepid.mid','jolly-r.mid','jungle_island.mid','jungly1.mid','jungly2.mid','jungly3.mid','knightly.mid','landlubber.mid','lasting.mid','legion.mid','lightness.mid','lightwalk.mid','lonesome.mid','long_ago.mid','long_way_home.mid','lullaby.mid','mage_arena.mid','magic_dance.mid','magical_journey.mid','march2.mid','medieval.mid','mellow.mid','miles_away.mid','miracle_dance.mid','monarch_waltz.mid','moody.mid','neverland.mid','newbie_melody.mid','nightfall.mid','nomad.mid','null.mid','organ_music_1.mid','organ_music_2.mid','oriental.mid','overture.mid','parade.mid','quest.mid','regal2.mid','reggae.mid','reggae2.mid','riverside.mid','royale.mid','rune_essence.mid','sad_meadow.mid','scape_cave.mid','scape_main.mid','scape_sad1.mid','scape_soft.mid','scape_wild1.mid','sea_shanty.mid','sea_shanty2.mid','serenade.mid','serene.mid','shine.mid','shining.mid','silence.mid','soundscape.mid','spirit.mid','splendour.mid','spooky2.mid','spooky_jungle.mid','starlight.mid','start.mid','still_night.mid','talking_forest.mid','the_desert.mid','the_shadow.mid','the_tower.mid','theme.mid','tomorrow.mid','trawler.mid','trawler_minor.mid','tree_spirits.mid','tribal.mid','tribal2.mid','tribal_background.mid','trinity.mid','troubled.mid','undercurrent.mid','underground.mid','understanding.mid','unknown_land.mid','upass1.mid','upcoming.mid','venture.mid','venture2.mid','vision.mid','voodoo_cult.mid','voyage.mid','wander.mid','waterfall.mid','wilderness2.mid','wilderness3.mid','wilderness4.mid','witching.mid','wolf_mountain.mid','wonder.mid','wonderous.mid','workshop.mid','yesteryear.mid','zealot.mid'],i=['advance agility.mid','advance attack.mid','advance attack2.mid','advance cooking.mid','advance cooking2.mid','advance crafting.mid','advance crafting2.mid','advance defense.mid','advance defense2.mid','advance firemarking.mid','advance firemarking2.mid','advance fishing.mid','advance fishing2.mid','advance fletching.mid','advance fletching2.mid','advance herblaw.mid','advance herblaw2.mid','advance hitpoints.mid','advance hitpoints2.mid','advance magic.mid','advance magic2.mid','advance mining.mid','advance mining2.mid','advance prayer.mid','advance prayer2.mid','advance ranged.mid','advance ranged2.mid','advance runecraft.mid','advance runecraft2.mid','advance smithing.mid','advance smithing2.mid','advance strength.mid','advance strength2.mid','advance thieving.mid','advance thieving2.mid','advance woodcutting.mid','advance woodcutting2.mid','death.mid','death2.mid','dice lose.mid','dice win.mid','duel start.mid','duel win2.mid','quest complete 1.mid','quest complete 2.mid','quest complete 3.mid','sailing journey.mid','treasure hunt win.mid'],r=['m29_75','m30_75','m31_75','m32_70','m32_71','m32_72','m32_73','m32_74','m32_75','m33_70','m33_71','m33_72','m33_73','m33_74','m33_75','m33_76','m34_70','m34_71','m34_72','m34_73','m34_74','m34_75','m34_76','m35_20','m35_75','m35_76','m36_146','m36_147','m36_148','m36_149','m36_150','m36_153','m36_154','m36_52','m36_53','m36_54','m36_72','m36_73','m36_74','m36_75','m36_76','m37_146','m37_147','m37_148','m37_149','m37_150','m37_151','m37_152','m37_153','m37_154','m37_48','m37_49','m37_50','m37_51','m37_52','m37_53','m37_54','m37_55','m37_72','m37_73','m37_74','m37_75','m38_146','m38_147','m38_148','m38_149','m38_150','m38_151','m38_152','m38_153','m38_154','m38_155','m38_45','m38_46','m38_47','m38_48','m38_49','m38_50','m38_51','m38_52','m38_53','m38_54','m38_55','m38_72','m38_73','m38_74','m39_147','m39_148','m39_149','m39_150','m39_151','m39_152','m39_153','m39_154','m39_155','m39_45','m39_46','m39_47','m39_48','m39_49','m39_50','m39_51','m39_52','m39_53','m39_54','m39_55','m39_72','m39_73','m39_74','m39_75','m39_76','m40_147','m40_148','m40_149','m40_150','m40_151','m40_152','m40_153','m40_154','m40_45','m40_46','m40_47','m40_48','m40_49','m40_50','m40_51','m40_52','m40_53','m40_54','m40_55','m40_72','m40_73','m40_74','m40_75','m40_76','m41_146','m41_149','m41_151','m41_152','m41_153','m41_154','m41_45','m41_46','m41_47','m41_48','m41_49','m41_50','m41_51','m41_52','m41_53','m41_54','m41_55','m41_56','m41_72','m41_73','m41_74','m41_75','m42_144','m42_145','m42_146','m42_151','m42_152','m42_153','m42_49','m42_50','m42_51','m42_52','m42_53','m42_54','m42_55','m42_56','m42_72','m42_73','m42_74','m42_75','m43_144','m43_145','m43_146','m43_153','m43_154','m43_45','m43_46','m43_47','m43_48','m43_49','m43_50','m43_51','m43_52','m43_53','m43_54','m43_55','m43_56','m43_72','m43_73','m43_74','m43_75','m44_144','m44_145','m44_146','m44_148','m44_149','m44_150','m44_151','m44_152','m44_153','m44_154','m44_155','m44_45','m44_46','m44_47','m44_48','m44_49','m44_50','m44_51','m44_52','m44_53','m44_54','m44_55','m44_72','m44_73','m44_74','m44_75','m45_145','m45_146','m45_148','m45_150','m45_151','m45_152','m45_153','m45_154','m45_155','m45_45','m45_46','m45_47','m45_48','m45_49','m45_50','m45_51','m45_52','m45_53','m45_54','m45_55','m45_56','m45_57','m45_58','m45_59','m45_60','m45_61','m45_62','m45_73','m45_74','m45_75','m45_76','m46_149','m46_150','m46_152','m46_153','m46_154','m46_161','m46_45','m46_46','m46_47','m46_48','m46_49','m46_50','m46_51','m46_52','m46_53','m46_54','m46_55','m46_56','m46_57','m46_58','m46_59','m46_60','m46_61','m46_62','m46_75','m47_148','m47_149','m47_150','m47_152','m47_153','m47_160','m47_161','m47_47','m47_48','m47_49','m47_50','m47_51','m47_52','m47_53','m47_54','m47_55','m47_56','m47_57','m47_58','m47_59','m47_60','m47_61','m47_62','m47_75','m48_148','m48_149','m48_152','m48_153','m48_154','m48_155','m48_156','m48_47','m48_48','m48_49','m48_50','m48_51','m48_52','m48_53','m48_54','m48_55','m48_56','m48_57','m48_58','m48_59','m48_60','m48_61','m48_62','m49_148','m49_149','m49_153','m49_154','m49_155','m49_156','m49_46','m49_47','m49_48','m49_49','m49_50','m49_51','m49_52','m49_53','m49_54','m49_55','m49_56','m49_57','m49_58','m49_59','m49_60','m49_61','m49_62','m50_149','m50_150','m50_152','m50_153','m50_154','m50_46','m50_47','m50_48','m50_49','m50_50','m50_51','m50_52','m50_53','m50_54','m50_55','m50_56','m50_57','m50_58','m50_59','m50_60','m50_61','m50_62','m51_147','m51_154','m51_46','m51_47','m51_48','m51_49','m51_50','m51_51','m51_52','m51_53','m51_54','m51_55','m51_56','m51_57','m51_58','m51_59','m51_60','m51_61','m51_62','m52_152','m52_153','m52_154','m52_46','m52_47','m52_48','m52_49','m52_50','m52_51','m52_52','m52_53','m52_54','m52_55','m52_56','m52_57','m52_58','m52_59','m52_60','m52_61','m52_62','m53_49','m53_50','m53_51','m53_52','m53_53']}},function(){return te&&(ie=(0,te[o(te)[0]])(te=0)),ie}),ce=!0;'undefined'!=typeof process&&(({FORCE_COLOR:re,NODE_DISABLE_COLORS:se,NO_COLOR:ne,TERM:ae}=process.env||{}),ce=process.stdout&&process.stdout.isTTY);var le={enabled:!se&&null==ne&&'dumb'!==ae&&(null!=re&&'0'!==re||ce),reset:de(0,0),bold:de(1,22),dim:de(2,22),italic:de(3,23),underline:de(4,24),inverse:de(7,27),hidden:de(8,28),strikethrough:de(9,29),black:de(30,39),red:de(31,39),green:de(32,39),yellow:de(33,39),blue:de(34,39),magenta:de(35,39),cyan:de(36,39),white:de(37,39),gray:de(90,39),grey:de(90,39),bgBlack:de(40,49),bgRed:de(41,49),bgGreen:de(42,49),bgYellow:de(43,49),bgBlue:de(44,49),bgMagenta:de(45,49),bgCyan:de(46,49),bgWhite:de(47,49)};function he(e,t){let i,r=0,s='',n='';for(;r=65&&r<=90?t+=BigInt(r+1-65):r>=97&&r<=122?t+=BigInt(r+1-97):r>=48&&r<=57&&(t+=BigInt(r+27-48))}return t}var fe=['_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9'];function ge(e){if(e<0n||e>=6582952005840035281n)return'invalid_name';if(e%37n===0n)return'invalid_name';let t=0;const i=Array(12);for(;0n!==e;){const r=e;e/=37n,i[11-t++]=fe[Number(r-37n*e)]}return i.slice(12-t).join('')}function me(e){return t=function(e){return ge(pe(e))}(e).replaceAll('_',' '),t.replace(/\w\S*/g,(e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()));var t}var ye,Ee,_e,Ae,ve=(ye=J(),Ee=1,_e=null!=ye?s(c(ye)):{},((e,t,i,r)=>{if(t&&'object'==typeof t||'function'==typeof t)for(let s of o(t))l.call(e,s)||s===i||n(e,s,{get:()=>t[s],enumerable:!(r=a(t,s))||r.enumerable});return e})(!Ee&&ye&&ye.__esModule?_e:n(_e,'default',{value:ye,enumerable:!0}),ye)),Te=class{key;next;prev;constructor(){this.key=0n,this.next=this,this.prev=this}unlink(){this.prev&&this.next&&(this.prev.next=this.next,this.next.prev=this.prev,this.next=null,this.prev=null)}},Ce=class{sentinel;cursor=null;constructor(){const e=new Te;e.next=e,e.prev=e,this.sentinel=e}addTail(e){e.prev&&e.unlink(),e.prev=this.sentinel.prev,e.next=this.sentinel,e.prev&&(e.prev.next=e),e.next.prev=e}addHead(e){e.prev&&e.unlink(),e.prev=this.sentinel,e.next=this.sentinel.next,e.prev.next=e,e.next&&(e.next.prev=e)}removeHead(){const e=this.sentinel.next;return e===this.sentinel?null:(e?.unlink(),e)}head(){const e=this.sentinel.next;return e===this.sentinel?(this.cursor=null,null):(this.cursor=e?.next||null,e)}tail(){const e=this.sentinel.prev;return e===this.sentinel?(this.cursor=null,null):(this.cursor=e?.prev||null,e)}next(){const e=this.cursor;return e===this.sentinel?(this.cursor=null,null):(this.cursor=e?.next||null,e)}prev(){const e=this.cursor;return e===this.sentinel?(this.cursor=null,null):(this.cursor=e?.prev||null,e)}clear(){for(;;){const e=this.sentinel.next;if(e===this.sentinel)return;e?.unlink()}}},Ie=class extends Te{nextHashable;prevHashable;constructor(){super(),this.nextHashable=this,this.prevHashable=this}uncache(){this.prevHashable&&this.nextHashable&&(this.prevHashable.nextHashable=this.nextHashable,this.nextHashable.prevHashable=this.prevHashable,this.nextHashable=null,this.prevHashable=null)}},Se=ve.default.jsbn.BigInteger,Oe=class e extends Ie{static crctable=new Int32Array(256);static bitmask=new Uint32Array(33);static crc32b=3988292384;static{for(let e=0;e<32;e++)this.bitmask[e]=(1<>>=1:t=t>>>1^this.crc32b;this.crctable[e]=t}}static getcrc(e,t,i){let r=4294967295;for(let s=t;s>>8^this.crctable[255&(r^e[s])];return~r}static checkcrc(t,i,r,s=0){return e.getcrc(t,i,r)==s}static alloc(t){let i=null;return 0===t&&this.cacheMinCount>0?(i=this.cacheMin.removeHead(),this.cacheMinCount--):1===t&&this.cacheMidCount>0?(i=this.cacheMid.removeHead(),this.cacheMidCount--):2===t&&this.cacheMaxCount>0?(i=this.cacheMax.removeHead(),this.cacheMaxCount--):3===t&&this.cacheBigCount>0?(i=this.cacheBig.removeHead(),this.cacheBigCount--):4===t&&this.cacheHugeCount>0?(i=this.cacheHuge.removeHead(),this.cacheHugeCount--):5===t&&this.cacheUnimaginableCount>0&&(i=this.cacheUnimaginable.removeHead(),this.cacheUnimaginableCount--),null!==i?(i.pos=0,i.bitPos=0,i):new e(0===t?new Uint8Array(100):1===t?new Uint8Array(5e3):2===t?new Uint8Array(3e4):3===t?new Uint8Array(1e5):4===t?new Uint8Array(5e5):5===t?new Uint8Array(2e6):new Uint8Array(t))}static load(t,i=!1){const r=new e(new Uint8Array(fs.readFileSync(t)));return i&&(r.pos=r.data.length),r}static async loadAsync(t,i=!1){const r=new e(new Uint8Array(await(await fetch(t)).arrayBuffer()));return i&&(r.pos=r.data.length),r}static cacheMinCount=0;static cacheMidCount=0;static cacheMaxCount=0;static cacheBigCount=0;static cacheHugeCount=0;static cacheUnimaginableCount=0;static cacheMin=new Ce;static cacheMid=new Ce;static cacheMax=new Ce;static cacheBig=new Ce;static cacheHuge=new Ce;static cacheUnimaginable=new Ce;data;#e;pos;bitPos;constructor(e){super(),this.data=e,this.#e=new DataView(this.data.buffer),this.pos=0,this.bitPos=0}get available(){return this.data.length-this.pos}get length(){return this.data.length}release(){this.pos=0,this.bitPos=0,100===this.data.length&&e.cacheMinCount<1e3?(e.cacheMin.addTail(this),e.cacheMinCount++):5e3===this.data.length&&e.cacheMidCount<250?(e.cacheMid.addTail(this),e.cacheMidCount++):3e4===this.data.length&&e.cacheMaxCount<50?(e.cacheMax.addTail(this),e.cacheMaxCount++):1e5===this.data.length&&e.cacheBigCount<10?(e.cacheBig.addTail(this),e.cacheBigCount++):5e5===this.data.length&&e.cacheHugeCount<5?(e.cacheHuge.addTail(this),e.cacheHugeCount++):2e6===this.data.length&&e.cacheUnimaginableCount<2&&(e.cacheUnimaginable.addTail(this),e.cacheUnimaginableCount++)}save(e,t=this.pos,i=0){if('undefined'==typeof self){const r=path.dirname(e);fs.existsSync(r)||fs.mkdirSync(r,{recursive:!0}),fs.writeFileSync(e,this.data.subarray(i,i+t))}else{const r=new Blob([this.data.subarray(i,i+t)],{type:'application/octet-stream'}),s=URL.createObjectURL(r);self.postMessage({type:'save',value:s,path:e})}}p1(e){this.#e.setUint8(this.pos++,e)}p2(e){this.#e.setUint16(this.pos,e),this.pos+=2}ip2(e){this.#e.setUint16(this.pos,e,!0),this.pos+=2}p3(e){this.#e.setUint8(this.pos++,e>>16),this.#e.setUint16(this.pos,e),this.pos+=2}p4(e){this.#e.setInt32(this.pos,e),this.pos+=4}ip4(e){this.#e.setInt32(this.pos,e,!0),this.pos+=4}p8(e){this.#e.setBigInt64(this.pos,e),this.pos+=8}pbool(e){this.p1(e?1:0)}pjstr(e,t=10){const i=e.length;for(let t=0;t=64)this.p1(e+64);else{if(!(e<16384&&e>=-16384))throw new Error('Error psmarts out of range: '+e);this.p2(e+49152)}}psmart(e){if(e>=0&&e<128)this.p1(e);else{if(!(e>=0&&e<32768))throw new Error('Error psmart out of range: '+e);this.p2(e+32768)}}g1(){return this.#e.getUint8(this.pos++)}g1b(){return this.#e.getInt8(this.pos++)}g2(){return this.pos+=2,this.#e.getUint16(this.pos-2)}g2s(){return this.pos+=2,this.#e.getInt16(this.pos-2)}ig2(){return this.pos+=2,this.#e.getUint16(this.pos-2,!0)}g3(){const e=this.#e.getUint8(this.pos++)<<16|this.#e.getUint16(this.pos);return this.pos+=2,e}g4(){return this.pos+=4,this.#e.getInt32(this.pos-4)}ig4(){return this.pos+=4,this.#e.getInt32(this.pos-4,!0)}g8(){return this.pos+=8,this.#e.getBigInt64(this.pos-8)}gbool(){return 1===this.g1()}gjstr(e=10){const t=this.data.length;let i,r='';for(;(i=this.#e.getUint8(this.pos++))!==e&&this.pos>>3}gBit(t){let i=this.bitPos>>>3,r=8-(7&this.bitPos),s=0;for(this.bitPos+=t;t>r;r=8)s+=(this.#e.getUint8(i++)&e.bitmask[r])<>>r-t&e.bitmask[t],s}pBit(e,t){const i=this.bitPos;this.bitPos+=e;let r=i>>>3,s=8-(7&i);const n=this.#e;for(;e>s;s=8){const i=(1<>>e-s&i),e-=s}const a=s-e,o=(1<0;){const t=e.g1();if(0===t)break;this.decode(t,e)}}},Le=class e extends Ne{static configNames=new Map;static configs=[];static load(e){if(!fs2.existsSync(`${e}/server/category.dat`))return void console.log('Warning: No category.dat found.');const t=Oe.load(`${e}/server/category.dat`);this.parse(t)}static async loadAsync(e){if(!(await fetch(`${e}/server/category.dat`)).ok)return void console.log('Warning: No category.dat found.');const t=await Oe.loadAsync(`${e}/server/category.dat`);this.parse(t)}static parse(t){e.configNames=new Map,e.configs=[];const i=t.g2();for(let r=0;re.tableId===t))}tableId=0;types=[];columnValues=[];decode(e,t){if(3===e){const e=t.g1();this.types=new Array(e),this.columnValues=new Array(e);for(let e=t.g1();255!=e;e=t.g1()){const i=new Array(t.g1());for(let e=0;e{i=e,r=t}));['_BZ2_bzBuffToBuffDecompress','_BZ2_bzBuffToBuffCompress','_malloc','_free','_memory','___indirect_function_table','onRuntimeInitialized'].forEach((e=>{Object.getOwnPropertyDescriptor(n,e)||Object.defineProperty(n,e,{get:()=>z('You are getting '+e+' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),set:()=>z('You are setting '+e+' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js')})}));var a='object'==typeof window,o='function'==typeof importScripts,c='object'==typeof process&&'object'==typeof process.versions&&'string'==typeof process.versions.node,l=!a&&!c&&!o;if(s.ENVIRONMENT)throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');if(c){const{createRequire:e}=await import('module');var h=e(import.meta.url)}var d,u,p,f=Object.assign({},s),g=(e,t)=>{throw t},m='';if(c){if('undefined'==typeof process||!process.release||'node'!==process.release.name)throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');var y=process.versions.node,E=y.split('.').slice(0,3);if((E=1e4*E[0]+100*E[1]+1*E[2].split('-')[0])<16e4)throw new Error('This emscripten-generated code requires node v16.0.0 (detected v'+y+')');var _=h('fs'),A=h('path');m=h('url').fileURLToPath(new URL('./',import.meta.url)),d=(e,t)=>(e=Q(e)?new URL(e):A.normalize(e),_.readFileSync(e,t?void 0:'utf8')),p=e=>{var t=d(e,!0);return t.buffer||(t=new Uint8Array(t)),U(t.buffer),t},u=(e,t,i,r=!0)=>{e=Q(e)?new URL(e):A.normalize(e),_.readFile(e,r?void 0:'utf8',((e,s)=>{e?i(e):t(r?s.buffer:s)}))},!s.thisProgram&&process.argv.length>1&&process.argv[1].replace(/\\/g,'/'),process.argv.slice(2),g=(e,t)=>{throw process.exitCode=e,t}}else if(l){if('object'==typeof process&&'function'==typeof h||'object'==typeof window||'function'==typeof importScripts)throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)')}else{if(!a&&!o)throw new Error('environment detection error');if(o?m=self.location.href:'undefined'!=typeof document&&document.currentScript&&(m=document.currentScript.src),Ae&&(m=Ae),m=m.startsWith('blob:')?'':m.substr(0,m.replace(/[?#].*/,'').lastIndexOf('/')+1),'object'!=typeof window&&'function'!=typeof importScripts)throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');d=e=>{var t=new XMLHttpRequest;return t.open('GET',e,!1),t.send(null),t.responseText},o&&(p=e=>{var t=new XMLHttpRequest;return t.open('GET',e,!1),t.responseType='arraybuffer',t.send(null),new Uint8Array(t.response)}),u=(e,t,i)=>{var r=new XMLHttpRequest;r.open('GET',e,!0),r.responseType='arraybuffer',r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):i()},r.onerror=i,r.send(null)}}var v,T,C,I=s.print||console.log.bind(console),S=s.printErr||console.error.bind(console);Object.assign(s,f),f=null,v='fetchSettings',Object.getOwnPropertyDescriptor(s,v)&&z(`\`Module.${v}\` was supplied but \`${v}\` not included in INCOMING_MODULE_JS_API`),s.arguments&&s.arguments,ee('arguments','arguments_'),s.thisProgram&&s.thisProgram,ee('thisProgram','thisProgram'),s.quit&&(g=s.quit),ee('quit','quit_'),U(void 0===s.memoryInitializerPrefixURL,'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead'),U(void 0===s.pthreadMainPrefixURL,'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead'),U(void 0===s.cdInitializerPrefixURL,'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead'),U(void 0===s.filePackagePrefixURL,'Module.filePackagePrefixURL option was removed, use Module.locateFile instead'),U(void 0===s.read,'Module.read option was removed (modify read_ in JS)'),U(void 0===s.readAsync,'Module.readAsync option was removed (modify readAsync in JS)'),U(void 0===s.readBinary,'Module.readBinary option was removed (modify readBinary in JS)'),U(void 0===s.setWindowTitle,'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)'),U(void 0===s.TOTAL_MEMORY,'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY'),ee('asm','wasmExports'),ee('read','read_'),ee('readAsync','readAsync'),ee('readBinary','readBinary'),ee('setWindowTitle','setWindowTitle'),U(!l,'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.'),s.wasmBinary&&(T=s.wasmBinary),ee('wasmBinary','wasmBinary'),'object'!=typeof WebAssembly&&S('no native wasm support detected');var O,N,L,P,w,b,R,B=!1;function U(e,t){e||z('Assertion failed'+(t?': '+t:''))}function D(){var e=C.buffer;s.HEAP8=O=new Int8Array(e),s.HEAP16=L=new Int16Array(e),s.HEAPU8=N=new Uint8Array(e),s.HEAPU16=new Uint16Array(e),s.HEAP32=P=new Int32Array(e),s.HEAPU32=w=new Uint32Array(e),s.HEAPF32=b=new Float32Array(e),s.HEAPF64=R=new Float64Array(e)}function k(){if(!B){var e=Ce();0==e&&(e+=4);var t=w[e>>2],i=w[e+4>>2];34821223==t&&2310721022==i||z(`Stack overflow! Stack cookie has been overwritten at ${ce(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ce(i)} ${ce(t)}`),1668509029!=w[0]&&z('Runtime error: The application has corrupted its heap memory area (address zero)!')}}U(!s.STACK_SIZE,'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time'),U('undefined'!=typeof Int32Array&&'undefined'!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,'JS engine does not provide full typed array support'),U(!s.wasmMemory,'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally'),U(!s.INITIAL_MEMORY,'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically'),function(){var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,115!==t[0]||99!==t[1])throw'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)'}();var M=[],x=[],F=[],H=!1;U(Math.imul,'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'),U(Math.fround,'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'),U(Math.clz32,'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'),U(Math.trunc,'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');var V=0,G=null,W=null,K={};function z(e){s.onAbort?.(e),S(e='Aborted('+e+')'),B=!0;var t=new WebAssembly.RuntimeError(e);throw r(t),t}var j={error(){z('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM')},init(){j.error()},createDataFile(){j.error()},createPreloadedFile(){j.error()},createLazyFile(){j.error()},open(){j.error()},mkdev(){j.error()},registerDevice(){j.error()},analyzePath(){j.error()},ErrnoError(){j.error()}};s.FS_createDataFile=j.createDataFile,s.FS_createPreloadedFile=j.createPreloadedFile;var Y,q=e=>e.startsWith("data:application/octet-stream;base64,"),Q=e=>e.startsWith('file://');function $(e,t){return(...i)=>{U(H,`native function \`${e}\` called before runtime initialization`);var r=_e[e];return U(r,`exported native function \`${e}\` not found`),U(i.length<=t,`native function \`${e}\` called with ${i.length} args but expects ${t}`),r(...i)}}function Z(){if(s.locateFile){var e='bzip2.wasm';return q(e)?e:(t=e,s.locateFile?s.locateFile(t,m):m+t)}var t;return new URL('bzip2.wasm',import.meta.url).href}function X(e){if(e==Y&&T)return new Uint8Array(T);if(p)return p(e);throw'both async and sync fetching of the wasm failed'}function J(e,t,i){return function(e){if(!T&&(a||o)){if('function'==typeof fetch&&!Q(e))return fetch(e,{credentials:'same-origin'}).then((t=>{if(!t.ok)throw`failed to load wasm binary file at '${e}'`;return t.arrayBuffer()})).catch((()=>X(e)));if(u)return new Promise(((t,i)=>{u(e,(e=>t(new Uint8Array(e))),i)}))}return Promise.resolve().then((()=>X(e)))}(e).then((e=>WebAssembly.instantiate(e,t))).then(i,(e=>{S(`failed to asynchronously prepare wasm: ${e}`),Q(Y)&&S(`warning: Loading from a file URI (${Y}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),z(e)}))}function ee(e,t,i=!0){Object.getOwnPropertyDescriptor(s,e)||Object.defineProperty(s,e,{configurable:!0,get(){z(`\`Module.${e}\` has been replaced by \`${t}\``+(i?' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)':''))}})}function te(e){return'FS_createPath'===e||'FS_createDataFile'===e||'FS_createPreloadedFile'===e||'FS_unlink'===e||'addRunDependency'===e||'FS_createLazyFile'===e||'FS_createDevice'===e||'removeRunDependency'===e}function ie(e,t){'undefined'!=typeof globalThis&&Object.defineProperty(globalThis,e,{configurable:!0,get(){le(`\`${e}\` is not longer defined by emscripten. ${t}`)}})}function re(e){Object.getOwnPropertyDescriptor(s,e)||Object.defineProperty(s,e,{configurable:!0,get(){var t=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;te(e)&&(t+='. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'),z(t)}})}function se(e){this.name='ExitStatus',this.message=`Program terminated with exit(${e})`,this.status=e}ie('buffer','Please use HEAP8.buffer or wasmMemory.buffer'),ie('asm','Please use wasmExports instead');var ne,ae=e=>{for(;e.length>0;)e.shift()(s)},oe=s.noExitRuntime||!0,ce=e=>(U('number'==typeof e),'0x'+(e>>>=0).toString(16).padStart(8,'0')),le=e=>{le.shown||={},le.shown[e]||(le.shown[e]=1,c&&(e='warning: '+e),S(e))},he=e=>{var t=C.buffer,i=(e-t.byteLength+65535)/65536;try{return C.grow(i),D(),1}catch(i){S(`growMemory: Attempted to grow heap from ${t.byteLength} bytes to ${e} bytes, but got error: ${i}`)}},de=()=>oe||!1,ue=(e,t)=>{if(function(){var e=I,t=S,i=!1;I=S=e=>{i=!0};try{ye()}catch(e){}I=e,S=t,i&&(le('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.'),le('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)'))}(),de()&&!t){var i=`program exited (with status: ${e}), but keepRuntimeAlive() is set (counter=0) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;r(i),S(i)}var n;n=e,de()||(s.onExit?.(n),B=!0),g(n,new se(n))},pe='undefined'!=typeof TextDecoder?new TextDecoder('utf8'):void 0,fe=(e,t,i)=>{for(var r=t+i,s=t;e[s]&&!(s>=r);)++s;if(s-t>16&&e.buffer&&pe)return pe.decode(e.subarray(t,s));for(var n='';t>10,56320|1023&l)}}else n+=String.fromCharCode((31&a)<<6|o)}else n+=String.fromCharCode(a)}return n},ge=[null,[],[]],me=(e,t)=>{var i=ge[e];U(i),0===t||10===t?((1===e?I:S)(fe(i,0)),i.length=0):i.push(t)},ye=()=>{ve(0),ge[1].length&&me(1,10),ge[2].length&&me(2,10)},Ee={_emscripten_memcpy_js:(e,t,i)=>N.copyWithin(e,t,t+i),emscripten_resize_heap:e=>{var t=N.length;U((e>>>=0)>t);var i=2147483648;if(e>i)return S(`Cannot enlarge memory, requested ${e} bytes, but the limit is 2147483648 bytes!`),!1;for(var r,s,n=1;n<=4;n*=2){var a=t*(1+.2/n);a=Math.min(a,e+100663296);var o=Math.min(i,(r=Math.max(e,a))+((s=65536)-r%s)%s);if(he(o))return!0}return S(`Failed to grow the heap from ${t} bytes to ${o} bytes, not enough memory!`),!1},exit:ue,fd_close:e=>{z('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM')},fd_seek:function(e,t,i,r,s){var n,a;return a=i,U((n=t)==n>>>0||n==(0|n)),U(a===(0|a)),70},fd_write:(e,t,i,r)=>{for(var s=0,n=0;n>2],o=w[t+4>>2];t+=8;for(var c=0;c>2]=s,0}},_e=function(){var e,t={env:Ee,wasi_snapshot_preview1:Ee};function i(e,t){var i;return _e=e.exports,U(C=_e.memory,'memory not found in wasm exports'),D(),i=_e.__wasm_call_ctors,x.unshift(i),function(e){if(V--,s.monitorRunDependencies?.(V),e?(U(K[e]),delete K[e]):S('warning: run dependency removed without ID'),0==V&&(null!==G&&(clearInterval(G),G=null),W)){var t=W;W=null,t()}}('wasm-instantiate'),_e}e='wasm-instantiate',V++,s.monitorRunDependencies?.(V),e?(U(!K[e]),K[e]=1,null===G&&'undefined'!=typeof setInterval&&(G=setInterval((()=>{if(B)return clearInterval(G),void(G=null);var e=!1;for(var t in K)e||(e=!0,S('still waiting on run dependencies:')),S(`dependency: ${t}`);e&&S('(end of list)')}),1e4))):S('warning: run dependency added without ID');var n,a,o,l,h=s;if(s.instantiateWasm)try{return s.instantiateWasm(t,i)}catch(e){S(`Module.instantiateWasm callback failed with error: ${e}`),r(e)}return Y||(Y=Z()),(n=T,a=Y,o=t,l=function(e){U(s===h,'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?'),h=null,i(e.instance)},n||'function'!=typeof WebAssembly.instantiateStreaming||q(a)||Q(a)||c||'function'!=typeof fetch?J(a,o,l):fetch(a,{credentials:'same-origin'}).then((e=>WebAssembly.instantiateStreaming(e,o).then(l,(function(e){return S(`wasm streaming compile failed: ${e}`),S('falling back to ArrayBuffer instantiation'),J(a,o,l)}))))).catch(r),{}}(),ve=($('__wasm_call_ctors',0),s._malloc=$('malloc',1),s._free=$('free',1),$('fflush',1)),Te=(s._BZ2_bzBuffToBuffCompress=$('BZ2_bzBuffToBuffCompress',7),s._BZ2_bzBuffToBuffDecompress=$('BZ2_bzBuffToBuffDecompress',6),()=>(Te=_e.emscripten_stack_init)()),Ce=()=>(Ce=_e.emscripten_stack_get_end)();function Ie(){var e;Te(),U(!(3&(e=Ce()))),0==e&&(e+=4),w[e>>2]=34821223,w[e+4>>2]=2310721022,w[0]=1668509029}function Se(){function e(){ne||(ne=!0,s.calledRun=!0,B||(U(!H),H=!0,k(),ae(x),i(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),U(!s._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){if(k(),s.postRun)for('function'==typeof s.postRun&&(s.postRun=[s.postRun]);s.postRun.length;)e=s.postRun.shift(),F.unshift(e);var e;ae(F)}()))}V>0||(Ie(),function(){if(s.preRun)for('function'==typeof s.preRun&&(s.preRun=[s.preRun]);s.preRun.length;)e=s.preRun.shift(),M.unshift(e);var e;ae(M)}(),V>0||(s.setStatus?(s.setStatus('Running...'),setTimeout((function(){setTimeout((function(){s.setStatus('')}),1),e()}),1)):e(),k()))}if(s.dynCall_jiji=$('dynCall_jiji',5),s.setValue=function(e,t,i="i8"){switch(i.endsWith('*')&&(i='*'),i){case'i1':case'i8':O[e]=t;break;case'i16':L[e>>1]=t;break;case'i32':P[e>>2]=t;break;case'i64':z('to do setValue(i64) use WASM_BIGINT');case'float':b[e>>2]=t;break;case'double':R[e>>3]=t;break;case'*':w[e>>2]=t;break;default:z(`invalid type for setValue: ${i}`)}},s.getValue=function(e,t="i8"){switch(t.endsWith('*')&&(t='*'),t){case'i1':case'i8':return O[e];case'i16':return L[e>>1];case'i32':return P[e>>2];case'i64':z('to do getValue(i64) use WASM_BIGINT');case'float':return b[e>>2];case'double':return R[e>>3];case'*':return w[e>>2];default:z(`invalid type for getValue: ${t}`)}},['writeI53ToI64','writeI53ToI64Clamped','writeI53ToI64Signaling','writeI53ToU64Clamped','writeI53ToU64Signaling','readI53FromI64','readI53FromU64','convertI32PairToI53','convertU32PairToI53','stackAlloc','getTempRet0','setTempRet0','zeroMemory','isLeapYear','ydayFromDate','arraySum','addDays','inetPton4','inetNtop4','inetPton6','inetNtop6','readSockaddr','writeSockaddr','initRandomFill','randomFill','emscriptenLog','readEmAsmArgs','jstoi_q','getExecutableName','listenOnce','autoResumeAudioContext','dynCallLegacy','getDynCaller','dynCall','handleException','runtimeKeepalivePush','runtimeKeepalivePop','callUserCallback','maybeExit','asmjsMangle','asyncLoad','alignMemory','mmapAlloc','HandleAllocator','getNativeTypeSize','STACK_SIZE','STACK_ALIGN','POINTER_SIZE','ASSERTIONS','getCFunc','ccall','cwrap','uleb128Encode','sigToWasmTypes','generateFuncType','convertJsFunctionToWasm','getEmptyTableSlot','updateTableMap','getFunctionAddress','addFunction','removeFunction','reallyNegative','unSign','strLen','reSign','formatString','stringToUTF8Array','stringToUTF8','lengthBytesUTF8','intArrayFromString','intArrayToString','AsciiToString','stringToAscii','UTF16ToString','stringToUTF16','lengthBytesUTF16','UTF32ToString','stringToUTF32','lengthBytesUTF32','stringToNewUTF8','stringToUTF8OnStack','writeArrayToMemory','registerKeyEventCallback','maybeCStringToJsString','findEventTarget','getBoundingClientRect','fillMouseEventData','registerMouseEventCallback','registerWheelEventCallback','registerUiEventCallback','registerFocusEventCallback','fillDeviceOrientationEventData','registerDeviceOrientationEventCallback','fillDeviceMotionEventData','registerDeviceMotionEventCallback','screenOrientation','fillOrientationChangeEventData','registerOrientationChangeEventCallback','fillFullscreenChangeEventData','registerFullscreenChangeEventCallback','JSEvents_requestFullscreen','JSEvents_resizeCanvasForFullscreen','registerRestoreOldStyle','hideEverythingExceptGivenElement','restoreHiddenElements','setLetterbox','softFullscreenResizeWebGLRenderTarget','doRequestFullscreen','fillPointerlockChangeEventData','registerPointerlockChangeEventCallback','registerPointerlockErrorEventCallback','requestPointerLock','fillVisibilityChangeEventData','registerVisibilityChangeEventCallback','registerTouchEventCallback','fillGamepadEventData','registerGamepadEventCallback','registerBeforeUnloadEventCallback','fillBatteryEventData','battery','registerBatteryEventCallback','setCanvasElementSize','getCanvasElementSize','jsStackTrace','getCallstack','convertPCtoSourceLocation','getEnvStrings','checkWasiClock','wasiRightsToMuslOFlags','wasiOFlagsToMuslOFlags','createDyncallWrapper','safeSetTimeout','setImmediateWrapped','clearImmediateWrapped','polyfillSetImmediate','getPromise','makePromise','idsToPromises','makePromiseCallback','ExceptionInfo','findMatchingCatch','Browser_asyncPrepareDataCounter','setMainLoop','getSocketFromFD','getSocketAddress','FS_createPreloadedFile','FS_modeStringToFlags','FS_getMode','FS_stdin_getChar','FS_createDataFile','FS_unlink','FS_mkdirTree','_setNetworkCallback','heapObjectForWebGLType','toTypedArrayIndex','webgl_enable_ANGLE_instanced_arrays','webgl_enable_OES_vertex_array_object','webgl_enable_WEBGL_draw_buffers','webgl_enable_WEBGL_multi_draw','emscriptenWebGLGet','computeUnpackAlignedImageSize','colorChannelsInGlTextureFormat','emscriptenWebGLGetTexPixelData','emscriptenWebGLGetUniform','webglGetUniformLocation','webglPrepareUniformLocationsBeforeFirstUse','webglGetLeftBracePos','emscriptenWebGLGetVertexAttrib','__glGetActiveAttribOrUniform','writeGLArray','registerWebGlEventCallback','runAndAbortIfError','ALLOC_NORMAL','ALLOC_STACK','allocate','writeStringToMemory','writeAsciiToMemory','setErrNo','demangle','stackTrace'].forEach((function(e){'undefined'==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,e)||Object.defineProperty(globalThis,e,{configurable:!0,get(){var t=`\`${e}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`,i=e;i.startsWith('_')||(i='$'+e),t+=` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${i}')`,te(e)&&(t+='. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'),le(t)}}),re(e)})),['run','addOnPreRun','addOnInit','addOnPreMain','addOnExit','addOnPostRun','addRunDependency','removeRunDependency','FS_createFolder','FS_createPath','FS_createLazyFile','FS_createLink','FS_createDevice','FS_readFile','out','err','callMain','abort','wasmMemory','wasmExports','writeStackCookie','checkStackCookie','convertI32PairToI53Checked','stackSave','stackRestore','ptrToString','exitJS','getHeapMax','growMemory','ENV','MONTH_DAYS_REGULAR','MONTH_DAYS_LEAP','MONTH_DAYS_REGULAR_CUMULATIVE','MONTH_DAYS_LEAP_CUMULATIVE','ERRNO_CODES','ERRNO_MESSAGES','DNS','Protocols','Sockets','timers','warnOnce','readEmAsmArgsArray','jstoi_s','keepRuntimeAlive','wasmTable','noExitRuntime','freeTableIndexes','functionsInTableMap','PATH','PATH_FS','UTF8Decoder','UTF8ArrayToString','UTF8ToString','UTF16Decoder','JSEvents','specialHTMLTargets','findCanvasEventTarget','currentFullscreenStrategy','restoreOldWindowedStyle','UNWIND_CACHE','ExitStatus','flush_NO_FILESYSTEM','promiseMap','uncaughtExceptionCount','exceptionLast','exceptionCaught','Browser','getPreloadedImageData__data','wget','SYSCALLS','preloadPlugins','FS_stdin_getChar_buffer','FS','MEMFS','TTY','PIPEFS','SOCKFS','tempFixedLengthArray','miniTempWebGLFloatBuffers','miniTempWebGLIntBuffers','GL','AL','GLUT','EGL','GLEW','IDBStore','SDL','SDL_gfx','allocateUTF8','allocateUTF8OnStack'].forEach(re),W=function e(){ne||Se(),ne||(W=e)},s.preInit)for('function'==typeof s.preInit&&(s.preInit=[s.preInit]);s.preInit.length>0;)s.preInit.pop()();Se(),t=n;for(const t of Object.keys(s))t in e||Object.defineProperty(e,t,{configurable:!0,get(){z(`Access to module property ('${t}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return t}),Ue=Be,De={'-2':'BZ_PARAM_ERROR: incorrect parameters','-3':"BZ_MEM_ERROR: couldn't allocate enough memory",'-4':'BZ_DATA_ERROR: data integrity error when decompressing','-5':'BZ_DATA_ERROR_MAGIC: compressed data has incorrect header','-7':'BZ_UNEXPECTED_EOF: compressed data ends too early','-8':'BZ_OUTBUFF_FULL: destination buffer is full'},ke=new class{constructor(){this.wasmModule=void 0}async init(){if(!this.wasmModule){if('undefined'!=typeof process){const{dirname:e}=await import('path'),{createRequire:t}=await import('module');globalThis.__dirname=e(import.meta.url),globalThis.require=t(import.meta.url)}this.wasmModule=await Ue()}}ensureInitialized(){if(!this.wasmModule)throw new Error(`${this.constructor.name} not initalized. call .init()`)}handleError(e,t,i){if(0===e)return;this.wasmModule._free(t),this.wasmModule._free(i);const r=De[e];if(r)throw new Error(r);throw new Error(`error code: ${e}`)}createWASMBuffers(e,t){const{_malloc:i,setValue:r,HEAPU8:s}=this.wasmModule,n=i(e.length);s.set(e,n);const a=i(t),o=i(t);return r(o,t,'i32'),{sourcePtr:n,destPtr:a,destLengthPtr:o}}createBuffer(e,t){const{_free:i,getValue:r,HEAPU8:s}=this.wasmModule,n=r(t,'i32'),a=new Uint8Array(n);return a.set(s.subarray(e,e+n)),i(e),i(t),a}decompress(e,t,i=!1,r=!1){if(r&&(t=e[0]<<24|e[1]<<16|e[2]<<8|e[3],e[0]='B'.charCodeAt(0),e[1]='Z'.charCodeAt(0),e[2]='h'.charCodeAt(0),e[3]='1'.charCodeAt(0),i=!1),i){const t=new Uint8Array(e.length+4);t[0]='B'.charCodeAt(0),t[1]='Z'.charCodeAt(0),t[2]='h'.charCodeAt(0),t[3]='1'.charCodeAt(0),t.set(e,4),e=t}this.ensureInitialized();const{sourcePtr:s,destPtr:n,destLengthPtr:a}=this.createWASMBuffers(e,t),o=this.wasmModule._BZ2_bzBuffToBuffDecompress(n,a,s,e.length,0,0);return this.wasmModule._free(s),this.handleError(o,n,a),this.createBuffer(n,a)}compress(e,t=!1,i=!1,r=1,s=0){if(this.ensureInitialized(),s||(s=e.length+1024),s<128&&(s=128),r<=0||r>9)throw new RangeError('blockSize should be between 1-9');const{sourcePtr:n,destPtr:a,destLengthPtr:o}=this.createWASMBuffers(e,s),c=this.wasmModule._BZ2_bzBuffToBuffCompress(a,o,n,e.length,r,0,30);this.wasmModule._free(n),this.handleError(c,a,o);const l=this.createBuffer(a,o);return t&&(l[0]=e.length>>24&255,l[1]=e.length>>16&255,l[2]=e.length>>8&255,l[3]=255&e.length),i?l.subarray(4):l}};await ke.init();var Me=ke;function xe(e){let t=0;e=e.toUpperCase();for(let i=0;ie===this.fileHash[t]));-1!==r&&(this.fileName[t]=He[r]),this.fileUnpackedSize[t]=e.g3(),this.filePackedSize[t]=e.g3(),this.filePos[t]=i,i+=this.filePackedSize[t]}}get(e){if(e<0||e>=this.fileCount)return null;if(null===this.data)throw new Error('Jagfile data is not loaded');const t=this.data.subarray(this.filePos[e],this.filePos[e]+this.filePackedSize[e]);return this.unpacked?new Oe(t):new Oe(Me.decompress(t,this.fileUnpackedSize[e],!0))}read(e){const t=xe(e);for(let e=0;ee===t.hash));if(t.write){if(-1===i&&(i=this.fileCount++,this.fileHash[i]=t.hash,this.fileName[i]=t.name),!t.data)throw new Error('Cannot write without data');this.fileUnpackedSize[i]=t.data.length,this.filePackedSize[i]=t.data.length,this.filePos[i]=-1,this.fileWrite[i]=t.data}if(t.delete&&-1!==i&&(this.fileHash.splice(i,1),this.fileName.splice(i,1),this.fileUnpackedSize.splice(i,1),this.filePackedSize.splice(i,1),this.filePos.splice(i,1),this.fileCount--),t.rename&&-1!==i){if(!t.newHash)throw new Error('Cannot rename without newHash');if(!t.newName)throw new Error('Cannot rename without newName');this.fileHash[i]=t.newHash,this.fileName[i]=t.newName}this.fileQueue.splice(e,1),e--}let r=1===this.fileCount;t&&r&&(r=!1),i.p2(this.fileCount);for(let e=0;e/?\\| ";for(let i=0;i<256;i++){let r=t.indexOf(String.fromCharCode(i));-1==r&&(r=74),e.CHAR_LOOKUP[i]=r}}static load(t){const i=Fe.load(`${t}/client/title`);e.instances[0]=new e(i,'p11'),e.instances[1]=new e(i,'p12'),e.instances[2]=new e(i,'b12'),e.instances[3]=new e(i,'q8')}static async loadAsync(t){const i=await Fe.loadAsync(`${t}/client/title`);e.instances[0]=new e(i,'p11'),e.instances[1]=new e(i,'p12'),e.instances[2]=new e(i,'b12'),e.instances[3]=new e(i,'q8')}static get(t){return e.instances[t]}static get count(){return this.instances.length}charMask=new Array(94);charMaskWidth=new Uint8Array(94);charMaskHeight=new Uint8Array(94);charOffsetX=new Uint8Array(94);charOffsetY=new Uint8Array(94);charAdvance=new Uint8Array(95);drawWidth=new Uint8Array(256);height=0;constructor(t,i){const r=t.read(`${i}.dat`),s=t.read('index.dat');if(!r||!s)return;s.pos=r.g2()+4;const n=s.g1();n>0&&(s.pos+=3*(n-1));for(let e=0;e<94;e++){this.charOffsetX[e]=s.g1(),this.charOffsetY[e]=s.g1();const t=this.charMaskWidth[e]=s.g2(),i=this.charMaskHeight[e]=s.g2(),n=s.g1(),a=t*i;if(this.charMask[e]=new Uint8Array(a),0==n)for(let t=0;tthis.height&&(this.height=i),this.charOffsetX[e]=1,this.charAdvance[e]=t+2;let o=0;for(let r=Math.floor(i/7);r0;){if(this.stringWidth(e)<=t&&-1===e.indexOf('|')){i.push(e);break}let r=e.length;for(let i=0;it)break;r=i}else if('|'===e[i]){r=i;break}i.push(e.substring(0,r)),e=e.substring(r+1)}return i}},We=(e=>(e[e.OFF=0]='OFF',e[e.OUTSIDE_WILDERNESS=1]='OUTSIDE_WILDERNESS',e))(We||{}),Ke=We,ze=(e=>(e[e.OFF=0]='OFF',e[e.PLAYER=1]='PLAYER',e[e.NPC=2]='NPC',e[e.OBJ=3]='OBJ',e[e.SCENERY=4]='SCENERY',e))(ze||{}),je=ze,Ye=(e=>(e[e.KEEPHUNTING=0]='KEEPHUNTING',e[e.PAUSEHUNT=1]='PAUSEHUNT',e))(Ye||{}),qe=Ye,Qe=(e=>(e[e.OFF=0]='OFF',e[e.LINEOFSIGHT=1]='LINEOFSIGHT',e[e.LINEOFWALK=2]='LINEOFWALK',e))(Qe||{}),$e=Qe,Ze=(e=>(e[e.NULL=-1]='NULL',e[e.NONE=0]='NONE',e[e.WANDER=1]='WANDER',e[e.PATROL=2]='PATROL',e[e.PLAYERESCAPE=3]='PLAYERESCAPE',e[e.PLAYERFOLLOW=4]='PLAYERFOLLOW',e[e.PLAYERFACE=5]='PLAYERFACE',e[e.PLAYERFACECLOSE=6]='PLAYERFACECLOSE',e[e.OPPLAYER1=7]='OPPLAYER1',e[e.OPPLAYER2=8]='OPPLAYER2',e[e.OPPLAYER3=9]='OPPLAYER3',e[e.OPPLAYER4=10]='OPPLAYER4',e[e.OPPLAYER5=11]='OPPLAYER5',e[e.APPLAYER1=12]='APPLAYER1',e[e.APPLAYER2=13]='APPLAYER2',e[e.APPLAYER3=14]='APPLAYER3',e[e.APPLAYER4=15]='APPLAYER4',e[e.APPLAYER5=16]='APPLAYER5',e[e.OPLOC1=17]='OPLOC1',e[e.OPLOC2=18]='OPLOC2',e[e.OPLOC3=19]='OPLOC3',e[e.OPLOC4=20]='OPLOC4',e[e.OPLOC5=21]='OPLOC5',e[e.APLOC1=22]='APLOC1',e[e.APLOC2=23]='APLOC2',e[e.APLOC3=24]='APLOC3',e[e.APLOC4=25]='APLOC4',e[e.APLOC5=26]='APLOC5',e[e.OPOBJ1=27]='OPOBJ1',e[e.OPOBJ2=28]='OPOBJ2',e[e.OPOBJ3=29]='OPOBJ3',e[e.OPOBJ4=30]='OPOBJ4',e[e.OPOBJ5=31]='OPOBJ5',e[e.APOBJ1=32]='APOBJ1',e[e.APOBJ2=33]='APOBJ2',e[e.APOBJ3=34]='APOBJ3',e[e.APOBJ4=35]='APOBJ4',e[e.APOBJ5=36]='APOBJ5',e[e.OPNPC1=37]='OPNPC1',e[e.OPNPC2=38]='OPNPC2',e[e.OPNPC3=39]='OPNPC3',e[e.OPNPC4=40]='OPNPC4',e[e.OPNPC5=41]='OPNPC5',e[e.APNPC1=42]='APNPC1',e[e.APNPC2=43]='APNPC2',e[e.APNPC3=44]='APNPC3',e[e.APNPC4=45]='APNPC4',e[e.APNPC5=46]='APNPC5',e[e.QUEUE1=47]='QUEUE1',e[e.QUEUE2=48]='QUEUE2',e[e.QUEUE3=49]='QUEUE3',e[e.QUEUE4=50]='QUEUE4',e[e.QUEUE5=51]='QUEUE5',e[e.QUEUE6=52]='QUEUE6',e[e.QUEUE7=53]='QUEUE7',e[e.QUEUE8=54]='QUEUE8',e[e.QUEUE9=55]='QUEUE9',e[e.QUEUE10=56]='QUEUE10',e[e.QUEUE11=57]='QUEUE11',e[e.QUEUE12=58]='QUEUE12',e[e.QUEUE13=59]='QUEUE13',e[e.QUEUE14=60]='QUEUE14',e[e.QUEUE15=61]='QUEUE15',e[e.QUEUE16=62]='QUEUE16',e[e.QUEUE17=63]='QUEUE17',e[e.QUEUE18=64]='QUEUE18',e[e.QUEUE19=65]='QUEUE19',e[e.QUEUE20=66]='QUEUE20',e))(Ze||{}),Xe=Ze,Je=class e extends Ne{static configNames=new Map;static configs=[];static load(e){if(!fs6.existsSync(`${e}/server/hunt.dat`))return void console.log('Warning: No hunt.dat found.');const t=Oe.load(`${e}/server/hunt.dat`);this.parse(t)}static async loadAsync(e){if(!(await fetch(`${e}/server/hunt.dat`)).ok)return void console.log('Warning: No hunt.dat found.');const t=await Oe.loadAsync(`${e}/server/hunt.dat`);this.parse(t)}static parse(t){e.configNames=new Map,e.configs=[];const i=t.g2();for(let r=0;r=40&&e<50)this.recol_s[e-40]=t.g2();else if(e>=50&&e<60)this.recol_d[e-50]=t.g2();else if(e>=60&&e<70)this.heads[e-60]=t.g2();else{if(250!==e)throw new Error(`Unrecognized idk config code: ${e}`);this.debugname=t.gjstr()}}},tt=class e{static TYPE_LAYER=0;static TYPE_UNUSED=1;static TYPE_INVENTORY=2;static TYPE_RECT=3;static TYPE_TEXT=4;static TYPE_SPRITE=5;static TYPE_MODEL=6;static TYPE_INVENTORY_TEXT=7;static NO_BUTTON=0;static BUTTON=1;static TARGET_BUTTON=2;static CLOSE_BUTTON=3;static TOGGLE_BUTTON=4;static SELECT_BUTTON=5;static PAUSE_BUTTON=6;static componentNames=new Map;static components=[];static load(e){if(!fs8.existsSync(`${e}/server/interface.dat`))return void console.log('Warning: No interface.dat found.');const t=Oe.load(`${e}/server/interface.dat`);this.parse(t)}static async loadAsync(e){if(!(await fetch(`${e}/server/interface.dat`)).ok)return void console.log('Warning: No interface.dat found.');const t=await Oe.loadAsync(`${e}/server/interface.dat`);this.parse(t)}static parse(t){this.componentNames=new Map,this.components=[],t.g2();let i=-1;for(;t.available>0;){let r=t.g2();65535===r&&(i=t.g2(),r=t.g2());const s=new e;s.id=r,s.rootLayer=i,s.comName=t.gjstr(),s.overlay=t.gbool(),s.type=t.g1(),s.buttonType=t.g1(),s.clientCode=t.g2(),s.width=t.g2(),s.height=t.g2(),s.overLayer=t.g1(),0==s.overLayer?s.overLayer=-1:s.overLayer=(s.overLayer-1<<8)+t.g1();const n=t.g1();if(n>0){s.scriptComparator=new Uint8Array(n).fill(0),s.scriptOperand=new Uint16Array(n).fill(0);for(let e=0;e0){s.scripts=new Array(a).fill(null);for(let e=0;e0&&10===r.shapes[0]?1:0,r.op&&r.op.length>0&&(r.active=1)),e.configs[i]=r,r.debugname&&e.configNames.set(r.debugname,i)}}static get(t){return e.configs[t]}static getId(t){return e.configNames.get(t)??-1}static getByName(e){const t=this.getId(e);return void 0===t||-1===t?null:this.get(t)}static get count(){return this.configs.length}models=null;shapes=null;name=null;desc=null;recol_s=null;recol_d=null;width=1;length=1;blockwalk=!0;blockrange=!0;active=0;hillskew=!1;sharelight=!1;occlude=!1;anim=-1;hasalpha=!1;wallwidth=16;ambient=0;contrast=0;op=null;mapfunction=-1;mapscene=-1;mirror=!1;shadow=!0;resizex=128;resizey=128;resizez=128;forceapproach=0;xoff=0;yoff=0;zoff=0;forcedecor=!1;category=-1;params=new Map;decode(e,t){if(1===e){const e=t.g1();this.models=new Uint16Array(e),this.shapes=new Uint8Array(e);for(let i=0;i=30&&e<35)this.op||(this.op=new Array(5).fill(null)),this.op[e-30]=t.gjstr(),'hidden'===this.op[e-30]&&(this.op[e-30]=null);else if(40===e){const e=t.g1();this.recol_s=new Uint16Array(e),this.recol_d=new Uint16Array(e);for(let i=0;i=1&&e<5)this.len[e-1]=t.g2();else{if(250!==e)throw new Error(`Unrecognized mesanim config code: ${e}`);this.debugname=t.gjstr()}}},ct=(e=>(e[e.NONE=0]='NONE',e[e.NPC=1]='NPC',e[e.ALL=2]='ALL',e))(ct||{}),lt=ct,ht=(e=>(e[e.NORMAL=0]='NORMAL',e[e.BLOCKED=1]='BLOCKED',e[e.BLOCKED_NORMAL=2]='BLOCKED_NORMAL',e[e.INDOORS=3]='INDOORS',e[e.OUTDOORS=4]='OUTDOORS',e[e.NOMOVE=5]='NOMOVE',e[e.PASSTHRU=6]='PASSTHRU',e))(ht||{}),dt=ht,ut=(e=>(e[e.ATTACK=0]='ATTACK',e[e.DEFENCE=1]='DEFENCE',e[e.STRENGTH=2]='STRENGTH',e[e.HITPOINTS=3]='HITPOINTS',e[e.RANGED=4]='RANGED',e[e.MAGIC=5]='MAGIC',e))(ut||{}),pt=ut,ft=class e extends Ne{static configNames=new Map;static configs=[];static load(e){if(!fs12.existsSync(`${e}/server/npc.dat`))return void console.log('Warning: No npc.dat found.');const t=Oe.load(`${e}/server/npc.dat`),i=Fe.load(`${e}/client/config`);this.parse(t,i)}static async loadAsync(e){if(!(await fetch(`${e}/server/npc.dat`)).ok)return void console.log('Warning: No npc.dat found.');const t=await Oe.loadAsync(`${e}/server/npc.dat`),i=await Fe.loadAsync(`${e}/client/config`);this.parse(t,i)}static parse(t,i){e.configNames=new Map,e.configs=[];const r=t.g2(),s=i.read('npc.dat');s.pos=2;for(let i=0;i=30&&e<40)this.op||(this.op=new Array(5).fill(null)),this.op[e-30]=t.gjstr(),'hidden'===this.op[e-30]&&(this.op[e-30]=null);else if(40===e){const e=t.g1();this.recol_s=new Uint16Array(e),this.recol_d=new Uint16Array(e);for(let i=0;i{gt.get(t)?.autodisable&&i.params.delete(t)})))}}static get(t){return e.configs[t]}static getId(t){return e.configNames.get(t)??-1}static getByName(e){const t=this.getId(e);return-1===t?null:this.get(t)}static get count(){return this.configs.length}static getWearPosId(e){switch(e){case'hat':return 0;case'back':return 1;case'front':return 2;case'righthand':return 3;case'torso':return 4;case'lefthand':return 5;case'arms':return 6;case'legs':return 7;case'head':return 8;case'hands':return 9;case'feet':return 10;case'jaw':return 11;case'ring':return 12;case'quiver':return 13;default:return-1}}model=0;name=null;desc=null;recol_s=null;recol_d=null;zoom2d=2e3;xan2d=0;yan2d=0;zan2d=0;xof2d=0;yof2d=0;code9=!1;code10=-1;stackable=!1;cost=1;members=!1;op=null;iop=null;manwear=-1;manwear2=-1;manwearOffsetY=0;womanwear=-1;womanwear2=-1;womanwearOffsetY=0;manwear3=-1;womanwear3=-1;manhead=-1;manhead2=-1;womanhead=-1;womanhead2=-1;countobj=null;countco=null;certlink=-1;certtemplate=-1;wearpos=-1;wearpos2=-1;wearpos3=-1;weight=0;category=-1;dummyitem=0;tradeable=!1;respawnrate=100;params=new Map;decode(e,t){if(1===e)this.model=t.g2();else if(2===e)this.name=t.gjstr();else if(3===e)this.desc=t.gjstr();else if(4===e)this.zoom2d=t.g2();else if(5===e)this.xan2d=t.g2();else if(6===e)this.yan2d=t.g2();else if(7===e)this.xof2d=t.g2s();else if(8===e)this.yof2d=t.g2s();else if(9===e)this.code9=!0;else if(10===e)this.code10=t.g2();else if(11===e)this.stackable=!0;else if(12===e)this.cost=t.g4();else if(13===e)this.wearpos=t.g1();else if(14===e)this.wearpos2=t.g1();else if(16===e)this.members=!0;else if(23===e)this.manwear=t.g2(),this.manwearOffsetY=t.g1b();else if(24===e)this.manwear2=t.g2();else if(25===e)this.womanwear=t.g2(),this.womanwearOffsetY=t.g1b();else if(26===e)this.womanwear2=t.g2();else if(27===e)this.wearpos3=t.g1();else if(e>=30&&e<35)this.op||(this.op=new Array(5).fill(null)),this.op[e-30]=t.gjstr();else if(e>=35&&e<40)this.iop||(this.iop=new Array(5).fill(null)),this.iop[e-35]=t.gjstr();else if(40===e){const e=t.g1();this.recol_s=new Uint16Array(e),this.recol_d=new Uint16Array(e);for(let i=0;i=100&&e<110)this.countobj&&this.countco||(this.countobj=new Uint16Array(10),this.countco=new Uint16Array(10)),this.countobj[e-100]=t.g2(),this.countco[e-100]=t.g2();else if(200===e)this.tradeable=!0;else if(201===e)this.respawnrate=t.g2();else if(249===e)this.params=nt(t);else{if(250!==e)throw new Error(`Unrecognized obj config code: ${e}`);this.debugname=t.gjstr()}}toCertificate(){const t=e.get(this.certtemplate);this.model=t.model,this.zoom2d=t.zoom2d,this.xan2d=t.xan2d,this.yan2d=t.yan2d,this.zan2d=t.zan2d,this.xof2d=t.xof2d,this.yof2d=t.yof2d,this.recol_s=t.recol_s,this.recol_d=t.recol_d;const i=e.get(this.certlink);this.name=i.name,this.members=i.members,this.cost=i.cost,this.tradeable=i.tradeable;let r='a';const s=(i.name||'').toLowerCase().charAt(0);'a'!==s&&'e'!==s&&'i'!==s&&'o'!==s&&'u'!==s||(r='an'),this.desc=`Swap this note at any bank for ${r} ${i.name}.`,this.stackable=!0}},Ct=class e{static instances=[];static load(e){if(!fs15.existsSync(`${e}/server/frame_del.dat`))return void console.log('Warning: No frame_del.dat found.');const t=Oe.load(`${e}/server/frame_del.dat`);this.parse(t)}static async loadAsync(e){if(!(await fetch(`${e}/server/frame_del.dat`)).ok)return void console.log('Warning: No frame_del.dat found.');const t=await Oe.loadAsync(`${e}/server/frame_del.dat`);this.parse(t)}static parse(t){e.instances=[];for(let i=0;i=0&&s6)return 0;let t=0;for(let i=0;i=0;i++)if(Bt.isNumerical(e[i]))return i;return-1}indexOfNonNumber(e,t){for(let i=e;i=0;i++)if(!Bt.isNumerical(t[i]))return i;return t.length}},wt=class{wordEncFragments;bads=[];badCombinations=[];constructor(e){this.wordEncFragments=e}filter(e){for(let t=0;t<2;t++)for(let t=this.bads.length-1;t>=0;t--)this.filterBadCombinations(this.badCombinations[t],e,this.bads[t])}filterBadCombinations(e,t,i){if(!(i.length>t.length))for(let r=0;r<=t.length-i.length;r++){let s=r;const{currentIndex:n,badIndex:a,hasSymbol:o,hasNumber:c,hasDigit:l}=this.processBadCharacters(t,i,s);s=n;let h=t[s],d=s+1=i.length)||c&&l)continue;let u,p=!0;if(o){let e=!1,i=!1;if((r-1<0||Bt.isSymbol(t[r-1])&&"'"!=t[r-1])&&(e=!0),(s>=t.length||Bt.isSymbol(t[s])&&"'"!=t[s])&&(i=!0),!e||!i){let i=!1;for(u=r-2,e&&(u=r);!i&&u=0&&(!Bt.isSymbol(t[u])||"'"==t[u])){const e=[];let r;for(r=0;r<3&&u+r=0&&(!Bt.isSymbol(t[u-1])||"'"==t[u-1])&&(s=!1),s&&!this.wordEncFragments.isBadFragment(e)&&(i=!0)}u++}i||(p=!1)}}else{h=' ',r-1>=0&&(h=t[r-1]),d=' ',s=e.length||o&&c);){const l=e[r],h=r+10)1===d&&Bt.isNumerical(l)&&(o=!0),2===d&&(Bt.isNumerical(l)||Bt.isNumerical(h))&&(o=!0),r+=d,s++;else{if(0===s)break;let e;if((e=this.getEmulatedBadCharLen(h,String.fromCharCode(t[s-1]),l))>0)r+=e;else{if(s>=t.length||!Bt.isNotLowercaseAlpha(l))break;if(Bt.isSymbol(l)&&"'"!==l&&(a=!0),Bt.isNumerical(l)&&(c=!0),r++,n++,(100*n/(r-i)|0)>90)break}}}return{currentIndex:r,badIndex:s,hasSymbol:a,hasNumber:o,hasDigit:c}}getEmulatedBadCharLen(e,t,i){if(t==i)return 1;if(t>='a'&&t<='m'){if('a'==t)return'4'!=i&&'@'!=i&&'^'!=i?'/'==i&&'\\'==e?2:0:1;if('b'==t)return'6'!=i&&'8'!=i?'1'==i&&'3'==e?2:0:1;if('c'==t)return'('!=i&&'<'!=i&&'{'!=i&&'['!=i?0:1;if('d'==t)return'['==i&&')'==e?2:0;if('e'==t)return'3'!=i&&'€'!=i?0:1;if('f'==t)return'p'==i&&'h'==e?2:'£'==i?1:0;if('g'==t)return'9'!=i&&'6'!=i?0:1;if('h'==t)return'#'==i?1:0;if('i'==t)return'y'!=i&&'l'!=i&&'j'!=i&&'1'!=i&&'!'!=i&&':'!=i&&';'!=i&&'|'!=i?0:1;if('j'==t)return 0;if('k'==t)return 0;if('l'==t)return'1'!=i&&'|'!=i&&'i'!=i?0:1;if('m'==t)return 0}if(t>='n'&&t<='z'){if('n'==t)return 0;if('o'==t)return'0'!=i&&'*'!=i?'('==i&&')'==e||'['==i&&']'==e||'{'==i&&'}'==e||'<'==i&&'>'==e?2:0:1;if('p'==t)return 0;if('q'==t)return 0;if('r'==t)return 0;if('s'==t)return'5'!=i&&'z'!=i&&'$'!=i&&'2'!=i?0:1;if('t'==t)return'7'!=i&&'+'!=i?0:1;if('u'==t)return'v'==i?1:'\\'==i&&'/'==e||'\\'==i&&'|'==e||'|'==i&&'/'==e?2:0;if('v'==t)return'\\'==i&&'/'==e||'\\'==i&&'|'==e||'|'==i&&'/'==e?2:0;if('w'==t)return'v'==i&&'v'==e?2:0;if('x'==t)return')'==i&&'('==e||'}'==i&&'{'==e||']'==i&&'['==e||'>'==i&&'<'==e?2:0;if('y'==t)return 0;if('z'==t)return 0}return t>='0'&&t<='9'?'0'==t?'o'==i||'O'==i?1:'('==i&&')'==e||'{'==i&&'}'==e||'['==i&&']'==e?2:0:'1'==t&&'l'==i?1:0:','==t?'.'==i?1:0:'.'==t?','==i?1:0:'!'==t&&'i'==i?1:0}comboMatches(e,t,i){let r=0,s=t.length-1;for(;r<=s;){const n=(r+s)/2|0;if(t[n][0]===e&&t[n][1]===i)return!0;e=0;r--)this.filterDomain(i,t,this.domains[r],e)}getEmulatedDomainCharLen(e,t,i){return t==i||'o'==t&&'0'==i?1:'o'==t&&'('==i&&')'==e?2:'c'!=t||'('!=i&&'<'!=i&&'['!=i?'e'==t&&'€'==i||'s'==t&&'$'==i||'l'==t&&'i'==i?1:0:1}filterDomain(e,t,i,r){const s=i.length,n=r.length;for(let a=0;a<=n-s;a++){const{matched:s,currentIndex:n}=this.findMatchingDomain(a,i,r);if(!s)continue;const o=Bt.prefixSymbolStatus(a,r,3,t,['@']),c=Bt.suffixSymbolStatus(n-1,r,3,e,['.',',']);(o>2||c>2)&&Bt.maskChars(a,n,r)}}findMatchingDomain(e,t,i){const r=t.length;let s=e,n=0;for(;s0)s+=c,n++;else{if(0===n)break;const i=this.getEmulatedDomainCharLen(o,String.fromCharCode(t[n-1]),a);if(i>0)s+=i,1===n&&e++;else{if(n>=r||!Bt.isSymbol(a))break;s++}}}return{matched:n>=r,currentIndex:s}}},Rt=class{wordEncBadWords;wordEncDomains;tlds=[];tldTypes=[];constructor(e,t){this.wordEncBadWords=e,this.wordEncDomains=t}filter(e){const t=[...e],i=[...e];this.wordEncBadWords.filterBadCombinations(null,t,Bt.PERIOD),this.wordEncBadWords.filterBadCombinations(null,i,Bt.SLASH);for(let r=0;ri.length))for(let n=0;n<=i.length-r.length;n++){const{currentIndex:a,tldIndex:o}=this.processTlds(i,r,n);if(o0&&h>0&&(c=!0),2==t&&(l>2&&h>0||l>0&&h>2)&&(c=!0),3==t&&l>0&&h>2&&(c=!0),!c)continue;let d,u=n,p=a-1,f=!1;if(l>2){if(4==l)for(f=!1,d=n-1;d>=0;d--)if(f){if('*'!=s[d])break;u=d}else'*'==s[d]&&(u=d,f=!0);for(f=!1,d=u-1;d>=0;d--)if(f){if(Bt.isSymbol(i[d]))break;u=d}else Bt.isSymbol(i[d])||(f=!0,u=d)}if(h>2){if(4==h)for(f=!1,d=p+1;d0)i+=a,r++;else{if(0===r)break;let e;if((e=this.wordEncDomains.getEmulatedDomainCharLen(n,String.fromCharCode(t[r-1]),s))>0)i+=e;else{if(!Bt.isSymbol(s))break;i++}}}return{currentIndex:i,tldIndex:r}}},Bt=class e{static PERIOD=new Uint16Array(['d','o','t'].join('').split('').map((e=>e.charCodeAt(0))));static AMPERSAT=new Uint16Array(['(','a',')'].join('').split('').map((e=>e.charCodeAt(0))));static SLASH=new Uint16Array(['s','l','a','s','h'].join('').split('').map((e=>e.charCodeAt(0))));static wordEncFragments=new Pt;static wordEncBadWords=new wt(this.wordEncFragments);static wordEncDomains=new bt(this.wordEncBadWords);static wordEncTlds=new Rt(this.wordEncBadWords,this.wordEncDomains);static whitelist=['cook',"cook's",'cooks','seeks','sheet'];static async load(e){if(!fs21.existsSync(`${e}/client/wordenc`))return void console.log('Warning: No wordenc found.');const t=Fe.load(`${e}/client/wordenc`);this.readAll(t)}static async loadAsync(e){if(!(await fetch(`${e}/client/wordenc`)).ok)return void console.log('Warning: No wordenc found.');const t=await Fe.loadAsync(`${e}/client/wordenc`);this.readAll(t)}static readAll(e){const t=e.read('fragmentsenc.txt');if(!t)return void console.log('Warning: No fragmentsenc found.');const i=e.read('badenc.txt');if(!i)return void console.log('Warning: No badenc found.');const r=e.read('domainenc.txt');if(!r)return void console.log('Warning: No domainenc found.');const s=e.read('tldlist.txt');s?(this.decodeBadEnc(i),this.decodeDomainEnc(r),this.decodeFragmentsEnc(t),this.decodeTldList(s)):console.log('Warning: No tldlist found.')}static filter(e){const t=[...e];this.format(t);const i=t.join('').trim(),r=i.toLowerCase(),s=[...r];this.wordEncTlds.filter(s),this.wordEncBadWords.filter(s),this.wordEncDomains.filter(s),this.wordEncFragments.filter(s);for(let e=0;e='0'&&e<='9'}static isLowercaseAlpha(e){return e>='a'&&e<='z'}static isUppercaseAlpha(e){return e>='A'&&e<='Z'}static isNumericalChars(e){for(let t=0;t=0&&e.isSymbol(t[s]);s--)'*'===t[s]&&r++;return r}static maskedCountForwards(e,t){let i=0;for(let r=t+1;r=r?4:this.isSymbol(s?e[i-1]:e[i+1])?1:0}static prefixSymbolStatus(t,i,r,s,n){if(0===t)return 2;for(let r=t-1;r>=0&&e.isSymbol(i[r]);r--)if(n.includes(i[r]))return 3;return e.maskedCharsStatus(i,s,t,r,!0)}static suffixSymbolStatus(t,i,r,s,n){if(t+1===i.length)return 2;for(let r=t+1;re.g1()))}static decodeBadEnc(e){const t=e.g4();for(let i=0;ie.g1()));const t=new Array(e.g1()).fill([]).map((()=>[e.g1b(),e.g1b()]));t.length>0&&(this.wordEncBadWords.badCombinations[i]=t)}}static decodeDomainEnc(e){const t=e.g4();for(let i=0;ie.g1()))}static decodeFragmentsEnc(e){const t=e.g4();for(let i=0;i=' '&&e<=''||' '==e||'\n'==e||'\t'==e||'£'==e||'€'==e}static replaceUppercases(e,t){for(let i=0;i=40&&e<50)this.recol_s[e-40]=t.g2();else if(e>=50&&e<60)this.recol_d[e-50]=t.g2();else{if(250!==e)throw new Error(`Unrecognized spotanim config code: ${e}`);this.debugname=t.gjstr()}}},Dt=(e=>(e[e.ActivePlayer=0]='ActivePlayer',e[e.ActivePlayer2=1]='ActivePlayer2',e[e.ProtectedActivePlayer=2]='ProtectedActivePlayer',e[e.ProtectedActivePlayer2=3]='ProtectedActivePlayer2',e[e.ActiveNpc=4]='ActiveNpc',e[e.ActiveNpc2=5]='ActiveNpc2',e[e.ActiveLoc=6]='ActiveLoc',e[e.ActiveLoc2=7]='ActiveLoc2',e[e.ActiveObj=8]='ActiveObj',e[e.ActiveObj2=9]='ActiveObj2',e[e._LAST=10]='_LAST',e))(Dt||{}),kt=[4,5],Mt=[6,7],xt=[8,9],Ft=[0,1],Ht=[2,3];function Vt(e,t){return function(i){'number'==typeof e?i.pointerCheck(e):i.pointerCheck(e[i.intOperand]),t(i)}}var Gt=Dt,Wt=(e=>(e[e.PUSH_CONSTANT_INT=0]='PUSH_CONSTANT_INT',e[e.PUSH_VARP=1]='PUSH_VARP',e[e.POP_VARP=2]='POP_VARP',e[e.PUSH_CONSTANT_STRING=3]='PUSH_CONSTANT_STRING',e[e.PUSH_VARN=4]='PUSH_VARN',e[e.POP_VARN=5]='POP_VARN',e[e.BRANCH=6]='BRANCH',e[e.BRANCH_NOT=7]='BRANCH_NOT',e[e.BRANCH_EQUALS=8]='BRANCH_EQUALS',e[e.BRANCH_LESS_THAN=9]='BRANCH_LESS_THAN',e[e.BRANCH_GREATER_THAN=10]='BRANCH_GREATER_THAN',e[e.PUSH_VARS=11]='PUSH_VARS',e[e.POP_VARS=12]='POP_VARS',e[e.RETURN=21]='RETURN',e[e.GOSUB=22]='GOSUB',e[e.JUMP=23]='JUMP',e[e.SWITCH=24]='SWITCH',e[e.BRANCH_LESS_THAN_OR_EQUALS=31]='BRANCH_LESS_THAN_OR_EQUALS',e[e.BRANCH_GREATER_THAN_OR_EQUALS=32]='BRANCH_GREATER_THAN_OR_EQUALS',e[e.PUSH_INT_LOCAL=33]='PUSH_INT_LOCAL',e[e.POP_INT_LOCAL=34]='POP_INT_LOCAL',e[e.PUSH_STRING_LOCAL=35]='PUSH_STRING_LOCAL',e[e.POP_STRING_LOCAL=36]='POP_STRING_LOCAL',e[e.JOIN_STRING=37]='JOIN_STRING',e[e.POP_INT_DISCARD=38]='POP_INT_DISCARD',e[e.POP_STRING_DISCARD=39]='POP_STRING_DISCARD',e[e.GOSUB_WITH_PARAMS=40]='GOSUB_WITH_PARAMS',e[e.JUMP_WITH_PARAMS=41]='JUMP_WITH_PARAMS',e[e.DEFINE_ARRAY=44]='DEFINE_ARRAY',e[e.PUSH_ARRAY_INT=45]='PUSH_ARRAY_INT',e[e.POP_ARRAY_INT=46]='POP_ARRAY_INT',e[e.COORDX=1e3]='COORDX',e[e.COORDY=1001]='COORDY',e[e.COORDZ=1002]='COORDZ',e[e.DISTANCE=1003]='DISTANCE',e[e.HUNTALL=1004]='HUNTALL',e[e.HUNTNEXT=1005]='HUNTNEXT',e[e.INZONE=1006]='INZONE',e[e.LINEOFSIGHT=1007]='LINEOFSIGHT',e[e.LINEOFWALK=1008]='LINEOFWALK',e[e.MAP_BLOCKED=1009]='MAP_BLOCKED',e[e.MAP_INDOORS=1010]='MAP_INDOORS',e[e.MAP_CLOCK=1011]='MAP_CLOCK',e[e.MAP_LOCADDUNSAFE=1012]='MAP_LOCADDUNSAFE',e[e.MAP_MEMBERS=1013]='MAP_MEMBERS',e[e.MAP_PLAYERCOUNT=1014]='MAP_PLAYERCOUNT',e[e.MOVECOORD=1015]='MOVECOORD',e[e.PLAYERCOUNT=1016]='PLAYERCOUNT',e[e.PROJANIM_MAP=1017]='PROJANIM_MAP',e[e.PROJANIM_NPC=1018]='PROJANIM_NPC',e[e.PROJANIM_PL=1019]='PROJANIM_PL',e[e.SEQLENGTH=1020]='SEQLENGTH',e[e.SPLIT_GET=1021]='SPLIT_GET',e[e.SPLIT_GETANIM=1022]='SPLIT_GETANIM',e[e.SPLIT_INIT=1023]='SPLIT_INIT',e[e.SPLIT_LINECOUNT=1024]='SPLIT_LINECOUNT',e[e.SPLIT_PAGECOUNT=1025]='SPLIT_PAGECOUNT',e[e.SPOTANIM_MAP=1026]='SPOTANIM_MAP',e[e.STAT_RANDOM=1027]='STAT_RANDOM',e[e.STRUCT_PARAM=1028]='STRUCT_PARAM',e[e.WORLD_DELAY=1029]='WORLD_DELAY',e[e.NPCCOUNT=1030]='NPCCOUNT',e[e.ZONECOUNT=1031]='ZONECOUNT',e[e.LOCCOUNT=1032]='LOCCOUNT',e[e.OBJCOUNT=1033]='OBJCOUNT',e[e.ALLOWDESIGN=2e3]='ALLOWDESIGN',e[e.ANIM=2001]='ANIM',e[e.BAS_READYANIM=2002]='BAS_READYANIM',e[e.BAS_RUNNING=2003]='BAS_RUNNING',e[e.BAS_TURNONSPOT=2004]='BAS_TURNONSPOT',e[e.BAS_WALK_B=2005]='BAS_WALK_B',e[e.BAS_WALK_F=2006]='BAS_WALK_F',e[e.BAS_WALK_L=2007]='BAS_WALK_L',e[e.BAS_WALK_R=2008]='BAS_WALK_R',e[e.BUFFER_FULL=2009]='BUFFER_FULL',e[e.BUILDAPPEARANCE=2010]='BUILDAPPEARANCE',e[e.BUSY=2011]='BUSY',e[e.CAM_LOOKAT=2012]='CAM_LOOKAT',e[e.CAM_MOVETO=2013]='CAM_MOVETO',e[e.CAM_RESET=2014]='CAM_RESET',e[e.CAM_SHAKE=2015]='CAM_SHAKE',e[e.CLEARQUEUE=2016]='CLEARQUEUE',e[e.CLEARSOFTTIMER=2017]='CLEARSOFTTIMER',e[e.CLEARTIMER=2018]='CLEARTIMER',e[e.COORD=2019]='COORD',e[e.DAMAGE=2020]='DAMAGE',e[e.DISPLAYNAME=2021]='DISPLAYNAME',e[e.FACESQUARE=2022]='FACESQUARE',e[e.FINDUID=2023]='FINDUID',e[e.GENDER=2024]='GENDER',e[e.GETQUEUE=2025]='GETQUEUE',e[e.GIVEXP=2026]='GIVEXP',e[e.HEADICONS_GET=2027]='HEADICONS_GET',e[e.HEADICONS_SET=2028]='HEADICONS_SET',e[e.HEALENERGY=2029]='HEALENERGY',e[e.HINT_COORD=2030]='HINT_COORD',e[e.HINT_NPC=2031]='HINT_NPC',e[e.HINT_PLAYER=2032]='HINT_PLAYER',e[e.HINT_STOP=2033]='HINT_STOP',e[e.IF_CLOSE=2034]='IF_CLOSE',e[e.IF_CLOSESTICKY=2035]='IF_CLOSESTICKY',e[e.IF_MULTIZONE=2036]='IF_MULTIZONE',e[e.IF_OPENCHAT=2037]='IF_OPENCHAT',e[e.IF_OPENCHATSTICKY=2038]='IF_OPENCHATSTICKY',e[e.IF_OPENMAINMODAL=2039]='IF_OPENMAINMODAL',e[e.IF_OPENMAINMODALSIDEOVERLAY=2040]='IF_OPENMAINMODALSIDEOVERLAY',e[e.IF_OPENSIDEOVERLAY=2041]='IF_OPENSIDEOVERLAY',e[e.IF_SETANIM=2042]='IF_SETANIM',e[e.IF_SETCOLOUR=2043]='IF_SETCOLOUR',e[e.IF_SETHIDE=2044]='IF_SETHIDE',e[e.IF_SETMODEL=2045]='IF_SETMODEL',e[e.IF_SETRECOL=2046]='IF_SETRECOL',e[e.IF_SETNPCHEAD=2047]='IF_SETNPCHEAD',e[e.IF_SETOBJECT=2048]='IF_SETOBJECT',e[e.IF_SETPLAYERHEAD=2049]='IF_SETPLAYERHEAD',e[e.IF_SETPOSITION=2050]='IF_SETPOSITION',e[e.IF_SETRESUMEBUTTONS=2051]='IF_SETRESUMEBUTTONS',e[e.IF_SETTAB=2052]='IF_SETTAB',e[e.IF_SETTABACTIVE=2053]='IF_SETTABACTIVE',e[e.IF_SETTABFLASH=2054]='IF_SETTABFLASH',e[e.IF_SETTEXT=2055]='IF_SETTEXT',e[e.LAST_LOGIN_INFO=2056]='LAST_LOGIN_INFO',e[e.LAST_COM=2057]='LAST_COM',e[e.LAST_INT=2058]='LAST_INT',e[e.LAST_ITEM=2059]='LAST_ITEM',e[e.LAST_SLOT=2060]='LAST_SLOT',e[e.LAST_TARGETSLOT=2061]='LAST_TARGETSLOT',e[e.LAST_USEITEM=2062]='LAST_USEITEM',e[e.LAST_USESLOT=2063]='LAST_USESLOT',e[e.LONGQUEUE=2064]='LONGQUEUE',e[e.MES=2065]='MES',e[e.MIDI_JINGLE=2066]='MIDI_JINGLE',e[e.MIDI_SONG=2067]='MIDI_SONG',e[e.NAME=2068]='NAME',e[e.P_APRANGE=2069]='P_APRANGE',e[e.P_ARRIVEDELAY=2070]='P_ARRIVEDELAY',e[e.P_COUNTDIALOG=2071]='P_COUNTDIALOG',e[e.P_DELAY=2072]='P_DELAY',e[e.P_EXACTMOVE=2073]='P_EXACTMOVE',e[e.P_FINDUID=2074]='P_FINDUID',e[e.P_LOCMERGE=2075]='P_LOCMERGE',e[e.P_LOGOUT=2076]='P_LOGOUT',e[e.P_OPHELD=2077]='P_OPHELD',e[e.P_OPLOC=2078]='P_OPLOC',e[e.P_OPNPC=2079]='P_OPNPC',e[e.P_OPNPCT=2080]='P_OPNPCT',e[e.P_OPOBJ=2081]='P_OPOBJ',e[e.P_OPPLAYER=2082]='P_OPPLAYER',e[e.P_OPPLAYERT=2083]='P_OPPLAYERT',e[e.P_PAUSEBUTTON=2084]='P_PAUSEBUTTON',e[e.P_STOPACTION=2085]='P_STOPACTION',e[e.P_TELEJUMP=2086]='P_TELEJUMP',e[e.P_TELEPORT=2087]='P_TELEPORT',e[e.P_WALK=2088]='P_WALK',e[e.PLAYER_FINDALLZONE=2089]='PLAYER_FINDALLZONE',e[e.PLAYER_FINDNEXT=2090]='PLAYER_FINDNEXT',e[e.QUEUE=2091]='QUEUE',e[e.SAY=2092]='SAY',e[e.WALKTRIGGER=2093]='WALKTRIGGER',e[e.SETTIMER=2094]='SETTIMER',e[e.SOFTTIMER=2095]='SOFTTIMER',e[e.SOUND_SYNTH=2096]='SOUND_SYNTH',e[e.SPOTANIM_PL=2097]='SPOTANIM_PL',e[e.STAFFMODLEVEL=2098]='STAFFMODLEVEL',e[e.STAT=2099]='STAT',e[e.STAT_ADD=2100]='STAT_ADD',e[e.STAT_BASE=2101]='STAT_BASE',e[e.STAT_HEAL=2102]='STAT_HEAL',e[e.STAT_SUB=2103]='STAT_SUB',e[e.STRONGQUEUE=2104]='STRONGQUEUE',e[e.UID=2105]='UID',e[e.WEAKQUEUE=2106]='WEAKQUEUE',e[e.IF_OPENMAINOVERLAY=2107]='IF_OPENMAINOVERLAY',e[e.AFK_EVENT=2108]='AFK_EVENT',e[e.LOWMEMORY=2109]='LOWMEMORY',e[e.SETIDKIT=2110]='SETIDKIT',e[e.P_CLEARPENDINGACTION=2111]='P_CLEARPENDINGACTION',e[e.GETWALKTRIGGER=2112]='GETWALKTRIGGER',e[e.BUSY2=2113]='BUSY2',e[e.FINDHERO=2114]='FINDHERO',e[e.BOTH_HEROPOINTS=2115]='BOTH_HEROPOINTS',e[e.SETGENDER=2116]='SETGENDER',e[e.SETSKINCOLOUR=2117]='SETSKINCOLOUR',e[e.P_ANIMPROTECT=2118]='P_ANIMPROTECT',e[e.RUNENERGY=2119]='RUNENERGY',e[e.WEIGHT=2120]='WEIGHT',e[e.LAST_COORD=2121]='LAST_COORD',e[e.NPC_ADD=2500]='NPC_ADD',e[e.NPC_ANIM=2501]='NPC_ANIM',e[e.NPC_BASESTAT=2502]='NPC_BASESTAT',e[e.NPC_CATEGORY=2503]='NPC_CATEGORY',e[e.NPC_CHANGETYPE=2504]='NPC_CHANGETYPE',e[e.NPC_COORD=2505]='NPC_COORD',e[e.NPC_DAMAGE=2506]='NPC_DAMAGE',e[e.NPC_DEL=2507]='NPC_DEL',e[e.NPC_DELAY=2508]='NPC_DELAY',e[e.NPC_FACESQUARE=2509]='NPC_FACESQUARE',e[e.NPC_FIND=2510]='NPC_FIND',e[e.NPC_FINDALLANY=2511]='NPC_FINDALLANY',e[e.NPC_FINDEXACT=2512]='NPC_FINDEXACT',e[e.NPC_FINDHERO=2513]='NPC_FINDHERO',e[e.NPC_FINDALLZONE=2514]='NPC_FINDALLZONE',e[e.NPC_FINDNEXT=2515]='NPC_FINDNEXT',e[e.NPC_FINDUID=2516]='NPC_FINDUID',e[e.NPC_GETMODE=2517]='NPC_GETMODE',e[e.NPC_HEROPOINTS=2518]='NPC_HEROPOINTS',e[e.NPC_NAME=2519]='NPC_NAME',e[e.NPC_PARAM=2520]='NPC_PARAM',e[e.NPC_QUEUE=2521]='NPC_QUEUE',e[e.NPC_RANGE=2522]='NPC_RANGE',e[e.NPC_SAY=2523]='NPC_SAY',e[e.NPC_HUNTALL=2524]='NPC_HUNTALL',e[e.NPC_HUNTNEXT=2525]='NPC_HUNTNEXT',e[e.NPC_SETHUNT=2526]='NPC_SETHUNT',e[e.NPC_SETHUNTMODE=2527]='NPC_SETHUNTMODE',e[e.NPC_SETMODE=2528]='NPC_SETMODE',e[e.NPC_WALKTRIGGER=2529]='NPC_WALKTRIGGER',e[e.NPC_SETTIMER=2530]='NPC_SETTIMER',e[e.NPC_STAT=2531]='NPC_STAT',e[e.NPC_STATADD=2532]='NPC_STATADD',e[e.NPC_STATHEAL=2533]='NPC_STATHEAL',e[e.NPC_STATSUB=2534]='NPC_STATSUB',e[e.NPC_TELE=2535]='NPC_TELE',e[e.NPC_TYPE=2536]='NPC_TYPE',e[e.NPC_UID=2537]='NPC_UID',e[e.SPOTANIM_NPC=2538]='SPOTANIM_NPC',e[e.NPC_WALK=2539]='NPC_WALK',e[e.NPC_ATTACKRANGE=2540]='NPC_ATTACKRANGE',e[e.LOC_ADD=3e3]='LOC_ADD',e[e.LOC_ANGLE=3001]='LOC_ANGLE',e[e.LOC_ANIM=3002]='LOC_ANIM',e[e.LOC_CATEGORY=3003]='LOC_CATEGORY',e[e.LOC_CHANGE=3004]='LOC_CHANGE',e[e.LOC_COORD=3005]='LOC_COORD',e[e.LOC_DEL=3006]='LOC_DEL',e[e.LOC_FIND=3007]='LOC_FIND',e[e.LOC_FINDALLZONE=3008]='LOC_FINDALLZONE',e[e.LOC_FINDNEXT=3009]='LOC_FINDNEXT',e[e.LOC_NAME=3010]='LOC_NAME',e[e.LOC_PARAM=3011]='LOC_PARAM',e[e.LOC_SHAPE=3012]='LOC_SHAPE',e[e.LOC_TYPE=3013]='LOC_TYPE',e[e.OBJ_ADD=3500]='OBJ_ADD',e[e.OBJ_ADDALL=3501]='OBJ_ADDALL',e[e.OBJ_COORD=3502]='OBJ_COORD',e[e.OBJ_COUNT=3503]='OBJ_COUNT',e[e.OBJ_DEL=3504]='OBJ_DEL',e[e.OBJ_NAME=3505]='OBJ_NAME',e[e.OBJ_PARAM=3506]='OBJ_PARAM',e[e.OBJ_TAKEITEM=3507]='OBJ_TAKEITEM',e[e.OBJ_TYPE=3508]='OBJ_TYPE',e[e.NC_CATEGORY=4e3]='NC_CATEGORY',e[e.NC_DEBUGNAME=4001]='NC_DEBUGNAME',e[e.NC_DESC=4002]='NC_DESC',e[e.NC_NAME=4003]='NC_NAME',e[e.NC_OP=4004]='NC_OP',e[e.NC_PARAM=4005]='NC_PARAM',e[e.LC_CATEGORY=4100]='LC_CATEGORY',e[e.LC_DEBUGNAME=4101]='LC_DEBUGNAME',e[e.LC_DESC=4102]='LC_DESC',e[e.LC_NAME=4103]='LC_NAME',e[e.LC_OP=4104]='LC_OP',e[e.LC_PARAM=4105]='LC_PARAM',e[e.LC_WIDTH=4106]='LC_WIDTH',e[e.LC_LENGTH=4107]='LC_LENGTH',e[e.OC_CATEGORY=4200]='OC_CATEGORY',e[e.OC_CERT=4201]='OC_CERT',e[e.OC_COST=4202]='OC_COST',e[e.OC_DEBUGNAME=4203]='OC_DEBUGNAME',e[e.OC_DESC=4204]='OC_DESC',e[e.OC_IOP=4205]='OC_IOP',e[e.OC_MEMBERS=4206]='OC_MEMBERS',e[e.OC_NAME=4207]='OC_NAME',e[e.OC_OP=4208]='OC_OP',e[e.OC_PARAM=4209]='OC_PARAM',e[e.OC_STACKABLE=4210]='OC_STACKABLE',e[e.OC_TRADEABLE=4211]='OC_TRADEABLE',e[e.OC_UNCERT=4212]='OC_UNCERT',e[e.OC_WEARPOS2=4213]='OC_WEARPOS2',e[e.OC_WEARPOS3=4214]='OC_WEARPOS3',e[e.OC_WEARPOS=4215]='OC_WEARPOS',e[e.OC_WEIGHT=4216]='OC_WEIGHT',e[e.INV_ALLSTOCK=4300]='INV_ALLSTOCK',e[e.INV_SIZE=4301]='INV_SIZE',e[e.INV_STOCKBASE=4302]='INV_STOCKBASE',e[e.INV_ADD=4303]='INV_ADD',e[e.INV_CHANGESLOT=4304]='INV_CHANGESLOT',e[e.INV_CLEAR=4305]='INV_CLEAR',e[e.INV_DEL=4306]='INV_DEL',e[e.INV_DELSLOT=4307]='INV_DELSLOT',e[e.INV_DROPITEM=4308]='INV_DROPITEM',e[e.INV_DROPSLOT=4309]='INV_DROPSLOT',e[e.INV_FREESPACE=4310]='INV_FREESPACE',e[e.INV_GETNUM=4311]='INV_GETNUM',e[e.INV_GETOBJ=4312]='INV_GETOBJ',e[e.INV_ITEMSPACE=4313]='INV_ITEMSPACE',e[e.INV_ITEMSPACE2=4314]='INV_ITEMSPACE2',e[e.INV_MOVEFROMSLOT=4315]='INV_MOVEFROMSLOT',e[e.INV_MOVETOSLOT=4316]='INV_MOVETOSLOT',e[e.BOTH_MOVEINV=4317]='BOTH_MOVEINV',e[e.INV_MOVEITEM=4318]='INV_MOVEITEM',e[e.INV_MOVEITEM_CERT=4319]='INV_MOVEITEM_CERT',e[e.INV_MOVEITEM_UNCERT=4320]='INV_MOVEITEM_UNCERT',e[e.INV_SETSLOT=4321]='INV_SETSLOT',e[e.INV_TOTAL=4322]='INV_TOTAL',e[e.INV_TOTALCAT=4323]='INV_TOTALCAT',e[e.INV_TRANSMIT=4324]='INV_TRANSMIT',e[e.INVOTHER_TRANSMIT=4325]='INVOTHER_TRANSMIT',e[e.INV_STOPTRANSMIT=4326]='INV_STOPTRANSMIT',e[e.BOTH_DROPSLOT=4327]='BOTH_DROPSLOT',e[e.INV_DROPALL=4328]='INV_DROPALL',e[e.INV_TOTALPARAM=4329]='INV_TOTALPARAM',e[e.INV_TOTALPARAM_STACK=4330]='INV_TOTALPARAM_STACK',e[e.ENUM=4400]='ENUM',e[e.ENUM_GETOUTPUTCOUNT=4401]='ENUM_GETOUTPUTCOUNT',e[e.APPEND_NUM=4500]='APPEND_NUM',e[e.APPEND=4501]='APPEND',e[e.APPEND_SIGNNUM=4502]='APPEND_SIGNNUM',e[e.LOWERCASE=4503]='LOWERCASE',e[e.TEXT_GENDER=4504]='TEXT_GENDER',e[e.TOSTRING=4505]='TOSTRING',e[e.COMPARE=4506]='COMPARE',e[e.TEXT_SWITCH=4507]='TEXT_SWITCH',e[e.APPEND_CHAR=4508]='APPEND_CHAR',e[e.STRING_LENGTH=4509]='STRING_LENGTH',e[e.SUBSTRING=4510]='SUBSTRING',e[e.STRING_INDEXOF_CHAR=4511]='STRING_INDEXOF_CHAR',e[e.STRING_INDEXOF_STRING=4512]='STRING_INDEXOF_STRING',e[e.ADD=4600]='ADD',e[e.SUB=4601]='SUB',e[e.MULTIPLY=4602]='MULTIPLY',e[e.DIVIDE=4603]='DIVIDE',e[e.RANDOM=4604]='RANDOM',e[e.RANDOMINC=4605]='RANDOMINC',e[e.INTERPOLATE=4606]='INTERPOLATE',e[e.ADDPERCENT=4607]='ADDPERCENT',e[e.SETBIT=4608]='SETBIT',e[e.CLEARBIT=4609]='CLEARBIT',e[e.TESTBIT=4610]='TESTBIT',e[e.MODULO=4611]='MODULO',e[e.POW=4612]='POW',e[e.INVPOW=4613]='INVPOW',e[e.AND=4614]='AND',e[e.OR=4615]='OR',e[e.MIN=4616]='MIN',e[e.MAX=4617]='MAX',e[e.SCALE=4618]='SCALE',e[e.BITCOUNT=4619]='BITCOUNT',e[e.TOGGLEBIT=4620]='TOGGLEBIT',e[e.SETBIT_RANGE=4621]='SETBIT_RANGE',e[e.CLEARBIT_RANGE=4622]='CLEARBIT_RANGE',e[e.GETBIT_RANGE=4623]='GETBIT_RANGE',e[e.SETBIT_RANGE_TOINT=4624]='SETBIT_RANGE_TOINT',e[e.SIN_DEG=4625]='SIN_DEG',e[e.COS_DEG=4626]='COS_DEG',e[e.ATAN2_DEG=4627]='ATAN2_DEG',e[e.ABS=4628]='ABS',e[e.DB_FIND_WITH_COUNT=7500]='DB_FIND_WITH_COUNT',e[e.DB_FINDNEXT=7501]='DB_FINDNEXT',e[e.DB_GETFIELD=7502]='DB_GETFIELD',e[e.DB_GETFIELDCOUNT=7503]='DB_GETFIELDCOUNT',e[e.DB_LISTALL_WITH_COUNT=7504]='DB_LISTALL_WITH_COUNT',e[e.DB_GETROWTABLE=7505]='DB_GETROWTABLE',e[e.DB_FINDBYINDEX=7506]='DB_FINDBYINDEX',e[e.DB_FIND_REFINE_WITH_COUNT=7507]='DB_FIND_REFINE_WITH_COUNT',e[e.DB_FIND=7508]='DB_FIND',e[e.DB_FIND_REFINE=7509]='DB_FIND_REFINE',e[e.DB_LISTALL=7510]='DB_LISTALL',e[e.ERROR=1e4]='ERROR',e[e.MAP_PRODUCTION=10001]='MAP_PRODUCTION',e[e.MAP_LASTCLOCK=10002]='MAP_LASTCLOCK',e[e.MAP_LASTWORLD=10003]='MAP_LASTWORLD',e[e.MAP_LASTCLIENTIN=10004]='MAP_LASTCLIENTIN',e[e.MAP_LASTNPC=10005]='MAP_LASTNPC',e[e.MAP_LASTPLAYER=10006]='MAP_LASTPLAYER',e[e.MAP_LASTLOGOUT=10007]='MAP_LASTLOGOUT',e[e.MAP_LASTLOGIN=10008]='MAP_LASTLOGIN',e[e.MAP_LASTZONE=10009]='MAP_LASTZONE',e[e.MAP_LASTCLIENTOUT=10010]='MAP_LASTCLIENTOUT',e[e.MAP_LASTCLEANUP=10011]='MAP_LASTCLEANUP',e[e.MAP_LASTBANDWIDTHIN=10012]='MAP_LASTBANDWIDTHIN',e[e.MAP_LASTBANDWIDTHOUT=10013]='MAP_LASTBANDWIDTHOUT',e))(Wt||{}),Kt=Wt,zt=class e{info={scriptName:'',sourceFilePath:'',lookupKey:-1,parameterTypes:[],pcs:[],lines:[]};id;intLocalCount=0;stringLocalCount=0;intArgCount=0;stringArgCount=0;switchTables=[];opcodes=[];intOperands=[];stringOperands=[];static isLargeOperand(e){if(e>100)return!1;switch(e){case Kt.RETURN:case Kt.POP_INT_DISCARD:case Kt.POP_STRING_DISCARD:case Kt.GOSUB:case Kt.JUMP:return!1}return!0}static decode(t,i){const r=i.data.length;if(r<16)throw new Error('Invalid script file (minimum length)');i.pos=r-2;const s=r-i.g2()-12-2;if(s<0||s>=r)throw new Error('Invalid script file (bad trailer pos)');i.pos=s;const n=new e(t);i.g4();n.intLocalCount=i.g2(),n.stringLocalCount=i.g2(),n.intArgCount=i.g2(),n.stringArgCount=i.g2();const a=i.g1();for(let e=0;ei.pos;){const t=i.g2();t===Kt.PUSH_CONSTANT_STRING?n.stringOperands[l]=i.gjstr(0):e.isLargeOperand(t)?n.intOperands[l]=i.g4():n.intOperands[l]=i.g1(),n.opcodes[l++]=t}return n}constructor(e){this.id=e}get name(){return this.info.scriptName}get fileName(){return path2.basename(this.info.sourceFilePath)}lineNumber(e){for(let t=0;te)return this.info.lines[t-1];return this.info.lines[this.info.lines.length-1]}},jt=class e{static COMPILER_VERSION=18;static scripts=[];static scriptLookup=new Map;static scriptNames=new Map;static load(e){const t=Oe.load(`${e}/server/script.dat`),i=Oe.load(`${e}/server/script.idx`);return this.parse(t,i)}static async loadAsync(e){const t=await Oe.loadAsync(`${e}/server/script.dat`),i=await Oe.loadAsync(`${e}/server/script.idx`);return this.parse(t,i)}static parse(t,i){t.data.length&&i.data.length||(console.log('\nFatal: No script.dat or script.idx found. Please run the server:build script.'),process.exit(1));const r=t.g2();i.pos+=2;t.g4()!==e.COMPILER_VERSION&&(console.error('\nFatal: Scripts were compiled with an older RuneScript compiler. Please update it, try `npm run build` and then restart the server.'),process.exit(1));const s=new Array(r),n=new Map,a=new Map;let o=0;for(let e=0;e=0;i--)t[i]=this.popInt();return t}pushInt(e){this.intStack[this.isp++]=qt(e)}popString(){return this.stringStack[--this.ssp]??''}popStrings(e){const t=Array(e);for(let i=e-1;i>=0;i--)t[i]=this.popString();return t}pushString(e){this.stringStack[this.ssp++]=e}reset(){this.pc=-1,this.frames=[],this.fp=0,this.intStack=[],this.isp=0,this.stringStack=[],this.ssp=0,this.intLocals=[],this.stringLocals=[],this.pointers=0}},Zt=class{requested=0;completed=0;items=[];constructor(e,t=0,i=[]){this.requested=e,this.completed=t,this.items=i}getLeftOver(){return this.requested-this.completed}hasSucceeded(){return this.completed==this.requested}hasFailed(){return!this.hasSucceeded()}revert(e){for(let t=0;tt&&t.id==e))}hasAt(e,t){const i=this.items[e];return i&&i.id==t}get nextFreeSlot(){return this.items.indexOf(null,0)}get freeSlotCount(){return this.items.filter((e=>null==e)).length}get occupiedSlotCount(){return this.items.filter((e=>null!=e)).length}get isFull(){return this.occupiedSlotCount==this.capacity}get isEmpty(){return 0==this.occupiedSlotCount}get hasAny(){return this.items.some((e=>null!=e))}get hasSpace(){return-1!=this.nextFreeSlot}get itemsFiltered(){return this.items.filter((e=>null!=e))}getItemCount(t){let i=0;for(let e=0;et&&t.id==e))}removeAll(){this.items.fill(null,0,this.capacity),this.update=!0}add(t,i=1,r=-1,s=!0,n=!1,a=!1){const o=Tt.get(t),c=!0===it.get(this.type).stockobj?.includes(t),l=!n&&this.stackType!=e.NEVER_STACK&&(o.stackable||this.stackType==e.ALWAYS_STACK);let h=0;if(l&&(h=this.getItemCount(t)),h==e.STACK_LIMIT)return new Zt(i,0,[]);const d=this.freeSlotCount;if(0==d&&(!l||l&&0==h&&!c))return new Zt(i,0,[]);if(s){if(l&&h>e.STACK_LIMIT-i)return new Zt(i,0,[]);if(!l&&i>d)return new Zt(i,0,[])}else{if(l&&h==e.STACK_LIMIT)return new Zt(i,0,[]);if(!l&&0==d)return new Zt(i,0,[])}let u=0;const p=[];if(l){let s=this.getItemIndex(t);if(-1==s&&(s=-1==r?this.nextFreeSlot:this.items.indexOf(null,r),-1==s))return new Zt(i,u,[]);const n=this.get(s)?.count??0,o=Math.min(e.STACK_LIMIT,n+i),c={id:t,count:o};a||this.set(s,c),p.push({slot:s,item:c}),u=o-n}else{for(let e=Math.max(0,r);e=i)break}}return new Zt(i,u,p)}remove(e,t=1,i=-1,r=!1){const s=this.getItemCount(e),n=!0===it.get(this.type).stockobj?.includes(e);if(r&&s=t)break}if(null!=c&&a=t)break}return a>0&&(this.update=!0),new Zt(t,a,o)}delete(e){this.items[e]=null,this.update=!0}swap(e,t){const i=this.items[e];this.set(e,this.items[t]),this.set(t,i)}shift(){this.items.sort(((e,t)=>null===e||null===t?+(null===e)-+(null===t):+(e>t)||-(e=0&&e=0)&&(c={id:o.certlink,count:a});const l=e.add(c.id,c.count,r,!1);if(0==l.completed)return null;const h=this.remove(t.id,l.completed,i,!1);return 0==h.completed?null:h}};async function Jt(e,t={}){const i={env:Object.assign(Object.create(globalThis),t.env||{},{abort(e,t,i,r){e=o(e>>>0),t=o(t>>>0),i>>>=0,r>>>=0,(()=>{throw Error(`${e} in ${t}:${i}:${r}`)})()},seed:()=>Date.now()*Math.random()})},{exports:r}=await WebAssembly.instantiate(e,i),s=r.memory||t.env.memory,n=Object.setPrototypeOf({findPath(e,t,i,s,n,a,o,l,d,u,p,f,g,m){return p=p?1:0,r.__setArgumentsLength(arguments.length),c(h,2,r.findPath(e,t,i,s,n,a,o,l,d,u,p,f,g,m)>>>0)},findNaivePath(e,t,i,s,n,a,o,l,d,u,p){return r.__setArgumentsLength(arguments.length),c(h,2,r.findNaivePath(e,t,i,s,n,a,o,l,d,u,p)>>>0)},changeFloor(e,t,i,s){s=s?1:0,r.changeFloor(e,t,i,s)},changeLoc(e,t,i,s,n,a,o,c){a=a?1:0,o=o?1:0,c=c?1:0,r.changeLoc(e,t,i,s,n,a,o,c)},changeNpc(e,t,i,s,n){n=n?1:0,r.changeNpc(e,t,i,s,n)},changePlayer(e,t,i,s,n){n=n?1:0,r.changePlayer(e,t,i,s,n)},changeRoof(e,t,i,s){s=s?1:0,r.changeRoof(e,t,i,s)},changeWall(e,t,i,s,n,a,o,c){a=a?1:0,o=o?1:0,c=c?1:0,r.changeWall(e,t,i,s,n,a,o,c)},allocateIfAbsent:(e,t,i)=>c(h,2,r.allocateIfAbsent(e,t,i)>>>0),isZoneAllocated:(e,t,i)=>0!=r.isZoneAllocated(e,t,i),isFlagged:(e,t,i,s)=>0!=r.isFlagged(e,t,i,s),canTravel(e,t,i,s,n,a,o,c){return r.__setArgumentsLength(arguments.length),0!=r.canTravel(e,t,i,s,n,a,o,c)},hasLineOfSight(e,t,i,s,n,a,o,c,l,h){return r.__setArgumentsLength(arguments.length),0!=r.hasLineOfSight(e,t,i,s,n,a,o,c,l,h)},hasLineOfWalk(e,t,i,s,n,a,o,c,l,h){return r.__setArgumentsLength(arguments.length),0!=r.hasLineOfWalk(e,t,i,s,n,a,o,c,l,h)},lineOfSight(e,t,i,s,n,a,o,l,d,u){return r.__setArgumentsLength(arguments.length),c(h,2,r.lineOfSight(e,t,i,s,n,a,o,l,d,u)>>>0)},lineOfWalk(e,t,i,s,n,a,o,l,d,u){return r.__setArgumentsLength(arguments.length),c(h,2,r.lineOfWalk(e,t,i,s,n,a,o,l,d,u)>>>0)},reached(e,t,i,s,n,a,o,c,l,h,d){return r.__setArgumentsLength(arguments.length),0!=r.reached(e,t,i,s,n,a,o,c,l,h,d)},__collides:(e,t,i,s,n,a,o,c)=>0!=r.__collides(e,t,i,s,n,a,o,c),__reachRectangle1:(e,t,i,s,n,a,o,c)=>0!=r.__reachRectangle1(e,t,i,s,n,a,o,c),__reachRectangleN:(e,t,i,s,n,a,o,c,l,h)=>0!=r.__reachRectangleN(e,t,i,s,n,a,o,c,l,h),__reachRectangle:(e,t,i,s,n,a,o,c,l,h)=>0!=r.__reachRectangle(e,t,i,s,n,a,o,c,l,h),__reachExclusiveRectangle:(e,t,i,s,n,a,o,c,l,h)=>0!=r.__reachExclusiveRectangle(e,t,i,s,n,a,o,c,l,h),CollisionFlag:(a={},a[a.NULL=r['CollisionFlag.NULL'].valueOf()]='NULL',a[a.OPEN=r['CollisionFlag.OPEN'].valueOf()]='OPEN',a[a.WALL_NORTH_WEST=r['CollisionFlag.WALL_NORTH_WEST'].valueOf()]='WALL_NORTH_WEST',a[a.WALL_NORTH=r['CollisionFlag.WALL_NORTH'].valueOf()]='WALL_NORTH',a[a.WALL_NORTH_EAST=r['CollisionFlag.WALL_NORTH_EAST'].valueOf()]='WALL_NORTH_EAST',a[a.WALL_EAST=r['CollisionFlag.WALL_EAST'].valueOf()]='WALL_EAST',a[a.WALL_SOUTH_EAST=r['CollisionFlag.WALL_SOUTH_EAST'].valueOf()]='WALL_SOUTH_EAST',a[a.WALL_SOUTH=r['CollisionFlag.WALL_SOUTH'].valueOf()]='WALL_SOUTH',a[a.WALL_SOUTH_WEST=r['CollisionFlag.WALL_SOUTH_WEST'].valueOf()]='WALL_SOUTH_WEST',a[a.WALL_WEST=r['CollisionFlag.WALL_WEST'].valueOf()]='WALL_WEST',a[a.LOC=r['CollisionFlag.LOC'].valueOf()]='LOC',a[a.WALL_NORTH_WEST_PROJ_BLOCKER=r['CollisionFlag.WALL_NORTH_WEST_PROJ_BLOCKER'].valueOf()]='WALL_NORTH_WEST_PROJ_BLOCKER',a[a.WALL_NORTH_PROJ_BLOCKER=r['CollisionFlag.WALL_NORTH_PROJ_BLOCKER'].valueOf()]='WALL_NORTH_PROJ_BLOCKER',a[a.WALL_NORTH_EAST_PROJ_BLOCKER=r['CollisionFlag.WALL_NORTH_EAST_PROJ_BLOCKER'].valueOf()]='WALL_NORTH_EAST_PROJ_BLOCKER',a[a.WALL_EAST_PROJ_BLOCKER=r['CollisionFlag.WALL_EAST_PROJ_BLOCKER'].valueOf()]='WALL_EAST_PROJ_BLOCKER',a[a.WALL_SOUTH_EAST_PROJ_BLOCKER=r['CollisionFlag.WALL_SOUTH_EAST_PROJ_BLOCKER'].valueOf()]='WALL_SOUTH_EAST_PROJ_BLOCKER',a[a.WALL_SOUTH_PROJ_BLOCKER=r['CollisionFlag.WALL_SOUTH_PROJ_BLOCKER'].valueOf()]='WALL_SOUTH_PROJ_BLOCKER',a[a.WALL_SOUTH_WEST_PROJ_BLOCKER=r['CollisionFlag.WALL_SOUTH_WEST_PROJ_BLOCKER'].valueOf()]='WALL_SOUTH_WEST_PROJ_BLOCKER',a[a.WALL_WEST_PROJ_BLOCKER=r['CollisionFlag.WALL_WEST_PROJ_BLOCKER'].valueOf()]='WALL_WEST_PROJ_BLOCKER',a[a.LOC_PROJ_BLOCKER=r['CollisionFlag.LOC_PROJ_BLOCKER'].valueOf()]='LOC_PROJ_BLOCKER',a[a.FLOOR_DECORATION=r['CollisionFlag.FLOOR_DECORATION'].valueOf()]='FLOOR_DECORATION',a[a.NPC=r['CollisionFlag.NPC'].valueOf()]='NPC',a[a.PLAYER=r['CollisionFlag.PLAYER'].valueOf()]='PLAYER',a[a.FLOOR=r['CollisionFlag.FLOOR'].valueOf()]='FLOOR',a[a.WALL_NORTH_WEST_ROUTE_BLOCKER=r['CollisionFlag.WALL_NORTH_WEST_ROUTE_BLOCKER'].valueOf()]='WALL_NORTH_WEST_ROUTE_BLOCKER',a[a.WALL_NORTH_ROUTE_BLOCKER=r['CollisionFlag.WALL_NORTH_ROUTE_BLOCKER'].valueOf()]='WALL_NORTH_ROUTE_BLOCKER',a[a.WALL_NORTH_EAST_ROUTE_BLOCKER=r['CollisionFlag.WALL_NORTH_EAST_ROUTE_BLOCKER'].valueOf()]='WALL_NORTH_EAST_ROUTE_BLOCKER',a[a.WALL_EAST_ROUTE_BLOCKER=r['CollisionFlag.WALL_EAST_ROUTE_BLOCKER'].valueOf()]='WALL_EAST_ROUTE_BLOCKER',a[a.WALL_SOUTH_EAST_ROUTE_BLOCKER=r['CollisionFlag.WALL_SOUTH_EAST_ROUTE_BLOCKER'].valueOf()]='WALL_SOUTH_EAST_ROUTE_BLOCKER',a[a.WALL_SOUTH_ROUTE_BLOCKER=r['CollisionFlag.WALL_SOUTH_ROUTE_BLOCKER'].valueOf()]='WALL_SOUTH_ROUTE_BLOCKER',a[a.WALL_SOUTH_WEST_ROUTE_BLOCKER=r['CollisionFlag.WALL_SOUTH_WEST_ROUTE_BLOCKER'].valueOf()]='WALL_SOUTH_WEST_ROUTE_BLOCKER',a[a.WALL_WEST_ROUTE_BLOCKER=r['CollisionFlag.WALL_WEST_ROUTE_BLOCKER'].valueOf()]='WALL_WEST_ROUTE_BLOCKER',a[a.LOC_ROUTE_BLOCKER=r['CollisionFlag.LOC_ROUTE_BLOCKER'].valueOf()]='LOC_ROUTE_BLOCKER',a[a.ROOF=r['CollisionFlag.ROOF'].valueOf()]='ROOF',a[a.FLOOR_BLOCKED=r['CollisionFlag.FLOOR_BLOCKED'].valueOf()]='FLOOR_BLOCKED',a[a.WALK_BLOCKED=r['CollisionFlag.WALK_BLOCKED'].valueOf()]='WALK_BLOCKED',a[a.BLOCK_WEST=r['CollisionFlag.BLOCK_WEST'].valueOf()]='BLOCK_WEST',a[a.BLOCK_EAST=r['CollisionFlag.BLOCK_EAST'].valueOf()]='BLOCK_EAST',a[a.BLOCK_SOUTH=r['CollisionFlag.BLOCK_SOUTH'].valueOf()]='BLOCK_SOUTH',a[a.BLOCK_NORTH=r['CollisionFlag.BLOCK_NORTH'].valueOf()]='BLOCK_NORTH',a[a.BLOCK_SOUTH_WEST=r['CollisionFlag.BLOCK_SOUTH_WEST'].valueOf()]='BLOCK_SOUTH_WEST',a[a.BLOCK_SOUTH_EAST=r['CollisionFlag.BLOCK_SOUTH_EAST'].valueOf()]='BLOCK_SOUTH_EAST',a[a.BLOCK_NORTH_WEST=r['CollisionFlag.BLOCK_NORTH_WEST'].valueOf()]='BLOCK_NORTH_WEST',a[a.BLOCK_NORTH_EAST=r['CollisionFlag.BLOCK_NORTH_EAST'].valueOf()]='BLOCK_NORTH_EAST',a[a.BLOCK_NORTH_AND_SOUTH_EAST=r['CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST'].valueOf()]='BLOCK_NORTH_AND_SOUTH_EAST',a[a.BLOCK_NORTH_AND_SOUTH_WEST=r['CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST'].valueOf()]='BLOCK_NORTH_AND_SOUTH_WEST',a[a.BLOCK_NORTH_EAST_AND_WEST=r['CollisionFlag.BLOCK_NORTH_EAST_AND_WEST'].valueOf()]='BLOCK_NORTH_EAST_AND_WEST',a[a.BLOCK_SOUTH_EAST_AND_WEST=r['CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST'].valueOf()]='BLOCK_SOUTH_EAST_AND_WEST',a[a.BLOCK_WEST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_WEST_ROUTE_BLOCKER',a[a.BLOCK_EAST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_EAST_ROUTE_BLOCKER'].valueOf()]='BLOCK_EAST_ROUTE_BLOCKER',a[a.BLOCK_SOUTH_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_SOUTH_ROUTE_BLOCKER'].valueOf()]='BLOCK_SOUTH_ROUTE_BLOCKER',a[a.BLOCK_NORTH_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_NORTH_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_ROUTE_BLOCKER',a[a.BLOCK_SOUTH_WEST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_SOUTH_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_SOUTH_WEST_ROUTE_BLOCKER',a[a.BLOCK_SOUTH_EAST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_SOUTH_EAST_ROUTE_BLOCKER'].valueOf()]='BLOCK_SOUTH_EAST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_WEST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_NORTH_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_WEST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_EAST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_NORTH_EAST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_EAST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_AND_SOUTH_EAST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_AND_SOUTH_WEST_ROUTE_BLOCKER',a[a.BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_NORTH_EAST_AND_WEST_ROUTE_BLOCKER',a[a.BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER=r['CollisionFlag.BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER'].valueOf()]='BLOCK_SOUTH_EAST_AND_WEST_ROUTE_BLOCKER',a),LocShape:(e=>(e[e.WALL_STRAIGHT=r['LocShape.WALL_STRAIGHT'].valueOf()]='WALL_STRAIGHT',e[e.WALL_DIAGONAL_CORNER=r['LocShape.WALL_DIAGONAL_CORNER'].valueOf()]='WALL_DIAGONAL_CORNER',e[e.WALL_L=r['LocShape.WALL_L'].valueOf()]='WALL_L',e[e.WALL_SQUARE_CORNER=r['LocShape.WALL_SQUARE_CORNER'].valueOf()]='WALL_SQUARE_CORNER',e[e.WALLDECOR_STRAIGHT_NOOFFSET=r['LocShape.WALLDECOR_STRAIGHT_NOOFFSET'].valueOf()]='WALLDECOR_STRAIGHT_NOOFFSET',e[e.WALLDECOR_STRAIGHT_OFFSET=r['LocShape.WALLDECOR_STRAIGHT_OFFSET'].valueOf()]='WALLDECOR_STRAIGHT_OFFSET',e[e.WALLDECOR_DIAGONAL_OFFSET=r['LocShape.WALLDECOR_DIAGONAL_OFFSET'].valueOf()]='WALLDECOR_DIAGONAL_OFFSET',e[e.WALLDECOR_DIAGONAL_NOOFFSET=r['LocShape.WALLDECOR_DIAGONAL_NOOFFSET'].valueOf()]='WALLDECOR_DIAGONAL_NOOFFSET',e[e.WALLDECOR_DIAGONAL_BOTH=r['LocShape.WALLDECOR_DIAGONAL_BOTH'].valueOf()]='WALLDECOR_DIAGONAL_BOTH',e[e.WALL_DIAGONAL=r['LocShape.WALL_DIAGONAL'].valueOf()]='WALL_DIAGONAL',e[e.CENTREPIECE_STRAIGHT=r['LocShape.CENTREPIECE_STRAIGHT'].valueOf()]='CENTREPIECE_STRAIGHT',e[e.CENTREPIECE_DIAGONAL=r['LocShape.CENTREPIECE_DIAGONAL'].valueOf()]='CENTREPIECE_DIAGONAL',e[e.ROOF_STRAIGHT=r['LocShape.ROOF_STRAIGHT'].valueOf()]='ROOF_STRAIGHT',e[e.ROOF_DIAGONAL_WITH_ROOFEDGE=r['LocShape.ROOF_DIAGONAL_WITH_ROOFEDGE'].valueOf()]='ROOF_DIAGONAL_WITH_ROOFEDGE',e[e.ROOF_DIAGONAL=r['LocShape.ROOF_DIAGONAL'].valueOf()]='ROOF_DIAGONAL',e[e.ROOF_L_CONCAVE=r['LocShape.ROOF_L_CONCAVE'].valueOf()]='ROOF_L_CONCAVE',e[e.ROOF_L_CONVEX=r['LocShape.ROOF_L_CONVEX'].valueOf()]='ROOF_L_CONVEX',e[e.ROOF_FLAT=r['LocShape.ROOF_FLAT'].valueOf()]='ROOF_FLAT',e[e.ROOFEDGE_STRAIGHT=r['LocShape.ROOFEDGE_STRAIGHT'].valueOf()]='ROOFEDGE_STRAIGHT',e[e.ROOFEDGE_DIAGONAL_CORNER=r['LocShape.ROOFEDGE_DIAGONAL_CORNER'].valueOf()]='ROOFEDGE_DIAGONAL_CORNER',e[e.ROOFEDGE_L=r['LocShape.ROOFEDGE_L'].valueOf()]='ROOFEDGE_L',e[e.ROOFEDGE_SQUARE_CORNER=r['LocShape.ROOFEDGE_SQUARE_CORNER'].valueOf()]='ROOFEDGE_SQUARE_CORNER',e[e.GROUND_DECOR=r['LocShape.GROUND_DECOR'].valueOf()]='GROUND_DECOR',e))({}),LocAngle:(e=>(e[e.WEST=r['LocAngle.WEST'].valueOf()]='WEST',e[e.NORTH=r['LocAngle.NORTH'].valueOf()]='NORTH',e[e.EAST=r['LocAngle.EAST'].valueOf()]='EAST',e[e.SOUTH=r['LocAngle.SOUTH'].valueOf()]='SOUTH',e))({}),CollisionType:(e=>(e[e.NORMAL=r['CollisionType.NORMAL'].valueOf()]='NORMAL',e[e.BLOCKED=r['CollisionType.BLOCKED'].valueOf()]='BLOCKED',e[e.INDOORS=r['CollisionType.INDOORS'].valueOf()]='INDOORS',e[e.OUTDOORS=r['CollisionType.OUTDOORS'].valueOf()]='OUTDOORS',e[e.LINE_OF_SIGHT=r['CollisionType.LINE_OF_SIGHT'].valueOf()]='LINE_OF_SIGHT',e))({}),LocLayer:(e=>(e[e.WALL=r['LocLayer.WALL'].valueOf()]='WALL',e[e.WALL_DECOR=r['LocLayer.WALL_DECOR'].valueOf()]='WALL_DECOR',e[e.GROUND=r['LocLayer.GROUND'].valueOf()]='GROUND',e[e.GROUND_DECOR=r['LocLayer.GROUND_DECOR'].valueOf()]='GROUND_DECOR',e))({}),BlockAccessFlag:(e=>(e[e.BLOCK_NORTH=r['BlockAccessFlag.BLOCK_NORTH'].valueOf()]='BLOCK_NORTH',e[e.BLOCK_EAST=r['BlockAccessFlag.BLOCK_EAST'].valueOf()]='BLOCK_EAST',e[e.BLOCK_SOUTH=r['BlockAccessFlag.BLOCK_SOUTH'].valueOf()]='BLOCK_SOUTH',e[e.BLOCK_WEST=r['BlockAccessFlag.BLOCK_WEST'].valueOf()]='BLOCK_WEST',e))({})},r);var a;function o(e){if(!e)return null;const t=e+new Uint32Array(s.buffer)[e-4>>>2]>>>1,i=new Uint16Array(s.buffer);let r=e>>>1,n='';for(;t-r>1024;)n+=String.fromCharCode(...i.subarray(r,r+=1024));return n+String.fromCharCode(...i.subarray(r,t))}function c(e,t,i){if(!i)return null;const r=function(e){try{return l.getUint32(e,!0)}catch{return l=new DataView(s.buffer),l.getUint32(e,!0)}}(i-4)>>>t,n=new Array(r);for(let s=0;s>>0));return n}let l=new DataView(s.buffer);function h(e){try{return l.getInt32(e,!0)}catch{return l=new DataView(s.buffer),l.getInt32(e,!0)}}return n}var{memory:ei,findPath:ti,findNaivePath:ii,changeFloor:ri,changeLoc:si,changeNpc:ni,changePlayer:ai,changeRoof:oi,changeWall:ci,allocateIfAbsent:li,deallocateIfPresent:hi,isZoneAllocated:di,isFlagged:ui,canTravel:pi,hasLineOfSight:fi,hasLineOfWalk:gi,lineOfSight:mi,lineOfWalk:yi,reached:Ei,locShapeLayer:_i,__get:Ai,__set:vi,__add:Ti,__remove:Ci,__rotate:Ii,__rotateFlags:Si,__collides:Oi,__reachRectangle1:Ni,__reachRectangleN:Li,__alteredRotation:Pi,__reachRectangle:wi,__reachExclusiveRectangle:bi,CollisionFlag:Ri,LocShape:Bi,LocAngle:Ui,CollisionType:Di,LocLayer:ki,BlockAccessFlag:Mi}=await(async e=>Jt(await(async()=>{try{return await globalThis.WebAssembly.compileStreaming(globalThis.fetch(e))}catch{return globalThis.WebAssembly.compile(await(await import('node:fs/promises')).readFile(e))}})(),{}))(new URL('rsmod-pathfinder.wasm',import.meta.url)),xi=0,Fi=1,Hi=2,Vi=3,Gi=4,Wi=5,Ki=6,zi=7,ji={zone:e=>e>>3,zoneCenter:e=>ji.zone(e)-6,zoneOrigin:e=>ji.zoneCenter(e)<<3,mapsquare:e=>e>>6,local:(e,t)=>e-(ji.zoneCenter(t)<<3),face:(e,t,i,r)=>e!=i?e>i?t>r?Wi:tr?zi:tr?Ki:te+ji.deltaX(t),moveZ:(e,t)=>e+ji.deltaZ(t),distanceTo(e,t){const i=ji.closest(e,t),r=ji.closest(t,e);return Math.max(Math.abs(i.x-r.x),Math.abs(i.z-r.z))},closest(e,t){const i=e.x+e.width-1,r=e.z+e.length-1;return{x:t.x<=e.x?e.x:t.x>=i?i:t.x,z:t.z<=e.z?e.z:t.z>=r?r:t.z}},distanceToSW(e,t){const i=Math.abs(e.x-t.x),r=Math.abs(e.z-t.z);return Math.max(i,r)},isWithinDistanceSW:(e,t,i)=>!(Math.abs(e.x-t.x)>i||Math.abs(e.z-t.z)>i),deltaX(e){switch(e){case zi:case Hi:case Gi:return 1;case Wi:case xi:case Vi:return-1}return 0},deltaZ(e){switch(e){case xi:case Hi:case Fi:return 1;case Wi:case zi:case Ki:return-1}return 0},unpackCoord:e=>({level:e>>28&3,x:e>>14&16383,z:16383&e}),packCoord:(e,t,i)=>16383&i|(16383&t)<<14|(3&e)<<28,packZoneCoord:(e,t)=>(7&e)<<4|7&t,intersects:(e,t,i,r,s,n,a,o)=>!(s>=e+i||s+a<=e||n>=t+r||n+o<=t),formatString:(e,t,i,r="_")=>e+r+(t>>6)+r+(i>>6)+r+(63&t)+r+(63&i)},Yi=(e=>(e[e.BLOCK=0]='BLOCK',e[e.DAMAGE=1]='DAMAGE',e[e.POISON=2]='POISON',e))(Yi||{}),qi=Yi,Qi=(e=>(e[e.ATTACK=0]='ATTACK',e[e.DEFENCE=1]='DEFENCE',e[e.STRENGTH=2]='STRENGTH',e[e.HITPOINTS=3]='HITPOINTS',e[e.RANGED=4]='RANGED',e[e.PRAYER=5]='PRAYER',e[e.MAGIC=6]='MAGIC',e[e.COOKING=7]='COOKING',e[e.WOODCUTTING=8]='WOODCUTTING',e[e.FLETCHING=9]='FLETCHING',e[e.FISHING=10]='FISHING',e[e.FIREMAKING=11]='FIREMAKING',e[e.CRAFTING=12]='CRAFTING',e[e.SMITHING=13]='SMITHING',e[e.MINING=14]='MINING',e[e.HERBLORE=15]='HERBLORE',e[e.AGILITY=16]='AGILITY',e[e.THIEVING=17]='THIEVING',e[e.STAT18=18]='STAT18',e[e.STAT19=19]='STAT19',e[e.RUNECRAFT=20]='RUNECRAFT',e))(Qi||{}),$i=Qi,Zi=class{type;count;name;constructor(e,t,i){this.type=e,this.count=t,this.name=i}validate(e){if(this.count(e))return this.type(e);throw new Error(`An input for a ${this.name} type was not valid to use. Input was ${e}.`)}},Xi=class{min;max;name;constructor(e,t,i){this.min=e,this.max=t,this.name=i}validate(e){if(e>=this.min&&e<=this.max)return e;throw new Error(`An input for a ${this.name} was out of range. Range should be: ${this.min} to ${this.max}. Input was ${e}.`)}},Ji=new class{validate(e){if(-1!==e)return e;throw Error('An input number was null(-1).')}},er=new class{validate(e){if(e.length>0)return e;throw Error('An input string was null(-1).')}},tr=new Zi(at.get,(e=>e>=0&&e=this.min&&e<=this.max)return ji.unpackCoord(e);throw new Error(`An input for a ${this.name} was out of range. Range should be: ${this.min} to ${this.max}. Input was ${e}.`)}}(0,2147483647,'Coord'),ar=new Zi(gt.get,(e=>e>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&ee>=0&&e=50)throw new Error('stack overflow');e.frames[e.fp++]={script:e.script,pc:e.pc,intLocals:e.intLocals,stringLocals:e.stringLocals};const i=jt.get(t);if(!i)throw new Error(`unable to find proc ${i}`);kr(e,i)}function Dr(e,t){const i=jt.get(t);if(!i)throw new Error(`unable to find label ${t}`);e.debugFrames[e.debugFp++]={script:e.script,pc:e.pc},kr(e,i),e.fp=0,e.frames=[]}function kr(e,t){e.script=t,e.pc=-1,e.intLocals=e.popInts(t.intArgCount),e.stringLocals=e.popStrings(t.stringArgCount)}var Mr,xr={[Kt.PUSH_CONSTANT_INT]:e=>{e.pushInt(e.intOperand)},[Kt.PUSH_CONSTANT_STRING]:e=>{e.pushString(e.stringOperand)},[Kt.PUSH_VARP]:e=>{const t=e.intOperand>>16&1;if(t&&!e._activePlayer2)throw new Error('No secondary active_player.');if(!t&&!e._activePlayer)throw new Error('No active_player.');const i=Br(65535&e.intOperand,Cr);i.type===Pe.STRING?e.pushString(t?e._activePlayer2.getVar(i.id):e._activePlayer.getVar(i.id)):e.pushInt(t?e._activePlayer2.getVar(i.id):e._activePlayer.getVar(i.id))},[Kt.POP_VARP]:e=>{const t=e.intOperand>>16&1;if(t&&!e._activePlayer2)throw new Error('No secondary active_player.');if(!t&&!e._activePlayer)throw new Error('No active_player.');const i=Br(65535&e.intOperand,Cr);if(!e.pointerGet(Ht[t])&&i.protect)throw new Error(`%${i.debugname} requires protected access`);if(i.type===Pe.STRING){const r=e.popString();t?e._activePlayer2.setVar(i.id,r):e._activePlayer.setVar(i.id,r)}else{const r=e.popInt();t?e._activePlayer2.setVar(i.id,r):e._activePlayer.setVar(i.id,r)}},[Kt.PUSH_VARN]:e=>{const t=e.intOperand>>16&1;if(t&&!e._activeNpc2)throw new Error('No secondary active_npc.');if(!t&&!e._activeNpc)throw new Error('No active_npc.');const i=Br(65535&e.intOperand,Ir);i.type===Pe.STRING?e.pushString(t?e._activeNpc2.getVar(i.id):e._activeNpc.getVar(i.id)):e.pushInt(t?e._activeNpc2.getVar(i.id):e._activeNpc.getVar(i.id))},[Kt.POP_VARN]:e=>{const t=e.intOperand>>16&1;if(t&&!e._activeNpc2)throw new Error('No secondary active_npc.');if(!t&&!e._activeNpc)throw new Error('No active_npc.');const i=Br(65535&e.intOperand,Ir);if(i.type===Pe.STRING){const r=e.popInt();t?e._activeNpc2.setVar(i.id,r):e._activeNpc.setVar(i.id,r)}else{const r=e.popInt();t?e._activeNpc2.setVar(i.id,r):e._activeNpc.setVar(i.id,r)}},[Kt.PUSH_INT_LOCAL]:e=>{e.pushInt(e.intLocals[e.intOperand])},[Kt.POP_INT_LOCAL]:e=>{e.intLocals[e.intOperand]=e.popInt()},[Kt.PUSH_STRING_LOCAL]:e=>{e.pushString(e.stringLocals[e.intOperand])},[Kt.POP_STRING_LOCAL]:e=>{e.stringLocals[e.intOperand]=e.popString()},[Kt.BRANCH]:e=>{e.pc+=e.intOperand},[Kt.BRANCH_NOT]:e=>{const t=e.popInt();e.popInt()!==t&&(e.pc+=e.intOperand)},[Kt.BRANCH_EQUALS]:e=>{const t=e.popInt();e.popInt()===t&&(e.pc+=e.intOperand)},[Kt.BRANCH_LESS_THAN]:e=>{const t=e.popInt();e.popInt(){const t=e.popInt();e.popInt()>t&&(e.pc+=e.intOperand)},[Kt.BRANCH_LESS_THAN_OR_EQUALS]:e=>{const t=e.popInt();e.popInt()<=t&&(e.pc+=e.intOperand)},[Kt.BRANCH_GREATER_THAN_OR_EQUALS]:e=>{const t=e.popInt();e.popInt()>=t&&(e.pc+=e.intOperand)},[Kt.POP_INT_DISCARD]:e=>{e.isp--},[Kt.POP_STRING_DISCARD]:e=>{e.ssp--},[Kt.RETURN]:e=>{if(0===e.fp)return void(e.execution=$t.FINISHED);const t=e.frames[--e.fp];e.pc=t.pc,e.script=t.script,e.intLocals=t.intLocals,e.stringLocals=t.stringLocals},[Kt.JOIN_STRING]:e=>{const t=e.intOperand,i=[];for(let r=0;r{Ur(e,e.popInt())},[Kt.GOSUB_WITH_PARAMS]:e=>{Ur(e,e.intOperand)},[Kt.JUMP]:e=>{Dr(e,e.popInt())},[Kt.JUMP_WITH_PARAMS]:e=>{Dr(e,e.intOperand)},[Kt.DEFINE_ARRAY]:e=>{throw new Error('unimplemented')},[Kt.PUSH_ARRAY_INT]:e=>{throw new Error('unimplemented')},[Kt.POP_ARRAY_INT]:e=>{throw new Error('unimplemented')},[Kt.SWITCH]:e=>{const t=e.popInt(),i=e.script.switchTables[e.intOperand];if(void 0===i)return;const r=i[t];r&&(e.pc+=r)},[Kt.PUSH_VARS]:e=>{const t=Br(65535&e.intOperand,Sr);t.type===Pe.STRING?e.pushString(Zl.varsString[t.id]??''):e.pushInt(Zl.vars[t.id])},[Kt.POP_VARS]:e=>{const t=Br(65535&e.intOperand,Sr);t.type===Pe.STRING?Zl.varsString[t.id]=e.popString():Zl.vars[t.id]=e.popInt()}},Fr=xr,Hr={[Kt.DB_FIND_WITH_COUNT]:e=>{throw new Error('unimplemented')},[Kt.DB_FINDNEXT]:e=>{if(!e.dbTable)throw new Error('No table selected');e.dbRow+1>=e.dbRowQuery.length?e.pushInt(-1):(e.dbRow++,e.pushInt(Br(e.dbRowQuery[e.dbRow],Pr).id))},[Kt.DB_GETFIELD]:e=>{const[t,i,r]=e.popInts(3),s=i>>12&65535,n=i>>4&127,a=Br(t,Pr),o=Br(s,wr);let c;c=a.tableId!==s?o.getDefault(n):a.getValue(n,r);const l=o.types[n];for(let t=0;t{const[t,i]=e.popInts(2),r=i>>12&65535,s=i>>4&127,n=Br(t,Pr),a=Br(r,wr);n.tableId===r?e.pushInt(n.columnValues[s].length/a.types[s].length):e.pushInt(0)},[Kt.DB_LISTALL_WITH_COUNT]:e=>{throw new Error('unimplemented')},[Kt.DB_GETROWTABLE]:e=>{e.pushInt(Br(e.popInt(),Pr).tableId)},[Kt.DB_FINDBYINDEX]:e=>{throw new Error('unimplemented')},[Kt.DB_FIND_REFINE_WITH_COUNT]:e=>{throw new Error('unimplemented')},[Kt.DB_FIND]:e=>{const t=2==e.popInt()?e.popString():e.popInt(),i=e.popInt(),r=i>>12&65535,s=i>>4&127;e.dbTable=Br(r,wr),e.dbRow=-1,e.dbRowQuery=[];const n=be.getInTable(r);for(let i=0;i{const t=2==e.popInt()?e.popString():e.popInt(),i=e.popInt(),r=i>>12&65535,s=i>>4&127,n=[],a=be.getInTable(r);for(let e=0;e{throw new Error('unimplemented')}},Vr=(e=>(e[e.CYCLE=0]='CYCLE',e[e.WORLD=1]='WORLD',e[e.CLIENT_IN=2]='CLIENT_IN',e[e.NPC=3]='NPC',e[e.PLAYER=4]='PLAYER',e[e.LOGOUT=5]='LOGOUT',e[e.LOGIN=6]='LOGIN',e[e.ZONE=7]='ZONE',e[e.CLIENT_OUT=8]='CLIENT_OUT',e[e.CLEANUP=9]='CLEANUP',e[e.BANDWIDTH_IN=10]='BANDWIDTH_IN',e[e.BANDWIDTH_OUT=11]='BANDWIDTH_OUT',e))(Vr||{}),Gr=Vr,Wr={[Kt.ERROR]:e=>{throw new Error(e.popString())},[Kt.MAP_PRODUCTION]:e=>{e.pushInt(vt.NODE_PRODUCTION?1:0)},[Kt.MAP_LASTCLOCK]:e=>{e.pushInt(Zl.lastCycleStats[Gr.CYCLE])},[Kt.MAP_LASTWORLD]:e=>{e.pushInt(Zl.lastCycleStats[Gr.WORLD])},[Kt.MAP_LASTCLIENTIN]:e=>{e.pushInt(Zl.lastCycleStats[Gr.CLIENT_IN])},[Kt.MAP_LASTNPC]:e=>{e.pushInt(Zl.lastCycleStats[Gr.NPC])},[Kt.MAP_LASTPLAYER]:e=>{e.pushInt(Zl.lastCycleStats[Gr.PLAYER])},[Kt.MAP_LASTLOGOUT]:e=>{e.pushInt(Zl.lastCycleStats[Gr.LOGOUT])},[Kt.MAP_LASTLOGIN]:e=>{e.pushInt(Zl.lastCycleStats[Gr.LOGIN])},[Kt.MAP_LASTZONE]:e=>{e.pushInt(Zl.lastCycleStats[Gr.ZONE])},[Kt.MAP_LASTCLIENTOUT]:e=>{e.pushInt(Zl.lastCycleStats[Gr.CLIENT_OUT])},[Kt.MAP_LASTCLEANUP]:e=>{e.pushInt(Zl.lastCycleStats[Gr.CLEANUP])},[Kt.MAP_LASTBANDWIDTHIN]:e=>{e.pushInt(Zl.lastCycleStats[Gr.BANDWIDTH_IN])},[Kt.MAP_LASTBANDWIDTHOUT]:e=>{e.pushInt(Zl.lastCycleStats[Gr.BANDWIDTH_OUT])}},Kr={[Kt.ENUM]:e=>{const[t,i,r,s]=e.popInts(4),n=Br(r,gr);if(n.inputtype!==t||n.outputtype!==i)throw new Error(`Type validation error: ${n.debugname} key: ${s}. Expected input: ${t} got: ${n.inputtype}. Expected output: ${i} got: ${n.outputtype}`);const a=n.values.get(s);'string'==typeof a?e.pushString(a??n.defaultString):e.pushInt(a??n.defaultInt)},[Kt.ENUM_GETOUTPUTCOUNT]:e=>{e.pushInt(Br(e.popInt(),gr).values.size)}},zr=Kr,jr=(e=>(e[e.FOREVER=0]='FOREVER',e[e.RESPAWN=1]='RESPAWN',e[e.DESPAWN=2]='DESPAWN',e))(jr||{}),Yr=jr,qr=class{level;x;z;width;length;lifecycle;lifecycleTick=-1;lastLifecycleTick=-1;constructor(e,t,i,r,s,n){this.level=e,this.x=t,this.z=i,this.width=r,this.length=s,this.lifecycle=n}updateLifeCycle(e){return this.lifecycleTick===e&&this.lifecycle!==Yr.FOREVER}checkLifeCycle(e){return this.lifecycle===Yr.FOREVER||(this.lifecycle===Yr.RESPAWN?this.lifecycleTicke)}setLifeCycle(e){this.lifecycleTick=e,this.lastLifecycleTick=Zl.currentTick}},Qr=class extends qr{resetEntity(e){}},$r=class extends Qr{type;count;receiverId=-1;reveal=-1;constructor(e,t,i,r,s,n){super(e,t,i,1,1,r),this.type=s,this.count=n}},Zr={[Kt.INV_ALLSTOCK]:e=>{const t=Br(e.popInt(),Er);e.pushInt(t.allstock?1:0)},[Kt.INV_SIZE]:e=>{const t=Br(e.popInt(),Er);e.pushInt(t.size)},[Kt.INV_STOCKBASE]:e=>{const[t,i]=e.popInts(2),r=Br(t,Er),s=Br(i,mr);if(!r.stockobj||!r.stockcount)return void e.pushInt(-1);const n=r.stockobj.indexOf(s.id);e.pushInt(n>=0?r.stockcount[n]:-1)},[Kt.INV_ADD]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3),s=Br(t,Er),n=Br(i,mr);if(Br(r,yr),!e.pointerGet(Ht[e.intOperand])&&s.protect&&s.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);if(!s.dummyinv&&0!==n.dummyitem)throw new Error(`dummyitem in non-dummyinv: ${n.debugname} -> ${s.debugname}`);const a=e.activePlayer,o=r-a.invAdd(s.id,n.id,r,!1);if(o>0)if(n.stackable&&1!==o)Zl.addObj(new $r(a.level,a.x,a.z,Yr.DESPAWN,n.id,o),a.pid,200);else for(let e=0;e{const[t,i,r,s]=e.popInts(4);throw new Error('unimplemented')})),[Kt.INV_CLEAR]:Vt(Ft,(e=>{const t=Br(e.popInt(),Er);if(!e.pointerGet(Ht[e.intOperand])&&t.protect&&t.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${t.debugname}`);e.activePlayer.invClear(t.id)})),[Kt.INV_DEL]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3),s=Br(t,Er),n=Br(i,mr);if(Br(r,yr),!e.pointerGet(Ht[e.intOperand])&&s.protect&&s.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);e.activePlayer.invDel(s.id,n.id,r)})),[Kt.INV_DELSLOT]:Vt(Ft,(e=>{const[t,i]=e.popInts(2),r=Br(t,Er);if(!e.pointerGet(Ht[e.intOperand])&&r.protect&&r.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${r.debugname}`);e.activePlayer.invGetSlot(r.id,i)&&e.activePlayer.invDelSlot(r.id,i)})),[Kt.INV_DROPITEM]:Vt(Ft,(e=>{const[t,i,r,s,n]=e.popInts(5),a=Br(t,Er),o=Br(i,nr),c=Br(r,mr);if(Br(s,yr),Br(n,sr),!e.pointerGet(Ht[e.intOperand])&&a.protect&&a.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);const l=e.activePlayer,h=l.invDel(a.id,c.id,s);if(0==h)return;l.playerLog('Dropped item from',a.debugname,c.debugname);const d=new $r(o.level,o.x,o.z,Yr.DESPAWN,c.id,h);Zl.addObj(d,l.pid,n),e.activeObj=d,e.pointerAdd(xt[e.intOperand])})),[Kt.INV_DROPSLOT]:Vt(Ft,(e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,Er);Br(s,sr);const a=Br(i,nr);if(!e.pointerGet(Ht[e.intOperand])&&n.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);const o=e.activePlayer.invGetSlot(n.id,r);if(!o)throw new Error('$slot is empty');const c=e.activePlayer,l=c.invDel(n.id,o.id,o.count,r);if(0===l)return;const h=Tt.get(o.id);if(c.playerLog('Dropped item from',n.debugname,h.debugname),h.stackable&&1!==l){const t=new $r(a.level,a.x,a.z,Yr.DESPAWN,o.id,l);Zl.addObj(t,c.pid,s),e.activeObj=t,e.pointerAdd(xt[e.intOperand])}else for(let t=0;t{const t=Br(e.popInt(),Er);e.pushInt(e.activePlayer.invFreeSpace(t.id))})),[Kt.INV_GETNUM]:Vt(Ft,(e=>{const[t,i]=e.popInts(2),r=Br(t,Er);e.pushInt(e.activePlayer.invGetSlot(r.id,i)?.count??0)})),[Kt.INV_GETOBJ]:Vt(Ft,(e=>{const[t,i]=e.popInts(2),r=Br(t,Er);e.pushInt(e.activePlayer.invGetSlot(r.id,i)?.id??-1)})),[Kt.INV_ITEMSPACE]:Vt(Ft,(e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,Er),a=Br(i,mr);if(Br(r,yr),s<0||s>n.size)throw new Error(`$count is out of range: ${r}`);e.pushInt(0===e.activePlayer.invItemSpace(n.id,a.id,r,s)?1:0)})),[Kt.INV_ITEMSPACE2]:Vt(Ft,(e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,Er),a=Br(i,mr);Br(r,yr),e.pushInt(e.activePlayer.invItemSpace(n.id,a.id,r,s))})),[Kt.INV_MOVEFROMSLOT]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3),s=Br(t,Er),n=Br(i,Er);if(!e.pointerGet(Ht[e.intOperand])&&s.protect&&s.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);if(!e.pointerGet(Ht[e.intOperand])&&n.protect&&s.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);const a=e.activePlayer,{overflow:o,fromObj:c}=a.invMoveFromSlot(s.id,n.id,r);if(o>0){if(Tt.get(c).stackable&&1!==o)Zl.addObj(new $r(a.level,a.x,a.z,Yr.DESPAWN,c,o),a.pid,200);else for(let e=0;e{const[t,i,r,s]=e.popInts(4),n=Br(t,Er),a=Br(i,Er);if(!e.pointerGet(Ht[e.intOperand])&&n.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);if(!e.pointerGet(Ht[e.intOperand])&&a.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);e.activePlayer.invMoveToSlot(n.id,a.id,r,s)})),[Kt.BOTH_MOVEINV]:Vt(Ft,(e=>{const[t,i]=e.popInts(2),r=Br(t,Er),s=Br(i,Er),n=1==e.intOperand,a=n?e._activePlayer2:e._activePlayer,o=n?e._activePlayer:e._activePlayer2;if(!a||!o)throw new Error('player is null');if(!e.pointerGet(Ht[n?1:0])&&r.protect&&r.scope!==it.SCOPE_SHARED)throw new Error(`$from_inv requires protected access: ${r.debugname}`);if(!e.pointerGet(Ht[n?0:1])&&s.protect&&r.scope!==it.SCOPE_SHARED)throw new Error(`$to_inv requires protected access: ${s.debugname}`);const c=a.getInventory(t),l=o.getInventory(i);if(!c||!l)throw new Error('inv is null');for(let e=0;e{const[t,i,r,s]=e.popInts(4),n=Br(t,Er),a=Br(i,Er),o=Br(r,mr);if(Br(s,yr),!e.pointerGet(Ht[e.intOperand])&&n.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);if(!e.pointerGet(Ht[e.intOperand])&&a.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);const c=e.activePlayer,l=c.invDel(n.id,o.id,s);if(0==l)return;const h=s-c.invAdd(a.id,o.id,l,!1);if(h>0)if(o.stackable&&1!==h)Zl.addObj(new $r(c.level,c.x,c.z,Yr.DESPAWN,o.id,h),c.pid,200);else for(let e=0;e{const[t,i,r,s]=e.popInts(4),n=Br(t,Er),a=Br(i,Er),o=Br(r,mr);if(Br(s,yr),!e.pointerGet(Ht[e.intOperand])&&n.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);if(!e.pointerGet(Ht[e.intOperand])&&a.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);const c=e.activePlayer,l=c.invDel(n.id,o.id,s);if(0==l)return;let h=o.id;-1===o.certtemplate&&o.certlink>=0&&(h=o.certlink);const d=s-c.invAdd(a.id,h,l,!1);d>0&&Zl.addObj(new $r(c.level,c.x,c.z,Yr.DESPAWN,h,d),c.pid,200)})),[Kt.INV_MOVEITEM_UNCERT]:Vt(Ft,(e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,Er),a=Br(i,Er),o=Br(r,mr);if(Br(s,yr),!e.pointerGet(Ht[e.intOperand])&&n.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);if(!e.pointerGet(Ht[e.intOperand])&&a.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${a.debugname}`);const c=e.activePlayer,l=c.invDel(n.id,o.id,s);0!=l&&(o.certtemplate>=0&&o.certlink>=0?c.invAdd(a.id,o.certlink,l):c.invAdd(a.id,o.id,l))})),[Kt.INV_SETSLOT]:Vt(Ft,(e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,Er),a=Br(r,mr);if(Br(s,yr),!e.pointerGet(Ht[e.intOperand])&&n.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${n.debugname}`);if(!n.dummyinv&&0!==a.dummyitem)throw new Error(`dummyitem in non-dummyinv: ${a.debugname} -> ${n.debugname}`);e.activePlayer.invSet(n.id,a.id,s,i)})),[Kt.INV_TOTAL]:Vt(Ft,(e=>{const[t,i]=e.popInts(2),r=Br(t,Er);-1!==i?e.pushInt(e.activePlayer.invTotal(r.id,i)):e.pushInt(0)})),[Kt.INV_TOTALCAT]:Vt(Ft,(e=>{const[t,i]=e.popInts(2),r=Br(t,Er),s=Br(i,_r);e.pushInt(e.activePlayer.invTotalCat(r.id,s.id))})),[Kt.INV_TRANSMIT]:Vt(Ft,(e=>{const[t,i]=e.popInts(2),r=Br(t,Er);Br(i,Ji),e.activePlayer.invListenOnCom(r.id,i,e.activePlayer.uid)})),[Kt.INVOTHER_TRANSMIT]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3);Br(t,Ji);const s=Br(i,Er);Br(r,Ji),e.activePlayer.invListenOnCom(s.id,r,t)})),[Kt.INV_STOPTRANSMIT]:Vt(Ft,(e=>{const t=Br(e.popInt(),Ji);e.activePlayer.invStopListenOnCom(t)})),[Kt.BOTH_DROPSLOT]:Vt(Ft,(e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,Er);Br(s,sr);const a=Br(i,nr),o=1==e.intOperand,c=o?e._activePlayer2:e._activePlayer,l=o?e._activePlayer:e._activePlayer2;if(!c||!l)throw new Error('player is null');if(!e.pointerGet(Ht[o?1:0])&&n.protect&&n.scope!==it.SCOPE_SHARED)throw new Error(`inv requires protected access: ${n.debugname}`);const h=c.invGetSlot(n.id,r);if(!h)throw new Error('$slot is empty');const d=c.invDel(n.id,h.id,h.count,r);if(0===d)return;const u=Tt.get(h.id);c.playerLog('Dropped item from',n.debugname,u.debugname),u.tradeable&&Zl.addObj(new $r(a.level,a.x,a.z,Yr.DESPAWN,h.id,d),l.pid,s)})),[Kt.INV_DROPALL]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3),s=Br(t,Er);Br(r,sr);const n=Br(i,nr);if(!e.pointerGet(Ht[e.intOperand])&&s.protect&&s.scope!==it.SCOPE_SHARED)throw new Error(`$inv requires protected access: ${s.debugname}`);const a=e.activePlayer.getInventory(s.id);if(a)for(let e=0;e{const[t,i]=e.popInts(2);e.pushInt(e.activePlayer.invTotalParam(t,i))})),[Kt.INV_TOTALPARAM_STACK]:Vt(Ft,(e=>{const[t,i]=e.popInts(2);e.pushInt(e.activePlayer.invTotalParamStack(t,i))}))},Xr=(e=>(e[e.ZONE=0]='ZONE',e[e.DISTANCE=1]='DISTANCE',e))(Xr||{}),Jr=Xr,es=class{iterator;tick;constructor(e){this.iterator=this.generator(),this.tick=e}[Symbol.iterator](){return this.iterator}next(){return this.iterator.next()}},ts=class extends es{x;z;level;minX;maxX;minZ;maxZ;distance;checkVis;checkType;checkCategory;type;constructor(e,t,i,r,s,n,a,o,c){super(e);const l=ji.zone(i),h=ji.zone(r),d=1+s/8|0;this.x=i,this.z=r,this.level=t,this.maxX=l+d,this.minX=l-d,this.maxZ=h+d,this.minZ=h-d,this.distance=s,this.checkVis=n,this.checkType=a,this.checkCategory=o,this.type=c}*generator(){for(let e=this.maxX;e>=this.minX;e--){const t=e<<3;for(let e=this.maxZ;e>=this.minZ;e--){const i=e<<3;if(this.type===je.PLAYER)for(const e of Zl.getZone(t,i,this.level).getAllPlayersSafe()){if(Zl.currentTick>this.tick)throw new Error('[HuntIterator] tried to use an old iterator. Create a new iterator instead.');ji.distanceToSW({x:this.x,z:this.z},e)>this.distance||(this.checkVis!==$e.LINEOFSIGHT||fi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(this.checkVis!==$e.LINEOFWALK||gi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(yield e)}else if(this.type===je.NPC)for(const e of Zl.getZone(t,i,this.level).getAllNpcsSafe()){if(Zl.currentTick>this.tick)throw new Error('[HuntIterator] tried to use an old iterator. Create a new iterator instead.');if(-1!==this.checkType&&e.type!==this.checkType)continue;const t=ft.get(e.type);-1!==this.checkCategory&&t.category!==this.checkCategory||t.op&&t.op[1]&&(ji.distanceToSW({x:this.x,z:this.z},e)>this.distance||(this.checkVis!==$e.LINEOFSIGHT||fi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(this.checkVis!==$e.LINEOFWALK||gi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(yield e))}else if(this.type===je.OBJ)for(const e of Zl.getZone(t,i,this.level).getAllObjsSafe()){if(Zl.currentTick>this.tick)throw new Error('[HuntIterator] tried to use an old iterator. Create a new iterator instead.');if(-1!==this.checkType&&e.type!==this.checkType)continue;const t=Tt.get(e.type);-1!==this.checkCategory&&t.category!==this.checkCategory||(ji.distanceToSW({x:this.x,z:this.z},e)>this.distance||(this.checkVis!==$e.LINEOFSIGHT||fi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(this.checkVis!==$e.LINEOFWALK||gi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(yield e))}else if(this.type===je.SCENERY)for(const e of Zl.getZone(t,i,this.level).getAllLocsSafe()){if(Zl.currentTick>this.tick)throw new Error('[HuntIterator] tried to use an old iterator. Create a new iterator instead.');if(-1!==this.checkType&&e.type!==this.checkType)continue;const t=at.get(e.type);-1!==this.checkCategory&&t.category!==this.checkCategory||(ji.distanceToSW({x:this.x,z:this.z},e)>this.distance||(this.checkVis!==$e.LINEOFSIGHT||fi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(this.checkVis!==$e.LINEOFWALK||gi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(yield e))}}}}},is=class extends es{level;x;z;minX;maxX;minZ;maxZ;distance;checkVis;type;constructor(e,t,i,r,s,n,a){super(e);const o=ji.zone(i),c=ji.zone(r),l=1+s/8|0;this.x=i,this.z=r,this.level=t,this.maxX=o+l,this.minX=o-l,this.maxZ=c+l,this.minZ=c-l,this.distance=s,this.checkVis=n,this.type=a}*generator(){if(this.type===Jr.ZONE)for(const e of Zl.getZone(this.x,this.z,this.level).getAllNpcsSafe()){if(Zl.currentTick>this.tick)throw new Error('[NpcIterator] tried to use an old iterator. Create a new iterator instead.');yield e}else if(this.type===Jr.DISTANCE)for(let e=this.maxX;e>=this.minX;e--){const t=e<<3;for(let e=this.maxZ;e>=this.minZ;e--){const i=e<<3;for(const e of Zl.getZone(t,i,this.level).getAllNpcsSafe()){if(Zl.currentTick>this.tick)throw new Error('[NpcIterator] tried to use an old iterator. Create a new iterator instead.');ji.distanceToSW({x:this.x,z:this.z},e)>this.distance||(this.checkVis!==$e.LINEOFSIGHT||fi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(this.checkVis!==$e.LINEOFWALK||gi(this.level,this.x,this.z,e.x,e.z,1,1,1,1))&&(yield e)}}}}},rs=class extends es{level;x;z;constructor(e,t,i,r){super(e),this.level=t,this.x=i,this.z=r}*generator(){for(const e of Zl.getZone(this.x,this.z,this.level).getAllLocsSafe()){if(Zl.currentTick>this.tick)throw new Error('[LocIterator] tried to use an old iterator. Create a new iterator instead.');yield e}}},ss=class extends Qr{info;constructor(e,t,i,r,s,n,a,o,c){super(e,t,i,r,s,n),this.info=16383&a|(31&o)<<14|(3&c)<<19}get type(){return 16383&this.info}get shape(){return this.info>>14&31}get angle(){return this.info>>19&3}},ns={[Kt.LOC_ADD]:e=>{const[t,i,r,s,n]=e.popInts(5),a=Br(t,nr),o=Br(i,tr),c=Br(r,ir),l=Br(s,rr);Br(n,sr);const h=new ss(a.level,a.x,a.z,o.width,o.length,Yr.DESPAWN,o.id,l,c),d=Zl.getZone(a.x,a.z,a.level).getLocsUnsafe(ji.packZoneCoord(a.x,a.z));for(const e of d)if(e!==h&&e.angle===c&&e.shape===l){Zl.removeLoc(e,n);break}Zl.addLoc(h,n),e.activeLoc=h,e.pointerAdd(Mt[e.intOperand])},[Kt.LOC_ANGLE]:Vt(Mt,(e=>{e.pushInt(Br(e.activeLoc.angle,ir))})),[Kt.LOC_ANIM]:Vt(Mt,(e=>{const t=Br(e.popInt(),Tr);Zl.animLoc(e.activeLoc,t.id)})),[Kt.LOC_CATEGORY]:Vt(Mt,(e=>{e.pushInt(Br(e.activeLoc.type,tr).category)})),[Kt.LOC_CHANGE]:Vt(Mt,(e=>{const[t,i]=e.popInts(2),r=Br(t,tr);Br(i,sr),Zl.removeLoc(e.activeLoc,i);const{level:s,x:n,z:a,angle:o,shape:c}=e.activeLoc,l=new ss(s,n,a,r.width,r.length,Yr.DESPAWN,r.id,c,o),h=Zl.getZone(n,a,s).getLocsUnsafe(ji.packZoneCoord(n,a));for(const e of h)if(e!==l&&e.angle===o&&e.shape===c){Zl.removeLoc(e,i);break}Zl.addLoc(l,i),e.activeLoc=l,e.pointerAdd(Mt[e.intOperand])})),[Kt.LOC_COORD]:Vt(Mt,(e=>{const t=e.activeLoc;e.pushInt(ji.packCoord(t.level,t.x,t.z))})),[Kt.LOC_DEL]:Vt(Mt,(e=>{const t=Br(e.popInt(),sr),{level:i,x:r,z:s,angle:n,shape:a}=e.activeLoc,o=Zl.getZone(r,s,i).getLocsUnsafe(ji.packZoneCoord(r,s));for(const i of o)if(i!==e.activeLoc&&i.angle===n&&i.shape===a){Zl.removeLoc(i,t);break}Zl.removeLoc(e.activeLoc,t)})),[Kt.LOC_FIND]:e=>{const[t,i]=e.popInts(2),r=Br(i,tr),s=Br(t,nr),n=Zl.getLoc(s.x,s.z,s.level,r.id);n?(e.activeLoc=n,e.pointerAdd(Mt[e.intOperand]),e.pushInt(1)):e.pushInt(0)},[Kt.LOC_FINDALLZONE]:e=>{const t=Br(e.popInt(),nr);e.locIterator=new rs(Zl.currentTick,t.level,t.x,t.z),e._activeLoc&&(e._activeLoc2=e._activeLoc,e.pointerAdd(Gt.ActiveLoc2))},[Kt.LOC_FINDNEXT]:e=>{const t=e.locIterator?.next();t&&!t.done?(e.activeLoc=t.value,e.pointerAdd(Mt[e.intOperand]),e.pushInt(1)):e.pushInt(0)},[Kt.LOC_PARAM]:Vt(Mt,(e=>{const t=Br(e.popInt(),ar),i=Br(e.activeLoc.type,tr);t.isString()?e.pushString(rt(t.id,i,t.defaultString)):e.pushInt(st(t.id,i,t.defaultInt))})),[Kt.LOC_TYPE]:Vt(Mt,(e=>{e.pushInt(Br(e.activeLoc.type,tr).id)})),[Kt.LOC_NAME]:Vt(Mt,(e=>{e.pushString(Br(e.activeLoc.type,tr).name??'null')})),[Kt.LOC_SHAPE]:Vt(Mt,(e=>{e.pushInt(Br(e.activeLoc.shape,rr))}))},as={[Kt.LC_NAME]:e=>{const t=Br(e.popInt(),tr);e.pushString(t.name??t.debugname??'null')},[Kt.LC_PARAM]:e=>{const[t,i]=e.popInts(2),r=Br(t,tr),s=Br(i,ar);s.isString()?e.pushString(rt(s.id,r,s.defaultString)):e.pushInt(st(s.id,r,s.defaultInt))},[Kt.LC_CATEGORY]:e=>{e.pushInt(Br(e.popInt(),tr).category)},[Kt.LC_DESC]:e=>{e.pushString(Br(e.popInt(),tr).desc??'null')},[Kt.LC_DEBUGNAME]:e=>{e.pushString(Br(e.popInt(),tr).debugname??'null')},[Kt.LC_WIDTH]:e=>{e.pushInt(Br(e.popInt(),tr).width)},[Kt.LC_LENGTH]:e=>{e.pushInt(Br(e.popInt(),tr).length)}},os=(e=>(e[e.PROC=0]='PROC',e[e.LABEL=1]='LABEL',e[e.DEBUGPROC=2]='DEBUGPROC',e[e.APNPC1=3]='APNPC1',e[e.APNPC2=4]='APNPC2',e[e.APNPC3=5]='APNPC3',e[e.APNPC4=6]='APNPC4',e[e.APNPC5=7]='APNPC5',e[e.APNPCU=8]='APNPCU',e[e.APNPCT=9]='APNPCT',e[e.OPNPC1=10]='OPNPC1',e[e.OPNPC2=11]='OPNPC2',e[e.OPNPC3=12]='OPNPC3',e[e.OPNPC4=13]='OPNPC4',e[e.OPNPC5=14]='OPNPC5',e[e.OPNPCU=15]='OPNPCU',e[e.OPNPCT=16]='OPNPCT',e[e.AI_APNPC1=17]='AI_APNPC1',e[e.AI_APNPC2=18]='AI_APNPC2',e[e.AI_APNPC3=19]='AI_APNPC3',e[e.AI_APNPC4=20]='AI_APNPC4',e[e.AI_APNPC5=21]='AI_APNPC5',e[e.AI_OPNPC1=24]='AI_OPNPC1',e[e.AI_OPNPC2=25]='AI_OPNPC2',e[e.AI_OPNPC3=26]='AI_OPNPC3',e[e.AI_OPNPC4=27]='AI_OPNPC4',e[e.AI_OPNPC5=28]='AI_OPNPC5',e[e.APOBJ1=31]='APOBJ1',e[e.APOBJ2=32]='APOBJ2',e[e.APOBJ3=33]='APOBJ3',e[e.APOBJ4=34]='APOBJ4',e[e.APOBJ5=35]='APOBJ5',e[e.APOBJU=36]='APOBJU',e[e.APOBJT=37]='APOBJT',e[e.OPOBJ1=38]='OPOBJ1',e[e.OPOBJ2=39]='OPOBJ2',e[e.OPOBJ3=40]='OPOBJ3',e[e.OPOBJ4=41]='OPOBJ4',e[e.OPOBJ5=42]='OPOBJ5',e[e.OPOBJU=43]='OPOBJU',e[e.OPOBJT=44]='OPOBJT',e[e.AI_APOBJ1=45]='AI_APOBJ1',e[e.AI_APOBJ2=46]='AI_APOBJ2',e[e.AI_APOBJ3=47]='AI_APOBJ3',e[e.AI_APOBJ4=48]='AI_APOBJ4',e[e.AI_APOBJ5=49]='AI_APOBJ5',e[e.AI_OPOBJ1=52]='AI_OPOBJ1',e[e.AI_OPOBJ2=53]='AI_OPOBJ2',e[e.AI_OPOBJ3=54]='AI_OPOBJ3',e[e.AI_OPOBJ4=55]='AI_OPOBJ4',e[e.AI_OPOBJ5=56]='AI_OPOBJ5',e[e.APLOC1=59]='APLOC1',e[e.APLOC2=60]='APLOC2',e[e.APLOC3=61]='APLOC3',e[e.APLOC4=62]='APLOC4',e[e.APLOC5=63]='APLOC5',e[e.APLOCU=64]='APLOCU',e[e.APLOCT=65]='APLOCT',e[e.OPLOC1=66]='OPLOC1',e[e.OPLOC2=67]='OPLOC2',e[e.OPLOC3=68]='OPLOC3',e[e.OPLOC4=69]='OPLOC4',e[e.OPLOC5=70]='OPLOC5',e[e.OPLOCU=71]='OPLOCU',e[e.OPLOCT=72]='OPLOCT',e[e.AI_APLOC1=73]='AI_APLOC1',e[e.AI_APLOC2=74]='AI_APLOC2',e[e.AI_APLOC3=75]='AI_APLOC3',e[e.AI_APLOC4=76]='AI_APLOC4',e[e.AI_APLOC5=77]='AI_APLOC5',e[e.AI_OPLOC1=80]='AI_OPLOC1',e[e.AI_OPLOC2=81]='AI_OPLOC2',e[e.AI_OPLOC3=82]='AI_OPLOC3',e[e.AI_OPLOC4=83]='AI_OPLOC4',e[e.AI_OPLOC5=84]='AI_OPLOC5',e[e.APPLAYER1=87]='APPLAYER1',e[e.APPLAYER2=88]='APPLAYER2',e[e.APPLAYER3=89]='APPLAYER3',e[e.APPLAYER4=90]='APPLAYER4',e[e.APPLAYER5=91]='APPLAYER5',e[e.APPLAYERU=92]='APPLAYERU',e[e.APPLAYERT=93]='APPLAYERT',e[e.OPPLAYER1=94]='OPPLAYER1',e[e.OPPLAYER2=95]='OPPLAYER2',e[e.OPPLAYER3=96]='OPPLAYER3',e[e.OPPLAYER4=97]='OPPLAYER4',e[e.OPPLAYER5=98]='OPPLAYER5',e[e.OPPLAYERU=99]='OPPLAYERU',e[e.OPPLAYERT=100]='OPPLAYERT',e[e.AI_APPLAYER1=101]='AI_APPLAYER1',e[e.AI_APPLAYER2=102]='AI_APPLAYER2',e[e.AI_APPLAYER3=103]='AI_APPLAYER3',e[e.AI_APPLAYER4=104]='AI_APPLAYER4',e[e.AI_APPLAYER5=105]='AI_APPLAYER5',e[e.AI_OPPLAYER1=108]='AI_OPPLAYER1',e[e.AI_OPPLAYER2=109]='AI_OPPLAYER2',e[e.AI_OPPLAYER3=110]='AI_OPPLAYER3',e[e.AI_OPPLAYER4=111]='AI_OPPLAYER4',e[e.AI_OPPLAYER5=112]='AI_OPPLAYER5',e[e.QUEUE=116]='QUEUE',e[e.AI_QUEUE1=117]='AI_QUEUE1',e[e.AI_QUEUE2=118]='AI_QUEUE2',e[e.AI_QUEUE3=119]='AI_QUEUE3',e[e.AI_QUEUE4=120]='AI_QUEUE4',e[e.AI_QUEUE5=121]='AI_QUEUE5',e[e.AI_QUEUE6=122]='AI_QUEUE6',e[e.AI_QUEUE7=123]='AI_QUEUE7',e[e.AI_QUEUE8=124]='AI_QUEUE8',e[e.AI_QUEUE9=125]='AI_QUEUE9',e[e.AI_QUEUE10=126]='AI_QUEUE10',e[e.AI_QUEUE11=127]='AI_QUEUE11',e[e.AI_QUEUE12=128]='AI_QUEUE12',e[e.AI_QUEUE13=129]='AI_QUEUE13',e[e.AI_QUEUE14=130]='AI_QUEUE14',e[e.AI_QUEUE15=131]='AI_QUEUE15',e[e.AI_QUEUE16=132]='AI_QUEUE16',e[e.AI_QUEUE17=133]='AI_QUEUE17',e[e.AI_QUEUE18=134]='AI_QUEUE18',e[e.AI_QUEUE19=135]='AI_QUEUE19',e[e.AI_QUEUE20=136]='AI_QUEUE20',e[e.SOFTTIMER=137]='SOFTTIMER',e[e.TIMER=138]='TIMER',e[e.AI_TIMER=139]='AI_TIMER',e[e.OPHELD1=140]='OPHELD1',e[e.OPHELD2=141]='OPHELD2',e[e.OPHELD3=142]='OPHELD3',e[e.OPHELD4=143]='OPHELD4',e[e.OPHELD5=144]='OPHELD5',e[e.OPHELDU=145]='OPHELDU',e[e.OPHELDT=146]='OPHELDT',e[e.IF_BUTTON=147]='IF_BUTTON',e[e.INV_BUTTON1=148]='INV_BUTTON1',e[e.INV_BUTTON2=149]='INV_BUTTON2',e[e.INV_BUTTON3=150]='INV_BUTTON3',e[e.INV_BUTTON4=151]='INV_BUTTON4',e[e.INV_BUTTON5=152]='INV_BUTTON5',e[e.INV_BUTTOND=153]='INV_BUTTOND',e[e.IF_CLOSE=154]='IF_CLOSE',e[e.LOGIN=155]='LOGIN',e[e.LOGOUT=156]='LOGOUT',e[e.TUTORIAL_CLICKSIDE=157]='TUTORIAL_CLICKSIDE',e[e.MOVE=158]='MOVE',e[e.WALKTRIGGER=159]='WALKTRIGGER',e[e.AI_WALKTRIGGER=160]='AI_WALKTRIGGER',e[e.LEVELUP=161]='LEVELUP',e))(os||{});(Mr=os||(os={})).toString=function(e){return Mr[e].toLowerCase()};var cs=os,ls=(e=>(e[e.SCRIPT=0]='SCRIPT',e[e.ENGINE=1]='ENGINE',e))(ls||{}),hs=ls,ds={[Kt.NPC_FINDUID]:e=>{const t=e.popInt(),i=65535&t,r=t>>16&65535,s=Zl.getNpc(i);s&&s.type===r?(e.activeNpc=s,e.pointerAdd(kt[e.intOperand]),e.pushInt(1)):e.pushInt(0)},[Kt.NPC_ADD]:e=>{const[t,i,r]=e.popInts(3),s=Br(t,nr),n=Br(i,or);Br(r,sr);const a=new kl(s.level,s.x,s.z,n.size,n.size,Yr.DESPAWN,Zl.getNextNid(),n.id,n.moverestrict,n.blockwalk);Zl.addNpc(a,r),e.activeNpc=a,e.pointerAdd(kt[e.intOperand])},[Kt.NPC_ANIM]:Vt(kt,(e=>{const t=Br(e.popInt(),Ji),i=e.popInt();e.activeNpc.playAnimation(i,t)})),[Kt.NPC_BASESTAT]:Vt(kt,(e=>{const t=Br(e.popInt(),cr);e.pushInt(e.activeNpc.baseLevels[t])})),[Kt.NPC_CATEGORY]:Vt(kt,(e=>{e.pushInt(Br(e.activeNpc.type,or).category)})),[Kt.NPC_COORD]:Vt(kt,(e=>{const t=e.activeNpc;e.pushInt(ji.packCoord(t.level,t.x,t.z))})),[Kt.NPC_DEL]:Vt(kt,(e=>{Zl.removeNpc(e.activeNpc,Br(e.activeNpc.type,or).respawnrate)})),[Kt.NPC_DELAY]:Vt(kt,(e=>{e.activeNpc.delay=Zl.currentTick+Br(e.popInt(),Ji)+1,e.execution=$t.NPC_SUSPENDED})),[Kt.NPC_FACESQUARE]:Vt(kt,(e=>{const t=Br(e.popInt(),nr);e.activeNpc.faceSquare(t.x,t.z)})),[Kt.NPC_FINDEXACT]:e=>{const[t,i]=e.popInts(2),r=Br(t,nr),s=Br(i,or);e.npcIterator=new is(Zl.currentTick,r.level,r.x,r.z,0,0,Jr.ZONE);for(const t of e.npcIterator)if(t.type===s.id&&t.x===r.x&&t.level===r.level&&t.z===r.z)return e.activeNpc=t,e.pointerAdd(kt[e.intOperand]),void e.pushInt(1);e.pushInt(0)},[Kt.NPC_FINDHERO]:Vt(kt,(e=>{const t=e.activeNpc.findHero();if(-1===t)return void e.pushInt(0);const i=Zl.getPlayerByUid(t);i?(e.activePlayer=i,e.pointerAdd(Gt.ActivePlayer),e.pushInt(1)):e.pushInt(0)})),[Kt.NPC_PARAM]:Vt(kt,(e=>{const t=Br(e.popInt(),ar),i=Br(e.activeNpc.type,or);t.isString()?e.pushString(rt(t.id,i,t.defaultString)):e.pushInt(st(t.id,i,t.defaultInt))})),[Kt.NPC_QUEUE]:Vt(kt,(e=>{const t=Br(e.popInt(),Ji),i=e.popInt(),r=Br(e.popInt(),hr),s=Br(e.activeNpc.type,or),n=jt.getByTrigger(cs.AI_QUEUE1+r-1,s.id,s.category);n&&e.activeNpc.enqueueScript(n,t,i)})),[Kt.NPC_RANGE]:Vt(kt,(e=>{const t=Br(e.popInt(),nr),i=e.activeNpc;t.level!==i.level?e.pushInt(-1):e.pushInt(ji.distanceTo(i,{x:t.x,z:t.z,width:1,length:1}))})),[Kt.NPC_SAY]:Vt(kt,(e=>{e.activeNpc.say(e.popString())})),[Kt.NPC_SETHUNT]:Vt(kt,(e=>{e.activeNpc.huntrange=Br(e.popInt(),Ji)})),[Kt.NPC_SETHUNTMODE]:Vt(kt,(e=>{e.activeNpc.huntMode=Br(e.popInt(),dr).id})),[Kt.NPC_SETMODE]:Vt(kt,(e=>{const t=Br(e.popInt(),ur);if(e.activeNpc.clearWaypoints(),t===Xe.NULL||t===Xe.NONE||t===Xe.WANDER||t===Xe.PATROL)return e.activeNpc.clearInteraction(),void(e.activeNpc.targetOp=t);let i;e.activeNpc.targetOp=t,i=t>=Xe.OPNPC1?e._activeNpc2:t>=Xe.OPOBJ1?e._activeObj:t>=Xe.OPLOC1?e._activeLoc:e._activePlayer,i?i instanceof kl||i instanceof $r||i instanceof ss?e.activeNpc.setInteraction(hs.SCRIPT,i,t,{type:i.type,com:-1}):e.activeNpc.setInteraction(hs.SCRIPT,i,t):e.activeNpc.noMode()})),[Kt.NPC_STAT]:Vt(kt,(e=>{const t=Br(e.popInt(),cr);e.pushInt(e.activeNpc.levels[t])})),[Kt.NPC_STATHEAL]:Vt(kt,(e=>{const[t,i,r]=e.popInts(3);Br(t,cr),Br(i,Ji),Br(r,Ji);const s=e.activeNpc,n=s.baseLevels[t],a=s.levels[t],o=a+(i+a*r/100);s.levels[t]=Math.min(o,n),0===t&&s.levels[t]===s.baseLevels[t]&&s.resetHeroPoints()})),[Kt.NPC_TYPE]:Vt(kt,(e=>{e.pushInt(Br(e.activeNpc.type,or).id)})),[Kt.NPC_DAMAGE]:Vt(kt,(e=>{const t=Br(e.popInt(),Ji),i=Br(e.popInt(),pr);e.activeNpc.applyDamage(t,i)})),[Kt.NPC_NAME]:Vt(kt,(e=>{e.pushString(Br(e.activeNpc.type,or).name??'null')})),[Kt.NPC_UID]:Vt(kt,(e=>{e.pushInt(e.activeNpc.uid)})),[Kt.NPC_SETTIMER]:Vt(kt,(e=>{e.activeNpc.setTimer(Br(e.popInt(),Ji))})),[Kt.SPOTANIM_NPC]:Vt(kt,(e=>{const t=Br(e.popInt(),Ji),i=Br(e.popInt(),Ji),r=Br(e.popInt(),fr);e.activeNpc.spotanim(r.id,i,t)})),[Kt.NPC_FIND]:e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,nr),a=Br(i,or);Br(r,Ji);const o=Br(s,vr);let c,l=r;const h=new is(Zl.currentTick,n.level,n.x,n.z,r,o,Jr.DISTANCE);for(const e of h)if(e&&e.type===a.id){const t=ji.distanceToSW(n,e);t<=l&&(c=e,l=t)}c?(e.activeNpc=c,e.pointerAdd(kt[e.intOperand]),e.pushInt(1)):e.pushInt(0)},[Kt.NPC_FINDALLANY]:e=>{const[t,i,r]=e.popInts(3),s=Br(t,nr);Br(i,Ji);const n=Br(r,vr);e.npcIterator=new is(Zl.currentTick,s.level,s.x,s.z,i,n,Jr.DISTANCE),e._activeNpc&&(e._activeNpc2=e._activeNpc,e.pointerAdd(Gt.ActiveNpc2))},[Kt.NPC_FINDALLZONE]:e=>{const t=Br(e.popInt(),nr);e.npcIterator=new is(Zl.currentTick,t.level,t.x,t.z,0,0,Jr.ZONE),e._activeNpc&&(e._activeNpc2=e._activeNpc,e.pointerAdd(Gt.ActiveNpc2))},[Kt.NPC_FINDNEXT]:e=>{const t=e.npcIterator?.next();t&&!t.done?(e.activeNpc=t.value,e.pointerAdd(kt[e.intOperand]),e.pushInt(1)):e.pushInt(0)},[Kt.NPC_TELE]:Vt(kt,(e=>{const t=Br(e.popInt(),nr);e.activeNpc.teleport(t.x,t.z,t.level)})),[Kt.NPC_WALK]:Vt(kt,(e=>{const t=Br(e.popInt(),nr);e.activeNpc.queueWaypoint(t.x,t.z)})),[Kt.NPC_CHANGETYPE]:Vt(kt,(e=>{e.activeNpc.changeType(Br(e.popInt(),or).id)})),[Kt.NPC_GETMODE]:Vt(kt,(e=>{e.pushInt(e.activeNpc.targetOp)})),[Kt.NPC_HEROPOINTS]:Vt([Gt.ActivePlayer,...kt],(e=>{e.activeNpc.addHero(e.activePlayer.uid,Br(e.popInt(),Ji))})),[Kt.NPC_WALKTRIGGER]:Vt(kt,(e=>{const[t,i]=e.popInts(2);Br(t,hr),e.activeNpc.walktrigger=t-1,e.activeNpc.walktriggerArg=i})),[Kt.NPC_STATADD]:Vt(kt,(e=>{const[t,i,r]=e.popInts(3);Br(t,cr),Br(i,Ji),Br(r,Ji);const s=e.activeNpc,n=s.levels[t],a=n+(i+n*r/100);s.levels[t]=Math.min(a,255),0===t&&s.levels[t]>=s.baseLevels[t]&&s.resetHeroPoints()})),[Kt.NPC_STATSUB]:Vt(kt,(e=>{const[t,i,r]=e.popInts(3);Br(t,cr),Br(i,Ji),Br(r,Ji);const s=e.activeNpc,n=s.levels[t],a=n-(i+n*r/100);s.levels[t]=Math.max(a,0)})),[Kt.NPC_ATTACKRANGE]:Vt(kt,(e=>{e.pushInt(Br(e.activeNpc.type,or).attackrange)}))},us=ds,ps={[Kt.NC_NAME]:e=>{const t=Br(e.popInt(),or);e.pushString(t.name??t.debugname??'null')},[Kt.NC_PARAM]:e=>{const[t,i]=e.popInts(2),r=Br(t,or),s=Br(i,ar);s.isString()?e.pushString(rt(i,r,s.defaultString)):e.pushInt(st(i,r,s.defaultInt))},[Kt.NC_CATEGORY]:e=>{e.pushInt(Br(e.popInt(),or).category)},[Kt.NC_DESC]:e=>{e.pushString(Br(e.popInt(),or).desc??'null')},[Kt.NC_DEBUGNAME]:e=>{e.pushString(Br(e.popInt(),or).debugname??'null')},[Kt.NC_OP]:e=>{const[t,i]=e.popInts(2),r=Br(t,or);Br(i,Ji),r.op?e.pushString(r.op[i-1]??''):e.pushString('')}},gs=class{static _sin=new Int32Array(16384);static _cos=new Int32Array(16384);static{const e=.0003834951969714103;for(let t=0;t<16384;t++)this._sin[t]=16384*Math.sin(t*e)|0,this._cos[t]=16384*Math.cos(t*e)|0}static radians(e){return(16383&e)/16384*6.283185307179586}static atan2(e,t){return 16383&Math.round(2607.5945876176133*Math.atan2(e,t))}static sin(e){return this._sin[16383&e]}static cos(e){return this._cos[16383&e]}},ms={[Kt.ADD]:e=>{const t=e.popInt(),i=e.popInt();e.pushInt(i+t)},[Kt.SUB]:e=>{const t=e.popInt(),i=e.popInt();e.pushInt(i-t)},[Kt.MULTIPLY]:e=>{const t=e.popInt(),i=e.popInt();e.pushInt(i*t)},[Kt.DIVIDE]:e=>{const t=e.popInt(),i=e.popInt();e.pushInt(i/t)},[Kt.RANDOM]:e=>{const t=e.popInt();e.pushInt(Math.random()*t)},[Kt.RANDOMINC]:e=>{const t=e.popInt();e.pushInt(Math.random()*(t+1))},[Kt.INTERPOLATE]:e=>{const[t,i,r,s,n]=e.popInts(5),a=Math.floor((i-t)/(s-r))*(n-r)+t;e.pushInt(a)},[Kt.ADDPERCENT]:e=>{const[t,i]=e.popInts(2);e.pushInt(t*i/100+t|0)},[Kt.SETBIT]:e=>{const[t,i]=e.popInts(2);e.pushInt(t|1<{const[t,i]=e.popInts(2);e.pushInt(t&~(1<{const[t,i]=e.popInts(2);e.pushInt(t&1<{const[t,i]=e.popInts(2);e.pushInt(t%i)},[Kt.POW]:e=>{const[t,i]=e.popInts(2);e.pushInt(Math.pow(t,i))},[Kt.INVPOW]:e=>{const[t,i]=e.popInts(2);if(0===t||0===i)e.pushInt(0);else switch(i){case 1:return void e.pushInt(t);case 2:return void e.pushInt(Math.sqrt(t));case 3:return void e.pushInt(Math.cbrt(t));case 4:return void e.pushInt(Math.sqrt(Math.sqrt(t)));default:return void e.pushInt(Math.pow(t,1/i))}},[Kt.AND]:e=>{const[t,i]=e.popInts(2);e.pushInt(t&i)},[Kt.OR]:e=>{const[t,i]=e.popInts(2);e.pushInt(t|i)},[Kt.MIN]:e=>{const[t,i]=e.popInts(2);e.pushInt(Math.min(t,i))},[Kt.MAX]:e=>{const[t,i]=e.popInts(2);e.pushInt(Math.max(t,i))},[Kt.SCALE]:e=>{const[t,i,r]=e.popInts(3);e.pushInt(t*r/i)},[Kt.BITCOUNT]:e=>{var t;e.pushInt((t=e.popInt(),16843009*((t=(858993459&(t-=t>>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135)>>24))},[Kt.TOGGLEBIT]:e=>{const[t,i]=e.popInts(2);e.pushInt(t^1<{const[t,i,r]=e.popInts(3);e.pushInt(function(e,t,i){return e|Yt[i-t+1]<{const[t,i,r]=e.popInts(3);e.pushInt(Qt(t,i,r))},[Kt.GETBIT_RANGE]:e=>{const[t,i,r]=e.popInts(3),s=31-r;e.pushInt(t<>>i+s)},[Kt.SETBIT_RANGE_TOINT]:e=>{const[t,i,r,s]=e.popInts(4),n=Qt(t,r,s),a=Yt[s-r+1];let o=i;i>a&&(o=a),e.pushInt(n|o<{e.pushInt(gs.sin(e.popInt()))},[Kt.COS_DEG]:e=>{e.pushInt(gs.cos(e.popInt()))},[Kt.ATAN2_DEG]:e=>{e.pushInt(gs.atan2(e.popInt(),e.popInt()))},[Kt.ABS]:e=>{e.pushInt(Math.abs(e.popInt()))}},ys=ms,Es={[Kt.OBJ_ADD]:e=>{const[t,i,r,s]=e.popInts(4);if(-1===i||-1===r)return;const n=Br(i,mr);Br(s,sr);const a=Br(t,nr);if(Br(r,yr),0!==n.dummyitem)throw new Error(`attempted to add dummy item: ${n.debugname}`);if(!n.members||vt.NODE_MEMBERS)if(n.stackable&&1!==r){const t=new $r(a.level,a.x,a.z,Yr.DESPAWN,i,r);Zl.addObj(t,e.activePlayer.pid,s),e.activeObj=t,e.pointerAdd(xt[e.intOperand])}else for(let t=0;t{const[t,i,r,s]=e.popInts(4);if(-1===i||-1===r)return;const n=Br(i,mr);Br(s,sr);const a=Br(t,nr);if(Br(r,yr),0!==n.dummyitem)throw new Error(`attempted to add dummy item: ${n.debugname}`);if(!n.members||vt.NODE_MEMBERS)if(n.stackable&&1!==r){const t=new $r(a.level,a.x,a.z,Yr.DESPAWN,i,r);Zl.addObj(t,-1,s),e.activeObj=t,e.pointerAdd(xt[e.intOperand])}else for(let t=0;t{const t=Br(e.popInt(),ar),i=Br(e.activeObj.type,mr);t.isString()?e.pushString(rt(t.id,i,t.defaultString)):e.pushInt(st(t.id,i,t.defaultInt))},[Kt.OBJ_NAME]:e=>{const t=Br(e.activeObj.type,mr);e.pushString(t.name??t.debugname??'null')},[Kt.OBJ_DEL]:e=>{const t=Tt.get(e.activeObj.type).respawnrate;e.pointerGet(Ft[e.intOperand]),Zl.removeObj(e.activeObj,t)},[Kt.OBJ_COUNT]:e=>{e.pushInt(Br(e.activeObj.count,yr))},[Kt.OBJ_TYPE]:e=>{e.pushInt(Br(e.activeObj.type,mr).id)},[Kt.OBJ_TAKEITEM]:e=>{const t=Br(e.popInt(),Er),i=e.activeObj,r=Tt.get(i.type),s=Zl.getZone(i.x,i.z,i.level);for(const n of s.getObjsSafe(ji.packZoneCoord(i.x,i.z)))if(n.type===i.type&&n.count===i.count&&(-1===n.receiverId||n.receiverId===e.activePlayer.pid)){if(e.activePlayer.playerLog('Picked up item',r.debugname),e.activePlayer.invAdd(t.id,i.type,i.count),i.lifecycle===Yr.RESPAWN){Zl.removeObj(i,r.respawnrate);break}if(i.lifecycle===Yr.DESPAWN){Zl.removeObj(i,0);break}}},[Kt.OBJ_COORD]:e=>{const t=e.activeObj;e.pushInt(ji.packCoord(t.level,t.x,t.z))}},_s={[Kt.OC_NAME]:e=>{const t=Br(e.popInt(),mr);e.pushString(t.name??t.debugname??'null')},[Kt.OC_PARAM]:e=>{const[t,i]=e.popInts(2),r=Br(t,mr),s=Br(i,ar);s.isString()?e.pushString(rt(s.id,r,s.defaultString)):e.pushInt(st(s.id,r,s.defaultInt))},[Kt.OC_CATEGORY]:e=>{e.pushInt(Br(e.popInt(),mr).category)},[Kt.OC_DESC]:e=>{e.pushString(Br(e.popInt(),mr).desc??'null')},[Kt.OC_MEMBERS]:e=>{e.pushInt(Br(e.popInt(),mr).members?1:0)},[Kt.OC_WEIGHT]:e=>{e.pushInt(Br(e.popInt(),mr).weight)},[Kt.OC_WEARPOS]:e=>{e.pushInt(Br(e.popInt(),mr).wearpos)},[Kt.OC_WEARPOS2]:e=>{e.pushInt(Br(e.popInt(),mr).wearpos2)},[Kt.OC_WEARPOS3]:e=>{e.pushInt(Br(e.popInt(),mr).wearpos3)},[Kt.OC_COST]:e=>{e.pushInt(Br(e.popInt(),mr).cost)},[Kt.OC_TRADEABLE]:e=>{e.pushInt(Br(e.popInt(),mr).tradeable?1:0)},[Kt.OC_DEBUGNAME]:e=>{e.pushString(Br(e.popInt(),mr).debugname??'null')},[Kt.OC_CERT]:e=>{const t=Br(e.popInt(),mr);-1==t.certtemplate&&t.certlink>=0?e.pushInt(t.certlink):e.pushInt(t.id)},[Kt.OC_UNCERT]:e=>{const t=Br(e.popInt(),mr);t.certtemplate>=0&&t.certlink>=0?e.pushInt(t.certlink):e.pushInt(t.id)},[Kt.OC_STACKABLE]:e=>{e.pushInt(Br(e.popInt(),mr).stackable?1:0)}},As=class extends Te{type;script;args;delay;lastInt=0;constructor(e,t,i,r){super(),this.type=e,this.script=t,this.args=i,this.delay=r}},vs=class extends Te{script;delay;constructor(e,t){super(),this.script=e,this.delay=t}},Ts=class e{constructor(t,i){this.id=t,this.length=i,e.all.push(this),e.byId[t]=this}static all=[];static byId=[];static IF_OPENCHATMODAL=new e(14,2);static IF_OPENMAINSIDEMODAL=new e(28,4);static IF_CLOSE=new e(129,0);static IF_OPENSIDEOVERLAY=new e(167,3);static IF_OPENMAINMODAL=new e(168,2);static IF_OPENSIDEMODAL=new e(195,2);static IF_SETCOLOUR=new e(2,4);static IF_SETHIDE=new e(26,3);static IF_SETOBJECT=new e(46,6);static IF_SHOWSIDE=new e(84,1);static IF_SETMODEL=new e(87,4);static IF_SETRECOL=new e(103,6);static IF_SETANIM=new e(146,4);static IF_SETPLAYERHEAD=new e(197,2);static IF_SETTEXT=new e(201,-2);static IF_SETNPCHEAD=new e(204,4);static IF_SETPOSITION=new e(209,6);static TUTORIAL_FLASHSIDE=new e(126,1);static TUTORIAL_OPENCHAT=new e(185,2);static UPDATE_INV_STOP_TRANSMIT=new e(15,2);static UPDATE_INV_FULL=new e(98,-2);static UPDATE_INV_PARTIAL=new e(213,-2);static CAM_LOOKAT=new e(74,6);static CAM_SHAKE=new e(13,4);static CAM_MOVETO=new e(3,6);static CAM_RESET=new e(239,0);static NPC_INFO=new e(1,-2);static PLAYER_INFO=new e(184,-2);static FINISH_TRACKING=new e(133,0);static ENABLE_TRACKING=new e(226,0);static MESSAGE_GAME=new e(4,-1);static UPDATE_IGNORELIST=new e(21,-2);static CHAT_FILTER_SETTINGS=new e(32,3);static MESSAGE_PRIVATE=new e(41,-1);static UPDATE_FRIENDLIST=new e(152,9);static UNSET_MAP_FLAG=new e(19,0);static UPDATE_RUNWEIGHT=new e(22,2);static HINT_ARROW=new e(25,6);static UPDATE_REBOOT_TIMER=new e(43,2);static UPDATE_STAT=new e(44,6);static UPDATE_RUNENERGY=new e(68,1);static RESET_ANIMS=new e(136,0);static UPDATE_UID192=new e(139,2);static LAST_LOGIN_INFO=new e(140,9);static LOGOUT=new e(142,0);static P_COUNTDIALOG=new e(243,0);static SET_MULTIWAY=new e(254,1);static DATA_LOC_DONE=new e(20,2);static DATA_LAND_DONE=new e(80,2);static DATA_LAND=new e(132,-2);static DATA_LOC=new e(220,-2);static REBUILD_NORMAL=new e(237,-2);static VARP_SMALL=new e(150,3);static VARP_LARGE=new e(175,6);static RESET_CLIENT_VARCACHE=new e(193,0);static SYNTH_SOUND=new e(12,5);static MIDI_SONG=new e(54,-1);static MIDI_JINGLE=new e(212,-2);static UPDATE_ZONE_PARTIAL_FOLLOWS=new e(7,2);static UPDATE_ZONE_FULL_FOLLOWS=new e(135,2);static UPDATE_ZONE_PARTIAL_ENCLOSED=new e(162,-2)},Cs=(e=>(e[e.STATIONARY=0]='STATIONARY',e[e.CRAWL=1]='CRAWL',e[e.WALK=2]='WALK',e[e.RUN=3]='RUN',e[e.INSTANT=4]='INSTANT',e))(Cs||{}),Is=Cs,Ss=(e=>(e[e.SMART=0]='SMART',e[e.NAIVE=1]='NAIVE',e[e.FLY=2]='FLY',e))(Ss||{}),Os=Ss,Ns=class e extends qr{moveRestrict;blockWalk;moveStrategy;coordmask;entitymask;moveSpeed=Is.INSTANT;walkDir=-1;runDir=-1;waypointIndex=-1;waypoints=new Int32Array(25);lastX=-1;lastZ=-1;lastLevel=-1;tele=!1;jump=!1;lastStepX=-1;lastStepZ=-1;stepsTaken=0;lastInt=-1;lastCrawl=!1;walktrigger=-1;walktriggerArg=0;interacted=!1;repathed=!1;target=null;targetOp=-1;targetSubject={type:-1,com:-1};targetX=-1;targetZ=-1;apRange=10;apRangeCalled=!1;alreadyFacedEntity=!1;mask=0;exactStartX=-1;exactStartZ=-1;exactEndX=-1;exactEndZ=-1;exactMoveStart=-1;exactMoveEnd=-1;exactMoveDirection=-1;faceX=-1;faceZ=-1;orientationX=-1;orientationZ=-1;faceEntity=-1;damageTaken=-1;damageType=-1;animId=-1;animDelay=-1;chat=null;graphicId=-1;graphicHeight=-1;graphicDelay=-1;constructor(e,t,i,r,s,n,a,o,c,l,h){super(e,t,i,r,s,n),this.moveRestrict=a,this.blockWalk=o,this.moveStrategy=c,this.coordmask=l,this.entitymask=h,this.lastStepX=t-1,this.lastStepZ=i}processMovement(){return!(!this.hasWaypoints()||this.moveSpeed===Is.STATIONARY||this.moveSpeed===Is.INSTANT)&&(this.moveSpeed===Is.CRAWL?(this.lastCrawl=!this.lastCrawl,this.lastCrawl&&-1===this.walkDir&&(this.walkDir=this.validateAndAdvanceStep()),!0):(-1===this.walkDir&&(this.walkDir=this.validateAndAdvanceStep(),this.moveSpeed===Is.RUN&&-1!==this.walkDir&&-1===this.runDir&&(this.runDir=this.validateAndAdvanceStep())),!0))}refreshZonePresence(e,t,i){if(this.x!=e||this.z!==t||this.level!==i){switch(this.blockWalk){case lt.NPC:Zl.gameMap.changeNpcCollision(this.width,e,t,i,!1),Zl.gameMap.changeNpcCollision(this.width,this.x,this.z,this.level,!0);break;case lt.ALL:Zl.gameMap.changeNpcCollision(this.width,e,t,i,!1),Zl.gameMap.changeNpcCollision(this.width,this.x,this.z,this.level,!0),Zl.gameMap.changePlayerCollision(this.width,e,t,i,!1),Zl.gameMap.changePlayerCollision(this.width,this.x,this.z,this.level,!0)}this.lastStepX=e,this.lastStepZ=t}ji.zone(e)===ji.zone(this.x)&&ji.zone(t)===ji.zone(this.z)&&i==this.level||(Zl.getZone(e,t,i).leave(this),Zl.getZone(this.x,this.z,this.level).enter(this))}validateAndAdvanceStep(){const e=this.takeStep();if(null===e)return-1;if(-1===e)return this.waypointIndex--,-1!=this.waypointIndex?this.validateAndAdvanceStep():-1;const t=this.x,i=this.z;return this.x=ji.moveX(this.x,e),this.z=ji.moveZ(this.z,e),this.orientationX=2*ji.moveX(this.x,e)+1,this.orientationZ=2*ji.moveZ(this.z,e)+1,this.stepsTaken++,this.refreshZonePresence(t,i,this.level),e}queueWaypoint(e,t){this.waypoints[0]=ji.packCoord(0,e,t),this.waypointIndex=0}queueWaypoints(e){let t=-1;for(let i=e.length-1,r=0;i>=0&&r2&&(this.jump=!0)}convertMovementDir(){let e=this.walkDir,t=this.runDir,i=this.moveSpeed===Is.INSTANT;const r=ji.distanceTo(this,{x:this.lastX,z:this.lastZ,width:this.width,length:this.length});if(i&&!this.jump&&r<=2){if(2===r){const i=(this.x+this.lastX)/2|0,r=(this.z+this.lastZ)/2|0;e=ji.face(this.lastX,this.lastZ,i,r),t=ji.face(i,r,this.x,this.z)}else e=ji.face(this.lastX,this.lastZ,this.x,this.z),t=-1;i=!1}this.walkDir=e,this.runDir=t,this.tele=i}hasWaypoints(){return-1!==this.waypointIndex}isLastOrNoWaypoint(){return this.waypointIndex<=0}inOperableDistance(t){if(t.level!==this.level)return!1;if(t instanceof e)return Ei(this.level,this.x,this.z,t.x,t.z,t.width,t.length,this.width,-1,-2);if(t instanceof ss){const e=at.get(t.type).forceapproach;return Ei(this.level,this.x,this.z,t.x,t.z,t.width,t.length,this.width,t.angle,t.shape,e)}const i=Ei(this.level,this.x,this.z,t.x,t.z,t.width,t.length,this.width,0,-2);return ui(t.x,t.z,t.level,Ri.WALK_BLOCKED)?i:!(this.hasWaypoints()||!i)||Ei(this.level,this.x,this.z,t.x,t.z,t.width,t.length,this.width,0,-1)}inApproachDistance(t,i){return i.level===this.level&&(!(i instanceof e&&ji.intersects(this.x,this.z,this.width,this.length,i.x,i.z,i.width,i.length))&&(ji.distanceTo(this,i)<=t&&fi(this.level,this.x,this.z,i.x,i.z,this.width,this.length,i.width,i.length,Ri.PLAYER)))}pathToMoveClick(e,t){if(this.moveStrategy===Os.SMART)if(t){const{x:t,z:i}=ji.unpackCoord(e[0]);this.queueWaypoints(ti(this.level,this.x,this.z,t,i))}else this.queueWaypoints(e);else{const{x:t,z:i}=ji.unpackCoord(e[e.length-1]);this.queueWaypoint(t,i)}}pathToPathingTarget(){this.target&&this.target instanceof e&&this.isLastOrNoWaypoint()&&(this.targetOp!==cs.APPLAYER3&&this.targetOp!==cs.OPPLAYER3?this.pathToTarget():this.queueWaypoint(this.target.lastStepX,this.target.lastStepZ))}pathToTarget(){if(!this.target)return;this.targetX=this.target.x,this.targetZ=this.target.z;const t=2*this.target.x+this.target.width,i=2*this.target.z+this.target.length;if(this.orientationX=t,this.orientationZ=i,this.moveStrategy===Os.SMART)if(this.target instanceof e)this.queueWaypoints(ti(this.level,this.x,this.z,this.target.x,this.target.z,this.width,this.target.width,this.target.length,0,-2));else if(this.target instanceof ss){const e=at.get(this.target.type).forceapproach;this.queueWaypoints(ti(this.level,this.x,this.z,this.target.x,this.target.z,this.width,this.target.width,this.target.length,this.target.angle,this.target.shape,!0,e))}else this.queueWaypoints(ti(this.level,this.x,this.z,this.target.x,this.target.z));else if(this.moveStrategy===Os.NAIVE){const t=this.getCollisionStrategy();if(null===t)return;const i=this.blockWalkFlag();if(i===Ri.NULL)return;this.target instanceof e?this.queueWaypoints(ii(this.level,this.x,this.z,this.target.x,this.target.z,this.width,this.length,this.target.width,this.target.length,i,t)):this.queueWaypoint(this.target.x,this.target.z)}else{if(null===this.getCollisionStrategy())return;if(this.blockWalkFlag()===Ri.NULL)return;this.queueWaypoint(this.target.x,this.target.z)}}setInteraction(e,t,i,r){this.target=t,this.targetOp=i,this.targetSubject=r??{type:-1,com:-1},this.targetX=t.x,this.targetZ=t.z,this.apRange=10,this.apRangeCalled=!1;const s=2*t.x+t.width,n=2*t.z+t.length;if(this.orientationX=s,this.orientationZ=n,t instanceof Do){const e=t.pid+32768;this.faceEntity!==e&&(this.faceEntity=e,this.mask|=this.entitymask)}else if(t instanceof kl){const e=t.nid;this.faceEntity!==e&&(this.faceEntity=e,this.mask|=this.entitymask)}else this.faceX===s&&this.faceZ===n||(this.faceX=s,this.faceZ=n,this.mask|=this.coordmask);e===hs.SCRIPT&&this.pathToTarget()}clearInteraction(){this.target=null,this.targetOp=-1,this.targetSubject={type:-1,com:-1},this.targetX=-1,this.targetZ=-1,this.apRange=10,this.apRangeCalled=!1,this.alreadyFacedEntity=!0}getCollisionStrategy(){return this.moveRestrict===dt.NORMAL?Di.NORMAL:this.moveRestrict===dt.BLOCKED?Di.BLOCKED:this.moveRestrict===dt.BLOCKED_NORMAL?Di.LINE_OF_SIGHT:this.moveRestrict===dt.INDOORS?Di.INDOORS:this.moveRestrict===dt.OUTDOORS?Di.OUTDOORS:this.moveRestrict===dt.NOMOVE?null:this.moveRestrict===dt.PASSTHRU?Di.NORMAL:null}resetPathingEntity(){this.moveSpeed=this.defaultMoveSpeed(),this.walkDir=-1,this.runDir=-1,this.jump=!1,this.tele=!1,this.lastX=this.x,this.lastZ=this.z,this.lastLevel=this.level,this.stepsTaken=0,this.interacted=!1,this.apRangeCalled=!1,this.mask=0,this.exactStartX=-1,this.exactStartZ=-1,this.exactEndX=-1,this.exactEndZ=-1,this.exactMoveStart=-1,this.exactMoveEnd=-1,this.exactMoveDirection=-1,this.animId=-1,this.animDelay=-1,this.animId=-1,this.animDelay=-1,this.chat=null,this.damageTaken=-1,this.damageType=-1,this.graphicId=-1,this.graphicHeight=-1,this.graphicDelay=-1,this.alreadyFacedEntity&&!this.target&&-1!==this.faceEntity&&(this.mask|=this.entitymask,this.faceEntity=-1,this.alreadyFacedEntity=!1)}takeStep(){if(-1===this.waypointIndex)return null;const e=this.x,t=this.z,{x:i,z:r}=ji.unpackCoord(this.waypoints[this.waypointIndex]),s=ji.face(e,t,i,r),n=ji.deltaX(s),a=ji.deltaZ(s);if(0==n&&0==a)return-1;const o=this.getCollisionStrategy();if(null===o)return-1;const c=this.blockWalkFlag();return c===Ri.NULL?-1:this.moveStrategy===Os.FLY||pi(this.level,this.x,this.z,n,a,this.width,c,o)?s:0!=n&&pi(this.level,this.x,this.z,n,0,this.width,c,o)?ji.face(e,t,i,t):0!=a&&pi(this.level,this.x,this.z,0,a,this.width,c,o)?ji.face(e,t,e,r):null}},Ls=class{sentinel;cursor=null;constructor(){const e=new Ie;e.nextHashable=e,e.prevHashable=e,this.sentinel=e}push(e){e.prevHashable&&e.uncache(),e.prevHashable=this.sentinel.prevHashable,e.nextHashable=this.sentinel,e.prevHashable&&(e.prevHashable.nextHashable=e),e.nextHashable.prevHashable=e}pop(){const e=this.sentinel.nextHashable;return e===this.sentinel?null:(e?.uncache(),e)}head(){const e=this.sentinel.nextHashable;return e===this.sentinel?(this.cursor=null,null):(this.cursor=e?.nextHashable||null,e)}next(){const e=this.cursor;return e===this.sentinel?(this.cursor=null,null):(this.cursor=e?.nextHashable||null,e)}clear(){for(;;){const e=this.sentinel.next;if(e==this.sentinel)return;e&&e.unlink()}}},Ps=new Map,ws=new Map;var bs=class extends Ie{},Rs=class e{static LOW=new e;static HIGH=new e},Bs=class extends bs{priority=Rs.LOW},Us=class extends bs{constructor(e){super(),this.uid=e}priority=Rs.HIGH},Ds=class extends bs{priority=Rs.HIGH},ks=class extends bs{priority=Rs.HIGH},Ms=class extends bs{constructor(e){super(),this.component=e}priority=Rs.LOW},xs=class extends bs{constructor(e){super(),this.component=e}priority=Rs.HIGH},Fs=class extends bs{constructor(e,t){super(),this.varp=e,this.value=t}priority=Rs.HIGH},Hs=class extends bs{constructor(e,t){super(),this.varp=e,this.value=t}priority=Rs.HIGH},Vs=class extends bs{constructor(e,t,i){super(),this.name=e,this.crc=t,this.length=i}priority=Rs.LOW},Gs=class extends bs{constructor(e,t){super(),this.delay=e,this.data=t}priority=Rs.LOW},Ws=class extends bs{constructor(e,t){super(),this.component=e,this.tab=t}priority=Rs.LOW},Ks=class extends bs{priority=Rs.HIGH},zs=class extends bs{constructor(e,t,i,r,s,n){super(),this.type=e,this.nid=t,this.pid=i,this.x=r,this.z=s,this.y=n}priority=Rs.LOW},js=class extends bs{constructor(e,t,i,r){super(),this.lastLoginIp=e,this.daysSinceLogin=t,this.daysSinceRecoveryChange=i,this.unreadMessageCount=r}priority=Rs.LOW},Ys=class extends bs{constructor(e){super(),this.msg=e}priority=Rs.HIGH},qs=class{type;receiverId;message;constructor(e,t,i){this.type=e,this.receiverId=t,this.message=i}},Qs=(e=>(e[e.ENCLOSED=0]='ENCLOSED',e[e.FOLLOWS=1]='FOLLOWS',e))(Qs||{}),$s=Qs,Zs=class extends bs{constructor(e,t,i,r,s){super(),this.zoneX=e,this.zoneZ=t,this.originX=i,this.originZ=r,this.data=s}priority=Rs.HIGH},Xs=class extends bs{constructor(e,t,i,r){super(),this.zoneX=e,this.zoneZ=t,this.originX=i,this.originZ=r}priority=Rs.HIGH},Js=class extends bs{constructor(e,t,i,r){super(),this.zoneX=e,this.zoneZ=t,this.originX=i,this.originZ=r}priority=Rs.HIGH},en=class extends bs{constructor(e){super(),this.coord=e}priority=Rs.HIGH},tn=class extends en{constructor(e,t,i){super(e),this.coord=e,this.obj=t,this.count=i}},rn=class extends en{constructor(e,t,i,r){super(e),this.coord=e,this.loc=t,this.shape=i,this.angle=r}},sn=class extends en{constructor(e,t,i){super(e),this.coord=e,this.shape=t,this.angle=i}},nn=class extends en{constructor(e,t,i,r,s,n,a,o,c,l,h,d){super(ji.packZoneCoord(e,t)),this.srcX=e,this.srcZ=t,this.dstX=i,this.dstZ=r,this.target=s,this.spotanim=n,this.srcHeight=a,this.dstHeight=o,this.startDelay=c,this.endDelay=l,this.peak=h,this.arc=d}},an=class extends en{constructor(e,t,i,r){super(e),this.coord=e,this.spotanim=t,this.height=i,this.delay=r}},on=class extends en{constructor(e,t){super(e),this.coord=e,this.obj=t}},cn=class extends en{constructor(e,t,i,r){super(e),this.coord=e,this.obj=t,this.oldCount=i,this.newCount=r}},ln=class extends en{constructor(e,t,i,r){super(e),this.coord=e,this.obj=t,this.count=i,this.receiverId=r}},hn=class extends en{constructor(e,t,i,r){super(e),this.coord=e,this.shape=t,this.angle=i,this.seq=r}},dn=class extends en{constructor(e,t,i,r,s,n,a,o,c,l,h,d){super(ji.packZoneCoord(e,t)),this.srcX=e,this.srcZ=t,this.shape=i,this.angle=r,this.locId=s,this.startCycle=n,this.endCycle=a,this.pid=o,this.east=c,this.south=l,this.west=h,this.north=d}},un=class{test(e){return this.prot.length}},pn=class extends un{prot=Ts.IF_OPENCHATMODAL;encode(e,t){e.p2(t.component)}},fn=class extends bs{constructor(e){super(),this.component=e}priority=Rs.LOW},gn=class extends bs{constructor(e,t,i,r,s,n,a,o,c,l,h,d,u,p,f){super(),this.buildArea=e,this.level=t,this.x=i,this.z=r,this.originX=s,this.originZ=n,this.uid=a,this.mask=o,this.tele=c,this.jump=l,this.walkDir=h,this.runDir=d,this.deltaX=u,this.deltaZ=p,this.changedLevel=f}priority=Rs.HIGH;accumulator=0},mn=class e extends un{static BITS_NEW=23;static BITS_IDLE=1;static BITS_RUN=10;static BITS_WALK=7;static BITS_EXTENDED=3;static BYTES_LIMIT=4997;prot=Ts.PLAYER_INFO;encode(e,t){const i=t.buildArea;t.changedLevel||t.deltaX>i.viewDistance||t.deltaZ>i.viewDistance?(i.players.clear(),i.lastResize=0,i.viewDistance=wo.PREFERRED_VIEW_DISTANCE):i.resize(),this.writeLocalPlayer(e,t),this.writePlayers(e,t),this.writeNewPlayers(e,t);const r=i.extendedInfo;if(r.size>0)for(const i of r){const r=Zl.getPlayerByUid(i.id);r?this.writeExtendedInfo(r,t,e,i.id===t.uid,i.added):e.p1(0)}i.clearExtended()}test(t){return e.BYTES_LIMIT}willFit(t,i,r,s){return(i.bitPos+r+7>>>3)+(t.accumulator+s)<=e.BYTES_LIMIT}writeLocalPlayer(e,t){const{buildArea:i,uid:r,level:s,x:n,z:a,tele:o,jump:c,walkDir:l,runDir:h}=t,d=Zl.getPlayerByUid(r);if(!d)return;const u=this.calculateExtendedInfo(d,t,!0,!1),p=u>0;e.bits(),e.pBit(1,o||-1!==h||-1!==l||p?1:0),o?(e.pBit(2,3),e.pBit(2,s),e.pBit(7,ji.local(n,d.originX)),e.pBit(7,ji.local(a,d.originZ)),e.pBit(1,c?1:0),e.pBit(1,p?1:0)):-1!==h?(e.pBit(2,2),e.pBit(3,l),e.pBit(3,h),e.pBit(1,p?1:0)):-1!==l?(e.pBit(2,1),e.pBit(3,l),e.pBit(1,p?1:0)):p&&e.pBit(2,0),p&&(i.extendedInfo.add({id:r,added:!1}),t.accumulator+=u)}writePlayers(t,i){const r=i.buildArea;t.pBit(8,r.players.size);for(const s of r.players){const n=Zl.getPlayerByUid(s);if(!n||n.tele||n.level!==i.level||!ji.isWithinDistanceSW(i,n,r.viewDistance)||!n.checkLifeCycle(Zl.currentTick)){t.pBit(1,1),t.pBit(2,3),r.players.delete(s);continue}const a=this.calculateExtendedInfo(n,i,!1,!1);let o=a>0;const{walkDir:c,runDir:l}=n;let h=e.BITS_IDLE;-1!==l?h=e.BITS_RUN:-1!==c?h=e.BITS_WALK:o&&(h=e.BITS_EXTENDED),this.willFit(i,t,h,a)||(o=!1),t.pBit(1,-1!==l||-1!==c||o?1:0),-1!==l?(t.pBit(2,2),t.pBit(3,c),t.pBit(3,l),t.pBit(1,o?1:0)):-1!==c?(t.pBit(2,1),t.pBit(3,c),t.pBit(1,o?1:0)):o&&t.pBit(2,0),o&&(r.extendedInfo.add({id:s,added:!1}),i.accumulator+=a)}}writeNewPlayers(t,i){const r=i.buildArea;for(const s of r.getNearbyPlayers(i.uid,i.x,i.z,i.originX,i.originZ)){const n=this.calculateExtendedInfo(s,i,!1,!0),a=n>0;if(!this.willFit(i,t,e.BITS_NEW+11,n))break;t.pBit(11,s.pid),t.pBit(5,s.x-i.x),t.pBit(5,s.z-i.z),t.pBit(1,s.jump?1:0),t.pBit(1,a?1:0),a&&(r.extendedInfo.add({id:s.uid,added:!0}),i.accumulator+=n),r.players.add(s.uid)}r.extendedInfo.size>0&&t.pBit(11,2047),t.bytes()}writeExtendedInfo(e,t,i,r=!1,s=!1){let n=e.mask;s&&(-1===e.orientationX&&-1===e.faceX||(n|=Do.FACE_COORD),-1!==e.faceEntity&&(n|=Do.FACE_ENTITY)),r&&n&Do.CHAT&&(n&=~Do.CHAT),t.buildArea.hasAppearance(e.uid,e.lastAppearance)||!e.appearance?n&=~Do.APPEARANCE:n|=Do.APPEARANCE,n>255&&(n|=Do.BIG_UPDATE),i.p1(255&n),n&Do.BIG_UPDATE&&i.p1(n>>8),n&Do.APPEARANCE&&(i.p1(e.appearance.length),i.pdata(e.appearance,0,e.appearance.length),t.buildArea.saveAppearance(e.uid,e.lastAppearance)),n&Do.ANIM&&(i.p2(e.animId),i.p1(e.animDelay)),n&Do.FACE_ENTITY&&(-1!==e.faceEntity&&(e.alreadyFacedEntity=!0),i.p2(e.faceEntity)),n&Do.SAY&&i.pjstr(e.chat??''),n&Do.DAMAGE&&(i.p1(e.damageTaken),i.p1(e.damageType),i.p1(e.levels[$i.HITPOINTS]),i.p1(e.baseLevels[$i.HITPOINTS])),n&Do.FACE_COORD&&(s&&-1!==e.orientationX?(i.p2(e.orientationX),i.p2(e.orientationZ)):(i.p2(e.faceX),i.p2(e.faceZ))),n&Do.CHAT&&(i.p1(e.messageColor),i.p1(e.messageEffect),i.p1(e.messageType),i.p1(e.message.length),i.pdata(e.message,0,e.message.length)),n&Do.SPOTANIM&&(i.p2(e.graphicId),i.p2(e.graphicHeight),i.p2(e.graphicDelay)),n&Do.EXACT_MOVE&&(i.p1(e.exactStartX-ji.zoneOrigin(t.originX)),i.p1(e.exactStartZ-ji.zoneOrigin(t.originZ)),i.p1(e.exactEndX-ji.zoneOrigin(t.originX)),i.p1(e.exactEndZ-ji.zoneOrigin(t.originZ)),i.p2(e.exactMoveStart),i.p2(e.exactMoveEnd),i.p1(e.exactMoveDirection))}calculateExtendedInfo(e,t,i=!1,r=!1){let s=0,n=e.mask;return r&&(-1===e.orientationX&&-1===e.faceX||(n|=Do.FACE_COORD),-1!==e.faceEntity&&(n|=Do.FACE_ENTITY)),i&&n&Do.CHAT&&(n&=~Do.CHAT),t.buildArea.hasAppearance(e.uid,e.lastAppearance)||!e.appearance?n&=~Do.APPEARANCE:n|=Do.APPEARANCE,n>255&&(n|=Do.BIG_UPDATE),0===n?0:(s+=1,n&Do.BIG_UPDATE&&(s+=1),n&Do.APPEARANCE&&(s+=1+e.appearance.length),n&Do.ANIM&&(s+=3),n&Do.FACE_ENTITY&&(s+=2),n&Do.SAY&&(s+=1+e.chat.length),n&Do.DAMAGE&&(s+=4),n&Do.FACE_COORD&&(s+=4),n&Do.CHAT&&(s+=4+e.message.length),n&Do.SPOTANIM&&(s+=6),n&Do.EXACT_MOVE&&(s+=9),s)}},yn=class extends bs{constructor(e,t){super(),this.zoneX=e,this.zoneZ=t}priority=Rs.HIGH;get mapsquares(){const e=this.zoneX-6,t=this.zoneX+6,i=this.zoneZ-6,r=this.zoneZ+6,s=new Set;for(let n=e;n<=t;n++){const e=ji.mapsquare(n<<3);for(let t=i;t<=r;t++){const i=ji.mapsquare(t<<3);s.add(e<<8|i)}}return s}},En=class extends un{prot=Ts.REBUILD_NORMAL;encode(e,t){e.p2(t.zoneX),e.p2(t.zoneZ);for(const i of t.mapsquares){const t=i>>8,r=255&i;e.p1(t),e.p1(r),e.p4(ws.get(`m${t}_${r}`)??0),e.p4(ws.get(`l${t}_${r}`)??0)}}test(e){return 4+10*e.mapsquares.size}},_n=class extends bs{constructor(e,t,i,r,s){super(),this.x=e,this.z=t,this.offset=i,this.length=r,this.data=s}priority=Rs.HIGH},An=class extends un{prot=Ts.DATA_LAND;encode(e,t){e.p1(t.x),e.p1(t.z),e.p2(t.offset),e.p2(t.length),e.pdata(t.data,0,t.data.length)}test(e){return 6+e.data.length}},vn=class extends bs{constructor(e,t){super(),this.x=e,this.z=t}priority=Rs.HIGH},Tn=class extends un{prot=Ts.DATA_LAND_DONE;encode(e,t){e.p1(t.x),e.p1(t.z)}},Cn=class extends bs{constructor(e,t,i,r,s){super(),this.x=e,this.z=t,this.offset=i,this.length=r,this.data=s}priority=Rs.HIGH},In=class extends un{prot=Ts.DATA_LOC;encode(e,t){e.p1(t.x),e.p1(t.z),e.p2(t.offset),e.p2(t.length),e.pdata(t.data,0,t.data.length)}test(e){return 6+e.data.length}},Sn=class extends bs{constructor(e,t){super(),this.x=e,this.z=t}priority=Rs.HIGH},On=class extends un{prot=Ts.DATA_LOC_DONE;encode(e,t){e.p1(t.x),e.p1(t.z)}},Nn=class extends bs{constructor(e,t,i,r,s){super(),this.x=e,this.z=t,this.height=i,this.speed=r,this.multiplier=s}priority=Rs.LOW},Ln=class extends un{prot=Ts.CAM_LOOKAT;encode(e,t){e.p1(t.x),e.p1(t.z),e.p2(t.height),e.p1(t.speed),e.p1(t.multiplier)}},Pn=class extends bs{constructor(e,t,i,r,s){super(),this.x=e,this.z=t,this.height=i,this.speed=r,this.multiplier=s}priority=Rs.LOW},wn=class extends un{prot=Ts.CAM_MOVETO;encode(e,t){e.p1(t.x),e.p1(t.z),e.p2(t.height),e.p1(t.speed),e.p1(t.multiplier)}},bn=class extends bs{priority=Rs.LOW},Rn=class extends un{prot=Ts.CAM_RESET;encode(e,t){}},Bn=class extends bs{constructor(e,t,i,r){super(),this.type=e,this.jitter=t,this.amplitude=i,this.frequency=r}priority=Rs.LOW},Un=class extends un{prot=Ts.CAM_SHAKE;encode(e,t){e.p1(t.type),e.p1(t.jitter),e.p1(t.amplitude),e.p1(t.frequency)}},Dn=class extends bs{constructor(e,t,i){super(),this.publicChat=e,this.privateChat=t,this.tradeDuel=i}priority=Rs.HIGH},kn=class extends un{prot=Ts.CHAT_FILTER_SETTINGS;encode(e,t){e.p1(t.publicChat),e.p1(t.privateChat),e.p1(t.tradeDuel)}},Mn=class extends bs{priority=Rs.LOW},xn=class extends un{prot=Ts.ENABLE_TRACKING;encode(e,t){}},Fn=class extends bs{priority=Rs.LOW},Hn=class extends un{prot=Ts.FINISH_TRACKING;encode(e,t){}},Vn=class extends un{prot=Ts.HINT_ARROW;encode(e,t){const{type:i,nid:r,pid:s,x:n,z:a,y:o}=t;1===i?(e.p1(i),e.p2(r),e.p2(0),e.p1(0)):i>=2&&i<=6?(e.p1(i),e.p2(n),e.p2(a),e.p1(o)):10===i?(e.p1(i),e.p2(s),e.p2(0),e.p1(0)):-1===i&&(e.p1(-1),e.p2(0),e.p2(0),e.p1(0))}},Gn=class extends un{prot=Ts.IF_CLOSE;encode(e,t){}},Wn=class extends bs{constructor(e){super(),this.component=e}priority=Rs.LOW},Kn=class extends un{prot=Ts.IF_OPENMAINMODAL;encode(e,t){e.p2(t.component)}},zn=class extends bs{constructor(e,t){super(),this.main=e,this.side=t}priority=Rs.LOW},jn=class extends un{prot=Ts.IF_OPENMAINSIDEMODAL;encode(e,t){e.p2(t.main),e.p2(t.side)}},Yn=class extends bs{constructor(e){super(),this.component=e}priority=Rs.LOW},qn=class extends un{prot=Ts.IF_OPENSIDEMODAL;encode(e,t){e.p2(t.component)}},Qn=class extends un{prot=Ts.IF_OPENSIDEOVERLAY;encode(e,t){e.p2(t.component),e.p1(t.tab)}},$n=class extends bs{constructor(e,t){super(),this.component=e,this.seq=t}priority=Rs.LOW},Zn=class extends un{prot=Ts.IF_SETANIM;encode(e,t){e.p2(t.component),e.p2(t.seq)}},Xn=class extends bs{constructor(e,t){super(),this.component=e,this.colour=t}priority=Rs.LOW},Jn=class extends un{prot=Ts.IF_SETCOLOUR;encode(e,t){e.p2(t.component),e.p2(t.colour)}},ea=class extends bs{constructor(e,t){super(),this.component=e,this.hidden=t}priority=Rs.LOW},ta=class extends un{prot=Ts.IF_SETHIDE;encode(e,t){e.p2(t.component),e.pbool(t.hidden)}},ia=class extends bs{constructor(e,t){super(),this.component=e,this.model=t}priority=Rs.LOW},ra=class extends un{prot=Ts.IF_SETMODEL;encode(e,t){e.p2(t.component),e.p2(t.model)}},sa=class extends bs{constructor(e,t){super(),this.component=e,this.npc=t}priority=Rs.LOW},na=class extends un{prot=Ts.IF_SETNPCHEAD;encode(e,t){e.p2(t.component),e.p2(t.npc)}},aa=class extends bs{constructor(e,t,i){super(),this.component=e,this.obj=t,this.scale=i}priority=Rs.LOW},oa=class extends un{prot=Ts.IF_SETOBJECT;encode(e,t){e.p2(t.component),e.p2(t.obj),e.p2(t.scale)}},ca=class extends bs{constructor(e){super(),this.component=e}priority=Rs.LOW},la=class extends un{prot=Ts.IF_SETPLAYERHEAD;encode(e,t){e.p2(t.component)}},ha=class extends bs{constructor(e,t,i){super(),this.component=e,this.x=t,this.y=i}priority=Rs.LOW},da=class extends un{prot=Ts.IF_SETPOSITION;encode(e,t){e.p2(t.component),e.p2(t.x),e.p2(t.y)}},ua=class extends bs{constructor(e,t,i){super(),this.component=e,this.src=t,this.dst=i}priority=Rs.LOW},pa=class extends un{prot=Ts.IF_SETRECOL;encode(e,t){e.p2(t.component),e.p2(t.src),e.p2(t.dst)}},fa=class extends bs{constructor(e,t){super(),this.component=e,this.text=t}priority=Rs.LOW},ga=class extends un{prot=Ts.IF_SETTEXT;encode(e,t){e.p2(t.component),e.pjstr(t.text)}test(e){return 3+e.text.length}},ma=class extends bs{constructor(e){super(),this.tab=e}priority=Rs.LOW},ya=class extends un{prot=Ts.IF_SHOWSIDE;encode(e,t){e.p1(t.tab)}},Ea=class extends un{prot=Ts.LAST_LOGIN_INFO;encode(e,t){e.p4(t.lastLoginIp),e.p2(t.daysSinceLogin),e.p1(t.daysSinceRecoveryChange),e.p2(t.unreadMessageCount)}},_a=class e extends Ts{static LOC_MERGE=new e(23,14);static LOC_ANIM=new e(42,4);static OBJ_DEL=new e(49,3);static OBJ_REVEAL=new e(50,7);static LOC_ADD_CHANGE=new e(59,4);static MAP_PROJANIM=new e(69,15);static LOC_DEL=new e(76,2);static OBJ_COUNT=new e(151,7);static MAP_ANIM=new e(191,6);static OBJ_ADD=new e(223,5)},Aa=class extends un{enclose(e){const t=new Oe(new Uint8Array(1+this.prot.length));return t.p1(this.prot.id),this.encode(t,e),t.data}},va=class extends Aa{prot=_a.LOC_ADD_CHANGE;encode(e,t){e.p1(t.coord),e.p1(t.shape<<2|3&t.angle),e.p2(t.loc)}},Ta=class extends Aa{prot=_a.LOC_ANIM;encode(e,t){e.p1(t.coord),e.p1(t.shape<<2|3&t.angle),e.p2(t.seq)}},Ca=class extends Aa{prot=_a.LOC_DEL;encode(e,t){e.p1(t.coord),e.p1(t.shape<<2|3&t.angle)}},Ia=class extends Aa{prot=_a.LOC_MERGE;encode(e,t){e.p1(t.coord),e.p1(t.shape<<2|3&t.angle),e.p2(t.locId),e.p2(t.startCycle),e.p2(t.endCycle),e.p2(t.pid),e.p1(t.east-t.srcX),e.p1(t.south-t.srcZ),e.p1(t.west-t.srcX),e.p1(t.north-t.srcZ)}},Sa=class extends bs{priority=Rs.HIGH},Oa=class extends un{prot=Ts.LOGOUT;encode(e,t){}},Na=class extends Aa{prot=_a.MAP_ANIM;encode(e,t){e.p1(t.coord),e.p2(t.spotanim),e.p1(t.height),e.p2(t.delay)}},La=class extends Aa{prot=_a.MAP_PROJANIM;encode(e,t){e.p1(t.coord),e.p1(t.dstX-t.srcX),e.p1(t.dstZ-t.srcZ),e.p2(t.target),e.p2(t.spotanim),e.p1(t.srcHeight),e.p1(t.dstHeight),e.p2(t.startDelay),e.p2(t.endDelay),e.p1(t.peak),e.p1(t.arc)}},Pa=class extends un{prot=Ts.MESSAGE_GAME;encode(e,t){e.pjstr(t.msg)}test(e){return 1+e.msg.length}},wa=class{static CHAR_LOOKUP=[" ","e","t","a","o","i","h","n","s","r","d","l","u","m","w","c","y","f","g","p","b","v","k","x","j","q","z","0","1","2","3","4","5","6","7","8","9"," ","!","?",".",",",":",";","(",")","-","&","*","\\","'","@","#","+","=","£","$","%",'"',"[","]"];static unpack(e,t){const i=[];let r,s=0,n=-1;for(let a=0;a>4&15,-1!==n?(i[s++]=this.CHAR_LOOKUP[(n<<4)+r-195],n=-1):r<13?i[s++]=this.CHAR_LOOKUP[r]:n=r,r=15&t,-1!=n?(i[s++]=this.CHAR_LOOKUP[(n<<4)+r-195],n=-1):r<13?i[s++]=this.CHAR_LOOKUP[r]:n=r}return this.toSentenceCase(i.slice(0,s).join(''))}static pack(e,t){t.length>80&&(t=t.substring(0,80)),t=t.toLowerCase();let i=-1;for(let r=0;r12&&(n+=195),-1==i?n<13?i=n:e.p1(n):n<13?(e.p1((i<<4)+n),i=-1):(e.p1((i<<4)+(n>>4)),i=15&n)}-1!=i&&e.p1(i<<4)}static toSentenceCase(e){const t=[...e.toLowerCase()];let i=!0;for(let e=0;e='a'&&r<='z'&&(t[e]=r.toUpperCase(),i=!1),'.'!==r&&'!'!==r||(i=!0)}return t.join('')}},ba=class extends un{prot=Ts.MESSAGE_PRIVATE;encode(e,t){e.p8(t.from),e.p4(t.messageId),e.p1(t.staffModLevel),wa.pack(e,Bt.filter(t.msg))}test(e){return 14+e.msg.length}},Ra=class extends bs{constructor(e,t,i,r){super(),this.from=e,this.messageId=t,this.staffModLevel=i,this.msg=r}priority=Rs.HIGH},Ba=class extends un{prot=Ts.MIDI_JINGLE;encode(e,t){e.p2(t.delay),e.p4(t.data.length),e.pdata(t.data,0,t.data.length)}test(e){return 6+e.data.length}},Ua=class extends un{prot=Ts.MIDI_SONG;encode(e,t){e.pjstr(t.name),e.p4(t.crc),e.p4(t.length)}test(e){return 1+e.name.length+4+4}},Da=class extends Aa{prot=_a.OBJ_ADD;encode(e,t){e.p1(t.coord),e.p2(t.obj),e.p2(Math.min(t.count,65535))}},ka=class extends Aa{prot=_a.OBJ_COUNT;encode(e,t){e.p1(t.coord),e.p2(t.obj),e.p2(Math.min(t.oldCount,65535)),e.p2(Math.min(t.newCount,65535))}},Ma=class extends Aa{prot=_a.OBJ_DEL;encode(e,t){e.p1(t.coord),e.p2(t.obj)}},xa=class extends Aa{prot=_a.OBJ_REVEAL;encode(e,t){e.p1(t.coord),e.p2(t.obj),e.p2(Math.min(t.count,65535)),e.p2(t.receiverId)}},Fa=class extends bs{priority=Rs.LOW},Ha=class extends un{prot=Ts.P_COUNTDIALOG;encode(e,t){}},Va=class extends un{prot=Ts.RESET_ANIMS;encode(e,t){}},Ga=class extends un{prot=Ts.RESET_CLIENT_VARCACHE;encode(e,t){}},Wa=class extends bs{constructor(e){super(),this.hidden=e}priority=Rs.LOW},Ka=class extends un{prot=Ts.SET_MULTIWAY;encode(e,t){e.pbool(t.hidden)}},za=class extends bs{constructor(e,t,i){super(),this.synth=e,this.loops=t,this.delay=i}priority=Rs.LOW},ja=class extends un{prot=Ts.SYNTH_SOUND;encode(e,t){e.p2(t.synth),e.p1(t.loops),e.p2(t.delay)}},Ya=class extends bs{constructor(e){super(),this.tab=e}priority=Rs.LOW},qa=class extends un{prot=Ts.TUTORIAL_FLASHSIDE;encode(e,t){e.p1(t.tab)}},Qa=class extends un{prot=Ts.TUTORIAL_OPENCHAT;encode(e,t){e.p2(t.component)}},$a=class extends un{prot=Ts.UNSET_MAP_FLAG;encode(e,t){}},Za=class extends bs{constructor(e,t){super(),this.name=e,this.nodeId=t}priority=Rs.LOW},Xa=class extends un{prot=Ts.UPDATE_FRIENDLIST;encode(e,t){e.p8(t.name),e.p1(t.nodeId)}},Ja=class extends bs{constructor(e){super(),this.names=e}priority=Rs.LOW},eo=class extends un{prot=Ts.UPDATE_IGNORELIST;encode(e,t){for(const i of t.names)e.p8(i)}test(e){return 8*e.names.length}},to=class extends bs{constructor(e,t){super(),this.component=e,this.inv=t}priority=Rs.HIGH},io=class extends un{prot=Ts.UPDATE_INV_FULL;encode(e,t){const{component:i,inv:r}=t,s=tt.get(i),n=Math.min(r.capacity,s.width*s.height);e.p2(i),e.p1(n);for(let t=0;t=255?(e.p1(255),e.p4(i.count)):e.p1(i.count)):(e.p2(0),e.p1(0))}}test(e){const{component:t,inv:i}=e,r=tt.get(t),s=Math.min(i.capacity,r.width*r.height);let n=0;n+=3;for(let e=0;e=255?n+=5:n+=1):n+=3}return n}},ro=class extends bs{constructor(e,t,...i){super(),this.component=e,this.inv=t,this.slots=i}priority=Rs.HIGH;slots},so=class extends un{prot=Ts.UPDATE_INV_PARTIAL;encode(e,t){const{component:i,inv:r}=t;e.p2(i);for(const i of t.slots){const t=r.get(i);e.p1(i),t?(e.p2(t.id+1),t.count>=255?(e.p1(255),e.p4(t.count)):e.p1(t.count)):(e.p2(0),e.p1(0))}}test(e){const{inv:t}=e;let i=0;i+=2;for(const r of e.slots){const e=t.get(r);i+=1,e?(i+=2,e.count>=255?i+=5:i+=1):i+=3}return i}},no=class extends un{prot=Ts.UPDATE_INV_STOP_TRANSMIT;encode(e,t){e.p2(t.component)}},ao=class extends bs{constructor(e){super(),this.energy=e}priority=Rs.LOW},oo=class extends un{prot=Ts.UPDATE_RUNENERGY;encode(e,t){e.p1(t.energy/100|0)}},co=class extends bs{constructor(e){super(),this.kg=e}priority=Rs.LOW},lo=class extends un{prot=Ts.UPDATE_RUNWEIGHT;encode(e,t){e.p2(t.kg)}},ho=class extends bs{constructor(e,t,i){super(),this.stat=e,this.exp=t,this.level=i}priority=Rs.LOW},uo=class extends un{prot=Ts.UPDATE_STAT;encode(e,t){e.p1(t.stat),e.p4(t.exp/10|0),e.p1(t.level)}},po=class extends un{prot=Ts.UPDATE_UID192;encode(e,t){e.p2(t.uid)}},fo=class extends un{prot=Ts.UPDATE_ZONE_FULL_FOLLOWS;encode(e,t){e.p1((t.zoneX<<3)-ji.zoneOrigin(t.originX)),e.p1((t.zoneZ<<3)-ji.zoneOrigin(t.originZ))}},go=class extends un{prot=Ts.UPDATE_ZONE_PARTIAL_FOLLOWS;encode(e,t){e.p1((t.zoneX<<3)-ji.zoneOrigin(t.originX)),e.p1((t.zoneZ<<3)-ji.zoneOrigin(t.originZ))}},mo=class extends un{prot=Ts.UPDATE_ZONE_PARTIAL_ENCLOSED;encode(e,t){e.p1((t.zoneX<<3)-ji.zoneOrigin(t.originX)),e.p1((t.zoneZ<<3)-ji.zoneOrigin(t.originZ)),e.pdata(t.data,0,t.data.length)}test(e){return 2+e.data.length}},yo=class extends un{prot=Ts.VARP_LARGE;encode(e,t){e.p2(t.varp),e.p4(t.value)}},Eo=class extends un{prot=Ts.VARP_SMALL;encode(e,t){e.p2(t.varp),e.p1(t.value)}},_o=class extends bs{constructor(e,t,i,r,s,n,a,o,c){super(),this.buildArea=e,this.level=t,this.x=i,this.z=r,this.originX=s,this.originZ=n,this.deltaX=a,this.deltaZ=o,this.changedLevel=c}priority=Rs.HIGH;accumulator=0},Ao=class e extends un{static BITS_NEW=35;static BITS_IDLE=1;static BITS_RUN=10;static BITS_WALK=7;static BITS_EXTENDED=3;static BYTES_LIMIT=4997;prot=Ts.NPC_INFO;encode(e,t){const i=t.buildArea;(t.changedLevel||t.deltaX>i.viewDistance||t.deltaZ>i.viewDistance)&&i.npcs.clear(),this.writeNpcs(e,t),this.writeNewNpcs(e,t);const r=i.extendedInfo;if(r.size>0)for(const t of r){const i=Zl.getNpc(t.id);i?this.writeExtendedInfo(i,e,t.added):e.p1(0)}i.clearExtended()}test(t){return e.BYTES_LIMIT}willFit(t,i,r,s){return(i.bitPos+r+7>>>3)+(t.accumulator+s)<=e.BYTES_LIMIT}writeNpcs(t,i){const r=i.buildArea;t.bits(),t.pBit(8,r.npcs.size);for(const s of r.npcs){const n=Zl.getNpc(s);if(!n||n.tele||n.level!==i.level||!ji.isWithinDistanceSW(i,n,15)||!n.checkLifeCycle(Zl.currentTick)){t.pBit(1,1),t.pBit(2,3),r.npcs.delete(s);continue}const a=this.calculateExtendedInfo(n,!1);let o=a>0;const{walkDir:c,runDir:l}=n;let h=e.BITS_IDLE;-1!==l?h=e.BITS_RUN:-1!==c?h=e.BITS_WALK:o&&(h=e.BITS_EXTENDED),this.willFit(i,t,h,a)||(o=!1),t.pBit(1,-1!==l||-1!==c||o?1:0),-1!==l?(t.pBit(2,2),t.pBit(3,c),t.pBit(3,l),t.pBit(1,o?1:0)):-1!==c?(t.pBit(2,1),t.pBit(3,c),t.pBit(1,o?1:0)):o&&t.pBit(2,0),o&&(r.extendedInfo.add({id:s,added:!1}),i.accumulator+=a)}}writeNewNpcs(t,i){const r=i.buildArea;for(const s of r.getNearbyNpcs(i.x,i.z,i.originX,i.originZ)){const n=this.calculateExtendedInfo(s,!0),a=n>0;if(!this.willFit(i,t,e.BITS_NEW+13,n))break;t.pBit(13,s.nid),t.pBit(11,s.type),t.pBit(5,s.x-i.x),t.pBit(5,s.z-i.z),t.pBit(1,a?1:0),a&&(r.extendedInfo.add({id:s.nid,added:!0}),i.accumulator+=n),r.npcs.add(s.nid)}r.extendedInfo.size>0&&t.pBit(13,8191),t.bytes()}writeExtendedInfo(e,t,i){let r=e.mask;i&&(-1===e.orientationX&&-1===e.faceX||(r|=kl.FACE_COORD),-1!==e.faceEntity&&(r|=kl.FACE_ENTITY)),t.p1(r),r&kl.ANIM&&(t.p2(e.animId),t.p1(e.animDelay)),r&kl.FACE_ENTITY&&(-1!==e.faceEntity&&(e.alreadyFacedEntity=!0),t.p2(e.faceEntity)),r&kl.SAY&&t.pjstr(e.chat??''),r&kl.DAMAGE&&(t.p1(e.damageTaken),t.p1(e.damageType),t.p1(e.levels[pt.HITPOINTS]),t.p1(e.baseLevels[pt.HITPOINTS])),r&kl.CHANGE_TYPE&&t.p2(e.type),r&kl.SPOTANIM&&(t.p2(e.graphicId),t.p2(e.graphicHeight),t.p2(e.graphicDelay)),r&kl.FACE_COORD&&(i&&-1!=e.orientationX?(t.p2(e.orientationX),t.p2(e.orientationZ)):(t.p2(e.faceX),t.p2(e.faceZ)))}calculateExtendedInfo(e,t){let i=0,r=e.mask;return t&&(-1===e.orientationX&&-1===e.faceX||(r|=kl.FACE_COORD),-1!==e.faceEntity&&(r|=kl.FACE_ENTITY)),0===r?0:(i+=1,r&kl.ANIM&&(i+=3),r&kl.FACE_ENTITY&&(i+=2),r&kl.SAY&&(i+=1+e.chat.length),r&kl.DAMAGE&&(i+=4),r&kl.CHANGE_TYPE&&(i+=2),r&kl.SPOTANIM&&(i+=6),r&kl.FACE_COORD&&(i+=4),i)}},vo=class extends bs{constructor(e){super(),this.ticks=e}priority=Rs.LOW},To=class extends un{prot=Ts.UPDATE_REBOOT_TIMER;encode(e,t){e.p2(t.ticks)}},Co=new class{encoders=new Map;bind(e,t){if(this.encoders.has(e))throw new Error(`[ServerProtRepository] Already defines a ${e.name}.`);this.encoders.set(e,t)}constructor(){this.bind(Nn,new Ln),this.bind(Pn,new wn),this.bind(bn,new Rn),this.bind(Bn,new Un),this.bind(Dn,new kn),this.bind(_n,new An),this.bind(vn,new Tn),this.bind(Cn,new In),this.bind(Sn,new On),this.bind(Mn,new xn),this.bind(Fn,new Hn),this.bind(zs,new Vn),this.bind(Bs,new Gn),this.bind(fn,new pn),this.bind(Wn,new Kn),this.bind(zn,new jn),this.bind(Yn,new qn),this.bind(Ws,new Qn),this.bind($n,new Zn),this.bind(Xn,new Jn),this.bind(ea,new ta),this.bind(ia,new ra),this.bind(sa,new na),this.bind(aa,new oa),this.bind(ca,new la),this.bind(ha,new da),this.bind(ua,new pa),this.bind(fa,new ga),this.bind(ma,new ya),this.bind(js,new Ea),this.bind(rn,new va),this.bind(hn,new Ta),this.bind(sn,new Ca),this.bind(dn,new Ia),this.bind(Sa,new Oa),this.bind(an,new Na),this.bind(nn,new La),this.bind(Ys,new Pa),this.bind(Ra,new ba),this.bind(Gs,new Ba),this.bind(Vs,new Ua),this.bind(_o,new Ao),this.bind(tn,new Da),this.bind(cn,new ka),this.bind(on,new Ma),this.bind(ln,new xa),this.bind(Fa,new Ha),this.bind(gn,new mn),this.bind(yn,new En),this.bind(Ds,new Va),this.bind(ks,new Ga),this.bind(Wa,new Ka),this.bind(za,new ja),this.bind(Ya,new qa),this.bind(Ms,new Qa),this.bind(Ks,new $a),this.bind(Za,new Xa),this.bind(Ja,new eo),this.bind(to,new io),this.bind(ro,new so),this.bind(xs,new no),this.bind(ao,new oo),this.bind(co,new lo),this.bind(vo,new To),this.bind(ho,new uo),this.bind(Us,new po),this.bind(Xs,new fo),this.bind(Zs,new mo),this.bind(Js,new go),this.bind(Hs,new yo),this.bind(Fs,new Eo)}getEncoder(e){return this.encoders.get(e.constructor)}getZoneEncoder(e){return this.encoders.get(e.constructor)}},Io=class extends Array{capacity;onFilled;constructor(e,t){super(),this.capacity=e,this.onFilled=t}*stack(e){const t=this[e];if(void 0!==t)for(let e=0;e=0;e--)yield i[e];else for(let e=0;er&&(r=t,i=e)}return i}nextBottomAll(){let e,t=Number.POSITIVE_INFINITY;for(let i=0;ir&&(r=s,i=e)}return i}nextBottomAll(){let e,t=Number.POSITIVE_INFINITY;for(let i=0;i>3,this.z=i.z>>3,this.level=i.level,this.events=new Set,this.players=new Set,this.npcs=new Set,this.locs=new So(e.LOCS,(e=>Zl.removeLoc(e,100))),this.objs=new Oo(e.OBJS,(e=>Zl.removeObj(e,100))),this.entityEvents=new Map}enter(e){e instanceof Do?(this.players.add(e.uid),Zl.getZoneGrid(this.level).flag(this.x,this.z)):e instanceof kl&&this.npcs.add(e.nid)}leave(e){e instanceof Do?(this.players.delete(e.uid),0===this.players.size&&Zl.getZoneGrid(this.level).unflag(this.x,this.z)):e instanceof kl&&this.npcs.delete(e.nid)}tick(e){let t;do{t=!1;for(const i of this.getAllObjsUnsafe())i.updateLifeCycle(e)&&i.lastLifecycleTick!==e&&(i.lifecycle===Yr.DESPAWN?-1!==i.receiverId?Zl.revealObj(i):(Zl.removeObj(i,0),t=!0):i.lifecycle===Yr.RESPAWN&&(Zl.addObj(i,-1,0),t=!0));for(const i of this.getAllLocsUnsafe())i.updateLifeCycle(e)&&i.lastLifecycleTick!==e&&(i.lifecycle===Yr.DESPAWN?(Zl.removeLoc(i,0),t=!0):i.lifecycle===Yr.RESPAWN&&(Zl.addLoc(i,0),t=!0))}while(t)}computeShared(){this.shared=null;let e=0;const t=[];for(const i of this.events.values()){if(i.type!==$s.ENCLOSED)continue;const r=Co.getZoneEncoder(i.message);if(void 0===r)continue;const s=r.enclose(i.message);t.push(s),e+=s.length}if(0===t.length||0===e)return;const i=new Uint8Array(e);let r=0;for(const e of t)i.set(e,r),r+=e.length;this.shared=i}writeFullFollows(e){e.write(new Xs(this.x,this.z,e.originX,e.originZ));for(const t of this.getAllObjsUnsafe(!0))-1!==t.receiverId&&t.receiverId!==e.pid||(e.write(new Js(this.x,this.z,e.originX,e.originZ)),(t.lifecycle===Yr.DESPAWN&&t.checkLifeCycle(Zl.currentTick)||t.lifecycle===Yr.RESPAWN&&t.checkLifeCycle(Zl.currentTick))&&e.write(new tn(ji.packZoneCoord(t.x,t.z),t.type,t.count)));for(const t of this.getAllLocsUnsafe(!0))t.lifecycle===Yr.DESPAWN&&t.checkLifeCycle(Zl.currentTick)?e.write(new rn(ji.packZoneCoord(t.x,t.z),t.type,t.shape,t.angle)):t.lifecycle!==Yr.RESPAWN||t.checkLifeCycle(Zl.currentTick)||e.write(new sn(ji.packZoneCoord(t.x,t.z),t.shape,t.angle))}writePartialEncloses(e){this.shared&&e.write(new Zs(this.x,this.z,e.originX,e.originZ,this.shared))}writePartialFollows(e){if(0!==this.events.size){e.write(new Js(this.x,this.z,e.originX,e.originZ));for(const t of this.events)t.type===$s.FOLLOWS&&(-1!==t.receiverId&&t.receiverId!==e.pid||e.write(t.message))}}reset(){this.events.clear(),this.entityEvents.clear()}addStaticLoc(e){const t=ji.packZoneCoord(e.x,e.z);this.locs.addLast(t,e,!0),this.totalLocs++,this.locs.sortStack(t,!0)}addStaticObj(e){const t=ji.packZoneCoord(e.x,e.z);this.objs.addLast(t,e,!0),this.totalObjs++,this.objs.sortStack(t,!0)}appendEvent(e,t){this.events.add(t);const i=this.entityEvents.get(e);void 0!==i?this.entityEvents.set(e,i.concat(t)):this.entityEvents.set(e,[t])}addLoc(e){const t=ji.packZoneCoord(e.x,e.z);e.lifecycle===Yr.DESPAWN&&(this.locs.addLast(t,e),this.totalLocs++),this.locs.sortStack(t),this.appendEvent(e,new qs($s.ENCLOSED,-1,new rn(t,e.type,e.shape,e.angle)))}removeLoc(e){const t=ji.packZoneCoord(e.x,e.z);e.lifecycle===Yr.DESPAWN&&(this.locs.remove(t,e),this.totalLocs--),this.locs.sortStack(t);const i=this.entityEvents.get(e);if(void 0!==i){for(let e=0;e>this.INT_BITS);grid;constructor(t=e.DEFAULT_GRID_SIZE){this.grid=new Int32Array(t)}index(t,i){return t<>>e.INT_BITS}flag(t,i){this.grid[this.index(t,i)]|=1<<(i&e.INT_BITS_FLAG)}unflag(t,i){this.grid[this.index(t,i)]&=~(1<<(i&e.INT_BITS_FLAG))}isFlagged(t,i,r){const s=Math.max(0,t-r),n=Math.min(e.GRID_SIZE-1,t+r),a=Math.max(0,i-r),o=Math.min(e.GRID_SIZE-1,i+r),c=e.INT_BITS_FLAG,l=a&~c,h=o>>>e.INT_BITS<o&&(s=r&(1<>>a-t),0!==n)return!0}return!1}},Po=class e{static zoneIndex(e,t,i){return e>>3&2047|(t>>3&2047)<<11|(3&i)<<22}static unpackIndex(e){return{x:(2047&e)<<3,z:(e>>11&2047)<<3,level:e>>22}}zones;grids;constructor(){this.zones=new Map,this.grids=new Map}zone(t,i,r){const s=e.zoneIndex(t,i,r);let n=this.zones.get(s);return void 0===n&&(n=new No(s),this.zones.set(s,n)),n}zoneByIndex(e){let t=this.zones.get(e);return void 0===t&&(t=new No(e),this.zones.set(e,t)),t}grid(e){let t=this.grids.get(e);return void 0===t&&(t=new Lo,this.grids.set(e,t)),t}zoneCount(){return this.zones.size}locCount(){let e=0;for(const t of this.zones.values())e+=t.totalLocs;return e}objCount(){let e=0;for(const t of this.zones.values())e+=t.totalObjs;return e}},wo=class e{static INTERVAL=10;static PREFERRED_PLAYERS=250;static PREFERRED_NPCS=255;static PREFERRED_VIEW_DISTANCE=15;npcs;players;loadedZones;activeZones;extendedInfo;appearances;forceViewDistance=!1;viewDistance=e.PREFERRED_VIEW_DISTANCE;lastResize=0;constructor(){this.npcs=new Set,this.players=new Set,this.loadedZones=new Set,this.activeZones=new Set,this.extendedInfo=new Set,this.appearances=new Map}resize(){if(!this.forceViewDistance)return this.players.size>=e.PREFERRED_PLAYERS?(this.viewDistance>1&&this.viewDistance--,void(this.lastResize=0)):void(++this.lastResize>=e.INTERVAL&&(this.viewDistance=e.PREFERRED_PLAYERS)break e;this.players.has(o.uid)||o.uid!==t&&(yield o)}}*getNearbyNpcs(t,i,r,s){e:for(const n of this.proximitySort(t,i,this.activeZones))for(const a of this.getNearby(Zl.getZoneIndex(n).getAllNpcsSafe(),t,i,r,s,15)){if(this.npcs.size>=e.PREFERRED_NPCS)break e;this.npcs.has(a.nid)||(yield a)}}*getNearby(e,t,i,r,s,n){const a=r-48,o=r+48,c=s+48,l=s-48;for(const r of e)r.x<=a||r.x>=o||r.z>=c||r.z<=l||ji.isWithinDistanceSW({x:t,z:i},r,n)&&(yield r)}proximitySort(e,t,i){return Array.from(i.values()).map((i=>this.zoneToDistance(i,e,t))).sort(((e,t)=>e.distance-t.distance)).map((({zoneIndex:e})=>e))}zoneToDistance(e,t,i){const r=Po.unpackIndex(e);return{zoneIndex:e,distance:Math.abs(r.x-t)+Math.abs(r.z-i)}}},bo=new Int32Array(99),Ro=0;for(let e=0;e<99;e++){const t=e+1;Ro+=Math.floor(t+300*Math.pow(2,t/7)),bo[e]=10*Math.floor(Ro/4)}function Bo(e){for(let t=98;t>=0;t--)if(e>=bo[t])return Math.min(t+2,99);return 1}function Uo(e){return bo[e-2]}var Do=class e extends Ns{static APPEARANCE=1;static ANIM=2;static FACE_ENTITY=4;static SAY=8;static DAMAGE=16;static FACE_COORD=32;static CHAT=64;static BIG_UPDATE=128;static SPOTANIM=256;static EXACT_MOVE=512;static SKILLS=['attack','defence','strength','hitpoints','ranged','prayer','magic','cooking','woodcutting','fletching','fishing','firemaking','crafting','smithing','mining','herblore','agility','thieving','stat18','stat19','runecraft'];static DESIGN_BODY_COLORS=[[6798,107,10283,16,4797,7744,5799,4634,33697,22433,2983,54193],[8741,12,64030,43162,7735,8404,1701,38430,24094,10153,56621,4783,1341,16578,35003,25239],[25238,8742,12,64030,43162,7735,8404,1701,38430,24094,10153,56621,4783,1341,16578,35003],[4626,11146,6439,12,4758,10270],[4550,4537,5681,5673,5790,6806,8076,4574]];save(){const e=Oe.alloc(1);e.p2(8196),e.p2(3),e.p2(this.x),e.p2(this.z),e.p1(this.level);for(let t=0;t<7;t++)e.p1(this.body[t]);for(let t=0;t<5;t++)e.p1(this.colors[t]);e.p1(this.gender),e.p2(this.runenergy),e.p4(this.playtime);for(let t=0;t<21;t++)e.p4(this.stats[t]),e.p1(this.levels[t]);e.p2(this.vars.length);for(let t=0;t=255?(e.p1(255),e.p4(i.count)):e.p1(i.count)):e.p2(0)}t++}}e.data[i]=t,e.p1(this.afkZones.length);for(let t=0;tt&&t.uid===e));if(-1!==i)return void(this.heroPoints[i].points+=t);const r=this.heroPoints.findIndex((e=>e&&-1===e.uid));-1===r||(this.heroPoints[r]={uid:e,points:t})}findHero(){return this.heroPoints.sort(((e,t)=>t.points-e.points)),this.heroPoints[0]?.uid??-1}resetEntity(e){e&&(this.faceX=-1,this.faceZ=-1,this.orientationX=-1,this.orientationZ=-1),super.resetPathingEntity(),this.repathed=!1,this.protect=!1,this.messageColor=null,this.messageEffect=null,this.messageType=null,this.message=null}onLogin(){this.playerLog('Logging in'),this.write(new Bs),this.write(new Us(this.pid)),this.unsetMapFlag(),this.write(new Ds),this.resetHeroPoints(),this.write(new ks);for(let e=0;e1){const e=Math.floor(this.runweight/1e3),t=67+67*Math.min(Math.max(e,0),64)/64|0;this.runenergy=Math.max(this.runenergy-t,0)}}recoverEnergy(e){if(!this.delayed()&&(!e||this.moveSpeed!==Is.RUN)&&this.runenergy<1e4){const e=8+(this.baseLevels[$i.AGILITY]/9|0);this.runenergy=Math.min(this.runenergy+e,1e4)}}blockWalkFlag(){return Ri.PLAYER}defaultMoveSpeed(){return this.getVar(Nt.PLAYER_RUN)?Is.RUN:Is.WALK}closeSticky(){if(-1!==this.modalSticky){const e=jt.getByTrigger(cs.IF_CLOSE,this.modalSticky);e&&this.enqueueScript(e,1),this.modalSticky=-1,this.write(new Ms(-1))}}closeModal(){if(this.receivedFirstClose){if(this.weakQueue.clear(),this.delayed()||(this.protect=!1),0!==this.modalState){if(-1!==this.modalTop){const e=jt.getByTrigger(cs.IF_CLOSE,this.modalTop);e&&this.enqueueScript(e,1),this.modalTop=-1}if(-1!==this.modalBottom){const e=jt.getByTrigger(cs.IF_CLOSE,this.modalBottom);e&&this.enqueueScript(e,1),this.modalBottom=-1}if(-1!==this.modalSidebar){const e=jt.getByTrigger(cs.IF_CLOSE,this.modalSidebar);e&&this.enqueueScript(e,1),this.modalSidebar=-1}this.modalState=0,this.refreshModalClose=!0}}else this.receivedFirstClose=!0}delayed(){return this.delay>Zl.currentTick}containsModalInterface(){return!(1&~this.modalState&&2&~this.modalState&&16&~this.modalState)}busy(){return this.delayed()||this.containsModalInterface()}canAccess(){return!this.protect&&!this.busy()}enqueueScript(e,t=0,i=0,r=[]){const s=new As(t,e,r,i);1===t?(s.delay=0,this.engineQueue.addTail(s)):2===t?this.weakQueue.addTail(s):this.queue.addTail(s)}processQueues(){let e=!1;for(let t=this.queue.head();null!==t;t=this.queue.next())if(3===t.type){e=!0;break}e&&this.closeModal(),this.processQueue(),this.processWeakQueue()}processQueue(){for(let e=this.queue.head();null!==e;e=this.queue.next()){3===e.type&&this.closeModal();const t=e.delay--;if(this.canAccess()&&t<=0){const t=Dl.init(e.script,this,null,e.args);this.executeScript(t,!0),e.unlink()}}}processWeakQueue(){for(let e=this.weakQueue.head();null!==e;e=this.weakQueue.next()){const t=e.delay--;if(this.canAccess()&&t<=0){const t=Dl.init(e.script,this,null,e.args);this.executeScript(t,!0),e.unlink()}}}setTimer(e,t,i=[],r){const s=t.id,n={type:e,script:t,args:i,interval:r,clock:r};this.timers.set(s,n)}clearTimer(e){this.timers.delete(e)}processTimers(e){for(const t of this.timers.values())if(e===t.type&&--t.clock<=0&&(1===t.type||this.canAccess())){t.clock=t.interval;const e=Dl.init(t.script,this,null,t.args);this.runScript(e,0===t.type)}}stopAction(){this.clearPendingAction(),this.unsetMapFlag()}clearPendingAction(){this.clearInteraction(),this.closeModal()}hasInteraction(){return null!==this.target}getOpTrigger(){if(!this.target)return null;let e=-1,t=-1;if(this.target instanceof kl||this.target instanceof ss||this.target instanceof $r){const i=this.target instanceof kl?ft.get(this.target.type):this.target instanceof ss?at.get(this.target.type):Tt.get(this.target.type);e=i.id,t=i.category}return-1!==this.targetSubject.type&&(e=this.targetSubject.type),-1!==this.targetSubject.com&&(e=this.targetSubject.com),jt.getByTrigger(this.targetOp+7,e,t)??null}getApTrigger(){if(!this.target)return null;let e=-1,t=-1;if(this.target instanceof kl||this.target instanceof ss||this.target instanceof $r){const i=this.target instanceof kl?ft.get(this.target.type):this.target instanceof ss?at.get(this.target.type):Tt.get(this.target.type);e=i.id,t=i.category}return-1!==this.targetSubject.type&&(e=this.targetSubject.type),-1!==this.targetSubject.com&&(e=this.targetSubject.com),jt.getByTrigger(this.targetOp,e,t)??null}processInteraction(){if(null===this.target||!this.canAccess())return void this.updateMovement();if(this.target.level!==this.level)return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof kl&&(void 0===Zl.getNpc(this.target.nid)||this.target.delayed()))return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof kl&&-1!==this.targetSubject.type&&null===Zl.getNpcByUid(this.targetSubject.type<<16|this.target.nid))return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof $r&&null===Zl.getObj(this.target.x,this.target.z,this.level,this.target.type,this.pid))return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof ss&&null===Zl.getLoc(this.target.x,this.target.z,this.level,this.target.type))return this.clearInteraction(),void this.unsetMapFlag();if(this.target instanceof e&&null===Zl.getPlayerByUid(this.target.uid))return this.clearInteraction(),void this.unsetMapFlag();if(this.targetOp===cs.APPLAYER3||this.targetOp===cs.OPPLAYER3){return void(this.updateMovement(!1)&&(this.alreadyFacedEntity=!1,this.lastMovement=Zl.currentTick+1))}const t=this.getOpTrigger(),i=this.getApTrigger();if(t&&this.target instanceof Ns&&this.inOperableDistance(this.target)){const e=this.target;this.target=null,this.executeScript(Dl.init(t,this,e),!0),null===this.target&&this.unsetMapFlag(),this.interacted=!0,this.clearWaypoints()}else if(i&&this.inApproachDistance(this.apRange,this.target)){const e=this.target;this.target=null,this.executeScript(Dl.init(i,this,e),!0),this.apRangeCalled?this.target=e:(this.clearWaypoints(),this.interacted=!0),null===this.target&&this.unsetMapFlag()}else if(this.target instanceof Ns&&this.inOperableDistance(this.target)){if(vt.NODE_DEBUG&&!t&&!i){let e='_';this.target instanceof kl?e=-1!==this.targetSubject.com&&this.targetOp===cs.APNPCT||this.targetOp===cs.OPNPCT?tt.get(this.targetSubject.com)?.comName??this.targetSubject.toString():ft.get(this.target.type)?.debugname??this.target.type.toString():this.target instanceof ss?e=at.get(this.target.type)?.debugname??this.target.type.toString():this.target instanceof $r?e=Tt.get(this.target.type)?.debugname??this.target.type.toString():-1!==this.targetSubject.com&&this.targetOp===cs.APNPCT||this.targetOp===cs.APPLAYERT||this.targetOp===cs.APLOCT||this.targetOp===cs.APOBJT?e=tt.get(this.targetSubject.com)?.comName??this.targetSubject.toString():-1!==this.targetSubject.type&&(e=Tt.get(this.targetSubject.type)?.debugname??this.targetSubject.toString()),this.messageGame(`No trigger for [${cs[this.targetOp+7].toLowerCase()},${e}]`)}this.target=null,this.messageGame('Nothing interesting happens.'),this.interacted=!0,this.clearWaypoints()}const r=this.updateMovement();if(r&&(this.alreadyFacedEntity=!1,this.lastMovement=Zl.currentTick+1),this.target&&(!this.interacted||this.apRangeCalled))if(this.interacted=!1,t&&(this.target instanceof Ns||!r)&&this.inOperableDistance(this.target)){const e=this.target;this.target=null,this.executeScript(Dl.init(t,this,e),!0),null===this.target&&this.unsetMapFlag(),this.interacted=!0,this.clearWaypoints()}else if(i&&this.inApproachDistance(this.apRange,this.target)){this.apRangeCalled=!1;const e=this.target;this.target=null,this.executeScript(Dl.init(i,this,e),!0),this.apRangeCalled?this.target=e:(this.clearWaypoints(),this.interacted=!0),null===this.target&&this.unsetMapFlag()}else if((this.target instanceof Ns||!r)&&this.inOperableDistance(this.target)){if(!vt.NODE_PRODUCTION&&!t&&!i){let e='_';this.target instanceof kl?e=ft.get(this.target.type)?.debugname??this.target.type.toString():this.target instanceof ss?e=at.get(this.target.type)?.debugname??this.target.type.toString():this.target instanceof $r?e=Tt.get(this.target.type)?.debugname??this.target.type.toString():-1!==this.targetSubject.com&&this.targetOp===cs.APNPCT||this.targetOp===cs.APPLAYERT||this.targetOp===cs.APLOCT||this.targetOp===cs.APOBJT?e=tt.get(this.targetSubject.com)?.comName??this.targetSubject.toString():-1!==this.targetSubject.type&&(e=Tt.get(this.targetSubject.type)?.debugname??this.targetSubject.toString()),this.messageGame(`No trigger for [${cs[this.targetOp+7].toLowerCase()},${e}]`)}this.target=null,this.messageGame('Nothing interesting happens.'),this.interacted=!0,this.clearWaypoints()}if(!this.interactWalkTrigger&&-1!==this.walktrigger&&!this.protect&&!this.delayed()){const e=jt.get(this.walktrigger);if(this.walktrigger=-1,e){const t=Dl.init(e,this);this.interactWalkTrigger=!0,this.unsetMapFlag(),this.runScript(t,!0)}}this.interacted||this.hasWaypoints()||r||(this.messageGame("I can't reach that!"),this.clearInteraction()),this.interacted&&!this.apRangeCalled&&null===this.target&&this.clearInteraction()}getAppearanceInSlot(e){let t=-1;return 8===e?t=this.body[0]:11===e?t=this.body[1]:4===e?t=this.body[2]:6===e?t=this.body[3]:9===e?t=this.body[4]:7===e?t=this.body[5]:10===e&&(t=this.body[6]),-1===t?0:256+t}getCombatLevel(){const e=.25*(this.baseLevels[$i.DEFENCE]+this.baseLevels[$i.HITPOINTS]+Math.floor(this.baseLevels[$i.PRAYER]/2)),t=.325*(this.baseLevels[$i.ATTACK]+this.baseLevels[$i.STRENGTH]),i=.325*(Math.floor(this.baseLevels[$i.RANGED]/2)+this.baseLevels[$i.RANGED]),r=.325*(Math.floor(this.baseLevels[$i.MAGIC]/2)+this.baseLevels[$i.MAGIC]);return Math.floor(e+Math.max(t,i,r))}generateAppearance(t){const i=Oe.alloc(0);i.p1(this.gender),i.p1(this.headicons);const r=[];let s=this.getInventory(t);s||(s=new Xt(it.WORN,0));for(let e=0;ei.type===e&&i.com===t)))return;it.get(e).scope===it.SCOPE_SHARED&&(i=-1),this.invListeners.push({type:e,com:t,source:i,firstSeen:!0})}invStopListenOnCom(e){const t=this.invListeners.findIndex((t=>t.com===e));-1!==t&&(this.invListeners.splice(t,1),this.write(new xs(e)))}invGetSlot(e,t){const i=this.getInventory(e);if(!i)throw new Error('invGetSlot: Invalid inventory type: '+e);if(!i.validSlot(t))throw new Error('invGetSlot: Invalid slot: '+t);return i.get(t)}invClear(e){const t=this.getInventory(e);if(!t)throw new Error('invClear: Invalid inventory type: '+e);t.removeAll()}invAdd(e,t,i,r=!0){const s=this.getInventory(e);if(!s)throw new Error('invAdd: Invalid inventory type: '+e);return s.add(t,i,-1,r).completed}invSet(e,t,i,r){const s=this.getInventory(e);if(!s)throw new Error('invSet: Invalid inventory type: '+e);if(!s.validSlot(r))throw new Error('invSet: Invalid slot: '+r);s.set(r,{id:t,count:i})}invDel(e,t,i,r=-1){const s=this.getInventory(e);if(!s)throw new Error('invDel: Invalid inventory type: '+e);if(r<-1||r>=this.invSize(e))throw new Error('invDel: Invalid beginSlot: '+r);return s.remove(t,i,r).completed}invDelSlot(e,t){const i=this.getInventory(e);if(!i)throw new Error('invDelSlot: Invalid inventory type: '+e);if(!i.validSlot(t))throw new Error('invDelSlot: Invalid slot: '+t);i.delete(t)}invSize(e){const t=this.getInventory(e);if(!t)throw new Error('invSize: Invalid inventory type: '+e);return t.capacity}invTotal(e,t){const i=this.getInventory(e);if(!i)throw new Error('invTotal: Invalid inventory type: '+e);return i.getItemCount(t)}invFreeSpace(e){const t=this.getInventory(e);if(!t)throw new Error('invFreeSpace: Invalid inventory type: '+e);return t.freeSlotCount}invItemSpace(e,t,i,r){const s=this.getInventory(e);if(!s)throw new Error('invItemSpace: Invalid inventory type: '+e);const n=Tt.get(t);let a=t;if(n.certtemplate>=0&&n.certlink>=0&&(a=n.certlink),n.stackable||a!=t||s.stackType==Xt.ALWAYS_STACK){const r=!0===it.get(e).stockobj?.includes(t);return 0!=this.invTotal(e,t)||0!=this.invFreeSpace(e)||r?Math.max(0,i-(Xt.STACK_LIMIT-this.invTotal(e,t))):i}return Math.max(0,i-(this.invFreeSpace(e)-(this.invSize(e)-r)))}invMoveToSlot(e,t,i,r){const s=this.getInventory(e);if(!s)throw new Error('invMoveToSlot: Invalid inventory type: '+e);if(!s.validSlot(i))throw new Error('invMoveToSlot: Invalid from slot: '+i);const n=this.getInventory(t);if(!n)throw new Error('invMoveToSlot: Invalid inventory type: '+t);if(!n.validSlot(r))throw new Error('invMoveToSlot: Invalid to slot: '+r);const a=this.invGetSlot(e,i);if(!a)throw new Error(`invMoveToSlot: Invalid from obj was null. This means the obj does not exist at this slot: ${i}`);const o=this.invGetSlot(t,r);this.invSet(t,a.id,a.count,r),o?this.invSet(e,o.id,o.count,i):this.invDelSlot(e,i)}invMoveFromSlot(e,t,i){const r=this.getInventory(e);if(!r)throw new Error('invMoveFromSlot: Invalid inventory type: '+e);if(!this.getInventory(t))throw new Error('invMoveFromSlot: Invalid inventory type: '+t);if(!r.validSlot(i))throw new Error('invMoveFromSlot: Invalid from slot: '+i);const s=this.invGetSlot(e,i);if(!s)throw new Error(`invMoveFromSlot: Invalid from obj was null. This means the obj does not exist at this slot: ${i}`);return this.invDelSlot(e,i),{overflow:s.count-this.invAdd(t,s.id,s.count,!1),fromObj:s.id}}invTotalCat(e,t){const i=this.getInventory(e);if(!i)throw new Error('invTotalCat: Invalid inventory type: '+e);return i.itemsFiltered.filter((e=>Tt.get(e.id).category==t)).reduce(((e,t)=>e+t.count),0)}_invTotalParam(e,t,i){const r=this.getInventory(e);if(!r)throw new Error('invTotalParam: Invalid inventory type: '+e);const s=gt.get(t);let n=0;for(let e=0;e=Tt.count)continue;const a=Tt.get(t.id),o=st(s.id,a,s.defaultInt);n+=i?t.count*o:o}return n}invTotalParam(e,t){return this._invTotalParam(e,t,!1)}invTotalParamStack(e,t){return this._invTotalParam(e,t,!0)}getVar(e){const t=Nt.get(e);return t.type===Pe.STRING?this.varsString[t.id]:this.vars[t.id]}setVar(e,t){const i=Nt.get(e);i.type===Pe.STRING&&'string'==typeof t?this.varsString[i.id]=t:'number'==typeof t&&(this.vars[i.id]=t,i.transmit&&this.writeVarp(e,t))}writeVarp(e,t){t>=-128&&t<=127?this.write(new Fs(e,t)):this.write(new Hs(e,t))}addXp(e,t){if(t<0)throw new Error(`Invalid xp parameter for addXp call: Stat was: ${e}, Exp was: ${t}`);if(0==t)return;const i=Number(vt.NODE_XPRATE)||1;this.stats[e]+=t*i,this.stats[e]>2e9&&(this.stats[e]=2e9);const r=this.baseLevels[e];if(this.levels[e]===this.baseLevels[e]&&(this.levels[e]=Bo(this.stats[e])),this.baseLevels[e]=Bo(this.stats[e]),this.baseLevels[e]>r){this.levels[e]=It.count||this.animProtect||(-1==t||-1==this.animId||It.get(t).priority>It.get(this.animId).priority||0===It.get(this.animId).priority)&&(this.animId=t,this.animDelay=i,this.mask|=e.ANIM)}spotanim(t,i,r){this.graphicId=t,this.graphicHeight=i,this.graphicDelay=r,this.mask|=e.SPOTANIM}applyDamage(t,i){this.damageTaken=t,this.damageType=i;const r=this.levels[$i.HITPOINTS];r-t<=0?(this.levels[$i.HITPOINTS]=0,this.damageTaken=r):this.levels[$i.HITPOINTS]=r-t,this.mask|=e.DAMAGE}say(t){this.chat=t,this.mask|=e.SAY}faceSquare(t,i){this.faceX=2*t+1,this.faceZ=2*i+1,this.orientationX=this.faceX,this.orientationZ=this.faceZ,this.mask|=e.FACE_COORD}playSong(e){if(!(e=e.toLowerCase().replaceAll(' ','_')))return;const t=Ps.get(e+'.mid'),i=ws.get(e+'.mid');if(t&&i){const r=t.length;this.write(new Vs(e,i,r))}}playJingle(e,t){if(!(t=t.toLowerCase().replaceAll('_',' ')))return;const i=Ps.get(t+'.mid');i&&this.write(new Gs(e,i))}openMainModal(e){4&this.modalState&&(this.write(new Bs),this.modalState&=-5,this.modalSidebar=-1),this.modalState|=1,this.modalTop=e,this.refreshModal=!0}openChat(e){this.modalState|=2,this.modalBottom=e,this.refreshModal=!0}openSideOverlay(e){this.modalState|=4,this.modalSidebar=e,this.refreshModal=!0}openChatSticky(e){this.write(new Ms(e)),this.modalState|=8,this.modalSticky=e}openMainModalSideOverlay(e,t){this.modalState|=1,this.modalTop=e,this.modalState|=4,this.modalSidebar=t,this.refreshModal=!0}exactMove(t,i,r,s,n,a,o){this.exactStartX=t,this.exactStartZ=i,this.exactEndX=r,this.exactEndZ=s,this.exactMoveStart=n,this.exactMoveEnd=a,this.exactMoveDirection=o,this.mask|=e.EXACT_MOVE,this.x=r,this.z=s,this.lastStepX=this.x-1,this.lastStepZ=this.z}setTab(e,t){this.overlaySide[t]=e,this.write(new Ws(e,t))}isComponentVisible(e){return this.modalTop===e.rootLayer||this.modalBottom===e.rootLayer||this.modalSidebar===e.rootLayer||-1!==this.overlaySide.findIndex((t=>t===e.rootLayer))||this.modalSticky===e.rootLayer}updateAfkZones(){if(this.lastAfkZone=Math.min(1e3,this.lastAfkZone+1),this.withinAfkZone())return;const e=ji.packCoord(0,this.x-10,this.z-10);this.moveSpeed===Is.INSTANT&&this.jump?this.afkZones[1]=e:this.afkZones[1]=this.afkZones[0],this.afkZones[0]=e,this.lastAfkZone=0}zonesAfk(){return 1e3===this.lastAfkZone}withinAfkZone(){for(let e=0;e=2944&&this.x<3392&&this.z>=3520&&this.z<6400||this.x>=2944&&this.x<3392&&this.z>=9920&&this.z<12800}runScript(e,t=!1,i=!1){if(!i&&t&&(this.protect||this.delayed()))return-1;t&&(e.pointerAdd(Gt.ProtectedActivePlayer),this.protect=!0);const r=Dl.execute(e);return t&&(this.protect=!1),e.pointerGet(Gt.ProtectedActivePlayer)&&e._activePlayer&&(e.pointerRemove(Gt.ProtectedActivePlayer),e._activePlayer.protect=!1),e.pointerGet(Gt.ProtectedActivePlayer2)&&e._activePlayer2&&(e.pointerRemove(Gt.ProtectedActivePlayer2),e._activePlayer2.protect=!1),r}executeScript(e,t=!1,i=!1){const r=this.runScript(e,t,i);-1!==r&&(r!==$t.FINISHED&&r!==$t.ABORTED?r===$t.WORLD_SUSPENDED?Zl.enqueueScript(e,e.popInt()):r===$t.NPC_SUSPENDED?e.activeNpc.activeScript=e:(e.activePlayer.activeScript=e,e.activePlayer.protect=t):e===this.activeScript&&(this.activeScript=null,1&this.modalState||this.closeModal()))}wrappedMessageGame(e){const t=Ge.get(1).split(e,456);for(const e of t)this.messageGame(e)}write(e){e.priority===Rs.HIGH?this.highPriorityOut.push(e):this.lowPriorityOut.push(e)}unsetMapFlag(){this.clearWaypoints(),this.write(new Ks)}hintNpc(e){this.write(new zs(1,e,0,0,0,0))}hintTile(e,t,i,r){this.write(new zs(e,0,0,t,i,r))}hintPlayer(e){this.write(new zs(10,0,e,0,0,0))}stopHint(){this.write(new zs(-1,0,0,0,0,0))}lastLoginInfo(e,t,i,r){this.write(new js(e,t,i,r)),this.modalState|=16}logout(){}terminate(){}messageGame(e){this.write(new Ys(e))}},ko=class e{constructor(t,i,r){this.index=t,this.id=i,this.length=r,e.all[t]=this,e.byId[i]=this}static all=[];static byId=[];static REBUILD_GETMAPS=new e(4,150,-1);static NO_TIMEOUT=new e(6,108,0);static IDLE_TIMER=new e(30,70,0);static EVENT_TRACKING=new e(34,81,-2);static EVENT_CAMERA_POSITION=new e(35,189,6);static ANTICHEAT_OPLOGIC1=new e(60,7,4);static ANTICHEAT_OPLOGIC2=new e(61,88,4);static ANTICHEAT_OPLOGIC3=new e(62,30,3);static ANTICHEAT_OPLOGIC4=new e(63,176,2);static ANTICHEAT_OPLOGIC5=new e(64,220,0);static ANTICHEAT_OPLOGIC6=new e(65,66,4);static ANTICHEAT_OPLOGIC7=new e(66,17,4);static ANTICHEAT_OPLOGIC8=new e(67,2,2);static ANTICHEAT_OPLOGIC9=new e(68,238,1);static ANTICHEAT_CYCLELOGIC1=new e(70,233,1);static ANTICHEAT_CYCLELOGIC2=new e(71,146,-1);static ANTICHEAT_CYCLELOGIC3=new e(74,215,3);static ANTICHEAT_CYCLELOGIC4=new e(72,236,4);static ANTICHEAT_CYCLELOGIC5=new e(75,85,0);static ANTICHEAT_CYCLELOGIC6=new e(73,219,-1);static OPOBJ1=new e(80,140,6);static OPOBJ2=new e(81,40,6);static OPOBJ3=new e(82,200,6);static OPOBJ4=new e(83,178,6);static OPOBJ5=new e(84,247,6);static OPOBJT=new e(88,138,8);static OPOBJU=new e(89,239,12);static OPNPC1=new e(100,194,2);static OPNPC2=new e(101,8,2);static OPNPC3=new e(102,27,2);static OPNPC4=new e(103,113,2);static OPNPC5=new e(104,100,2);static OPNPCT=new e(108,134,4);static OPNPCU=new e(109,202,8);static OPLOC1=new e(120,245,6);static OPLOC2=new e(121,172,6);static OPLOC3=new e(122,96,6);static OPLOC4=new e(123,97,6);static OPLOC5=new e(124,116,6);static OPLOCT=new e(128,9,8);static OPLOCU=new e(129,75,12);static OPPLAYER1=new e(140,164,2);static OPPLAYER2=new e(141,53,2);static OPPLAYER3=new e(142,185,2);static OPPLAYER4=new e(143,206,2);static OPPLAYERT=new e(148,177,4);static OPPLAYERU=new e(149,248,8);static OPHELD1=new e(160,195,6);static OPHELD2=new e(161,71,6);static OPHELD3=new e(162,133,6);static OPHELD4=new e(163,157,6);static OPHELD5=new e(164,211,6);static OPHELDT=new e(168,48,8);static OPHELDU=new e(169,130,12);static INV_BUTTON1=new e(190,31,6);static INV_BUTTON2=new e(191,59,6);static INV_BUTTON3=new e(192,212,6);static INV_BUTTON4=new e(193,38,6);static INV_BUTTON5=new e(194,6,6);static IF_BUTTON=new e(200,155,2);static RESUME_PAUSEBUTTON=new e(201,235,2);static CLOSE_MODAL=new e(202,231,0);static RESUME_P_COUNTDIALOG=new e(203,237,4);static TUTORIAL_CLICKSIDE=new e(204,175,1);static MOVE_OPCLICK=new e(242,93,-1);static BUG_REPORT=new e(243,190,10);static MOVE_MINIMAPCLICK=new e(244,165,-1);static INV_BUTTOND=new e(245,159,6);static IGNORELIST_DEL=new e(246,171,8);static IGNORELIST_ADD=new e(247,79,8);static IF_PLAYERDESIGN=new e(248,52,13);static CHAT_SETMODE=new e(249,244,3);static MESSAGE_PRIVATE=new e(250,148,-1);static FRIENDLIST_DEL=new e(251,11,8);static FRIENDLIST_ADD=new e(252,118,8);static CLIENT_CHEAT=new e(253,4,-1);static MESSAGE_PUBLIC=new e(254,158,-1);static MOVE_GAMECLICK=new e(255,181,-1)},Mo=class{},xo=class{},Fo=class e{constructor(e,t){this.id=e,this.limit=t}static CLIENT_EVENT=new e(0,20);static USER_EVENT=new e(1,5)},Ho=class extends xo{constructor(e){super(),this.input=e}category=Fo.USER_EVENT},Vo=class extends Mo{prot=ko.CLIENT_CHEAT;decode(e){const t=e.gjstr();return new Ho(t)}},Go=class extends xo{category=Fo.USER_EVENT},Wo=class extends Mo{prot=ko.CLOSE_MODAL;decode(){return new Go}},Ko=class extends xo{category=Fo.CLIENT_EVENT},zo=class extends Mo{prot=ko.IDLE_TIMER;decode(){return new Ko}},jo=class extends xo{constructor(e){super(),this.component=e}category=Fo.USER_EVENT},Yo=class extends Mo{prot=ko.IF_BUTTON;decode(e){const t=e.g2();return new jo(t)}},qo=class extends xo{constructor(e,t,i){super(),this.gender=e,this.idkit=t,this.color=i}category=Fo.USER_EVENT},Qo=class extends Mo{prot=ko.IF_PLAYERDESIGN;decode(e){const t=e.g1(),i=[];for(let t=0;t<7;t++)i[t]=e.g1(),255===i[t]&&(i[t]=-1);const r=[];for(let t=0;t<5;t++)r[t]=e.g1();return new qo(t,i,r)}},$o=class extends xo{constructor(e,t,i,r){super(),this.op=e,this.obj=t,this.slot=i,this.component=r}category=Fo.USER_EVENT},Zo=class extends Mo{constructor(e,t){super(),this.prot=e,this.op=t}decode(e){const t=e.g2(),i=e.g2(),r=e.g2();return new $o(this.op,t,i,r)}},Xo=class extends xo{constructor(e,t,i){super(),this.component=e,this.slot=t,this.targetSlot=i}category=Fo.USER_EVENT},Jo=class extends Mo{prot=ko.INV_BUTTOND;decode(e){const t=e.g2(),i=e.g2(),r=e.g2();return new Xo(t,i,r)}},ec=class extends xo{constructor(e,t){super(),this.username=e,this.input=t}category=Fo.USER_EVENT},tc=class extends Mo{prot=ko.MESSAGE_PRIVATE;decode(e){const t=e.g8(),i=wa.unpack(e,e.length-8);return new ec(t,i)}},ic=class extends xo{constructor(e,t,i){super(),this.input=e,this.color=t,this.effect=i}category=Fo.USER_EVENT},rc=class extends Mo{prot=ko.MESSAGE_PUBLIC;decode(e){const t=e.g1(),i=e.g1(),r=wa.unpack(e,e.length-2);return new ic(r,t,i)}},sc=class extends xo{constructor(e,t,i,r){super(),this.op=e,this.obj=t,this.slot=i,this.component=r}category=Fo.USER_EVENT},nc=class extends Mo{constructor(e,t){super(),this.prot=e,this.op=t}decode(e){const t=e.g2(),i=e.g2(),r=e.g2();return new sc(this.op,t,i,r)}},ac=class extends xo{constructor(e,t,i,r){super(),this.obj=e,this.slot=t,this.component=i,this.spellComponent=r}category=Fo.USER_EVENT},oc=class extends Mo{prot=ko.OPHELDT;decode(e){const t=e.g2(),i=e.g2(),r=e.g2(),s=e.g2();return new ac(t,i,r,s)}},cc=class extends xo{constructor(e,t,i,r,s,n){super(),this.obj=e,this.slot=t,this.component=i,this.useObj=r,this.useSlot=s,this.useComponent=n}category=Fo.USER_EVENT},lc=class extends Mo{prot=ko.OPHELDU;decode(e){const t=e.g2(),i=e.g2(),r=e.g2(),s=e.g2(),n=e.g2(),a=e.g2();return new cc(t,i,r,s,n,a)}},hc=class extends xo{constructor(e,t,i,r){super(),this.op=e,this.x=t,this.z=i,this.loc=r}category=Fo.USER_EVENT},dc=class extends Mo{constructor(e,t){super(),this.prot=e,this.op=t}decode(e){const t=e.g2(),i=e.g2(),r=e.g2();return new hc(this.op,t,i,r)}},uc=class extends xo{constructor(e,t,i,r){super(),this.x=e,this.z=t,this.loc=i,this.spellComponent=r}category=Fo.USER_EVENT},pc=class extends Mo{prot=ko.OPLOCT;decode(e){const t=e.g2(),i=e.g2(),r=e.g2(),s=e.g2();return new uc(t,i,r,s)}},fc=class extends xo{constructor(e,t,i,r,s,n){super(),this.x=e,this.z=t,this.loc=i,this.useObj=r,this.useSlot=s,this.useComponent=n}category=Fo.USER_EVENT},gc=class extends Mo{prot=ko.OPLOCU;decode(e){const t=e.g2(),i=e.g2(),r=e.g2(),s=e.g2(),n=e.g2(),a=e.g2();return new fc(t,i,r,s,n,a)}},mc=class extends xo{constructor(e,t){super(),this.op=e,this.nid=t}category=Fo.USER_EVENT},yc=class extends Mo{constructor(e,t){super(),this.prot=e,this.op=t}decode(e){const t=e.g2();return new mc(this.op,t)}},Ec=class extends xo{constructor(e,t){super(),this.nid=e,this.spellComponent=t}category=Fo.USER_EVENT},_c=class extends Mo{prot=ko.OPNPCT;decode(e){const t=e.g2(),i=e.g2();return new Ec(t,i)}},Ac=class extends xo{constructor(e,t,i,r){super(),this.nid=e,this.useObj=t,this.useSlot=i,this.useComponent=r}category=Fo.USER_EVENT},vc=class extends Mo{prot=ko.OPNPCU;decode(e){const t=e.g2(),i=e.g2(),r=e.g2(),s=e.g2();return new Ac(t,i,r,s)}},Tc=class extends xo{constructor(e,t,i,r){super(),this.op=e,this.x=t,this.z=i,this.obj=r}category=Fo.USER_EVENT},Cc=class extends Mo{constructor(e,t){super(),this.prot=e,this.op=t}decode(e){const t=e.g2(),i=e.g2(),r=e.g2();return new Tc(this.op,t,i,r)}},Ic=class extends xo{constructor(e,t,i,r){super(),this.x=e,this.z=t,this.obj=i,this.spellComponent=r}category=Fo.USER_EVENT},Sc=class extends Mo{prot=ko.OPOBJT;decode(e){const t=e.g2(),i=e.g2(),r=e.g2(),s=e.g2();return new Ic(t,i,r,s)}},Oc=class extends xo{constructor(e,t,i,r,s,n){super(),this.x=e,this.z=t,this.obj=i,this.useObj=r,this.useSlot=s,this.useComponent=n}category=Fo.USER_EVENT},Nc=class extends Mo{prot=ko.OPOBJU;decode(e){const t=e.g2(),i=e.g2(),r=e.g2(),s=e.g2(),n=e.g2(),a=e.g2();return new Oc(t,i,r,s,n,a)}},Lc=class extends xo{constructor(e,t){super(),this.op=e,this.pid=t}category=Fo.USER_EVENT},Pc=class extends Mo{constructor(e,t){super(),this.prot=e,this.op=t}decode(e){const t=e.g2();return new Lc(this.op,t)}},wc=class extends xo{constructor(e,t){super(),this.pid=e,this.spellComponent=t}category=Fo.USER_EVENT},bc=class extends Mo{prot=ko.OPPLAYERT;decode(e){const t=e.g2(),i=e.g2();return new wc(t,i)}},Rc=class extends xo{constructor(e,t,i,r){super(),this.pid=e,this.useObj=t,this.useSlot=i,this.useComponent=r}category=Fo.USER_EVENT},Bc=class extends Mo{prot=ko.OPPLAYERU;decode(e){const t=e.g2(),i=e.g2(),r=e.g2(),s=e.g2();return new Rc(t,i,r,s)}},Uc=class extends xo{constructor(e){super(),this.maps=e}category=Fo.USER_EVENT},Dc=class extends Mo{prot=ko.REBUILD_GETMAPS;decode(e){const t=[],i=e.length/3;for(let r=0;re.com===n));if(!o)return!1;const c=t.getInventoryFromListener(o);if(!c||!c.validSlot(s)||!c.hasAt(s,r))return!1;if(t.delayed())return!1;let l;t.lastItem=r,t.lastSlot=s,l=1===i?cs.INV_BUTTON1:2===i?cs.INV_BUTTON2:3===i?cs.INV_BUTTON3:4===i?cs.INV_BUTTON4:cs.INV_BUTTON5;const h=jt.getByTrigger(l,n,-1);if(h){const e=tt.get(a.rootLayer);t.executeScript(Dl.init(h,t),0==e.overlay)}else vt.NODE_DEBUG&&t.messageGame(`No trigger for [${cs.toString(l)},${a.comName}]`);return!0}},Kc=class e{static TCP=0;static WEBSOCKET=1;socket=null;type=-1;state=-1;remoteAddress;totalBytesRead=0;totalBytesWritten=0;uniqueId='undefined'==typeof self?randomUUID():'https:'===self.location.protocol?self.crypto.randomUUID():'0';encryptor=null;decryptor=null;in=new Uint8Array(5e3);inOffset=0;inCount=new Uint8Array(256);out=new Oe(new Uint8Array(5e3));player=null;constructor(t,i,r=e.TCP,s=-1){this.socket=t,this.remoteAddress=i,this.type=r,this.state=s}isTCP(){return this.type===e.TCP}isWebSocket(){return this.type===e.WEBSOCKET}send(e){if('undefined'==typeof self){if(!this.socket)return;this.totalBytesWritten+=e.length,this.isTCP()?this.socket.write(e):this.isWebSocket()&&this.socket.send(e)}else this.totalBytesWritten+=e.length,self.postMessage(e)}close(){if('undefined'==typeof self){if(!this.socket)return;setTimeout((()=>{this.isTCP()?this.socket.end():this.isWebSocket()&&this.socket.close()}),100)}else setTimeout((()=>{self.close()}),100)}terminate(){if('undefined'==typeof self){if(!this.socket)return;this.isTCP()?this.socket.destroy():this.isWebSocket()&&this.socket.terminate()}else self.close()}reset(){this.inOffset=0,this.inCount.fill(0)}writeImmediate(e){this.send(e)}flush(){const e=this.out;0!==e.pos&&(this.send(e.data.subarray(0,e.pos)),e.pos=0)}},zc=class extends Kc{constructor(){super(null,'')}isTCP(){return this.type===Kc.TCP}isWebSocket(){return this.type===Kc.WEBSOCKET}send(e){this.socket}close(){this.socket}terminate(){this.socket}reset(){this.inOffset=0,this.inCount.fill(0)}},jc=class e{static loadFromFile(t){const i=ge(pe(t));let r;return r=fs24.existsSync(`data/players/${i}.sav`)?Oe.load(`data/players/${i}.sav`):new Oe(new Uint8Array),e.load(t,r,null)}static load(e,t,i){const r=pe(e),s=ge(r),n=i?new Il(s,r,i):new Do(s,r);if(vt.NODE_PRODUCTION?void 0!==vt.NODE_STAFF.find((e=>e===s))&&(n.staffModLevel=3):n.staffModLevel=3,t.data.length<2){for(let e=0;e<21;e++)n.stats[e]=0,n.baseLevels[e]=1,n.levels[e]=1;return n.stats[$i.HITPOINTS]=Uo(10),n.baseLevels[$i.HITPOINTS]=10,n.levels[$i.HITPOINTS]=10,n}if(8196!==t.g2())throw new Error('Invalid player save');const a=t.g2();if(a>3)throw new Error('Unsupported player save format');t.pos=t.data.length-4;if(t.g4()!=Oe.getcrc(t.data,0,t.data.length-4))throw new Error('Player save corrupted');t.pos=4,n.x=t.g2(),n.z=t.g2(),n.level=t.g1();for(let e=0;e<7;e++)n.body[e]=t.g1(),255===n.body[e]&&(n.body[e]=-1);for(let e=0;e<5;e++)n.colors[e]=t.g1();n.gender=t.g1(),n.runenergy=t.g2(),n.playtime=a>=2?t.g4():t.g2();for(let e=0;e<21;e++)n.stats[e]=t.g4(),n.baseLevels[e]=Bo(n.stats[e]),n.levels[e]=t.g1();const o=t.g2();for(let e=0;e=3){const e=t.g1();for(let i=0;i80)return!1;const{input:i}=e,r=i.toLowerCase().split(' '),s=r.shift();if(void 0===s||s.length<=0)return!1;if(t.playerLog('Cheat ran',i),t.staffModLevel>=3)if('reload'!==s||'undefined'!=typeof self||vt.NODE_PRODUCTION)if('rebuild'!==s||vt.NODE_PRODUCTION){if('serverdrop'===s)t.terminate();else if('bench'===s){const e=Date.now();for(let e=0;e<1e5;e++)ti(t.level,t.x,t.z,t.x,t.z+10);const i=Date.now();console.log(`took = ${i-e} ms`)}else if('bots'===s){t.messageGame('Adding bots');for(let e=0;e<1999;e++){const t=jc.load(`bot${e}`,new Oe(new Uint8Array),new zc);Zl.addPlayer(t)}}else if('lightbots'===s){t.messageGame('Adding lightweight bots');for(let e=0;e<1999;e++){const t=jc.load(`bot${e}`,new Oe(new Uint8Array),null);Zl.addPlayer(t)}}else if('teleall'===s){t.messageGame('Teleporting all players');for(const e of Zl.players){e.closeModal();do{const t=Math.floor(64*Math.random())+3200,i=Math.floor(64*Math.random())+3200;e.teleJump(t+Math.floor(64*Math.random())-32,i+Math.floor(64*Math.random())-32,0)}while(ui(e.x,e.z,e.level,Ri.WALK_BLOCKED))}}else if('moveall'===s){t.messageGame('Moving all players'),console.time('moveall');for(const e of Zl.players)e.closeModal(),e.queueWaypoints(ti(e.level,e.x,e.z,32+(e.x>>>6<<6),32+(e.z>>>6<<6)));console.timeEnd('moveall')}else if('speed'===s){if(r.length<1)return t.messageGame('Usage: ::speed '),!1;const e=yt(r.shift(),20);if(e<20)return t.messageGame('::speed input was too low.'),!1;t.messageGame(`World speed was changed to ${e}ms`),Zl.tickRate=e}else if('fly'===s)t.moveStrategy===Os.FLY?t.moveStrategy=Os.SMART:t.moveStrategy=Os.FLY,t.messageGame(`Fly is on? ${t.moveStrategy===Os.FLY}`);else if('naive'===s)t.moveStrategy===Os.NAIVE?t.moveStrategy=Os.SMART:t.moveStrategy=Os.NAIVE,t.messageGame(`Naive is on? ${t.moveStrategy===Os.NAIVE}`);else if('teleto'===s){if(r.length<1)return!1;const e=Zl.getPlayerByUsername(r[0]);if(!e)return t.messageGame(`${r[0]} is not logged in.`),!1;t.teleJump(e.x,e.z,e.level)}else if('teleother'===s){if(r.length<1)return!1;const e=Zl.getPlayerByUsername(r[0]);if(!e)return t.messageGame(`${r[0]} is not logged in.`),!1;e.teleJump(t.x,t.z,t.level)}else if('setvarother'===s){if(r.length<3)return!1;const e=Zl.getPlayerByUsername(r[0]);if(!e)return t.messageGame(`${r[0]} is not logged in.`),!1;const i=Nt.getId(r[1]),s=Math.max(-2147483648,Math.min(yt(r[2],0),2147483647));if(-1===i)return!1;e.setVar(i,s),t.messageGame('set '+r[1]+': to '+s+' on '+e.username)}else if('shutdown'===s){if(r.length<1)return!1;Zl.rebootTimer(yt(r[0],50))}}else Zl.devThread.postMessage({type:'pack'});else{Zl.reload();const e=jt.load('data/pack');t.messageGame(`Reloaded ${e} scripts.`)}if(vt.NODE_ALLOW_CHEATS||t.staffModLevel>=2)if('tele'===s){if(r.length<1)return!1;if('up'===r[0])t.teleJump(t.x,t.z,t.level+1),t.messageGame('::tele '+ji.formatString(t.level,t.x,t.z,','));else if('down'===r[0])t.teleJump(t.x,t.z,t.level-1),t.messageGame('::tele '+ji.formatString(t.level,t.x,t.z,','));else if(-1===r[0].indexOf(','))t.teleJump(yt(r[0],3200),yt(r[1],3200),yt(r[2],t.level));else{const e=r[0].split(',');if(5!==e.length)return!1;const i=yt(e[0],0),s=yt(e[1],50),n=yt(e[2],50),a=yt(e[3],0),o=yt(e[4],0);if(i<0||i>3||s<0||s>255||n<0||n>255||a<0||a>63||o<0||o>63)return!1;t.teleJump((s<<6)+a,(n<<6)+o,i)}}else if('setvar'===s){if(r.length<2)return!1;const e=Nt.getId(r[0]),i=Math.max(-2147483648,Math.min(yt(r[1],0),2147483647));if(-1===e)return!1;t.setVar(e,i),t.messageGame('set '+r[0]+': to '+i)}else if('random'===s)t.afkEventReady=!0;else if('minme'===s)for(let e=0;e '),!1;const e=Do.SKILLS.indexOf(r[0]);if(-1===e)return t.messageGame(`Unknown stat ${r[0]}`),!1;const i=10*parseInt(r[1]);t.stats[e]=i}else if('setstat'===s){if(r.length<2)return!1;const e=Do.SKILLS.indexOf(r[0]);if(-1===e)return!1;t.setLevel(e,parseInt(r[1]))}else if('advancestat'===s){if(r.length<1)return!1;const e=Do.SKILLS.indexOf(r[0]),i=Math.min(99,Math.max(1,yt(r[1],1)));if(-1===e)return!1;t.setLevel(e,t.baseLevels[e]+i)}else if('getvar'===s){if(r.length<1)return!1;const e=Nt.getId(r[0]);if(-1===e)return!1;const i=t.getVar(e);t.messageGame('get '+r[0]+': '+i)}else if('give'===s){if(r.length<1)return!1;const e=Tt.getId(r[0]),i=Math.max(1,Math.min(yt(r[1],1),2147483647));if(-1===e)return!1;t.invAdd(it.INV,e,i,!1)}if((vt.NODE_ALLOW_CHEATS||t.staffModLevel>=1)&&'getcoord'===s&&t.messageGame(ji.formatString(t.level,t.x,t.z,'_')),vt.NODE_ALLOW_CHEATS||t.staffModLevel>=2){const e=jt.getByName(`[debugproc,${s}]`);if(!e)return!1;const n=new Array(e.info.parameterTypes.length).fill(-1);for(let t=0;t1)return!1;let n=!0;for(let e=0;e<7;e++){let t=e;if(1===i&&(t+=7),8==t&&-1===r[e])continue;const s=et.get(r[e]);if(!s||s.disable||s.type!=t){n=!1;break}}if(!n)return!1;for(let e=0;e<5;e++)if(s[e]>=Do.DESIGN_BODY_COLORS[e].length){n=!1;break}return!!n&&(t.gender=i,t.body=r,t.colors=s,t.generateAppearance(it.WORN),!0)}},Xc=class extends Gc{handle(e,t){const{component:i,slot:r,targetSlot:s}=e,n=tt.get(i);if(void 0===n||!t.isComponentVisible(n))return!1;const a=t.invListeners.find((e=>e.com===i));if(!a)return!1;const o=t.getInventoryFromListener(a);if(!(o&&o.validSlot(r)&&o.get(r)&&o.validSlot(s)))return!1;if(t.delayed())return t.write(new ro(i,o,r,s)),!1;t.lastSlot=r,t.lastTargetSlot=s;const c=jt.getByTrigger(cs.INV_BUTTOND,i);if(c){const e=tt.get(n.rootLayer);t.executeScript(Dl.init(c,t),0==e.overlay)}else vt.NODE_DEBUG&&t.messageGame(`No trigger for [inv_buttond,${n.comName}]`);return!0}},Jc=class extends Gc{handle(e,t){return!0}},el=class extends Gc{handle(e,t){const{color:i,effect:r,input:s}=e;if(i<0||i>11||r<0||r>2||s.length>100)return!1;t.messageColor=i,t.messageEffect=r,t.messageType=0;const n=Oe.alloc(0);return wa.pack(n,Bt.filter(s)),t.message=new Uint8Array(n.pos),n.pos=0,n.gdata(t.message,0,t.message.length),n.release(),t.mask|=Do.CHAT,!0}},tl=class extends Gc{handle(e,t){const{obj:i,slot:r,component:s}=e,n=tt.get(s);if(void 0===n||!t.isComponentVisible(n))return!1;const a=Tt.get(i);if(5!==e.op&&(a.iop&&!a.iop[e.op-1]||!a.iop))return!1;const o=t.invListeners.find((e=>e.com===s));if(!o)return!1;const c=t.getInventoryFromListener(o);if(!c||!c.validSlot(r)||!c.hasAt(r,i))return!1;if(t.delayed())return!1;let l;t.lastItem=i,t.lastSlot=r,t.clearInteraction(),t.closeModal(),l=1===e.op?cs.OPHELD1:2===e.op?cs.OPHELD2:3===e.op?cs.OPHELD3:4===e.op?cs.OPHELD4:cs.OPHELD5;const h=jt.getByTrigger(l,a.id,a.category);return h?t.executeScript(Dl.init(h,t),!0):vt.NODE_DEBUG&&t.messageGame(`No trigger for [${cs.toString(l)},${a.debugname}]`),!0}},il=class extends Gc{handle(e,t){const{obj:i,slot:r,component:s,spellComponent:n}=e,a=tt.get(s);if(void 0===a||!t.isComponentVisible(a))return t.unsetMapFlag(),!1;const o=tt.get(s);if(void 0===o||!t.isComponentVisible(o))return t.unsetMapFlag(),!1;const c=t.invListeners.find((e=>e.com===s));if(!c)return t.unsetMapFlag(),!1;const l=t.getInventoryFromListener(c);if(!l||!l.validSlot(r)||!l.hasAt(r,i))return t.unsetMapFlag(),!1;if(t.delayed())return t.unsetMapFlag(),!1;t.lastItem=i,t.lastSlot=r,t.clearInteraction(),t.closeModal();const h=jt.getByTrigger(cs.OPHELDT,n,-1);return h?t.executeScript(Dl.init(h,t),!0):(vt.NODE_DEBUG&&t.messageGame(`No trigger for [opheldt,${o.comName}]`),t.messageGame('Nothing interesting happens.')),!0}},rl=class extends Gc{handle(e,t){const{obj:i,slot:r,component:s,useObj:n,useSlot:a,useComponent:o}=e,c=tt.get(s);if(void 0===c||!t.isComponentVisible(c))return t.unsetMapFlag(),!1;const l=tt.get(s);if(void 0===l||!t.isComponentVisible(l))return t.unsetMapFlag(),!1;{const e=t.invListeners.find((e=>e.com===s));if(!e)return t.unsetMapFlag(),!1;const n=t.getInventoryFromListener(e);if(!n||!n.validSlot(r)||!n.hasAt(r,i))return t.unsetMapFlag(),!1}{const e=t.invListeners.find((e=>e.com===o));if(!e)return t.unsetMapFlag(),!1;const i=t.getInventoryFromListener(e);if(!i||!i.validSlot(a)||!i.hasAt(a,n))return t.unsetMapFlag(),!1}if(t.delayed())return t.unsetMapFlag(),!1;t.lastItem=i,t.lastSlot=r,t.lastUseItem=n,t.lastUseSlot=a;const h=Tt.get(t.lastItem),d=Tt.get(t.lastUseItem);if((h.members||d.members)&&!vt.NODE_MEMBERS)return t.messageGame("To use this item please login to a members' server."),t.unsetMapFlag(),!1;let u=jt.getByTriggerSpecific(cs.OPHELDU,h.id,-1);u||(u=jt.getByTriggerSpecific(cs.OPHELDU,d.id,-1),[t.lastItem,t.lastUseItem]=[t.lastUseItem,t.lastItem],[t.lastSlot,t.lastUseSlot]=[t.lastUseSlot,t.lastSlot]);const p=-1!==h.category?Le.get(h.category):null;!u&&p&&(u=jt.getByTriggerSpecific(cs.OPHELDU,-1,p.id));const f=-1!==d.category?Le.get(d.category):null;return!u&&f&&(u=jt.getByTriggerSpecific(cs.OPHELDU,-1,f.id),[t.lastItem,t.lastUseItem]=[t.lastUseItem,t.lastItem],[t.lastSlot,t.lastUseSlot]=[t.lastUseSlot,t.lastSlot]),t.clearInteraction(),t.closeModal(),u?t.executeScript(Dl.init(u,t),!0):(vt.NODE_DEBUG&&t.messageGame(`No trigger for [opheldu,${h.debugname}]`),t.messageGame('Nothing interesting happens.')),!0}},sl=class extends Gc{handle(e,t){const{x:i,z:r,loc:s}=e;if(t.delayed())return t.unsetMapFlag(),!1;const n=t.originX-52,a=t.originX+52,o=t.originZ+52,c=t.originZ-52;if(ia||ro)return!1;const l=Zl.getLoc(i,r,t.level,s);if(!l)return t.unsetMapFlag(),!1;const h=at.get(l.type);if(!h.op||!h.op[e.op-1])return t.unsetMapFlag(),!1;let d;return d=1===e.op?cs.APLOC1:2===e.op?cs.APLOC2:3===e.op?cs.APLOC3:4===e.op?cs.APLOC4:cs.APLOC5,t.clearPendingAction(),t.setInteraction(hs.ENGINE,l,d),t.opcalled=!0,!0}},nl=class extends Gc{handle(e,t){const{x:i,z:r,loc:s,spellComponent:n}=e;if(t.delayed())return t.unsetMapFlag(),!1;const a=tt.get(n);if(void 0===a||!t.isComponentVisible(a))return t.unsetMapFlag(),!1;const o=t.originX-52,c=t.originX+52,l=t.originZ+52,h=t.originZ-52;if(ic||rl)return t.unsetMapFlag(),!1;const d=Zl.getLoc(i,r,t.level,s);return d?(t.clearPendingAction(),t.setInteraction(hs.ENGINE,d,cs.APLOCT,{type:d.type,com:n}),t.opcalled=!0,!0):(t.unsetMapFlag(),!1)}},al=class extends Gc{handle(e,t){const{x:i,z:r,loc:s,useObj:n,useSlot:a,useComponent:o}=e;if(t.delayed())return t.unsetMapFlag(),!1;const c=tt.get(o);if(void 0===c||!t.isComponentVisible(c))return t.unsetMapFlag(),!1;const l=t.originX-52,h=t.originX+52,d=t.originZ+52,u=t.originZ-52;if(ih||rd)return t.unsetMapFlag(),!1;const p=t.invListeners.find((e=>e.com===o));if(!p)return t.unsetMapFlag(),!1;const f=t.getInventoryFromListener(p);if(!f||!f.validSlot(a)||!f.hasAt(a,n))return t.unsetMapFlag(),!1;const g=Zl.getLoc(i,r,t.level,s);return g?Tt.get(n).members&&!vt.NODE_MEMBERS?(t.messageGame("To use this item please login to a members' server."),t.unsetMapFlag(),!1):(t.lastUseItem=n,t.lastUseSlot=a,t.clearPendingAction(),t.setInteraction(hs.ENGINE,g,cs.APLOCU),t.opcalled=!0,!0):(t.unsetMapFlag(),!1)}},ol=class extends Gc{handle(e,t){const{nid:i}=e;if(t.delayed())return t.unsetMapFlag(),!1;const r=Zl.getNpc(i);if(!r||r.delayed())return t.unsetMapFlag(),!1;if(!t.buildArea.npcs.has(r.nid))return t.unsetMapFlag(),!1;const s=ft.get(r.type);if(!s.op||!s.op[e.op-1])return t.unsetMapFlag(),!1;let n;return n=1===e.op?cs.APNPC1:2===e.op?cs.APNPC2:3===e.op?cs.APNPC3:4===e.op?cs.APNPC4:cs.APNPC5,t.clearPendingAction(),t.setInteraction(hs.ENGINE,r,n,{type:r.type,com:-1}),t.opcalled=!0,!0}},cl=class extends Gc{handle(e,t){const{nid:i,spellComponent:r}=e;if(t.delayed())return t.unsetMapFlag(),!1;const s=tt.get(r);if(void 0===s||!t.isComponentVisible(s))return t.unsetMapFlag(),!1;const n=Zl.getNpc(i);return!n||n.delayed()?(t.unsetMapFlag(),!1):t.buildArea.npcs.has(n.nid)?(t.clearPendingAction(),t.setInteraction(hs.ENGINE,n,cs.APNPCT,{type:n.type,com:r}),t.opcalled=!0,!0):(t.unsetMapFlag(),!1)}},ll=class extends Gc{handle(e,t){const{nid:i,useObj:r,useSlot:s,useComponent:n}=e;if(t.delayed())return t.unsetMapFlag(),!1;const a=tt.get(n);if(void 0===a||!t.isComponentVisible(a))return t.unsetMapFlag(),!1;const o=t.invListeners.find((e=>e.com===n));if(!o)return t.unsetMapFlag(),!1;const c=t.getInventoryFromListener(o);if(!c||!c.validSlot(s)||!c.hasAt(s,r))return t.unsetMapFlag(),!1;const l=Zl.getNpc(i);return!l||l.delayed()?(t.unsetMapFlag(),!1):t.buildArea.npcs.has(l.nid)?Tt.get(r).members&&!vt.NODE_MEMBERS?(t.messageGame("To use this item please login to a members' server."),t.unsetMapFlag(),!1):(t.lastUseItem=r,t.lastUseSlot=s,t.clearPendingAction(),t.setInteraction(hs.ENGINE,l,cs.APNPCU,{type:l.type,com:-1}),t.opcalled=!0,!0):(t.unsetMapFlag(),!1)}},hl=class extends Gc{handle(e,t){const{x:i,z:r,obj:s}=e;if(t.delayed())return t.unsetMapFlag(),!1;const n=t.originX-52,a=t.originX+52,o=t.originZ+52,c=t.originZ-52;if(ia||ro)return t.unsetMapFlag(),!1;const l=Zl.getObj(i,r,t.level,s,t.pid);if(!l)return t.unsetMapFlag(),!1;const h=Tt.get(l.type);if(1===e.op&&(h.op&&!h.op[0]||!h.op)||4===e.op&&(h.op&&!h.op[3]||!h.op))return t.unsetMapFlag(),!1;let d;return d=1===e.op?cs.APOBJ1:2===e.op?cs.APOBJ2:3===e.op?cs.APOBJ3:4===e.op?cs.APOBJ4:cs.APOBJ5,t.clearPendingAction(),t.setInteraction(hs.ENGINE,l,d),t.opcalled=!0,!0}},dl=class extends Gc{handle(e,t){const{x:i,z:r,obj:s,spellComponent:n}=e;if(t.delayed())return t.unsetMapFlag(),!1;const a=tt.get(n);if(void 0===a||!t.isComponentVisible(a))return t.unsetMapFlag(),!1;const o=t.originX-52,c=t.originX+52,l=t.originZ+52,h=t.originZ-52;if(ic||rl)return t.unsetMapFlag(),!1;const d=Zl.getObj(i,r,t.level,s,t.pid);return d?(t.clearPendingAction(),t.setInteraction(hs.ENGINE,d,cs.APOBJT,{type:d.type,com:n}),t.opcalled=!0,!0):(t.unsetMapFlag(),!1)}},ul=class extends Gc{handle(e,t){const{x:i,z:r,obj:s,useObj:n,useSlot:a,useComponent:o}=e;if(t.delayed())return t.unsetMapFlag(),!1;const c=tt.get(o);if(void 0===c||!t.isComponentVisible(c))return t.unsetMapFlag(),!1;const l=t.originX-52,h=t.originX+52,d=t.originZ+52,u=t.originZ-52;if(ih||rd)return t.unsetMapFlag(),!1;const p=t.invListeners.find((e=>e.com===o));if(!p)return t.unsetMapFlag(),!1;const f=t.getInventoryFromListener(p);if(!f||!f.validSlot(a)||!f.hasAt(a,n))return t.unsetMapFlag(),!1;const g=Zl.getObj(i,r,t.level,s,t.pid);return g?Tt.get(n).members&&!vt.NODE_MEMBERS?(t.messageGame("To use this item please login to a members' server."),t.unsetMapFlag(),!1):(t.lastUseItem=n,t.lastUseSlot=a,t.clearPendingAction(),t.setInteraction(hs.ENGINE,g,cs.APOBJU),t.opcalled=!0,!0):(t.unsetMapFlag(),!1)}},pl=class extends Gc{handle(e,t){const{pid:i}=e;if(t.delayed())return t.unsetMapFlag(),!1;const r=Zl.getPlayer(i);if(!r)return t.unsetMapFlag(),!1;if(!t.buildArea.players.has(r.uid))return t.unsetMapFlag(),!1;let s;return s=1===e.op?cs.APPLAYER1:2===e.op?cs.APPLAYER2:3===e.op?cs.APPLAYER3:cs.APPLAYER4,t.clearPendingAction(),t.setInteraction(hs.ENGINE,r,s),t.opcalled=!0,!0}},fl=class extends Gc{handle(e,t){const{pid:i,spellComponent:r}=e;if(t.delayed())return t.unsetMapFlag(),!1;const s=tt.get(r);if(void 0===s||!t.isComponentVisible(s))return t.unsetMapFlag(),!1;const n=Zl.getPlayer(i);return n&&t.buildArea.players.has(n.uid)?(t.clearPendingAction(),t.setInteraction(hs.ENGINE,n,cs.APPLAYERT,{type:-1,com:r}),t.opcalled=!0,!0):(t.unsetMapFlag(),!1)}},gl=class extends Gc{handle(e,t){const{pid:i,useObj:r,useSlot:s,useComponent:n}=e;if(t.delayed())return t.unsetMapFlag(),!1;const a=tt.get(n);if(void 0===a||!t.isComponentVisible(a))return t.unsetMapFlag(),!1;const o=t.invListeners.find((e=>e.com===n));if(!o)return t.unsetMapFlag(),!1;const c=t.getInventoryFromListener(o);if(!c||!c.validSlot(s)||!c.hasAt(s,r))return t.unsetMapFlag(),!1;const l=Zl.getPlayer(i);return l&&t.buildArea.players.has(l.uid)?Tt.get(r).members&&!vt.NODE_MEMBERS?(t.messageGame("To use this item please login to a members' server."),t.unsetMapFlag(),!1):(t.lastUseSlot=s,t.clearPendingAction(),t.setInteraction(hs.ENGINE,l,cs.APPLAYERU,{type:r,com:-1}),t.opcalled=!0,!0):(t.unsetMapFlag(),!1)}},ml=class extends Gc{handle(e,t){const{maps:i}=e;for(let e=0;e13)return!1;const r=jt.getByTriggerSpecific(cs.TUTORIAL_CLICKSIDE,-1,-1);return r&&t.executeScript(Dl.init(r,t),!0),!0}},Al=class extends xo{constructor(e,t,i){super(),this.path=e,this.ctrlHeld=t,this.opClick=i}category=Fo.USER_EVENT},vl=class extends Mo{constructor(e){super(),this.prot=e}decode(e){const t=e.g1(),i=e.g2(),r=e.g2(),s=this.prot===ko.MOVE_MINIMAPCLICK?14:0,n=e.available-s>>1,a=[{x:i,z:r}];for(let t=1;t<=n&&t<25;t++)a.push({x:i+e.g1b(),z:r+e.g1b()});return new Al(a,t,this.prot===ko.MOVE_OPCLICK)}},Tl=class extends Gc{handle(e,t){const i=e.path[0];if(t.delayed()||e.ctrlHeld<0||e.ctrlHeld>1||ji.distanceToSW(t,{x:i.x,z:i.z})>104)return t.unsetMapFlag(),t.userPath=[],!1;if(vt.NODE_CLIENT_ROUTEFINDER){t.userPath=[];for(let i=0;ie;){const t=ko.byId[this.client.in[e++]];let i=t.length;-1==i?i=this.client.in[e++]:-2==i&&(i=this.client.in[e++]<<8|this.client.in[e++]);const r=new Oe(this.client.in.slice(e,e+i));e+=i;const s=Cl.getDecoder(t);if(s){const e=s.decode(r),i=Cl.getHandler(t);i&&i.handle(e,this)}}this.client?.reset()}encodeOut(){if(this.client){(this.modalTop!==this.lastModalTop||this.modalBottom!==this.lastModalBottom||this.modalSidebar!==this.lastModalSidebar||this.refreshModalClose)&&(this.refreshModalClose&&this.write(new Bs),this.refreshModalClose=!1,this.lastModalTop=this.modalTop,this.lastModalBottom=this.modalBottom,this.lastModalSidebar=this.modalSidebar),this.refreshModal&&(1&~this.modalState||4&~this.modalState?1&~this.modalState?2&~this.modalState?4&~this.modalState||this.write(new Yn(this.modalSidebar)):this.write(new fn(this.modalBottom)):this.write(new Wn(this.modalTop)):this.write(new zn(this.modalTop,this.modalSidebar)),this.refreshModal=!1);for(let e=this.highPriorityOut.head();e;e=this.highPriorityOut.next())this.writeInner(e),e.uncache();for(let e=this.lowPriorityOut.head();e;e=this.lowPriorityOut.next())this.writeInner(e),e.uncache();this.client.flush()}}writeInner(e){const t=this.client;if(!t)return;const i=Co.getEncoder(e);if(!i)return void console.error('No encoder for message',e);const r=i.prot,s=t.out,n=1+(-1===r.length?1:-2===r.length?2:0)+i.test(e);s.pos+n>=s.length&&t.flush();const a=s.pos;s.p1(r.id),-1===r.length?s.pos+=1:-2===r.length&&(s.pos+=2);const o=s.pos;i.encode(s,e),-1===r.length?s.psize1(s.pos-o):-2===r.length&&s.psize2(s.pos-o),t.encryptor&&(s.data[a]=s.data[a]+t.encryptor.nextInt()&255),Zl.cycleStats[Gr.BANDWIDTH_OUT]+=s.pos-a}logout(){this.writeInner(new Sa),this.client?.flush()}terminate(){this.client?.terminate(),this.client=null}playerLog(e,...t){'undefined'==typeof self&&(t.length>0?fs25.appendFileSync(`data/players/${this.username}.log`,`[${(new Date).toISOString().split('T')[0]} ${this.client?.remoteAddress}]: ${e} ${t.join(' ')}\n`):fs25.appendFileSync(`data/players/${this.username}.log`,`[${(new Date).toISOString().split('T')[0]} ${this.client?.remoteAddress}]: ${e}\n`))}updateMap(){const e=this.buildArea.loadedZones,t=this.buildArea.activeZones,i=ji.zone(this.originX)-4<<3,r=ji.zone(this.originX)+5<<3,s=ji.zone(this.originZ)+5<<3,n=ji.zone(this.originZ)-4<<3;(this.xr-1||this.z>s-1)&&(this.write(new yn(ji.zone(this.x),ji.zone(this.z))),this.originX=this.x,this.originZ=this.z,e.clear());for(let e=this.cameraPackets.head();null!==e;e=this.cameraPackets.next()){const t=e.camX-ji.zoneOrigin(this.originX),i=e.camZ-ji.zoneOrigin(this.originZ);e.type===Ts.CAM_MOVETO?this.write(new Pn(t,i,e.height,e.rotationSpeed,e.rotationMultiplier)):e.type===Ts.CAM_LOOKAT&&this.write(new Nn(t,i,e.height,e.rotationSpeed,e.rotationMultiplier)),e.unlink()}this.moveSpeed===Is.INSTANT&&this.jump&&e.clear(),t.clear();const a=ji.zone(this.x),o=ji.zone(this.z),c=ji.zone(this.originX)-6,l=ji.zone(this.originX)+6,h=ji.zone(this.originZ)+6,d=ji.zone(this.originZ)-6;for(let e=a-3;e<=a+3;e++)for(let i=o-3;i<=o+3;i++)el||i>h||i243?t>>=4:i>217?t>>=3:i>192?t>>=2:i>179&&(t>>=1),((255&e)>>2<<10)+(t>>5<<7)+(i>>1)}static rgb15to24(e){return((e>>10&31)<<3<<16)+((e>>5&31)<<3<<8)+((31&e)<<3)}static rgb15toHsl16(t){const i=(t>>10&31)/31,r=(t>>5&31)/31,s=(31&t)/31;return e.rgbToHsl(i,r,s)}static rgb24to15(e){return((e>>16&255)>>3<<10)+((e>>8&255)>>3<<5)+((255&e)>>3)}static rgb24toHsl16(t){const i=(t>>16&255)/256,r=(t>>8&255)/256,s=(255&t)/256;return e.rgbToHsl(i,r,s)}static rgbToHsl(t,i,r){let s=t;in&&(n=i),r>n&&(n=r);let a=0,o=0;const c=(s+n)/2;s!==n&&(c<.5?o=(n-s)/(n+s):c>=.5&&(o=(n-s)/(2-n-s)),t===n?a=(i-r)/(n-s):i===n?a=(r-t)/(n-s)+2:r===n&&(a=(t-i)/(n-s)+4)),a/=6;const l=256*a|0;let h=256*o|0,d=256*c|0;return h<0?h=0:h>255&&(h=255),d<0?d=0:d>255&&(d=255),e.hsl24to16(l,h,d)}static RGB15_HSL16=new Int32Array(32768);static{for(let t=0;t<32768;t++)e.RGB15_HSL16[t]=e.rgb15toHsl16(t)}static reverseHsl(t){const i=[];for(let r=0;r<32768;r++)e.RGB15_HSL16[r]===t&&i.push(r);return i}},Ll={[Kt.FINDUID]:e=>{const t=e.popInt(),i=Zl.getPlayerByUid(t);i?(e.activePlayer=i,e.pointerAdd(Ft[e.intOperand]),e.pushInt(1)):e.pushInt(0)},[Kt.P_FINDUID]:e=>{const t=e.popInt()>>>0,i=Zl.getPlayerByUid(t);e.pointerGet(Ht[e.intOperand])&&e.activePlayer.uid===t?e.pushInt(1):i&&i.canAccess()?(e.activePlayer=i,e.pointerAdd(Ft[e.intOperand]),e.pointerAdd(Ht[e.intOperand]),e.pushInt(1)):e.pushInt(0)},[Kt.STRONGQUEUE]:Vt(Ft,(e=>{const t=Pl(e),i=Br(e.popInt(),Ji),r=e.popInt(),s=jt.get(r);if(!s)throw new Error(`Unable to find queue script: ${r}`);e.activePlayer.enqueueScript(s,3,i,t)})),[Kt.WEAKQUEUE]:Vt(Ft,(e=>{const t=Pl(e),i=Br(e.popInt(),Ji),r=e.popInt(),s=jt.get(r);if(!s)throw new Error(`Unable to find queue script: ${r}`);e.activePlayer.enqueueScript(s,2,i,t)})),[Kt.QUEUE]:Vt(Ft,(e=>{const t=Pl(e),i=Br(e.popInt(),Ji),r=e.popInt(),s=jt.get(r);if(!s)throw new Error(`Unable to find queue script: ${r}`);e.activePlayer.enqueueScript(s,0,i,t)})),[Kt.ANIM]:Vt(Ft,(e=>{const t=e.popInt(),i=e.popInt();e.activePlayer.playAnimation(i,t)})),[Kt.BUFFER_FULL]:Vt(Ft,(e=>{throw new Error('unimplemented')})),[Kt.BUILDAPPEARANCE]:Vt(Ft,(e=>{e.activePlayer.generateAppearance(Br(e.popInt(),Er).id)})),[Kt.CAM_LOOKAT]:Vt(Ft,(e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,nr);e.activePlayer.cameraPackets.addTail(new Ol(Ts.CAM_LOOKAT,n.x,n.z,i,r,s))})),[Kt.CAM_MOVETO]:Vt(Ft,(e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,nr);e.activePlayer.cameraPackets.addTail(new Ol(Ts.CAM_MOVETO,n.x,n.z,i,r,s))})),[Kt.CAM_SHAKE]:Vt(Ft,(e=>{const[t,i,r,s]=e.popInts(4);e.activePlayer.write(new Bn(t,i,r,s))})),[Kt.CAM_RESET]:Vt(Ft,(e=>{e.activePlayer.write(new bn)})),[Kt.COORD]:Vt(Ft,(e=>{const t=e.activePlayer;e.pushInt(ji.packCoord(t.level,t.x,t.z))})),[Kt.DISPLAYNAME]:Vt(Ft,(e=>{e.pushString(e.activePlayer.displayName)})),[Kt.FACESQUARE]:Vt(Ft,(e=>{const t=Br(e.popInt(),nr);e.activePlayer.faceSquare(t.x,t.z)})),[Kt.IF_CLOSE]:Vt(Ft,(e=>{e.activePlayer.closeModal()})),[Kt.LAST_COM]:e=>{e.pushInt(e.activePlayer.lastCom)},[Kt.LAST_INT]:e=>{e.pushInt(e.lastInt)},[Kt.LAST_ITEM]:e=>{if(![cs.OPHELD1,cs.OPHELD2,cs.OPHELD3,cs.OPHELD4,cs.OPHELD5,cs.OPHELDU,cs.OPHELDT,cs.INV_BUTTON1,cs.INV_BUTTON2,cs.INV_BUTTON3,cs.INV_BUTTON4,cs.INV_BUTTON5].includes(e.trigger))throw new Error('is not safe to use in this trigger');e.pushInt(e.activePlayer.lastItem)},[Kt.LAST_SLOT]:e=>{if(![cs.OPHELD1,cs.OPHELD2,cs.OPHELD3,cs.OPHELD4,cs.OPHELD5,cs.OPHELDU,cs.OPHELDT,cs.INV_BUTTON1,cs.INV_BUTTON2,cs.INV_BUTTON3,cs.INV_BUTTON4,cs.INV_BUTTON5,cs.INV_BUTTOND].includes(e.trigger))throw new Error('is not safe to use in this trigger');e.pushInt(e.activePlayer.lastSlot)},[Kt.LAST_USEITEM]:e=>{if(![cs.OPHELDU,cs.APOBJU,cs.APLOCU,cs.APNPCU,cs.APPLAYERU,cs.OPOBJU,cs.OPLOCU,cs.OPNPCU,cs.OPPLAYERU].includes(e.trigger))throw new Error('is not safe to use in this trigger');e.pushInt(e.activePlayer.lastUseItem)},[Kt.LAST_USESLOT]:e=>{if(![cs.OPHELDU,cs.APOBJU,cs.APLOCU,cs.APNPCU,cs.APPLAYERU,cs.OPOBJU,cs.OPLOCU,cs.OPNPCU,cs.OPPLAYERU].includes(e.trigger))throw new Error('is not safe to use in this trigger');e.pushInt(e.activePlayer.lastUseSlot)},[Kt.MES]:Vt(Ft,(e=>{const t=e.popString();e.activePlayer.messageGame(t)})),[Kt.NAME]:Vt(Ft,(e=>{e.pushString(e.activePlayer.username)})),[Kt.P_APRANGE]:Vt(Ht,(e=>{e.activePlayer.apRange=Br(e.popInt(),Ji),e.activePlayer.apRangeCalled=!0})),[Kt.P_ARRIVEDELAY]:Vt(Ht,(e=>{e.activePlayer.lastMovement{e.activePlayer.write(new Fa),e.execution=$t.COUNTDIALOG})),[Kt.P_DELAY]:Vt(Ht,(e=>{e.activePlayer.delay=Zl.currentTick+Br(e.popInt(),Ji)+1,e.execution=$t.SUSPENDED})),[Kt.P_OPHELD]:Vt(Ht,(e=>{throw new Error('unimplemented')})),[Kt.P_OPLOC]:Vt(Ht,(e=>{const t=Br(e.popInt(),Ji)-1;if(t<0||t>=5)throw new Error(`Invalid oploc: ${t+1}`);e.activePlayer.stopAction(),e.activePlayer.setInteraction(hs.SCRIPT,e.activeLoc,cs.APLOC1+t)})),[Kt.P_OPNPC]:Vt(Ht,(e=>{const t=Br(e.popInt(),Ji)-1;if(t<0||t>=5)throw new Error(`Invalid opnpc: ${t+1}`);e.activePlayer.stopAction(),e.activePlayer.setInteraction(hs.SCRIPT,e.activeNpc,cs.APNPC1+t,{type:e.activeNpc.type,com:-1})})),[Kt.P_OPNPCT]:Vt(Ht,(e=>{const t=Br(e.popInt(),Ji);e.activePlayer.stopAction(),e.activePlayer.setInteraction(hs.SCRIPT,e.activeNpc,cs.APNPCT,{type:e.activeNpc.type,com:t})})),[Kt.P_PAUSEBUTTON]:Vt(Ht,(e=>{e.execution=$t.PAUSEBUTTON})),[Kt.P_STOPACTION]:Vt(Ht,(e=>{e.activePlayer.stopAction()})),[Kt.P_CLEARPENDINGACTION]:Vt(Ht,(e=>{e.activePlayer.clearPendingAction()})),[Kt.P_TELEJUMP]:Vt(Ht,(e=>{const t=Br(e.popInt(),nr);e.activePlayer.teleJump(t.x,t.z,t.level)})),[Kt.P_TELEPORT]:Vt(Ht,(e=>{const t=Br(e.popInt(),nr);e.activePlayer.teleport(t.x,t.z,t.level)})),[Kt.P_WALK]:Vt(Ht,(e=>{const t=Br(e.popInt(),nr),i=e.activePlayer;i.queueWaypoints(ti(i.level,i.x,i.z,t.x,t.z,i.width,i.width,i.length)),i.updateMovement(!1)})),[Kt.SAY]:Vt(Ft,(e=>{e.activePlayer.say(e.popString())})),[Kt.SOUND_SYNTH]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3);e.activePlayer.write(new za(t,i,r))})),[Kt.STAFFMODLEVEL]:Vt(Ft,(e=>{e.pushInt(e.activePlayer.staffModLevel)})),[Kt.STAT]:Vt(Ft,(e=>{const t=Br(e.popInt(),lr);e.pushInt(e.activePlayer.levels[t])})),[Kt.STAT_BASE]:Vt(Ft,(e=>{const t=Br(e.popInt(),lr);e.pushInt(e.activePlayer.baseLevels[t])})),[Kt.STAT_ADD]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3);Br(t,lr),Br(i,Ji),Br(r,Ji);const s=e.activePlayer,n=s.levels[t],a=n+(i+n*r/100);s.levels[t]=Math.min(a,255),3===t&&s.levels[3]>=s.baseLevels[3]&&s.resetHeroPoints()})),[Kt.STAT_SUB]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3);Br(t,lr),Br(i,Ji),Br(r,Ji);const s=e.activePlayer,n=s.levels[t],a=n-(i+n*r/100);s.levels[t]=Math.max(a,0)})),[Kt.SPOTANIM_PL]:Vt(Ft,(e=>{const t=Br(e.popInt(),Ji),i=e.popInt(),r=Br(e.popInt(),fr);e.activePlayer.spotanim(r.id,i,t)})),[Kt.STAT_HEAL]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3);Br(t,lr),Br(i,Ji),Br(r,Ji);const s=e.activePlayer,n=s.baseLevels[t],a=s.levels[t],o=a+(i+a*r/100);s.levels[t]=Math.max(Math.min(o,n),a),3===t&&s.levels[3]>=s.baseLevels[3]&&s.resetHeroPoints()})),[Kt.UID]:Vt(Ft,(e=>{e.pushInt(e.activePlayer.uid)})),[Kt.P_LOGOUT]:Vt(Ht,(e=>{e.activePlayer.logoutRequested=!0})),[Kt.IF_SETCOLOUR]:Vt(Ft,(e=>{const[t,i]=e.popInts(2);Br(t,Ji),Br(i,Ji),e.activePlayer.write(new Xn(t,Nl.rgb24to15(i)))})),[Kt.IF_OPENCHAT]:Vt(Ft,(e=>{e.activePlayer.openChat(Br(e.popInt(),Ji))})),[Kt.IF_OPENMAINMODALSIDEOVERLAY]:Vt(Ft,(e=>{const[t,i]=e.popInts(2);Br(t,Ji),Br(i,Ji),e.activePlayer.openMainModalSideOverlay(t,i)})),[Kt.IF_SETHIDE]:Vt(Ft,(e=>{const[t,i]=e.popInts(2);Br(t,Ji),Br(i,Ji),e.activePlayer.write(new ea(t,1===i))})),[Kt.IF_SETOBJECT]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3);Br(t,Ji),Br(i,mr),Br(r,Ji),e.activePlayer.write(new aa(t,i,r))})),[Kt.IF_SETTABACTIVE]:Vt(Ft,(e=>{e.activePlayer.write(new ma(Br(e.popInt(),Ji)))})),[Kt.IF_SETMODEL]:Vt(Ft,(e=>{const[t,i]=e.popInts(2);Br(t,Ji),Br(i,Ji),e.activePlayer.write(new ia(t,i))})),[Kt.IF_SETRECOL]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3);Br(t,Ji),e.activePlayer.write(new ua(t,i,r))})),[Kt.IF_SETTABFLASH]:Vt(Ft,(e=>{e.activePlayer.write(new Ya(Br(e.popInt(),Ji)))})),[Kt.IF_SETANIM]:Vt(Ft,(e=>{const[t,i]=e.popInts(2);Br(t,Ji),-1!==i&&e.activePlayer.write(new $n(t,i))})),[Kt.IF_SETTAB]:Vt(Ft,(e=>{const[t,i]=e.popInts(2);Br(i,Ji),e.activePlayer.setTab(t,i)})),[Kt.IF_OPENMAINMODAL]:Vt(Ft,(e=>{e.activePlayer.openMainModal(Br(e.popInt(),Ji))})),[Kt.IF_OPENCHATSTICKY]:Vt(Ft,(e=>{e.activePlayer.openChatSticky(Br(e.popInt(),Ji))})),[Kt.IF_OPENSIDEOVERLAY]:Vt(Ft,(e=>{e.activePlayer.openSideOverlay(Br(e.popInt(),Ji))})),[Kt.IF_SETPLAYERHEAD]:Vt(Ft,(e=>{e.activePlayer.write(new ca(Br(e.popInt(),Ji)))})),[Kt.IF_SETTEXT]:Vt(Ft,(e=>{const t=e.popString(),i=Br(e.popInt(),Ji);e.activePlayer.write(new fa(i,t))})),[Kt.IF_SETNPCHEAD]:Vt(Ft,(e=>{const[t,i]=e.popInts(2);Br(t,Ji),Br(i,or),e.activePlayer.write(new sa(t,i))})),[Kt.IF_SETPOSITION]:Vt(Ft,(e=>{const[t,i,r]=e.popInts(3);Br(t,Ji),e.activePlayer.write(new ha(t,i,r))})),[Kt.IF_MULTIZONE]:Vt(Ft,(e=>{e.activePlayer.write(new Wa(1===Br(e.popInt(),Ji)))})),[Kt.GIVEXP]:Vt(Ht,(e=>{const[t,i]=e.popInts(2);Br(t,Ji),Br(i,Ji),e.activePlayer.addXp(t,i)})),[Kt.DAMAGE]:e=>{const t=Br(e.popInt(),Ji),i=Br(e.popInt(),pr),r=Br(e.popInt(),Ji),s=Zl.getPlayerByUid(r);s&&s.applyDamage(t,i)},[Kt.IF_SETRESUMEBUTTONS]:Vt(Ft,(e=>{const[t,i,r,s,n]=e.popInts(5);e.activePlayer.resumeButtons=[t,i,r,s,n]})),[Kt.TEXT_GENDER]:Vt(Ft,(e=>{const[t,i]=e.popStrings(2);0==e.activePlayer.gender?e.pushString(t):e.pushString(i)})),[Kt.MIDI_SONG]:e=>{e.activePlayer.playSong(Br(e.popString(),er))},[Kt.MIDI_JINGLE]:e=>{const t=Br(e.popInt(),Ji),i=Br(e.popString(),er);e.activePlayer.playJingle(t,i)},[Kt.SOFTTIMER]:Vt(Ft,(e=>{const t=Pl(e),i=e.popInt(),r=e.popInt(),s=jt.get(r);if(!s)throw new Error(`Unable to find timer script: ${r}`);e.activePlayer.setTimer(1,s,t,i)})),[Kt.CLEARSOFTTIMER]:Vt(Ft,(e=>{e.activePlayer.clearTimer(e.popInt())})),[Kt.SETTIMER]:Vt(Ft,(e=>{const t=Pl(e),i=e.popInt(),r=e.popInt(),s=jt.get(r);if(!s)throw new Error(`Unable to find timer script: ${r}`);e.activePlayer.setTimer(0,s,t,i)})),[Kt.CLEARTIMER]:Vt(Ft,(e=>{e.activePlayer.clearTimer(e.popInt())})),[Kt.HINT_COORD]:e=>{const[t,i,r]=e.popInts(3),s=Br(i,nr);e.activePlayer.hintTile(t,s.x,s.z,r)},[Kt.HINT_STOP]:e=>{e.activePlayer.stopHint()},[Kt.IF_CLOSESTICKY]:e=>{e.activePlayer.closeSticky()},[Kt.P_EXACTMOVE]:Vt(Ht,(e=>{const[t,i,r,s,n]=e.popInts(5),a=Br(t,nr),o=Br(i,nr);e.activePlayer.unsetMapFlag(),e.activePlayer.exactMove(a.x,a.z,o.x,o.z,r,s,n)})),[Kt.BUSY]:e=>{e.pushInt(e.activePlayer.busy()?1:0)},[Kt.BUSY2]:e=>{e.pushInt(e.activePlayer.hasInteraction()||e.activePlayer.hasWaypoints()?1:0)},[Kt.GETQUEUE]:e=>{const t=e.popInt();let i=0;for(let r=e.activePlayer.queue.head();null!==r;r=e.activePlayer.queue.next())r.script.id===t&&i++;for(let r=e.activePlayer.weakQueue.head();null!==r;r=e.activePlayer.weakQueue.next())r.script.id===t&&i++;e.pushInt(i)},[Kt.P_LOCMERGE]:Vt(Ht,(e=>{const[t,i,r,s]=e.popInts(4),n=Br(r,nr),a=Br(s,nr);Zl.mergeLoc(e.activeLoc,e.activePlayer,t,i,n.z,n.x,a.z,a.x)})),[Kt.LAST_LOGIN_INFO]:e=>{const t=e.activePlayer;if(!Sl(t)||null===t.client)return;const i=t.client.remoteAddress;if(null==i)return;const r=new Uint32Array(new Uint8Array(i.split('.').map((e=>parseInt(e)))).reverse().buffer)[0];t.lastLoginInfo(r,0,201,0)},[Kt.BAS_READYANIM]:e=>{e.activePlayer.basReadyAnim=Br(e.popInt(),Tr).id},[Kt.BAS_TURNONSPOT]:e=>{e.activePlayer.basTurnOnSpot=Br(e.popInt(),Tr).id},[Kt.BAS_WALK_F]:e=>{e.activePlayer.basWalkForward=Br(e.popInt(),Tr).id},[Kt.BAS_WALK_B]:e=>{e.activePlayer.basWalkBackward=Br(e.popInt(),Tr).id},[Kt.BAS_WALK_L]:e=>{e.activePlayer.basWalkLeft=Br(e.popInt(),Tr).id},[Kt.BAS_WALK_R]:e=>{e.activePlayer.basWalkRight=Br(e.popInt(),Tr).id},[Kt.BAS_RUNNING]:e=>{const t=e.popInt();e.activePlayer.basRunning=-1!==t?Br(t,Tr).id:-1},[Kt.GENDER]:e=>{e.pushInt(e.activePlayer.gender)},[Kt.HINT_NPC]:e=>{e.activePlayer.hintNpc(Br(e.popInt(),Ji))},[Kt.HINT_PLAYER]:e=>{const t=Br(e.popInt(),Ji),i=Zl.getPlayerByUid(t);i&&e.activePlayer.hintPlayer(i.pid)},[Kt.HEADICONS_GET]:e=>{e.pushInt(e.activePlayer.headicons)},[Kt.HEADICONS_SET]:e=>{e.activePlayer.headicons=Br(e.popInt(),Ji)},[Kt.P_OPOBJ]:Vt(Ht,(e=>{const t=Br(e.popInt(),Ji)-1;if(t<0||t>=5)throw new Error(`Invalid opobj: ${t+1}`);e.activePlayer.stopAction(),e.activePlayer.setInteraction(hs.SCRIPT,e.activeObj,cs.APOBJ1+t)})),[Kt.P_OPPLAYER]:Vt(Ht,(e=>{const t=Br(e.popInt(),Ji)-1;if(t<0||t>=5)throw new Error(`Invalid opplayer: ${t+1}`);const i=e._activePlayer2;i&&(e.activePlayer.stopAction(),e.activePlayer.setInteraction(hs.SCRIPT,i,cs.APPLAYER1+t))})),[Kt.ALLOWDESIGN]:e=>{e.activePlayer.allowDesign=1===Br(e.popInt(),Ji)},[Kt.LAST_TARGETSLOT]:e=>{if(![cs.INV_BUTTOND].includes(e.trigger))throw new Error('is not safe to use in this trigger');e.pushInt(e.activePlayer.lastTargetSlot)},[Kt.WALKTRIGGER]:e=>{e.activePlayer.walktrigger=e.popInt()},[Kt.GETWALKTRIGGER]:e=>{e.pushInt(e.activePlayer.walktrigger)},[Kt.CLEARQUEUE]:e=>{const t=e.popInt();for(let i=e.activePlayer.queue.head();null!==i;i=e.activePlayer.queue.next())i.script.id===t&&i.unlink();for(let i=e.activePlayer.weakQueue.head();null!==i;i=e.activePlayer.weakQueue.next())i.script.id===t&&i.unlink()},[Kt.HEALENERGY]:e=>{const t=Br(e.popInt(),Ji),i=e.activePlayer;i.runenergy=Math.min(Math.max(i.runenergy+t,0),1e4)},[Kt.AFK_EVENT]:e=>{e.pushInt(e.activePlayer.afkEventReady?1:0),e.activePlayer.afkEventReady=!1},[Kt.LOWMEMORY]:e=>{e.pushInt(e.activePlayer.lowMemory?1:0)},[Kt.SETIDKIT]:e=>{const[t,i]=e.popInts(2),r=Br(t,Ar);let s=r.type;1===e.activePlayer.gender&&(s-=7),e.activePlayer.body[s]=r.id;let n=r.type;1===e.activePlayer.gender&&(n-=7);let a=-1;0===n||1===n?a=0:2===n||3===n?a=1:4===n||(5===n?a=2:6===n&&(a=3)),-1!==a&&(e.activePlayer.colors[a]=i)},[Kt.SETGENDER]:e=>{const t=Br(e.popInt(),br);for(let i=0;i<7;i++){e.activePlayer.body[i]=-1;for(let r=0;r{const t=Br(e.popInt(),Rr);e.activePlayer.colors[4]=t},[Kt.P_OPPLAYERT]:Vt(Ht,(e=>{const t=Br(e.popInt(),Ji),i=e._activePlayer2;i&&(e.activePlayer.stopAction(),e.activePlayer.setInteraction(hs.SCRIPT,i,cs.APPLAYERT,{type:-1,com:t}))})),[Kt.FINDHERO]:Vt(Ft,(e=>{const t=e.activePlayer.findHero();if(-1===t)return void e.pushInt(0);const i=Zl.getPlayerByUid(t);i?(e._activePlayer2=i,e.pointerAdd(Gt.ActivePlayer2),e.pushInt(1)):e.pushInt(0)})),[Kt.BOTH_HEROPOINTS]:Vt(Ft,(e=>{const t=Br(e.popInt(),Ji),i=1===e.intOperand,r=i?e._activePlayer2:e._activePlayer,s=i?e._activePlayer:e._activePlayer2;if(!r||!s)throw new Error('player is null');s.addHero(r.uid,t)})),[Kt.P_ANIMPROTECT]:Vt(Ht,(e=>{e.activePlayer.animProtect=Br(e.popInt(),Ji)})),[Kt.RUNENERGY]:Vt(Ft,(e=>{const t=e.activePlayer;e.pushInt(t.runenergy)})),[Kt.WEIGHT]:Vt(Ht,(e=>{e.pushInt(e.activePlayer.runweight)})),[Kt.LAST_COORD]:Vt(Ft,(e=>{e.pushInt(ji.packCoord(e.activePlayer.level,e.activePlayer.lastX,e.activePlayer.lastZ))}))};function Pl(e){const t=e.popString(),i=[];for(let r=t.length-1;r>=0;r--){const s=t.charAt(r);i[r]='s'===s?e.popString():e.popInt()}return i}var wl=Ll,bl={[Kt.MAP_CLOCK]:e=>{e.pushInt(Zl.currentTick)},[Kt.MAP_MEMBERS]:e=>{e.pushInt(vt.NODE_MEMBERS?1:0)},[Kt.MAP_PLAYERCOUNT]:e=>{const[t,i]=e.popInts(2),r=Br(t,nr),s=Br(i,nr);let n=0;for(let e=Math.floor(r.x/8);e<=Math.ceil(s.x/8);e++)for(let t=Math.floor(r.z/8);t<=Math.ceil(s.z/8);t++)for(const i of Zl.getZone(e<<3,t<<3,r.level).getAllPlayersSafe())i.x>=r.x&&i.x<=s.x&&i.z>=r.z&&i.z<=s.z&&n++;e.pushInt(n)},[Kt.HUNTALL]:e=>{const[t,i,r]=e.popInts(3),s=Br(t,nr);Br(i,Ji);const n=Br(r,vr);e.huntIterator=new ts(Zl.currentTick,s.level,s.x,s.z,i,n,-1,-1,je.PLAYER)},[Kt.HUNTNEXT]:e=>{const t=e.huntIterator?.next();if(t&&!t.done){if(!(t.value instanceof Do))throw new Error('[ServerOps] huntnext command must result instance of Player.');e.activePlayer=t.value,e.pointerAdd(Ft[e.intOperand]),e.pushInt(1)}else e.pushInt(0)},[Kt.NPC_HUNTALL]:e=>{const[t,i,r]=e.popInts(3),s=Br(t,nr);Br(i,Ji);const n=Br(r,vr);e.huntIterator=new ts(Zl.currentTick,s.level,s.x,s.z,i,n,-1,-1,je.NPC)},[Kt.NPC_HUNTNEXT]:e=>{const t=e.huntIterator?.next();if(t&&!t.done){if(!(t.value instanceof kl))throw new Error('[ServerOps] npc_huntnext command must result instance of Npc.');e.activeNpc=t.value,e.pointerAdd(kt[e.intOperand]),e.pushInt(1)}else e.pushInt(0)},[Kt.INZONE]:e=>{const[t,i,r]=e.popInts(3),s=Br(t,nr),n=Br(i,nr),a=Br(r,nr);a.xn.x||a.leveln.level||a.zn.z?e.pushInt(0):e.pushInt(1)},[Kt.LINEOFWALK]:e=>{const[t,i]=e.popInts(2),r=Br(t,nr),s=Br(i,nr);r.level===s.level?e.pushInt(gi(r.level,r.x,r.z,s.x,s.z,1,1,1,1)?1:0):e.pushInt(0)},[Kt.STAT_RANDOM]:e=>{const[t,i,r]=e.popInts(3),s=Math.floor(i*(99-t)/98)+Math.floor(r*(t-1)/98)+1,n=Math.floor(256*Math.random());e.pushInt(s>n?1:0)},[Kt.SPOTANIM_MAP]:e=>{const[t,i,r,s]=e.popInts(4),n=Br(i,nr),a=Br(t,fr);Zl.animMap(n.level,n.x,n.z,a.id,r,s)},[Kt.DISTANCE]:e=>{const[t,i]=e.popInts(2),r=Br(t,nr),s=Br(i,nr);e.pushInt(ji.distanceToSW(r,s))},[Kt.MOVECOORD]:e=>{const[t,i,r,s]=e.popInts(4),n=Br(t,nr);e.pushInt(ji.packCoord(n.level+r,n.x+i,n.z+s))},[Kt.SEQLENGTH]:e=>{e.pushInt(Br(e.popInt(),Tr).duration)},[Kt.SPLIT_INIT]:e=>{const[t,i,r]=e.popInts(3);let s=e.popString();const n=Br(r,Or);if(s.startsWith('')){const t=s.substring(3,s.indexOf('>'));e.splitMesanim=ot.getId(t),s=s.substring(s.indexOf('>')+1)}else e.splitMesanim=-1;e.splitPages=[];const a=n.split(s,t);for(;a.length>0;)e.splitPages.push(a.splice(0,i))},[Kt.SPLIT_GET]:e=>{const[t,i]=e.popInts(2);e.pushString(e.splitPages[t][i])},[Kt.SPLIT_PAGECOUNT]:e=>{e.pushInt(e.splitPages.length)},[Kt.SPLIT_LINECOUNT]:e=>{const t=e.popInt();e.pushInt(e.splitPages[t].length)},[Kt.SPLIT_GETANIM]:e=>{const t=e.popInt();-1!==e.splitMesanim?e.pushInt(Br(e.splitMesanim,Nr).len[e.splitPages[t].length-1]):e.pushInt(-1)},[Kt.STRUCT_PARAM]:e=>{const[t,i]=e.popInts(2),r=Br(i,ar),s=Br(t,Lr);r.isString()?e.pushString(rt(r.id,s,r.defaultString)):e.pushInt(st(r.id,s,r.defaultInt))},[Kt.COORDX]:e=>{e.pushInt(Br(e.popInt(),nr).x)},[Kt.COORDY]:e=>{e.pushInt(Br(e.popInt(),nr).level)},[Kt.COORDZ]:e=>{e.pushInt(Br(e.popInt(),nr).z)},[Kt.PLAYERCOUNT]:e=>{e.pushInt(Zl.getTotalPlayers())},[Kt.MAP_BLOCKED]:e=>{const t=Br(e.popInt(),nr);e.pushInt(ui(t.x,t.z,t.level,Ri.WALK_BLOCKED)?1:0)},[Kt.MAP_INDOORS]:e=>{const t=Br(e.popInt(),nr);e.pushInt(ui(t.x,t.z,t.level,Ri.ROOF)?1:0)},[Kt.LINEOFSIGHT]:e=>{const[t,i]=e.popInts(2),r=Br(t,nr),s=Br(i,nr);r.level===s.level?e.pushInt(fi(r.level,r.x,r.z,s.x,s.z,1,1,1,1)?1:0):e.pushInt(0)},[Kt.WORLD_DELAY]:e=>{e.execution=$t.WORLD_SUSPENDED},[Kt.PROJANIM_PL]:e=>{const[t,i,r,s,n,a,o,c,l]=e.popInts(9),h=Br(t,nr),d=Br(r,fr),u=Zl.getPlayerByUid(i);if(!u)throw new Error(`attempted to use invalid player uid: ${i}`);Zl.mapProjAnim(h.level,h.x,h.z,u.x,u.z,-u.pid-1,d.id,s+100,n+100,a,o,c,l)},[Kt.PROJANIM_NPC]:e=>{const[t,i,r,s,n,a,o,c,l]=e.popInts(9),h=Br(t,nr),d=Br(r,fr),u=65535&i,p=Zl.getNpc(u);if(!p)throw new Error(`attempted to use invalid npc uid: ${i}`);Zl.mapProjAnim(h.level,h.x,h.z,p.x,p.z,p.nid+1,d.id,s+100,n+100,a,o,c,l)},[Kt.PROJANIM_MAP]:e=>{const[t,i,r,s,n,a,o,c,l]=e.popInts(9),h=Br(r,fr),d=Br(t,nr),u=Br(i,nr);Zl.mapProjAnim(d.level,d.x,d.z,u.x,u.z,0,h.id,s+100,n,a,o,c,l)},[Kt.MAP_LOCADDUNSAFE]:e=>{const t=Br(e.popInt(),nr);for(const i of Zl.getZone(t.x,t.z,t.level).getAllLocsUnsafe()){if(1!==Br(i.type,tr).active)continue;const r=_i(i.shape);if(i.checkLifeCycle(Zl.currentTick)||r!==ki.WALL)if(r===ki.WALL){if(i.x===t.x&&i.z===t.z)return void e.pushInt(1)}else if(r===ki.GROUND){const r=i.angle===Ui.NORTH||i.angle===Ui.SOUTH?i.length:i.width,s=i.angle===Ui.NORTH||i.angle===Ui.SOUTH?i.width:i.length;for(let n=0;n{e.pushInt(Zl.getTotalNpcs())},[Kt.ZONECOUNT]:e=>{e.pushInt(Zl.getTotalZones())},[Kt.LOCCOUNT]:e=>{e.pushInt(Zl.getTotalLocs())},[Kt.OBJCOUNT]:e=>{e.pushInt(Zl.getTotalObjs())}},Rl=bl,Bl={[Kt.APPEND_NUM]:e=>{const t=e.popString(),i=e.popInt();e.pushString(t+i)},[Kt.APPEND]:e=>{const[t,i]=e.popStrings(2);e.pushString(t+i)},[Kt.APPEND_SIGNNUM]:e=>{const t=e.popString(),i=e.popInt();i>=0?e.pushString(`${t}+${i}`):e.pushString(t+i)},[Kt.LOWERCASE]:e=>{e.pushString(e.popString().toLowerCase())},[Kt.TOSTRING]:e=>{e.pushString(e.popInt().toString())},[Kt.COMPARE]:e=>{const[t,i]=e.popStrings(2);e.pushInt(function(e,t){const i=e.length,r=t.length,s=Math.min(i,r);let n=0;for(;n{const t=e.popInt(),[i,r]=e.popStrings(2);e.pushString(1===t?i:r)},[Kt.APPEND_CHAR]:e=>{const t=e.popString(),i=e.popInt();e.pushString(t+String.fromCharCode(i))},[Kt.STRING_LENGTH]:e=>{e.pushInt(e.popString().length)},[Kt.SUBSTRING]:e=>{const t=e.popString(),[i,r]=e.popInts(2);e.pushString(t.substring(i,r))},[Kt.STRING_INDEXOF_CHAR]:e=>{const t=e.popString(),i=String.fromCharCode(e.popInt());e.pushInt(t.indexOf(i))},[Kt.STRING_INDEXOF_STRING]:e=>{const t=e.popString(),i=e.popString();e.pushInt(t.indexOf(i))}};var Ul=Bl,Dl=class e{static HANDLERS={...Fr,...Rl,...wl,...us,...ns,...Es,...ps,...as,..._s,...Zr,...zr,...Ul,...ys,...Hr,...Wr};static init(e,t=null,i=null,r=[]){const s=new $t(e,r);return s.self=t,t instanceof Do?(s._activePlayer=t,s.pointerAdd(Gt.ActivePlayer)):t instanceof kl?(s._activeNpc=t,s.pointerAdd(Gt.ActiveNpc)):t instanceof ss?(s._activeLoc=t,s.pointerAdd(Gt.ActiveLoc)):t instanceof $r&&(s._activeObj=t,s.pointerAdd(Gt.ActiveObj)),i instanceof Do?t instanceof Do?(s._activePlayer2=i,s.pointerAdd(Gt.ActivePlayer2)):(s._activePlayer=i,s.pointerAdd(Gt.ActivePlayer)):i instanceof kl?t instanceof kl?(s._activeNpc2=i,s.pointerAdd(Gt.ActiveNpc2)):(s._activeNpc=i,s.pointerAdd(Gt.ActiveNpc)):i instanceof ss?t instanceof ss?(s._activeLoc2=i,s.pointerAdd(Gt.ActiveLoc2)):(s._activeLoc=i,s.pointerAdd(Gt.ActiveLoc)):i instanceof $r&&(t instanceof $r?(s._activeObj2=i,s.pointerAdd(Gt.ActiveObj2)):(s._activeObj=i,s.pointerAdd(Gt.ActiveObj))),s}static execute(t,i=!1,r=!1){if(!t||!t.script||!t.script.info)return $t.ABORTED;try{i&&t.reset(),t.execution!==$t.RUNNING&&t.executionHistory.push(t.execution),t.execution=$t.RUNNING;const s=1e3*performance.now();for(;t.execution===$t.RUNNING;){if(t.pc>=t.script.opcodes.length||t.pc<-1)throw new Error('Invalid program counter: '+t.pc+', max expected: '+t.script.opcodes.length);if(!r&&t.opcount>5e5)throw new Error('Too many instructions');t.opcount++,e.executeInner(t,t.script.opcodes[++t.pc])}const n=1e3*performance.now()-s|0;if(vt.NODE_DEBUG_PROFILE&&n>1e3){const e=`Warning [cpu time]: Script: ${t.script.info.scriptName}, time: ${n}us, opcount: ${t.opcount}`;t.self instanceof Do?t.self.wrappedMessageGame(e):console.warn(e)}}catch(e){if(t.pc>=0&&t.pc>16&1:i<=Kt.POP_ARRAY_INT&&(r=0),e.message=Kt[i].toLowerCase()+' '+e.message,r&&(e.message='.'+e.message)}if(t.self instanceof Do){t.self.wrappedMessageGame(`script error: ${e.message}`),t.self.wrappedMessageGame(`file: ${path3.basename(t.script.info.sourceFilePath)}`),t.self.wrappedMessageGame(''),t.self.wrappedMessageGame('stack backtrace:'),t.self.wrappedMessageGame(` 1: ${t.script.name} - ${t.script.fileName}:${t.script.lineNumber(t.pc)}`);let i=1;for(let e=t.fp;e>0;e--){const r=t.frames[e];r&&(i++,t.self.wrappedMessageGame(` ${i}: ${r.script.name} - ${r.script.fileName}:${r.script.lineNumber(r.pc)}`))}for(let e=t.debugFp;e>=0;e--){const r=t.debugFrames[e];r&&(i++,t.self.wrappedMessageGame(` ${i}: ${r.script.name} - ${r.script.fileName}:${r.script.lineNumber(r.pc)}`))}}console.error(`script error: ${e.message}`),console.error(`file: ${path3.basename(t.script.info.sourceFilePath)}`),console.error(''),console.error('stack backtrace:'),console.error(` 1: ${t.script.name} - ${t.script.fileName}:${t.script.lineNumber(t.pc)}`);let i=1;for(let e=t.fp;e>0;e--){const r=t.frames[e];r&&(i++,console.error(` ${i}: ${r.script.name} - ${r.script.fileName}:${r.script.lineNumber(r.pc)}`))}for(let e=t.debugFp;e>=0;e--){const r=t.debugFrames[e];r&&(i++,console.error(` ${i}: ${r.script.name} - ${r.script.fileName}:${r.script.lineNumber(r.pc)}`))}t.execution=$t.ABORTED}return t.execution}static executeInner(t,i){const r=e.HANDLERS[i];if(!r)throw new Error(`Unknown opcode ${i}`);r(t)}},kl=class e extends Ns{static ANIM=2;static FACE_ENTITY=4;static SAY=8;static DAMAGE=16;static CHANGE_TYPE=32;static SPOTANIM=64;static FACE_COORD=128;nid;type;uid;origType;startX;startZ;levels=new Uint8Array(6);baseLevels=new Uint8Array(6);vars;varsString;activeScript=null;delay=0;queue=new Ce;timerInterval=0;timerClock=0;huntMode=-1;nextHuntTick=-1;huntrange=5;nextPatrolTick=-1;nextPatrolPoint=0;delayedPatrol=!1;heroPoints=new Array(16);constructor(t,i,r,s,n,a,o,c,l,h){super(t,i,r,s,n,a,l,h,Os.NAIVE,e.FACE_COORD,e.FACE_ENTITY),this.nid=o,this.type=c,this.uid=c<<16|o,this.startX=this.x,this.startZ=this.z,this.origType=c;const d=ft.get(c);for(let e=0;et&&t.uid===e));if(-1!==i)return void(this.heroPoints[i].points+=t);const r=this.heroPoints.findIndex((e=>e&&-1===e.uid));-1===r||(this.heroPoints[r]={uid:e,points:t})}findHero(){return this.heroPoints.sort(((e,t)=>t.points-e.points)),this.heroPoints[0]?.uid??-1}getVar(e){const t=Ot.get(e);return t.type===Pe.STRING?this.varsString[t.id]:this.vars[t.id]}setVar(e,t){const i=Ot.get(e);i.type===Pe.STRING&&'string'==typeof t?this.varsString[i.id]=t:'number'==typeof t&&(this.vars[i.id]=t)}resetEntity(e){if(e){this.type=this.origType,this.uid=this.type<<16|this.nid,this.faceX=-1,this.faceZ=-1,this.orientationX=-1,this.orientationZ=-1;for(let e=0;et.maxrange&&e>t.maxrange)return!1}if(this.targetOp>=Xe.OPPLAYER1&&this.targetOp<=Xe.OPPLAYER5){const e=Math.abs(this.target.x-this.startX),i=Math.abs(this.target.z-this.startZ);if(Math.max(e,i)>t.maxrange+1)return this.defaultMode(),!1;if(e===t.maxrange+1&&i===t.maxrange+1)return this.defaultMode(),!1}else if(this.targetOp>=Xe.APPLAYER1&&this.targetOp<=Xe.APPLAYER5&&ji.distanceToSW(this.target,{x:this.startX,z:this.startZ})>t.maxrange+t.attackrange)return this.defaultMode(),!1}if(e&&this.target instanceof Ns&&!this.interacted&&-1===this.walktrigger&&this.pathToPathingTarget(),-1!==this.walktrigger){const e=ft.get(this.type),t=jt.getByTrigger(cs.AI_QUEUE1+this.walktrigger,e.id,e.category);if(this.walktrigger=-1,t){const e=Dl.init(t,this,null,[this.walktriggerArg]);Dl.execute(e)}}return this.moveSpeed!==Is.INSTANT&&(this.moveSpeed=this.defaultMoveSpeed()),super.processMovement()}blockWalkFlag(){return this.moveRestrict===dt.NORMAL?Ri.NPC:this.moveRestrict===dt.BLOCKED?Ri.OPEN:this.moveRestrict===dt.BLOCKED_NORMAL||this.moveRestrict===dt.INDOORS||this.moveRestrict===dt.OUTDOORS?Ri.NPC:this.moveRestrict===dt.NOMOVE?Ri.NULL:this.moveRestrict===dt.PASSTHRU?Ri.OPEN:Ri.NULL}defaultMoveSpeed(){return Is.WALK}delayed(){return this.delay>Zl.currentTick}setTimer(e){this.timerInterval=e,this.timerClock=0}executeScript(e){if(!e)return;const t=Dl.execute(e);t!==$t.FINISHED&&t!==$t.ABORTED?t===$t.WORLD_SUSPENDED?Zl.enqueueScript(e,e.popInt()):t===$t.NPC_SUSPENDED?e.activeNpc.activeScript=e:e.activePlayer.activeScript=e:e===this.activeScript&&(this.activeScript=null),e.pointerGet(Gt.ProtectedActivePlayer)&&e._activePlayer&&(e._activePlayer.protect=!1,e.pointerRemove(Gt.ProtectedActivePlayer)),e.pointerGet(Gt.ProtectedActivePlayer2)&&e._activePlayer2&&(e._activePlayer2.protect=!1,e.pointerRemove(Gt.ProtectedActivePlayer2))}processTimers(){if(0!==this.timerInterval&&++this.timerClock>=this.timerInterval){this.timerClock=0;const e=ft.get(this.type),t=jt.getByTrigger(cs.AI_TIMER,e.id,e.category);t&&this.executeScript(Dl.init(t,this))}}processQueue(){for(let e=this.queue.head();null!==e;e=this.queue.next())if(this.delayed()||e.delay--,!this.delayed()&&e.delay<=0){const t=Dl.init(e.script,this,null,e.args);t.lastInt=e.lastInt,this.executeScript(t),e.unlink()}}enqueueScript(e,t=0,i=0){const r=new As(0,e,[],t);r.lastInt=i,this.queue.addTail(r)}randomWalk(e){const t=Math.round(Math.random()*(2*e)-e),i=Math.round(Math.random()*(2*e)-e),r=this.startX+t,s=this.startZ+i;r===this.x&&s===this.z||this.queueWaypoint(r,s)}processNpcModes(){this.targetOp===Xe.NULL?this.defaultMode():this.targetOp===Xe.NONE?this.noMode():this.targetOp===Xe.WANDER?this.wanderMode():this.targetOp===Xe.PATROL?this.patrolMode():this.targetOp===Xe.PLAYERESCAPE?this.playerEscapeMode():this.targetOp===Xe.PLAYERFOLLOW?this.playerFollowMode():this.targetOp===Xe.PLAYERFACE?this.playerFaceMode():this.targetOp===Xe.PLAYERFACECLOSE?this.playerFaceCloseMode():this.aiMode()}noMode(){this.clearInteraction(),this.updateMovement(!1),this.targetOp=Xe.NONE}defaultMode(){this.clearInteraction(),this.updateMovement(!1);const e=ft.get(this.type);this.targetOp=e.defaultmode}wanderMode(){const e=ft.get(this.type);e.moverestrict!==dt.NOMOVE&&Math.random()<.125&&this.randomWalk(e.wanderrange),this.updateMovement(!1)}patrolMode(){const e=ft.get(this.type),t=e.patrolCoord,i=e.patrolDelay[this.nextPatrolPoint];let r=ji.unpackCoord(t[this.nextPatrolPoint]);this.updateMovement(!1),this.hasWaypoints()||this.target||this.queueWaypoint(r.x,r.z),(this.x!==r.x||this.z!==r.z)&&Zl.currentTick>=this.nextPatrolTick&&this.teleport(r.x,r.z,r.level),this.x!==r.x||this.z!==r.z||this.delayedPatrol||(this.nextPatrolTick=Zl.currentTick+i,this.delayedPatrol=!0),this.nextPatrolTick>Zl.currentTick||(this.nextPatrolPoint=(this.nextPatrolPoint+1)%t.length,this.nextPatrolTick=Zl.currentTick+30,this.delayedPatrol=!1,r=ji.unpackCoord(t[this.nextPatrolPoint]),this.queueWaypoint(r.x,r.z))}playerEscapeMode(){if(!this.target)return void this.defaultMode();if(!(this.target instanceof Do))throw new Error('[Npc] Target must be a Player for playerescape mode.');if(null===Zl.getPlayerByUid(this.target.uid))return void this.defaultMode();if(ji.distanceToSW(this,this.target)>25)return void this.defaultMode();let e,t;this.target.x>=this.x&&this.target.z>=this.z?(e=Wi,t=Ri.WALL_SOUTH|Ri.WALL_WEST):this.target.x>=this.x&&this.target.z=this.z?(e=zi,t=Ri.WALL_SOUTH|Ri.WALL_EAST):(e=Hi,t=Ri.WALL_NORTH|Ri.WALL_EAST);const i=ji.moveX(this.x,e),r=ji.moveZ(this.z,e);if(ui(i,r,this.level,t))return void this.defaultMode();const s={x:i,z:r,level:this.level};if(ji.distanceToSW(s,{x:this.startX,z:this.startZ})e.maxrange?this.defaultMode():this.updateMovement(!1)}playerFaceCloseMode(){if(this.target){if(!(this.target instanceof Do))throw new Error('[Npc] Target must be a Player for playerfaceclose mode.');null!=Zl.getPlayerByUid(this.target.uid)&&this.level===this.target.level?ji.distanceTo(this,this.target)>1?this.defaultMode():this.updateMovement(!1):this.defaultMode()}else this.defaultMode()}aiMode(){if(this.delayed()||!this.target)return void this.defaultMode();if(this.target.level!==this.level)return void this.defaultMode();if(this.target instanceof e&&(void 0===Zl.getNpc(this.target.nid)||this.target.delayed()))return void this.defaultMode();if(this.target instanceof e&&-1!==this.targetSubject.type&&null===Zl.getNpcByUid(this.targetSubject.type<<16|this.target.nid))return void this.defaultMode();if(this.target instanceof $r&&null===Zl.getObj(this.target.x,this.target.z,this.level,this.target.type,-1))return void this.defaultMode();if(this.target instanceof ss&&null===Zl.getLoc(this.target.x,this.target.z,this.level,this.target.type))return void this.defaultMode();if(this.target instanceof Do&&null===Zl.getPlayerByUid(this.target.uid))return void this.defaultMode();const t=ft.get(this.type),i=this.targetOp>=Xe.APNPC1&&this.targetOp<=Xe.APNPC5||this.targetOp>=Xe.APPLAYER1&&this.targetOp<=Xe.APPLAYER5||this.targetOp>=Xe.APLOC1&&this.targetOp<=Xe.APLOC5||this.targetOp>=Xe.APOBJ1&&this.targetOp<=Xe.APOBJ5,r=!i,s=this.getTrigger();s&&r&&this.inOperableDistance(this.target)&&this.target instanceof Ns||s&&i&&this.inApproachDistance(t.attackrange,this.target)?(this.executeScript(Dl.init(s,this,this.target)),this.interacted=!0,this.clearWaypoints()):this.inOperableDistance(this.target)&&this.target instanceof Ns&&(this.target=null,this.interacted=!0,this.clearWaypoints());const n=this.updateMovement();n&&(this.alreadyFacedEntity=!1),this.target&&!this.interacted&&(this.interacted=!1,s&&r&&this.inOperableDistance(this.target)&&(this.target instanceof Ns||!n)||s&&i&&this.inApproachDistance(t.attackrange,this.target)?(this.executeScript(Dl.init(s,this,this.target)),this.interacted=!0,this.clearWaypoints()):this.inOperableDistance(this.target)&&(this.target instanceof Ns||!n)&&(this.target=null,this.interacted=!0,this.clearWaypoints()))}getTrigger(){const e=this.getTriggerForMode(this.targetOp);return e?jt.getByTrigger(e,this.type,-1)??null:null}getTriggerForMode(e){return e===Xe.OPPLAYER1?cs.AI_OPPLAYER1:e===Xe.OPPLAYER2?cs.AI_OPPLAYER2:e===Xe.OPPLAYER3?cs.AI_OPPLAYER3:e===Xe.OPPLAYER4?cs.AI_OPPLAYER4:e===Xe.OPPLAYER5?cs.AI_OPPLAYER5:e===Xe.APPLAYER1?cs.AI_APPLAYER1:e===Xe.APPLAYER2?cs.AI_APPLAYER2:e===Xe.APPLAYER3?cs.AI_APPLAYER3:e===Xe.APPLAYER4?cs.AI_APPLAYER4:e===Xe.APPLAYER5?cs.AI_APPLAYER5:e===Xe.OPLOC1?cs.AI_OPLOC1:e===Xe.OPLOC2?cs.AI_OPLOC2:e===Xe.OPLOC3?cs.AI_OPLOC3:e===Xe.OPLOC4?cs.AI_OPLOC4:e===Xe.OPLOC5?cs.AI_OPLOC5:e===Xe.APLOC1?cs.AI_APLOC1:e===Xe.APLOC2?cs.AI_APLOC2:e===Xe.APLOC3?cs.AI_APLOC3:e===Xe.APLOC4?cs.AI_APLOC4:e===Xe.APLOC5?cs.AI_APLOC5:e===Xe.OPOBJ1?cs.AI_OPOBJ1:e===Xe.OPOBJ2?cs.AI_OPOBJ2:e===Xe.OPOBJ3?cs.AI_OPOBJ3:e===Xe.OPOBJ4?cs.AI_OPOBJ4:e===Xe.OPOBJ5?cs.AI_OPOBJ5:e===Xe.APOBJ1?cs.AI_APOBJ1:e===Xe.APOBJ2?cs.AI_APOBJ2:e===Xe.APOBJ3?cs.AI_APOBJ3:e===Xe.APOBJ4?cs.AI_APOBJ4:e===Xe.APOBJ5?cs.AI_APOBJ5:e===Xe.OPNPC1?cs.AI_OPNPC1:e===Xe.OPNPC2?cs.AI_OPNPC2:e===Xe.OPNPC3?cs.AI_OPNPC3:e===Xe.OPNPC4?cs.AI_OPNPC4:e===Xe.OPNPC5?cs.AI_OPNPC5:e===Xe.APNPC1?cs.AI_APNPC1:e===Xe.APNPC2?cs.AI_APNPC2:e===Xe.APNPC3?cs.AI_APNPC3:e===Xe.APNPC4?cs.AI_APNPC4:e===Xe.APNPC5?cs.AI_APNPC5:e===Xe.QUEUE1?cs.AI_QUEUE1:e===Xe.QUEUE2?cs.AI_QUEUE2:e===Xe.QUEUE3?cs.AI_QUEUE3:e===Xe.QUEUE4?cs.AI_QUEUE4:e===Xe.QUEUE5?cs.AI_QUEUE5:e===Xe.QUEUE6?cs.AI_QUEUE6:e===Xe.QUEUE7?cs.AI_QUEUE7:e===Xe.QUEUE8?cs.AI_QUEUE8:e===Xe.QUEUE9?cs.AI_QUEUE9:e===Xe.QUEUE10?cs.AI_QUEUE10:e===Xe.QUEUE11?cs.AI_QUEUE11:e===Xe.QUEUE12?cs.AI_QUEUE12:e===Xe.QUEUE13?cs.AI_QUEUE13:e===Xe.QUEUE14?cs.AI_QUEUE14:e===Xe.QUEUE15?cs.AI_QUEUE15:e===Xe.QUEUE16?cs.AI_QUEUE16:e===Xe.QUEUE17?cs.AI_QUEUE17:e===Xe.QUEUE18?cs.AI_QUEUE18:e===Xe.QUEUE19?cs.AI_QUEUE19:e===Xe.QUEUE20?cs.AI_QUEUE20:null}huntAll(){if(this.nextHuntTick>Zl.currentTick)return;const e=Je.get(this.huntMode);if(e.type===je.OFF)return;if(e.nobodyNear===qe.PAUSEHUNT&&!Zl.getZoneGrid(this.level).isFlagged(ji.zone(this.x),ji.zone(this.z),5))return;if(!e.findKeepHunting&&null!==this.target)return;let t;if(t=e.type===je.PLAYER?this.huntPlayers(e):e.type===je.NPC?this.huntNpcs(e):e.type===je.OBJ?this.huntObjs(e):this.huntLocs(e),t.length>0){const i=t[Math.floor(Math.random()*t.length)];this.setInteraction(hs.SCRIPT,i,e.findNewMode)}this.nextHuntTick=Zl.currentTick+e.rate}huntPlayers(e){const t=ft.get(this.type),i=[],r=new ts(Zl.currentTick,this.level,this.x,this.z,this.huntrange,e.checkVis,-1,-1,je.PLAYER),s=e.findNewMode>=Xe.OPPLAYER1&&e.findNewMode<=Xe.OPPLAYER5;for(const n of r){if(!(n instanceof Do))throw new Error('[Npc] huntAll must be of type Player here.');if(s){const e=Math.abs(n.x-this.startX),i=Math.abs(n.z-this.startZ);if(Math.max(e,i)>t.maxrange+1)continue;if(e===t.maxrange+1&&i===t.maxrange+1)continue}else if(ji.distanceToSW(n,{x:this.startX,z:this.startZ})>t.maxrange+t.attackrange)continue;if((!e.checkAfk||!n.zonesAfk())&&((e.checkNotTooStrong!==Ke.OUTSIDE_WILDERNESS||n.isInWilderness()||!(n.combatLevel>2*t.vislevel))&&!(-1!==e.checkNotCombat&&n.getVar(e.checkNotCombat)+8>Zl.currentTick||-1!==e.checkNotCombatSelf&&this.getVar(e.checkNotCombatSelf)>=Zl.currentTick))){if(-1!==e.checkInv){let t=0;if(-1!==e.checkObj?t=n.invTotal(e.checkInv,e.checkObj):-1!==e.checkObjParam&&(t=n.invTotalParam(e.checkInv,e.checkObjParam)),te.checkInvMaxQuantity)continue}e.checkNotBusy&&n.busy()||i.push(n)}}return i}huntNpcs(e){return Array.from(new ts(Zl.currentTick,this.level,this.x,this.z,this.huntrange,e.checkVis,e.checkNpc,e.checkCategory,je.NPC))}huntObjs(e){return Array.from(new ts(Zl.currentTick,this.level,this.x,this.z,this.huntrange,e.checkVis,e.checkObj,e.checkCategory,je.OBJ))}huntLocs(e){return Array.from(new ts(Zl.currentTick,this.level,this.x,this.z,this.huntrange,e.checkVis,e.checkLoc,e.checkCategory,je.SCENERY))}playAnimation(t,i){t>=It.count||(-1==t||-1==this.animId||It.get(t).priority>It.get(this.animId).priority||0===It.get(this.animId).priority)&&(this.animId=t,this.animDelay=i,this.mask|=e.ANIM)}spotanim(t,i,r){this.graphicId=t,this.graphicHeight=i,this.graphicDelay=r,this.mask|=e.SPOTANIM}applyDamage(t,i){this.damageTaken=t,this.damageType=i;const r=this.levels[pt.HITPOINTS];r-t<=0?(this.levels[pt.HITPOINTS]=0,this.damageTaken=r):this.levels[pt.HITPOINTS]=r-t,this.mask|=e.DAMAGE}say(t){t&&(this.chat=t,this.mask|=e.SAY)}faceSquare(t,i){this.faceX=2*t+1,this.faceZ=2*i+1,this.orientationX=this.faceX,this.orientationZ=this.faceZ,this.mask|=e.FACE_COORD}changeType(t){this.type=t,this.mask|=e.CHANGE_TYPE,this.uid=t<<16|this.nid;const i=ft.get(t);this.setTimer(i.timer)}},Ml=class e{static OPEN=0;static BLOCKED=1;static BRIDGE=2;static ROOF=4;static WALL=8;static LOWMEMORY=16;static Y=4;static X=64;static Z=64;static MAPSQUARE=e.X*e.Y*e.Z;init(t){console.time('Loading game map');const i='data/pack/server/maps/',r=fs26.readdirSync(i).filter((e=>'m'===e[0]));for(let s=0;s(oe(),ee))),s=r;for(let r=0;r0;){const{x:r,z:s,level:n}=this.unpackCoord(e.g2()),a=t+r,o=i+s,c=e.g1();for(let t=0;t0;){const{x:s,z:n,level:a}=this.unpackCoord(e.g2()),o=t+s,c=i+n,l=e.g1();for(let t=0;t>2,E=3&u,_=o+r,A=h+s;n.zone(_,A,p).addStaticLoc(new ss(p,_,A,g,m,Yr.RESPAWN,a,y,E)),f.blockwalk&&this.changeLocCollision(y,E,f.blockrange,m,g,f.active,_,A,p,!0)}o=i.gsmart()}}packCoord(e,t,i){return 63&t|(63&e)<<6|(3&i)<<12}unpackCoord(e){return{x:e>>6&63,z:63&e,level:e>>12&3}}},xl=class{count=0;rsl=new Int32Array(256);mem=new Int32Array(256);a=0;b=0;c=0;constructor(e=[0,0,0,0]){for(let t=0;t>>2,s+=t,i+=r,i^=r<<8,n+=i,r+=s,r^=s>>>16,a+=r,s+=n,s^=n<<10,o+=s,n+=a,n^=a>>>4,e+=n,a+=o,a^=o<<8,t+=a,o+=e,o^=e>>>9,i+=o,e+=t;for(let c=0;c<256;c+=8)e+=this.rsl[c],t+=this.rsl[c+1],i+=this.rsl[c+2],r+=this.rsl[c+3],s+=this.rsl[c+4],n+=this.rsl[c+5],a+=this.rsl[c+6],o+=this.rsl[c+7],e^=t<<11,r+=e,t+=i,t^=i>>>2,s+=t,i+=r,i^=r<<8,n+=i,r+=s,r^=s>>>16,a+=r,s+=n,s^=n<<10,o+=s,n+=a,n^=a>>>4,e+=n,a+=o,a^=o<<8,t+=a,o+=e,o^=e>>>9,i+=o,e+=t,this.mem[c]=e,this.mem[c+1]=t,this.mem[c+2]=i,this.mem[c+3]=r,this.mem[c+4]=s,this.mem[c+5]=n,this.mem[c+6]=a,this.mem[c+7]=o;for(let c=0;c<256;c+=8)e+=this.mem[c],t+=this.mem[c+1],i+=this.mem[c+2],r+=this.mem[c+3],s+=this.mem[c+4],n+=this.mem[c+5],a+=this.mem[c+6],o+=this.mem[c+7],e^=t<<11,r+=e,t+=i,t^=i>>>2,s+=t,i+=r,i^=r<<8,n+=i,r+=s,r^=s>>>16,a+=r,s+=n,s^=n<<10,o+=s,n+=a,n^=a>>>4,e+=n,a+=o,a^=o<<8,t+=a,o+=e,o^=e>>>9,i+=o,e+=t,this.mem[c]=e,this.mem[c+1]=t,this.mem[c+2]=i,this.mem[c+3]=r,this.mem[c+4]=s,this.mem[c+5]=n,this.mem[c+6]=a,this.mem[c+7]=o;this.isaac(),this.count=256}isaac(){this.c++,this.b+=this.c;for(let e=0;e<256;e++){const t=this.mem[e];switch(3&e){case 0:this.a^=this.a<<13;break;case 1:this.a^=this.a>>>6;break;case 2:this.a^=this.a<<2;break;case 3:this.a^=this.a>>>16}let i;this.a+=this.mem[e+128&255],this.mem[e]=i=this.mem[t>>>2&255]+this.a+this.b,this.rsl[e]=this.b=this.mem[i>>>8>>>2&255]+t}}nextInt(){return 0==this.count--&&(this.isaac(),this.count=255),this.rsl[this.count]}};function Fl(e){return'undefined'==typeof self?new NodeWorker(e):new Worker(e,{type:'module'})}var Hl=class{static SUCCESSFUL=Uint8Array.from([2]);static INVALID_USER_OR_PASS=Uint8Array.from([3]);static ACCOUNT_DISABLED=Uint8Array.from([4]);static LOGGED_IN=Uint8Array.from([5]);static SERVER_UPDATED=Uint8Array.from([6]);static WORLD_FULL=Uint8Array.from([7]);static LOGIN_SERVER_OFFLINE=Uint8Array.from([8]);static LOGIN_LIMIT_EXCEEDED=Uint8Array.from([9]);static UNABLE_TO_CONNECT=Uint8Array.from([10]);static LOGIN_REJECTED=Uint8Array.from([11]);static NEED_MEMBERS_ACCOUNT=Uint8Array.from([12]);static COULD_NOT_COMPLETE=Uint8Array.from([13]);static SERVER_UPDATING=Uint8Array.from([14]);static RECONNECTING=Uint8Array.from([15]);static LOGIN_ATTEMPTS_EXCEEDED=Uint8Array.from([16]);static STANDING_IN_MEMBERS=Uint8Array.from([17]);static STAFF_MOD_LEVEL=Uint8Array.from([18])},Vl=new Oe(new Uint8Array(36)),Gl=[],Wl=0;function Kl(e){if(!fs28.existsSync(e))return;const t=Oe.load(e),i=Oe.getcrc(t.data,0,t.data.length);Gl.push(i),Vl.p4(i)}function zl(){Gl=[],Vl.pos=0,Vl.p4(0),Kl('data/pack/client/title'),Kl('data/pack/client/config'),Kl('data/pack/client/interface'),Kl('data/pack/client/media'),Kl('data/pack/client/models'),Kl('data/pack/client/textures'),Kl('data/pack/client/wordenc'),Kl('data/pack/client/sounds'),Wl=Oe.getcrc(Vl.data,0,Vl.data.length)}async function jl(e){if(!(await fetch(e)).ok)return;const t=await Oe.loadAsync(e),i=Oe.getcrc(t.data,0,t.data.length);Gl.push(i),Vl.p4(i)}'undefined'==typeof self?fs28.existsSync('data/pack/client/')&&zl():(await fetch('data/pack/client')).ok&&await async function(){Gl=[],Vl.pos=0,Vl.p4(0),await jl('data/pack/client/title'),await jl('data/pack/client/config'),await jl('data/pack/client/interface'),await jl('data/pack/client/media'),await jl('data/pack/client/models'),await jl('data/pack/client/textures'),await jl('data/pack/client/wordenc'),await jl('data/pack/client/sounds'),Wl=Oe.getcrc(Vl.data,0,Vl.data.length)}();var Yl=new class{loginThread=Fl('undefined'==typeof self?'./src/lostcity/server/LoginThread.ts':'LoginThread.js');loginRequests=new Map;logoutRequests=new Set;constructor(){const e=e=>{try{this.onMessage(e)}catch(e){console.error('Login Thread:',e)}};'undefined'==typeof self?this.loginThread instanceof NodeWorker2&&this.loginThread.on('message',e):this.loginThread instanceof Worker&&(this.loginThread.onmessage=e)}async readIn(e,t){const i=t.g1();if(16===i){const r=t.g1();if(t.available=2e3)return r.writeImmediate(Hl.WORLD_FULL),void r.close();if(Zl.shutdownTick>-1&&Zl.currentTick-Zl.shutdownTick>0)return r.writeImmediate(Hl.SERVER_UPDATING),void r.close();if(!vt.LOGIN_KEY)for(const e of Zl.players)if(e.username===a)return r.writeImmediate(Hl.LOGGED_IN),void r.close();r.decryptor=new xl(n);for(let e=0;e<4;e++)n[e]+=50;r.encryptor=new xl(n);const c=jc.load(a,new Oe(o),r);c.lowMemory=!!(1&s),c.webClient=r.isWebSocket(),Zl.addPlayer(c);break}case'logoutreply':{const{username:t}=e,i=Zl.getPlayerByUsername(t);i&&(Zl.getZone(i.x,i.z,i.level).leave(i),Zl.players.remove(i.pid),i.pid=-1,i.terminate(),this.logoutRequests.delete(i.username37));break}default:throw new Error('Unknown message type: '+e.type)}else switch(e.data.type){case'loginreply':{const{status:t,socket:i}=e.data,r=this.loginRequests.get(i);if(!r)return;if(this.loginRequests.delete(i),2!==t[0])return r.writeImmediate(t),void r.close();const{info:s,seed:n,username:a,save:o}=e.data;if(Zl.getTotalPlayers()>=2e3)return r.writeImmediate(Hl.WORLD_FULL),void r.close();if(Zl.shutdownTick>-1&&Zl.currentTick-Zl.shutdownTick>0)return r.writeImmediate(Hl.SERVER_UPDATING),void r.close();if(!vt.LOGIN_KEY)for(const e of Zl.players)if(e.username===a)return r.writeImmediate(Hl.LOGGED_IN),void r.close();r.decryptor=new xl(n);for(let e=0;e<4;e++)n[e]+=50;r.encryptor=new xl(n);const c=jc.load(a,new Oe(o),r);c.lowMemory=!!(1&s),c.webClient=!0,Zl.addPlayer(c);break}case'logoutreply':{const{username:t}=e.data,i=Zl.getPlayerByUsername(t);i&&(Zl.getZone(i.x,i.z,i.level).leave(i),Zl.players.remove(i.pid),i.pid=-1,i.terminate(),this.logoutRequests.delete(i.username37));break}default:throw new Error('Unknown message type: '+e.data.type)}}},ql=class extends Array{free;indexPadding;ids;lastUsedIndex=0;constructor(e,t){super(e),this.ids=new Int32Array(e).fill(-1),this.free=new Set(Array.from({length:e},((e,t)=>t))),this.indexPadding=t}next(e=!1,t=this.lastUsedIndex+1){const i=this.ids.length;for(let e=t;e(oe(),ee))),r=t;for(let e=0;e{'done'===e.type&&(this.devRebuilding=!1,this.reload())})),this.devThread.on('exit',(()=>{this.devRebuilding=!1,this.stopDevWatcher(),-1===this.shutdownTick&&(this.broadcastMes('Error while rebuilding - see console for more info.'),this.startDevWatcher())})),this.devWatcher=new Watcher('./data/src',{recursive:!0}),this.devWatcher.on('add',(e=>{if(e.endsWith('.pack'))return;const t=fs29.statSync(e);this.devMTime.set(e,t.mtimeMs)})),this.devWatcher.on('change',(e=>{if(e.endsWith('.pack'))return;const t=fs29.statSync(e),i=this.devMTime.get(e);i&&i>=t.mtimeMs||(this.devMTime.set(e,t.mtimeMs),this.devRebuilding||(console.log('dev:',path4.basename(e),'was edited'),this.devRebuilding=!0,this.broadcastMes('Rebuilding, please wait...'),this.devThread||(this.devThread=Fl('./src/lostcity/server/DevThread.ts')),this.devThread.postMessage({type:'pack'})))}))}stopDevWatcher(){this.devWatcher&&this.devWatcher.close(),this.devThread&&(this.devThread.terminate(),this.devThread=null)}rebootTimer(e){this.shutdownTick=this.currentTick+e,this.stopDevWatcher();for(const e of this.players)e.write(new vo(this.shutdownTick-this.currentTick))}async cycle(t=!0){const i=Date.now();this.processWorld(),await this.processClientsIn(),this.processNpcs(),await this.processPlayers(),await this.processLogouts(),await this.processLogins(),this.processZones(),this.processMovementDirections(),await this.processClientsOut(),this.processCleanup();const r=this.currentTick;r%e.LOGIN_PINGRATE==0&&this.heartbeat(),this.shutdownTick>-1&&r>=this.shutdownTick&&await this.processShutdown(),r%e.PLAYER_SAVERATE==0&&r>0&&this.savePlayers(),this.currentTick++,this.cycleStats[Gr.CYCLE]=Date.now()-i,this.lastCycleStats[Gr.CYCLE]=this.cycleStats[Gr.CYCLE],this.lastCycleStats[Gr.WORLD]=this.cycleStats[Gr.WORLD],this.lastCycleStats[Gr.CLIENT_IN]=this.cycleStats[Gr.CLIENT_IN],this.lastCycleStats[Gr.NPC]=this.cycleStats[Gr.NPC],this.lastCycleStats[Gr.PLAYER]=this.cycleStats[Gr.PLAYER],this.lastCycleStats[Gr.LOGOUT]=this.cycleStats[Gr.LOGOUT],this.lastCycleStats[Gr.LOGIN]=this.cycleStats[Gr.LOGIN],this.lastCycleStats[Gr.ZONE]=this.cycleStats[Gr.ZONE],this.lastCycleStats[Gr.CLIENT_OUT]=this.cycleStats[Gr.CLIENT_OUT],this.lastCycleStats[Gr.CLEANUP]=this.cycleStats[Gr.CLEANUP],this.lastCycleStats[Gr.BANDWIDTH_IN]=this.cycleStats[Gr.BANDWIDTH_IN],this.lastCycleStats[Gr.BANDWIDTH_OUT]=this.cycleStats[Gr.BANDWIDTH_OUT],t&&setTimeout(this.cycle.bind(this),this.tickRate-this.cycleStats[Gr.CYCLE]),vt.NODE_DEBUG_PROFILE&&(console.log(`tick ${this.currentTick} took ${this.cycleStats[Gr.CYCLE]}ms: ${this.getTotalPlayers()} players`),console.log(`${this.cycleStats[Gr.WORLD]} ms world | ${this.cycleStats[Gr.CLIENT_IN]} ms client in | ${this.cycleStats[Gr.NPC]} ms npcs | ${this.cycleStats[Gr.PLAYER]} ms players | ${this.cycleStats[Gr.LOGOUT]} ms logout | ${this.cycleStats[Gr.LOGIN]} ms login | ${this.cycleStats[Gr.ZONE]} ms zones | ${this.cycleStats[Gr.CLIENT_OUT]} ms client out | ${this.cycleStats[Gr.CLEANUP]} ms cleanup`),console.log('----'))}processWorld(){const t=Date.now(),i=this.currentTick;for(let e=this.queue.head();e;e=this.queue.next()){if(e.delay-- >0)continue;const t=e.script;try{const i=Dl.execute(t);e.unlink(),i===$t.SUSPENDED?t.activePlayer.activeScript=t:i===$t.NPC_SUSPENDED?t.activeNpc.activeScript=t:i===$t.WORLD_SUSPENDED&&this.enqueueScript(t,t.popInt())}catch(e){console.error(e)}}if(i%e.AFK_EVENTRATE==0)for(const e of this.players)e.afkEventReady=Math.random()<(e.zonesAfk()?.1666:.0833);for(const e of this.npcs)e.updateLifeCycle(i)&&(e.lifecycle===Yr.RESPAWN?this.addNpc(e,-1):e.lifecycle===Yr.DESPAWN&&this.removeNpc(e,-1));for(const e of this.npcs)e.checkLifeCycle(i)&&!e.delayed()&&-1!==e.huntMode&&e.huntAll();this.cycleStats[Gr.WORLD]=Date.now()-t}async processClientsIn(){const e=Date.now();this.cycleStats[Gr.BANDWIDTH_IN]=0;for(const e of this.players)if(Sl(e))try{e.decodeIn()}catch(t){console.error(t),await this.removePlayer(e)}for(const e of this.players)if(Sl(e)){if(e.userPath.length>0||e.opcalled){if(e.delayed()){e.unsetMapFlag();continue}if((!e.target||e.target instanceof ss||e.target instanceof $r)&&-1!==e.faceEntity&&(e.faceEntity=-1,e.mask|=Do.FACE_ENTITY),e.opcalled&&(0===e.userPath.length||!vt.NODE_CLIENT_ROUTEFINDER)){e.pathToTarget();continue}e.pathToMoveClick(e.userPath,!vt.NODE_CLIENT_ROUTEFINDER)}e.target instanceof Do&&(e.targetOp===cs.APPLAYER3||e.targetOp===cs.OPPLAYER3)&&(ji.distanceToSW(e,e.target)<=25?e.pathToPathingTarget():e.clearWaypoints())}this.cycleStats[Gr.CLIENT_IN]=Date.now()-e}processNpcs(){const e=Date.now();for(const e of this.npcs)if(e.checkLifeCycle(this.currentTick))try{if(e.delayed())continue;if(e.activeScript&&e.executeScript(e.activeScript),!e.checkLifeCycle(this.currentTick))continue;e.processTimers(),e.processQueue(),e.processNpcModes(),e.validateDistanceWalked()}catch(t){console.error(t),this.removeNpc(e,-1)}this.cycleStats[Gr.NPC]=Date.now()-e}async processPlayers(){const t=Date.now();for(const t of this.players)try{t.playtime++,t.activeScript&&!t.delayed()&&t.activeScript.execution===$t.SUSPENDED&&t.executeScript(t.activeScript,!0),t.processQueues(),t.processTimers(0),t.processTimers(1),t.processEngineQueue(),t.processInteraction(),t.mask&Do.EXACT_MOVE||t.validateDistanceWalked(),this.shutdownTick=e.TIMEOUT_IDLE_TICKS&&(t.logoutRequested=!0),t.logoutRequested&&t.closeModal()}catch(e){console.error(e),await this.removePlayer(t)}this.cycleStats[Gr.PLAYER]=Date.now()-t}async processLogouts(){const t=Date.now();for(const t of this.players)if(vt.NODE_SOCKET_TIMEOUT&&this.currentTick-t.lastResponse>=e.TIMEOUT_LOGOUT_TICKS&&(t.queue.clear(),t.weakQueue.clear(),t.engineQueue.clear(),t.clearInteraction(),t.closeModal(),t.unsetMapFlag(),t.logoutRequested=!0,t.setVar(Nt.LASTCOMBAT,0)),t.logoutRequested)if(null===t.queue.head()){const e=jt.getByTriggerSpecific(cs.LOGOUT,-1,-1);if(!e){console.error('LOGOUT TRIGGER IS BROKEN!');continue}const i=Dl.init(e,t);i.pointerAdd(Gt.ProtectedActivePlayer),Dl.execute(i);0===i.popInt()&&(t.logoutRequested=!1),t.logoutRequested&&await this.removePlayer(t)}else t.messageGame('[DEBUG]: Waiting for queue to empty before logging out.');this.cycleStats[Gr.LOGOUT]=Date.now()-t}async processLogins(){const e=Date.now();e:for(const e of this.newPlayers){for(const t of this.players)if(e.username===t.username){Sl(e)&&e.client&&(e.client.send(Hl.LOGGED_IN),e.client.close());continue e}let t;try{t=this.getNextPid(Sl(e)?e.client:null)}catch(t){Sl(e)&&(e.client?.send(Hl.WORLD_FULL),e.client?.close());continue}this.players.set(t,e),e.pid=t,e.uid=(Number(0x1fffffn&e.username37)<<11|e.pid)>>>0,e.tele=!0,this.getZone(e.x,e.z,e.level).enter(e),e.onLogin(),this.shutdownTick>-1&&e.write(new vo(this.shutdownTick-this.currentTick)),Sl(e)&&e.client&&(e.client.state=1,e.staffModLevel>=2?e.client.send(Hl.STAFF_MOD_LEVEL):e.client.send(Hl.SUCCESSFUL))}this.newPlayers.clear(),this.cycleStats[Gr.LOGIN]=Date.now()-e}processZones(){const e=Date.now(),t=this.currentTick,i=this.zonesTracking.get(t);if(void 0!==i)for(const e of i)e.tick(t);this.computeSharedEvents(),this.cycleStats[Gr.ZONE]=Date.now()-e}processMovementDirections(){for(const e of this.players)e.convertMovementDir();for(const e of this.npcs)e.convertMovementDir()}async processClientsOut(){const e=Date.now();this.cycleStats[Gr.BANDWIDTH_OUT]=0;for(const e of this.players)if(Sl(e))try{e.updateMap(),e.updatePlayers(),e.updateNpcs(),e.updateZones(),e.updateInvs(),e.updateStats(),e.updateAfkZones(),e.encodeOut()}catch(t){console.error(t),await this.removePlayer(e)}else e.highPriorityOut.clear(),e.lowPriorityOut.clear();this.cycleStats[Gr.CLIENT_OUT]=Date.now()-e}processCleanup(){const t=Date.now(),i=this.currentTick,r=this.zonesTracking.get(i);if(void 0!==r)for(const e of r)e.reset();this.zonesTracking.delete(i);for(const e of this.players){e.resetEntity(!1);for(const t of e.invs.values())t&&(t.update=!1)}for(const e of this.npcs)e.checkLifeCycle(i)&&e.resetEntity(!1);for(const t of this.invs){t.update=!1;const r=it.get(t.type);if(r.restock&&r.stockcount&&r.stockrate)for(let s=0;sr.stockcount[s]&&i%r.stockrate[s]==0||r.allstock&&!r.stockcount[s]&&i%e.INV_STOCKRATE==0)&&(t.remove(n?.id,1,s,!0),t.update=!0))}}this.cycleStats[Gr.CLEANUP]=Date.now()-t}heartbeat(){const e=[];for(const t of this.players)e.push(t.username37);Yl.loginThread.postMessage({type:'heartbeat',players:e})}async processShutdown(){const t=this.currentTick-this.shutdownTick;if(this.getTotalPlayers()){for(const e of this.players)e.logoutRequested=!0,Sl(e)&&(e.logout(),e.client&&t>2&&e.client.close());if(this.npcs.reset(),t>2){if(console.log('Super fast shutdown initiated...'),this.tickRate>e.SHUTDOWN_TICKRATE&&(this.tickRate=e.SHUTDOWN_TICKRATE),t>e.SHUTDOWN_TICKS){for(const e of this.players)await this.removePlayer(e);this.tickRate=e.NORMAL_TICKRATE}vt.NODE_PRODUCTION||process.exit(0)}}else process.exit(0)}savePlayers(){if('undefined'==typeof self)for(const e of this.players)e.save().release()}enqueueScript(e,t=0){this.queue.addTail(new vs(e,t+1))}getInventory(e){if(-1===e)return null;for(const t of this.invs)if(t.type===e)return t;const t=Xt.fromType(e);return this.invs.add(t),t}getZone(e,t,i){return this.zoneMap.zone(e,t,i)}getZoneIndex(e){return this.zoneMap.zoneByIndex(e)}getZoneGrid(e){return this.zoneMap.grid(e)}computeSharedEvents(){const e=new Set;for(const t of this.players)if(Sl(t))for(const i of t.buildArea.loadedZones)e.add(i);for(const t of e)this.getZoneIndex(t).computeShared()}addNpc(e,t){this.npcs.set(e.nid,e),e.x=e.startX,e.z=e.startZ;switch(this.getZone(e.x,e.z,e.level).enter(e),e.blockWalk){case lt.NPC:this.gameMap.changeNpcCollision(e.width,e.x,e.z,e.level,!0);break;case lt.ALL:this.gameMap.changeNpcCollision(e.width,e.x,e.z,e.level,!0),this.gameMap.changePlayerCollision(e.width,e.x,e.z,e.level,!0)}e.resetEntity(!0),e.playAnimation(-1,0),e.setLifeCycle(this.currentTick+t)}removeNpc(e,t){switch(this.getZone(e.x,e.z,e.level).leave(e),e.blockWalk){case lt.NPC:this.gameMap.changeNpcCollision(e.width,e.x,e.z,e.level,!1);break;case lt.ALL:this.gameMap.changeNpcCollision(e.width,e.x,e.z,e.level,!1),this.gameMap.changePlayerCollision(e.width,e.x,e.z,e.level,!1)}e.lifecycle===Yr.DESPAWN?this.npcs.remove(e.nid):e.lifecycle===Yr.RESPAWN&&e.setLifeCycle(this.currentTick+t)}getLoc(e,t,i,r){return this.getZone(e,t,i).getLoc(e,t,r)}getObj(e,t,i,r,s){return this.getZone(e,t,i).getObj(e,t,r,s)}trackZone(e,t){let i;const r=this.zonesTracking.get(e);i=r||new Set,i.add(t),this.zonesTracking.set(e,i)}addLoc(e,t){const i=at.get(e.type);i.blockwalk&&this.gameMap.changeLocCollision(e.shape,e.angle,i.blockrange,i.length,i.width,i.active,e.x,e.z,e.level,!0);const r=this.getZone(e.x,e.z,e.level);r.addLoc(e),e.setLifeCycle(this.currentTick+t),this.trackZone(this.currentTick+t,r),this.trackZone(this.currentTick,r)}mergeLoc(e,t,i,r,s,n,a,o){const c=this.getZone(e.x,e.z,e.level);c.mergeLoc(e,t,i,r,s,n,a,o),this.trackZone(this.currentTick,c)}animLoc(e,t){const i=this.getZone(e.x,e.z,e.level);i.animLoc(e,t),this.trackZone(this.currentTick,i)}removeLoc(e,t){const i=at.get(e.type);i.blockwalk&&this.gameMap.changeLocCollision(e.shape,e.angle,i.blockrange,i.length,i.width,i.active,e.x,e.z,e.level,!1);const r=this.getZone(e.x,e.z,e.level);r.removeLoc(e),e.setLifeCycle(this.currentTick+t),this.trackZone(this.currentTick+t,r),this.trackZone(this.currentTick,r)}addObj(e,t,i){const r=Tt.get(e.type),s=this.getObj(e.x,e.z,e.level,e.type,t);if(s&&s.lifecycle===Yr.DESPAWN&&e.lifecycle===Yr.DESPAWN){const i=e.count+s.count;if(r.stackable&&i<=Xt.STACK_LIMIT)return void this.changeObj(s,t,i)}const n=this.getZone(e.x,e.z,e.level);n.addObj(e,t),-1!==t&&r.tradeable?(e.setLifeCycle(this.currentTick+100),this.trackZone(this.currentTick+100,n),this.trackZone(this.currentTick,n),e.receiverId=t,e.reveal=i):(e.setLifeCycle(this.currentTick+i),this.trackZone(this.currentTick+i,n),this.trackZone(this.currentTick,n))}revealObj(e){const t=e.reveal,i=this.getZone(e.x,e.z,e.level);i.revealObj(e,e.receiverId),e.setLifeCycle(this.currentTick+t),this.trackZone(this.currentTick+t,i),this.trackZone(this.currentTick,i)}changeObj(e,t,i){const r=this.getZone(e.x,e.z,e.level);r.changeObj(e,t,e.count,i),this.trackZone(this.currentTick,r)}removeObj(e,t){const i=this.getZone(e.x,e.z,e.level);i.removeObj(e),e.setLifeCycle(this.currentTick+t),this.trackZone(this.currentTick+t,i),this.trackZone(this.currentTick,i)}animMap(e,t,i,r,s,n){const a=this.getZone(t,i,e);a.animMap(t,i,r,s,n),this.trackZone(this.currentTick,a)}mapProjAnim(e,t,i,r,s,n,a,o,c,l,h,d,u){const p=this.getZone(t,i,e);p.mapProjAnim(t,i,r,s,n,a,o,c,l,h,d,u),this.trackZone(this.currentTick,p)}async readIn(e,t){for(;t.available>0;){const i=t.pos;let r=t.g1();if(e.decryptor&&(r=r-e.decryptor.nextInt()&255,t.data[i]=r),void 0===ko.byId[r])return e.state=-1,void e.close();let s=ko.byId[r].length;if(-1===s?s=t.g1():-2===s&&(s=t.g2()),t.available5)continue;const n=new Uint8Array(t.pos-i),a=t.pos;t.pos=i,t.gdata(n,0,n.length),t.pos=a,e.in.set(n,e.inOffset),e.inOffset+=t.pos-i}}addPlayer(e){this.newPlayers.add(e)}async removePlayer(e){-1!==e.pid&&(e.playerLog('Logging out'),Sl(e)&&(e.logout(),e.client.close(),e.client=null),Yl.logout(e))}getPlayer(e){return this.players.get(e)}getPlayerByUid(e){const t=2047&e,i=e>>11&2097151,r=this.getPlayer(t);return r?Number(0x1fffffn&r.username37)!==i?null:r:null}getPlayerByUsername(e){const t=pe(e);for(const e of this.players)if(e.username37===t)return e;for(const e of this.newPlayers)if(e.username37===t)return e}getTotalPlayers(){return this.players.count}getTotalNpcs(){return this.npcs.count}getTotalZones(){return this.zoneMap.zoneCount()}getTotalLocs(){return this.zoneMap.locCount()}getTotalObjs(){return this.zoneMap.objCount()}getNpc(e){return this.npcs.get(e)}getNpcByUid(e){const t=65535&e,i=e>>16&65535,r=this.getNpc(t);return r&&r.type===i?r:null}getNextNid(){return this.npcs.next()}getNextPid(e=null){if(e){const t=e.remoteAddress.split('.'),i=parseInt(t[3])%20*100;return this.players.next(!0,i)}return this.players.next()}};await Zl.start(),(new class{socket=new Kc(null,'127.0.0.1');constructor(){}start(){const e=new Oe(new Uint8Array(8));e.p4(Math.floor(4294967295*Math.random())),e.p4(Math.floor(4294967295*Math.random())),this.socket.send(e.data),self.onmessage=async e=>{const t=new Oe(new Uint8Array(e.data));e.data.type;try{1===this.socket.state?await Zl.readIn(this.socket,t):await Yl.readIn(this.socket,t)}catch(e){this.socket.close()}}}}).start(); \ No newline at end of file diff --git a/worker.js.LICENSE.txt b/worker.js.LICENSE.txt deleted file mode 100644 index 4b2642b7..00000000 --- a/worker.js.LICENSE.txt +++ /dev/null @@ -1,10 +0,0 @@ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ - -/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ - -/*! safe-buffer. MIT License. Feross Aboukhadijeh */