yj-deploy 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ (function(zt,Ht){typeof exports=="object"&&typeof module<"u"?module.exports=Ht():typeof define=="function"&&define.amd?define(Ht):(zt=typeof globalThis<"u"?globalThis:zt||self,zt["yj-deploy"]=Ht())})(this,function(){"use strict";var wh=Object.defineProperty;var mh=(zt,Ht,wn)=>Ht in zt?wh(zt,Ht,{enumerable:!0,configurable:!0,writable:!0,value:wn}):zt[Ht]=wn;var _r=(zt,Ht,wn)=>(mh(zt,typeof Ht!="symbol"?Ht+"":Ht,wn),wn);function zt(r){if(r.__esModule)return r;var t=r.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:function(){return r[n]}})}),e}var Ht={exports:{}},wn=function(){return/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g},Oo=wn(),Do=function(r){return typeof r=="string"?r.replace(Oo,""):r},Ho=function(r,t){if(r==null)throw TypeError();r=String(r);var e=r.length,n=t?Number(t):0;if(Number.isNaN(n)&&(n=0),!(n<0||n>=e)){var s=r.charCodeAt(n);if(s>=55296&&s<=56319&&e>n+1){var i=r.charCodeAt(n+1);if(i>=56320&&i<=57343)return(s-55296)*1024+i-56320+65536}return s}},Qo=Number.isNaN||function(r){return r!==r},Fo=Qo,Mo=function(r){return Fo(r)?!1:r>=4352&&(r<=4447||r===9001||r===9002||11904<=r&&r<=12871&&r!==12351||12880<=r&&r<=19903||19968<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65131||65281<=r&&r<=65376||65504<=r&&r<=65510||110592<=r&&r<=110593||127488<=r&&r<=127569||131072<=r&&r<=262141)},Ko=Do,Wo=Ho,$o=Mo,qo=function(r){if(typeof r!="string"||r.length===0)return 0;var t=0;r=Ko(r);for(var e=0;e<r.length;e++){var n=Wo(r,e);n<=31||n>=127&&n<=159||(n>=65536&&e++,$o(n)?t+=2:t++)}return t};Ht.exports,function(r){var t=new Buffer("1b5b3130303044","hex").toString(),e=new Buffer("1b5b3141","hex").toString(),n=new Buffer("1b5b304b","hex").toString(),s=qo;r.exports=function(i){var o=i.write,f;i.write=function(g){return f&&g!==f&&(f=null),o.apply(this,arguments)},(i===process.stderr||i===process.stdout)&&process.on("exit",function(){f!==null&&i.write("")});var c=0,h=function(){f="";for(var g=Array.prototype.join.call(arguments," "),u=0;u<c;u++)f+=t+n+(u<c-1?e:"");f+=g,i.write(f);var d=g.split(`
2
+ `);c=0;for(var u=0;u<d.length;u++)c+=Math.ceil(s(d[u])/i.columns)||1};return h.clear=function(){i.write("")},h},r.exports.stdout=r.exports(process.stdout),r.exports.stderr=r.exports(process.stderr)}(Ht);var Go=Ht.exports;const Yn={},tt=zt(Object.freeze(Object.defineProperty({__proto__:null,default:Yn},Symbol.toStringTag,{value:"Module"})));var Oi={exports:{}},Mr={newInvalidAsn1Error:function(r){var t=new Error;return t.name="InvalidAsn1Error",t.message=r||"",t}},Kr={EOC:0,Boolean:1,Integer:2,BitString:3,OctetString:4,Null:5,OID:6,ObjectDescriptor:7,External:8,Real:9,Enumeration:10,PDV:11,Utf8String:12,RelativeOID:13,Sequence:16,Set:17,NumericString:18,PrintableString:19,T61String:20,VideotexString:21,IA5String:22,UTCTime:23,GeneralizedTime:24,GraphicString:25,VisibleString:26,GeneralString:28,UniversalString:29,CharacterString:30,BMPString:31,Constructor:32,Context:128},Er=tt,Ln=Er.Buffer,Xt={},jt;for(jt in Er)Er.hasOwnProperty(jt)&&(jt==="SlowBuffer"||jt==="Buffer"||(Xt[jt]=Er[jt]));var Un=Xt.Buffer={};for(jt in Ln)Ln.hasOwnProperty(jt)&&(jt==="allocUnsafe"||jt==="allocUnsafeSlow"||(Un[jt]=Ln[jt]));if(Xt.Buffer.prototype=Ln.prototype,(!Un.from||Un.from===Uint8Array.from)&&(Un.from=function(r,t,e){if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof r);if(r&&typeof r.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);return Ln(r,t,e)}),Un.alloc||(Un.alloc=function(r,t,e){if(typeof r!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof r);if(r<0||r>=2*(1<<30))throw new RangeError('The value "'+r+'" is invalid for option "size"');var n=Ln(r);return!t||t.length===0?n.fill(0):typeof e=="string"?n.fill(t,e):n.fill(t),n}),!Xt.kStringMaxLength)try{Xt.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}Xt.constants||(Xt.constants={MAX_LENGTH:Xt.kMaxLength},Xt.kStringMaxLength&&(Xt.constants.MAX_STRING_LENGTH=Xt.kStringMaxLength));var Di=Xt,Yo=tt,Hi=Di.Buffer,Xn=Kr,Xo=Mr,Pn=Xo.newInvalidAsn1Error;function Qt(r){if(!r||!Hi.isBuffer(r))throw new TypeError("data must be a node Buffer");this._buf=r,this._size=r.length,this._len=0,this._offset=0}Object.defineProperty(Qt.prototype,"length",{enumerable:!0,get:function(){return this._len}}),Object.defineProperty(Qt.prototype,"offset",{enumerable:!0,get:function(){return this._offset}}),Object.defineProperty(Qt.prototype,"remain",{get:function(){return this._size-this._offset}}),Object.defineProperty(Qt.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}}),Qt.prototype.readByte=function(r){if(this._size-this._offset<1)return null;var t=this._buf[this._offset]&255;return r||(this._offset+=1),t},Qt.prototype.peek=function(){return this.readByte(!0)},Qt.prototype.readLength=function(r){if(r===void 0&&(r=this._offset),r>=this._size)return null;var t=this._buf[r++]&255;if(t===null)return null;if((t&128)===128){if(t&=127,t===0)throw Pn("Indefinite length not supported");if(t>4)throw Pn("encoding too long");if(this._size-r<t)return null;this._len=0;for(var e=0;e<t;e++)this._len=(this._len<<8)+(this._buf[r++]&255)}else this._len=t;return r},Qt.prototype.readSequence=function(r){var t=this.peek();if(t===null)return null;if(r!==void 0&&r!==t)throw Pn("Expected 0x"+r.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);return e===null?null:(this._offset=e,t)},Qt.prototype.readInt=function(){return this._readTag(Xn.Integer)},Qt.prototype.readBoolean=function(){return this._readTag(Xn.Boolean)!==0},Qt.prototype.readEnumeration=function(){return this._readTag(Xn.Enumeration)},Qt.prototype.readString=function(r,t){r||(r=Xn.OctetString);var e=this.peek();if(e===null)return null;if(e!==r)throw Pn("Expected 0x"+r.toString(16)+": got 0x"+e.toString(16));var n=this.readLength(this._offset+1);if(n===null||this.length>this._size-n)return null;if(this._offset=n,this.length===0)return t?Hi.alloc(0):"";var s=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?s:s.toString("utf8")},Qt.prototype.readOID=function(r){r||(r=Xn.OID);var t=this.readString(r,!0);if(t===null)return null;for(var e=[],n=0,s=0;s<t.length;s++){var i=t[s]&255;n<<=7,n+=i&127,i&128||(e.push(n),n=0)}return n=e.shift(),e.unshift(n%40),e.unshift(n/40>>0),e.join(".")},Qt.prototype._readTag=function(r){Yo.ok(r!==void 0);var t=this.peek();if(t===null)return null;if(t!==r)throw Pn("Expected 0x"+r.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);if(e===null)return null;if(this.length>4)throw Pn("Integer too long: "+this.length);if(this.length>this._size-e)return null;this._offset=e;for(var n=this._buf[this._offset],s=0,i=0;i<this.length;i++)s<<=8,s|=this._buf[this._offset++]&255;return(n&128)===128&&i!==4&&(s-=1<<i*8),s>>0};var jo=Qt,gn=tt,pr=Di.Buffer,_n=Kr,Vo=Mr,br=Vo.newInvalidAsn1Error,zo={size:1024,growthFactor:8};function Jo(r,t){gn.ok(r),gn.equal(typeof r,"object"),gn.ok(t),gn.equal(typeof t,"object");var e=Object.getOwnPropertyNames(r);return e.forEach(function(n){if(!t[n]){var s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,s)}}),t}function Tt(r){r=Jo(zo,r||{}),this._buf=pr.alloc(r.size||1024),this._size=this._buf.length,this._offset=0,this._options=r,this._seq=[]}Object.defineProperty(Tt.prototype,"buffer",{get:function(){if(this._seq.length)throw br(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}}),Tt.prototype.writeByte=function(r){if(typeof r!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=r},Tt.prototype.writeInt=function(r,t){if(typeof r!="number")throw new TypeError("argument must be a Number");typeof t!="number"&&(t=_n.Integer);for(var e=4;(!(r&4286578688)||(r&4286578688)===-8388608)&&e>1;)e--,r<<=8;if(e>4)throw br("BER ints cannot be > 0xffffffff");for(this._ensure(2+e),this._buf[this._offset++]=t,this._buf[this._offset++]=e;e-- >0;)this._buf[this._offset++]=(r&4278190080)>>>24,r<<=8},Tt.prototype.writeNull=function(){this.writeByte(_n.Null),this.writeByte(0)},Tt.prototype.writeEnumeration=function(r,t){if(typeof r!="number")throw new TypeError("argument must be a Number");return typeof t!="number"&&(t=_n.Enumeration),this.writeInt(r,t)},Tt.prototype.writeBoolean=function(r,t){if(typeof r!="boolean")throw new TypeError("argument must be a Boolean");typeof t!="number"&&(t=_n.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=r?255:0},Tt.prototype.writeString=function(r,t){if(typeof r!="string")throw new TypeError("argument must be a string (was: "+typeof r+")");typeof t!="number"&&(t=_n.OctetString);var e=pr.byteLength(r);this.writeByte(t),this.writeLength(e),e&&(this._ensure(e),this._buf.write(r,this._offset),this._offset+=e)},Tt.prototype.writeBuffer=function(r,t){if(typeof t!="number")throw new TypeError("tag must be a number");if(!pr.isBuffer(r))throw new TypeError("argument must be a buffer");this.writeByte(t),this.writeLength(r.length),this._ensure(r.length),r.copy(this._buf,this._offset,0,r.length),this._offset+=r.length},Tt.prototype.writeStringArray=function(r){if(!r instanceof Array)throw new TypeError("argument must be an Array[String]");var t=this;r.forEach(function(e){t.writeString(e)})},Tt.prototype.writeOID=function(r,t){if(typeof r!="string")throw new TypeError("argument must be a string");if(typeof t!="number"&&(t=_n.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(r))throw new Error("argument is not a valid OID string");function e(o,f){f<128?o.push(f):f<16384?(o.push(f>>>7|128),o.push(f&127)):f<2097152?(o.push(f>>>14|128),o.push((f>>>7|128)&255),o.push(f&127)):f<268435456?(o.push(f>>>21|128),o.push((f>>>14|128)&255),o.push((f>>>7|128)&255),o.push(f&127)):(o.push((f>>>28|128)&255),o.push((f>>>21|128)&255),o.push((f>>>14|128)&255),o.push((f>>>7|128)&255),o.push(f&127))}var n=r.split("."),s=[];s.push(parseInt(n[0],10)*40+parseInt(n[1],10)),n.slice(2).forEach(function(o){e(s,parseInt(o,10))});var i=this;this._ensure(2+s.length),this.writeByte(t),this.writeLength(s.length),s.forEach(function(o){i.writeByte(o)})},Tt.prototype.writeLength=function(r){if(typeof r!="number")throw new TypeError("argument must be a Number");if(this._ensure(4),r<=127)this._buf[this._offset++]=r;else if(r<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=r;else if(r<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=r>>8,this._buf[this._offset++]=r;else if(r<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=r>>16,this._buf[this._offset++]=r>>8,this._buf[this._offset++]=r;else throw br("Length too long (> 4 bytes)")},Tt.prototype.startSequence=function(r){typeof r!="number"&&(r=_n.Sequence|_n.Constructor),this.writeByte(r),this._seq.push(this._offset),this._ensure(3),this._offset+=3},Tt.prototype.endSequence=function(){var r=this._seq.pop(),t=r+3,e=this._offset-t;if(e<=127)this._shift(t,e,-2),this._buf[r]=e;else if(e<=255)this._shift(t,e,-1),this._buf[r]=129,this._buf[r+1]=e;else if(e<=65535)this._buf[r]=130,this._buf[r+1]=e>>8,this._buf[r+2]=e;else if(e<=16777215)this._shift(t,e,1),this._buf[r]=131,this._buf[r+1]=e>>16,this._buf[r+2]=e>>8,this._buf[r+3]=e;else throw br("Sequence too long")},Tt.prototype._shift=function(r,t,e){gn.ok(r!==void 0),gn.ok(t!==void 0),gn.ok(e),this._buf.copy(this._buf,r+e,r,r+t),this._offset+=e},Tt.prototype._ensure=function(r){if(gn.ok(r),this._size-this._offset<r){var t=this._size*this._options.growthFactor;t-this._offset<r&&(t+=r);var e=pr.alloc(t);this._buf.copy(e,0,0,this._offset),this._buf=e,this._size=t}};var Zo=Tt;(function(r){var t=Mr,e=Kr,n=jo,s=Zo;r.exports={Reader:n,Writer:s};for(var i in e)e.hasOwnProperty(i)&&(r.exports[i]=e[i]);for(var o in t)t.hasOwnProperty(o)&&(r.exports[o]=t[o])})(Oi);var ef=Oi.exports,Wr=ef,Ir={Ber:Wr,BerReader:Wr.Reader,BerWriter:Wr.Writer};function tf(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Qi={exports:{}};(function(r){(function(t){var e=function(l){var E,_=new Float64Array(16);if(l)for(E=0;E<l.length;E++)_[E]=l[E];return _},n=function(){throw new Error("no PRNG")},s=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=e(),f=e([1]),c=e([56129,1]),h=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),g=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),d=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),A=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function I(l,E,_,a){l[E]=_>>24&255,l[E+1]=_>>16&255,l[E+2]=_>>8&255,l[E+3]=_&255,l[E+4]=a>>24&255,l[E+5]=a>>16&255,l[E+6]=a>>8&255,l[E+7]=a&255}function y(l,E,_,a,b){var P,H=0;for(P=0;P<b;P++)H|=l[E+P]^_[a+P];return(1&H-1>>>8)-1}function w(l,E,_,a){return y(l,E,_,a,16)}function R(l,E,_,a){return y(l,E,_,a,32)}function M(l,E,_,a){for(var b=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,P=_[0]&255|(_[1]&255)<<8|(_[2]&255)<<16|(_[3]&255)<<24,H=_[4]&255|(_[5]&255)<<8|(_[6]&255)<<16|(_[7]&255)<<24,ee=_[8]&255|(_[9]&255)<<8|(_[10]&255)<<16|(_[11]&255)<<24,de=_[12]&255|(_[13]&255)<<8|(_[14]&255)<<16|(_[15]&255)<<24,Ie=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,Ee=E[0]&255|(E[1]&255)<<8|(E[2]&255)<<16|(E[3]&255)<<24,at=E[4]&255|(E[5]&255)<<8|(E[6]&255)<<16|(E[7]&255)<<24,be=E[8]&255|(E[9]&255)<<8|(E[10]&255)<<16|(E[11]&255)<<24,He=E[12]&255|(E[13]&255)<<8|(E[14]&255)<<16|(E[15]&255)<<24,Qe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Ye=_[16]&255|(_[17]&255)<<8|(_[18]&255)<<16|(_[19]&255)<<24,$e=_[20]&255|(_[21]&255)<<8|(_[22]&255)<<16|(_[23]&255)<<24,Fe=_[24]&255|(_[25]&255)<<8|(_[26]&255)<<16|(_[27]&255)<<24,Ke=_[28]&255|(_[29]&255)<<8|(_[30]&255)<<16|(_[31]&255)<<24,Me=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,xe=b,Ce=P,pe=H,ye=ee,Se=de,_e=Ie,W=Ee,$=at,ie=be,Z=He,te=Qe,ue=Ye,Te=$e,Xe=Fe,ze=Ke,je=Me,C,et=0;et<20;et+=2)C=xe+Te|0,Se^=C<<7|C>>>32-7,C=Se+xe|0,ie^=C<<9|C>>>32-9,C=ie+Se|0,Te^=C<<13|C>>>32-13,C=Te+ie|0,xe^=C<<18|C>>>32-18,C=_e+Ce|0,Z^=C<<7|C>>>32-7,C=Z+_e|0,Xe^=C<<9|C>>>32-9,C=Xe+Z|0,Ce^=C<<13|C>>>32-13,C=Ce+Xe|0,_e^=C<<18|C>>>32-18,C=te+W|0,ze^=C<<7|C>>>32-7,C=ze+te|0,pe^=C<<9|C>>>32-9,C=pe+ze|0,W^=C<<13|C>>>32-13,C=W+pe|0,te^=C<<18|C>>>32-18,C=je+ue|0,ye^=C<<7|C>>>32-7,C=ye+je|0,$^=C<<9|C>>>32-9,C=$+ye|0,ue^=C<<13|C>>>32-13,C=ue+$|0,je^=C<<18|C>>>32-18,C=xe+ye|0,Ce^=C<<7|C>>>32-7,C=Ce+xe|0,pe^=C<<9|C>>>32-9,C=pe+Ce|0,ye^=C<<13|C>>>32-13,C=ye+pe|0,xe^=C<<18|C>>>32-18,C=_e+Se|0,W^=C<<7|C>>>32-7,C=W+_e|0,$^=C<<9|C>>>32-9,C=$+W|0,Se^=C<<13|C>>>32-13,C=Se+$|0,_e^=C<<18|C>>>32-18,C=te+Z|0,ue^=C<<7|C>>>32-7,C=ue+te|0,ie^=C<<9|C>>>32-9,C=ie+ue|0,Z^=C<<13|C>>>32-13,C=Z+ie|0,te^=C<<18|C>>>32-18,C=je+ze|0,Te^=C<<7|C>>>32-7,C=Te+je|0,Xe^=C<<9|C>>>32-9,C=Xe+Te|0,ze^=C<<13|C>>>32-13,C=ze+Xe|0,je^=C<<18|C>>>32-18;xe=xe+b|0,Ce=Ce+P|0,pe=pe+H|0,ye=ye+ee|0,Se=Se+de|0,_e=_e+Ie|0,W=W+Ee|0,$=$+at|0,ie=ie+be|0,Z=Z+He|0,te=te+Qe|0,ue=ue+Ye|0,Te=Te+$e|0,Xe=Xe+Fe|0,ze=ze+Ke|0,je=je+Me|0,l[0]=xe>>>0&255,l[1]=xe>>>8&255,l[2]=xe>>>16&255,l[3]=xe>>>24&255,l[4]=Ce>>>0&255,l[5]=Ce>>>8&255,l[6]=Ce>>>16&255,l[7]=Ce>>>24&255,l[8]=pe>>>0&255,l[9]=pe>>>8&255,l[10]=pe>>>16&255,l[11]=pe>>>24&255,l[12]=ye>>>0&255,l[13]=ye>>>8&255,l[14]=ye>>>16&255,l[15]=ye>>>24&255,l[16]=Se>>>0&255,l[17]=Se>>>8&255,l[18]=Se>>>16&255,l[19]=Se>>>24&255,l[20]=_e>>>0&255,l[21]=_e>>>8&255,l[22]=_e>>>16&255,l[23]=_e>>>24&255,l[24]=W>>>0&255,l[25]=W>>>8&255,l[26]=W>>>16&255,l[27]=W>>>24&255,l[28]=$>>>0&255,l[29]=$>>>8&255,l[30]=$>>>16&255,l[31]=$>>>24&255,l[32]=ie>>>0&255,l[33]=ie>>>8&255,l[34]=ie>>>16&255,l[35]=ie>>>24&255,l[36]=Z>>>0&255,l[37]=Z>>>8&255,l[38]=Z>>>16&255,l[39]=Z>>>24&255,l[40]=te>>>0&255,l[41]=te>>>8&255,l[42]=te>>>16&255,l[43]=te>>>24&255,l[44]=ue>>>0&255,l[45]=ue>>>8&255,l[46]=ue>>>16&255,l[47]=ue>>>24&255,l[48]=Te>>>0&255,l[49]=Te>>>8&255,l[50]=Te>>>16&255,l[51]=Te>>>24&255,l[52]=Xe>>>0&255,l[53]=Xe>>>8&255,l[54]=Xe>>>16&255,l[55]=Xe>>>24&255,l[56]=ze>>>0&255,l[57]=ze>>>8&255,l[58]=ze>>>16&255,l[59]=ze>>>24&255,l[60]=je>>>0&255,l[61]=je>>>8&255,l[62]=je>>>16&255,l[63]=je>>>24&255}function ce(l,E,_,a){for(var b=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,P=_[0]&255|(_[1]&255)<<8|(_[2]&255)<<16|(_[3]&255)<<24,H=_[4]&255|(_[5]&255)<<8|(_[6]&255)<<16|(_[7]&255)<<24,ee=_[8]&255|(_[9]&255)<<8|(_[10]&255)<<16|(_[11]&255)<<24,de=_[12]&255|(_[13]&255)<<8|(_[14]&255)<<16|(_[15]&255)<<24,Ie=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,Ee=E[0]&255|(E[1]&255)<<8|(E[2]&255)<<16|(E[3]&255)<<24,at=E[4]&255|(E[5]&255)<<8|(E[6]&255)<<16|(E[7]&255)<<24,be=E[8]&255|(E[9]&255)<<8|(E[10]&255)<<16|(E[11]&255)<<24,He=E[12]&255|(E[13]&255)<<8|(E[14]&255)<<16|(E[15]&255)<<24,Qe=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Ye=_[16]&255|(_[17]&255)<<8|(_[18]&255)<<16|(_[19]&255)<<24,$e=_[20]&255|(_[21]&255)<<8|(_[22]&255)<<16|(_[23]&255)<<24,Fe=_[24]&255|(_[25]&255)<<8|(_[26]&255)<<16|(_[27]&255)<<24,Ke=_[28]&255|(_[29]&255)<<8|(_[30]&255)<<16|(_[31]&255)<<24,Me=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,xe=b,Ce=P,pe=H,ye=ee,Se=de,_e=Ie,W=Ee,$=at,ie=be,Z=He,te=Qe,ue=Ye,Te=$e,Xe=Fe,ze=Ke,je=Me,C,et=0;et<20;et+=2)C=xe+Te|0,Se^=C<<7|C>>>32-7,C=Se+xe|0,ie^=C<<9|C>>>32-9,C=ie+Se|0,Te^=C<<13|C>>>32-13,C=Te+ie|0,xe^=C<<18|C>>>32-18,C=_e+Ce|0,Z^=C<<7|C>>>32-7,C=Z+_e|0,Xe^=C<<9|C>>>32-9,C=Xe+Z|0,Ce^=C<<13|C>>>32-13,C=Ce+Xe|0,_e^=C<<18|C>>>32-18,C=te+W|0,ze^=C<<7|C>>>32-7,C=ze+te|0,pe^=C<<9|C>>>32-9,C=pe+ze|0,W^=C<<13|C>>>32-13,C=W+pe|0,te^=C<<18|C>>>32-18,C=je+ue|0,ye^=C<<7|C>>>32-7,C=ye+je|0,$^=C<<9|C>>>32-9,C=$+ye|0,ue^=C<<13|C>>>32-13,C=ue+$|0,je^=C<<18|C>>>32-18,C=xe+ye|0,Ce^=C<<7|C>>>32-7,C=Ce+xe|0,pe^=C<<9|C>>>32-9,C=pe+Ce|0,ye^=C<<13|C>>>32-13,C=ye+pe|0,xe^=C<<18|C>>>32-18,C=_e+Se|0,W^=C<<7|C>>>32-7,C=W+_e|0,$^=C<<9|C>>>32-9,C=$+W|0,Se^=C<<13|C>>>32-13,C=Se+$|0,_e^=C<<18|C>>>32-18,C=te+Z|0,ue^=C<<7|C>>>32-7,C=ue+te|0,ie^=C<<9|C>>>32-9,C=ie+ue|0,Z^=C<<13|C>>>32-13,C=Z+ie|0,te^=C<<18|C>>>32-18,C=je+ze|0,Te^=C<<7|C>>>32-7,C=Te+je|0,Xe^=C<<9|C>>>32-9,C=Xe+Te|0,ze^=C<<13|C>>>32-13,C=ze+Xe|0,je^=C<<18|C>>>32-18;l[0]=xe>>>0&255,l[1]=xe>>>8&255,l[2]=xe>>>16&255,l[3]=xe>>>24&255,l[4]=_e>>>0&255,l[5]=_e>>>8&255,l[6]=_e>>>16&255,l[7]=_e>>>24&255,l[8]=te>>>0&255,l[9]=te>>>8&255,l[10]=te>>>16&255,l[11]=te>>>24&255,l[12]=je>>>0&255,l[13]=je>>>8&255,l[14]=je>>>16&255,l[15]=je>>>24&255,l[16]=W>>>0&255,l[17]=W>>>8&255,l[18]=W>>>16&255,l[19]=W>>>24&255,l[20]=$>>>0&255,l[21]=$>>>8&255,l[22]=$>>>16&255,l[23]=$>>>24&255,l[24]=ie>>>0&255,l[25]=ie>>>8&255,l[26]=ie>>>16&255,l[27]=ie>>>24&255,l[28]=Z>>>0&255,l[29]=Z>>>8&255,l[30]=Z>>>16&255,l[31]=Z>>>24&255}function q(l,E,_,a){M(l,E,_,a)}function le(l,E,_,a){ce(l,E,_,a)}var se=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function fe(l,E,_,a,b,P,H){var ee=new Uint8Array(16),de=new Uint8Array(64),Ie,Ee;for(Ee=0;Ee<16;Ee++)ee[Ee]=0;for(Ee=0;Ee<8;Ee++)ee[Ee]=P[Ee];for(;b>=64;){for(q(de,ee,H,se),Ee=0;Ee<64;Ee++)l[E+Ee]=_[a+Ee]^de[Ee];for(Ie=1,Ee=8;Ee<16;Ee++)Ie=Ie+(ee[Ee]&255)|0,ee[Ee]=Ie&255,Ie>>>=8;b-=64,E+=64,a+=64}if(b>0)for(q(de,ee,H,se),Ee=0;Ee<b;Ee++)l[E+Ee]=_[a+Ee]^de[Ee];return 0}function k(l,E,_,a,b){var P=new Uint8Array(16),H=new Uint8Array(64),ee,de;for(de=0;de<16;de++)P[de]=0;for(de=0;de<8;de++)P[de]=a[de];for(;_>=64;){for(q(H,P,b,se),de=0;de<64;de++)l[E+de]=H[de];for(ee=1,de=8;de<16;de++)ee=ee+(P[de]&255)|0,P[de]=ee&255,ee>>>=8;_-=64,E+=64}if(_>0)for(q(H,P,b,se),de=0;de<_;de++)l[E+de]=H[de];return 0}function v(l,E,_,a,b){var P=new Uint8Array(32);le(P,a,b,se);for(var H=new Uint8Array(8),ee=0;ee<8;ee++)H[ee]=a[ee+16];return k(l,E,_,H,P)}function T(l,E,_,a,b,P,H){var ee=new Uint8Array(32);le(ee,P,H,se);for(var de=new Uint8Array(8),Ie=0;Ie<8;Ie++)de[Ie]=P[Ie+16];return fe(l,E,_,a,b,de,ee)}var J=function(l){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var E,_,a,b,P,H,ee,de;E=l[0]&255|(l[1]&255)<<8,this.r[0]=E&8191,_=l[2]&255|(l[3]&255)<<8,this.r[1]=(E>>>13|_<<3)&8191,a=l[4]&255|(l[5]&255)<<8,this.r[2]=(_>>>10|a<<6)&7939,b=l[6]&255|(l[7]&255)<<8,this.r[3]=(a>>>7|b<<9)&8191,P=l[8]&255|(l[9]&255)<<8,this.r[4]=(b>>>4|P<<12)&255,this.r[5]=P>>>1&8190,H=l[10]&255|(l[11]&255)<<8,this.r[6]=(P>>>14|H<<2)&8191,ee=l[12]&255|(l[13]&255)<<8,this.r[7]=(H>>>11|ee<<5)&8065,de=l[14]&255|(l[15]&255)<<8,this.r[8]=(ee>>>8|de<<8)&8191,this.r[9]=de>>>5&127,this.pad[0]=l[16]&255|(l[17]&255)<<8,this.pad[1]=l[18]&255|(l[19]&255)<<8,this.pad[2]=l[20]&255|(l[21]&255)<<8,this.pad[3]=l[22]&255|(l[23]&255)<<8,this.pad[4]=l[24]&255|(l[25]&255)<<8,this.pad[5]=l[26]&255|(l[27]&255)<<8,this.pad[6]=l[28]&255|(l[29]&255)<<8,this.pad[7]=l[30]&255|(l[31]&255)<<8};J.prototype.blocks=function(l,E,_){for(var a=this.fin?0:2048,b,P,H,ee,de,Ie,Ee,at,be,He,Qe,Ye,$e,Fe,Ke,Me,xe,Ce,pe,ye=this.h[0],Se=this.h[1],_e=this.h[2],W=this.h[3],$=this.h[4],ie=this.h[5],Z=this.h[6],te=this.h[7],ue=this.h[8],Te=this.h[9],Xe=this.r[0],ze=this.r[1],je=this.r[2],C=this.r[3],et=this.r[4],ct=this.r[5],ht=this.r[6],Ze=this.r[7],st=this.r[8],ot=this.r[9];_>=16;)b=l[E+0]&255|(l[E+1]&255)<<8,ye+=b&8191,P=l[E+2]&255|(l[E+3]&255)<<8,Se+=(b>>>13|P<<3)&8191,H=l[E+4]&255|(l[E+5]&255)<<8,_e+=(P>>>10|H<<6)&8191,ee=l[E+6]&255|(l[E+7]&255)<<8,W+=(H>>>7|ee<<9)&8191,de=l[E+8]&255|(l[E+9]&255)<<8,$+=(ee>>>4|de<<12)&8191,ie+=de>>>1&8191,Ie=l[E+10]&255|(l[E+11]&255)<<8,Z+=(de>>>14|Ie<<2)&8191,Ee=l[E+12]&255|(l[E+13]&255)<<8,te+=(Ie>>>11|Ee<<5)&8191,at=l[E+14]&255|(l[E+15]&255)<<8,ue+=(Ee>>>8|at<<8)&8191,Te+=at>>>5|a,be=0,He=be,He+=ye*Xe,He+=Se*(5*ot),He+=_e*(5*st),He+=W*(5*Ze),He+=$*(5*ht),be=He>>>13,He&=8191,He+=ie*(5*ct),He+=Z*(5*et),He+=te*(5*C),He+=ue*(5*je),He+=Te*(5*ze),be+=He>>>13,He&=8191,Qe=be,Qe+=ye*ze,Qe+=Se*Xe,Qe+=_e*(5*ot),Qe+=W*(5*st),Qe+=$*(5*Ze),be=Qe>>>13,Qe&=8191,Qe+=ie*(5*ht),Qe+=Z*(5*ct),Qe+=te*(5*et),Qe+=ue*(5*C),Qe+=Te*(5*je),be+=Qe>>>13,Qe&=8191,Ye=be,Ye+=ye*je,Ye+=Se*ze,Ye+=_e*Xe,Ye+=W*(5*ot),Ye+=$*(5*st),be=Ye>>>13,Ye&=8191,Ye+=ie*(5*Ze),Ye+=Z*(5*ht),Ye+=te*(5*ct),Ye+=ue*(5*et),Ye+=Te*(5*C),be+=Ye>>>13,Ye&=8191,$e=be,$e+=ye*C,$e+=Se*je,$e+=_e*ze,$e+=W*Xe,$e+=$*(5*ot),be=$e>>>13,$e&=8191,$e+=ie*(5*st),$e+=Z*(5*Ze),$e+=te*(5*ht),$e+=ue*(5*ct),$e+=Te*(5*et),be+=$e>>>13,$e&=8191,Fe=be,Fe+=ye*et,Fe+=Se*C,Fe+=_e*je,Fe+=W*ze,Fe+=$*Xe,be=Fe>>>13,Fe&=8191,Fe+=ie*(5*ot),Fe+=Z*(5*st),Fe+=te*(5*Ze),Fe+=ue*(5*ht),Fe+=Te*(5*ct),be+=Fe>>>13,Fe&=8191,Ke=be,Ke+=ye*ct,Ke+=Se*et,Ke+=_e*C,Ke+=W*je,Ke+=$*ze,be=Ke>>>13,Ke&=8191,Ke+=ie*Xe,Ke+=Z*(5*ot),Ke+=te*(5*st),Ke+=ue*(5*Ze),Ke+=Te*(5*ht),be+=Ke>>>13,Ke&=8191,Me=be,Me+=ye*ht,Me+=Se*ct,Me+=_e*et,Me+=W*C,Me+=$*je,be=Me>>>13,Me&=8191,Me+=ie*ze,Me+=Z*Xe,Me+=te*(5*ot),Me+=ue*(5*st),Me+=Te*(5*Ze),be+=Me>>>13,Me&=8191,xe=be,xe+=ye*Ze,xe+=Se*ht,xe+=_e*ct,xe+=W*et,xe+=$*C,be=xe>>>13,xe&=8191,xe+=ie*je,xe+=Z*ze,xe+=te*Xe,xe+=ue*(5*ot),xe+=Te*(5*st),be+=xe>>>13,xe&=8191,Ce=be,Ce+=ye*st,Ce+=Se*Ze,Ce+=_e*ht,Ce+=W*ct,Ce+=$*et,be=Ce>>>13,Ce&=8191,Ce+=ie*C,Ce+=Z*je,Ce+=te*ze,Ce+=ue*Xe,Ce+=Te*(5*ot),be+=Ce>>>13,Ce&=8191,pe=be,pe+=ye*ot,pe+=Se*st,pe+=_e*Ze,pe+=W*ht,pe+=$*ct,be=pe>>>13,pe&=8191,pe+=ie*et,pe+=Z*C,pe+=te*je,pe+=ue*ze,pe+=Te*Xe,be+=pe>>>13,pe&=8191,be=(be<<2)+be|0,be=be+He|0,He=be&8191,be=be>>>13,Qe+=be,ye=He,Se=Qe,_e=Ye,W=$e,$=Fe,ie=Ke,Z=Me,te=xe,ue=Ce,Te=pe,E+=16,_-=16;this.h[0]=ye,this.h[1]=Se,this.h[2]=_e,this.h[3]=W,this.h[4]=$,this.h[5]=ie,this.h[6]=Z,this.h[7]=te,this.h[8]=ue,this.h[9]=Te},J.prototype.finish=function(l,E){var _=new Uint16Array(10),a,b,P,H;if(this.leftover){for(H=this.leftover,this.buffer[H++]=1;H<16;H++)this.buffer[H]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,H=2;H<10;H++)this.h[H]+=a,a=this.h[H]>>>13,this.h[H]&=8191;for(this.h[0]+=a*5,a=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=a,a=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=a,_[0]=this.h[0]+5,a=_[0]>>>13,_[0]&=8191,H=1;H<10;H++)_[H]=this.h[H]+a,a=_[H]>>>13,_[H]&=8191;for(_[9]-=8192,b=(a^1)-1,H=0;H<10;H++)_[H]&=b;for(b=~b,H=0;H<10;H++)this.h[H]=this.h[H]&b|_[H];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,P=this.h[0]+this.pad[0],this.h[0]=P&65535,H=1;H<8;H++)P=(this.h[H]+this.pad[H]|0)+(P>>>16)|0,this.h[H]=P&65535;l[E+0]=this.h[0]>>>0&255,l[E+1]=this.h[0]>>>8&255,l[E+2]=this.h[1]>>>0&255,l[E+3]=this.h[1]>>>8&255,l[E+4]=this.h[2]>>>0&255,l[E+5]=this.h[2]>>>8&255,l[E+6]=this.h[3]>>>0&255,l[E+7]=this.h[3]>>>8&255,l[E+8]=this.h[4]>>>0&255,l[E+9]=this.h[4]>>>8&255,l[E+10]=this.h[5]>>>0&255,l[E+11]=this.h[5]>>>8&255,l[E+12]=this.h[6]>>>0&255,l[E+13]=this.h[6]>>>8&255,l[E+14]=this.h[7]>>>0&255,l[E+15]=this.h[7]>>>8&255},J.prototype.update=function(l,E,_){var a,b;if(this.leftover){for(b=16-this.leftover,b>_&&(b=_),a=0;a<b;a++)this.buffer[this.leftover+a]=l[E+a];if(_-=b,E+=b,this.leftover+=b,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(_>=16&&(b=_-_%16,this.blocks(l,E,b),E+=b,_-=b),_){for(a=0;a<_;a++)this.buffer[this.leftover+a]=l[E+a];this.leftover+=_}};function X(l,E,_,a,b,P){var H=new J(P);return H.update(_,a,b),H.finish(l,E),0}function he(l,E,_,a,b,P){var H=new Uint8Array(16);return X(H,0,_,a,b,P),w(l,E,H,0)}function ae(l,E,_,a,b){var P;if(_<32)return-1;for(T(l,0,E,0,_,a,b),X(l,16,l,32,_-32,l),P=0;P<16;P++)l[P]=0;return 0}function Ae(l,E,_,a,b){var P,H=new Uint8Array(32);if(_<32||(v(H,0,32,a,b),he(E,16,E,32,_-32,H)!==0))return-1;for(T(l,0,E,0,_,a,b),P=0;P<32;P++)l[P]=0;return 0}function oe(l,E){var _;for(_=0;_<16;_++)l[_]=E[_]|0}function ge(l){var E,_,a=1;for(E=0;E<16;E++)_=l[E]+a+65535,a=Math.floor(_/65536),l[E]=_-a*65536;l[0]+=a-1+37*(a-1)}function Q(l,E,_){for(var a,b=~(_-1),P=0;P<16;P++)a=b&(l[P]^E[P]),l[P]^=a,E[P]^=a}function j(l,E){var _,a,b,P=e(),H=e();for(_=0;_<16;_++)H[_]=E[_];for(ge(H),ge(H),ge(H),a=0;a<2;a++){for(P[0]=H[0]-65517,_=1;_<15;_++)P[_]=H[_]-65535-(P[_-1]>>16&1),P[_-1]&=65535;P[15]=H[15]-32767-(P[14]>>16&1),b=P[15]>>16&1,P[14]&=65535,Q(H,P,1-b)}for(_=0;_<16;_++)l[2*_]=H[_]&255,l[2*_+1]=H[_]>>8}function Y(l,E){var _=new Uint8Array(32),a=new Uint8Array(32);return j(_,l),j(a,E),R(_,0,a,0)}function re(l){var E=new Uint8Array(32);return j(E,l),E[0]&1}function we(l,E){var _;for(_=0;_<16;_++)l[_]=E[2*_]+(E[2*_+1]<<8);l[15]&=32767}function me(l,E,_){for(var a=0;a<16;a++)l[a]=E[a]+_[a]}function ve(l,E,_){for(var a=0;a<16;a++)l[a]=E[a]-_[a]}function Ne(l,E,_){var a,b,P=0,H=0,ee=0,de=0,Ie=0,Ee=0,at=0,be=0,He=0,Qe=0,Ye=0,$e=0,Fe=0,Ke=0,Me=0,xe=0,Ce=0,pe=0,ye=0,Se=0,_e=0,W=0,$=0,ie=0,Z=0,te=0,ue=0,Te=0,Xe=0,ze=0,je=0,C=_[0],et=_[1],ct=_[2],ht=_[3],Ze=_[4],st=_[5],ot=_[6],Ct=_[7],dt=_[8],yt=_[9],St=_[10],wt=_[11],kt=_[12],Pt=_[13],Ot=_[14],Dt=_[15];a=E[0],P+=a*C,H+=a*et,ee+=a*ct,de+=a*ht,Ie+=a*Ze,Ee+=a*st,at+=a*ot,be+=a*Ct,He+=a*dt,Qe+=a*yt,Ye+=a*St,$e+=a*wt,Fe+=a*kt,Ke+=a*Pt,Me+=a*Ot,xe+=a*Dt,a=E[1],H+=a*C,ee+=a*et,de+=a*ct,Ie+=a*ht,Ee+=a*Ze,at+=a*st,be+=a*ot,He+=a*Ct,Qe+=a*dt,Ye+=a*yt,$e+=a*St,Fe+=a*wt,Ke+=a*kt,Me+=a*Pt,xe+=a*Ot,Ce+=a*Dt,a=E[2],ee+=a*C,de+=a*et,Ie+=a*ct,Ee+=a*ht,at+=a*Ze,be+=a*st,He+=a*ot,Qe+=a*Ct,Ye+=a*dt,$e+=a*yt,Fe+=a*St,Ke+=a*wt,Me+=a*kt,xe+=a*Pt,Ce+=a*Ot,pe+=a*Dt,a=E[3],de+=a*C,Ie+=a*et,Ee+=a*ct,at+=a*ht,be+=a*Ze,He+=a*st,Qe+=a*ot,Ye+=a*Ct,$e+=a*dt,Fe+=a*yt,Ke+=a*St,Me+=a*wt,xe+=a*kt,Ce+=a*Pt,pe+=a*Ot,ye+=a*Dt,a=E[4],Ie+=a*C,Ee+=a*et,at+=a*ct,be+=a*ht,He+=a*Ze,Qe+=a*st,Ye+=a*ot,$e+=a*Ct,Fe+=a*dt,Ke+=a*yt,Me+=a*St,xe+=a*wt,Ce+=a*kt,pe+=a*Pt,ye+=a*Ot,Se+=a*Dt,a=E[5],Ee+=a*C,at+=a*et,be+=a*ct,He+=a*ht,Qe+=a*Ze,Ye+=a*st,$e+=a*ot,Fe+=a*Ct,Ke+=a*dt,Me+=a*yt,xe+=a*St,Ce+=a*wt,pe+=a*kt,ye+=a*Pt,Se+=a*Ot,_e+=a*Dt,a=E[6],at+=a*C,be+=a*et,He+=a*ct,Qe+=a*ht,Ye+=a*Ze,$e+=a*st,Fe+=a*ot,Ke+=a*Ct,Me+=a*dt,xe+=a*yt,Ce+=a*St,pe+=a*wt,ye+=a*kt,Se+=a*Pt,_e+=a*Ot,W+=a*Dt,a=E[7],be+=a*C,He+=a*et,Qe+=a*ct,Ye+=a*ht,$e+=a*Ze,Fe+=a*st,Ke+=a*ot,Me+=a*Ct,xe+=a*dt,Ce+=a*yt,pe+=a*St,ye+=a*wt,Se+=a*kt,_e+=a*Pt,W+=a*Ot,$+=a*Dt,a=E[8],He+=a*C,Qe+=a*et,Ye+=a*ct,$e+=a*ht,Fe+=a*Ze,Ke+=a*st,Me+=a*ot,xe+=a*Ct,Ce+=a*dt,pe+=a*yt,ye+=a*St,Se+=a*wt,_e+=a*kt,W+=a*Pt,$+=a*Ot,ie+=a*Dt,a=E[9],Qe+=a*C,Ye+=a*et,$e+=a*ct,Fe+=a*ht,Ke+=a*Ze,Me+=a*st,xe+=a*ot,Ce+=a*Ct,pe+=a*dt,ye+=a*yt,Se+=a*St,_e+=a*wt,W+=a*kt,$+=a*Pt,ie+=a*Ot,Z+=a*Dt,a=E[10],Ye+=a*C,$e+=a*et,Fe+=a*ct,Ke+=a*ht,Me+=a*Ze,xe+=a*st,Ce+=a*ot,pe+=a*Ct,ye+=a*dt,Se+=a*yt,_e+=a*St,W+=a*wt,$+=a*kt,ie+=a*Pt,Z+=a*Ot,te+=a*Dt,a=E[11],$e+=a*C,Fe+=a*et,Ke+=a*ct,Me+=a*ht,xe+=a*Ze,Ce+=a*st,pe+=a*ot,ye+=a*Ct,Se+=a*dt,_e+=a*yt,W+=a*St,$+=a*wt,ie+=a*kt,Z+=a*Pt,te+=a*Ot,ue+=a*Dt,a=E[12],Fe+=a*C,Ke+=a*et,Me+=a*ct,xe+=a*ht,Ce+=a*Ze,pe+=a*st,ye+=a*ot,Se+=a*Ct,_e+=a*dt,W+=a*yt,$+=a*St,ie+=a*wt,Z+=a*kt,te+=a*Pt,ue+=a*Ot,Te+=a*Dt,a=E[13],Ke+=a*C,Me+=a*et,xe+=a*ct,Ce+=a*ht,pe+=a*Ze,ye+=a*st,Se+=a*ot,_e+=a*Ct,W+=a*dt,$+=a*yt,ie+=a*St,Z+=a*wt,te+=a*kt,ue+=a*Pt,Te+=a*Ot,Xe+=a*Dt,a=E[14],Me+=a*C,xe+=a*et,Ce+=a*ct,pe+=a*ht,ye+=a*Ze,Se+=a*st,_e+=a*ot,W+=a*Ct,$+=a*dt,ie+=a*yt,Z+=a*St,te+=a*wt,ue+=a*kt,Te+=a*Pt,Xe+=a*Ot,ze+=a*Dt,a=E[15],xe+=a*C,Ce+=a*et,pe+=a*ct,ye+=a*ht,Se+=a*Ze,_e+=a*st,W+=a*ot,$+=a*Ct,ie+=a*dt,Z+=a*yt,te+=a*St,ue+=a*wt,Te+=a*kt,Xe+=a*Pt,ze+=a*Ot,je+=a*Dt,P+=38*Ce,H+=38*pe,ee+=38*ye,de+=38*Se,Ie+=38*_e,Ee+=38*W,at+=38*$,be+=38*ie,He+=38*Z,Qe+=38*te,Ye+=38*ue,$e+=38*Te,Fe+=38*Xe,Ke+=38*ze,Me+=38*je,b=1,a=P+b+65535,b=Math.floor(a/65536),P=a-b*65536,a=H+b+65535,b=Math.floor(a/65536),H=a-b*65536,a=ee+b+65535,b=Math.floor(a/65536),ee=a-b*65536,a=de+b+65535,b=Math.floor(a/65536),de=a-b*65536,a=Ie+b+65535,b=Math.floor(a/65536),Ie=a-b*65536,a=Ee+b+65535,b=Math.floor(a/65536),Ee=a-b*65536,a=at+b+65535,b=Math.floor(a/65536),at=a-b*65536,a=be+b+65535,b=Math.floor(a/65536),be=a-b*65536,a=He+b+65535,b=Math.floor(a/65536),He=a-b*65536,a=Qe+b+65535,b=Math.floor(a/65536),Qe=a-b*65536,a=Ye+b+65535,b=Math.floor(a/65536),Ye=a-b*65536,a=$e+b+65535,b=Math.floor(a/65536),$e=a-b*65536,a=Fe+b+65535,b=Math.floor(a/65536),Fe=a-b*65536,a=Ke+b+65535,b=Math.floor(a/65536),Ke=a-b*65536,a=Me+b+65535,b=Math.floor(a/65536),Me=a-b*65536,a=xe+b+65535,b=Math.floor(a/65536),xe=a-b*65536,P+=b-1+37*(b-1),b=1,a=P+b+65535,b=Math.floor(a/65536),P=a-b*65536,a=H+b+65535,b=Math.floor(a/65536),H=a-b*65536,a=ee+b+65535,b=Math.floor(a/65536),ee=a-b*65536,a=de+b+65535,b=Math.floor(a/65536),de=a-b*65536,a=Ie+b+65535,b=Math.floor(a/65536),Ie=a-b*65536,a=Ee+b+65535,b=Math.floor(a/65536),Ee=a-b*65536,a=at+b+65535,b=Math.floor(a/65536),at=a-b*65536,a=be+b+65535,b=Math.floor(a/65536),be=a-b*65536,a=He+b+65535,b=Math.floor(a/65536),He=a-b*65536,a=Qe+b+65535,b=Math.floor(a/65536),Qe=a-b*65536,a=Ye+b+65535,b=Math.floor(a/65536),Ye=a-b*65536,a=$e+b+65535,b=Math.floor(a/65536),$e=a-b*65536,a=Fe+b+65535,b=Math.floor(a/65536),Fe=a-b*65536,a=Ke+b+65535,b=Math.floor(a/65536),Ke=a-b*65536,a=Me+b+65535,b=Math.floor(a/65536),Me=a-b*65536,a=xe+b+65535,b=Math.floor(a/65536),xe=a-b*65536,P+=b-1+37*(b-1),l[0]=P,l[1]=H,l[2]=ee,l[3]=de,l[4]=Ie,l[5]=Ee,l[6]=at,l[7]=be,l[8]=He,l[9]=Qe,l[10]=Ye,l[11]=$e,l[12]=Fe,l[13]=Ke,l[14]=Me,l[15]=xe}function Je(l,E){Ne(l,E,E)}function Gt(l,E){var _=e(),a;for(a=0;a<16;a++)_[a]=E[a];for(a=253;a>=0;a--)Je(_,_),a!==2&&a!==4&&Ne(_,_,E);for(a=0;a<16;a++)l[a]=_[a]}function sn(l,E){var _=e(),a;for(a=0;a<16;a++)_[a]=E[a];for(a=250;a>=0;a--)Je(_,_),a!==1&&Ne(_,_,E);for(a=0;a<16;a++)l[a]=_[a]}function on(l,E,_){var a=new Uint8Array(32),b=new Float64Array(80),P,H,ee=e(),de=e(),Ie=e(),Ee=e(),at=e(),be=e();for(H=0;H<31;H++)a[H]=E[H];for(a[31]=E[31]&127|64,a[0]&=248,we(b,_),H=0;H<16;H++)de[H]=b[H],Ee[H]=ee[H]=Ie[H]=0;for(ee[0]=Ee[0]=1,H=254;H>=0;--H)P=a[H>>>3]>>>(H&7)&1,Q(ee,de,P),Q(Ie,Ee,P),me(at,ee,Ie),ve(ee,ee,Ie),me(Ie,de,Ee),ve(de,de,Ee),Je(Ee,at),Je(be,ee),Ne(ee,Ie,ee),Ne(Ie,de,at),me(at,ee,Ie),ve(ee,ee,Ie),Je(de,ee),ve(Ie,Ee,be),Ne(ee,Ie,c),me(ee,ee,Ee),Ne(Ie,Ie,ee),Ne(ee,Ee,be),Ne(Ee,de,b),Je(de,at),Q(ee,de,P),Q(Ie,Ee,P);for(H=0;H<16;H++)b[H+16]=ee[H],b[H+32]=Ie[H],b[H+48]=de[H],b[H+64]=Ee[H];var He=b.subarray(32),Qe=b.subarray(16);return Gt(He,He),Ne(Qe,Qe,He),j(l,Qe),0}function Nt(l,E){return on(l,E,i)}function N(l,E){return n(E,32),Nt(l,E)}function S(l,E,_){var a=new Uint8Array(32);return on(a,_,E),le(l,s,a,se)}var p=ae,O=Ae;function ne(l,E,_,a,b,P){var H=new Uint8Array(32);return S(H,b,P),p(l,E,_,a,H)}function F(l,E,_,a,b,P){var H=new Uint8Array(32);return S(H,b,P),O(l,E,_,a,H)}var m=[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 B(l,E,_,a){for(var b=new Int32Array(16),P=new Int32Array(16),H,ee,de,Ie,Ee,at,be,He,Qe,Ye,$e,Fe,Ke,Me,xe,Ce,pe,ye,Se,_e,W,$,ie,Z,te,ue,Te=l[0],Xe=l[1],ze=l[2],je=l[3],C=l[4],et=l[5],ct=l[6],ht=l[7],Ze=E[0],st=E[1],ot=E[2],Ct=E[3],dt=E[4],yt=E[5],St=E[6],wt=E[7],kt=0;a>=128;){for(Se=0;Se<16;Se++)_e=8*Se+kt,b[Se]=_[_e+0]<<24|_[_e+1]<<16|_[_e+2]<<8|_[_e+3],P[Se]=_[_e+4]<<24|_[_e+5]<<16|_[_e+6]<<8|_[_e+7];for(Se=0;Se<80;Se++)if(H=Te,ee=Xe,de=ze,Ie=je,Ee=C,at=et,be=ct,He=ht,Qe=Ze,Ye=st,$e=ot,Fe=Ct,Ke=dt,Me=yt,xe=St,Ce=wt,W=ht,$=wt,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=(C>>>14|dt<<32-14)^(C>>>18|dt<<32-18)^(dt>>>41-32|C<<32-(41-32)),$=(dt>>>14|C<<32-14)^(dt>>>18|C<<32-18)^(C>>>41-32|dt<<32-(41-32)),ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,W=C&et^~C&ct,$=dt&yt^~dt&St,ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,W=m[Se*2],$=m[Se*2+1],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,W=b[Se%16],$=P[Se%16],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,pe=te&65535|ue<<16,ye=ie&65535|Z<<16,W=pe,$=ye,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=(Te>>>28|Ze<<32-28)^(Ze>>>34-32|Te<<32-(34-32))^(Ze>>>39-32|Te<<32-(39-32)),$=(Ze>>>28|Te<<32-28)^(Te>>>34-32|Ze<<32-(34-32))^(Te>>>39-32|Ze<<32-(39-32)),ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,W=Te&Xe^Te&ze^Xe&ze,$=Ze&st^Ze&ot^st&ot,ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,He=te&65535|ue<<16,Ce=ie&65535|Z<<16,W=Ie,$=Fe,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=pe,$=ye,ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,Ie=te&65535|ue<<16,Fe=ie&65535|Z<<16,Xe=H,ze=ee,je=de,C=Ie,et=Ee,ct=at,ht=be,Te=He,st=Qe,ot=Ye,Ct=$e,dt=Fe,yt=Ke,St=Me,wt=xe,Ze=Ce,Se%16===15)for(_e=0;_e<16;_e++)W=b[_e],$=P[_e],ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=b[(_e+9)%16],$=P[(_e+9)%16],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,pe=b[(_e+1)%16],ye=P[(_e+1)%16],W=(pe>>>1|ye<<32-1)^(pe>>>8|ye<<32-8)^pe>>>7,$=(ye>>>1|pe<<32-1)^(ye>>>8|pe<<32-8)^(ye>>>7|pe<<32-7),ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,pe=b[(_e+14)%16],ye=P[(_e+14)%16],W=(pe>>>19|ye<<32-19)^(ye>>>61-32|pe<<32-(61-32))^pe>>>6,$=(ye>>>19|pe<<32-19)^(pe>>>61-32|ye<<32-(61-32))^(ye>>>6|pe<<32-6),ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,b[_e]=te&65535|ue<<16,P[_e]=ie&65535|Z<<16;W=Te,$=Ze,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=l[0],$=E[0],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,l[0]=Te=te&65535|ue<<16,E[0]=Ze=ie&65535|Z<<16,W=Xe,$=st,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=l[1],$=E[1],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,l[1]=Xe=te&65535|ue<<16,E[1]=st=ie&65535|Z<<16,W=ze,$=ot,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=l[2],$=E[2],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,l[2]=ze=te&65535|ue<<16,E[2]=ot=ie&65535|Z<<16,W=je,$=Ct,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=l[3],$=E[3],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,l[3]=je=te&65535|ue<<16,E[3]=Ct=ie&65535|Z<<16,W=C,$=dt,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=l[4],$=E[4],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,l[4]=C=te&65535|ue<<16,E[4]=dt=ie&65535|Z<<16,W=et,$=yt,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=l[5],$=E[5],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,l[5]=et=te&65535|ue<<16,E[5]=yt=ie&65535|Z<<16,W=ct,$=St,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=l[6],$=E[6],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,l[6]=ct=te&65535|ue<<16,E[6]=St=ie&65535|Z<<16,W=ht,$=wt,ie=$&65535,Z=$>>>16,te=W&65535,ue=W>>>16,W=l[7],$=E[7],ie+=$&65535,Z+=$>>>16,te+=W&65535,ue+=W>>>16,Z+=ie>>>16,te+=Z>>>16,ue+=te>>>16,l[7]=ht=te&65535|ue<<16,E[7]=wt=ie&65535|Z<<16,kt+=128,a-=128}return a}function x(l,E,_){var a=new Int32Array(8),b=new Int32Array(8),P=new Uint8Array(256),H,ee=_;for(a[0]=1779033703,a[1]=3144134277,a[2]=1013904242,a[3]=2773480762,a[4]=1359893119,a[5]=2600822924,a[6]=528734635,a[7]=1541459225,b[0]=4089235720,b[1]=2227873595,b[2]=4271175723,b[3]=1595750129,b[4]=2917565137,b[5]=725511199,b[6]=4215389547,b[7]=327033209,B(a,b,E,_),_%=128,H=0;H<_;H++)P[H]=E[ee-_+H];for(P[_]=128,_=256-128*(_<112?1:0),P[_-9]=0,I(P,_-8,ee/536870912|0,ee<<3),B(a,b,P,_),H=0;H<8;H++)I(l,8*H,a[H],b[H]);return 0}function K(l,E){var _=e(),a=e(),b=e(),P=e(),H=e(),ee=e(),de=e(),Ie=e(),Ee=e();ve(_,l[1],l[0]),ve(Ee,E[1],E[0]),Ne(_,_,Ee),me(a,l[0],l[1]),me(Ee,E[0],E[1]),Ne(a,a,Ee),Ne(b,l[3],E[3]),Ne(b,b,g),Ne(P,l[2],E[2]),me(P,P,P),ve(H,a,_),ve(ee,P,b),me(de,P,b),me(Ie,a,_),Ne(l[0],H,ee),Ne(l[1],Ie,de),Ne(l[2],de,ee),Ne(l[3],H,Ie)}function z(l,E,_){var a;for(a=0;a<4;a++)Q(l[a],E[a],_)}function V(l,E){var _=e(),a=e(),b=e();Gt(b,E[2]),Ne(_,E[0],b),Ne(a,E[1],b),j(l,a),l[31]^=re(_)<<7}function We(l,E,_){var a,b;for(oe(l[0],o),oe(l[1],f),oe(l[2],f),oe(l[3],o),b=255;b>=0;--b)a=_[b/8|0]>>(b&7)&1,z(l,E,a),K(E,l),K(l,l),z(l,E,a)}function rt(l,E){var _=[e(),e(),e(),e()];oe(_[0],u),oe(_[1],d),oe(_[2],f),Ne(_[3],u,d),We(l,_,E)}function mt(l,E,_){var a=new Uint8Array(64),b=[e(),e(),e(),e()],P;for(_||n(E,32),x(a,E,32),a[0]&=248,a[31]&=127,a[31]|=64,rt(b,a),V(l,b),P=0;P<32;P++)E[P+32]=l[P];return 0}var De=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function gt(l,E){var _,a,b,P;for(a=63;a>=32;--a){for(_=0,b=a-32,P=a-12;b<P;++b)E[b]+=_-16*E[a]*De[b-(a-32)],_=E[b]+128>>8,E[b]-=_*256;E[b]+=_,E[a]=0}for(_=0,b=0;b<32;b++)E[b]+=_-(E[31]>>4)*De[b],_=E[b]>>8,E[b]&=255;for(b=0;b<32;b++)E[b]-=_*De[b];for(a=0;a<32;a++)E[a+1]+=E[a]>>8,l[a]=E[a]&255}function At(l){var E=new Float64Array(64),_;for(_=0;_<64;_++)E[_]=l[_];for(_=0;_<64;_++)l[_]=0;gt(l,E)}function ut(l,E,_,a){var b=new Uint8Array(64),P=new Uint8Array(64),H=new Uint8Array(64),ee,de,Ie=new Float64Array(64),Ee=[e(),e(),e(),e()];x(b,a,32),b[0]&=248,b[31]&=127,b[31]|=64;var at=_+64;for(ee=0;ee<_;ee++)l[64+ee]=E[ee];for(ee=0;ee<32;ee++)l[32+ee]=b[32+ee];for(x(H,l.subarray(32),_+32),At(H),rt(Ee,H),V(l,Ee),ee=32;ee<64;ee++)l[ee]=a[ee];for(x(P,l,_+64),At(P),ee=0;ee<64;ee++)Ie[ee]=0;for(ee=0;ee<32;ee++)Ie[ee]=H[ee];for(ee=0;ee<32;ee++)for(de=0;de<32;de++)Ie[ee+de]+=P[ee]*b[de];return gt(l.subarray(32),Ie),at}function qe(l,E){var _=e(),a=e(),b=e(),P=e(),H=e(),ee=e(),de=e();return oe(l[2],f),we(l[1],E),Je(b,l[1]),Ne(P,b,h),ve(b,b,l[2]),me(P,l[2],P),Je(H,P),Je(ee,H),Ne(de,ee,H),Ne(_,de,b),Ne(_,_,P),sn(_,_),Ne(_,_,b),Ne(_,_,P),Ne(_,_,P),Ne(l[0],_,P),Je(a,l[0]),Ne(a,a,P),Y(a,b)&&Ne(l[0],l[0],A),Je(a,l[0]),Ne(a,a,P),Y(a,b)?-1:(re(l[0])===E[31]>>7&&ve(l[0],o,l[0]),Ne(l[3],l[0],l[1]),0)}function Ge(l,E,_,a){var b,P,H=new Uint8Array(32),ee=new Uint8Array(64),de=[e(),e(),e(),e()],Ie=[e(),e(),e(),e()];if(P=-1,_<64||qe(Ie,a))return-1;for(b=0;b<_;b++)l[b]=E[b];for(b=0;b<32;b++)l[b+32]=a[b];if(x(ee,l,_),At(ee),We(de,Ie,ee),rt(Ie,E.subarray(32)),K(de,Ie),V(H,de),_-=64,R(E,0,H,0)){for(b=0;b<_;b++)l[b]=0;return-1}for(b=0;b<_;b++)l[b]=E[b+64];return P=_,P}var Ve=32,vt=24,Mt=32,It=16,xt=32,qt=32,dn=32,fn=32,vn=32,Ar=vt,Ut=Mt,gr=It,An=64,Tn=32,Gn=64,Ui=32,Pi=64;t.lowlevel={crypto_core_hsalsa20:le,crypto_stream_xor:T,crypto_stream:v,crypto_stream_salsa20_xor:fe,crypto_stream_salsa20:k,crypto_onetimeauth:X,crypto_onetimeauth_verify:he,crypto_verify_16:w,crypto_verify_32:R,crypto_secretbox:ae,crypto_secretbox_open:Ae,crypto_scalarmult:on,crypto_scalarmult_base:Nt,crypto_box_beforenm:S,crypto_box_afternm:p,crypto_box:ne,crypto_box_open:F,crypto_box_keypair:N,crypto_hash:x,crypto_sign:ut,crypto_sign_keypair:mt,crypto_sign_open:Ge,crypto_secretbox_KEYBYTES:Ve,crypto_secretbox_NONCEBYTES:vt,crypto_secretbox_ZEROBYTES:Mt,crypto_secretbox_BOXZEROBYTES:It,crypto_scalarmult_BYTES:xt,crypto_scalarmult_SCALARBYTES:qt,crypto_box_PUBLICKEYBYTES:dn,crypto_box_SECRETKEYBYTES:fn,crypto_box_BEFORENMBYTES:vn,crypto_box_NONCEBYTES:Ar,crypto_box_ZEROBYTES:Ut,crypto_box_BOXZEROBYTES:gr,crypto_sign_BYTES:An,crypto_sign_PUBLICKEYBYTES:Tn,crypto_sign_SECRETKEYBYTES:Gn,crypto_sign_SEEDBYTES:Ui,crypto_hash_BYTES:Pi};function vo(l,E){if(l.length!==Ve)throw new Error("bad key size");if(E.length!==vt)throw new Error("bad nonce size")}function Sh(l,E){if(l.length!==dn)throw new Error("bad public key size");if(E.length!==fn)throw new Error("bad secret key size")}function Yt(){var l,E;for(E=0;E<arguments.length;E++)if((l=Object.prototype.toString.call(arguments[E]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+l+", use Uint8Array")}function To(l){for(var E=0;E<l.length;E++)l[E]=0}t.util||(t.util={},t.util.decodeUTF8=t.util.encodeUTF8=t.util.encodeBase64=t.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),t.randomBytes=function(l){var E=new Uint8Array(l);return n(E,l),E},t.secretbox=function(l,E,_){Yt(l,E,_),vo(_,E);for(var a=new Uint8Array(Mt+l.length),b=new Uint8Array(a.length),P=0;P<l.length;P++)a[P+Mt]=l[P];return ae(b,a,a.length,E,_),b.subarray(It)},t.secretbox.open=function(l,E,_){Yt(l,E,_),vo(_,E);for(var a=new Uint8Array(It+l.length),b=new Uint8Array(a.length),P=0;P<l.length;P++)a[P+It]=l[P];return a.length<32||Ae(b,a,a.length,E,_)!==0?!1:b.subarray(Mt)},t.secretbox.keyLength=Ve,t.secretbox.nonceLength=vt,t.secretbox.overheadLength=It,t.scalarMult=function(l,E){if(Yt(l,E),l.length!==qt)throw new Error("bad n size");if(E.length!==xt)throw new Error("bad p size");var _=new Uint8Array(xt);return on(_,l,E),_},t.scalarMult.base=function(l){if(Yt(l),l.length!==qt)throw new Error("bad n size");var E=new Uint8Array(xt);return Nt(E,l),E},t.scalarMult.scalarLength=qt,t.scalarMult.groupElementLength=xt,t.box=function(l,E,_,a){var b=t.box.before(_,a);return t.secretbox(l,E,b)},t.box.before=function(l,E){Yt(l,E),Sh(l,E);var _=new Uint8Array(vn);return S(_,l,E),_},t.box.after=t.secretbox,t.box.open=function(l,E,_,a){var b=t.box.before(_,a);return t.secretbox.open(l,E,b)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var l=new Uint8Array(dn),E=new Uint8Array(fn);return N(l,E),{publicKey:l,secretKey:E}},t.box.keyPair.fromSecretKey=function(l){if(Yt(l),l.length!==fn)throw new Error("bad secret key size");var E=new Uint8Array(dn);return Nt(E,l),{publicKey:E,secretKey:new Uint8Array(l)}},t.box.publicKeyLength=dn,t.box.secretKeyLength=fn,t.box.sharedKeyLength=vn,t.box.nonceLength=Ar,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(l,E){if(Yt(l,E),E.length!==Gn)throw new Error("bad secret key size");var _=new Uint8Array(An+l.length);return ut(_,l,l.length,E),_},t.sign.open=function(l,E){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(Yt(l,E),E.length!==Tn)throw new Error("bad public key size");var _=new Uint8Array(l.length),a=Ge(_,l,l.length,E);if(a<0)return null;for(var b=new Uint8Array(a),P=0;P<b.length;P++)b[P]=_[P];return b},t.sign.detached=function(l,E){for(var _=t.sign(l,E),a=new Uint8Array(An),b=0;b<a.length;b++)a[b]=_[b];return a},t.sign.detached.verify=function(l,E,_){if(Yt(l,E,_),E.length!==An)throw new Error("bad signature size");if(_.length!==Tn)throw new Error("bad public key size");var a=new Uint8Array(An+l.length),b=new Uint8Array(An+l.length),P;for(P=0;P<An;P++)a[P]=E[P];for(P=0;P<l.length;P++)a[P+An]=l[P];return Ge(b,a,a.length,_)>=0},t.sign.keyPair=function(){var l=new Uint8Array(Tn),E=new Uint8Array(Gn);return mt(l,E),{publicKey:l,secretKey:E}},t.sign.keyPair.fromSecretKey=function(l){if(Yt(l),l.length!==Gn)throw new Error("bad secret key size");for(var E=new Uint8Array(Tn),_=0;_<E.length;_++)E[_]=l[32+_];return{publicKey:E,secretKey:new Uint8Array(l)}},t.sign.keyPair.fromSeed=function(l){if(Yt(l),l.length!==Ui)throw new Error("bad seed size");for(var E=new Uint8Array(Tn),_=new Uint8Array(Gn),a=0;a<32;a++)_[a]=l[a];return mt(E,_,!0),{publicKey:E,secretKey:_}},t.sign.publicKeyLength=Tn,t.sign.secretKeyLength=Gn,t.sign.seedLength=Ui,t.sign.signatureLength=An,t.hash=function(l){Yt(l);var E=new Uint8Array(Pi);return x(E,l,l.length),E},t.hash.hashLength=Pi,t.verify=function(l,E){return Yt(l,E),l.length===0||E.length===0||l.length!==E.length?!1:y(l,0,E,0,l.length)===0},t.setPRNG=function(l){n=l},function(){var l=typeof self<"u"?self.crypto||self.msCrypto:null;if(l&&l.getRandomValues){var E=65536;t.setPRNG(function(_,a){var b,P=new Uint8Array(a);for(b=0;b<a;b+=E)l.getRandomValues(P.subarray(b,b+Math.min(a-b,E)));for(b=0;b<a;b++)_[b]=P[b];To(P)})}else typeof tf<"u"&&(l=tt,l&&l.randomBytes&&t.setPRNG(function(_,a){var b,P=l.randomBytes(a);for(b=0;b<a;b++)_[b]=P[b];To(P)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(Qi);var nf=Qi.exports,$r=nf.lowlevel.crypto_hash,an=0,mn=function(){this.S=[new Uint32Array([3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946]),new Uint32Array([1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055]),new Uint32Array([3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504]),new Uint32Array([976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462])],this.P=new Uint32Array([608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731])};function xr(r,t,e){return(r[0][t[e+3]]+r[1][t[e+2]]^r[2][t[e+1]])+r[3][t[e]]}mn.prototype.encipher=function(r,t){t===void 0&&(t=new Uint8Array(r.buffer),r.byteOffset!==0&&(t=t.subarray(r.byteOffset))),r[0]^=this.P[0];for(var e=1;e<16;e+=2)r[1]^=xr(this.S,t,0)^this.P[e],r[0]^=xr(this.S,t,4)^this.P[e+1];var n=r[0];r[0]=r[1]^this.P[17],r[1]=n},mn.prototype.decipher=function(r){var t=new Uint8Array(r.buffer);r.byteOffset!==0&&(t=t.subarray(r.byteOffset)),r[0]^=this.P[17];for(var e=16;e>0;e-=2)r[1]^=xr(this.S,t,0)^this.P[e],r[0]^=xr(this.S,t,4)^this.P[e-1];var n=r[0];r[0]=r[1]^this.P[0],r[1]=n};function Cn(r,t){var e,n=0;for(e=0;e<4;e++,an++)an>=t&&(an=0),n=n<<8|r[an];return n}mn.prototype.expand0state=function(r,t){var e=new Uint32Array(2),n,s,i=new Uint8Array(e.buffer);for(n=0,an=0;n<18;n++)this.P[n]^=Cn(r,t);for(an=0,n=0;n<18;n+=2)this.encipher(e,i),this.P[n]=e[0],this.P[n+1]=e[1];for(n=0;n<4;n++)for(s=0;s<256;s+=2)this.encipher(e,i),this.S[n][s]=e[0],this.S[n][s+1]=e[1]},mn.prototype.expandstate=function(r,t,e,n){var s=new Uint32Array(2),i,o;for(i=0,an=0;i<18;i++)this.P[i]^=Cn(e,n);for(i=0,an=0;i<18;i+=2)s[0]^=Cn(r,t),s[1]^=Cn(r,t),this.encipher(s),this.P[i]=s[0],this.P[i+1]=s[1];for(i=0;i<4;i++)for(o=0;o<256;o+=2)s[0]^=Cn(r,t),s[1]^=Cn(r,t),this.encipher(s),this.S[i][o]=s[0],this.S[i][o+1]=s[1];an=0},mn.prototype.enc=function(r,t){for(var e=0;e<t;e++)this.encipher(r.subarray(e*2))},mn.prototype.dec=function(r,t){for(var e=0;e<t;e++)this.decipher(r.subarray(e*2))};var yr=8,qr=32;function Gr(r,t,e){var n=new mn,s=new Uint32Array(yr),i,o=new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,105,116,101]);for(n.expandstate(t,64,r,64),i=0;i<64;i++)n.expand0state(t,64),n.expand0state(r,64);for(i=0;i<yr;i++)s[i]=Cn(o,o.byteLength);for(i=0;i<64;i++)n.enc(s,s.byteLength/8);for(i=0;i<yr;i++)e[4*i+3]=s[i]>>>24,e[4*i+2]=s[i]>>>16,e[4*i+1]=s[i]>>>8,e[4*i+0]=s[i]}function rf(r,t,e,n,s,i,o){var f=new Uint8Array(64),c=new Uint8Array(64),h=new Uint8Array(qr),g=new Uint8Array(qr),u=new Uint8Array(n+4),d,A,I,y,w,R,M=i;if(o<1||t===0||n===0||i===0||i>h.byteLength*h.byteLength||n>1<<20)return-1;for(y=Math.floor((i+h.byteLength-1)/h.byteLength),I=Math.floor((i+y-1)/y),d=0;d<n;d++)u[d]=e[d];for($r(f,r,t),R=1;i>0;R++){for(u[n+0]=R>>>24,u[n+1]=R>>>16,u[n+2]=R>>>8,u[n+3]=R,$r(c,u,n+4),Gr(f,c,g),d=h.byteLength;d--;)h[d]=g[d];for(d=1;d<o;d++)for($r(c,g,g.byteLength),Gr(f,c,g),A=0;A<h.byteLength;A++)h[A]^=g[A];for(I=Math.min(I,i),d=0;d<I&&(w=d*y+(R-1),!(w>=M));d++)s[w]=h[d];i-=d}return 0}var Fi={BLOCKS:yr,HASHSIZE:qr,hash:Gr,pbkdf:rf},Yr={exports:{}},Mi;function En(){return Mi||(Mi=1,function(r){const t=tt;let e;try{e=require("cpu-features")()}catch{}const{bindingAvailable:n,CIPHER_INFO:s,MAC_INFO:i}=Bn(),o=(()=>{if(typeof t.sign=="function"&&typeof t.verify=="function"){const le=`-----BEGIN PRIVATE KEY-----\r
3
+ MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
4
+ -----END PRIVATE KEY-----`,se=Buffer.from("a");let fe,k;try{fe=t.sign(null,se,le),k=t.verify(null,se,le,fe)}catch{}return Buffer.isBuffer(fe)&&fe.length===64&&k===!0}return!1})(),f=typeof t.diffieHellman=="function"&&typeof t.generateKeyPairSync=="function"&&typeof t.createPublicKey=="function",c=["ecdh-sha2-nistp256","ecdh-sha2-nistp384","ecdh-sha2-nistp521","diffie-hellman-group-exchange-sha256","diffie-hellman-group14-sha256","diffie-hellman-group15-sha512","diffie-hellman-group16-sha512","diffie-hellman-group17-sha512","diffie-hellman-group18-sha512"];f&&(c.unshift("curve25519-sha256"),c.unshift("curve25519-sha256@libssh.org"));const h=c.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),g=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];o&&g.unshift("ssh-ed25519");const u=g.concat(["ssh-dss"]),d=(()=>{const le=t.getCiphers();return se=>le.includes(s[se].sslName)})();let A=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];e&&e.flags&&!e.flags.aes?n?A.unshift("chacha20-poly1305@openssh.com"):A.push("chacha20-poly1305@openssh.com"):n&&e&&e.arch==="x86"?A.splice(4,0,"chacha20-poly1305@openssh.com"):A.push("chacha20-poly1305@openssh.com"),A=A.filter(d);const I=A.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(d)),y=(()=>{const le=t.getHashes();return se=>le.includes(i[se].sslName)})(),w=["hmac-sha2-256-etm@openssh.com","hmac-sha2-512-etm@openssh.com","hmac-sha1-etm@openssh.com","hmac-sha2-256","hmac-sha2-512","hmac-sha1"].filter(y),R=w.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(y)),M=["none","zlib@openssh.com","zlib"],ce=M.concat([]),q={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};r.exports={MESSAGE:{DISCONNECT:1,IGNORE:2,UNIMPLEMENTED:3,DEBUG:4,SERVICE_REQUEST:5,SERVICE_ACCEPT:6,EXT_INFO:7,KEXINIT:20,NEWKEYS:21,KEXDH_INIT:30,KEXDH_REPLY:31,KEXDH_GEX_GROUP:31,KEXDH_GEX_INIT:32,KEXDH_GEX_REPLY:33,KEXDH_GEX_REQUEST:34,KEXECDH_INIT:30,KEXECDH_REPLY:31,USERAUTH_REQUEST:50,USERAUTH_FAILURE:51,USERAUTH_SUCCESS:52,USERAUTH_BANNER:53,USERAUTH_PASSWD_CHANGEREQ:60,USERAUTH_PK_OK:60,USERAUTH_INFO_REQUEST:60,USERAUTH_INFO_RESPONSE:61,GLOBAL_REQUEST:80,REQUEST_SUCCESS:81,REQUEST_FAILURE:82,CHANNEL_OPEN:90,CHANNEL_OPEN_CONFIRMATION:91,CHANNEL_OPEN_FAILURE:92,CHANNEL_WINDOW_ADJUST:93,CHANNEL_DATA:94,CHANNEL_EXTENDED_DATA:95,CHANNEL_EOF:96,CHANNEL_CLOSE:97,CHANNEL_REQUEST:98,CHANNEL_SUCCESS:99,CHANNEL_FAILURE:100},DISCONNECT_REASON:{HOST_NOT_ALLOWED_TO_CONNECT:1,PROTOCOL_ERROR:2,KEY_EXCHANGE_FAILED:3,RESERVED:4,MAC_ERROR:5,COMPRESSION_ERROR:6,SERVICE_NOT_AVAILABLE:7,PROTOCOL_VERSION_NOT_SUPPORTED:8,HOST_KEY_NOT_VERIFIABLE:9,CONNECTION_LOST:10,BY_APPLICATION:11,TOO_MANY_CONNECTIONS:12,AUTH_CANCELED_BY_USER:13,NO_MORE_AUTH_METHODS_AVAILABLE:14,ILLEGAL_USER_NAME:15},DISCONNECT_REASON_STR:void 0,CHANNEL_OPEN_FAILURE:{ADMINISTRATIVELY_PROHIBITED:1,CONNECT_FAILED:2,UNKNOWN_CHANNEL_TYPE:3,RESOURCE_SHORTAGE:4},TERMINAL_MODE:{TTY_OP_END:0,VINTR:1,VQUIT:2,VERASE:3,VKILL:4,VEOF:5,VEOL:6,VEOL2:7,VSTART:8,VSTOP:9,VSUSP:10,VDSUSP:11,VREPRINT:12,VWERASE:13,VLNEXT:14,VFLUSH:15,VSWTCH:16,VSTATUS:17,VDISCARD:18,IGNPAR:30,PARMRK:31,INPCK:32,ISTRIP:33,INLCR:34,IGNCR:35,ICRNL:36,IUCLC:37,IXON:38,IXANY:39,IXOFF:40,IMAXBEL:41,ISIG:50,ICANON:51,XCASE:52,ECHO:53,ECHOE:54,ECHOK:55,ECHONL:56,NOFLSH:57,TOSTOP:58,IEXTEN:59,ECHOCTL:60,ECHOKE:61,PENDIN:62,OPOST:70,OLCUC:71,ONLCR:72,OCRNL:73,ONOCR:74,ONLRET:75,CS7:90,CS8:91,PARENB:92,PARODD:93,TTY_OP_ISPEED:128,TTY_OP_OSPEED:129},CHANNEL_EXTENDED_DATATYPE:{STDERR:1},SIGNALS:["ABRT","ALRM","FPE","HUP","ILL","INT","QUIT","SEGV","TERM","USR1","USR2","KILL","PIPE"].reduce((le,se)=>({...le,[se]:1}),{}),COMPAT:q,COMPAT_CHECKS:[["Cisco-1.25",q.BAD_DHGEX],[/^Cisco-1[.]/,q.BUG_DHGEX_LARGE],[/^[0-9.]+$/,q.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,q.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,q.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:c,SUPPORTED_KEX:h,DEFAULT_SERVER_HOST_KEY:g,SUPPORTED_SERVER_HOST_KEY:u,DEFAULT_CIPHER:A,SUPPORTED_CIPHER:I,DEFAULT_MAC:w,SUPPORTED_MAC:R,DEFAULT_COMPRESSION:M,SUPPORTED_COMPRESSION:ce,curve25519Supported:f,eddsaSupported:o},r.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(r.exports.DISCONNECT_REASON)).reduce((le,[se,fe])=>({...le,[fe]:se}),{})}(Yr)),Yr.exports}var Xr,Ki;function nn(){if(Ki)return Xr;Ki=1;const r=Ir.Ber;let t;const e=Buffer[Symbol.species],n=Object.getPrototypeOf(Uint8Array.prototype).fill;function s(u,d){return u[d++]*16777216+u[d++]*65536+u[d++]*256+u[d]}function i(u,d,A,I,y){y||(y=0),I>u.length&&(I=u.length);let w=I-A;const R=d.length-y;return w>R&&(w=R),d.set(new Uint8Array(u.buffer,u.byteOffset+A,w),y),w}function o(u,d,A){return A===void 0&&(A=u.length),new e(u.buffer,u.byteOffset+d,A-d)}function f(){let u=0,d;const A={init:(I,y)=>{d=I,u=typeof y=="number"?y:0},pos:()=>u,length:()=>d?d.length:0,avail:()=>d&&u<d.length?d.length-u:0,clear:()=>{d=void 0},readUInt32BE:()=>{if(!(!d||u+3>=d.length))return d[u++]*16777216+d[u++]*65536+d[u++]*256+d[u++]},readUInt64BE:I=>{if(!(!d||u+7>=d.length))switch(I){case"always":return BigInt(`0x${d.hexSlice(u,u+=8)}`);case"maybe":if(d[u]>31)return BigInt(`0x${d.hexSlice(u,u+=8)}`);default:return d[u++]*72057594037927940+d[u++]*281474976710656+d[u++]*1099511627776+d[u++]*4294967296+d[u++]*16777216+d[u++]*65536+d[u++]*256+d[u++]}},skip:I=>{d&&I>0&&(u+=I)},skipString:()=>{const I=A.readUInt32BE();if(I!==void 0)return u+=I,u<=d.length?I:void 0},readByte:()=>{if(d&&u<d.length)return d[u++]},readBool:()=>{if(d&&u<d.length)return!!d[u++]},readList:()=>{const I=A.readString(!0);if(I!==void 0)return I?I.split(","):[]},readString:(I,y)=>{typeof I=="number"&&(y=I,I=void 0);const w=A.readUInt32BE();if(w!==void 0&&!(d.length-u<w||typeof y=="number"&&w>y))return I?Buffer.isBuffer(I)?i(d,I,u,u+=w):d.utf8Slice(u,u+=w):o(d,u,u+=w)},readRaw:I=>{if(d){if(typeof I!="number")return o(d,u,u+=d.length-u);if(d.length-u>=I)return o(d,u,u+=I)}}};return A}function c(u,d,A){const I=new Error(u);return typeof d=="boolean"?(A=d,I.level="protocol"):I.level=d||"protocol",I.fatal=!!A,I}function h(u,d,A){return u[A++]=d>>>24,u[A++]=d>>>16,u[A++]=d>>>8,u[A++]=d,A}const g=f();return Xr={bufferCopy:i,bufferSlice:o,FastBuffer:e,bufferFill:(u,d,A,I)=>n.call(u,d,A,I),makeError:c,doFatalError:(u,d,A,I)=>{let y;return t===void 0&&({DISCONNECT_REASON:t}=En()),d instanceof Error?(y=d,typeof A!="number"?I=t.PROTOCOL_ERROR:I=A):y=c(d,A,!0),typeof I!="number"&&(I=t.PROTOCOL_ERROR),u.disconnect(I),u._destruct(),u._onError(y),1/0},readUInt32BE:s,writeUInt32BE:h,writeUInt32LE:(u,d,A)=>(u[A++]=d,u[A++]=d>>>8,u[A++]=d>>>16,u[A++]=d>>>24,A),makeBufferParser:f,bufferParser:f(),readString:(u,d,A,I)=>{typeof A=="number"&&(I=A,A=void 0),d===void 0&&(d=0);const y=u.length-d;if(d<0||d>=u.length||y<4)return;const w=s(u,d);if(y<4+w||typeof I=="number"&&w>I)return;d+=4;const R=d+w;return u._pos=R,A?Buffer.isBuffer(A)?i(u,A,d,R):u.utf8Slice(d,R):o(u,d,R)},sigSSHToASN1:(u,d)=>{switch(d){case"ssh-dss":{if(u.length>40)return u;const A=new r.Writer;A.startSequence();let I=u.slice(0,20),y=u.slice(20);if(I[0]&128){const w=Buffer.allocUnsafe(21);w[0]=0,I.copy(w,1),I=w}else I[0]===0&&!(I[1]&128)&&(I=I.slice(1));if(y[0]&128){const w=Buffer.allocUnsafe(21);w[0]=0,y.copy(w,1),y=w}else y[0]===0&&!(y[1]&128)&&(y=y.slice(1));return A.writeBuffer(I,r.Integer),A.writeBuffer(y,r.Integer),A.endSequence(),A.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{g.init(u,0);const A=g.readString(),I=g.readString();if(g.clear(),A===void 0||I===void 0)return;const y=new r.Writer;return y.startSequence(),y.writeBuffer(A,r.Integer),y.writeBuffer(I,r.Integer),y.endSequence(),y.buffer}default:return u}},convertSignature:(u,d)=>{switch(d){case"ssh-dss":{if(u.length<=40)return u;const A=new r.Reader(u);A.readSequence();let I=A.readString(r.Integer,!0),y=A.readString(r.Integer,!0),w=0,R=0;if(I.length<20){const ce=Buffer.allocUnsafe(20);ce.set(I,1),I=ce,I[0]=0}if(y.length<20){const ce=Buffer.allocUnsafe(20);ce.set(y,1),y=ce,y[0]=0}I.length>20&&I[0]===0&&(w=1),y.length>20&&y[0]===0&&(R=1);const M=Buffer.allocUnsafe(I.length-w+(y.length-R));return i(I,M,w,I.length,0),i(y,M,R,y.length,I.length-w),M}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(u[0]===0)return u;const A=new r.Reader(u);A.readSequence();const I=A.readString(r.Integer,!0),y=A.readString(r.Integer,!0);if(I===null||y===null)return;const w=Buffer.allocUnsafe(4+I.length+4+y.length);return h(w,I.length,0),w.set(I,4),h(w,y.length,4+I.length),w.set(y,4+4+I.length),w}}return u},sendPacket:(u,d,A)=>!A&&u._kexinit!==void 0?(u._queue===void 0&&(u._queue=[]),u._queue.push(d),u._debug&&u._debug("Outbound: ... packet queued"),!1):(u._cipher.encrypt(d),!0)},Xr}var jr={exports:{}},Wi;function sf(){return Wi||(Wi=1,function(r,t){var e=function(){var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),function(s){s=s||{};var i;i||(i=typeof s<"u"?s:{});var o,f;i.ready=new Promise(function(m,B){o=m,f=B});var c={},h;for(h in i)i.hasOwnProperty(h)&&(c[h]=i[h]);var g=typeof window=="object",u=typeof importScripts=="function",d=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",A="",I,y,w,R,M;d?(A=u?tt.dirname(A)+"/":__dirname+"/",I=function(m,B){var x=Nt(m);return x?B?x:x.toString():(R||(R=tt),M||(M=tt),m=M.normalize(m),R.readFileSync(m,B?null:"utf8"))},w=function(m){return m=I(m,!0),m.buffer||(m=new Uint8Array(m)),fe(m.buffer),m},y=function(m,B,x){var K=Nt(m);K&&B(K),R||(R=tt),M||(M=tt),m=M.normalize(m),R.readFile(m,function(z,V){z?x(z):B(V.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),i.inspect=function(){return"[Emscripten Module object]"}):(g||u)&&(u?A=self.location.href:typeof document<"u"&&document.currentScript&&(A=document.currentScript.src),n&&(A=n),A.indexOf("blob:")!==0?A=A.substr(0,A.lastIndexOf("/")+1):A="",I=function(m){try{var B=new XMLHttpRequest;return B.open("GET",m,!1),B.send(null),B.responseText}catch(z){if(m=Nt(m)){B=[];for(var x=0;x<m.length;x++){var K=m[x];255<K&&(K&=255),B.push(String.fromCharCode(K))}return B.join("")}throw z}},u&&(w=function(m){try{var B=new XMLHttpRequest;return B.open("GET",m,!1),B.responseType="arraybuffer",B.send(null),new Uint8Array(B.response)}catch(x){if(m=Nt(m))return m;throw x}}),y=function(m,B,x){var K=new XMLHttpRequest;K.open("GET",m,!0),K.responseType="arraybuffer",K.onload=function(){if(K.status==200||K.status==0&&K.response)B(K.response);else{var z=Nt(m);z?B(z.buffer):x()}},K.onerror=x,K.send(null)}),i.print||console.log.bind(console);var ce=i.printErr||console.warn.bind(console);for(h in c)c.hasOwnProperty(h)&&(i[h]=c[h]);c=null;var q;i.wasmBinary&&(q=i.wasmBinary),i.noExitRuntime,typeof WebAssembly!="object"&&we("no native wasm support detected");var le,se=!1;function fe(m,B){m||we("Assertion failed: "+B)}function k(m){var B=i["_"+m];return fe(B,"Cannot call unknown function "+m+", make sure it is exported"),B}function v(m,B,x,K){var z={string:function(De){var gt=0;if(De!=null&&De!==0){var At=(De.length<<2)+1;gt=O(At);var ut=gt,qe=he;if(0<At){At=ut+At-1;for(var Ge=0;Ge<De.length;++Ge){var Ve=De.charCodeAt(Ge);if(55296<=Ve&&57343>=Ve){var vt=De.charCodeAt(++Ge);Ve=65536+((Ve&1023)<<10)|vt&1023}if(127>=Ve){if(ut>=At)break;qe[ut++]=Ve}else{if(2047>=Ve){if(ut+1>=At)break;qe[ut++]=192|Ve>>6}else{if(65535>=Ve){if(ut+2>=At)break;qe[ut++]=224|Ve>>12}else{if(ut+3>=At)break;qe[ut++]=240|Ve>>18,qe[ut++]=128|Ve>>12&63}qe[ut++]=128|Ve>>6&63}qe[ut++]=128|Ve&63}}qe[ut]=0}}return gt},array:function(De){var gt=O(De.length);return X.set(De,gt),gt}},V=k(m),We=[];if(m=0,K)for(var rt=0;rt<K.length;rt++){var mt=z[x[rt]];mt?(m===0&&(m=S()),We[rt]=mt(K[rt])):We[rt]=K[rt]}return x=V.apply(null,We),x=function(De){if(B==="string")if(De){for(var gt=he,At=De+NaN,ut=De;gt[ut]&&!(ut>=At);)++ut;if(16<ut-De&&gt.subarray&&T)De=T.decode(gt.subarray(De,ut));else{for(At="";De<ut;){var qe=gt[De++];if(qe&128){var Ge=gt[De++]&63;if((qe&224)==192)At+=String.fromCharCode((qe&31)<<6|Ge);else{var Ve=gt[De++]&63;qe=(qe&240)==224?(qe&15)<<12|Ge<<6|Ve:(qe&7)<<18|Ge<<12|Ve<<6|gt[De++]&63,65536>qe?At+=String.fromCharCode(qe):(qe-=65536,At+=String.fromCharCode(55296|qe>>10,56320|qe&1023))}}else At+=String.fromCharCode(qe)}De=At}}else De="";else De=B==="boolean"?!!De:De;return De}(x),m!==0&&p(m),x}var T=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,J,X,he;function ae(){var m=le.buffer;J=m,i.HEAP8=X=new Int8Array(m),i.HEAP16=new Int16Array(m),i.HEAP32=new Int32Array(m),i.HEAPU8=he=new Uint8Array(m),i.HEAPU16=new Uint16Array(m),i.HEAPU32=new Uint32Array(m),i.HEAPF32=new Float32Array(m),i.HEAPF64=new Float64Array(m)}var Ae,oe=[],ge=[],Q=[];function j(){var m=i.preRun.shift();oe.unshift(m)}var Y=0,re=null;i.preloadedImages={},i.preloadedAudios={};function we(m){throw i.onAbort&&i.onAbort(m),ce(m),se=!0,m=new WebAssembly.RuntimeError("abort("+m+"). Build with -s ASSERTIONS=1 for more info."),f(m),m}var me="data:application/octet-stream;base64,",ve;if(ve="data:application/octet-stream;base64,AGFzbQEAAAABIAZgAX8Bf2ADf39/AGABfwBgAABgAAF/YAZ/f39/f38AAgcBAWEBYQAAAwsKAAEDAQAAAgQFAgQFAXABAQEFBwEBgAKAgAIGCQF/AUGAjMACCwclCQFiAgABYwADAWQACQFlAAgBZgAHAWcABgFoAAUBaQAKAWoBAAqGTQpPAQJ/QYAIKAIAIgEgAEEDakF8cSICaiEAAkAgAkEAIAAgAU0bDQAgAD8AQRB0SwRAIAAQAEUNAQtBgAggADYCACABDwtBhAhBMDYCAEF/C4wFAg5+Cn8gACgCJCEUIAAoAiAhFSAAKAIcIREgACgCGCESIAAoAhQhEyACQRBPBEAgAC0ATEVBGHQhFyAAKAIEIhZBBWytIQ8gACgCCCIYQQVsrSENIAAoAgwiGUEFbK0hCyAAKAIQIhpBBWytIQkgADUCACEIIBqtIRAgGa0hDiAYrSEMIBatIQoDQCASIAEtAAMiEiABLQAEQQh0ciABLQAFQRB0ciABLQAGIhZBGHRyQQJ2Qf///x9xaq0iAyAOfiABLwAAIAEtAAJBEHRyIBNqIBJBGHRBgICAGHFqrSIEIBB+fCARIAEtAAdBCHQgFnIgAS0ACEEQdHIgAS0ACSIRQRh0ckEEdkH///8fcWqtIgUgDH58IAEtAApBCHQgEXIgAS0AC0EQdHIgAS0ADEEYdHJBBnYgFWqtIgYgCn58IBQgF2ogAS8ADSABLQAPQRB0cmqtIgcgCH58IAMgDH4gBCAOfnwgBSAKfnwgBiAIfnwgByAJfnwgAyAKfiAEIAx+fCAFIAh+fCAGIAl+fCAHIAt+fCADIAh+IAQgCn58IAUgCX58IAYgC358IAcgDX58IAMgCX4gBCAIfnwgBSALfnwgBiANfnwgByAPfnwiA0IaiEL/////D4N8IgRCGohC/////w+DfCIFQhqIQv////8Pg3wiBkIaiEL/////D4N8IgdCGoinQQVsIAOnQf///x9xaiITQRp2IASnQf///x9xaiESIAWnQf///x9xIREgBqdB////H3EhFSAHp0H///8fcSEUIBNB////H3EhEyABQRBqIQEgAkEQayICQQ9LDQALCyAAIBQ2AiQgACAVNgIgIAAgETYCHCAAIBI2AhggACATNgIUCwMAAQu2BAEGfwJAIAAoAjgiBARAIABBPGohBQJAIAJBECAEayIDIAIgA0kbIgZFDQAgBkEDcSEHAkAgBkEBa0EDSQRAQQAhAwwBCyAGQXxxIQhBACEDA0AgBSADIARqaiABIANqLQAAOgAAIAUgA0EBciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0ECciIEIAAoAjhqaiABIARqLQAAOgAAIAUgA0EDciIEIAAoAjhqaiABIARqLQAAOgAAIANBBGohAyAAKAI4IQQgCEEEayIIDQALCyAHRQ0AA0AgBSADIARqaiABIANqLQAAOgAAIANBAWohAyAAKAI4IQQgB0EBayIHDQALCyAAIAQgBmoiAzYCOCADQRBJDQEgACAFQRAQAiAAQQA2AjggAiAGayECIAEgBmohAQsgAkEQTwRAIAAgASACQXBxIgMQAiACQQ9xIQIgASADaiEBCyACRQ0AIAJBA3EhBCAAQTxqIQVBACEDIAJBAWtBA08EQCACQXxxIQcDQCAFIAAoAjggA2pqIAEgA2otAAA6AAAgBSADQQFyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQJyIgYgACgCOGpqIAEgBmotAAA6AAAgBSADQQNyIgYgACgCOGpqIAEgBmotAAA6AAAgA0EEaiEDIAdBBGsiBw0ACwsgBARAA0AgBSAAKAI4IANqaiABIANqLQAAOgAAIANBAWohAyAEQQFrIgQNAAsLIAAgACgCOCACajYCOAsLoS0BDH8jAEEQayIMJAACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgAEH0AU0EQEGICCgCACIFQRAgAEELakF4cSAAQQtJGyIIQQN2IgJ2IgFBA3EEQCABQX9zQQFxIAJqIgNBA3QiAUG4CGooAgAiBEEIaiEAAkAgBCgCCCICIAFBsAhqIgFGBEBBiAggBUF+IAN3cTYCAAwBCyACIAE2AgwgASACNgIICyAEIANBA3QiAUEDcjYCBCABIARqIgEgASgCBEEBcjYCBAwNCyAIQZAIKAIAIgpNDQEgAQRAAkBBAiACdCIAQQAgAGtyIAEgAnRxIgBBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2aiIDQQN0IgBBuAhqKAIAIgQoAggiASAAQbAIaiIARgRAQYgIIAVBfiADd3EiBTYCAAwBCyABIAA2AgwgACABNgIICyAEQQhqIQAgBCAIQQNyNgIEIAQgCGoiAiADQQN0IgEgCGsiA0EBcjYCBCABIARqIAM2AgAgCgRAIApBA3YiAUEDdEGwCGohB0GcCCgCACEEAn8gBUEBIAF0IgFxRQRAQYgIIAEgBXI2AgAgBwwBCyAHKAIICyEBIAcgBDYCCCABIAQ2AgwgBCAHNgIMIAQgATYCCAtBnAggAjYCAEGQCCADNgIADA0LQYwIKAIAIgZFDQEgBkEAIAZrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QbgKaigCACIBKAIEQXhxIAhrIQMgASECA0ACQCACKAIQIgBFBEAgAigCFCIARQ0BCyAAKAIEQXhxIAhrIgIgAyACIANJIgIbIQMgACABIAIbIQEgACECDAELCyABIAhqIgkgAU0NAiABKAIYIQsgASABKAIMIgRHBEAgASgCCCIAQZgIKAIASRogACAENgIMIAQgADYCCAwMCyABQRRqIgIoAgAiAEUEQCABKAIQIgBFDQQgAUEQaiECCwNAIAIhByAAIgRBFGoiAigCACIADQAgBEEQaiECIAQoAhAiAA0ACyAHQQA2AgAMCwtBfyEIIABBv39LDQAgAEELaiIAQXhxIQhBjAgoAgAiCUUNAEEAIAhrIQMCQAJAAkACf0EAIAhBgAJJDQAaQR8gCEH///8HSw0AGiAAQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgCCAAQRVqdkEBcXJBHGoLIgVBAnRBuApqKAIAIgJFBEBBACEADAELQQAhACAIQQBBGSAFQQF2ayAFQR9GG3QhAQNAAkAgAigCBEF4cSAIayIHIANPDQAgAiEEIAciAw0AQQAhAyACIQAMAwsgACACKAIUIgcgByACIAFBHXZBBHFqKAIQIgJGGyAAIAcbIQAgAUEBdCEBIAINAAsLIAAgBHJFBEBBACEEQQIgBXQiAEEAIABrciAJcSIARQ0DIABBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2akECdEG4CmooAgAhAAsgAEUNAQsDQCAAKAIEQXhxIAhrIgEgA0khAiABIAMgAhshAyAAIAQgAhshBCAAKAIQIgEEfyABBSAAKAIUCyIADQALCyAERQ0AIANBkAgoAgAgCGtPDQAgBCAIaiIGIARNDQEgBCgCGCEFIAQgBCgCDCIBRwRAIAQoAggiAEGYCCgCAEkaIAAgATYCDCABIAA2AggMCgsgBEEUaiICKAIAIgBFBEAgBCgCECIARQ0EIARBEGohAgsDQCACIQcgACIBQRRqIgIoAgAiAA0AIAFBEGohAiABKAIQIgANAAsgB0EANgIADAkLIAhBkAgoAgAiAk0EQEGcCCgCACEDAkAgAiAIayIBQRBPBEBBkAggATYCAEGcCCADIAhqIgA2AgAgACABQQFyNgIEIAIgA2ogATYCACADIAhBA3I2AgQMAQtBnAhBADYCAEGQCEEANgIAIAMgAkEDcjYCBCACIANqIgAgACgCBEEBcjYCBAsgA0EIaiEADAsLIAhBlAgoAgAiBkkEQEGUCCAGIAhrIgE2AgBBoAhBoAgoAgAiAiAIaiIANgIAIAAgAUEBcjYCBCACIAhBA3I2AgQgAkEIaiEADAsLQQAhACAIQS9qIgkCf0HgCygCAARAQegLKAIADAELQewLQn83AgBB5AtCgKCAgICABDcCAEHgCyAMQQxqQXBxQdiq1aoFczYCAEH0C0EANgIAQcQLQQA2AgBBgCALIgFqIgVBACABayIHcSICIAhNDQpBwAsoAgAiBARAQbgLKAIAIgMgAmoiASADTQ0LIAEgBEsNCwtBxAstAABBBHENBQJAAkBBoAgoAgAiAwRAQcgLIQADQCADIAAoAgAiAU8EQCABIAAoAgRqIANLDQMLIAAoAggiAA0ACwtBABABIgFBf0YNBiACIQVB5AsoAgAiA0EBayIAIAFxBEAgAiABayAAIAFqQQAgA2txaiEFCyAFIAhNDQYgBUH+////B0sNBkHACygCACIEBEBBuAsoAgAiAyAFaiIAIANNDQcgACAESw0HCyAFEAEiACABRw0BDAgLIAUgBmsgB3EiBUH+////B0sNBSAFEAEiASAAKAIAIAAoAgRqRg0EIAEhAAsCQCAAQX9GDQAgCEEwaiAFTQ0AQegLKAIAIgEgCSAFa2pBACABa3EiAUH+////B0sEQCAAIQEMCAsgARABQX9HBEAgASAFaiEFIAAhAQwIC0EAIAVrEAEaDAULIAAiAUF/Rw0GDAQLAAtBACEEDAcLQQAhAQwFCyABQX9HDQILQcQLQcQLKAIAQQRyNgIACyACQf7///8HSw0BIAIQASEBQQAQASEAIAFBf0YNASAAQX9GDQEgACABTQ0BIAAgAWsiBSAIQShqTQ0BC0G4C0G4CygCACAFaiIANgIAQbwLKAIAIABJBEBBvAsgADYCAAsCQAJAAkBBoAgoAgAiBwRAQcgLIQADQCABIAAoAgAiAyAAKAIEIgJqRg0CIAAoAggiAA0ACwwCC0GYCCgCACIAQQAgACABTRtFBEBBmAggATYCAAtBACEAQcwLIAU2AgBByAsgATYCAEGoCEF/NgIAQawIQeALKAIANgIAQdQLQQA2AgADQCAAQQN0IgNBuAhqIANBsAhqIgI2AgAgA0G8CGogAjYCACAAQQFqIgBBIEcNAAtBlAggBUEoayIDQXggAWtBB3FBACABQQhqQQdxGyIAayICNgIAQaAIIAAgAWoiADYCACAAIAJBAXI2AgQgASADakEoNgIEQaQIQfALKAIANgIADAILIAAtAAxBCHENACADIAdLDQAgASAHTQ0AIAAgAiAFajYCBEGgCCAHQXggB2tBB3FBACAHQQhqQQdxGyIAaiICNgIAQZQIQZQIKAIAIAVqIgEgAGsiADYCACACIABBAXI2AgQgASAHakEoNgIEQaQIQfALKAIANgIADAELQZgIKAIAIAFLBEBBmAggATYCAAsgASAFaiECQcgLIQACQAJAAkACQAJAAkADQCACIAAoAgBHBEAgACgCCCIADQEMAgsLIAAtAAxBCHFFDQELQcgLIQADQCAHIAAoAgAiAk8EQCACIAAoAgRqIgQgB0sNAwsgACgCCCEADAALAAsgACABNgIAIAAgACgCBCAFajYCBCABQXggAWtBB3FBACABQQhqQQdxG2oiCSAIQQNyNgIEIAJBeCACa0EHcUEAIAJBCGpBB3EbaiIFIAggCWoiBmshAiAFIAdGBEBBoAggBjYCAEGUCEGUCCgCACACaiIANgIAIAYgAEEBcjYCBAwDCyAFQZwIKAIARgRAQZwIIAY2AgBBkAhBkAgoAgAgAmoiADYCACAGIABBAXI2AgQgACAGaiAANgIADAMLIAUoAgQiAEEDcUEBRgRAIABBeHEhBwJAIABB/wFNBEAgBSgCCCIDIABBA3YiAEEDdEGwCGpGGiADIAUoAgwiAUYEQEGICEGICCgCAEF+IAB3cTYCAAwCCyADIAE2AgwgASADNgIIDAELIAUoAhghCAJAIAUgBSgCDCIBRwRAIAUoAggiACABNgIMIAEgADYCCAwBCwJAIAVBFGoiACgCACIDDQAgBUEQaiIAKAIAIgMNAEEAIQEMAQsDQCAAIQQgAyIBQRRqIgAoAgAiAw0AIAFBEGohACABKAIQIgMNAAsgBEEANgIACyAIRQ0AAkAgBSAFKAIcIgNBAnRBuApqIgAoAgBGBEAgACABNgIAIAENAUGMCEGMCCgCAEF+IAN3cTYCAAwCCyAIQRBBFCAIKAIQIAVGG2ogATYCACABRQ0BCyABIAg2AhggBSgCECIABEAgASAANgIQIAAgATYCGAsgBSgCFCIARQ0AIAEgADYCFCAAIAE2AhgLIAUgB2ohBSACIAdqIQILIAUgBSgCBEF+cTYCBCAGIAJBAXI2AgQgAiAGaiACNgIAIAJB/wFNBEAgAkEDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwDC0EfIQAgAkH///8HTQRAIAJBCHYiACAAQYD+P2pBEHZBCHEiA3QiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASADciAAcmsiAEEBdCACIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQQCQEGMCCgCACIDQQEgAHQiAXFFBEBBjAggASADcjYCACAEIAY2AgAgBiAENgIYDAELIAJBAEEZIABBAXZrIABBH0YbdCEAIAQoAgAhAQNAIAEiAygCBEF4cSACRg0DIABBHXYhASAAQQF0IQAgAyABQQRxaiIEKAIQIgENAAsgBCAGNgIQIAYgAzYCGAsgBiAGNgIMIAYgBjYCCAwCC0GUCCAFQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBBoAggACABaiIANgIAIAAgAkEBcjYCBCABIANqQSg2AgRBpAhB8AsoAgA2AgAgByAEQScgBGtBB3FBACAEQSdrQQdxG2pBL2siACAAIAdBEGpJGyICQRs2AgQgAkHQCykCADcCECACQcgLKQIANwIIQdALIAJBCGo2AgBBzAsgBTYCAEHICyABNgIAQdQLQQA2AgAgAkEYaiEAA0AgAEEHNgIEIABBCGohASAAQQRqIQAgASAESQ0ACyACIAdGDQMgAiACKAIEQX5xNgIEIAcgAiAHayIEQQFyNgIEIAIgBDYCACAEQf8BTQRAIARBA3YiAEEDdEGwCGohAgJ/QYgIKAIAIgFBASAAdCIAcUUEQEGICCAAIAFyNgIAIAIMAQsgAigCCAshACACIAc2AgggACAHNgIMIAcgAjYCDCAHIAA2AggMBAtBHyEAIAdCADcCECAEQf///wdNBEAgBEEIdiIAIABBgP4/akEQdkEIcSICdCIAIABBgOAfakEQdkEEcSIBdCIAIABBgIAPakEQdkECcSIAdEEPdiABIAJyIAByayIAQQF0IAQgAEEVanZBAXFyQRxqIQALIAcgADYCHCAAQQJ0QbgKaiEDAkBBjAgoAgAiAkEBIAB0IgFxRQRAQYwIIAEgAnI2AgAgAyAHNgIAIAcgAzYCGAwBCyAEQQBBGSAAQQF2ayAAQR9GG3QhACADKAIAIQEDQCABIgIoAgRBeHEgBEYNBCAAQR12IQEgAEEBdCEAIAIgAUEEcWoiAygCECIBDQALIAMgBzYCECAHIAI2AhgLIAcgBzYCDCAHIAc2AggMAwsgAygCCCIAIAY2AgwgAyAGNgIIIAZBADYCGCAGIAM2AgwgBiAANgIICyAJQQhqIQAMBQsgAigCCCIAIAc2AgwgAiAHNgIIIAdBADYCGCAHIAI2AgwgByAANgIIC0GUCCgCACIAIAhNDQBBlAggACAIayIBNgIAQaAIQaAIKAIAIgIgCGoiADYCACAAIAFBAXI2AgQgAiAIQQNyNgIEIAJBCGohAAwDC0GECEEwNgIAQQAhAAwCCwJAIAVFDQACQCAEKAIcIgJBAnRBuApqIgAoAgAgBEYEQCAAIAE2AgAgAQ0BQYwIIAlBfiACd3EiCTYCAAwCCyAFQRBBFCAFKAIQIARGG2ogATYCACABRQ0BCyABIAU2AhggBCgCECIABEAgASAANgIQIAAgATYCGAsgBCgCFCIARQ0AIAEgADYCFCAAIAE2AhgLAkAgA0EPTQRAIAQgAyAIaiIAQQNyNgIEIAAgBGoiACAAKAIEQQFyNgIEDAELIAQgCEEDcjYCBCAGIANBAXI2AgQgAyAGaiADNgIAIANB/wFNBEAgA0EDdiIAQQN0QbAIaiECAn9BiAgoAgAiAUEBIAB0IgBxRQRAQYgIIAAgAXI2AgAgAgwBCyACKAIICyEAIAIgBjYCCCAAIAY2AgwgBiACNgIMIAYgADYCCAwBC0EfIQAgA0H///8HTQRAIANBCHYiACAAQYD+P2pBEHZBCHEiAnQiACAAQYDgH2pBEHZBBHEiAXQiACAAQYCAD2pBEHZBAnEiAHRBD3YgASACciAAcmsiAEEBdCADIABBFWp2QQFxckEcaiEACyAGIAA2AhwgBkIANwIQIABBAnRBuApqIQICQAJAIAlBASAAdCIBcUUEQEGMCCABIAlyNgIAIAIgBjYCACAGIAI2AhgMAQsgA0EAQRkgAEEBdmsgAEEfRht0IQAgAigCACEIA0AgCCIBKAIEQXhxIANGDQIgAEEddiECIABBAXQhACABIAJBBHFqIgIoAhAiCA0ACyACIAY2AhAgBiABNgIYCyAGIAY2AgwgBiAGNgIIDAELIAEoAggiACAGNgIMIAEgBjYCCCAGQQA2AhggBiABNgIMIAYgADYCCAsgBEEIaiEADAELAkAgC0UNAAJAIAEoAhwiAkECdEG4CmoiACgCACABRgRAIAAgBDYCACAEDQFBjAggBkF+IAJ3cTYCAAwCCyALQRBBFCALKAIQIAFGG2ogBDYCACAERQ0BCyAEIAs2AhggASgCECIABEAgBCAANgIQIAAgBDYCGAsgASgCFCIARQ0AIAQgADYCFCAAIAQ2AhgLAkAgA0EPTQRAIAEgAyAIaiIAQQNyNgIEIAAgAWoiACAAKAIEQQFyNgIEDAELIAEgCEEDcjYCBCAJIANBAXI2AgQgAyAJaiADNgIAIAoEQCAKQQN2IgBBA3RBsAhqIQRBnAgoAgAhAgJ/QQEgAHQiACAFcUUEQEGICCAAIAVyNgIAIAQMAQsgBCgCCAshACAEIAI2AgggACACNgIMIAIgBDYCDCACIAA2AggLQZwIIAk2AgBBkAggAzYCAAsgAUEIaiEACyAMQRBqJAAgAAsQACMAIABrQXBxIgAkACAACwYAIAAkAAsEACMAC4AJAgh/BH4jAEGQAWsiBiQAIAYgBS0AA0EYdEGAgIAYcSAFLwAAIAUtAAJBEHRycjYCACAGIAUoAANBAnZBg/7/H3E2AgQgBiAFKAAGQQR2Qf+B/x9xNgIIIAYgBSgACUEGdkH//8AfcTYCDCAFLwANIQggBS0ADyEJIAZCADcCFCAGQgA3AhwgBkEANgIkIAYgCCAJQRB0QYCAPHFyNgIQIAYgBSgAEDYCKCAGIAUoABQ2AiwgBiAFKAAYNgIwIAUoABwhBSAGQQA6AEwgBkEANgI4IAYgBTYCNCAGIAEgAhAEIAQEQCAGIAMgBBAECyAGKAI4IgEEQCAGQTxqIgIgAWpBAToAACABQQFqQQ9NBEAgASAGakE9aiEEAkBBDyABayIDRQ0AIAMgBGoiAUEBa0EAOgAAIARBADoAACADQQNJDQAgAUECa0EAOgAAIARBADoAASABQQNrQQA6AAAgBEEAOgACIANBB0kNACABQQRrQQA6AAAgBEEAOgADIANBCUkNACAEQQAgBGtBA3EiAWoiBEEANgIAIAQgAyABa0F8cSIBaiIDQQRrQQA2AgAgAUEJSQ0AIARBADYCCCAEQQA2AgQgA0EIa0EANgIAIANBDGtBADYCACABQRlJDQAgBEEANgIYIARBADYCFCAEQQA2AhAgBEEANgIMIANBEGtBADYCACADQRRrQQA2AgAgA0EYa0EANgIAIANBHGtBADYCACABIARBBHFBGHIiAWsiA0EgSQ0AIAEgBGohAQNAIAFCADcDGCABQgA3AxAgAUIANwMIIAFCADcDACABQSBqIQEgA0EgayIDQR9LDQALCwsgBkEBOgBMIAYgAkEQEAILIAY1AjQhECAGNQIwIREgBjUCLCEOIAAgBjUCKCAGKAIkIAYoAiAgBigCHCAGKAIYIgNBGnZqIgJBGnZqIgFBGnZqIgtBgICAYHIgAUH///8fcSINIAJB////H3EiCCAGKAIUIAtBGnZBBWxqIgFB////H3EiCUEFaiIFQRp2IANB////H3EgAUEadmoiA2oiAUEadmoiAkEadmoiBEEadmoiDEEfdSIHIANxIAEgDEEfdkEBayIDQf///x9xIgpxciIBQRp0IAUgCnEgByAJcXJyrXwiDzwAACAAIA9CGIg8AAMgACAPQhCIPAACIAAgD0IIiDwAASAAIA4gByAIcSACIApxciICQRR0IAFBBnZyrXwgD0IgiHwiDjwABCAAIA5CGIg8AAcgACAOQhCIPAAGIAAgDkIIiDwABSAAIBEgByANcSAEIApxciIBQQ50IAJBDHZyrXwgDkIgiHwiDjwACCAAIA5CGIg8AAsgACAOQhCIPAAKIAAgDkIIiDwACSAAIBAgAyAMcSAHIAtxckEIdCABQRJ2cq18IA5CIIh8Ig48AAwgACAOQhiIPAAPIAAgDkIQiDwADiAAIA5CCIg8AA0gBkIANwIwIAZCADcCKCAGQgA3AiAgBkIANwIYIAZCADcCECAGQgA3AgggBkIANwIAIAZBkAFqJAALpwwBB38CQCAARQ0AIABBCGsiAyAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQNxRQ0BIAMgAygCACIBayIDQZgIKAIASQ0BIAAgAWohACADQZwIKAIARwRAIAFB/wFNBEAgAygCCCICIAFBA3YiBEEDdEGwCGpGGiACIAMoAgwiAUYEQEGICEGICCgCAEF+IAR3cTYCAAwDCyACIAE2AgwgASACNgIIDAILIAMoAhghBgJAIAMgAygCDCIBRwRAIAMoAggiAiABNgIMIAEgAjYCCAwBCwJAIANBFGoiAigCACIEDQAgA0EQaiICKAIAIgQNAEEAIQEMAQsDQCACIQcgBCIBQRRqIgIoAgAiBA0AIAFBEGohAiABKAIQIgQNAAsgB0EANgIACyAGRQ0BAkAgAyADKAIcIgJBAnRBuApqIgQoAgBGBEAgBCABNgIAIAENAUGMCEGMCCgCAEF+IAJ3cTYCAAwDCyAGQRBBFCAGKAIQIANGG2ogATYCACABRQ0CCyABIAY2AhggAygCECICBEAgASACNgIQIAIgATYCGAsgAygCFCICRQ0BIAEgAjYCFCACIAE2AhgMAQsgBSgCBCIBQQNxQQNHDQBBkAggADYCACAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAA8LIAMgBU8NACAFKAIEIgFBAXFFDQACQCABQQJxRQRAIAVBoAgoAgBGBEBBoAggAzYCAEGUCEGUCCgCACAAaiIANgIAIAMgAEEBcjYCBCADQZwIKAIARw0DQZAIQQA2AgBBnAhBADYCAA8LIAVBnAgoAgBGBEBBnAggAzYCAEGQCEGQCCgCACAAaiIANgIAIAMgAEEBcjYCBCAAIANqIAA2AgAPCyABQXhxIABqIQACQCABQf8BTQRAIAUoAggiAiABQQN2IgRBA3RBsAhqRhogAiAFKAIMIgFGBEBBiAhBiAgoAgBBfiAEd3E2AgAMAgsgAiABNgIMIAEgAjYCCAwBCyAFKAIYIQYCQCAFIAUoAgwiAUcEQCAFKAIIIgJBmAgoAgBJGiACIAE2AgwgASACNgIIDAELAkAgBUEUaiICKAIAIgQNACAFQRBqIgIoAgAiBA0AQQAhAQwBCwNAIAIhByAEIgFBFGoiAigCACIEDQAgAUEQaiECIAEoAhAiBA0ACyAHQQA2AgALIAZFDQACQCAFIAUoAhwiAkECdEG4CmoiBCgCAEYEQCAEIAE2AgAgAQ0BQYwIQYwIKAIAQX4gAndxNgIADAILIAZBEEEUIAYoAhAgBUYbaiABNgIAIAFFDQELIAEgBjYCGCAFKAIQIgIEQCABIAI2AhAgAiABNgIYCyAFKAIUIgJFDQAgASACNgIUIAIgATYCGAsgAyAAQQFyNgIEIAAgA2ogADYCACADQZwIKAIARw0BQZAIIAA2AgAPCyAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAAsgAEH/AU0EQCAAQQN2IgFBA3RBsAhqIQACf0GICCgCACICQQEgAXQiAXFFBEBBiAggASACcjYCACAADAELIAAoAggLIQIgACADNgIIIAIgAzYCDCADIAA2AgwgAyACNgIIDwtBHyECIANCADcCECAAQf///wdNBEAgAEEIdiIBIAFBgP4/akEQdkEIcSIBdCICIAJBgOAfakEQdkEEcSICdCIEIARBgIAPakEQdkECcSIEdEEPdiABIAJyIARyayIBQQF0IAAgAUEVanZBAXFyQRxqIQILIAMgAjYCHCACQQJ0QbgKaiEBAkACQAJAQYwIKAIAIgRBASACdCIHcUUEQEGMCCAEIAdyNgIAIAEgAzYCACADIAE2AhgMAQsgAEEAQRkgAkEBdmsgAkEfRht0IQIgASgCACEBA0AgASIEKAIEQXhxIABGDQIgAkEddiEBIAJBAXQhAiAEIAFBBHFqIgdBEGooAgAiAQ0ACyAHIAM2AhAgAyAENgIYCyADIAM2AgwgAyADNgIIDAELIAQoAggiACADNgIMIAQgAzYCCCADQQA2AhggAyAENgIMIAMgADYCCAtBqAhBqAgoAgBBAWsiAEF/IAAbNgIACwsLCQEAQYEICwIGUA==",!ve.startsWith(me)){var Ne=ve;ve=i.locateFile?i.locateFile(Ne,A):A+Ne}function Je(){var m=ve;try{if(m==ve&&q)return new Uint8Array(q);var B=Nt(m);if(B)return B;if(w)return w(m);throw"both async and sync fetching of the wasm failed"}catch(x){we(x)}}function Gt(){if(!q&&(g||u)){if(typeof fetch=="function"&&!ve.startsWith("file://"))return fetch(ve,{credentials:"same-origin"}).then(function(m){if(!m.ok)throw"failed to load wasm binary file at '"+ve+"'";return m.arrayBuffer()}).catch(function(){return Je()});if(y)return new Promise(function(m,B){y(ve,function(x){m(new Uint8Array(x))},B)})}return Promise.resolve().then(function(){return Je()})}function sn(m){for(;0<m.length;){var B=m.shift();if(typeof B=="function")B(i);else{var x=B.m;typeof x=="number"?B.l===void 0?Ae.get(x)():Ae.get(x)(B.l):x(B.l===void 0?null:B.l)}}}var on=typeof atob=="function"?atob:function(m){var B="",x=0;m=m.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var K="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(m.charAt(x++)),z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(m.charAt(x++)),V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(m.charAt(x++)),We="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(m.charAt(x++));K=K<<2|z>>4,z=(z&15)<<4|V>>2;var rt=(V&3)<<6|We;B+=String.fromCharCode(K),V!==64&&(B+=String.fromCharCode(z)),We!==64&&(B+=String.fromCharCode(rt))}while(x<m.length);return B};function Nt(m){if(m.startsWith(me)){if(m=m.slice(me.length),typeof d=="boolean"&&d){var B=Buffer.from(m,"base64");B=new Uint8Array(B.buffer,B.byteOffset,B.byteLength)}else try{var x=on(m),K=new Uint8Array(x.length);for(m=0;m<x.length;++m)K[m]=x.charCodeAt(m);B=K}catch{throw Error("Converting base64 string to bytes failed.")}return B}}var N={a:function(m){var B=he.length;if(m>>>=0,2147483648<m)return!1;for(var x=1;4>=x;x*=2){var K=B*(1+.2/x);K=Math.min(K,m+100663296),K=Math.max(m,K),0<K%65536&&(K+=65536-K%65536);e:{try{le.grow(Math.min(2147483648,K)-J.byteLength+65535>>>16),ae();var z=1;break e}catch{}z=void 0}if(z)return!0}return!1}};(function(){function m(z){i.asm=z.exports,le=i.asm.b,ae(),Ae=i.asm.j,ge.unshift(i.asm.c),Y--,i.monitorRunDependencies&&i.monitorRunDependencies(Y),Y==0&&re&&(z=re,re=null,z())}function B(z){m(z.instance)}function x(z){return Gt().then(function(V){return WebAssembly.instantiate(V,K)}).then(z,function(V){ce("failed to asynchronously prepare wasm: "+V),we(V)})}var K={a:N};if(Y++,i.monitorRunDependencies&&i.monitorRunDependencies(Y),i.instantiateWasm)try{return i.instantiateWasm(K,m)}catch(z){return ce("Module.instantiateWasm callback failed with error: "+z),!1}return function(){return q||typeof WebAssembly.instantiateStreaming!="function"||ve.startsWith(me)||ve.startsWith("file://")||typeof fetch!="function"?x(B):fetch(ve,{credentials:"same-origin"}).then(function(z){return WebAssembly.instantiateStreaming(z,K).then(B,function(V){return ce("wasm streaming compile failed: "+V),ce("falling back to ArrayBuffer instantiation"),x(B)})})}().catch(f),{}})(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.c).apply(null,arguments)},i._poly1305_auth=function(){return(i._poly1305_auth=i.asm.d).apply(null,arguments)};var S=i.stackSave=function(){return(S=i.stackSave=i.asm.e).apply(null,arguments)},p=i.stackRestore=function(){return(p=i.stackRestore=i.asm.f).apply(null,arguments)},O=i.stackAlloc=function(){return(O=i.stackAlloc=i.asm.g).apply(null,arguments)};i._malloc=function(){return(i._malloc=i.asm.h).apply(null,arguments)},i._free=function(){return(i._free=i.asm.i).apply(null,arguments)},i.cwrap=function(m,B,x,K){x=x||[];var z=x.every(function(V){return V==="number"});return B!=="string"&&z&&!K?k(m):function(){return v(m,B,x,arguments)}};var ne;re=function m(){ne||F(),ne||(re=m)};function F(){function m(){if(!ne&&(ne=!0,i.calledRun=!0,!se)){if(sn(ge),o(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;){var B=i.postRun.shift();Q.unshift(B)}sn(Q)}}if(!(0<Y)){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)j();sn(oe),0<Y||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),m()},1)):m())}}if(i.run=F,i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);0<i.preInit.length;)i.preInit.pop()();return F(),s.ready}}();r.exports=e}(jr)),jr.exports}var Vr,$i;function Bn(){if($i)return Vr;$i=1;const{createCipheriv:r,createDecipheriv:t,createHmac:e,randomFillSync:n,timingSafeEqual:s}=tt,{readUInt32BE:i,writeUInt32BE:o}=nn(),f=Buffer[Symbol.species],c=2**32-1,h=Buffer.alloc(0),g=Buffer.alloc(4),u=new Map,d=35e3;let A,I,y,w,R,M,ce;try{A=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:I,ChaChaPolyCipher:y,GenericCipher:w,AESGCMDecipher:R,ChaChaPolyDecipher:M,GenericDecipher:ce}=A}catch{}const q=1,le=(()=>{function N(S,p,O,ne,F,m,B){return{sslName:S,blockLen:p,keyLen:O,ivLen:ne!==0||B&q?ne:p,authLen:F,discardLen:m,stream:!!(B&q)}}return{"chacha20-poly1305@openssh.com":N("chacha20",8,64,0,16,0,q),"aes128-gcm":N("aes-128-gcm",16,16,12,16,0,q),"aes256-gcm":N("aes-256-gcm",16,32,12,16,0,q),"aes128-gcm@openssh.com":N("aes-128-gcm",16,16,12,16,0,q),"aes256-gcm@openssh.com":N("aes-256-gcm",16,32,12,16,0,q),"aes128-cbc":N("aes-128-cbc",16,16,0,0,0,0),"aes192-cbc":N("aes-192-cbc",16,24,0,0,0,0),"aes256-cbc":N("aes-256-cbc",16,32,0,0,0,0),"rijndael-cbc@lysator.liu.se":N("aes-256-cbc",16,32,0,0,0,0),"3des-cbc":N("des-ede3-cbc",8,24,0,0,0,0),"blowfish-cbc":N("bf-cbc",8,16,0,0,0,0),"idea-cbc":N("idea-cbc",8,16,0,0,0,0),"cast128-cbc":N("cast-cbc",8,16,0,0,0,0),"aes128-ctr":N("aes-128-ctr",16,16,16,0,0,q),"aes192-ctr":N("aes-192-ctr",16,24,16,0,0,q),"aes256-ctr":N("aes-256-ctr",16,32,16,0,0,q),"3des-ctr":N("des-ede3",8,24,8,0,0,q),"blowfish-ctr":N("bf-ecb",8,16,8,0,0,q),"cast128-ctr":N("cast5-ecb",8,16,8,0,0,q),arcfour:N("rc4",8,16,0,0,1536,q),arcfour128:N("rc4",8,16,0,0,1536,q),arcfour256:N("rc4",8,32,0,0,1536,q),arcfour512:N("rc4",8,64,0,0,1536,q)}})(),se=(()=>{function N(S,p,O,ne){return{sslName:S,len:p,actualLen:O,isETM:ne}}return{"hmac-md5":N("md5",16,16,!1),"hmac-md5-96":N("md5",16,12,!1),"hmac-ripemd160":N("ripemd160",20,20,!1),"hmac-sha1":N("sha1",20,20,!1),"hmac-sha1-etm@openssh.com":N("sha1",20,20,!0),"hmac-sha1-96":N("sha1",20,12,!1),"hmac-sha2-256":N("sha256",32,32,!1),"hmac-sha2-256-etm@openssh.com":N("sha256",32,32,!0),"hmac-sha2-256-96":N("sha256",32,12,!1),"hmac-sha2-512":N("sha512",64,64,!1),"hmac-sha2-512-etm@openssh.com":N("sha512",64,64,!0),"hmac-sha2-512-96":N("sha512",64,12,!1)}})();class fe{constructor(S,p){this.outSeqno=S,this._onWrite=p,this._dead=!1}free(){this._dead=!0}allocPacket(S){let p=5+S,O=8-(p&8-1);O<4&&(O+=8),p+=O;const ne=Buffer.allocUnsafe(p);return o(ne,p-4,0),ne[4]=O,n(ne,5+S,O),ne}encrypt(S){this._dead||(this._onWrite(S),this.outSeqno=this.outSeqno+1>>>0)}}const k=Buffer.alloc(32),v=Buffer.alloc(16);let T,J,X;class he{constructor(S){const p=S.outbound;this.outSeqno=p.seqno,this._onWrite=p.onWrite,this._encKeyMain=p.cipherKey.slice(0,32),this._encKeyPktLen=p.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(S){let p=5+S,O=8-(p-4&8-1);O<4&&(O+=8),p+=O;const ne=Buffer.allocUnsafe(p);return o(ne,p-4,0),ne[4]=O,n(ne,5+S,O),ne}encrypt(S){if(this._dead)return;v[0]=0,o(v,this.outSeqno,12);const p=r("chacha20",this._encKeyMain,v).update(k),O=r("chacha20",this._encKeyPktLen,v).update(S.slice(0,4));this._onWrite(O),v[0]=1;const ne=r("chacha20",this._encKeyMain,v).update(S.slice(4));this._onWrite(ne),X(J,O,O.length,ne,ne.length,p);const F=Buffer.allocUnsafe(16);F.set(new Uint8Array(T.HEAPU8.buffer,J,16),0),this._onWrite(F),this.outSeqno=this.outSeqno+1>>>0}}class ae{constructor(S){const p=S.outbound;this.outSeqno=p.seqno,this._onWrite=p.onWrite,this._instance=new y(p.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(S){let p=5+S,O=8-(p-4&8-1);O<4&&(O+=8),p+=O;const ne=Buffer.allocUnsafe(p+16);return o(ne,p-4,0),ne[4]=O,n(ne,5+S,O),ne}encrypt(S){this._dead||(this._instance.encrypt(S,this.outSeqno),this._onWrite(S),this.outSeqno=this.outSeqno+1>>>0)}}class Ae{constructor(S){const p=S.outbound;this.outSeqno=p.seqno,this._onWrite=p.onWrite,this._encSSLName=p.cipherInfo.sslName,this._encKey=p.cipherKey,this._encIV=p.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(S){let p=5+S,O=16-(p-4&16-1);O<4&&(O+=16),p+=O;const ne=Buffer.allocUnsafe(p);return o(ne,p-4,0),ne[4]=O,n(ne,5+S,O),ne}encrypt(S){if(this._dead)return;const p=r(this._encSSLName,this._encKey,this._encIV);p.setAutoPadding(!1);const O=S.slice(0,4);p.setAAD(O),this._onWrite(O);const ne=p.update(S.slice(4));this._onWrite(ne);const F=p.final();F.length&&this._onWrite(F);const m=p.getAuthTag();this._onWrite(m),Je(this._encIV),this.outSeqno=this.outSeqno+1>>>0}}class oe{constructor(S){const p=S.outbound;this.outSeqno=p.seqno,this._onWrite=p.onWrite,this._instance=new I(p.cipherInfo.sslName,p.cipherKey,p.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(S){let p=5+S,O=16-(p-4&16-1);O<4&&(O+=16),p+=O;const ne=Buffer.allocUnsafe(p+16);return o(ne,p-4,0),ne[4]=O,n(ne,5+S,O),ne}encrypt(S){this._dead||(this._instance.encrypt(S),this._onWrite(S),this.outSeqno=this.outSeqno+1>>>0)}}class ge{constructor(S){const p=S.outbound;this.outSeqno=p.seqno,this._onWrite=p.onWrite,this._encBlockLen=p.cipherInfo.blockLen,this._cipherInstance=r(p.cipherInfo.sslName,p.cipherKey,p.cipherIV),this._macSSLName=p.macInfo.sslName,this._macKey=p.macKey,this._macActualLen=p.macInfo.actualLen,this._macETM=p.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;const O=p.cipherInfo.discardLen;if(O){let ne=u.get(O);ne===void 0&&(ne=Buffer.alloc(O),u.set(O,ne)),this._cipherInstance.update(ne)}}free(){this._dead=!0}allocPacket(S){const p=this._encBlockLen;let O=4+1+S,ne=p-(O-this._aadLen&p-1);ne<4&&(ne+=p),O+=ne;const F=Buffer.allocUnsafe(O);return o(F,O-4,0),F[4]=ne,n(F,5+S,ne),F}encrypt(S){if(this._dead)return;let p;if(this._macETM){const ne=new Uint8Array(S.buffer,S.byteOffset,4),F=this._cipherInstance.update(new Uint8Array(S.buffer,S.byteOffset+4,S.length-4));this._onWrite(ne),this._onWrite(F),p=e(this._macSSLName,this._macKey),o(g,this.outSeqno,0),p.update(g),p.update(ne),p.update(F)}else{const ne=this._cipherInstance.update(S);this._onWrite(ne),p=e(this._macSSLName,this._macKey),o(g,this.outSeqno,0),p.update(g),p.update(S)}let O=p.digest();O.length>this._macActualLen&&(O=O.slice(0,this._macActualLen)),this._onWrite(O),this.outSeqno=this.outSeqno+1>>>0}}class Q{constructor(S){const p=S.outbound;this.outSeqno=p.seqno,this._onWrite=p.onWrite,this._encBlockLen=p.cipherInfo.blockLen,this._macLen=p.macInfo.len,this._macActualLen=p.macInfo.actualLen,this._aadLen=p.macInfo.isETM?4:0,this._instance=new w(p.cipherInfo.sslName,p.cipherKey,p.cipherIV,p.macInfo.sslName,p.macKey,p.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(S){const p=this._encBlockLen;let O=4+1+S,ne=p-(O-this._aadLen&p-1);ne<4&&(ne+=p),O+=ne;const F=Buffer.allocUnsafe(O+this._macLen);return o(F,O-4,0),F[4]=ne,n(F,5+S,ne),F}encrypt(S){this._dead||(this._instance.encrypt(S,this.outSeqno),this._macActualLen<this._macLen&&(S=new f(S.buffer,S.byteOffset,S.length-(this._macLen-this._macActualLen))),this._onWrite(S),this.outSeqno=this.outSeqno+1>>>0)}}class j{constructor(S,p){this.inSeqno=S,this._onPayload=p,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(S,p,O){for(;p<O;){if(this._lenBytes<4){let F=Math.min(4-this._lenBytes,O-p);for(this._lenBytes+=F;F--;)this._len=(this._len<<8)+S[p++];if(this._lenBytes<4)return;if(this._len>d||this._len<8||4+this._len&7)throw new Error("Bad packet length");if(p>=O)return}if(this._packetPos<this._len){const F=Math.min(this._len-this._packetPos,O-p);let m;if(p!==0||F!==O?m=new Uint8Array(S.buffer,S.byteOffset+p,F):m=S,F===this._len?this._packet=m:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(m,this._packetPos)),p+=F,this._packetPos+=F,this._packetPos<this._len)return}const ne=this._packet?new f(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):h;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{const F=this._onPayload(ne);if(F!==void 0)return F===!1?p:F}}}}class Y{constructor(S){const p=S.inbound;this.inSeqno=p.seqno,this._onPayload=p.onPayload,this._decKeyMain=p.decipherKey.slice(0,32),this._decKeyPktLen=p.decipherKey.slice(32),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._calcMac=Buffer.allocUnsafe(16),this._macPos=0}free(){}decrypt(S,p,O){for(;p<O;){if(this._lenPos<4){let B=Math.min(4-this._lenPos,O-p);for(;B--;)this._lenBuf[this._lenPos++]=S[p++];if(this._lenPos<4)return;v[0]=0,o(v,this.inSeqno,12);const x=t("chacha20",this._decKeyPktLen,v).update(this._lenBuf);if(this._len=i(x,0),this._len>d||this._len<8||this._len&7)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(p>=O)return;const B=Math.min(this._len-this._pktLen,O-p);let x;if(p!==0||B!==O?x=new Uint8Array(S.buffer,S.byteOffset+p,B):x=S,B===this._len?this._packet=x:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(x,this._pktLen)),p+=B,this._pktLen+=B,this._pktLen<this._len||p>=O)return}{const B=Math.min(16-this._macPos,O-p);if(p!==0||B!==O?this._mac.set(new Uint8Array(S.buffer,S.byteOffset+p,B),this._macPos):this._mac.set(S,this._macPos),p+=B,this._macPos+=B,this._macPos<16)return}v[0]=0,o(v,this.inSeqno,12);const ne=r("chacha20",this._decKeyMain,v).update(k);if(X(J,this._lenBuf,4,this._packet,this._packet.length,ne),this._calcMac.set(new Uint8Array(T.HEAPU8.buffer,J,16),0),!s(this._calcMac,this._mac))throw new Error("Invalid MAC");v[0]=1;const F=t("chacha20",this._decKeyMain,v).update(this._packet),m=new f(F.buffer,F.byteOffset+1,F.length-F[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{const B=this._onPayload(m);if(B!==void 0)return B===!1?p:B}}}}class re{constructor(S){const p=S.inbound;this.inSeqno=p.seqno,this._onPayload=p.onPayload,this._instance=new M(p.decipherKey),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._macPos=0}free(){this._instance.free()}decrypt(S,p,O){for(;p<O;){if(this._lenPos<4){let F=Math.min(4-this._lenPos,O-p);for(;F--;)this._lenBuf[this._lenPos++]=S[p++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>d||this._len<8||this._len&7)throw new Error("Bad packet length");if(p>=O)return}if(this._pktLen<this._len){const F=Math.min(this._len-this._pktLen,O-p);let m;if(p!==0||F!==O?m=new Uint8Array(S.buffer,S.byteOffset+p,F):m=S,F===this._len?this._packet=m:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(m,this._pktLen)),p+=F,this._pktLen+=F,this._pktLen<this._len||p>=O)return}{const F=Math.min(16-this._macPos,O-p);if(p!==0||F!==O?this._mac.set(new Uint8Array(S.buffer,S.byteOffset+p,F),this._macPos):this._mac.set(S,this._macPos),p+=F,this._macPos+=F,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);const ne=new f(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{const F=this._onPayload(ne);if(F!==void 0)return F===!1?p:F}}}}class we{constructor(S){const p=S.inbound;this.inSeqno=p.seqno,this._onPayload=p.onPayload,this._decipherInstance=null,this._decipherSSLName=p.decipherInfo.sslName,this._decipherKey=p.decipherKey,this._decipherIV=p.decipherIV,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(S,p,O){for(;p<O;){if(this._lenBytes<4){let F=Math.min(4-this._lenBytes,O-p);for(this._lenBytes+=F;F--;)this._len=(this._len<<8)+S[p++];if(this._lenBytes<4)return;if(this._len+20>d||this._len<16||this._len&15)throw new Error("Bad packet length");this._decipherInstance=t(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(Gt(this._len))}if(this._pktLen<this._len){if(p>=O)return;const F=Math.min(this._len-this._pktLen,O-p);let m;if(p!==0||F!==O?m=this._decipherInstance.update(new Uint8Array(S.buffer,S.byteOffset+p,F)):m=this._decipherInstance.update(S),m.length&&(F===this._len?this._packet=m:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(m,this._packetPos)),this._packetPos+=m.length),p+=F,this._pktLen+=F,this._pktLen<this._len||p>=O)return}{const F=Math.min(16-this._tagPos,O-p);if(p!==0||F!==O?this._tag.set(new Uint8Array(S.buffer,S.byteOffset+p,F),this._tagPos):this._tag.set(S,this._tagPos),p+=F,this._tagPos+=F,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);const F=this._decipherInstance.final();F.length&&(this._packet?this._packet.set(F,this._packetPos):this._packet=F)}const ne=this._packet?new f(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):h;this.inSeqno=this.inSeqno+1>>>0,Je(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{const F=this._onPayload(ne);if(F!==void 0)return F===!1?p:F}}}}class me{constructor(S){const p=S.inbound;this.inSeqno=p.seqno,this._onPayload=p.onPayload,this._instance=new R(p.decipherInfo.sslName,p.decipherKey,p.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(S,p,O){for(;p<O;){if(this._lenBytes<4){let F=Math.min(4-this._lenBytes,O-p);for(this._lenBytes+=F;F--;)this._len=(this._len<<8)+S[p++];if(this._lenBytes<4)return;if(this._len+20>d||this._len<16||this._len&15)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(p>=O)return;const F=Math.min(this._len-this._pktLen,O-p);let m;if(p!==0||F!==O?m=new Uint8Array(S.buffer,S.byteOffset+p,F):m=S,F===this._len?this._packet=m:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(m,this._pktLen)),p+=F,this._pktLen+=F,this._pktLen<this._len||p>=O)return}{const F=Math.min(16-this._tagPos,O-p);if(p!==0||F!==O?this._tag.set(new Uint8Array(S.buffer,S.byteOffset+p,F),this._tagPos):this._tag.set(S,this._tagPos),p+=F,this._tagPos+=F,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);const ne=new f(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tagPos=0;{const F=this._onPayload(ne);if(F!==void 0)return F===!1?p:F}}}}class ve{constructor(S){const p=S.inbound;this.inSeqno=p.seqno,this._onPayload=p.onPayload,this._decipherInstance=t(p.decipherInfo.sslName,p.decipherKey,p.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(p.macInfo.isETM?4:p.decipherInfo.blockLen),this._blockSize=p.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(p.macInfo.actualLen),this._macPos=0,this._macSSLName=p.macInfo.sslName,this._macKey=p.macKey,this._macActualLen=p.macInfo.actualLen,this._macETM=p.macInfo.isETM,this._macInstance=null;const O=p.decipherInfo.discardLen;if(O){let ne=u.get(O);ne===void 0&&(ne=Buffer.alloc(O),u.set(O,ne)),this._decipherInstance.update(ne)}}free(){}decrypt(S,p,O){for(;p<O;){if(this._blockPos<this._block.length){const m=Math.min(this._block.length-this._blockPos,O-p);if(p!==0||m!==O||m<S.length?this._block.set(new Uint8Array(S.buffer,S.byteOffset+p,m),this._blockPos):this._block.set(S,this._blockPos),p+=m,this._blockPos+=m,this._blockPos<this._block.length)return;let B,x;if(this._macETM?this._len=x=i(this._block,0):(B=this._decipherInstance.update(this._block),this._len=i(B,0),x=4+this._len-this._blockSize),this._len>d||this._len<5||x&this._blockSize-1)throw new Error("Bad packet length");if(this._macInstance=e(this._macSSLName,this._macKey),o(g,this.inSeqno,0),this._macInstance.update(g),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(B.buffer,B.byteOffset,4)),this._pktLen=B.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(B.buffer,B.byteOffset+4,this._packetPos),0)),p>=O)return}if(this._pktLen<this._len){const m=Math.min(this._len-this._pktLen,O-p);let B;p!==0||m!==O?B=new Uint8Array(S.buffer,S.byteOffset+p,m):B=S,this._macETM&&this._macInstance.update(B);const x=this._decipherInstance.update(B);if(x.length&&(m===this._len?this._packet=x:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(x,this._packetPos)),this._packetPos+=x.length),p+=m,this._pktLen+=m,this._pktLen<this._len||p>=O)return}{const m=Math.min(this._macActualLen-this._macPos,O-p);if(p!==0||m!==O?this._mac.set(new Uint8Array(S.buffer,S.byteOffset+p,m),this._macPos):this._mac.set(S,this._macPos),p+=m,this._macPos+=m,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let ne=this._macInstance.digest();if(this._macActualLen<ne.length&&(ne=new Uint8Array(ne.buffer,ne.byteOffset,this._macActualLen)),!sn(ne,this._mac))throw new Error("Invalid MAC");const F=new f(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._macPos=0,this._macInstance=null;{const m=this._onPayload(F);if(m!==void 0)return m===!1?p:m}}}}class Ne{constructor(S){const p=S.inbound;this.inSeqno=p.seqno,this._onPayload=p.onPayload,this._instance=new ce(p.decipherInfo.sslName,p.decipherKey,p.decipherIV,p.macInfo.sslName,p.macKey,p.macInfo.isETM,p.macInfo.actualLen),this._block=Buffer.allocUnsafe(p.macInfo.isETM||p.decipherInfo.stream?4:p.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(p.macInfo.actualLen),this._macPos=0,this._macActualLen=p.macInfo.actualLen,this._macETM=p.macInfo.isETM}free(){this._instance.free()}decrypt(S,p,O){for(;p<O;){if(this._blockPos<this._block.length){const F=Math.min(this._block.length-this._blockPos,O-p);if(p!==0||F!==O||F<S.length?this._block.set(new Uint8Array(S.buffer,S.byteOffset+p,F),this._blockPos):this._block.set(S,this._blockPos),p+=F,this._blockPos+=F,this._blockPos<this._block.length)return;let m;if(this._macETM?this._len=m=i(this._block,0):(this._instance.decryptBlock(this._block),this._len=i(this._block,0),m=4+this._len-this._block.length),this._len>d||this._len<5||m&this._block.length-1)throw new Error("Bad packet length");if(this._macETM||(this._pktLen=this._block.length-4,this._pktLen&&(this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(this._block.buffer,this._block.byteOffset+4,this._pktLen),0))),p>=O)return}if(this._pktLen<this._len){const F=Math.min(this._len-this._pktLen,O-p);let m;if(p!==0||F!==O?m=new Uint8Array(S.buffer,S.byteOffset+p,F):m=S,F===this._len?this._packet=m:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(m,this._pktLen)),p+=F,this._pktLen+=F,this._pktLen<this._len||p>=O)return}{const F=Math.min(this._macActualLen-this._macPos,O-p);if(p!==0||F!==O?this._mac.set(new Uint8Array(S.buffer,S.byteOffset+p,F),this._macPos):this._mac.set(S,this._macPos),p+=F,this._macPos+=F,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);const ne=new f(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._macPos=0,this._macInstance=null;{const F=this._onPayload(ne);if(F!==void 0)return F===!1?p:F}}}}function Je(N){++N[11]>>>8&&++N[10]>>>8&&++N[9]>>>8&&++N[8]>>>8&&++N[7]>>>8&&++N[6]>>>8&&++N[5]>>>8&&++N[4]>>>8}const Gt=(()=>{const N=Buffer.alloc(4);return S=>(N[0]=S>>>24,N[1]=S>>>16,N[2]=S>>>8,N[3]=S,N)})();function sn(N,S){return N.length!==S.length?(s(N,N),!1):s(N,S)}function on(N){if(typeof N!="object"||N===null)throw new Error("Invalid config");if(typeof N.outbound!="object"||N.outbound===null)throw new Error("Invalid outbound");const S=N.outbound;if(typeof S.onWrite!="function")throw new Error("Invalid outbound.onWrite");if(typeof S.cipherInfo!="object"||S.cipherInfo===null)throw new Error("Invalid outbound.cipherInfo");if(!Buffer.isBuffer(S.cipherKey)||S.cipherKey.length!==S.cipherInfo.keyLen)throw new Error("Invalid outbound.cipherKey");if(S.cipherInfo.ivLen&&(!Buffer.isBuffer(S.cipherIV)||S.cipherIV.length!==S.cipherInfo.ivLen))throw new Error("Invalid outbound.cipherIV");if(typeof S.seqno!="number"||S.seqno<0||S.seqno>c)throw new Error("Invalid outbound.seqno");const p=!!S.forceNative;switch(S.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return I&&!p?new oe(N):new Ae(N);case"chacha20":return y&&!p?new ae(N):new he(N);default:{if(typeof S.macInfo!="object"||S.macInfo===null)throw new Error("Invalid outbound.macInfo");if(!Buffer.isBuffer(S.macKey)||S.macKey.length!==S.macInfo.len)throw new Error("Invalid outbound.macKey");return w&&!p?new Q(N):new ge(N)}}}function Nt(N){if(typeof N!="object"||N===null)throw new Error("Invalid config");if(typeof N.inbound!="object"||N.inbound===null)throw new Error("Invalid inbound");const S=N.inbound;if(typeof S.onPayload!="function")throw new Error("Invalid inbound.onPayload");if(typeof S.decipherInfo!="object"||S.decipherInfo===null)throw new Error("Invalid inbound.decipherInfo");if(!Buffer.isBuffer(S.decipherKey)||S.decipherKey.length!==S.decipherInfo.keyLen)throw new Error("Invalid inbound.decipherKey");if(S.decipherInfo.ivLen&&(!Buffer.isBuffer(S.decipherIV)||S.decipherIV.length!==S.decipherInfo.ivLen))throw new Error("Invalid inbound.decipherIV");if(typeof S.seqno!="number"||S.seqno<0||S.seqno>c)throw new Error("Invalid inbound.seqno");const p=!!S.forceNative;switch(S.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return R&&!p?new me(N):new we(N);case"chacha20":return M&&!p?new re(N):new Y(N);default:{if(typeof S.macInfo!="object"||S.macInfo===null)throw new Error("Invalid inbound.macInfo");if(!Buffer.isBuffer(S.macKey)||S.macKey.length!==S.macInfo.len)throw new Error("Invalid inbound.macKey");return ce&&!p?new Ne(N):new ve(N)}}}return Vr={CIPHER_INFO:le,MAC_INFO:se,bindingAvailable:!!A,init:(()=>new Promise(async(N,S)=>{try{T=await sf()(),J=T._malloc(16),X=T.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(p){return S(p)}N()}))(),NullCipher:fe,createCipher:on,NullDecipher:j,createDecipher:Nt},Vr}const{createDecipheriv:zr,createECDH:of,createHash:jn,createHmac:ff,createSign:af,createVerify:cf,getCiphers:hf,sign:qi,verify:Gi}=tt,uf=hf(),{Ber:Pe}=Ir,lf=Fi.pbkdf,{CIPHER_INFO:Vn}=Bn(),{eddsaSupported:Jr,SUPPORTED_CIPHER:df}=En(),{bufferSlice:kn,makeBufferParser:Af,readString:Le,readUInt32BE:zn,writeUInt32BE:Rt}=nn(),cn=Symbol("Hash Algorithm"),Jt=Symbol("Private key PEM"),rn=Symbol("Public key PEM"),pn=Symbol("Public key SSH"),On=Symbol("Decrypted Key"),Zr=Object.create(null);{const r=Object.keys(Vn);for(let t=0;t<r.length;++t){const e=Vn[r[t]].sslName;!e||Zr[e]||(Zr[e]=Vn[r[t]])}}const Sr=Af();function Zt(r,t){t=t.base64Slice(0,t.length);let e=t.replace(/.{64}/g,`$&
5
+ `);return t.length&63&&(e+=`
6
+ `),`-----BEGIN ${r} KEY-----
7
+ ${e}-----END ${r} KEY-----`}function Jn(r,t){const e=Buffer.allocUnsafe(r.length+t.length);return e.set(r,0),e.set(t,r.length),e}function ei(r,t){const e=r.length;let n=r._pos||0;for(let s=0;s<t;++s){const i=e-n;if(n>=e||i<4)return!1;const o=zn(r,n);if(i<4+o)return!1;n+=4+o}return r._pos=n,!0}function Zn(r,t){const e=new Pe.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.113549.1.1.1"),e.writeNull(),e.endSequence(),e.startSequence(Pe.BitString),e.writeByte(0),e.startSequence(),e.writeBuffer(r,Pe.Integer),e.writeBuffer(t,Pe.Integer),e.endSequence(),e.endSequence(),e.endSequence(),Zt("PUBLIC",e.buffer)}function er(r,t){const e=Buffer.allocUnsafe(15+t.length+4+r.length);Rt(e,7,0),e.utf8Write("ssh-rsa",4,7);let n=4+7;return Rt(e,t.length,n),e.set(t,n+=4),Rt(e,r.length,n+=t.length),e.set(r,n+4),e}const Yi=(()=>{function r(n,s,i,o,f,c,h,g){const u=new Pe.Writer;return u.startSequence(),u.writeInt(0,Pe.Integer),u.writeBuffer(n,Pe.Integer),u.writeBuffer(s,Pe.Integer),u.writeBuffer(i,Pe.Integer),u.writeBuffer(o,Pe.Integer),u.writeBuffer(f,Pe.Integer),u.writeBuffer(c,Pe.Integer),u.writeBuffer(h,Pe.Integer),u.writeBuffer(g,Pe.Integer),u.endSequence(),u.buffer}function t(n){return BigInt(`0x${n.hexSlice(0,n.length)}`)}function e(n){let s=n.toString(16);if(s.length&1)s=`0${s}`;else{const i=s.charCodeAt(0);(i===56||i===57||i>=97&&i<=102)&&(s=`00${s}`)}return Buffer.from(s,"hex")}return function(s,i,o,f,c,h){const g=t(o),u=e(g%(t(c)-1n)),d=e(g%(t(h)-1n));return Zt("RSA PRIVATE",r(s,i,o,c,h,u,d,f))}})();function tr(r,t,e,n){const s=new Pe.Writer;return s.startSequence(),s.startSequence(),s.writeOID("1.2.840.10040.4.1"),s.startSequence(),s.writeBuffer(r,Pe.Integer),s.writeBuffer(t,Pe.Integer),s.writeBuffer(e,Pe.Integer),s.endSequence(),s.endSequence(),s.startSequence(Pe.BitString),s.writeByte(0),s.writeBuffer(n,Pe.Integer),s.endSequence(),s.endSequence(),Zt("PUBLIC",s.buffer)}function nr(r,t,e,n){const s=Buffer.allocUnsafe(15+r.length+4+t.length+4+e.length+4+n.length);Rt(s,7,0),s.utf8Write("ssh-dss",4,7);let i=4+7;return Rt(s,r.length,i),s.set(r,i+=4),Rt(s,t.length,i+=r.length),s.set(t,i+=4),Rt(s,e.length,i+=t.length),s.set(e,i+=4),Rt(s,n.length,i+=e.length),s.set(n,i+4),s}function Xi(r,t,e,n,s){const i=new Pe.Writer;return i.startSequence(),i.writeInt(0,Pe.Integer),i.writeBuffer(r,Pe.Integer),i.writeBuffer(t,Pe.Integer),i.writeBuffer(e,Pe.Integer),i.writeBuffer(n,Pe.Integer),i.writeBuffer(s,Pe.Integer),i.endSequence(),Zt("DSA PRIVATE",i.buffer)}function ji(r){const t=new Pe.Writer;return t.startSequence(),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Pe.BitString),t.writeByte(0),t._ensure(r.length),t._buf.set(r,t._offset),t._offset+=r.length,t.endSequence(),t.endSequence(),Zt("PUBLIC",t.buffer)}function Vi(r){const t=Buffer.allocUnsafe(19+r.length);return Rt(t,11,0),t.utf8Write("ssh-ed25519",4,11),Rt(t,r.length,15),t.set(r,19),t}function gf(r){const t=new Pe.Writer;return t.startSequence(),t.writeInt(0,Pe.Integer),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Pe.OctetString),t.writeBuffer(r,Pe.OctetString),t.endSequence(),t.endSequence(),Zt("PRIVATE",t.buffer)}function ti(r,t){const e=new Pe.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.10045.2.1"),e.writeOID(r),e.endSequence(),e.startSequence(Pe.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),Zt("PUBLIC",e.buffer)}function ni(r,t){let e;switch(r){case"1.2.840.10045.3.1.7":e="nistp256";break;case"1.3.132.0.34":e="nistp384";break;case"1.3.132.0.35":e="nistp521";break;default:return}const n=Buffer.allocUnsafe(4+19+4+8+4+t.length);return Rt(n,19,0),n.utf8Write(`ecdsa-sha2-${e}`,4,19),Rt(n,8,23),n.utf8Write(e,27,8),Rt(n,t.length,35),n.set(t,39),n}function _f(r,t,e){const n=new Pe.Writer;return n.startSequence(),n.writeInt(1,Pe.Integer),n.writeBuffer(e,Pe.OctetString),n.startSequence(160),n.writeOID(r),n.endSequence(),n.startSequence(161),n.startSequence(Pe.BitString),n.writeByte(0),n._ensure(t.length),n._buf.set(t,n._offset),n._offset+=t.length,n.endSequence(),n.endSequence(),n.endSequence(),Zt("EC PRIVATE",n.buffer)}function Ef(r,t){const e=of(r);return e.setPrivateKey(t),e.getPublicKey()}const rr={sign:(()=>typeof qi=="function"?function(t,e){const n=this[Jt];if(n===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[cn]);try{return qi(e,t,n)}catch(s){return s}}:function(t,e){const n=this[Jt];if(n===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[cn]);const s=af(e);s.update(t);try{return s.sign(n)}catch(i){return i}})(),verify:(()=>typeof Gi=="function"?function(t,e,n){const s=this[rn];if(s===null)return new Error("No public key available");(!n||typeof n!="string")&&(n=this[cn]);try{return Gi(n,t,s,e)}catch(i){return i}}:function(t,e,n){const s=this[rn];if(s===null)return new Error("No public key available");(!n||typeof n!="string")&&(n=this[cn]);const i=cf(n);i.update(t);try{return i.verify(s,e)}catch(o){return o}})(),isPrivateKey:function(){return this[Jt]!==null},getPrivatePEM:function(){return this[Jt]},getPublicPEM:function(){return this[rn]},getPublicSSH:function(){return this[pn]},equals:function(t){const e=Zi(t);return e instanceof Error?!1:this.type===e.type&&this[Jt]===e[Jt]&&this[rn]===e[rn]&&this[pn]===e[pn]}};function wr(r,t,e,n,s,i,o){this.type=r,this.comment=t,this[Jt]=e,this[rn]=n,this[pn]=s,this[cn]=i,this[On]=o}wr.prototype=rr;{let t=function(e,n,s){const i=[];if(e.length<8)return new Error("Malformed OpenSSH private key");const o=zn(e,0),f=zn(e,4);if(o!==f)return s?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");e._pos=8;let c,h;for(c=0;c<n;++c){let u,d,A,I;const y=Le(e,e._pos,!0);if(y===void 0)return new Error("Malformed OpenSSH private key");switch(y){case"ssh-rsa":{const R=Le(e,e._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");const M=Le(e,e._pos);if(M===void 0)return new Error("Malformed OpenSSH private key");const ce=Le(e,e._pos);if(ce===void 0)return new Error("Malformed OpenSSH private key");const q=Le(e,e._pos);if(q===void 0)return new Error("Malformed OpenSSH private key");const le=Le(e,e._pos);if(le===void 0)return new Error("Malformed OpenSSH private key");const se=Le(e,e._pos);if(se===void 0)return new Error("Malformed OpenSSH private key");A=Zn(R,M),I=er(R,M),d=Yi(R,M,ce,q,le,se),u="sha1";break}case"ssh-dss":{const R=Le(e,e._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");const M=Le(e,e._pos);if(M===void 0)return new Error("Malformed OpenSSH private key");const ce=Le(e,e._pos);if(ce===void 0)return new Error("Malformed OpenSSH private key");const q=Le(e,e._pos);if(q===void 0)return new Error("Malformed OpenSSH private key");const le=Le(e,e._pos);if(le===void 0)return new Error("Malformed OpenSSH private key");A=tr(R,M,ce,q),I=nr(R,M,ce,q),d=Xi(R,M,ce,q,le),u="sha1";break}case"ssh-ed25519":{if(!Jr)return new Error(`Unsupported OpenSSH private key type: ${y}`);const R=Le(e,e._pos);if(R===void 0||R.length!==32)return new Error("Malformed OpenSSH private key");const M=Le(e,e._pos);if(M===void 0||M.length!==64)return new Error("Malformed OpenSSH private key");A=ji(R),I=Vi(R),d=gf(kn(M,0,32)),u=null;break}case"ecdsa-sha2-nistp256":u="sha256",h="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":u===void 0&&(u="sha384",h="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(u===void 0&&(u="sha512",h="1.3.132.0.35"),!ei(e,1))return new Error("Malformed OpenSSH private key");const R=Le(e,e._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");const M=Le(e,e._pos);if(M===void 0)return new Error("Malformed OpenSSH private key");A=ti(h,R),I=ni(h,R),d=_f(h,R,M);break}default:return new Error(`Unsupported OpenSSH private key type: ${y}`)}const w=Le(e,e._pos,!0);if(w===void 0)return new Error("Malformed OpenSSH private key");i.push(new wr(y,w,d,A,I,u,s))}let g=0;for(c=e._pos;c<e.length;++c)if(e[c]!==++g%255)return new Error("Malformed OpenSSH private key");return i};const r=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;wr.parse=(e,n)=>{const s=r.exec(e);if(s===null)return null;let i;const o=Buffer.from(s[1],"base64");if(o.length<31)return new Error("Malformed OpenSSH private key");const f=o.utf8Slice(0,15);if(f!=="openssh-key-v1\0")return new Error(`Unsupported OpenSSH key magic: ${f}`);const c=Le(o,15,!0);if(c===void 0)return new Error("Malformed OpenSSH private key");if(c!=="none"&&df.indexOf(c)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${c}`);const h=Le(o,o._pos,!0);if(h===void 0)return new Error("Malformed OpenSSH private key");if(h!=="none"){if(c==="none")return new Error("Malformed OpenSSH private key");if(h!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${h}`);if(!n)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(c!=="none")return new Error("Malformed OpenSSH private key");let g,u,d;c!=="none"&&(g=Vn[c]);const A=Le(o,o._pos);if(A===void 0)return new Error("Malformed OpenSSH private key");if(A.length)switch(h){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{const y=Le(A,0);if(y===void 0||A._pos+4>A.length)return new Error("Malformed OpenSSH private key");const w=zn(A,A._pos),R=Buffer.allocUnsafe(g.keyLen+g.ivLen);if(lf(n,n.length,y,y.length,R,R.length,w)!==0)return new Error("Failed to generate information to decrypt key");u=kn(R,0,g.keyLen),d=kn(R,g.keyLen,R.length);break}}else if(h!=="none")return new Error("Malformed OpenSSH private key");if(o._pos+3>=o.length)return new Error("Malformed OpenSSH private key");const I=zn(o,o._pos);if(o._pos+=4,I>0){for(let w=0;w<I;++w){const R=Le(o,o._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");if(Le(R,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let y=Le(o,o._pos);if(y===void 0)return new Error("Malformed OpenSSH private key");if(u!==void 0){if(y.length<g.blockLen||y.length%g.blockLen!==0)return new Error("Malformed OpenSSH private key");try{const w={authTagLength:g.authLen},R=zr(g.sslName,u,d,w);if(R.setAutoPadding(!1),g.authLen>0){if(o.length-o._pos<g.authLen)return new Error("Malformed OpenSSH private key");R.setAuthTag(kn(o,o._pos,o._pos+=g.authLen))}y=Jn(R.update(y),R.final())}catch(w){return w}}if(o._pos!==o.length)return new Error("Malformed OpenSSH private key");i=t(y,I,u!==void 0)}else i=[];return i instanceof Error?i:i[0]}}function mr(r,t,e,n,s,i,o){this.type=r,this.comment=t,this[Jt]=e,this[rn]=n,this[pn]=s,this[cn]=i,this[On]=o}mr.prototype=rr;{const r=/^-----BEGIN (RSA|DSA|EC) PRIVATE KEY-----(?:\r\n|\n)((?:[^:]+:\s*[\S].*(?:\r\n|\n))*)([\s\S]+)(?:\r\n|\n)-----END (RSA|DSA|EC) PRIVATE KEY-----$/;mr.parse=(t,e)=>{const n=r.exec(t);if(n===null)return null;let s=Buffer.from(n[3],"base64"),i=n[2],o=!1;if(i!==void 0){i=i.split(/\r\n|\n/g);for(let I=0;I<i.length;++I){const y=i[I];let w=y.indexOf(":");if(y.slice(0,w)==="DEK-Info"){const R=y.slice(w+2);if(w=R.indexOf(","),w===-1)continue;const M=R.slice(0,w).toLowerCase();if(uf.indexOf(M)===-1)return new Error(`Cipher (${M}) not supported for encrypted OpenSSH private key`);const ce=Zr[M];if(!ce)return new Error(`Cipher (${M}) not supported for encrypted OpenSSH private key`);const q=Buffer.from(R.slice(w+1),"hex");if(q.length!==ce.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!e)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");const le=kn(q,0,8);let se=jn("md5").update(e).update(le).digest();for(;se.length<ce.keyLen;)se=Jn(se,jn("md5").update(se).update(e).update(le).digest());se.length>ce.keyLen&&(se=kn(se,0,ce.keyLen));try{const fe=zr(M,se,q);fe.setAutoPadding(!1),s=Jn(fe.update(s),fe.final()),o=!0}catch(fe){return fe}}}}let f,c,h,g,u,d,A="Malformed OpenSSH private key";switch(o&&(A+=". Bad passphrase?"),n[1]){case"RSA":f="ssh-rsa",c=Zt("RSA PRIVATE",s);try{d=new Pe.Reader(s),d.readSequence(),d.readInt();const I=d.readString(Pe.Integer,!0);if(I===null)return new Error(A);const y=d.readString(Pe.Integer,!0);if(y===null)return new Error(A);h=Zn(I,y),g=er(I,y)}catch{return new Error(A)}u="sha1";break;case"DSA":f="ssh-dss",c=Zt("DSA PRIVATE",s);try{d=new Pe.Reader(s),d.readSequence(),d.readInt();const I=d.readString(Pe.Integer,!0);if(I===null)return new Error(A);const y=d.readString(Pe.Integer,!0);if(y===null)return new Error(A);const w=d.readString(Pe.Integer,!0);if(w===null)return new Error(A);const R=d.readString(Pe.Integer,!0);if(R===null)return new Error(A);h=tr(I,y,w,R),g=nr(I,y,w,R)}catch{return new Error(A)}u="sha1";break;case"EC":{let I,y,w;try{d=new Pe.Reader(s),d.readSequence(),d.readInt(),y=d.readString(Pe.OctetString,!0),d.readByte();const M=d.readLength();if(M!==null){if(d._offset=M,w=d.readOID(),w===null)return new Error(A);switch(w){case"1.2.840.10045.3.1.7":I="prime256v1",f="ecdsa-sha2-nistp256",u="sha256";break;case"1.3.132.0.34":I="secp384r1",f="ecdsa-sha2-nistp384",u="sha384";break;case"1.3.132.0.35":I="secp521r1",f="ecdsa-sha2-nistp521",u="sha512";break;default:return new Error(`Unsupported private key EC OID: ${w}`)}}else return new Error(A)}catch{return new Error(A)}c=Zt("EC PRIVATE",s);const R=Ef(I,y);h=ti(w,R),g=ni(w,R);break}}return new mr(f,"",c,h,g,u,o)}}function Cr(r,t,e,n,s,i,o){this.type=r,this.comment=t,this[Jt]=e,this[rn]=n,this[pn]=s,this[cn]=i,this[On]=o}Cr.prototype=rr;{const r=Buffer.alloc(0),t=Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e=Buffer.from([0,0,0,0]),n=Buffer.from([0,0,0,1]),s=/^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\r?\nEncryption: (aes256-cbc|none)\r?\nComment: ([^\r\n]*)\r?\nPublic-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-MAC: ([^\r\n]+)/;Cr.parse=(i,o)=>{const f=s.exec(i);if(f===null)return null;const c=f[2],h=c!=="none";if(h&&!o)return new Error("Encrypted PPK private key detected, but no passphrase given");let g=Buffer.from(f[5],"base64");if(h){const T=Vn[c];let J=Jn(jn("sha1").update(e).update(o).digest(),jn("sha1").update(n).update(o).digest());J.length>T.keyLen&&(J=kn(J,0,T.keyLen));try{const X=zr(T.sslName,J,t);X.setAutoPadding(!1),g=Jn(X.update(g),X.final())}catch(X){return X}}const u=f[1],d=f[3],A=Buffer.from(f[4],"base64"),I=f[6],y=u.length,w=c.length,R=Buffer.byteLength(d),M=A.length,ce=g.length,q=Buffer.allocUnsafe(4+y+4+w+4+R+4+M+4+ce);let le=0;if(Rt(q,y,le),q.utf8Write(u,le+=4,y),Rt(q,w,le+=y),q.utf8Write(c,le+=4,w),Rt(q,R,le+=w),q.utf8Write(d,le+=4,R),Rt(q,M,le+=R),q.set(A,le+=4),Rt(q,ce,le+=M),q.set(g,le+4),o||(o=r),ff("sha1",jn("sha1").update("putty-private-key-file-mac-key").update(o).digest()).update(q).digest("hex")!==I)return h?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let fe,k,v;switch(A._pos=0,ei(A,1),u){case"ssh-rsa":{const T=Le(A,A._pos);if(T===void 0)return new Error("Malformed PPK public key");const J=Le(A,A._pos);if(J===void 0)return new Error("Malformed PPK public key");const X=Le(g,0);if(X===void 0)return new Error("Malformed PPK private key");const he=Le(g,g._pos);if(he===void 0)return new Error("Malformed PPK private key");const ae=Le(g,g._pos);if(ae===void 0)return new Error("Malformed PPK private key");const Ae=Le(g,g._pos);if(Ae===void 0)return new Error("Malformed PPK private key");fe=Zn(J,T),k=er(J,T),v=Yi(J,T,X,Ae,he,ae);break}case"ssh-dss":{const T=Le(A,A._pos);if(T===void 0)return new Error("Malformed PPK public key");const J=Le(A,A._pos);if(J===void 0)return new Error("Malformed PPK public key");const X=Le(A,A._pos);if(X===void 0)return new Error("Malformed PPK public key");const he=Le(A,A._pos);if(he===void 0)return new Error("Malformed PPK public key");const ae=Le(g,0);if(ae===void 0)return new Error("Malformed PPK private key");fe=tr(T,J,X,he),k=nr(T,J,X,he),v=Xi(T,J,X,he,ae);break}}return new Cr(u,d,v,fe,k,"sha1",h)}}function Br(r,t,e,n,s){this.type=r,this.comment=t,this[Jt]=null,this[rn]=e,this[pn]=n,this[cn]=s,this[On]=!1}Br.prototype=rr;{let r;Jr?r=/^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/:r=/^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/,Br.parse=t=>{const e=r.exec(t);if(e===null)return null;const n=e[1],s=e[2],i=Buffer.from(e[3],"base64"),o=e[4]||"",f=Le(i,i._pos,!0);return f===void 0||f.indexOf(s)!==0?new Error("Malformed OpenSSH public key"):ri(i,s,o,n)}}function kr(r,t,e,n,s){this.type=r,this.comment=t,this[Jt]=null,this[rn]=e,this[pn]=n,this[cn]=s,this[On]=!1}kr.prototype=rr;{const r=/^---- BEGIN SSH2 PUBLIC KEY ----(?:\r?\n)((?:.{0,72}\r?\n)+)---- END SSH2 PUBLIC KEY ----$/,t=/^[A-Z0-9a-z/+=\r\n]+$/,e=/^([\x21-\x39\x3B-\x7E]{1,64}): ((?:[^\\]*\\\r?\n)*[^\r\n]+)\r?\n/gm,n=/\\\r?\n/g;kr.parse=s=>{let i=r.exec(s);if(i===null)return null;const o=i[1];let f=0,c="";for(;i=e.exec(o);){const A=i[1],I=i[2].replace(n,"");if(I.length>1024)return e.lastIndex=0,new Error("Malformed RFC4716 public key");f=e.lastIndex,A.toLowerCase()==="comment"&&(c=I,c.length>1&&c.charCodeAt(0)===34&&c.charCodeAt(c.length-1)===34&&(c=c.slice(1,-1)))}let h=o.slice(f);if(!t.test(h))return new Error("Malformed RFC4716 public key");h=Buffer.from(h,"base64");const g=Le(h,0,!0);if(g===void 0)return new Error("Malformed RFC4716 public key");let u=null,d=null;switch(g){case"ssh-rsa":{const A=Le(h,h._pos);if(A===void 0)return new Error("Malformed RFC4716 public key");const I=Le(h,h._pos);if(I===void 0)return new Error("Malformed RFC4716 public key");u=Zn(I,A),d=er(I,A);break}case"ssh-dss":{const A=Le(h,h._pos);if(A===void 0)return new Error("Malformed RFC4716 public key");const I=Le(h,h._pos);if(I===void 0)return new Error("Malformed RFC4716 public key");const y=Le(h,h._pos);if(y===void 0)return new Error("Malformed RFC4716 public key");const w=Le(h,h._pos);if(w===void 0)return new Error("Malformed RFC4716 public key");u=tr(A,I,y,w),d=nr(A,I,y,w);break}default:return new Error("Malformed RFC4716 public key")}return new kr(g,c,u,d,"sha1")}}function ri(r,t,e,n){if(!zi(t))return new Error(`Unsupported OpenSSH public key type: ${t}`);let s,i,o=null,f=null;switch(t){case"ssh-rsa":{const c=Le(r,r._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");const h=Le(r,r._pos);if(h===void 0)return new Error("Malformed OpenSSH public key");o=Zn(h,c),f=er(h,c),s="sha1";break}case"ssh-dss":{const c=Le(r,r._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");const h=Le(r,r._pos);if(h===void 0)return new Error("Malformed OpenSSH public key");const g=Le(r,r._pos);if(g===void 0)return new Error("Malformed OpenSSH public key");const u=Le(r,r._pos);if(u===void 0)return new Error("Malformed OpenSSH public key");o=tr(c,h,g,u),f=nr(c,h,g,u),s="sha1";break}case"ssh-ed25519":{const c=Le(r,r._pos||0);if(c===void 0||c.length!==32)return new Error("Malformed OpenSSH public key");o=ji(c),f=Vi(c),s=null;break}case"ecdsa-sha2-nistp256":s="sha256",i="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":s===void 0&&(s="sha384",i="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(s===void 0&&(s="sha512",i="1.3.132.0.35"),!ei(r,1))return new Error("Malformed OpenSSH public key");const c=Le(r,r._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");o=ti(i,c),f=ni(i,c);break}default:return new Error(`Unsupported OpenSSH public key type: ${t}`)}return new Br(n,e,o,f,s)}function zi(r){switch(r){case"ssh-rsa":case"ssh-dss":case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":return!0;case"ssh-ed25519":if(Jr)return!0;default:return!1}}function Ji(r){return r?typeof r[On]=="boolean":!1}function Zi(r,t){if(Ji(r))return r;let e;if(Buffer.isBuffer(r))e=r,r=r.utf8Slice(0,r.length).trim();else if(typeof r=="string")r=r.trim();else return new Error("Key data must be a Buffer or string");if(t!=null){if(typeof t=="string")t=Buffer.from(t);else if(!Buffer.isBuffer(t))return new Error("Passphrase must be a string or Buffer when supplied")}let n;if((n=wr.parse(r,t))!==null||(n=mr.parse(r,t))!==null||(n=Cr.parse(r,t))!==null||(n=Br.parse(r))!==null||(n=kr.parse(r))!==null)return n;if(e){Sr.init(e,0);const s=Sr.readString(!0);s!==void 0&&(r=Sr.readRaw(),r!==void 0&&(n=ri(r,s,"",s),n instanceof Error&&(n=null))),Sr.clear()}return n||new Error("Unsupported key format")}var Rn={isParsedKey:Ji,isSupportedKeyType:zi,parseDERKey:(r,t)=>ri(r,t,"",t),parseKey:Zi};const{Socket:es}=tt,{Duplex:ts}=tt,{resolve:pf}=tt,{readFile:ns}=tt,{execFile:bf,spawn:If}=tt,{isParsedKey:rs,parseKey:ir}=Rn,{makeBufferParser:xf,readUInt32BE:ii,writeUInt32BE:Kt,writeUInt32LE:is}=nn();function sr(r){let t=!1;return(...e)=>{t||(t=!0,r(...e))}}function yf(r,t){const e=Buffer.allocUnsafe(r.length+t.length);return r.copy(e,0),t.copy(e,r.length),e}function si(){}const Sf=Buffer.alloc(0),bt=xf();let oi=class{getIdentities(t){t(new Error("Missing getIdentities() implementation"))}sign(t,e,n,s){typeof n=="function"&&(s=n),s(new Error("Missing sign() implementation"))}},Rr=class extends oi{constructor(t){super(),this.socketPath=t}getStream(t){t=sr(t);const e=new es;e.on("connect",()=>{t(null,e)}),e.on("close",n).on("end",n).on("error",n),e.connect(this.socketPath);function n(){try{e.destroy()}catch{}t(new Error("Failed to connect to agent"))}}getIdentities(t){t=sr(t),this.getStream((e,n)=>{function s(o){if(n)try{n.destroy()}catch{}o||(o=new Error("Failed to retrieve identities from agent")),t(o)}if(e)return s(e);const i=new fi(!0);i.on("error",s),i.pipe(n).pipe(i),n.on("close",s).on("end",s).on("error",s),i.getIdentities((o,f)=>{if(o)return s(o);try{n.destroy()}catch{}t(null,f)})})}sign(t,e,n,s){typeof n=="function"?(s=n,n=void 0):(typeof n!="object"||n===null)&&(n=void 0),s=sr(s),this.getStream((i,o)=>{function f(h){if(o)try{o.destroy()}catch{}h||(h=new Error("Failed to sign data with agent")),s(h)}if(i)return f(i);const c=new fi(!0);c.on("error",f),c.pipe(o).pipe(c),o.on("close",f).on("end",f).on("error",f),c.sign(t,e,n,(h,g)=>{if(h)return f(h);try{o.destroy()}catch{}s(null,g)})})}};const ss=(()=>{const o=pf(__dirname,"..","util/pagent.exe"),f={10:new Error("Invalid pagent.exe arguments"),11:new Error("Pageant is not running"),12:new Error("pagent.exe could not create an mmap"),13:new Error("pagent.exe could not set mode for stdin"),14:new Error("pagent.exe could not set mode for stdout"),15:new Error("pagent.exe did not get expected input payload")};function c(g){g.buffer=null,g.proc&&(g.proc.kill(),g.proc=void 0)}class h extends ts{constructor(){super(),this.proc=void 0,this.buffer=null}_read(u){}_write(u,d,A){if(this.buffer===null)this.buffer=u;else{const R=Buffer.allocUnsafe(this.buffer.length+u.length);this.buffer.copy(R,0),u.copy(R,this.buffer.length),this.buffer=R}if(this.buffer.length<4)return A();const I=ii(this.buffer,0);if(this.buffer.length-4<I)return A();if(u=this.buffer.slice(0,4+I),this.buffer.length>4+I)return A(new Error("Unexpected multiple agent requests"));this.buffer=null;let y;const w=this.proc=If(o,[u.length]);w.stdout.on("data",R=>{this.push(R)}),w.on("error",R=>{y=R,A(y)}),w.on("close",R=>{if(this.proc=void 0,!y){if(y=f[R])return A(y);A()}}),w.stdin.end(u)}_final(u){c(this),u()}_destroy(u,d){c(this),d()}}return class extends Rr{getStream(u){u(null,new h)}}})(),os=(()=>{const r=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Rr{getStream(e){e=sr(e);let n=this.socketPath,s=!1;ns(n,function i(o,f){if(o){if(s)return e(new Error("Invalid cygwin unix socket path"));bf("cygpath",["-w",n],(se,fe,k)=>{if(se||fe.length===0)return e(new Error("Invalid cygwin unix socket path"));s=!0,n=fe.toString().replace(/[\r\n]/g,""),ns(n,i)});return}const c=r.exec(f.toString("ascii"));if(!c)return e(new Error("Malformed cygwin unix socket file"));let h,g=0,u=!1;const d=[];let A,I=Buffer.alloc(12);const y=parseInt(c[1],10),w=c[2].replace(/-/g,""),R=Buffer.allocUnsafe(16);for(let se=0,fe=0;fe<32;++se,fe+=2)R[se]=parseInt(w.substring(fe,fe+2),16);for(let se=0;se<16;se+=4)is(R,ii(R,se),se);le();function M(){g=0,h="secret",A.write(R)}function ce(se){if(g+=se.length,h==="secret"){g===16&&(g=0,h="creds",A.write(I));return}if(h==="creds"&&(u||d.push(se),g===12)){if(A.removeListener("connect",M),A.removeListener("data",ce),A.removeListener("error",q),A.removeListener("end",q),A.removeListener("close",q),u)return e(null,A);u=!0,I=Buffer.concat(d),is(I,process.pid,0),A.on("error",()=>{}),A.destroy(),le()}}function q(){e(new Error("Problem negotiating cygwin unix socket security"))}function le(){A=new es,A.on("connect",M),A.on("data",ce),A.on("error",q),A.on("end",q),A.on("close",q),A.connect(y)}})}}})(),wf=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function fs(r){return process.platform==="win32"&&!wf.test(r)?r==="pageant"?new ss:new os(r):new Rr(r)}const fi=(()=>{function h(k){let v;for(;k[M].length;){const T=k[M][0][u];if(T===void 0)break;k[M].shift(),v=k.push(T)}return v}const g=Symbol("Inbound Request Type"),u=Symbol("Inbound Request Response"),d=Symbol("Inbound Request Context");class A{constructor(v,T){this[g]=v,this[u]=void 0,this[d]=T}hasResponded(){return this[u]!==void 0}getType(){return this[g]}getContext(){return this[d]}}function I(k,v,T){return v[u]=T,h(k)}function y(k){if(k[q]=null,k[ce]===0){const v=k[M];if(v&&v.length){k[M]=[];for(const T of v)T.cb(new Error("No reply from server"))}}try{k.end()}catch{}setImmediate(()=>{k[fe]||k.emit("end"),k[se]||k.emit("close")})}function w(){this[se]=!0}function R(){this[fe]=!0}const M=Symbol("Requests"),ce=Symbol("Agent Protocol Role"),q=Symbol("Agent Protocol Buffer"),le=Symbol("Agent Protocol Current Message Length"),se=Symbol("Agent Protocol Closed"),fe=Symbol("Agent Protocol Ended");return class extends ts{constructor(v){super({autoDestroy:!0,emitClose:!1}),this[ce]=v?0:1,this[M]=[],this[q]=null,this[le]=-1,this.once("end",R),this.once("close",w)}_read(v){}_write(v,T,J){this[q]===null?this[q]=v:this[q]=yf(this[q],v);let X=this[q],he=X.length,ae=0;for(;ae<he&&!(he<5||(this[le]===-1&&(this[le]=ii(X,ae)),he<4+this[le]));){const Ae=X[ae+=4];if(++ae,this[ce]===0){if(this[M].length===0)return J(new Error("Received unexpected message from server"));const oe=this[M].shift();switch(Ae){case 5:oe.cb(new Error("Agent responded with failure"));break;case 12:{if(oe.type!==11)return J(new Error("Agent responded with wrong message type"));bt.init(X,ae);const ge=bt.readUInt32BE();if(ge===void 0)return bt.clear(),J(new Error("Malformed agent response"));const Q=[];for(let j=0;j<ge;++j){let Y=bt.readString();if(Y===void 0)return bt.clear(),J(new Error("Malformed agent response"));const re=bt.readString(!0);if(re===void 0)return bt.clear(),J(new Error("Malformed agent response"));Y=ir(Y),!(Y instanceof Error)&&(Y.comment=Y.comment||re,Q.push(Y))}ae=bt.pos(),bt.clear(),oe.cb(null,Q);break}case 14:{if(oe.type!==13)return J(new Error("Agent responded with wrong message type"));bt.init(X,ae);let ge=bt.readString();if(ae=bt.pos(),bt.clear(),ge===void 0)return J(new Error("Malformed agent response"));if(bt.init(ge,0),bt.readString(!0),ge=bt.readString(),bt.clear(),ge===void 0)return J(new Error("Malformed OpenSSH signature format"));oe.cb(null,ge);break}default:return J(new Error("Agent responded with unsupported message type"))}}else switch(Ae){case 11:{const oe=new A(Ae);this[M].push(oe),this.emit("identities",oe);break}case 13:{bt.init(X,ae);let oe=bt.readString();const ge=bt.readString(),Q=bt.readUInt32BE();if(ae=bt.pos(),bt.clear(),Q===void 0){const we=new A(Ae);return this[M].push(we),this.failureReply(we)}if(oe=ir(oe),oe instanceof Error){const we=new A(Ae);return this[M].push(we),this.failureReply(we)}const j={hash:void 0};let Y;oe.type==="ssh-rsa"&&(Q&2?(Y="rsa-sha2-256",j.hash="sha256"):Q&4&&(Y="rsa-sha2-512",j.hash="sha512")),Y===void 0&&(Y=oe.type);const re=new A(Ae,Y);this[M].push(re),this.emit("sign",re,oe,ge,j);break}default:{const oe=new A(Ae);this[M].push(oe),this.failureReply(oe)}}if(this[le]=-1,ae===he){this[q]=null;break}else this[q]=X=X.slice(ae),he=X.length,ae=0}J()}_destroy(v,T){y(this),T()}_final(v){y(this),v()}sign(v,T,J,X){if(this[ce]!==0)throw new Error("Client-only method called with server role");typeof J=="function"?(X=J,J=void 0):(typeof J!="object"||J===null)&&(J=void 0);let he=0;if(v=ir(v),v instanceof Error)throw new Error("Invalid public key argument");if(v.type==="ssh-rsa"&&J)switch(J.hash){case"sha256":he=2;break;case"sha512":he=4;break}v=v.getPublicSSH();const ae=13,Ae=v.length,oe=T.length;let ge=0;const Q=Buffer.allocUnsafe(4+1+4+Ae+4+oe+4);return Kt(Q,Q.length-4,ge),Q[ge+=4]=ae,Kt(Q,Ae,++ge),v.copy(Q,ge+=4),Kt(Q,oe,ge+=Ae),T.copy(Q,ge+=4),Kt(Q,he,ge+=oe),typeof X!="function"&&(X=si),this[M].push({type:ae,cb:X}),this.push(Q)}getIdentities(v){if(this[ce]!==0)throw new Error("Client-only method called with server role");const T=11;let J=0;const X=Buffer.allocUnsafe(4+1);return Kt(X,X.length-4,J),X[J+=4]=T,typeof v!="function"&&(v=si),this[M].push({type:T,cb:v}),this.push(X)}failureReply(v){if(this[ce]!==1)throw new Error("Server-only method called with client role");if(!(v instanceof A))throw new Error("Wrong request argument");if(v.hasResponded())return!0;let T=0;const J=Buffer.allocUnsafe(4+1);return Kt(J,J.length-4,T),J[T+=4]=5,I(this,v,J)}getIdentitiesReply(v,T){if(this[ce]!==1)throw new Error("Server-only method called with client role");if(!(v instanceof A))throw new Error("Wrong request argument");if(v.hasResponded())return!0;if(v.getType()!==11)throw new Error("Invalid response to request");if(!Array.isArray(T))throw new Error("Keys argument must be an array");let J=4;const X=[];for(let Ae=0;Ae<T.length;++Ae){const oe=T[Ae];if(typeof oe!="object"||oe===null)throw new Error(`Invalid key entry: ${oe}`);let ge,Q;if(rs(oe))ge=oe;else if(rs(oe.pubKey))ge=oe.pubKey;else if(typeof oe.pubKey!="object"||oe.pubKey===null||({pubKey:ge,comment:Q}=oe.pubKey,ge=ir(ge),ge instanceof Error))continue;Q=ge.comment||Q,ge=ge.getPublicSSH(),J+=4+ge.length,Q&&typeof Q=="string"?Q=Buffer.from(Q):Buffer.isBuffer(Q)||(Q=Sf),J+=4+Q.length,X.push({pubKey:ge,comment:Q})}let he=0;const ae=Buffer.allocUnsafe(4+1+J);Kt(ae,ae.length-4,he),ae[he+=4]=12,Kt(ae,X.length,++he),he+=4;for(let Ae=0;Ae<X.length;++Ae){const{pubKey:oe,comment:ge}=X[Ae];Kt(ae,oe.length,he),oe.copy(ae,he+=4),Kt(ae,ge.length,he+=oe.length),he+=4,ge.length&&(ge.copy(ae,he),he+=ge.length)}return I(this,v,ae)}signReply(v,T){if(this[ce]!==1)throw new Error("Server-only method called with client role");if(!(v instanceof A))throw new Error("Wrong request argument");if(v.hasResponded())return!0;if(v.getType()!==13)throw new Error("Invalid response to request");if(!Buffer.isBuffer(T))throw new Error("Signature argument must be a Buffer");if(T.length===0)throw new Error("Signature argument must be non-empty");let J=0;const X=v.getContext(),he=Buffer.byteLength(X),ae=Buffer.allocUnsafe(4+1+4+4+he+4+T.length);return Kt(ae,ae.length-4,J),ae[J+=4]=14,Kt(ae,4+he+4+T.length,++J),Kt(ae,he,J+=4),ae.utf8Write(X,J+=4,he),Kt(ae,T.length,J+=he),T.copy(ae,J+=4),I(this,v,ae)}}})(),ai=Symbol("Agent"),en=Symbol("Agent Keys"),hn=Symbol("Agent Keys Index"),Dn=Symbol("Agent Init Callbacks");let mf=class{constructor(t){if(typeof t=="string")t=fs(t);else if(!as(t))throw new Error("Invalid agent argument");this[ai]=t,this[en]=null,this[hn]=-1,this[Dn]=null}init(t){if(typeof t!="function"&&(t=si),this[en]===null)if(this[Dn]===null){this[Dn]=[t];const e=(...n)=>{process.nextTick(()=>{const s=this[Dn];this[Dn]=null;for(const i of s)i(...n)})};this[ai].getIdentities(sr((n,s)=>{if(n)return e(n);if(!Array.isArray(s))return e(new Error("Agent implementation failed to provide keys"));const i=[];for(let o of s)o=ir(o),!(o instanceof Error)&&i.push(o);this[en]=i,this[hn]=-1,e()}))}else this[Dn].push(t);else process.nextTick(t)}nextKey(){return this[en]===null||++this[hn]>=this[en].length?!1:this[en][this[hn]]}currentKey(){return this[en]===null||this[hn]>=this[en].length?null:this[en][this[hn]]}pos(){return this[en]===null||this[hn]>=this[en].length?-1:this[hn]}reset(){this[hn]=-1}sign(...t){this[ai].sign(...t)}};function as(r){return r instanceof oi}var cs={AgentContext:mf,AgentProtocol:fi,BaseAgent:oi,createAgent:fs,CygwinAgent:os,isAgent:as,OpenSSHAgent:Rr,PageantAgent:ss},hs={};const{kMaxLength:Cf}=tt,{createInflate:Bf,constants:{DEFLATE:kf,INFLATE:Rf,Z_DEFAULT_CHUNK:Nf,Z_DEFAULT_COMPRESSION:vf,Z_DEFAULT_MEMLEVEL:Tf,Z_DEFAULT_STRATEGY:Lf,Z_DEFAULT_WINDOWBITS:Uf,Z_PARTIAL_FLUSH:Pf}}=tt,Of=Bf()._handle.constructor;function Df(){throw new Error("Should not get here")}function Hf(r,t,e){const n=this._owner,s=new Error(r);s.errno=t,s.code=e,n._err=s}function ci(r){r._handle&&(r._handle.close(),r._handle=null)}class us{constructor(t){const e=Uf,n=vf,s=Tf,i=Lf,o=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=Nf,this._maxOutputLength=Cf,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new Of(t),this._handle._owner=this,this._handle.onerror=Hf,this._handle.init(e,n,s,i,this._writeState,Df,o)}writeSync(t,e){const n=this._handle;if(!n)throw new Error("Invalid Zlib instance");let s=t.length,i=this._chunkSize-this._outOffset,o=0,f,c,h,g=0;const u=this._writeState;let d=this._outBuffer,A=this._outOffset;const I=this._chunkSize;for(;;){if(n.writeSync(Pf,t,o,s,d,A,i),this._err)throw this._err;f=u[0],c=u[1];const w=s-c,R=i-f;if(R>0){const M=A===0&&R===d.length?d:d.slice(A,A+R);if(A+=R,h?h.push===void 0?h=[h,M]:h.push(M):h=M,g+=M.byteLength,g>this._maxOutputLength)throw ci(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(R!==0)throw new Error("have should not go down");if((f===0||A>=I)&&(i=I,A=0,d=Buffer.allocUnsafe(I)),f===0)o+=w,s=c;else break}if(this._outBuffer=d,this._outOffset=A,g===0&&(h=Buffer.alloc(0)),e)return h.totalLen=g,h;if(h.push===void 0)return h;const y=Buffer.allocUnsafe(g);for(let w=0,R=0;w<h.length;++w){const M=h[w];y.set(M,R),R+=M.length}return y}}var ls={PacketReader:class{cleanup(){}read(t){return t}},PacketWriter:class{constructor(t){this.allocStart=5,this.allocStartKEX=5,this._protocol=t}cleanup(){}alloc(t,e){return this._protocol._kexinit===void 0||e?this._protocol._cipher.allocPacket(t):Buffer.allocUnsafe(t)}finalize(t,e){return t}},ZlibPacketReader:class{constructor(){this._zlib=new us(Rf)}cleanup(){this._zlib&&ci(this._zlib)}read(t){return this._zlib.writeSync(t,!1)}},ZlibPacketWriter:class{constructor(t){this.allocStart=0,this.allocStartKEX=0,this._protocol=t,this._zlib=new us(kf)}cleanup(){this._zlib&&ci(this._zlib)}alloc(t,e){return Buffer.allocUnsafe(t)}finalize(t,e){if(this._protocol._kexinit===void 0||e){const n=this._zlib.writeSync(t,!0),s=this._protocol._cipher.allocPacket(n.totalLen);if(n.push===void 0)s.set(n,5);else for(let i=0,o=5;i<n.length;++i){const f=n[i];s.set(f,o),o+=f.length}return s}return t}}};const{bufferSlice:hi,bufferParser:U,doFatalError:_t,sigSSHToASN1:ds,writeUInt32BE:As}=nn(),{CHANNEL_OPEN_FAILURE:Qf,COMPAT:Ff,MESSAGE:Et,TERMINAL_MODE:gs}=En(),{parseKey:Mf}=Rn,Kf=Array.from(Object.entries(gs)).reduce((r,[t,e])=>({...r,[t]:e}),{});var Wf={[Et.DISCONNECT]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE(),n=U.readString(!0),s=U.readString();if(U.clear(),s===void 0)return _t(r,"Inbound: Malformed DISCONNECT packet");r._debug&&r._debug(`Inbound: Received DISCONNECT (${e}, "${n}")`);const i=r._handlers.DISCONNECT;i&&i(r,e,n)},[Et.IGNORE]:(r,t)=>{r._debug&&r._debug("Inbound: Received IGNORE")},[Et.UNIMPLEMENTED]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE();if(U.clear(),e===void 0)return _t(r,"Inbound: Malformed UNIMPLEMENTED packet");r._debug&&r._debug(`Inbound: Received UNIMPLEMENTED (seqno ${e})`)},[Et.DEBUG]:(r,t)=>{U.init(t,1);const e=U.readBool(),n=U.readString(!0),s=U.readString();if(U.clear(),s===void 0)return _t(r,"Inbound: Malformed DEBUG packet");r._debug&&r._debug("Inbound: Received DEBUG");const i=r._handlers.DEBUG;i&&i(r,e,n)},[Et.SERVICE_REQUEST]:(r,t)=>{U.init(t,1);const e=U.readString(!0);if(U.clear(),e===void 0)return _t(r,"Inbound: Malformed SERVICE_REQUEST packet");r._debug&&r._debug(`Inbound: Received SERVICE_REQUEST (${e})`);const n=r._handlers.SERVICE_REQUEST;n&&n(r,e)},[Et.SERVICE_ACCEPT]:(r,t)=>{U.init(t,1);const e=U.readString(!0);if(U.clear(),e===void 0)return _t(r,"Inbound: Malformed SERVICE_ACCEPT packet");r._debug&&r._debug(`Inbound: Received SERVICE_ACCEPT (${e})`);const n=r._handlers.SERVICE_ACCEPT;n&&n(r,e)},[Et.EXT_INFO]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE();let n;if(e!==void 0){n=[];for(let i=0;i<e;++i){const o=U.readString(!0),f=U.readString();if(f!==void 0)switch(o){case"server-sig-algs":{const c=f.latin1Slice(0,f.length).split(",");n.push({name:o,algs:c});continue}default:continue}n=void 0;break}}if(U.clear(),n===void 0)return _t(r,"Inbound: Malformed EXT_INFO packet");r._debug&&r._debug("Inbound: Received EXT_INFO");const s=r._handlers.EXT_INFO;s&&s(r,n)},[Et.USERAUTH_REQUEST]:(r,t)=>{U.init(t,1);const e=U.readString(!0),n=U.readString(!0),s=U.readString(!0);let i,o;switch(s){case"none":i=null;break;case"password":{const c=U.readBool();if(c!==void 0&&(i=U.readString(!0),i!==void 0&&c)){const h=U.readString(!0);h!==void 0?i={oldPassword:i,newPassword:h}:i=void 0}break}case"publickey":{const c=U.readBool();if(c!==void 0){const h=U.readString(!0);let g=h;const u=U.readString();let d;switch(h){case"rsa-sha2-256":g="ssh-rsa",d="sha256";break;case"rsa-sha2-512":g="ssh-rsa",d="sha512";break}if(c){const A=U.pos();let I=U.readString();if(I!==void 0&&(I.length>4+h.length+4&&I.utf8Slice(4,4+h.length)===h&&(I=hi(I,4+h.length+4)),I=ds(I,g),I)){const y=r._kex.sessionID,w=Buffer.allocUnsafe(4+y.length+A);As(w,y.length,0),w.set(y,4),w.set(new Uint8Array(t.buffer,t.byteOffset,A),4+y.length),i={keyAlgo:g,key:u,signature:I,blob:w,hashAlgo:d}}}else i={keyAlgo:g,key:u,hashAlgo:d},o="publickey -- check"}break}case"hostbased":{const c=U.readString(!0);let h=c;const g=U.readString(),u=U.readString(!0),d=U.readString(!0);let A;switch(c){case"rsa-sha2-256":h="ssh-rsa",A="sha256";break;case"rsa-sha2-512":h="ssh-rsa",A="sha512";break}const I=U.pos();let y=U.readString();if(y!==void 0&&(y.length>4+c.length+4&&y.utf8Slice(4,4+c.length)===c&&(y=hi(y,4+c.length+4)),y=ds(y,h),y!==void 0)){const w=r._kex.sessionID,R=Buffer.allocUnsafe(4+w.length+I);As(R,w.length,0),R.set(w,4),R.set(new Uint8Array(t.buffer,t.byteOffset,I),4+w.length),i={keyAlgo:h,key:g,signature:y,blob:R,localHostname:u,localUsername:d,hashAlgo:A}}break}case"keyboard-interactive":U.skipString(),i=U.readList();break;default:s!==void 0&&(i=U.readRaw())}if(U.clear(),i===void 0)return _t(r,"Inbound: Malformed USERAUTH_REQUEST packet");o===void 0&&(o=s),r._authsQueue.push(s),r._debug&&r._debug(`Inbound: Received USERAUTH_REQUEST (${o})`);const f=r._handlers.USERAUTH_REQUEST;f&&f(r,e,n,s,i)},[Et.USERAUTH_FAILURE]:(r,t)=>{U.init(t,1);const e=U.readList(),n=U.readBool();if(U.clear(),n===void 0)return _t(r,"Inbound: Malformed USERAUTH_FAILURE packet");r._debug&&r._debug(`Inbound: Received USERAUTH_FAILURE (${e})`),r._authsQueue.shift();const s=r._handlers.USERAUTH_FAILURE;s&&s(r,e,n)},[Et.USERAUTH_SUCCESS]:(r,t)=>{r._debug&&r._debug("Inbound: Received USERAUTH_SUCCESS"),r._authsQueue.shift();const e=r._handlers.USERAUTH_SUCCESS;e&&e(r)},[Et.USERAUTH_BANNER]:(r,t)=>{U.init(t,1);const e=U.readString(!0),n=U.readString();if(U.clear(),n===void 0)return _t(r,"Inbound: Malformed USERAUTH_BANNER packet");r._debug&&r._debug("Inbound: Received USERAUTH_BANNER");const s=r._handlers.USERAUTH_BANNER;s&&s(r,e)},60:(r,t)=>{if(!r._authsQueue.length){r._debug&&r._debug("Inbound: Received payload type 60 without auth");return}switch(r._authsQueue[0]){case"password":{U.init(t,1);const e=U.readString(!0),n=U.readString();if(U.clear(),n===void 0)return _t(r,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");r._debug&&r._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");const s=r._handlers.USERAUTH_PASSWD_CHANGEREQ;s&&s(r,e);break}case"publickey":{U.init(t,1);const e=U.readString(!0),n=U.readString();if(U.clear(),n===void 0)return _t(r,"Inbound: Malformed USERAUTH_PK_OK packet");r._debug&&r._debug("Inbound: Received USERAUTH_PK_OK"),r._authsQueue.shift();const s=r._handlers.USERAUTH_PK_OK;s&&s(r,e,n);break}case"keyboard-interactive":{U.init(t,1);const e=U.readString(!0),n=U.readString(!0);U.readString();const s=U.readUInt32BE();let i;if(s!==void 0){i=new Array(s);let f;for(f=0;f<s;++f){const c=U.readString(!0),h=U.readBool();if(h===void 0)break;i[f]={prompt:c,echo:h}}f!==s&&(i=void 0)}if(U.clear(),i===void 0)return _t(r,"Inbound: Malformed USERAUTH_INFO_REQUEST packet");r._debug&&r._debug("Inbound: Received USERAUTH_INFO_REQUEST");const o=r._handlers.USERAUTH_INFO_REQUEST;o&&o(r,e,n,i);break}default:r._debug&&r._debug("Inbound: Received unexpected payload type 60")}},61:(r,t)=>{if(!r._authsQueue.length){r._debug&&r._debug("Inbound: Received payload type 61 without auth");return}if(r._authsQueue[0]!=="keyboard-interactive")return _t(r,"Inbound: Received unexpected payload type 61");U.init(t,1);const e=U.readUInt32BE();let n;if(e!==void 0){n=new Array(e);let i;for(i=0;i<e;++i){const o=U.readString(!0);if(o===void 0)break;n[i]=o}i!==e&&(n=void 0)}if(U.clear(),n===void 0)return _t(r,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");r._debug&&r._debug("Inbound: Received USERAUTH_INFO_RESPONSE");const s=r._handlers.USERAUTH_INFO_RESPONSE;s&&s(r,n)},[Et.GLOBAL_REQUEST]:(r,t)=>{U.init(t,1);const e=U.readString(!0),n=U.readBool();let s;if(n!==void 0)switch(e){case"tcpip-forward":case"cancel-tcpip-forward":{const o=U.readString(!0),f=U.readUInt32BE();f!==void 0&&(s={bindAddr:o,bindPort:f});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{const o=U.readString(!0);o!==void 0&&(s={socketPath:o});break}case"no-more-sessions@openssh.com":s=null;break;case"hostkeys-00@openssh.com":{for(s=[];U.avail()>0;){const o=U.readString();if(o===void 0){s=void 0;break}const f=Mf(o);f instanceof Error||s.push(f)}break}default:s=U.readRaw()}if(U.clear(),s===void 0)return _t(r,"Inbound: Malformed GLOBAL_REQUEST packet");r._debug&&r._debug(`Inbound: GLOBAL_REQUEST (${e})`);const i=r._handlers.GLOBAL_REQUEST;i?i(r,e,n,s):r.requestFailure()},[Et.REQUEST_SUCCESS]:(r,t)=>{const e=t.length>1?hi(t,1):null;r._debug&&r._debug("Inbound: REQUEST_SUCCESS");const n=r._handlers.REQUEST_SUCCESS;n&&n(r,e)},[Et.REQUEST_FAILURE]:(r,t)=>{r._debug&&r._debug("Inbound: Received REQUEST_FAILURE");const e=r._handlers.REQUEST_FAILURE;e&&e(r)},[Et.CHANNEL_OPEN]:(r,t)=>{U.init(t,1);const e=U.readString(!0),n=U.readUInt32BE(),s=U.readUInt32BE(),i=U.readUInt32BE();let o;switch(e){case"forwarded-tcpip":case"direct-tcpip":{const c=U.readString(!0),h=U.readUInt32BE(),g=U.readString(!0),u=U.readUInt32BE();u!==void 0&&(o={type:e,sender:n,window:s,packetSize:i,data:{destIP:c,destPort:h,srcIP:g,srcPort:u}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{const c=U.readString(!0);c!==void 0&&(o={type:e,sender:n,window:s,packetSize:i,data:{socketPath:c}});break}case"x11":{const c=U.readString(!0),h=U.readUInt32BE();h!==void 0&&(o={type:e,sender:n,window:s,packetSize:i,data:{srcIP:c,srcPort:h}});break}default:o={type:e,sender:n,window:s,packetSize:i,data:{}}}if(U.clear(),o===void 0)return _t(r,"Inbound: Malformed CHANNEL_OPEN packet");r._debug&&r._debug(`Inbound: CHANNEL_OPEN (s:${n}, ${e})`);const f=r._handlers.CHANNEL_OPEN;f?f(r,o):r.channelOpenFail(o.sender,Qf.ADMINISTRATIVELY_PROHIBITED,"","")},[Et.CHANNEL_OPEN_CONFIRMATION]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE(),n=U.readUInt32BE(),s=U.readUInt32BE(),i=U.readUInt32BE(),o=U.avail()?U.readRaw():void 0;if(U.clear(),i===void 0)return _t(r,"Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet");r._debug&&r._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${e}, s:${n})`);const f=r._handlers.CHANNEL_OPEN_CONFIRMATION;f&&f(r,{recipient:e,sender:n,window:s,packetSize:i,data:o})},[Et.CHANNEL_OPEN_FAILURE]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE(),n=U.readUInt32BE(),s=U.readString(!0),i=U.readString();if(U.clear(),i===void 0)return _t(r,"Inbound: Malformed CHANNEL_OPEN_FAILURE packet");r._debug&&r._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${e})`);const o=r._handlers.CHANNEL_OPEN_FAILURE;o&&o(r,e,n,s)},[Et.CHANNEL_WINDOW_ADJUST]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE(),n=U.readUInt32BE();if(U.clear(),n===void 0)return _t(r,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");r._debug&&r._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${e}, ${n})`);const s=r._handlers.CHANNEL_WINDOW_ADJUST;s&&s(r,e,n)},[Et.CHANNEL_DATA]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE(),n=U.readString();if(U.clear(),n===void 0)return _t(r,"Inbound: Malformed CHANNEL_DATA packet");r._debug&&r._debug(`Inbound: CHANNEL_DATA (r:${e}, ${n.length})`);const s=r._handlers.CHANNEL_DATA;s&&s(r,e,n)},[Et.CHANNEL_EXTENDED_DATA]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE(),n=U.readUInt32BE(),s=U.readString();if(U.clear(),s===void 0)return _t(r,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");r._debug&&r._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${e}, ${s.length})`);const i=r._handlers.CHANNEL_EXTENDED_DATA;i&&i(r,e,s,n)},[Et.CHANNEL_EOF]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE();if(U.clear(),e===void 0)return _t(r,"Inbound: Malformed CHANNEL_EOF packet");r._debug&&r._debug(`Inbound: CHANNEL_EOF (r:${e})`);const n=r._handlers.CHANNEL_EOF;n&&n(r,e)},[Et.CHANNEL_CLOSE]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE();if(U.clear(),e===void 0)return _t(r,"Inbound: Malformed CHANNEL_CLOSE packet");r._debug&&r._debug(`Inbound: CHANNEL_CLOSE (r:${e})`);const n=r._handlers.CHANNEL_CLOSE;n&&n(r,e)},[Et.CHANNEL_REQUEST]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE(),n=U.readString(!0),s=U.readBool();let i;if(s!==void 0)switch(n){case"exit-status":i=U.readUInt32BE(),r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n}: ${i})`);break;case"exit-signal":{let f,c;if(r._compatFlags&Ff.OLD_EXIT){const g=U.readUInt32BE();switch(g){case 1:f="HUP";break;case 2:f="INT";break;case 3:f="QUIT";break;case 6:f="ABRT";break;case 9:f="KILL";break;case 14:f="ALRM";break;case 15:f="TERM";break;default:g!==void 0&&(f=`UNKNOWN (${g})`)}c=!1}else f=U.readString(!0),c=U.readBool(),c===void 0&&(f=void 0);const h=U.readString(!0);U.skipString()!==void 0&&(i={signal:f,coreDumped:c,errorMessage:h}),r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n}: ${f})`);break}case"pty-req":{const f=U.readString(!0),c=U.readUInt32BE(),h=U.readUInt32BE(),g=U.readUInt32BE(),u=U.readUInt32BE(),d=U.readString();if(d!==void 0){U.init(d,1);let A={};for(;U.avail();){const I=U.readByte();if(I===gs.TTY_OP_END)break;const y=Kf[I],w=U.readUInt32BE();if(I===void 0||y===void 0||w===void 0){A=void 0;break}A[y]=w}A!==void 0&&(i={term:f,cols:c,rows:h,width:g,height:u,modes:A})}r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n})`);break}case"window-change":{const f=U.readUInt32BE(),c=U.readUInt32BE(),h=U.readUInt32BE(),g=U.readUInt32BE();g!==void 0&&(i={cols:f,rows:c,width:h,height:g}),r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n})`);break}case"x11-req":{const f=U.readBool(),c=U.readString(!0),h=U.readString(),g=U.readUInt32BE();g!==void 0&&(i={single:f,protocol:c,cookie:h,screen:g}),r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n})`);break}case"env":{const f=U.readString(!0),c=U.readString(!0);c!==void 0&&(i={name:f,value:c}),r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n}: ${f}=${c})`);break}case"shell":i=null,r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n})`);break;case"exec":i=U.readString(!0),r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n}: ${i})`);break;case"subsystem":i=U.readString(!0),r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n}: ${i})`);break;case"signal":i=U.readString(!0),r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n}: ${i})`);break;case"xon-xoff":i=U.readBool(),r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n}: ${i})`);break;case"auth-agent-req@openssh.com":i=null,r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n})`);break;default:i=U.avail()?U.readRaw():null,r._debug&&r._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${n})`)}if(U.clear(),i===void 0)return _t(r,"Inbound: Malformed CHANNEL_REQUEST packet");const o=r._handlers.CHANNEL_REQUEST;o&&o(r,e,n,s,i)},[Et.CHANNEL_SUCCESS]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE();if(U.clear(),e===void 0)return _t(r,"Inbound: Malformed CHANNEL_SUCCESS packet");r._debug&&r._debug(`Inbound: CHANNEL_SUCCESS (r:${e})`);const n=r._handlers.CHANNEL_SUCCESS;n&&n(r,e)},[Et.CHANNEL_FAILURE]:(r,t)=>{U.init(t,1);const e=U.readUInt32BE();if(U.clear(),e===void 0)return _t(r,"Inbound: Malformed CHANNEL_FAILURE packet");r._debug&&r._debug(`Inbound: CHANNEL_FAILURE (r:${e})`);const n=r._handlers.CHANNEL_FAILURE;n&&n(r,e)}},ui,_s;function li(){if(_s)return ui;_s=1;const r=new Array(256);return[Ai().HANDLERS,Wf].forEach(t=>{for(let[e,n]of Object.entries(t))e=+e,isFinite(e)&&e>=0&&e<r.length&&(r[e]=n)}),ui=r,ui}var di,Es;function Ai(){if(Es)return di;Es=1;const{createDiffieHellman:r,createDiffieHellmanGroup:t,createECDH:e,createHash:n,createPublicKey:s,diffieHellman:i,generateKeyPairSync:o,randomFillSync:f}=tt,{Ber:c}=Ir,{COMPAT:h,curve25519Supported:g,DEFAULT_KEX:u,DEFAULT_SERVER_HOST_KEY:d,DEFAULT_CIPHER:A,DEFAULT_MAC:I,DEFAULT_COMPRESSION:y,DISCONNECT_REASON:w,MESSAGE:R}=En(),{CIPHER_INFO:M,createCipher:ce,createDecipher:q,MAC_INFO:le}=Bn(),{parseDERKey:se}=Rn,{bufferFill:fe,bufferParser:k,convertSignature:v,doFatalError:T,FastBuffer:J,sigSSHToASN1:X,writeUInt32BE:he}=nn(),{PacketReader:ae,PacketWriter:Ae,ZlibPacketReader:oe,ZlibPacketWriter:ge}=ls;let Q;const j=2048,Y=8192,re=Buffer.alloc(0);function we(N){let S;if(N._compatFlags&h.BAD_DHGEX){const p=N._offer.lists.kex;let O=p.array,ne=!1;for(let F=0;F<O.length;++F)O[F].includes("group-exchange")&&(ne||(ne=!0,O=O.slice()),O.splice(F--,1));if(ne){let F=17+N._offer.totalSize+1+4;const m=Buffer.from(O.join(","));F-=p.buffer.length-m.length;const B=N._offer.lists.all,x=new Uint8Array(B.buffer,B.byteOffset+4+p.buffer.length,B.length-(4+p.buffer.length));S=Buffer.allocUnsafe(F),he(S,m.length,17),S.set(m,17+4),S.set(x,17+4+m.length)}}S===void 0&&(S=Buffer.allocUnsafe(1+16+N._offer.totalSize+1+4),N._offer.copyAllTo(S,17)),N._debug&&N._debug("Outbound: Sending KEXINIT"),S[0]=R.KEXINIT,f(S,1,16),fe(S,0,S.length-5),N._kexinit=S,N._packetRW.write.allocStart=0;{const p=N._packetRW.write.allocStartKEX,O=N._packetRW.write.alloc(S.length,!0);O.set(S,p),N._cipher.encrypt(N._packetRW.write.finalize(O,!0))}}function me(N,S){const p={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0}};if(k.init(S,17),(p.kex=k.readList())===void 0||(p.serverHostKey=k.readList())===void 0||(p.cs.cipher=k.readList())===void 0||(p.sc.cipher=k.readList())===void 0||(p.cs.mac=k.readList())===void 0||(p.sc.mac=k.readList())===void 0||(p.cs.compress=k.readList())===void 0||(p.sc.compress=k.readList())===void 0||(p.cs.lang=k.readList())===void 0||(p.sc.lang=k.readList())===void 0)return k.clear(),T(N,"Received malformed KEXINIT","handshake",w.KEY_EXCHANGE_FAILED);const O=k.pos(),ne=O<S.length&&S[O]===1;k.clear();const F=N._offer,m=p;let B=F.lists.kex.array;if(N._compatFlags&h.BAD_DHGEX){let Ge=!1;for(let Ve=0;Ve<B.length;++Ve)B[Ve].indexOf("group-exchange")!==-1&&(Ge||(Ge=!0,B=B.slice()),B.splice(Ve--,1))}let x,K,z;const V=N._debug;V&&V("Inbound: Handshake in progress"),V&&V(`Handshake: (local) KEX method: ${B}`),V&&V(`Handshake: (remote) KEX method: ${m.kex}`);let We;if(N._server?(K=B,x=m.kex,We=x.indexOf("ext-info-c")!==-1):(K=m.kex,x=B,We=K.indexOf("ext-info-s")!==-1),N._strictMode===void 0&&(N._server?N._strictMode=x.indexOf("kex-strict-c-v00@openssh.com")!==-1:N._strictMode=K.indexOf("kex-strict-s-v00@openssh.com")!==-1,N._strictMode&&(V&&V("Handshake: strict KEX mode enabled"),N._decipher.inSeqno!==1)))return V&&V("Handshake: KEXINIT not first packet in strict KEX mode"),T(N,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",w.KEY_EXCHANGE_FAILED);for(z=0;z<x.length&&K.indexOf(x[z])===-1;++z);if(z===x.length)return V&&V("Handshake: no matching key exchange algorithm"),T(N,"Handshake failed: no matching key exchange algorithm","handshake",w.KEY_EXCHANGE_FAILED);p.kex=x[z],V&&V(`Handshake: KEX algorithm: ${x[z]}`),ne&&(!m.kex.length||x[z]!==m.kex[0])&&(N._skipNextInboundPacket=!0);const rt=F.lists.serverHostKey.array;for(V&&V(`Handshake: (local) Host key format: ${rt}`),V&&V(`Handshake: (remote) Host key format: ${m.serverHostKey}`),N._server?(K=rt,x=m.serverHostKey):(K=m.serverHostKey,x=rt),z=0;z<x.length&&K.indexOf(x[z])===-1;++z);if(z===x.length)return V&&V("Handshake: No matching host key format"),T(N,"Handshake failed: no matching host key format","handshake",w.KEY_EXCHANGE_FAILED);p.serverHostKey=x[z],V&&V(`Handshake: Host key format: ${x[z]}`);const mt=F.lists.cs.cipher.array;for(V&&V(`Handshake: (local) C->S cipher: ${mt}`),V&&V(`Handshake: (remote) C->S cipher: ${m.cs.cipher}`),N._server?(K=mt,x=m.cs.cipher):(K=m.cs.cipher,x=mt),z=0;z<x.length&&K.indexOf(x[z])===-1;++z);if(z===x.length)return V&&V("Handshake: No matching C->S cipher"),T(N,"Handshake failed: no matching C->S cipher","handshake",w.KEY_EXCHANGE_FAILED);p.cs.cipher=x[z],V&&V(`Handshake: C->S Cipher: ${x[z]}`);const De=F.lists.sc.cipher.array;for(V&&V(`Handshake: (local) S->C cipher: ${De}`),V&&V(`Handshake: (remote) S->C cipher: ${m.sc.cipher}`),N._server?(K=De,x=m.sc.cipher):(K=m.sc.cipher,x=De),z=0;z<x.length&&K.indexOf(x[z])===-1;++z);if(z===x.length)return V&&V("Handshake: No matching S->C cipher"),T(N,"Handshake failed: no matching S->C cipher","handshake",w.KEY_EXCHANGE_FAILED);p.sc.cipher=x[z],V&&V(`Handshake: S->C cipher: ${x[z]}`);const gt=F.lists.cs.mac.array;if(V&&V(`Handshake: (local) C->S MAC: ${gt}`),V&&V(`Handshake: (remote) C->S MAC: ${m.cs.mac}`),M[p.cs.cipher].authLen>0)p.cs.mac="",V&&V("Handshake: C->S MAC: <implicit>");else{for(N._server?(K=gt,x=m.cs.mac):(K=m.cs.mac,x=gt),z=0;z<x.length&&K.indexOf(x[z])===-1;++z);if(z===x.length)return V&&V("Handshake: No matching C->S MAC"),T(N,"Handshake failed: no matching C->S MAC","handshake",w.KEY_EXCHANGE_FAILED);p.cs.mac=x[z],V&&V(`Handshake: C->S MAC: ${x[z]}`)}const At=F.lists.sc.mac.array;if(V&&V(`Handshake: (local) S->C MAC: ${At}`),V&&V(`Handshake: (remote) S->C MAC: ${m.sc.mac}`),M[p.sc.cipher].authLen>0)p.sc.mac="",V&&V("Handshake: S->C MAC: <implicit>");else{for(N._server?(K=At,x=m.sc.mac):(K=m.sc.mac,x=At),z=0;z<x.length&&K.indexOf(x[z])===-1;++z);if(z===x.length)return V&&V("Handshake: No matching S->C MAC"),T(N,"Handshake failed: no matching S->C MAC","handshake",w.KEY_EXCHANGE_FAILED);p.sc.mac=x[z],V&&V(`Handshake: S->C MAC: ${x[z]}`)}const ut=F.lists.cs.compress.array;for(V&&V(`Handshake: (local) C->S compression: ${ut}`),V&&V(`Handshake: (remote) C->S compression: ${m.cs.compress}`),N._server?(K=ut,x=m.cs.compress):(K=m.cs.compress,x=ut),z=0;z<x.length&&K.indexOf(x[z])===-1;++z);if(z===x.length)return V&&V("Handshake: No matching C->S compression"),T(N,"Handshake failed: no matching C->S compression","handshake",w.KEY_EXCHANGE_FAILED);p.cs.compress=x[z],V&&V(`Handshake: C->S compression: ${x[z]}`);const qe=F.lists.sc.compress.array;for(V&&V(`Handshake: (local) S->C compression: ${qe}`),V&&V(`Handshake: (remote) S->C compression: ${m.sc.compress}`),N._server?(K=qe,x=m.sc.compress):(K=m.sc.compress,x=qe),z=0;z<x.length&&K.indexOf(x[z])===-1;++z);if(z===x.length)return V&&V("Handshake: No matching S->C compression"),T(N,"Handshake failed: no matching S->C compression","handshake",w.KEY_EXCHANGE_FAILED);p.sc.compress=x[z],V&&V(`Handshake: S->C compression: ${x[z]}`),p.cs.lang="",p.sc.lang="",N._kex&&(N._kexinit||we(N),N._decipher._onPayload=sn.bind(N,{firstPacket:!1})),N._kex=ve(p,N,S),N._kex.remoteExtInfoEnabled=We,N._kex.start()}const ve=(()=>{function N(m){let B=0,x=m.length;for(;m[B]===0;)++B,--x;let K;return m[B]&128?(K=Buffer.allocUnsafe(1+x),K[0]=0,m.copy(K,1,B),m=K):x!==m.length&&(K=Buffer.allocUnsafe(x),m.copy(K,0,B),m=K),m}class S{constructor(B,x,K){this._protocol=x,this.sessionID=x._kex?x._kex.sessionID:void 0,this.negotiated=B,this.remoteExtInfoEnabled=!1,this._step=1,this._public=null,this._dh=null,this._sentNEWKEYS=!1,this._receivedNEWKEYS=!1,this._finished=!1,this._hostVerified=!1,this._kexinit=x._kexinit,this._remoteKexinit=K,this._identRaw=x._identRaw,this._remoteIdentRaw=x._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(B){if(this._finished)return!1;this._finished=!0;const x=this._protocol._server,K=this.negotiated,z=this.convertPublicKey(this._dhData);let V=this.computeSecret(this._dhData);if(V instanceof Error)return V.message=`Error while computing DH secret (${this.type}): ${V.message}`,V.level="handshake",T(this._protocol,V,w.KEY_EXCHANGE_FAILED);const We=n(this.hashName);Je(We,x?this._remoteIdentRaw:this._identRaw),Je(We,x?this._identRaw:this._remoteIdentRaw),Je(We,x?this._remoteKexinit:this._kexinit),Je(We,x?this._kexinit:this._remoteKexinit);const rt=x?this._hostKey.getPublicSSH():this._hostKey;if(Je(We,rt),this.type==="groupex"){const qe=this.getDHParams(),Ge=Buffer.allocUnsafe(4);he(Ge,this._minBits,0),We.update(Ge),he(Ge,this._prefBits,0),We.update(Ge),he(Ge,this._maxBits,0),We.update(Ge),Je(We,qe.prime),Je(We,qe.generator)}Je(We,x?z:this.getPublicKey());const mt=x?this.getPublicKey():z;Je(We,mt),Je(We,V);const De=We.digest();if(x){let qe;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":qe="sha256";break;case"rsa-sha2-512":qe="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let Ge=this._hostKey.sign(De,qe);if(Ge instanceof Error)return T(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${Ge.message}`,"handshake",w.KEY_EXCHANGE_FAILED);if(Ge=v(Ge,this._hostKey.type),Ge===!1)return T(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",w.KEY_EXCHANGE_FAILED);const Ve=this.negotiated.serverHostKey,vt=Buffer.byteLength(Ve),Mt=4+vt+4+Ge.length;let It=this._protocol._packetRW.write.allocStartKEX;const xt=this._protocol._packetRW.write.alloc(1+4+rt.length+4+mt.length+4+Mt,!0);if(xt[It]=R.KEXDH_REPLY,he(xt,rt.length,++It),xt.set(rt,It+=4),he(xt,mt.length,It+=rt.length),xt.set(mt,It+=4),he(xt,Mt,It+=mt.length),he(xt,vt,It+=4),xt.utf8Write(Ve,It+=4,vt),he(xt,Ge.length,It+=vt),xt.set(Ge,It+=4),this._protocol._debug){let qt;switch(this.type){case"group":qt="KEXDH_REPLY";break;case"groupex":qt="KEXDH_GEX_REPLY";break;default:qt="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${qt}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(xt,!0))}else{k.init(this._sig,0);const qe=k.readString(!0);if(!qe)return T(this._protocol,"Malformed packet while reading signature","handshake",w.KEY_EXCHANGE_FAILED);if(qe!==K.serverHostKey)return T(this._protocol,`Wrong signature type: ${qe}, expected: ${K.serverHostKey}`,"handshake",w.KEY_EXCHANGE_FAILED);let Ge=k.readString();if(k.clear(),Ge===void 0)return T(this._protocol,"Malformed packet while reading signature","handshake",w.KEY_EXCHANGE_FAILED);if(!(Ge=X(Ge,qe)))return T(this._protocol,"Malformed signature","handshake",w.KEY_EXCHANGE_FAILED);let Ve;{k.init(this._hostKey,0);const It=k.readString(!0),xt=this._hostKey.slice(k.pos());if(k.clear(),Ve=se(xt,It),Ve instanceof Error)return Ve.level="handshake",T(this._protocol,Ve,w.KEY_EXCHANGE_FAILED)}let vt;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":vt="sha256";break;case"rsa-sha2-512":vt="sha512";break}this._protocol._debug&&this._protocol._debug("Verifying signature ...");const Mt=Ve.verify(De,Ge,vt);if(Mt!==!0)return Mt instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${Mt.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),T(this._protocol,"Handshake failed: signature verification failed","handshake",w.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(x||!B)&&Nt(this);let gt,At;const ut=qe=>{if(gt)return Nt(this),gt.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=ce(gt),this._protocol._packetRW.write=At,gt=void 0,At=void 0,this._protocol._onHandshakeComplete(K),!1;this.sessionID||(this.sessionID=De);{const gr=Buffer.allocUnsafe(4+V.length);he(gr,V.length,0),gr.set(V,4),V=gr}const Ge=M[K.cs.cipher],Ve=M[K.sc.cipher],vt=Gt(Ge.ivLen,this.hashName,V,De,this.sessionID,"A"),Mt=Gt(Ve.ivLen,this.hashName,V,De,this.sessionID,"B"),It=Gt(Ge.keyLen,this.hashName,V,De,this.sessionID,"C"),xt=Gt(Ve.keyLen,this.hashName,V,De,this.sessionID,"D");let qt,dn;Ge.authLen||(qt=le[K.cs.mac],dn=Gt(qt.len,this.hashName,V,De,this.sessionID,"E"));let fn,vn;Ve.authLen||(fn=le[K.sc.mac],vn=Gt(fn.len,this.hashName,V,De,this.sessionID,"F"));const Ar={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:x?Ge:Ve,decipherIV:x?vt:Mt,decipherKey:x?It:xt,macInfo:x?qt:fn,macKey:x?dn:vn},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:x?Ve:Ge,cipherIV:x?Mt:vt,cipherKey:x?xt:It,macInfo:x?fn:qt,macKey:x?vn:dn}};this._protocol._decipher.free(),gt=Ar,this._protocol._decipher=q(Ar);const Ut={read:void 0,write:void 0};switch(K.cs.compress){case"zlib":x?Ut.read=new oe:Ut.write=new ge(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){x?Ut.read=new oe:Ut.write=new ge(this._protocol);break}default:x?Ut.read=new ae:Ut.write=new Ae(this._protocol)}switch(K.sc.compress){case"zlib":x?Ut.write=new ge(this._protocol):Ut.read=new oe;break;case"zlib@openssh.com":if(this._protocol._authenticated){x?Ut.write=new ge(this._protocol):Ut.read=new oe;break}default:x?Ut.write=new Ae(this._protocol):Ut.read=new ae}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=Ut.read,At=Ut.write,this._public=null,this._dh=null,this._kexinit=this._protocol._kexinit=void 0,this._remoteKexinit=void 0,this._identRaw=void 0,this._remoteIdentRaw=void 0,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0,qe?!1:ut()};if((x||B)&&(this.finish=ut),!x)return ut(B)}start(){if(!this._protocol._server){if(this._protocol._debug){let z;switch(this.type){case"group":z="KEXDH_INIT";break;default:z="KEXECDH_INIT"}this._protocol._debug(`Outbound: Sending ${z}`)}const B=this.getPublicKey();let x=this._protocol._packetRW.write.allocStartKEX;const K=this._protocol._packetRW.write.alloc(1+4+B.length,!0);K[x]=R.KEXDH_INIT,he(K,B.length,++x),K.set(B,x+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(K,!0))}}getPublicKey(){this.generateKeys();const B=this._public;if(B)return this.convertPublicKey(B)}convertPublicKey(B){let x,K=0,z=B.length;for(;B[K]===0;)++K,--z;return B[K]&128?(x=Buffer.allocUnsafe(1+z),x[0]=0,B.copy(x,1,K),x):(z!==B.length&&(x=Buffer.allocUnsafe(z),B.copy(x,0,K),B=x),B)}computeSecret(B){this.generateKeys();try{return N(this._dh.computeSecret(B))}catch(x){return x}}parse(B){const x=B[0];switch(this._step){case 1:if(this._protocol._server){if(x!==R.KEXDH_INIT)return T(this._protocol,`Received packet ${x} instead of ${R.KEXDH_INIT}`,"handshake",w.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),k.init(B,1);const K=k.readString();if(k.clear(),K===void 0)return T(this._protocol,"Received malformed KEX*_INIT","handshake",w.KEY_EXCHANGE_FAILED);this._dhData=K;let z=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(z)&&(z=z[0]),this._hostKey=z,this.finish()}else{if(x!==R.KEXDH_REPLY)return T(this._protocol,`Received packet ${x} instead of ${R.KEXDH_REPLY}`,"handshake",w.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),k.init(B,1);let K,z,V;if((K=k.readString())===void 0||(z=k.readString())===void 0||(V=k.readString())===void 0)return k.clear(),T(this._protocol,"Received malformed KEX*_REPLY","handshake",w.KEY_EXCHANGE_FAILED);k.clear(),k.init(K,0);const We=k.readString(!0);if(k.clear(),We===void 0)return T(this._protocol,"Received malformed host public key","handshake",w.KEY_EXCHANGE_FAILED);if(We!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(We==="ssh-rsa")break;default:return T(this._protocol,"Host key does not match negotiated type","handshake",w.KEY_EXCHANGE_FAILED)}this._hostKey=K,this._dhData=z,this._sig=V;let rt=!1,mt;if(this._protocol._hostVerifier===void 0?(mt=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):mt=this._protocol._hostVerifier(K,De=>{if(!rt){if(rt=!0,De===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),T(this._protocol,"Host denied (verification failed)","handshake",w.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():Nt(this)}}),mt===void 0){++this._step;return}if(rt=!0,mt===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),T(this._protocol,"Host denied (verification failed)","handshake",w.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,Nt(this)}++this._step;break;case 2:return x!==R.NEWKEYS?T(this._protocol,`Received packet ${x} instead of ${R.NEWKEYS}`,"handshake",w.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Inbound: NEWKEYS"),this._receivedNEWKEYS=!0,this._protocol._strictMode&&(this._protocol._decipher.inSeqno=0),++this._step,this.finish(!this._protocol._server&&!this._hostVerified));default:return T(this._protocol,`Received unexpected packet ${x} after NEWKEYS`,"handshake",w.KEY_EXCHANGE_FAILED)}}}class p extends S{constructor(B,...x){super(...x),this.type="25519",this.hashName=B,this._keys=null}generateKeys(){this._keys||(this._keys=o("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(B){let x,K=0,z=B.length;for(;B[K]===0;)++K,--z;return B.length===32||z!==B.length&&(x=Buffer.allocUnsafe(z),B.copy(x,0,K),B=x),B}computeSecret(B){this.generateKeys();try{const x=new c.Writer;return x.startSequence(),x.startSequence(),x.writeOID("1.3.101.110"),x.endSequence(),x.startSequence(c.BitString),x.writeByte(0),x._ensure(B.length),B.copy(x._buf,x._offset,0,B.length),x._offset+=B.length,x.endSequence(),x.endSequence(),N(i({privateKey:this._keys.privateKey,publicKey:s({key:x.buffer,type:"spki",format:"der"})}))}catch(x){return x}}}class O extends S{constructor(B,x,...K){super(...K),this.type="ecdh",this.curveName=B,this.hashName=x}generateKeys(){this._dh||(this._dh=e(this.curveName),this._public=this._dh.generateKeys())}}class ne extends S{constructor(B,...x){super(...x),this.type="groupex",this.hashName=B,this._prime=null,this._generator=null,this._minBits=j,this._prefBits=on(this.negotiated),this._protocol._compatFlags&h.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=Y}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let B=this._protocol._packetRW.write.allocStartKEX;const x=this._protocol._packetRW.write.alloc(1+4+4+4,!0);x[B]=R.KEXDH_GEX_REQUEST,he(x,this._minBits,++B),he(x,this._prefBits,B+=4),he(x,this._maxBits,B+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(x,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=r(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(B,x){if(!Buffer.isBuffer(B))throw new Error("Invalid prime value");if(!Buffer.isBuffer(x))throw new Error("Invalid generator value");this._prime=B,this._generator=x}getDHParams(){if(this._dh)return{prime:N(this._dh.getPrime()),generator:N(this._dh.getGenerator())}}parse(B){const x=B[0];switch(this._step){case 1:{if(this._protocol._server)return x!==R.KEXDH_GEX_REQUEST?T(this._protocol,`Received packet ${x} instead of `+R.KEXDH_GEX_REQUEST,"handshake",w.KEY_EXCHANGE_FAILED):T(this._protocol,"Group exchange not implemented for server","handshake",w.KEY_EXCHANGE_FAILED);if(x!==R.KEXDH_GEX_GROUP)return T(this._protocol,`Received packet ${x} instead of ${R.KEXDH_GEX_GROUP}`,"handshake",w.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),k.init(B,1);let K,z;if((K=k.readString())===void 0||(z=k.readString())===void 0)return k.clear(),T(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",w.KEY_EXCHANGE_FAILED);k.clear(),this.setDHParams(K,z),this.generateKeys();const V=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let We=this._protocol._packetRW.write.allocStartKEX;const rt=this._protocol._packetRW.write.alloc(1+4+V.length,!0);rt[We]=R.KEXDH_GEX_INIT,he(rt,V.length,++We),rt.set(V,We+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(rt,!0)),++this._step;break}case 2:if(this._protocol._server)return x!==R.KEXDH_GEX_INIT?T(this._protocol,`Received packet ${x} instead of ${R.KEXDH_GEX_INIT}`,"handshake",w.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),T(this._protocol,"Group exchange not implemented for server","handshake",w.KEY_EXCHANGE_FAILED));if(x!==R.KEXDH_GEX_REPLY)return T(this._protocol,`Received packet ${x} instead of ${R.KEXDH_GEX_REPLY}`,"handshake",w.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,B[0]=R.KEXDH_REPLY,this.parse=S.prototype.parse,this.parse(B)}}}class F extends S{constructor(B,x,...K){super(...K),this.type="group",this.groupName=B,this.hashName=x}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");const B=this.getPublicKey();let x=this._protocol._packetRW.write.allocStartKEX;const K=this._protocol._packetRW.write.alloc(1+4+B.length,!0);K[x]=R.KEXDH_INIT,he(K,B.length,++x),K.set(B,x+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(K,!0))}}generateKeys(){this._dh||(this._dh=t(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:N(this._dh.getPrime()),generator:N(this._dh.getGenerator())}}}return(m,...B)=>{if(typeof m!="object"||m===null)throw new Error("Invalid negotiated argument");const x=m.kex;if(typeof x=="string"){switch(B=[m,...B],x){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!g)break;return new p("sha256",...B);case"ecdh-sha2-nistp256":return new O("prime256v1","sha256",...B);case"ecdh-sha2-nistp384":return new O("secp384r1","sha384",...B);case"ecdh-sha2-nistp521":return new O("secp521r1","sha512",...B);case"diffie-hellman-group1-sha1":return new F("modp2","sha1",...B);case"diffie-hellman-group14-sha1":return new F("modp14","sha1",...B);case"diffie-hellman-group14-sha256":return new F("modp14","sha256",...B);case"diffie-hellman-group15-sha512":return new F("modp15","sha512",...B);case"diffie-hellman-group16-sha512":return new F("modp16","sha512",...B);case"diffie-hellman-group17-sha512":return new F("modp17","sha512",...B);case"diffie-hellman-group18-sha512":return new F("modp18","sha512",...B);case"diffie-hellman-group-exchange-sha1":return new ne("sha1",...B);case"diffie-hellman-group-exchange-sha256":return new ne("sha256",...B)}throw new Error(`Unsupported key exchange algorithm: ${x}`)}throw new Error(`Invalid key exchange type: ${x}`)}})(),Ne=(()=>{const N=["kex","serverHostKey",["cs","cipher"],["sc","cipher"],["cs","mac"],["sc","mac"],["cs","compress"],["sc","compress"],["cs","lang"],["sc","lang"]];return class{constructor(p){if(typeof p!="object"||p===null)throw new TypeError("Argument must be an object");const O={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},all:void 0};let ne=0;for(const B of N){let x,K,z,V;if(typeof B=="string")x=O,K=p[B],z=V=B;else{const rt=B[0];x=O[rt],V=B[1],K=p[rt][V],z=`${rt}.${V}`}const We={array:void 0,buffer:void 0};if(Buffer.isBuffer(K))We.array=(""+K).split(","),We.buffer=K,ne+=4+K.length;else{if(typeof K=="string"&&(K=K.split(",")),Array.isArray(K))We.array=K,We.buffer=Buffer.from(K.join(","));else throw new TypeError(`Invalid \`${z}\` type: ${typeof K}`);ne+=4+We.buffer.length}x[V]=We}const F=Buffer.allocUnsafe(ne);O.all=F;let m=0;for(const B of N){let x;typeof B=="string"?x=O[B].buffer:x=O[B[0]][B[1]].buffer,m=he(F,x.length,m),F.set(x,m),m+=x.length}this.totalSize=ne,this.lists=O}copyAllTo(p,O){const ne=this.lists.all;if(typeof O!="number")throw new TypeError(`Invalid offset value: ${typeof O}`);if(p.length-O<ne.length)throw new Error("Insufficient space to copy list");return p.set(ne,O),ne.length}}})(),Je=(()=>{const N=Buffer.allocUnsafe(4);return(S,p)=>{he(N,p.length,0),S.update(N),S.update(p)}})();function Gt(N,S,p,O,ne,F){let m;if(N){let B=n(S).update(p).update(O).update(F).update(ne).digest();for(;B.length<N;){const x=n(S).update(p).update(O).update(B).digest(),K=Buffer.allocUnsafe(B.length+x.length);K.set(B,0),K.set(x,B.length),B=K}B.length===N?m=B:m=new J(B.buffer,B.byteOffset,N)}else m=re;return m}function sn(N,S){if(S.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}if(this._skipNextInboundPacket){this._skipNextInboundPacket=!1;return}S=this._packetRW.read.read(S);const p=S[0];if(!this._strictMode)switch(p){case R.IGNORE:case R.UNIMPLEMENTED:case R.DEBUG:return Q||(Q=li()),Q[p](this,S)}switch(p){case R.DISCONNECT:return Q||(Q=li()),Q[p](this,S);case R.KEXINIT:return N.firstPacket?(N.firstPacket=!1,me(this,S)):T(this,"Received extra KEXINIT during handshake","handshake",w.KEY_EXCHANGE_FAILED);default:if(p<20||p>49)return T(this,`Received unexpected packet type ${p}`,"handshake",w.KEY_EXCHANGE_FAILED)}return this._kex.parse(S)}function on(N){const S=M[N.cs.cipher],p=M[N.sc.cipher],O=Math.max(0,S.sslName==="des-ede3-cbc"?14:S.keyLen,S.blockLen,S.ivLen,p.sslName==="des-ede3-cbc"?14:p.keyLen,p.blockLen,p.ivLen)*8;return O<=112?2048:O<=128?3072:O<=192?7680:8192}function Nt(N){if(!N._sentNEWKEYS){N._protocol._debug&&N._protocol._debug("Outbound: Sending NEWKEYS");const S=N._protocol._packetRW.write.allocStartKEX,p=N._protocol._packetRW.write.alloc(1,!0);p[S]=R.NEWKEYS,N._protocol._cipher.encrypt(N._protocol._packetRW.write.finalize(p,!0)),N._sentNEWKEYS=!0,N._protocol._strictMode&&(N._protocol._cipher.outSeqno=0)}}return di={KexInit:Ne,kexinit:we,onKEXPayload:sn,DEFAULT_KEXINIT_CLIENT:new Ne({kex:u.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:d,cs:{cipher:A,mac:I,compress:y,lang:[]},sc:{cipher:A,mac:I,compress:y,lang:[]}}),DEFAULT_KEXINIT_SERVER:new Ne({kex:u.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:d,cs:{cipher:A,mac:I,compress:y,lang:[]},sc:{cipher:A,mac:I,compress:y,lang:[]}}),HANDLERS:{[R.KEXINIT]:me}},di}const $f={_from:"ssh2@^1.15.0",_id:"ssh2@1.15.0",_inBundle:!1,_integrity:"sha512-C0PHgX4h6lBxYx7hcXwu3QWdh4tg6tZZsTfXcdvc5caW/EMxaB4H9dWsl7qk+F7LAW762hp8VbXOX7x4xUYvEw==",_location:"/ssh2",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"ssh2@^1.15.0",name:"ssh2",escapedName:"ssh2",rawSpec:"^1.15.0",saveSpec:null,fetchSpec:"^1.15.0"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/ssh2/-/ssh2-1.15.0.tgz",_shasum:"2f998455036a7f89e0df5847efb5421748d9871b",_spec:"ssh2@^1.15.0",_where:"D:\\work\\package\\ssh",author:{name:"Brian White",email:"mscdex@mscdex.net"},bugs:{url:"https://github.com/mscdex/ssh2/issues"},bundleDependencies:!1,dependencies:{asn1:"^0.2.6","bcrypt-pbkdf":"^1.0.2","cpu-features":"~0.0.9",nan:"^2.18.0"},deprecated:!1,description:"SSH2 client and server modules written in pure JavaScript for node.js",devDependencies:{"@mscdex/eslint-config":"^1.1.0",eslint:"^7.32.0"},engines:{node:">=10.16.0"},homepage:"https://github.com/mscdex/ssh2#readme",keywords:["ssh","ssh2","sftp","secure","shell","exec","remote","client"],licenses:[{type:"MIT",url:"http://github.com/mscdex/ssh2/raw/master/LICENSE"}],main:"./lib/index.js",name:"ssh2",optionalDependencies:{"cpu-features":"~0.0.9",nan:"^2.18.0"},repository:{type:"git",url:"git+ssh://git@github.com/mscdex/ssh2.git"},scripts:{install:"node install.js",lint:"eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js examples lib test","lint:fix":"npm run lint -- --fix",rebuild:"node install.js",test:"node test/test.js"},version:"1.15.0"},{inspect:ps}=tt,{bindingAvailable:qf,NullCipher:Gf,NullDecipher:Yf}=Bn(),{COMPAT_CHECKS:Xf,DISCONNECT_REASON:bs,eddsaSupported:jf,MESSAGE:Be,SIGNALS:Is,TERMINAL_MODE:gi}=En(),{DEFAULT_KEXINIT_CLIENT:Vf,DEFAULT_KEXINIT_SERVER:zf,KexInit:xs,kexinit:ys,onKEXPayload:Jf}=Ai(),{parseKey:Ss}=Rn,Zf=li(),{bufferCopy:Nr,bufferFill:ea,bufferSlice:ws,convertSignature:ms,sendPacket:ke,writeUInt32BE:L}=nn(),{PacketReader:ta,PacketWriter:na,ZlibPacketReader:Cs,ZlibPacketWriter:Bs}=ls,ra=$f.version,ia=new Map(Object.values(bs).map(r=>[r,1])),ks=Buffer.from(`SSH-2.0-ssh2js${ra}`),sa=Buffer.from(`${ks}\r
8
+ `),oa=8192,fa=1024,Rs=Buffer.from([Be.GLOBAL_REQUEST,0,0,0,21,107,101,101,112,97,108,105,118,101,64,111,112,101,110,115,115,104,46,99,111,109,1]),aa=Buffer.from([gi.TTY_OP_END]);function _i(){}let ca=class{constructor(t){const e=t.onWrite;if(typeof e!="function")throw new Error("Missing onWrite function");this._onWrite=A=>{e(A)};const n=t.onError;if(typeof n!="function")throw new Error("Missing onError function");this._onError=A=>{n(A)};const s=t.debug;this._debug=typeof s=="function"?A=>{s(A)}:void 0;const i=t.onHeader;this._onHeader=typeof i=="function"?(...A)=>{i(...A)}:_i;const o=t.onPacket;this._onPacket=typeof o=="function"?()=>{o()}:_i;let f=t.onHandshakeComplete;typeof f!="function"&&(f=_i);let c;this._onHandshakeComplete=(...A)=>{this._debug&&this._debug("Handshake completed"),c===void 0?c=!0:c=!1;const I=this._queue;if(I){this._queue=void 0,this._debug&&this._debug(`Draining outbound queue (${I.length}) ...`);for(let y=0;y<I.length;++y){const w=I[y];let R=this._packetRW.write.finalize(w);if(R===w){const M=this._cipher.allocPacket(w.length);M.set(w,5),R=M}ke(this,R)}this._debug&&this._debug("... finished draining outbound queue")}c&&this._server&&this._kex.remoteExtInfoEnabled&&_a(this),f(...A)},this._queue=void 0;const h=t.messageHandlers;typeof h=="object"&&h!==null?this._handlers=h:this._handlers={},this._onPayload=da.bind(this),this._server=!!t.server,this._banner=void 0;let g;if(this._server){if(typeof t.hostKeys!="object"||t.hostKeys===null)throw new Error("Missing server host key(s)");this._hostKeys=t.hostKeys,typeof t.greeting=="string"&&t.greeting.length&&(g=t.greeting.slice(-2)===`\r
9
+ `?t.greeting:`${t.greeting}\r
10
+ `),typeof t.banner=="string"&&t.banner.length&&(this._banner=t.banner.slice(-2)===`\r
11
+ `?t.banner:`${t.banner}\r
12
+ `)}else this._hostKeys=void 0;let u=t.offer;typeof u!="object"||u===null?u=this._server?zf:Vf:u.constructor!==xs&&(this._server?u.kex=u.kex.concat(["kex-strict-s-v00@openssh.com"]):u.kex=u.kex.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),u=new xs(u)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=u,this._cipher=new Gf(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new ta,write:new na(this)},this._hostVerifier=!this._server&&typeof t.hostVerifier=="function"?t.hostVerifier:void 0,this._parse=ua,this._buffer=void 0,this._authsQueue=[],this._authenticated=!1,this._remoteIdentRaw=void 0;let d;if(typeof t.ident=="string")this._identRaw=Buffer.from(`SSH-2.0-${t.ident}`),d=Buffer.allocUnsafe(this._identRaw.length+2),d.set(this._identRaw,0),d[d.length-2]=13,d[d.length-1]=10;else if(Buffer.isBuffer(t.ident)){const A=Buffer.allocUnsafe(8+t.ident.length);A.latin1Write("SSH-2.0-",0,8),A.set(t.ident,8),this._identRaw=A,d=Buffer.allocUnsafe(A.length+2),d.set(A,0),d[d.length-2]=13,d[d.length-1]=10}else this._identRaw=ks,d=sa;this._compatFlags=0,this._debug&&(qf?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${ps(this._identRaw.toString())}`),this.start=()=>{this.start=void 0,g&&this._onWrite(g),this._onWrite(d)}}_destruct(t){this._packetRW.read.cleanup(),this._packetRW.write.cleanup(),this._cipher&&this._cipher.free(),this._decipher&&this._decipher.free(),(typeof t!="string"||t.length===0)&&(t="fatal error"),this.parse=()=>{throw new Error(`Instance unusable after ${t}`)},this._onWrite=()=>{throw new Error(`Instance unusable after ${t}`)},this._destruct=void 0}cleanup(){this._destruct&&this._destruct()}parse(t,e,n){for(;e<n;)e=this._parse(t,e,n)}disconnect(t){let n=this._packetRW.write.allocStartKEX;const s=this._packetRW.write.alloc(13,!0),i=n+13;ia.has(t)||(t=bs.PROTOCOL_ERROR),s[n]=Be.DISCONNECT,L(s,t,++n),s.fill(0,n+=4,i),this._debug&&this._debug(`Outbound: Sending DISCONNECT (${t})`),ke(this,this._packetRW.write.finalize(s,!0),!0)}ping(){const t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(Rs.length);e.set(Rs,t),this._debug&&this._debug("Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)"),ke(this,this._packetRW.write.finalize(e))}rekey(){this._kexinit===void 0?(this._debug&&this._debug("Outbound: Initiated explicit rekey"),this._queue=[],ys(this)):this._debug&&this._debug("Outbound: Ignoring rekey during handshake")}requestSuccess(t){let e=this._packetRW.write.allocStart,n;Buffer.isBuffer(t)?(n=this._packetRW.write.alloc(1+t.length),n[e]=Be.REQUEST_SUCCESS,n.set(t,++e)):(n=this._packetRW.write.alloc(1),n[e]=Be.REQUEST_SUCCESS),this._debug&&this._debug("Outbound: Sending REQUEST_SUCCESS"),ke(this,this._packetRW.write.finalize(n))}requestFailure(){const t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=Be.REQUEST_FAILURE,this._debug&&this._debug("Outbound: Sending REQUEST_FAILURE"),ke(this,this._packetRW.write.finalize(e))}channelSuccess(t){let e=this._packetRW.write.allocStart;const n=this._packetRW.write.alloc(1+4);n[e]=Be.CHANNEL_SUCCESS,L(n,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${t})`),ke(this,this._packetRW.write.finalize(n))}channelFailure(t){let e=this._packetRW.write.allocStart;const n=this._packetRW.write.alloc(1+4);n[e]=Be.CHANNEL_FAILURE,L(n,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${t})`),ke(this,this._packetRW.write.finalize(n))}channelEOF(t){let e=this._packetRW.write.allocStart;const n=this._packetRW.write.alloc(1+4);n[e]=Be.CHANNEL_EOF,L(n,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_EOF (r:${t})`),ke(this,this._packetRW.write.finalize(n))}channelClose(t){let e=this._packetRW.write.allocStart;const n=this._packetRW.write.alloc(1+4);n[e]=Be.CHANNEL_CLOSE,L(n,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${t})`),ke(this,this._packetRW.write.finalize(n))}channelWindowAdjust(t,e){let n=this._packetRW.write.allocStart;const s=this._packetRW.write.alloc(1+4+4);s[n]=Be.CHANNEL_WINDOW_ADJUST,L(s,t,++n),L(s,e,n+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${t}, ${e})`),ke(this,this._packetRW.write.finalize(s))}channelData(t,e){const n=Buffer.isBuffer(e),s=n?e.length:Buffer.byteLength(e);let i=this._packetRW.write.allocStart;const o=this._packetRW.write.alloc(1+4+4+s);o[i]=Be.CHANNEL_DATA,L(o,t,++i),L(o,s,i+=4),n?o.set(e,i+=4):o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_DATA (r:${t}, ${s})`),ke(this,this._packetRW.write.finalize(o))}channelExtData(t,e,n){const s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e);let o=this._packetRW.write.allocStart;const f=this._packetRW.write.alloc(1+4+4+4+i);f[o]=Be.CHANNEL_EXTENDED_DATA,L(f,t,++o),L(f,n,o+=4),L(f,i,o+=4),s?f.set(e,o+=4):f.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${t})`),ke(this,this._packetRW.write.finalize(f))}channelOpenConfirm(t,e,n,s){let i=this._packetRW.write.allocStart;const o=this._packetRW.write.alloc(1+4+4+4+4);o[i]=Be.CHANNEL_OPEN_CONFIRMATION,L(o,t,++i),L(o,e,i+=4),L(o,n,i+=4),L(o,s,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${t}, l:${e})`),ke(this,this._packetRW.write.finalize(o))}channelOpenFail(t,e,n){typeof n!="string"&&(n="");const s=Buffer.byteLength(n);let i=this._packetRW.write.allocStart;const o=this._packetRW.write.alloc(1+4+4+4+s+4);o[i]=Be.CHANNEL_OPEN_FAILURE,L(o,t,++i),L(o,e,i+=4),L(o,s,i+=4),i+=4,s&&(o.utf8Write(n,i,s),i+=s),L(o,0,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${t})`),ke(this,this._packetRW.write.finalize(o))}service(t){if(this._server)throw new Error("Client-only method called in server mode");const e=Buffer.byteLength(t);let n=this._packetRW.write.allocStart;const s=this._packetRW.write.alloc(1+4+e);s[n]=Be.SERVICE_REQUEST,L(s,e,++n),s.utf8Write(t,n+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_REQUEST (${t})`),ke(this,this._packetRW.write.finalize(s))}authPassword(t,e,n){if(this._server)throw new Error("Client-only method called in server mode");const s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=n?Buffer.byteLength(n):0;let f=this._packetRW.write.allocStart;const c=this._packetRW.write.alloc(1+4+s+4+14+4+8+1+4+i+(n?4+o:0));c[f]=Be.USERAUTH_REQUEST,L(c,s,++f),c.utf8Write(t,f+=4,s),L(c,14,f+=s),c.utf8Write("ssh-connection",f+=4,14),L(c,8,f+=14),c.utf8Write("password",f+=4,8),c[f+=8]=n?1:0,L(c,i,++f),Buffer.isBuffer(e)?Nr(e,c,0,i,f+=4):c.utf8Write(e,f+=4,i),n?(L(c,o,f+=i),Buffer.isBuffer(n)?Nr(n,c,0,o,f+=4):c.utf8Write(n,f+=4,o),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (changed password)")):this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (password)"),this._authsQueue.push("password"),ke(this,this._packetRW.write.finalize(c))}authPK(t,e,n,s){if(this._server)throw new Error("Client-only method called in server mode");if(e=Ss(e),e instanceof Error)throw new Error("Invalid key");const i=e.type;e=e.getPublicSSH(),typeof n=="function"&&(s=n,n=void 0),n||(n=i);const o=Buffer.byteLength(t),f=Buffer.byteLength(n),c=e.length,h=this._kex.sessionID,g=h.length,u=(s?4+g:0)+1+4+o+4+14+4+9+1+4+f+4+c;let d,A;if(s?(d=Buffer.allocUnsafe(u),A=0,L(d,g,A),d.set(h,A+=4),A+=g):(d=this._packetRW.write.alloc(u),A=this._packetRW.write.allocStart),d[A]=Be.USERAUTH_REQUEST,L(d,o,++A),d.utf8Write(t,A+=4,o),L(d,14,A+=o),d.utf8Write("ssh-connection",A+=4,14),L(d,9,A+=14),d.utf8Write("publickey",A+=4,9),d[A+=9]=s?1:0,L(d,f,++A),d.utf8Write(n,A+=4,f),L(d,c,A+=f),d.set(e,A+=4),!s){this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),ke(this,this._packetRW.write.finalize(d));return}s(d,I=>{if(I=ms(I,i),I===!1)throw new Error("Error while converting handshake signature");const y=I.length;A=this._packetRW.write.allocStart,d=this._packetRW.write.alloc(1+4+o+4+14+4+9+1+4+f+4+c+4+4+f+4+y),d[A]=Be.USERAUTH_REQUEST,L(d,o,++A),d.utf8Write(t,A+=4,o),L(d,14,A+=o),d.utf8Write("ssh-connection",A+=4,14),L(d,9,A+=14),d.utf8Write("publickey",A+=4,9),d[A+=9]=1,L(d,f,++A),d.utf8Write(n,A+=4,f),L(d,c,A+=f),d.set(e,A+=4),L(d,4+f+4+y,A+=c),L(d,f,A+=4),d.utf8Write(n,A+=4,f),L(d,y,A+=f),d.set(I,A+=4),this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey)"),ke(this,this._packetRW.write.finalize(d))})}authHostbased(t,e,n,s,i,o){if(this._server)throw new Error("Client-only method called in server mode");if(e=Ss(e),e instanceof Error)throw new Error("Invalid key");const f=e.type;e=e.getPublicSSH(),typeof i=="function"&&(o=i,i=void 0),i||(i=f);const c=Buffer.byteLength(t),h=Buffer.byteLength(i),g=e.length,u=this._kex.sessionID,d=u.length,A=Buffer.byteLength(n),I=Buffer.byteLength(s),y=Buffer.allocUnsafe(4+d+1+4+c+4+14+4+9+4+h+4+g+4+A+4+I);let w=0;L(y,d,w),y.set(u,w+=4),y[w+=d]=Be.USERAUTH_REQUEST,L(y,c,++w),y.utf8Write(t,w+=4,c),L(y,14,w+=c),y.utf8Write("ssh-connection",w+=4,14),L(y,9,w+=14),y.utf8Write("hostbased",w+=4,9),L(y,h,w+=9),y.utf8Write(i,w+=4,h),L(y,g,w+=h),y.set(e,w+=4),L(y,A,w+=g),y.utf8Write(n,w+=4,A),L(y,I,w+=A),y.utf8Write(s,w+=4,I),o(y,R=>{if(R=ms(R,f),!R)throw new Error("Error while converting handshake signature");const M=R.length,ce=y.length-d-4;w=this._packetRW.write.allocStart;const q=this._packetRW.write.alloc(ce+4+4+h+4+M);Nr(y,q,4+d,y.length,w),L(q,4+h+4+M,w+=ce),L(q,h,w+=4),q.utf8Write(i,w+=4,h),L(q,M,w+=h),q.set(R,w+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),ke(this,this._packetRW.write.finalize(q))})}authKeyboard(t){if(this._server)throw new Error("Client-only method called in server mode");const e=Buffer.byteLength(t);let n=this._packetRW.write.allocStart;const s=this._packetRW.write.alloc(1+4+e+4+14+4+20+4+4);s[n]=Be.USERAUTH_REQUEST,L(s,e,++n),s.utf8Write(t,n+=4,e),L(s,14,n+=e),s.utf8Write("ssh-connection",n+=4,14),L(s,20,n+=14),s.utf8Write("keyboard-interactive",n+=4,20),L(s,0,n+=20),L(s,0,n+=4),this._authsQueue.push("keyboard-interactive"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)"),ke(this,this._packetRW.write.finalize(s))}authNone(t){if(this._server)throw new Error("Client-only method called in server mode");const e=Buffer.byteLength(t);let n=this._packetRW.write.allocStart;const s=this._packetRW.write.alloc(1+4+e+4+14+4+4);s[n]=Be.USERAUTH_REQUEST,L(s,e,++n),s.utf8Write(t,n+=4,e),L(s,14,n+=e),s.utf8Write("ssh-connection",n+=4,14),L(s,4,n+=14),s.utf8Write("none",n+=4,4),this._authsQueue.push("none"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (none)"),ke(this,this._packetRW.write.finalize(s))}authInfoRes(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,n;if(t){n=new Array(t.length);for(let o=0;o<t.length;++o){const f=Buffer.byteLength(t[o]);n[o]=f,e+=4+f}}let s=this._packetRW.write.allocStart;const i=this._packetRW.write.alloc(1+4+e);if(i[s]=Be.USERAUTH_INFO_RESPONSE,t){L(i,t.length,++s),s+=4;for(let o=0;o<t.length;++o){const f=n[o];L(i,f,s),s+=4,f&&(i.utf8Write(t[o],s,f),s+=f)}}else L(i,0,++s);this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_RESPONSE"),ke(this,this._packetRW.write.finalize(i))}tcpipForward(t,e,n){if(this._server)throw new Error("Client-only method called in server mode");const s=Buffer.byteLength(t);let i=this._packetRW.write.allocStart;const o=this._packetRW.write.alloc(1+4+13+1+4+s+4);o[i]=Be.GLOBAL_REQUEST,L(o,13,++i),o.utf8Write("tcpip-forward",i+=4,13),o[i+=13]=n===void 0||n===!0?1:0,L(o,s,++i),o.utf8Write(t,i+=4,s),L(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (tcpip-forward)"),ke(this,this._packetRW.write.finalize(o))}cancelTcpipForward(t,e,n){if(this._server)throw new Error("Client-only method called in server mode");const s=Buffer.byteLength(t);let i=this._packetRW.write.allocStart;const o=this._packetRW.write.alloc(1+4+20+1+4+s+4);o[i]=Be.GLOBAL_REQUEST,L(o,20,++i),o.utf8Write("cancel-tcpip-forward",i+=4,20),o[i+=20]=n===void 0||n===!0?1:0,L(o,s,++i),o.utf8Write(t,i+=4,s),L(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)"),ke(this,this._packetRW.write.finalize(o))}openssh_streamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");const n=Buffer.byteLength(t);let s=this._packetRW.write.allocStart;const i=this._packetRW.write.alloc(1+4+31+1+4+n);i[s]=Be.GLOBAL_REQUEST,L(i,31,++s),i.utf8Write("streamlocal-forward@openssh.com",s+=4,31),i[s+=31]=e===void 0||e===!0?1:0,L(i,n,++s),i.utf8Write(t,s+=4,n),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)"),ke(this,this._packetRW.write.finalize(i))}openssh_cancelStreamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");const n=Buffer.byteLength(t);let s=this._packetRW.write.allocStart;const i=this._packetRW.write.alloc(1+4+38+1+4+n);i[s]=Be.GLOBAL_REQUEST,L(i,38,++s),i.utf8Write("cancel-streamlocal-forward@openssh.com",s+=4,38),i[s+=38]=e===void 0||e===!0?1:0,L(i,n,++s),i.utf8Write(t,s+=4,n),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-streamlocal-forward@openssh.com)"),ke(this,this._packetRW.write.finalize(i))}directTcpip(t,e,n,s){if(this._server)throw new Error("Client-only method called in server mode");const i=Buffer.byteLength(s.srcIP),o=Buffer.byteLength(s.dstIP);let f=this._packetRW.write.allocStart;const c=this._packetRW.write.alloc(1+4+12+4+4+4+4+i+4+4+o+4);c[f]=Be.CHANNEL_OPEN,L(c,12,++f),c.utf8Write("direct-tcpip",f+=4,12),L(c,t,f+=12),L(c,e,f+=4),L(c,n,f+=4),L(c,o,f+=4),c.utf8Write(s.dstIP,f+=4,o),L(c,s.dstPort,f+=o),L(c,i,f+=4),c.utf8Write(s.srcIP,f+=4,i),L(c,s.srcPort,f+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-tcpip)`),ke(this,this._packetRW.write.finalize(c))}openssh_directStreamLocal(t,e,n,s){if(this._server)throw new Error("Client-only method called in server mode");const i=Buffer.byteLength(s.socketPath);let o=this._packetRW.write.allocStart;const f=this._packetRW.write.alloc(1+4+30+4+4+4+4+i+4+4);f[o]=Be.CHANNEL_OPEN,L(f,30,++o),f.utf8Write("direct-streamlocal@openssh.com",o+=4,30),L(f,t,o+=30),L(f,e,o+=4),L(f,n,o+=4),L(f,i,o+=4),f.utf8Write(s.socketPath,o+=4,i),ea(f,0,o+=i,o+8),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-streamlocal@openssh.com)`),ke(this,this._packetRW.write.finalize(f))}openssh_noMoreSessions(t){if(this._server)throw new Error("Client-only method called in server mode");let e=this._packetRW.write.allocStart;const n=this._packetRW.write.alloc(1+4+28+1);n[e]=Be.GLOBAL_REQUEST,L(n,28,++e),n.utf8Write("no-more-sessions@openssh.com",e+=4,28),n[e+=28]=t===void 0||t===!0?1:0,this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)"),ke(this,this._packetRW.write.finalize(n))}session(t,e,n){if(this._server)throw new Error("Client-only method called in server mode");let s=this._packetRW.write.allocStart;const i=this._packetRW.write.alloc(1+4+7+4+4+4);i[s]=Be.CHANNEL_OPEN,L(i,7,++s),i.utf8Write("session",s+=4,7),L(i,t,s+=7),L(i,e,s+=4),L(i,n,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, session)`),ke(this,this._packetRW.write.finalize(i))}windowChange(t,e,n,s,i){if(this._server)throw new Error("Client-only method called in server mode");let o=this._packetRW.write.allocStart;const f=this._packetRW.write.alloc(1+4+4+13+1+4+4+4+4);f[o]=Be.CHANNEL_REQUEST,L(f,t,++o),L(f,13,o+=4),f.utf8Write("window-change",o+=4,13),f[o+=13]=0,L(f,n,++o),L(f,e,o+=4),L(f,i,o+=4),L(f,s,o+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, window-change)`),ke(this,this._packetRW.write.finalize(f))}pty(t,e,n,s,i,o,f,c){if(this._server)throw new Error("Client-only method called in server mode");(!o||!o.length)&&(o="vt100"),f&&!Buffer.isBuffer(f)&&!Array.isArray(f)&&typeof f=="object"&&f!==null&&(f=ga(f)),(!f||!f.length)&&(f=aa);const h=o.length,g=f.length;let u=this._packetRW.write.allocStart;const d=this._packetRW.write.alloc(1+4+4+7+1+4+h+4+4+4+4+4+g);if(d[u]=Be.CHANNEL_REQUEST,L(d,t,++u),L(d,7,u+=4),d.utf8Write("pty-req",u+=4,7),d[u+=7]=c===void 0||c===!0?1:0,L(d,h,++u),d.utf8Write(o,u+=4,h),L(d,n,u+=h),L(d,e,u+=4),L(d,i,u+=4),L(d,s,u+=4),L(d,g,u+=4),u+=4,Array.isArray(f))for(let A=0;A<g;++A)d[u++]=f[A];else Buffer.isBuffer(f)&&d.set(f,u);this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, pty-req)`),ke(this,this._packetRW.write.finalize(d))}shell(t,e){if(this._server)throw new Error("Client-only method called in server mode");let n=this._packetRW.write.allocStart;const s=this._packetRW.write.alloc(1+4+4+5+1);s[n]=Be.CHANNEL_REQUEST,L(s,t,++n),L(s,5,n+=4),s.utf8Write("shell",n+=4,5),s[n+=5]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, shell)`),ke(this,this._packetRW.write.finalize(s))}exec(t,e,n){if(this._server)throw new Error("Client-only method called in server mode");const s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e);let o=this._packetRW.write.allocStart;const f=this._packetRW.write.alloc(1+4+4+4+1+4+i);f[o]=Be.CHANNEL_REQUEST,L(f,t,++o),L(f,4,o+=4),f.utf8Write("exec",o+=4,4),f[o+=4]=n===void 0||n===!0?1:0,L(f,i,++o),s?f.set(e,o+=4):f.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exec: ${e})`),ke(this,this._packetRW.write.finalize(f))}signal(t,e){if(this._server)throw new Error("Client-only method called in server mode");const n=e;if(e=e.toUpperCase(),e.slice(0,3)==="SIG"&&(e=e.slice(3)),Is[e]!==1)throw new Error(`Invalid signal: ${n}`);const s=e.length;let i=this._packetRW.write.allocStart;const o=this._packetRW.write.alloc(1+4+4+6+1+4+s);o[i]=Be.CHANNEL_REQUEST,L(o,t,++i),L(o,6,i+=4),o.utf8Write("signal",i+=4,6),o[i+=6]=0,L(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, signal: ${e})`),ke(this,this._packetRW.write.finalize(o))}env(t,e,n,s){if(this._server)throw new Error("Client-only method called in server mode");const i=Buffer.byteLength(e),o=Buffer.isBuffer(n),f=o?n.length:Buffer.byteLength(n);let c=this._packetRW.write.allocStart;const h=this._packetRW.write.alloc(1+4+4+3+1+4+i+4+f);h[c]=Be.CHANNEL_REQUEST,L(h,t,++c),L(h,3,c+=4),h.utf8Write("env",c+=4,3),h[c+=3]=s===void 0||s===!0?1:0,L(h,i,++c),h.utf8Write(e,c+=4,i),L(h,f,c+=i),o?h.set(n,c+=4):h.utf8Write(n,c+=4,f),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, env: ${e}=${n})`),ke(this,this._packetRW.write.finalize(h))}x11Forward(t,e,n){if(this._server)throw new Error("Client-only method called in server mode");const s=e.protocol,i=e.cookie,o=Buffer.isBuffer(s),f=o?s.length:Buffer.byteLength(s),c=Buffer.isBuffer(i),h=c?i.length:Buffer.byteLength(i);let g=this._packetRW.write.allocStart;const u=this._packetRW.write.alloc(1+4+4+7+1+1+4+f+4+h+4);u[g]=Be.CHANNEL_REQUEST,L(u,t,++g),L(u,7,g+=4),u.utf8Write("x11-req",g+=4,7),u[g+=7]=n===void 0||n===!0?1:0,u[++g]=e.single?1:0,L(u,f,++g),o?u.set(s,g+=4):u.utf8Write(s,g+=4,f),L(u,h,g+=f),c?u.set(i,g+=4):u.latin1Write(i,g+=4,h),L(u,e.screen||0,g+=h),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, x11-req)`),ke(this,this._packetRW.write.finalize(u))}subsystem(t,e,n){if(this._server)throw new Error("Client-only method called in server mode");const s=Buffer.byteLength(e);let i=this._packetRW.write.allocStart;const o=this._packetRW.write.alloc(1+4+4+9+1+4+s);o[i]=Be.CHANNEL_REQUEST,L(o,t,++i),L(o,9,i+=4),o.utf8Write("subsystem",i+=4,9),o[i+=9]=n===void 0||n===!0?1:0,L(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, subsystem: ${e})`),ke(this,this._packetRW.write.finalize(o))}openssh_agentForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let n=this._packetRW.write.allocStart;const s=this._packetRW.write.alloc(1+4+4+26+1);s[n]=Be.CHANNEL_REQUEST,L(s,t,++n),L(s,26,n+=4),s.utf8Write("auth-agent-req@openssh.com",n+=4,26),s[n+=26]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, auth-agent-req@openssh.com)`),ke(this,this._packetRW.write.finalize(s))}openssh_hostKeysProve(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0;const n=[];for(const o of t){const f=o.getPublicSSH();e+=4+f.length,n.push(f)}let s=this._packetRW.write.allocStart;const i=this._packetRW.write.alloc(1+4+29+1+e);i[s]=Be.GLOBAL_REQUEST,L(i,29,++s),i.utf8Write("hostkeys-prove-00@openssh.com",s+=4,29),i[s+=29]=1,++s;for(const o of n)L(i,o.length,s),Nr(o,i,0,o.length,s+=4),s+=o.length;this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)"),ke(this,this._packetRW.write.finalize(i))}serviceAccept(t){if(!this._server)throw new Error("Server-only method called in client mode");const e=Buffer.byteLength(t);let n=this._packetRW.write.allocStart;const s=this._packetRW.write.alloc(1+4+e);if(s[n]=Be.SERVICE_ACCEPT,L(s,e,++n),s.utf8Write(t,n+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_ACCEPT (${t})`),ke(this,this._packetRW.write.finalize(s)),this._server&&this._banner&&t==="ssh-userauth"){const i=this._banner;this._banner=void 0;const o=Buffer.byteLength(i);n=this._packetRW.write.allocStart;const f=this._packetRW.write.alloc(1+4+o+4);f[n]=Be.USERAUTH_BANNER,L(f,o,++n),f.utf8Write(i,n+=4,o),L(f,0,n+=o),this._debug&&this._debug("Outbound: Sending USERAUTH_BANNER"),ke(this,this._packetRW.write.finalize(f))}}forwardedTcpip(t,e,n,s){if(!this._server)throw new Error("Server-only method called in client mode");const i=Buffer.byteLength(s.boundAddr),o=Buffer.byteLength(s.remoteAddr);let f=this._packetRW.write.allocStart;const c=this._packetRW.write.alloc(1+4+15+4+4+4+4+i+4+4+o+4);c[f]=Be.CHANNEL_OPEN,L(c,15,++f),c.utf8Write("forwarded-tcpip",f+=4,15),L(c,t,f+=15),L(c,e,f+=4),L(c,n,f+=4),L(c,i,f+=4),c.utf8Write(s.boundAddr,f+=4,i),L(c,s.boundPort,f+=i),L(c,o,f+=4),c.utf8Write(s.remoteAddr,f+=4,o),L(c,s.remotePort,f+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-tcpip)`),ke(this,this._packetRW.write.finalize(c))}x11(t,e,n,s){if(!this._server)throw new Error("Server-only method called in client mode");const i=Buffer.byteLength(s.originAddr);let o=this._packetRW.write.allocStart;const f=this._packetRW.write.alloc(1+4+3+4+4+4+4+i+4);f[o]=Be.CHANNEL_OPEN,L(f,3,++o),f.utf8Write("x11",o+=4,3),L(f,t,o+=3),L(f,e,o+=4),L(f,n,o+=4),L(f,i,o+=4),f.utf8Write(s.originAddr,o+=4,i),L(f,s.originPort,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, x11)`),ke(this,this._packetRW.write.finalize(f))}openssh_authAgent(t,e,n){if(!this._server)throw new Error("Server-only method called in client mode");let s=this._packetRW.write.allocStart;const i=this._packetRW.write.alloc(1+4+22+4+4+4);i[s]=Be.CHANNEL_OPEN,L(i,22,++s),i.utf8Write("auth-agent@openssh.com",s+=4,22),L(i,t,s+=22),L(i,e,s+=4),L(i,n,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, auth-agent@openssh.com)`),ke(this,this._packetRW.write.finalize(i))}openssh_forwardedStreamLocal(t,e,n,s){if(!this._server)throw new Error("Server-only method called in client mode");const i=Buffer.byteLength(s.socketPath);let o=this._packetRW.write.allocStart;const f=this._packetRW.write.alloc(1+4+33+4+4+4+4+i+4);f[o]=Be.CHANNEL_OPEN,L(f,33,++o),f.utf8Write("forwarded-streamlocal@openssh.com",o+=4,33),L(f,t,o+=33),L(f,e,o+=4),L(f,n,o+=4),L(f,i,o+=4),f.utf8Write(s.socketPath,o+=4,i),L(f,0,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-streamlocal@openssh.com)`),ke(this,this._packetRW.write.finalize(f))}exitStatus(t,e){if(!this._server)throw new Error("Server-only method called in client mode");let n=this._packetRW.write.allocStart;const s=this._packetRW.write.alloc(1+4+4+11+1+4);s[n]=Be.CHANNEL_REQUEST,L(s,t,++n),L(s,11,n+=4),s.utf8Write("exit-status",n+=4,11),s[n+=11]=0,L(s,e,++n),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-status: ${e})`),ke(this,this._packetRW.write.finalize(s))}exitSignal(t,e,n,s){if(!this._server)throw new Error("Server-only method called in client mode");const i=e;if(typeof i!="string"||!i)throw new Error(`Invalid signal: ${i}`);let o=e.toUpperCase();if(o.slice(0,3)==="SIG"&&(o=o.slice(3)),Is[o]!==1)throw new Error(`Invalid signal: ${i}`);const f=Buffer.byteLength(o),c=s?Buffer.byteLength(s):0;let h=this._packetRW.write.allocStart;const g=this._packetRW.write.alloc(1+4+4+11+1+4+f+1+4+c+4);g[h]=Be.CHANNEL_REQUEST,L(g,t,++h),L(g,11,h+=4),g.utf8Write("exit-signal",h+=4,11),g[h+=11]=0,L(g,f,++h),g.utf8Write(o,h+=4,f),g[h+=f]=n?1:0,L(g,c,++h),h+=4,c&&(g.utf8Write(s,h,c),h+=c),L(g,0,h),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-signal: ${e})`),ke(this,this._packetRW.write.finalize(g))}authFailure(t,e){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0)throw new Error("No auth in progress");let n;if(typeof t=="boolean"&&(e=t,t=void 0),t){n=[];for(let f=0;f<t.length;++f)t[f].toLowerCase()!=="none"&&n.push(t[f]);n=n.join(",")}else n="";const s=n.length;let i=this._packetRW.write.allocStart;const o=this._packetRW.write.alloc(1+4+s+1);o[i]=Be.USERAUTH_FAILURE,L(o,s,++i),o.utf8Write(n,i+=4,s),o[i+=s]=e===!0?1:0,this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_FAILURE"),ke(this,this._packetRW.write.finalize(o))}authSuccess(){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0)throw new Error("No auth in progress");const t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=Be.USERAUTH_SUCCESS,this._authsQueue.shift(),this._authenticated=!0,this._debug&&this._debug("Outbound: Sending USERAUTH_SUCCESS"),ke(this,this._packetRW.write.finalize(e)),this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.read=new Cs),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new Bs(this))}authPKOK(t,e){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0||this._authsQueue[0]!=="publickey")throw new Error('"publickey" auth not in progress');const n=Buffer.byteLength(t),s=e.length;let i=this._packetRW.write.allocStart;const o=this._packetRW.write.alloc(1+4+n+4+s);o[i]=Be.USERAUTH_PK_OK,L(o,n,++i),o.utf8Write(t,i+=4,n),L(o,s,i+=n),o.set(e,i+=4),this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_PK_OK"),ke(this,this._packetRW.write.finalize(o))}authPasswdChg(t){if(!this._server)throw new Error("Server-only method called in client mode");const e=Buffer.byteLength(t);let n=this._packetRW.write.allocStart;const s=this._packetRW.write.alloc(1+4+e+4);s[n]=Be.USERAUTH_PASSWD_CHANGEREQ,L(s,e,++n),s.utf8Write(t,n+=4,e),L(s,0,n+=e),this._debug&&this._debug("Outbound: Sending USERAUTH_PASSWD_CHANGEREQ"),ke(this,this._packetRW.write.finalize(s))}authInfoReq(t,e,n){if(!this._server)throw new Error("Server-only method called in client mode");let s=0;const i=t?Buffer.byteLength(t):0,o=e?Buffer.byteLength(e):0;for(let h=0;h<n.length;++h)s+=4+Buffer.byteLength(n[h].prompt)+1;let f=this._packetRW.write.allocStart;const c=this._packetRW.write.alloc(1+4+i+4+o+4+4+s);c[f]=Be.USERAUTH_INFO_REQUEST,L(c,i,++f),f+=4,t&&(c.utf8Write(t,f,i),f+=i),L(c,o,f),f+=4,e&&(c.utf8Write(e,f,o),f+=o),L(c,0,f),L(c,n.length,f+=4),f+=4;for(let h=0;h<n.length;++h){const g=n[h],u=Buffer.byteLength(g.prompt);L(c,u,f),f+=4,u&&(c.utf8Write(g.prompt,f,u),f+=u),c[f++]=g.echo?1:0}this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_REQUEST"),ke(this,this._packetRW.write.finalize(c))}};const ha=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function ua(r,t,e){let n,s;this._buffer?(n=Buffer.allocUnsafe(this._buffer.length+(e-t)),n.set(this._buffer,0),t===0?n.set(r,this._buffer.length):n.set(new Uint8Array(r.buffer,r.byteOffset+t,e-t),this._buffer.length),s=this._buffer.length,t=0):(n=r,s=0);const i=t;let o=t,f=t,c=!1,h=0,g=0;for(;t<n.length;++t){const u=n[t];if(u===13){c=!0;continue}if(u===10){if(f>o&&f-o>4&&n[o]===83&&n[o+1]===83&&n[o+2]===72&&n[o+3]===45){const d=n.latin1Slice(i,f+1),A=o===i?d:d.slice(o-i),I=ha.exec(A);if(!I)throw new Error("Invalid identification string");const y={greeting:o===i?"":d.slice(0,o-i),identRaw:A,versions:{protocol:I[1],software:I[2]},comments:I[3]};return this._remoteIdentRaw=Buffer.from(A),this._debug&&this._debug(`Remote ident: ${ps(A)}`),this._compatFlags=Aa(y),this._buffer=void 0,this._decipher=new Yf(0,Jf.bind(this,{firstPacket:!0})),this._parse=la,this._onHeader(y),this._destruct?(ys(this),t+1-s):e}if(this._server)throw new Error("Greetings from clients not permitted");if(++g>fa)throw new Error("Max greeting lines exceeded");c=!1,o=t+1,h=0}else{if(c)throw new Error("Invalid header: expected newline");if(++h>=oa)throw new Error("Header line too long")}f=t}return this._buffer||(this._buffer=ws(n,i)),t-s}function la(r,t,e){return this._decipher.decrypt(r,t,e)}function da(r){if(this._onPacket(),r.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}r=this._packetRW.read.read(r);const t=r[0];t===Be.USERAUTH_SUCCESS&&!this._server&&!this._authenticated&&(this._authenticated=!0,this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.write=new Bs(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new Cs));const e=Zf[t];if(e===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${t}`);return}return e(this,r)}function Aa(r){const t=r.versions.software;let e=0;for(const n of Xf)typeof n[0]=="string"?t===n[0]&&(e|=n[1]):n[0].test(t)&&(e|=n[1]);return e}function ga(r){const t=Object.keys(r),e=Buffer.allocUnsafe(5*t.length+1);let n=0;for(let s=0;s<t.length;++s){const i=t[s];if(i==="TTY_OP_END")continue;const o=gi[i];if(o===void 0)continue;const f=r[i];typeof f=="number"&&isFinite(f)&&(e[n++]=o,e[n++]=f>>>24,e[n++]=f>>>16,e[n++]=f>>>8,e[n++]=f)}return e[n++]=gi.TTY_OP_END,n<e.length?ws(e,0,n):e}function _a(r){let t="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";jf&&(t=`ssh-ed25519,${t}`);const e=Buffer.byteLength(t);let n=r._packetRW.write.allocStart;const s=r._packetRW.write.alloc(1+4+4+15+4+e);s[n]=Be.EXT_INFO,L(s,1,++n),L(s,15,n+=4),s.utf8Write("server-sig-algs",n+=4,15),L(s,e,n+=15),s.utf8Write(t,n+=4,e),r._debug&&r._debug("Outbound: Sending EXT_INFO"),ke(r,r._packetRW.write.finalize(s))}var Ns=ca,or={};const vr=tt,{inspect:Ea}=tt;function vs(r){let t="",e=r.length;const n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return`${r.slice(0,e)}${t}`}function Ts(r,t){if(vr(typeof t=="string","`thing` has to be of type string"),Array.isArray(r)){const e=r.length;return vr(e>0,"At least one expected value needs to be specified"),r=r.map(n=>String(n)),e>2?`one of ${t} ${r.slice(0,e-1).join(", ")}, or `+r[e-1]:e===2?`one of ${t} ${r[0]} or ${r[1]}`:`of ${t} ${r[0]}`}return`of ${t} ${String(r)}`}or.ERR_INTERNAL_ASSERTION=class Lo extends Error{constructor(t){super(),Error.captureStackTrace(this,Lo);const e=`This is caused by either a bug in ssh2 or incorrect usage of ssh2 internals.
13
+ Please open an issue with this stack trace at https://github.com/mscdex/ssh2/issues
14
+ `;this.message=t===void 0?e:`${t}
15
+ ${e}`}};const pa=2**32,Ls=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();or.ERR_OUT_OF_RANGE=class Uo extends RangeError{constructor(t,e,n,s){super(),Error.captureStackTrace(this,Uo),vr(e,'Missing "range" argument');let i=s?t:`The value of "${t}" is out of range.`,o;Number.isInteger(n)&&Math.abs(n)>pa?o=vs(String(n)):typeof n=="bigint"?(o=String(n),(n>Ls||n<-Ls)&&(o=vs(o)),o+="n"):o=Ea(n),i+=` It must be ${e}. Received ${o}`,this.message=i}};let Us=class Po extends TypeError{constructor(t,e,n){super(),Error.captureStackTrace(this,Po),vr(typeof t=="string","'name' must be a string");let s;typeof e=="string"&&e.startsWith("not ")?(s="must not be",e=e.replace(/^not /,"")):s="must be";let i;if(t.endsWith(" argument"))i=`The ${t} ${s} ${Ts(e,"type")}`;else{const o=t.includes(".")?"property":"argument";i=`The "${t}" ${o} ${s} ${Ts(e,"type")}`}i+=`. Received type ${typeof n}`,this.message=i}};or.ERR_INVALID_ARG_TYPE=Us,or.validateNumber=function(t,e){if(typeof t!="number")throw new Us(e,"number",t)};const ba=tt,bn=tt,{constants:Wt}=bn,{Readable:Ps,Writable:Ei}=tt,{inherits:Os,isDate:pi}=tt,Ia=Buffer[Symbol.species],{bufferCopy:In,bufferSlice:Hn,makeBufferParser:xa,writeUInt32BE:G}=nn(),un={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},Oe=Buffer.alloc(28),it={OK:0,EOF:1,NO_SUCH_FILE:2,PERMISSION_DENIED:3,FAILURE:4,BAD_MESSAGE:5,NO_CONNECTION:6,CONNECTION_LOST:7,OP_UNSUPPORTED:8},ya=new Map(Object.values(it).map(r=>[r,1])),Sa={[it.OK]:"No error",[it.EOF]:"End of file",[it.NO_SUCH_FILE]:"No such file or directory",[it.PERMISSION_DENIED]:"Permission denied",[it.FAILURE]:"Failure",[it.BAD_MESSAGE]:"Bad message",[it.NO_CONNECTION]:"No connection",[it.CONNECTION_LOST]:"Connection lost",[it.OP_UNSUPPORTED]:"Operation unsupported"},Ue={INIT:1,OPEN:3,CLOSE:4,READ:5,WRITE:6,LSTAT:7,FSTAT:8,SETSTAT:9,FSETSTAT:10,OPENDIR:11,READDIR:12,REMOVE:13,MKDIR:14,RMDIR:15,REALPATH:16,STAT:17,RENAME:18,READLINK:19,SYMLINK:20,EXTENDED:200},$t={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},Re={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},Ds=2*1024,lt=2**32-1,wa=Buffer.from([0,0,0,5,Ue.INIT,0,0,0,3]),ma=Buffer.from([0,0,0,5,$t.VERSION,0,0,0,3]),Ca=/^SSH-2.0-(?:OpenSSH|dropbear)/,bi=256*1024,D=xa(),Ba={readable:!1,writable:!1,push:r=>{},once:()=>{},on:()=>{},emit:()=>{},end:()=>{}};function Hs(){}let ka=class extends ba{constructor(t,e,n){super(),(typeof n!="object"||!n)&&(n={});const s=t._protocol._remoteIdentRaw;this.server=!!n.server,this._debug=typeof n.debug=="function"?n.debug:void 0,this._isOpenSSH=s&&Ca.test(s),this._version=-1,this._extensions={},this._biOpt=n.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=bi,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?bi:34e3)-Ds,this._maxWriteLen=(this._isOpenSSH?bi:34e3)-Ds,this.maxOpenHandles=void 0,this._client=t,this._protocol=t._protocol,this._callbacks=[],this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this._waitWindow=!1,this._chunkcb=void 0,this._buffer=[],this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this.stderr=Ba,this.readable=!0}push(t){if(t===null){if(qs(this),!this.readable)return;this.readable=!1,this.emit("end");return}let e=0;for(;e<t.length;){if(this._pktLenBytes<4){let o=Math.min(4-this._pktLenBytes,t.length-e);for(this._pktLenBytes+=o;o--;)this._pktLen=(this._pktLen<<8)+t[e++];if(this._pktLenBytes<4)return;if(this._pktLen===0)return ft(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){const f=this._maxInPktLen;return ft(this,`Packet length ${this._pktLen} exceeds max length of ${f}`)}if(e>=t.length)return}if(this._pktPos<this._pktLen){const o=Math.min(this._pktLen-this._pktPos,t.length-e);if(e!==0||o!==t.length?o===this._pktLen?this._pkt=new Ia(t.buffer,t.byteOffset+e,o):(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._pktPos)):o===this._pktLen?this._pkt=t:(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(t,this._pktPos)),e+=o,this._pktPos+=o,this._pktPos<this._pktLen)return}const n=this._pkt[0],s=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;const i=this.server?La[n]:Ta[n];if(!i)return ft(this,`Unknown packet type ${n}`);if(this._version===-1){if(this.server){if(n!==Ue.INIT)return ft(this,`Expected INIT packet, got ${n}`)}else if(n!==$t.VERSION)return ft(this,`Expected VERSION packet, got ${n}`)}if(i(this,s)===!1)return}}end(){this.destroy()}destroy(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._protocol.channelClose(this.outgoing.id))}_init(){this._init=Hs,this.server||nt(this,wa)}createReadStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new ln(this,t,e)}createWriteStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new Vt(this,t,e)}open(t,e,n,s){if(this.server)throw new Error("Client-only method called in server mode");typeof n=="function"&&(s=n,n=void 0);const i=typeof e=="number"?e:Ks(e);if(i===null)throw new Error(`Unknown flags string: ${e}`);let o=0,f=0;(typeof n=="string"||typeof n=="number")&&(n={mode:n}),typeof n=="object"&&n!==null&&(n=Nn(n),o=n.flags,f=n.nb);const c=Buffer.byteLength(t);let h=9;const g=Buffer.allocUnsafe(4+1+4+4+c+4+4+f);G(g,g.length-4,0),g[4]=Ue.OPEN;const u=this._writeReqid=this._writeReqid+1&lt;G(g,u,5),G(g,c,h),g.utf8Write(t,h+=4,c),G(g,i,h+=c),G(g,o,h+=4),f&&(h+=4,f===Oe.length?g.set(Oe,h):In(Oe,g,0,f,h),h+=f),this._requests[u]={cb:s};const d=nt(this,g);this._debug&&this._debug(`SFTP: Outbound: ${d?"Buffered":"Sending"} OPEN`)}close(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");const n=t.length;let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=Ue.CLOSE;const o=this._writeReqid=this._writeReqid+1&lt;G(i,o,5),G(i,n,s),i.set(t,s+=4),this._requests[o]={cb:e};const f=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} CLOSE`)}read(t,e,n,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(n>=e.length)throw new Error("offset is out of bounds");if(n+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");Qs(this,t,e,n,s,i,o)}readData(t,e,n,s,i,o){this.read(t,e,n,s,i,o)}write(t,e,n,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(n>e.length)throw new Error("offset is out of bounds");if(n+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");if(!s){o&&process.nextTick(o,void 0,0);return}const f=this._maxWriteLen,c=Math.max(s-f,0),h=i;c&&(s=f);const g=t.length;let u=9;const d=Buffer.allocUnsafe(4+1+4+4+g+8+4+s);G(d,d.length-4,0),d[4]=Ue.WRITE;const A=this._writeReqid=this._writeReqid+1&lt;G(d,A,5),G(d,g,u),d.set(t,u+=4),u+=g;for(let y=7;y>=0;--y)d[u+y]=i&255,i/=256;G(d,s,u+=8),In(e,d,n,n+s,u+=4),this._requests[A]={cb:y=>{y?typeof o=="function"&&o(y):c?this.write(t,e,n+s,c,h+s,o):typeof o=="function"&&o(void 0,n+s)}};const I=nt(this,d);if(this._debug){const y=I?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${y} WRITE (id:${A})`)}}writeData(t,e,n,s,i,o){this.write(t,e,n,s,i,o)}fastGet(t,e,n,s){if(this.server)throw new Error("Client-only method called in server mode");Fs(this,bn,t,e,n,s)}fastPut(t,e,n,s){if(this.server)throw new Error("Client-only method called in server mode");Fs(bn,this,t,e,n,s)}readFile(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof n=="function"?s=n:typeof e=="function"&&(s=e,e=void 0),typeof e=="string")e={encoding:e,flag:"r"};else if(!e)e={encoding:null,flag:"r"};else if(typeof e!="object")throw new TypeError("Bad arguments");const i=e.encoding;if(i&&!Buffer.isEncoding(i))throw new Error(`Unknown encoding: ${i}`);let o,f,c,h=0,g,u=0;const d=e.flag||"r",A=()=>{o===0?(f=Buffer.allocUnsafe(8192),this.read(g,f,0,8192,u,I)):this.read(g,f,h,o-h,u,I)},I=(w,R)=>{let M;if(w){if(M=w.code===it.EOF,!M)return this.close(g,()=>s&&s(w))}else M=!1;if(M||o===0&&R===0)return y();u+=R,h+=R,o!==0?h===o?y():A():(c.push(Hn(f,0,R)),A())};I._wantEOFError=!0;const y=()=>{this.close(g,w=>(o===0?f=Buffer.concat(c,h):h<o&&(f=Hn(f,0,h)),i&&(f=f.toString(i)),s&&s(w,f)))};this.open(t,d,438,(w,R)=>{if(w)return s&&s(w);g=R;const M=(ce,q)=>{if(ce){this.stat(t,(le,se)=>{if(le)return this.close(g,()=>{s&&s(ce)});M(null,se)});return}if(o=q.size||0,o===0)return c=[],A();f=Buffer.allocUnsafe(o),A()};this.fstat(g,M)})}writeFile(t,e,n,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof n=="function"&&(i=n,n=void 0),typeof n=="string")n={encoding:n,mode:438,flag:"w"};else if(!n)n={encoding:"utf8",mode:438,flag:"w"};else if(typeof n!="object")throw new TypeError("Bad arguments");if(n.encoding&&!Buffer.isEncoding(n.encoding))throw new Error(`Unknown encoding: ${n.encoding}`);const o=n.flag||"w";this.open(t,o,n.mode,(f,c)=>{if(f)i&&i(f);else{const h=Buffer.isBuffer(e)?e:Buffer.from(""+e,n.encoding||"utf8"),g=/a/.test(o)?null:0;if(g===null){const u=(d,A)=>{if(d){this.stat(t,(I,y)=>{if(I)return this.close(c,()=>{i&&i(d)});u(null,y)});return}Ii(this,c,h,0,h.length,A.size,i)};this.fstat(c,u);return}Ii(this,c,h,0,h.length,g,i)}})}appendFile(t,e,n,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof n=="function"&&(i=n,n=void 0),typeof n=="string")n={encoding:n,mode:438,flag:"a"};else if(!n)n={encoding:"utf8",mode:438,flag:"a"};else if(typeof n!="object")throw new TypeError("Bad arguments");n.flag||(n=Object.assign({flag:"a"},n)),this.writeFile(t,e,n,i)}exists(t,e){if(this.server)throw new Error("Client-only method called in server mode");this.stat(t,n=>{e&&e(!n)})}unlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");const n=Buffer.byteLength(t);let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=Ue.REMOVE;const o=this._writeReqid=this._writeReqid+1&lt;G(i,o,5),G(i,n,s),i.utf8Write(t,s+=4,n),this._requests[o]={cb:e};const f=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} REMOVE`)}rename(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");const s=Buffer.byteLength(t),i=Buffer.byteLength(e);let o=9;const f=Buffer.allocUnsafe(4+1+4+4+s+4+i);G(f,f.length-4,0),f[4]=Ue.RENAME;const c=this._writeReqid=this._writeReqid+1&lt;G(f,c,5),G(f,s,o),f.utf8Write(t,o+=4,s),G(f,i,o+=s),f.utf8Write(e,o+=4,i),this._requests[c]={cb:n};const h=nt(this,f);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} RENAME`)}mkdir(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="function"&&(n=e,e=void 0),typeof e=="object"&&e!==null&&(e=Nn(e),s=e.flags,i=e.nb);const o=Buffer.byteLength(t);let f=9;const c=Buffer.allocUnsafe(4+1+4+4+o+4+i);G(c,c.length-4,0),c[4]=Ue.MKDIR;const h=this._writeReqid=this._writeReqid+1&lt;G(c,h,5),G(c,o,f),c.utf8Write(t,f+=4,o),G(c,s,f+=o),i&&(f+=4,i===Oe.length?c.set(Oe,f):In(Oe,c,0,i,f),f+=i),this._requests[h]={cb:n};const g=nt(this,c);this._debug&&this._debug(`SFTP: Outbound: ${g?"Buffered":"Sending"} MKDIR`)}rmdir(t,e){if(this.server)throw new Error("Client-only method called in server mode");const n=Buffer.byteLength(t);let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=Ue.RMDIR;const o=this._writeReqid=this._writeReqid+1&lt;G(i,o,5),G(i,n,s),i.utf8Write(t,s+=4,n),this._requests[o]={cb:e};const f=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} RMDIR`)}readdir(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");typeof e=="function"&&(n=e,e={}),(typeof e!="object"||e===null)&&(e={});const s=!(e&&e.full);if(!Buffer.isBuffer(t)&&typeof t!="string")throw new Error("missing directory handle or path");if(typeof t=="string"){const g=[];let u=0;const d=(A,I)=>{if(A)return n(A);this.readdir(I,e,(y,w)=>{const R=y&&y.code===it.EOF;if(y&&!R)return this.close(I,()=>n(y));if(R)return this.close(I,M=>{if(M)return n(M);n(void 0,g)});for(let M=0;M<w.length;++M,++u)g[u]=w[M];d(void 0,I)})};return this.opendir(t,d)}const i=t.length;let o=9;const f=Buffer.allocUnsafe(4+1+4+4+i);G(f,f.length-4,0),f[4]=Ue.READDIR;const c=this._writeReqid=this._writeReqid+1&lt;G(f,c,5),G(f,i,o),f.set(t,o+=4),this._requests[c]={cb:s?(g,u)=>{if(typeof n=="function"){if(g)return n(g);for(let d=u.length-1;d>=0;--d)(u[d].filename==="."||u[d].filename==="..")&&u.splice(d,1);n(void 0,u)}}:n};const h=nt(this,f);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} READDIR`)}fstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");const n=t.length;let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=Ue.FSTAT;const o=this._writeReqid=this._writeReqid+1&lt;G(i,o,5),G(i,n,s),i.set(t,s+=4),this._requests[o]={cb:e};const f=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} FSTAT`)}stat(t,e){if(this.server)throw new Error("Client-only method called in server mode");const n=Buffer.byteLength(t);let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=Ue.STAT;const o=this._writeReqid=this._writeReqid+1&lt;G(i,o,5),G(i,n,s),i.utf8Write(t,s+=4,n),this._requests[o]={cb:e};const f=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} STAT`)}lstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");const n=Buffer.byteLength(t);let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=Ue.LSTAT;const o=this._writeReqid=this._writeReqid+1&lt;G(i,o,5),G(i,n,s),i.utf8Write(t,s+=4,n),this._requests[o]={cb:e};const f=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} LSTAT`)}opendir(t,e){if(this.server)throw new Error("Client-only method called in server mode");const n=Buffer.byteLength(t);let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=Ue.OPENDIR;const o=this._writeReqid=this._writeReqid+1&lt;G(i,o,5),G(i,n,s),i.utf8Write(t,s+=4,n),this._requests[o]={cb:e};const f=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} OPENDIR`)}setstat(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="object"&&e!==null?(e=Nn(e),s=e.flags,i=e.nb):typeof e=="function"&&(n=e);const o=Buffer.byteLength(t);let f=9;const c=Buffer.allocUnsafe(4+1+4+4+o+4+i);G(c,c.length-4,0),c[4]=Ue.SETSTAT;const h=this._writeReqid=this._writeReqid+1&lt;G(c,h,5),G(c,o,f),c.utf8Write(t,f+=4,o),G(c,s,f+=o),i&&(f+=4,i===Oe.length?c.set(Oe,f):In(Oe,c,0,i,f),f+=i),this._requests[h]={cb:n};const g=nt(this,c);this._debug&&this._debug(`SFTP: Outbound: ${g?"Buffered":"Sending"} SETSTAT`)}fsetstat(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=0,i=0;typeof e=="object"&&e!==null?(e=Nn(e),s=e.flags,i=e.nb):typeof e=="function"&&(n=e);const o=t.length;let f=9;const c=Buffer.allocUnsafe(4+1+4+4+o+4+i);G(c,c.length-4,0),c[4]=Ue.FSETSTAT;const h=this._writeReqid=this._writeReqid+1&lt;G(c,h,5),G(c,o,f),c.set(t,f+=4),G(c,s,f+=o),i&&(f+=4,i===Oe.length?c.set(Oe,f):In(Oe,c,0,i,f),f+=i),this._requests[h]={cb:n};const g=nt(this,c);this._debug&&this._debug(`SFTP: Outbound: ${g?"Buffered":"Sending"} FSETSTAT`)}futimes(t,e,n,s){return this.fsetstat(t,{atime:Qn(e),mtime:Qn(n)},s)}utimes(t,e,n,s){return this.setstat(t,{atime:Qn(e),mtime:Qn(n)},s)}fchown(t,e,n,s){return this.fsetstat(t,{uid:e,gid:n},s)}chown(t,e,n,s){return this.setstat(t,{uid:e,gid:n},s)}fchmod(t,e,n){return this.fsetstat(t,{mode:e},n)}chmod(t,e,n){return this.setstat(t,{mode:e},n)}readlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");const n=Buffer.byteLength(t);let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=Ue.READLINK;const o=this._writeReqid=this._writeReqid+1&lt;G(i,o,5),G(i,n,s),i.utf8Write(t,s+=4,n),this._requests[o]={cb:(c,h)=>{if(typeof e=="function"){if(c)return e(c);if(!h||!h.length)return e(new Error("Response missing link info"));e(void 0,h[0].filename)}}};const f=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} READLINK`)}symlink(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");const s=Buffer.byteLength(e),i=Buffer.byteLength(t);let o=9;const f=Buffer.allocUnsafe(4+1+4+4+s+4+i);G(f,f.length-4,0),f[4]=Ue.SYMLINK;const c=this._writeReqid=this._writeReqid+1&lt;G(f,c,5),this._isOpenSSH?(G(f,i,o),f.utf8Write(t,o+=4,i),G(f,s,o+=i),f.utf8Write(e,o+=4,s)):(G(f,s,o),f.utf8Write(e,o+=4,s),G(f,i,o+=s),f.utf8Write(t,o+=4,i)),this._requests[c]={cb:n};const h=nt(this,f);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} SYMLINK`)}realpath(t,e){if(this.server)throw new Error("Client-only method called in server mode");const n=Buffer.byteLength(t);let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=Ue.REALPATH;const o=this._writeReqid=this._writeReqid+1&lt;G(i,o,5),G(i,n,s),i.utf8Write(t,s+=4,n),this._requests[o]={cb:(c,h)=>{if(typeof e=="function"){if(c)return e(c);if(!h||!h.length)return e(new Error("Response missing path info"));e(void 0,h[0].filename)}}};const f=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");const s=this._extensions["posix-rename@openssh.com"];if(!s||s!=="1")throw new Error("Server does not support this extended request");const i=Buffer.byteLength(t),o=Buffer.byteLength(e);let f=9;const c=Buffer.allocUnsafe(4+1+4+4+24+4+i+4+o);G(c,c.length-4,0),c[4]=Ue.EXTENDED;const h=this._writeReqid=this._writeReqid+1&lt;G(c,h,5),G(c,24,f),c.utf8Write("posix-rename@openssh.com",f+=4,24),G(c,i,f+=24),c.utf8Write(t,f+=4,i),G(c,o,f+=i),c.utf8Write(e,f+=4,o),this._requests[h]={cb:n};const g=nt(this,c);if(this._debug){const u=g?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${u} posix-rename@openssh.com`)}}ext_openssh_statvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");const n=this._extensions["statvfs@openssh.com"];if(!n||n!=="2")throw new Error("Server does not support this extended request");const s=Buffer.byteLength(t);let i=9;const o=Buffer.allocUnsafe(4+1+4+4+19+4+s);G(o,o.length-4,0),o[4]=Ue.EXTENDED;const f=this._writeReqid=this._writeReqid+1&lt;G(o,f,5),G(o,19,i),o.utf8Write("statvfs@openssh.com",i+=4,19),G(o,s,i+=19),o.utf8Write(t,i+=4,s),this._requests[f]={extended:"statvfs@openssh.com",cb:e};const c=nt(this,o);if(this._debug){const h=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} statvfs@openssh.com`)}}ext_openssh_fstatvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");const n=this._extensions["fstatvfs@openssh.com"];if(!n||n!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");const s=t.length;let i=9;const o=Buffer.allocUnsafe(4+1+4+4+20+4+s);G(o,o.length-4,0),o[4]=Ue.EXTENDED;const f=this._writeReqid=this._writeReqid+1&lt;G(o,f,5),G(o,20,i),o.utf8Write("fstatvfs@openssh.com",i+=4,20),G(o,s,i+=20),o.set(t,i+=4),this._requests[f]={extended:"fstatvfs@openssh.com",cb:e};const c=nt(this,o);if(this._debug){const h=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} fstatvfs@openssh.com`)}}ext_openssh_hardlink(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["hardlink@openssh.com"]!=="1")throw new Error("Server does not support this extended request");const i=Buffer.byteLength(t),o=Buffer.byteLength(e);let f=9;const c=Buffer.allocUnsafe(4+1+4+4+20+4+i+4+o);G(c,c.length-4,0),c[4]=Ue.EXTENDED;const h=this._writeReqid=this._writeReqid+1&lt;G(c,h,5),G(c,20,f),c.utf8Write("hardlink@openssh.com",f+=4,20),G(c,i,f+=20),c.utf8Write(t,f+=4,i),G(c,o,f+=i),c.utf8Write(e,f+=4,o),this._requests[h]={cb:n};const g=nt(this,c);if(this._debug){const u=g?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${u} hardlink@openssh.com`)}}ext_openssh_fsync(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["fsync@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");const s=t.length;let i=9;const o=Buffer.allocUnsafe(4+1+4+4+17+4+s);G(o,o.length-4,0),o[4]=Ue.EXTENDED;const f=this._writeReqid=this._writeReqid+1&lt;G(o,f,5),G(o,17,i),o.utf8Write("fsync@openssh.com",i+=4,17),G(o,s,i+=17),o.set(t,i+=4),this._requests[f]={cb:e};const c=nt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${c?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["lsetstat@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=0,o=0;typeof e=="object"&&e!==null?(e=Nn(e),i=e.flags,o=e.nb):typeof e=="function"&&(n=e);const f=Buffer.byteLength(t);let c=9;const h=Buffer.allocUnsafe(4+1+4+4+20+4+f+4+o);G(h,h.length-4,0),h[4]=Ue.EXTENDED;const g=this._writeReqid=this._writeReqid+1&lt;G(h,g,5),G(h,20,c),h.utf8Write("lsetstat@openssh.com",c+=4,20),G(h,f,c+=20),h.utf8Write(t,c+=4,f),G(h,i,c+=f),o&&(c+=4,o===Oe.length?h.set(Oe,c):In(Oe,h,0,o,c),c+=o),this._requests[g]={cb:n};const u=nt(this,h);if(this._debug){const d=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${d} lsetstat@openssh.com`)}}ext_openssh_expandPath(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["expand-path@openssh.com"]!=="1")throw new Error("Server does not support this extended request");const s=Buffer.byteLength(t);let i=9;const o=Buffer.allocUnsafe(4+1+4+4+23+4+s);G(o,o.length-4,0),o[4]=Ue.EXTENDED;const f=this._writeReqid=this._writeReqid+1&lt;G(o,f,5),G(o,23,i),o.utf8Write("expand-path@openssh.com",i+=4,23),G(o,s,i+=20),o.utf8Write(t,i+=4,s),this._requests[f]={cb:(h,g)=>{if(typeof e=="function"){if(h)return e(h);if(!g||!g.length)return e(new Error("Response missing expanded path"));e(void 0,g[0].filename)}}};const c=nt(this,o);if(this._debug){const h=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} expand-path@openssh.com`)}}ext_copy_data(t,e,n,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["copy-data"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("Source handle is not a Buffer");if(!Buffer.isBuffer(s))throw new Error("Destination handle is not a Buffer");let c=0;const h=Buffer.allocUnsafe(4+1+4+4+9+4+t.length+8+8+4+s.length+8);G(h,h.length-4,c),c+=4,h[c]=Ue.EXTENDED,++c;const g=this._writeReqid=this._writeReqid+1&lt;G(h,g,c),c+=4,G(h,9,c),c+=4,h.utf8Write("copy-data",c,9),c+=9,G(h,t.length,c),c+=4,h.set(t,c),c+=t.length;for(let d=7;d>=0;--d)h[c+d]=e&255,e/=256;c+=8;for(let d=7;d>=0;--d)h[c+d]=n&255,n/=256;c+=8,G(h,s.length,c),c+=4,h.set(s,c),c+=s.length;for(let d=7;d>=0;--d)h[c+d]=i&255,i/=256;this._requests[g]={cb:o};const u=nt(this,h);if(this._debug){const d=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${d} copy-data`)}}ext_home_dir(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["home-directory"]!=="1")throw new Error("Server does not support this extended request");if(typeof t!="string")throw new TypeError("username is not a string");let s=0;const i=Buffer.byteLength(t),o=Buffer.allocUnsafe(4+1+4+4+14+4+i);G(o,o.length-4,s),s+=4,o[s]=Ue.EXTENDED,++s;const f=this._writeReqid=this._writeReqid+1&lt;G(o,f,s),s+=4,G(o,14,s),s+=4,o.utf8Write("home-directory",s,14),s+=14,G(o,i,s),s+=4,o.utf8Write(t,s,i),s+=i,this._requests[f]={cb:(h,g)=>{if(typeof e=="function"){if(h)return e(h);if(!g||!g.length)return e(new Error("Response missing home directory"));e(void 0,g[0].filename)}}};const c=nt(this,o);if(this._debug){const h=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} home-directory`)}}ext_users_groups(t,e,n){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["users-groups-by-id@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Array.isArray(t))throw new TypeError("uids is not an array");for(const h of t)if(!Number.isInteger(h)||h<0||h>2**32-1)throw new Error("uid values must all be 32-bit unsigned integers");if(!Array.isArray(e))throw new TypeError("gids is not an array");for(const h of e)if(!Number.isInteger(h)||h<0||h>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let i=0;const o=Buffer.allocUnsafe(4+1+4+4+30+4+4*t.length+4+4*e.length);G(o,o.length-4,i),i+=4,o[i]=Ue.EXTENDED,++i;const f=this._writeReqid=this._writeReqid+1&lt;G(o,f,i),i+=4,G(o,30,i),i+=4,o.utf8Write("users-groups-by-id@openssh.com",i,30),i+=30,G(o,4*t.length,i),i+=4;for(const h of t)G(o,h,i),i+=4;G(o,4*e.length,i),i+=4;for(const h of e)G(o,h,i),i+=4;this._requests[f]={extended:"users-groups-by-id@openssh.com",cb:n};const c=nt(this,o);if(this._debug){const h=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} users-groups-by-id@openssh.com`)}}handle(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");const n=e.length;if(n>256)throw new Error("handle too large (> 256 bytes)");let s=9;const i=Buffer.allocUnsafe(4+1+4+4+n);G(i,i.length-4,0),i[4]=$t.HANDLE,G(i,t,5),G(i,n,s),n&&i.set(e,s+=4);const o=nt(this,i);this._debug&&this._debug(`SFTP: Outbound: ${o?"Buffered":"Sending"} HANDLE`)}status(t,e,n){if(!this.server)throw new Error("Server-only method called in client mode");if(!ya.has(e))throw new Error(`Bad status code: ${e}`);n||(n="");const s=Buffer.byteLength(n);let i=9;const o=Buffer.allocUnsafe(4+1+4+4+4+s+4);G(o,o.length-4,0),o[4]=$t.STATUS,G(o,t,5),G(o,e,i),G(o,s,i+=4),i+=4,s&&(o.utf8Write(n,i,s),i+=s),G(o,0,i);const f=nt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} STATUS`)}data(t,e,n){if(!this.server)throw new Error("Server-only method called in client mode");const s=Buffer.isBuffer(e);if(!s&&typeof e!="string")throw new Error("data is not a Buffer or string");let i;!s&&!n&&(n=void 0,i=!0);const o=s?e.length:Buffer.byteLength(e,n);let f=9;const c=Buffer.allocUnsafe(4+1+4+4+o);G(c,c.length-4,0),c[4]=$t.DATA,G(c,t,5),G(c,o,f),o&&(s?c.set(e,f+=4):i?c.utf8Write(e,f+=4,o):c.write(e,f+=4,o,n));const h=nt(this,c);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} DATA`)}name(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Array.isArray(e)){if(typeof e!="object"||e===null)throw new Error("names is not an object or array");e=[e]}const n=e.length;let s=0,i;const o=[];for(let g=0;g<n;++g){const u=e[g],d=!u||!u.filename||typeof u.filename!="string"?"":u.filename;s+=4+Buffer.byteLength(d);const A=!u||!u.longname||typeof u.longname!="string"?"":u.longname;if(s+=4+Buffer.byteLength(A),typeof u.attrs=="object"&&u.attrs!==null){if(i=Nn(u.attrs),s+=4+i.nb,i.nb){let I;i.nb===Oe.length?I=new Uint8Array(Oe):(I=new Uint8Array(i.nb),In(Oe,I,0,i.nb,0)),i.bytes=I}o.push(i)}else s+=4,o.push(null)}let f=9;const c=Buffer.allocUnsafe(4+1+4+4+s);G(c,c.length-4,0),c[4]=$t.NAME,G(c,t,5),G(c,n,f),f+=4;for(let g=0;g<n;++g){const u=e[g];{const A=!u||!u.filename||typeof u.filename!="string"?"":u.filename,I=Buffer.byteLength(A);G(c,I,f),f+=4,I&&(c.utf8Write(A,f,I),f+=I)}{const A=!u||!u.longname||typeof u.longname!="string"?"":u.longname,I=Buffer.byteLength(A);G(c,I,f),f+=4,I&&(c.utf8Write(A,f,I),f+=I)}const d=o[g];d?(G(c,d.flags,f),f+=4,d.flags&&d.bytes&&(c.set(d.bytes,f),f+=d.nb)):(G(c,0,f),f+=4)}const h=nt(this,c);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} NAME`)}attrs(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(typeof e!="object"||e===null)throw new Error("attrs is not an object");e=Nn(e);const n=e.flags,s=e.nb;let i=9;const o=Buffer.allocUnsafe(4+1+4+4+s);G(o,o.length-4,0),o[4]=$t.ATTRS,G(o,t,5),G(o,n,i),s&&(i+=4,s===Oe.length?o.set(Oe,i):In(Oe,o,0,s,i),i+=s);const f=nt(this,o);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} ATTRS`)}};function Ra(r){try{return Buffer.allocUnsafe(r)}catch(t){return t}}function Qs(r,t,e,n,s,i,o,f){const c=r._maxReadLen,h=Math.max(s-c,0);h&&(s=c);const g=t.length;let u=9,d=i;const A=Buffer.allocUnsafe(4+1+4+4+g+8+4);G(A,A.length-4,0),A[4]=Ue.READ;const I=r._writeReqid=r._writeReqid+1&lt;G(A,I,5),G(A,g,u),A.set(t,u+=4),u+=g;for(let R=7;R>=0;--R)A[u+R]=d&255,d/=256;G(A,s,u+=8),typeof o!="function"&&(o=Hs);const y=f||{nb:0,position:i,off:n,origOff:n,len:void 0,overflow:void 0,cb:(R,M,ce)=>{const q=y.len,le=y.overflow;if(R){if(o._wantEOFError||R.code!==it.EOF)return o(R)}else{if(ce>q)return o(new Error("Received more data than requested"));if(ce===q&&le){y.nb+=ce,y.position+=ce,y.off+=ce,Qs(r,t,e,y.off,le,y.position,o,y);return}}ce=ce||0,y.origOff===0&&e.length===y.nb?M=e:M=Hn(e,y.origOff,y.origOff+y.nb+ce),o(void 0,y.nb+ce,M,y.position)},buffer:void 0};y.len=s,y.overflow=h,y.buffer=Hn(e,n,n+s),r._requests[I]=y;const w=nt(r,A);r._debug&&r._debug(`SFTP: Outbound: ${w?"Buffered":"Sending"} READ`)}function Fs(r,t,e,n,s,i){let o=64,f=32768,c,h,g;typeof s=="function"?i=s:typeof s=="object"&&s!==null&&(typeof s.concurrency=="number"&&s.concurrency>0&&!isNaN(s.concurrency)&&(o=s.concurrency),typeof s.chunkSize=="number"&&s.chunkSize>0&&!isNaN(s.chunkSize)&&(f=s.chunkSize),typeof s.fileSize=="number"&&s.fileSize>0&&!isNaN(s.fileSize)&&(g=s.fileSize),typeof s.step=="function"&&(c=s.step),(typeof s.mode=="string"||typeof s.mode=="number")&&(h=xi(s.mode)));let u,d=0,A=0,I=!1,y,w,R,M=f*o;function ce(q){if(I)return;I=!0;let le=0,se;y||w?(se=()=>{--le===0&&i(q)},y&&(r===bn||r.outgoing.state==="open")&&++le,w&&(t===bn||t.outgoing.state==="open")&&++le,y&&(r===bn||r.outgoing.state==="open")&&r.close(y,se),w&&(t===bn||t.outgoing.state==="open")&&t.close(w,se)):i(q)}r.open(e,"r",(q,le)=>{if(q)return ce(q);y=le,g===void 0?r.fstat(y,se):se(null,{size:g});function se(fe,k){if(fe){if(r!==bn){r.stat(e,(v,T)=>{if(v)return ce(fe);se(null,T)});return}return ce(fe)}u=k.size,t.open(n,"w",(v,T)=>{if(v)return ce(v);if(w=T,u<=0)return ce();for(;M>u;){if(o===1){M=u;break}M-=f,--o}if(R=Ra(M),R instanceof Error)return ce(R);h!==void 0?t.fchmod(w,h,function Ae(oe){if(oe){t.chmod(n,h,ge=>Ae());return}ae()}):ae();function J(Ae,oe,ge,Q,j,Y){if(Ae)return ce(Ae);j=j||0,t.write(w,R,j,oe,Q,re);function re(we){if(we)return ce(we);if(A+=oe,c&&c(A,oe,u),oe<Y)return he(j,Q+oe,Y-oe);if(A===u){t.close(w,ve=>{if(w=void 0,ve)return ce(ve);r.close(y,Ne=>{if(y=void 0,Ne)return ce(Ne);i()})});return}if(d>=u)return;const me=d+f>u?u-d:f;he(j,d,me),d+=me}}function X(Ae,oe,ge){return(Q,j,Y)=>{J(Q,j,Y,oe,Ae,ge)}}function he(Ae,oe,ge){r.read(y,R,Ae,ge,oe,X(Ae,oe,ge))}function ae(){let Ae=0,oe=0;for(;d<u&&Ae<o;){const ge=d+f>u?u-d:f;he(oe,d,ge),oe+=ge,d+=ge,++Ae}}})}})}function Ii(r,t,e,n,s,i,o){const f=typeof o=="function"?o:void 0;r.write(t,e,n,s,i,(c,h)=>{if(c)return r.close(t,()=>{f&&f(c)});h===s?r.close(t,f):(n+=h,s-=h,i+=h,Ii(r,t,e,n,s,i,f))})}class Ms{constructor(t){this.mode=t&&t.mode,this.uid=t&&t.uid,this.gid=t&&t.gid,this.size=t&&t.size,this.atime=t&&t.atime,this.mtime=t&&t.mtime,this.extended=t&&t.extended}isDirectory(){return(this.mode&Wt.S_IFMT)===Wt.S_IFDIR}isFile(){return(this.mode&Wt.S_IFMT)===Wt.S_IFREG}isBlockDevice(){return(this.mode&Wt.S_IFMT)===Wt.S_IFBLK}isCharacterDevice(){return(this.mode&Wt.S_IFMT)===Wt.S_IFCHR}isSymbolicLink(){return(this.mode&Wt.S_IFMT)===Wt.S_IFLNK}isFIFO(){return(this.mode&Wt.S_IFMT)===Wt.S_IFIFO}isSocket(){return(this.mode&Wt.S_IFMT)===Wt.S_IFSOCK}}function Nn(r){let t=0,e=0;if(typeof r=="object"&&r!==null){if(typeof r.size=="number"){t|=un.SIZE;const n=r.size;Oe[e++]=n/72057594037927940,Oe[e++]=n/281474976710656,Oe[e++]=n/1099511627776,Oe[e++]=n/4294967296,Oe[e++]=n/16777216,Oe[e++]=n/65536,Oe[e++]=n/256,Oe[e++]=n}if(typeof r.uid=="number"&&typeof r.gid=="number"){t|=un.UIDGID;const n=r.uid,s=r.gid;Oe[e++]=n>>>24,Oe[e++]=n>>>16,Oe[e++]=n>>>8,Oe[e++]=n,Oe[e++]=s>>>24,Oe[e++]=s>>>16,Oe[e++]=s>>>8,Oe[e++]=s}if(typeof r.mode=="number"||typeof r.mode=="string"){const n=xi(r.mode);t|=un.PERMISSIONS,Oe[e++]=n>>>24,Oe[e++]=n>>>16,Oe[e++]=n>>>8,Oe[e++]=n}if((typeof r.atime=="number"||pi(r.atime))&&(typeof r.mtime=="number"||pi(r.mtime))){const n=Qn(r.atime),s=Qn(r.mtime);t|=un.ACMODTIME,Oe[e++]=n>>>24,Oe[e++]=n>>>16,Oe[e++]=n>>>8,Oe[e++]=n,Oe[e++]=s>>>24,Oe[e++]=s>>>16,Oe[e++]=s>>>8,Oe[e++]=s}}return{flags:t,nb:e}}function Qn(r){if(typeof r=="number"&&r===r)return r;if(pi(r))return parseInt(r.getTime()/1e3,10);throw new Error(`Cannot parse time: ${r}`)}function xi(r){if(typeof r=="number"&&r===r)return r;if(typeof r=="string")return xi(parseInt(r,8));throw new Error(`Cannot parse mode: ${r}`)}const yi={r:Re.READ,"r+":Re.READ|Re.WRITE,w:Re.TRUNC|Re.CREAT|Re.WRITE,wx:Re.TRUNC|Re.CREAT|Re.WRITE|Re.EXCL,xw:Re.TRUNC|Re.CREAT|Re.WRITE|Re.EXCL,"w+":Re.TRUNC|Re.CREAT|Re.READ|Re.WRITE,"wx+":Re.TRUNC|Re.CREAT|Re.READ|Re.WRITE|Re.EXCL,"xw+":Re.TRUNC|Re.CREAT|Re.READ|Re.WRITE|Re.EXCL,a:Re.APPEND|Re.CREAT|Re.WRITE,ax:Re.APPEND|Re.CREAT|Re.WRITE|Re.EXCL,xa:Re.APPEND|Re.CREAT|Re.WRITE|Re.EXCL,"a+":Re.APPEND|Re.CREAT|Re.READ|Re.WRITE,"ax+":Re.APPEND|Re.CREAT|Re.READ|Re.WRITE|Re.EXCL,"xa+":Re.APPEND|Re.CREAT|Re.READ|Re.WRITE|Re.EXCL};function Ks(r){const t=yi[r];return t!==void 0?t:null}const Na=(()=>{const r=Object.keys(yi);return t=>{for(let e=0;e<r.length;++e){const n=r[e];if(yi[n]===t)return n}return null}})();function Fn(r){const t=D.readUInt32BE();if(t===void 0)return;const e=new Ms;if(t&un.SIZE){const n=D.readUInt64BE(r);if(n===void 0)return;e.size=n}if(t&un.UIDGID){const n=D.readUInt32BE(),s=D.readUInt32BE();if(s===void 0)return;e.uid=n,e.gid=s}if(t&un.PERMISSIONS){const n=D.readUInt32BE();if(n===void 0)return;e.mode=n}if(t&un.ACMODTIME){const n=D.readUInt32BE(),s=D.readUInt32BE();if(s===void 0)return;e.atime=n,e.mtime=s}if(t&un.EXTENDED){const n=D.readUInt32BE();if(n===void 0)return;const s={};for(let i=0;i<n;++i){const o=D.readString(!0),f=D.readString();if(f===void 0)return;s[o]=f}e.extended=s}return e}function nt(r,t){const e=Ws(r,t);return e!==void 0?(r._buffer.push(e),!1):!0}function Ws(r,t){const e=r.outgoing;if(e.state!=="open")return;if(e.window===0)return r._waitWindow=!0,r._chunkcb=$s,t;let n;const s=t.length;let i=0;for(;s-i>0&&e.window>0;){const o=Math.min(s-i,e.window,e.packetSize);e.window-=o,e.window===0&&(r._waitWindow=!0,r._chunkcb=$s),i===0&&o===s?r._protocol.channelData(r.outgoing.id,t):r._protocol.channelData(r.outgoing.id,Hn(t,i,i+o)),i+=o}return s-i>0&&(i>0?n=Hn(t,i,s):n=t),n}function $s(){this._chunkcb=void 0;const r=this._buffer;let t=0;for(;t<r.length;){const e=r[t],n=Ws(this,e);if(n!==void 0){n!==e&&(r[t]=n),t>0&&(this._buffer=r.slice(t));return}++t}t>0&&(this._buffer=[])}function ft(r,t,e){const n=new Error(t);return n.level="sftp-protocol",!e&&r._debug&&r._debug(`SFTP: Inbound: ${t}`),r.emit("error",n),r.destroy(),qs(r),!1}function qs(r){const t=Object.keys(r._requests);if(t.length===0)return;const e=r._requests;r._requests={};const n=new Error("No response from server");for(let s=0;s<t.length;++s){const i=e[t[s]];typeof i.cb=="function"&&i.cb(n)}}function va(r,t){let e=9;const n=Buffer.allocUnsafe(4+1+4+4+18);G(n,n.length-4,0),n[4]=Ue.EXTENDED;const s=r._writeReqid=r._writeReqid+1&lt;G(n,s,5),G(n,18,e),n.utf8Write("limits@openssh.com",e+=4,18),r._requests[s]={extended:"limits@openssh.com",cb:t};const i=nt(r,n);if(r._debug){const o=i?"Buffered":"Sending";r._debug(`SFTP: Outbound: ${o} limits@openssh.com`)}}const Ta={[$t.VERSION]:(r,t)=>{if(r._version!==-1)return ft(r,"Duplicate VERSION packet");const e={};D.init(t,1);let n=D.readUInt32BE();for(;D.avail();){const s=D.readString(!0),i=D.readString(!0);if(i===void 0){n=void 0;break}e[s]=i}if(D.clear(),n===void 0)return ft(r,"Malformed VERSION packet");if(r._debug){const s=Object.keys(e);s.length?r._debug(`SFTP: Inbound: Received VERSION (v${n}, exts:${s})`):r._debug(`SFTP: Inbound: Received VERSION (v${n})`)}if(r._version=n,r._extensions=e,e["limits@openssh.com"]==="1")return va(r,(s,i)=>{s||(i.maxPktLen>0&&(r._maxOutPktLen=i.maxPktLen),i.maxReadLen>0&&(r._maxReadLen=i.maxReadLen),i.maxWriteLen>0&&(r._maxWriteLen=i.maxWriteLen),r.maxOpenHandles=i.maxOpenHandles>0?i.maxOpenHandles:1/0),r.emit("ready")});r.emit("ready")},[$t.STATUS]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readUInt32BE(),s=D.readString(!0);if(D.clear(),r._debug){const o=JSON.stringify(s);r._debug(`SFTP: Inbound: Received STATUS (id:${e}, ${n}, ${o})`)}const i=r._requests[e];if(delete r._requests[e],i&&typeof i.cb=="function"){if(n===it.OK){i.cb();return}const o=new Error(s||Sa[n]||"Unknown status");o.code=n,i.cb(o)}},[$t.HANDLE]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString();if(D.clear(),n===void 0)return e!==void 0&&delete r._requests[e],ft(r,"Malformed HANDLE packet");r._debug&&r._debug(`SFTP: Inbound: Received HANDLE (id:${e})`);const s=r._requests[e];delete r._requests[e],s&&typeof s.cb=="function"&&s.cb(void 0,n)},[$t.DATA]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE();let n;if(e!==void 0&&(n=r._requests[e],delete r._requests[e]),n&&typeof n.cb=="function")if(n.buffer){const s=D.readString(n.buffer);if(D.clear(),s!==void 0){r._debug&&r._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`),n.cb(void 0,n.buffer,s);return}}else{const s=D.readString();if(D.clear(),s!==void 0){r._debug&&r._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s.length})`),n.cb(void 0,s);return}}else{const s=D.skipString();if(D.clear(),s!==void 0){r._debug&&r._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`);return}}return ft(r,"Malformed DATA packet")},[$t.NAME]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE();let n;e!==void 0&&(n=r._requests[e],delete r._requests[e]);const s=D.readUInt32BE();if(s!==void 0){let i=[];for(let o=0;o<s;++o){const f=D.readString(!0),c=D.readString(!0),h=Fn(r._biOpt);if(h===void 0){i=void 0;break}i.push({filename:f,longname:c,attrs:h})}if(i!==void 0){r._debug&&r._debug(`SFTP: Inbound: Received NAME (id:${e}, ${i.length})`),D.clear(),n&&typeof n.cb=="function"&&n.cb(void 0,i);return}}return D.clear(),ft(r,"Malformed NAME packet")},[$t.ATTRS]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE();let n;e!==void 0&&(n=r._requests[e],delete r._requests[e]);const s=Fn(r._biOpt);if(D.clear(),s!==void 0){r._debug&&r._debug(`SFTP: Inbound: Received ATTRS (id:${e})`),n&&typeof n.cb=="function"&&n.cb(void 0,s);return}return ft(r,"Malformed ATTRS packet")},[$t.EXTENDED]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE();if(e!==void 0){const n=r._requests[e];if(n)switch(delete r._requests[e],n.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{const s=r._biOpt,i={f_bsize:D.readUInt64BE(s),f_frsize:D.readUInt64BE(s),f_blocks:D.readUInt64BE(s),f_bfree:D.readUInt64BE(s),f_bavail:D.readUInt64BE(s),f_files:D.readUInt64BE(s),f_ffree:D.readUInt64BE(s),f_favail:D.readUInt64BE(s),f_sid:D.readUInt64BE(s),f_flag:D.readUInt64BE(s),f_namemax:D.readUInt64BE(s)};if(i.f_namemax===void 0)break;r._debug&&r._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${n.extended})`),D.clear(),typeof n.cb=="function"&&n.cb(void 0,i);return}case"limits@openssh.com":{const s={maxPktLen:D.readUInt64BE(),maxReadLen:D.readUInt64BE(),maxWriteLen:D.readUInt64BE(),maxOpenHandles:D.readUInt64BE()};if(s.maxOpenHandles===void 0)break;r._debug&&r._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${n.extended})`),D.clear(),typeof n.cb=="function"&&n.cb(void 0,s);return}case"users-groups-by-id@openssh.com":{const s=D.readUInt32BE();if(s===void 0)break;const i=new Array(s);for(let c=0;c<i.length;++c)i[c]=D.readString(!0);const o=D.readUInt32BE();if(o===void 0)break;const f=new Array(o);for(let c=0;c<f.length;++c)f[c]=D.readString(!0);if(f.length>0&&f[f.length-1]===void 0)break;r._debug&&r._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${n.extended})`),D.clear(),typeof n.cb=="function"&&n.cb(void 0,i,f);return}default:r._debug&&r._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),D.clear(),typeof n.cb=="function"&&n.cb();return}else{r._debug&&r._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),D.clear();return}}return D.clear(),ft(r,"Malformed EXTENDED_REPLY packet")}},La={[Ue.INIT]:(r,t)=>{if(r._version!==-1)return ft(r,"Duplicate INIT packet");const e={};D.init(t,1);let n=D.readUInt32BE();for(;D.avail();){const s=D.readString(!0),i=D.readString(!0);if(i===void 0){n=void 0;break}e[s]=i}if(D.clear(),n===void 0)return ft(r,"Malformed INIT packet");if(r._debug){const s=Object.keys(e);s.length?r._debug(`SFTP: Inbound: Received INIT (v${n}, exts:${s})`):r._debug(`SFTP: Inbound: Received INIT (v${n})`)}nt(r,ma),r._version=n,r._extensions=e,r.emit("ready")},[Ue.OPEN]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0),s=D.readUInt32BE(),i=Fn(r._biOpt);if(D.clear(),i===void 0)return ft(r,"Malformed OPEN packet");r._debug&&r._debug(`SFTP: Inbound: Received OPEN (id:${e})`),r.emit("OPEN",e,n,s,i)||r.status(e,it.OP_UNSUPPORTED)},[Ue.CLOSE]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString();if(D.clear(),n===void 0||n.length>256)return ft(r,"Malformed CLOSE packet");r._debug&&r._debug(`SFTP: Inbound: Received CLOSE (id:${e})`),r.emit("CLOSE",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.READ]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(),s=D.readUInt64BE(r._biOpt),i=D.readUInt32BE();if(D.clear(),i===void 0||n.length>256)return ft(r,"Malformed READ packet");r._debug&&r._debug(`SFTP: Inbound: Received READ (id:${e})`),r.emit("READ",e,n,s,i)||r.status(e,it.OP_UNSUPPORTED)},[Ue.WRITE]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(),s=D.readUInt64BE(r._biOpt),i=D.readString();if(D.clear(),i===void 0||n.length>256)return ft(r,"Malformed WRITE packet");r._debug&&r._debug(`SFTP: Inbound: Received WRITE (id:${e})`),r.emit("WRITE",e,n,s,i)||r.status(e,it.OP_UNSUPPORTED)},[Ue.LSTAT]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0);if(D.clear(),n===void 0)return ft(r,"Malformed LSTAT packet");r._debug&&r._debug(`SFTP: Inbound: Received LSTAT (id:${e})`),r.emit("LSTAT",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.FSTAT]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString();if(D.clear(),n===void 0||n.length>256)return ft(r,"Malformed FSTAT packet");r._debug&&r._debug(`SFTP: Inbound: Received FSTAT (id:${e})`),r.emit("FSTAT",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.SETSTAT]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0),s=Fn(r._biOpt);if(D.clear(),s===void 0)return ft(r,"Malformed SETSTAT packet");r._debug&&r._debug(`SFTP: Inbound: Received SETSTAT (id:${e})`),r.emit("SETSTAT",e,n,s)||r.status(e,it.OP_UNSUPPORTED)},[Ue.FSETSTAT]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(),s=Fn(r._biOpt);if(D.clear(),s===void 0||n.length>256)return ft(r,"Malformed FSETSTAT packet");r._debug&&r._debug(`SFTP: Inbound: Received FSETSTAT (id:${e})`),r.emit("FSETSTAT",e,n,s)||r.status(e,it.OP_UNSUPPORTED)},[Ue.OPENDIR]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0);if(D.clear(),n===void 0)return ft(r,"Malformed OPENDIR packet");r._debug&&r._debug(`SFTP: Inbound: Received OPENDIR (id:${e})`),r.emit("OPENDIR",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.READDIR]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString();if(D.clear(),n===void 0||n.length>256)return ft(r,"Malformed READDIR packet");r._debug&&r._debug(`SFTP: Inbound: Received READDIR (id:${e})`),r.emit("READDIR",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.REMOVE]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0);if(D.clear(),n===void 0)return ft(r,"Malformed REMOVE packet");r._debug&&r._debug(`SFTP: Inbound: Received REMOVE (id:${e})`),r.emit("REMOVE",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.MKDIR]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0),s=Fn(r._biOpt);if(D.clear(),s===void 0)return ft(r,"Malformed MKDIR packet");r._debug&&r._debug(`SFTP: Inbound: Received MKDIR (id:${e})`),r.emit("MKDIR",e,n,s)||r.status(e,it.OP_UNSUPPORTED)},[Ue.RMDIR]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0);if(D.clear(),n===void 0)return ft(r,"Malformed RMDIR packet");r._debug&&r._debug(`SFTP: Inbound: Received RMDIR (id:${e})`),r.emit("RMDIR",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.REALPATH]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0);if(D.clear(),n===void 0)return ft(r,"Malformed REALPATH packet");r._debug&&r._debug(`SFTP: Inbound: Received REALPATH (id:${e})`),r.emit("REALPATH",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.STAT]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0);if(D.clear(),n===void 0)return ft(r,"Malformed STAT packet");r._debug&&r._debug(`SFTP: Inbound: Received STAT (id:${e})`),r.emit("STAT",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.RENAME]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0),s=D.readString(!0);if(D.clear(),s===void 0)return ft(r,"Malformed RENAME packet");r._debug&&r._debug(`SFTP: Inbound: Received RENAME (id:${e})`),r.emit("RENAME",e,n,s)||r.status(e,it.OP_UNSUPPORTED)},[Ue.READLINK]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0);if(D.clear(),n===void 0)return ft(r,"Malformed READLINK packet");r._debug&&r._debug(`SFTP: Inbound: Received READLINK (id:${e})`),r.emit("READLINK",e,n)||r.status(e,it.OP_UNSUPPORTED)},[Ue.SYMLINK]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0),s=D.readString(!0);if(D.clear(),s===void 0)return ft(r,"Malformed SYMLINK packet");r._debug&&r._debug(`SFTP: Inbound: Received SYMLINK (id:${e})`);let i;r._isOpenSSH?i=r.emit("SYMLINK",e,s,n):i=r.emit("SYMLINK",e,n,s),i||r.status(e,it.OP_UNSUPPORTED)},[Ue.EXTENDED]:(r,t)=>{D.init(t,1);const e=D.readUInt32BE(),n=D.readString(!0);if(n===void 0)return D.clear(),ft(r,"Malformed EXTENDED packet");let s;D.avail()&&(s=D.readRaw()),D.clear(),r._debug&&r._debug(`SFTP: Inbound: Received EXTENDED (id:${e})`),r.emit("EXTENDED",e,n,s)||r.status(e,it.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:Ua,ERR_OUT_OF_RANGE:Tr,validateNumber:Pa}=or,Gs=128;let Ft;const Si=[];function Oa(r){Si.length>0?Ft=Si.pop():Ft=Buffer.allocUnsafe(r),Ft.used=0}function wi(r,t){if(!Number.isSafeInteger(r))throw Pa(r,t),Number.isInteger(r)?new Tr(t,">= 0 and <= 2 ** 53 - 1",r):new Tr(t,"an integer",r);if(r<0)throw new Tr(t,">= 0 and <= 2 ** 53 - 1",r)}function mi(r){return r+7&-8}function ln(r,t,e){if(e===void 0)e={};else if(typeof e=="string")e={encoding:e};else{if(e===null||typeof e!="object")throw new TypeError('"options" argument must be a string or an object');e=Object.create(e)}if(e.highWaterMark===void 0&&(e.highWaterMark=64*1024),e.emitClose=!1,e.autoDestroy=!1,Ps.call(this,e),this.path=t,this.flags=e.flags===void 0?"r":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.end=e.end,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesRead=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=r,this._opening=!1,this.start!==void 0&&(wi(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(wi(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new Tr("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}Os(ln,Ps),ln.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(r,t)=>{if(this._opening=!1,r){this.emit("error",r),this.autoClose&&this.destroy();return}this.handle=t,this.emit("open",t),this.emit("ready"),this.read()}))},ln.prototype._read=function(r){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(r));if(this.destroyed)return;(!Ft||Ft.length-Ft.used<Gs)&&Oa(this.readableHighWaterMark||this._readableState.highWaterMark);const t=Ft;let e=Math.min(Ft.length-Ft.used,r);const n=Ft.used;if(this.end!==void 0&&(e=Math.min(this.end-this.pos+1,e)),e<=0)return this.push(null);this.sftp.read(this.handle,Ft,Ft.used,e,this.pos,(s,i)=>{if(s){this.emit("error",s),this.autoClose&&this.destroy();return}let o=null;if(n+e===t.used&&t===Ft)t.used=mi(t.used+i-e);else{const f=n+e&-8,c=mi(n+i);f-c>=Gs&&Si.push(t.slice(c,f))}i>0&&(this.bytesRead+=i,o=t.slice(n,n+i)),this.pos+=i,this.push(o)}),Ft.used=mi(Ft.used+e)},ln.prototype._destroy=function(r,t){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",Ys.bind(null,this,t,r));return}Ys(this,t,r),this.handle=null,this._opening=!1};function Ys(r,t,e){if(!r.handle)return n();r.sftp.close(r.handle,n);function n(s){s=s||e,t(s),r.isClosed=!0,s||r.emit("close")}}ln.prototype.close=function(r){this.destroy(null,r)},Object.defineProperty(ln.prototype,"pending",{get(){return this.handle===null},configurable:!0});function Vt(r,t,e){if(e===void 0)e={};else if(typeof e=="string")e={encoding:e};else{if(e===null||typeof e!="object")throw new TypeError('"options" argument must be a string or an object');e=Object.create(e)}e.emitClose=!1,e.autoDestroy=!1,Ei.call(this,e),this.path=t,this.flags=e.flags===void 0?"w":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesWritten=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=r,this._opening=!1,this.start!==void 0&&(wi(this.start,"start"),this.pos=this.start),e.encoding&&this.setDefaultEncoding(e.encoding),this.on("finish",function(){this._writableState.finalCalled||this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}Os(Vt,Ei),Vt.prototype._final=function(r){this.autoClose&&this.destroy(),r()},Vt.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(r,t)=>{if(this._opening=!1,r){this.emit("error",r),this.autoClose&&this.destroy();return}this.handle=t;const e=n=>{if(n){this.sftp.chmod(this.path,this.mode,s=>e());return}if(this.flags[0]==="a"){const s=(i,o)=>{if(i){this.sftp.stat(this.path,(f,c)=>{if(f){this.destroy(),this.emit("error",i);return}s(null,c)});return}this.pos=o.size,this.emit("open",t),this.emit("ready")};this.sftp.fstat(t,s);return}this.emit("open",t),this.emit("ready")};this.sftp.fchmod(t,this.mode,e)}))},Vt.prototype._write=function(r,t,e){if(!Buffer.isBuffer(r)){const n=new Ua("data","Buffer",r);return this.emit("error",n)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(r,t,e)});this.sftp.write(this.handle,r,0,r.length,this.pos,(n,s)=>{if(n)return this.autoClose&&this.destroy(),e(n);this.bytesWritten+=s,e()}),this.pos+=r.length},Vt.prototype._writev=function(r,t){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(r,t)});const e=this.sftp,n=this.handle;let s=r.length;const i=(o,f)=>{if(o)return this.destroy(),t(o);this.bytesWritten+=f,--s===0&&t()};for(let o=0;o<r.length;++o){const f=r[o].chunk;e.write(n,f,0,f.length,this.pos,i),this.pos+=f.length}},typeof Ei.prototype.destroy!="function"&&(Vt.prototype.destroy=ln.prototype.destroy),Vt.prototype._destroy=ln.prototype._destroy,Vt.prototype.close=function(r){if(r){if(this.isClosed){process.nextTick(r);return}this.on("close",r)}this.autoClose||this.on("finish",this.destroy.bind(this)),this.end()},Vt.prototype.destroySoon=Vt.prototype.end,Object.defineProperty(Vt.prototype,"pending",{get(){return this.handle===null},configurable:!0});var Lr={flagsToString:Na,OPEN_MODE:Re,SFTP:ka,Stats:Ms,STATUS_CODE:it,stringToFlags:Ks};const{Duplex:Da,Readable:Ha,Writable:Qa}=tt,{CHANNEL_EXTENDED_DATATYPE:{STDERR:Xs}}=En(),{bufferSlice:Ur}=nn(),Fa=32*1024,fr=2*1024*1024,Ci=fr/2;class Ma extends Ha{constructor(t,e){super(e),this._channel=t}_read(t){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=Ci&&Bi(this._channel))}}class Ka extends Qa{constructor(t){super({highWaterMark:fr}),this._channel=t}_write(t,e,n){const s=this._channel,i=s._client._protocol,o=s.outgoing,f=o.packetSize,c=o.id;let h=o.window;const g=t.length;let u=0;if(o.state==="open"){for(;g-u>0&&h>0;){let d=g-u;d>h&&(d=h),d>f&&(d=f),u===0&&d===g?i.channelExtData(c,t,Xs):i.channelExtData(c,Ur(t,u,u+d),Xs),u+=d,h-=d}if(o.window=h,g-u>0){h===0&&(s._waitWindow=!0),u>0?s._chunkErr=Ur(t,u,g):s._chunkErr=t,s._chunkcbErr=n;return}n()}}}let Wa=class extends Da{constructor(t,e,n){const s={highWaterMark:fr,allowHalfOpen:!n||n&&n.allowHalfOpen!==!1,emitClose:!1};super(s),this.allowHalfOpen=s.allowHalfOpen;const i=!!(n&&n.server);this.server=i,this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this._callbacks=[],this._client=t,this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this.stdin=this.stdout=this,i?this.stderr=new Ka(this):this.stderr=new Ma(this,s),this._waitWindow=!1,this._waitChanDrain=!1,this._chunk=void 0,this._chunkcb=void 0,this._chunkErr=void 0,this._chunkcbErr=void 0,this.on("finish",js).on("prefinish",js),this.on("end",Vs).on("close",Vs)}_read(t){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=Ci&&Bi(this))}_write(t,e,n){const s=this._client._protocol,i=this.outgoing,o=i.packetSize,f=i.id;let c=i.window;const h=t.length;let g=0;if(i.state==="open"){for(;h-g>0&&c>0;){let u=h-g;u>c&&(u=c),u>o&&(u=o),g===0&&u===h?s.channelData(f,t):s.channelData(f,Ur(t,g,g+u)),g+=u,c-=u}if(i.window=c,h-g>0){c===0&&(this._waitWindow=!0),g>0?this._chunk=Ur(t,g,h):this._chunk=t,this._chunkcb=n;return}n()}}eof(){this.outgoing.state==="open"&&(this.outgoing.state="eof",this._client._protocol.channelEOF(this.outgoing.id))}close(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._client._protocol.channelClose(this.outgoing.id))}destroy(){return this.end(),this.close(),this}setWindow(t,e,n,s){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&(this.subtype==="shell"||this.subtype==="exec")&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.windowChange(this.outgoing.id,t,e,n,s)}signal(t){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.signal(this.outgoing.id,t)}exit(t,e,n){if(!this.server)throw new Error("Server-only method called in client mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&(typeof t=="number"?this._client._protocol.exitStatus(this.outgoing.id,t):this._client._protocol.exitSignal(this.outgoing.id,t,e,n))}};function js(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}function Vs(){this.readable=!1}function Bi(r){if(r.outgoing.state==="closed")return;const t=fr-r.incoming.window;t<=0||(r.incoming.window+=t,r._client._protocol.channelWindowAdjust(r.outgoing.id,t))}var zs={Channel:Wa,MAX_WINDOW:fr,PACKET_SIZE:Fa,windowAdjust:Bi,WINDOW_THRESHOLD:Ci};const{SFTP:$a}=Lr,ar=2**32-1;function Js(r,t,e,n){if(r._chanMgr.remove(t),typeof n!="function")return;let s;e instanceof Error?s=e:typeof e=="object"&&e!==null?(s=new Error(`(SSH) Channel open failure: ${e.description}`),s.reason=e.reason):(s=new Error("(SSH) Channel open failure: server closed channel unexpectedly"),s.reason=""),n(s)}function Zs(r,t,e,n,s){if(typeof e=="function"){Js(r,t,n,e);return}if(typeof e!="object"||e===null||e.incoming&&e.incoming.state==="closed"||(r._chanMgr.remove(t),e.server&&e.constructor.name==="Session"))return;e.incoming.state="closed",e.readable&&e.push(null),e.server?e.stderr.writable&&e.stderr.end():e.stderr.readable&&e.stderr.push(null),e.constructor!==$a&&(e.outgoing.state==="open"||e.outgoing.state==="eof")&&!s&&e.close(),e.outgoing.state==="closing"&&(e.outgoing.state="closed");const i=e._readableState,o=e._writableState;o&&!o.ending&&!o.finished&&!s&&e.end();const f=e._callbacks;e._callbacks=[];for(let c=0;c<f.length;++c)f[c](!0);if(e.server)!e.readable||e.destroyed||i&&i.endEmitted?e.emit("close"):e.once("end",()=>e.emit("close"));else{let c;switch(e.type){case"direct-streamlocal@openssh.com":case"direct-tcpip":c=()=>e.emit("close");break;default:{const g=e._exit;c=()=>{g.code===null?e.emit("close",g.code,g.signal,g.dump,g.desc):e.emit("close",g.code)}}}!e.readable||e.destroyed||i&&i.endEmitted?c():e.once("end",c);const h=e.stderr._readableState;!e.stderr.readable||e.stderr.destroyed||h&&h.endEmitted?e.stderr.emit("close"):e.stderr.once("end",()=>e.stderr.emit("close"))}}let qa=class{constructor(t){this._client=t,this._channels={},this._cur=-1,this._count=0}add(t){let e;if(this._cur<ar)e=++this._cur;else if(this._count===0)this._cur=0,e=0;else{const n=this._channels;for(let s=0;s<ar;++s)if(n[s]===void 0){e=s;break}}return e===void 0?-1:(this._channels[e]=t||!0,++this._count,e)}update(t,e){if(typeof t!="number"||t<0||t>=ar||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);e&&this._channels[t]&&(this._channels[t]=e)}get(t){if(typeof t!="number"||t<0||t>=ar||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);return this._channels[t]}remove(t){if(typeof t!="number"||t<0||t>=ar||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);this._channels[t]&&(delete this._channels[t],this._count&&--this._count)}cleanup(t){const e=this._channels;this._channels={},this._cur=-1,this._count=0;const n=Object.keys(e),s=this._client;for(let i=0;i<n.length;++i){const o=+n[i],f=e[o];Zs(s,o,f._channel||f,t,!0)}}};const ki=(()=>{const r=Object.prototype.toString;return t=>r.call(t)==="[object RegExp]"})();function Ga(r,t,e){if(Array.isArray(r)&&r.length>0){for(let n=0;n<r.length;++n)if(e.indexOf(r[n])===-1)throw new Error(`Unsupported algorithm: ${r[n]}`);return r}if(typeof r=="object"&&r!==null){const n=Object.keys(r);let s=t;for(let i=0;i<n.length;++i){const o=n[i];let f=r[o];switch(o){case"append":if(Array.isArray(f)||(f=[f]),Array.isArray(f))for(let c=0;c<f.length;++c){const h=f[c];if(typeof h=="string"){if(!h||s.indexOf(h)!==-1)continue;if(e.indexOf(h)===-1)throw new Error(`Unsupported algorithm: ${h}`);s===t&&(s=s.slice()),s.push(h)}else if(ki(h))for(let g=0;g<e.length;++g){const u=e[g];if(h.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.push(u)}}}break;case"prepend":if(Array.isArray(f)||(f=[f]),Array.isArray(f))for(let c=f.length;c>=0;--c){const h=f[c];if(typeof h=="string"){if(!h||s.indexOf(h)!==-1)continue;if(e.indexOf(h)===-1)throw new Error(`Unsupported algorithm: ${h}`);s===t&&(s=s.slice()),s.unshift(h)}else if(ki(h))for(let g=e.length;g>=0;--g){const u=e[g];if(h.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.unshift(u)}}}break;case"remove":if(Array.isArray(f)||(f=[f]),Array.isArray(f))for(let c=0;c<f.length;++c){const h=f[c];if(typeof h=="string"){if(!h)continue;const g=s.indexOf(h);if(g===-1)continue;s===t&&(s=s.slice()),s.splice(g,1)}else if(ki(h))for(let g=0;g<s.length;++g)h.test(s[g])&&(s===t&&(s=s.slice()),s.splice(g,1),--g)}break}}return s}return t}var eo={ChannelManager:qa,generateAlgorithmList:Ga,onChannelOpenFailure:Js,onCHANNEL_CLOSE:Zs,isWritable:r=>r&&r.writable&&r._readableState&&r._readableState.ended===!1};const{createHash:Ya,getHashes:Xa,randomFillSync:ja}=tt,{Socket:Va}=tt,{lookup:za}=tt,Ja=tt,Za=Xa(),{COMPAT:to,CHANNEL_EXTENDED_DATATYPE:{STDERR:ec},CHANNEL_OPEN_FAILURE:cr,DEFAULT_CIPHER:no,DEFAULT_COMPRESSION:ro,DEFAULT_KEX:io,DEFAULT_MAC:so,DEFAULT_SERVER_HOST_KEY:oo,DISCONNECT_REASON:fo,DISCONNECT_REASON_BY_VALUE:tc,SUPPORTED_CIPHER:nc,SUPPORTED_COMPRESSION:rc,SUPPORTED_KEX:ic,SUPPORTED_MAC:sc,SUPPORTED_SERVER_HOST_KEY:oc}=En(),{init:fc}=Bn(),ac=Ns,{parseKey:Pr}=Rn,{SFTP:cc}=Lr,{bufferCopy:ao,makeBufferParser:co,makeError:hc,readUInt32BE:uc,sigSSHToASN1:lc,writeUInt32BE:Ri}=nn(),{AgentContext:ho,createAgent:uo,isAgent:lo}=cs,{Channel:Ao,MAX_WINDOW:Or,PACKET_SIZE:Dr,windowAdjust:go,WINDOW_THRESHOLD:_o}=zs,{ChannelManager:dc,generateAlgorithmList:hr,isWritable:Bt,onChannelOpenFailure:Ac,onCHANNEL_CLOSE:gc}=eo,Hr=co(),Qr=co(),ur=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,Ni=r=>{};let _c=class extends Ja{constructor(){super(),this.config={host:void 0,port:void 0,localAddress:void 0,localPort:void 0,forceIPv4:void 0,forceIPv6:void 0,keepaliveCountMax:void 0,keepaliveInterval:void 0,readyTimeout:void 0,ident:void 0,username:void 0,password:void 0,privateKey:void 0,tryKeyboard:void 0,agent:void 0,allowAgentFwd:void 0,authHandler:void 0,hostHashAlgo:void 0,hostHashCb:void 0,strictVendor:void 0,debug:void 0},this._agent=void 0,this._readyTimeout=void 0,this._chanMgr=void 0,this._callbacks=void 0,this._forwarding=void 0,this._forwardingUnix=void 0,this._acceptX11=void 0,this._agentFwdEnabled=void 0,this._remoteVer=void 0,this._protocol=void 0,this._sock=void 0,this._resetKA=void 0}connect(t){if(this._sock&&Bt(this._sock))return this.once("close",()=>{this.connect(t)}),this.end(),this;this.config.host=t.hostname||t.host||"localhost",this.config.port=t.port||22,this.config.localAddress=typeof t.localAddress=="string"?t.localAddress:void 0,this.config.localPort=typeof t.localPort=="string"||typeof t.localPort=="number"?t.localPort:void 0,this.config.forceIPv4=t.forceIPv4||!1,this.config.forceIPv6=t.forceIPv6||!1,this.config.keepaliveCountMax=typeof t.keepaliveCountMax=="number"&&t.keepaliveCountMax>=0?t.keepaliveCountMax:3,this.config.keepaliveInterval=typeof t.keepaliveInterval=="number"&&t.keepaliveInterval>0?t.keepaliveInterval:0,this.config.readyTimeout=typeof t.readyTimeout=="number"&&t.readyTimeout>=0?t.readyTimeout:2e4,this.config.ident=typeof t.ident=="string"||Buffer.isBuffer(t.ident)?t.ident:void 0;const e={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:[]},sc:void 0};let n=!0;if(typeof t.algorithms=="object"&&t.algorithms!==null&&(e.kex=hr(t.algorithms.kex,io,ic),e.kex!==io&&(n=!1),e.serverHostKey=hr(t.algorithms.serverHostKey,oo,oc),e.serverHostKey!==oo&&(n=!1),e.cs.cipher=hr(t.algorithms.cipher,no,nc),e.cs.cipher!==no&&(n=!1),e.cs.mac=hr(t.algorithms.hmac,so,sc),e.cs.mac!==so&&(n=!1),e.cs.compress=hr(t.algorithms.compress,ro,rc),e.cs.compress!==ro&&(n=!1),n||(e.sc=e.cs)),typeof t.username=="string")this.config.username=t.username;else if(typeof t.user=="string")this.config.username=t.user;else throw new Error("Invalid username");this.config.password=typeof t.password=="string"?t.password:void 0,this.config.privateKey=typeof t.privateKey=="string"||Buffer.isBuffer(t.privateKey)?t.privateKey:void 0,this.config.localHostname=typeof t.localHostname=="string"?t.localHostname:void 0,this.config.localUsername=typeof t.localUsername=="string"?t.localUsername:void 0,this.config.tryKeyboard=t.tryKeyboard===!0,typeof t.agent=="string"&&t.agent.length?this.config.agent=uo(t.agent):lo(t.agent)?this.config.agent=t.agent:this.config.agent=void 0,this.config.allowAgentFwd=t.agentForward===!0&&this.config.agent!==void 0;let s=this.config.authHandler=typeof t.authHandler=="function"||Array.isArray(t.authHandler)?t.authHandler:void 0;this.config.strictVendor=typeof t.strictVendor=="boolean"?t.strictVendor:!0;const i=this.config.debug=typeof t.debug=="function"?t.debug:void 0;if(t.agentForward===!0&&!this.config.allowAgentFwd)throw new Error("You must set a valid agent path to allow agent forwarding");let o=this._callbacks=[];this._chanMgr=new dc(this),this._forwarding={},this._forwardingUnix={},this._acceptX11=0,this._agentFwdEnabled=!1,this._agent=this.config.agent?this.config.agent:void 0,this._remoteVer=void 0;let f;if(this.config.privateKey){if(f=Pr(this.config.privateKey,t.passphrase),f instanceof Error)throw new Error(`Cannot parse privateKey: ${f.message}`);if(Array.isArray(f)&&(f=f[0]),f.getPrivatePEM()===null)throw new Error("privateKey value does not contain a (valid) private key")}let c;if(typeof t.hostVerifier=="function"){const Q=t.hostVerifier;let j;Za.indexOf(t.hostHash)!==-1&&(j=Ya(t.hostHash)),c=(Y,re)=>{j&&(j.update(Y),Y=j.digest("hex"));const we=Q(Y,re);we!==void 0&&re(we)}}const h=this._sock=t.sock||new Va;let g=!1,u=!1;this._protocol&&this._protocol.cleanup();const d=i?(Q,j,Y)=>{i(`Debug output from server: ${JSON.stringify(Y)}`)}:void 0;let A;const I=this._protocol=new ac({ident:this.config.ident,offer:n?void 0:e,onWrite:Q=>{Bt(h)&&h.write(Q)},onError:Q=>{Q.level==="handshake"&&clearTimeout(this._readyTimeout),I._destruct||h.removeAllListeners("data"),this.emit("error",Q);try{h.end()}catch{}},onHeader:Q=>{u=!0,this._remoteVer=Q.versions.software,Q.greeting&&this.emit("greeting",Q.greeting)},onHandshakeComplete:Q=>{this.emit("handshake",Q),g||(g=!0,I.service("ssh-userauth"))},debug:i,hostVerifier:c,messageHandlers:{DEBUG:d,DISCONNECT:(Q,j,Y)=>{if(j!==fo.BY_APPLICATION){Y||(Y=tc[j],Y===void 0&&(Y=`Unexpected disconnection reason: ${j}`));const re=new Error(Y);re.code=j,this.emit("error",re)}h.end()},SERVICE_ACCEPT:(Q,j)=>{j==="ssh-userauth"&&Ae()},EXT_INFO:(Q,j)=>{if(A===void 0){for(const Y of j)if(Y.name==="server-sig-algs"){A=Y.algs;return}A=null}},USERAUTH_BANNER:(Q,j)=>{this.emit("banner",j)},USERAUTH_SUCCESS:Q=>{q(),clearTimeout(this._readyTimeout),this.emit("ready")},USERAUTH_FAILURE:(Q,j,Y)=>{if(k.keyAlgos){const re=k.keyAlgos[0][0];if(i&&i(`Client: ${k.type} (${re}) auth failed`),k.keyAlgos.shift(),k.keyAlgos.length){const[we,me]=k.keyAlgos[0];switch(k.type){case"agent":I.authPK(k.username,k.agentCtx.currentKey(),we);return;case"publickey":I.authPK(k.username,k.key,we);return;case"hostbased":I.authHostbased(k.username,k.key,k.localHostname,k.localUsername,we,(ve,Ne)=>{const Je=k.key.sign(ve,me);if(Je instanceof Error)return Je.message=`Error while signing with key: ${Je.message}`,Je.level="client-authentication",this.emit("error",Je),Ae();Ne(Je)});return}}else k.keyAlgos=void 0}if(k.type==="agent"){const re=k.agentCtx.pos();return i&&i(`Client: Agent key #${re+1} failed`),oe()}i&&i(`Client: ${k.type} auth failed`),v=Y,T=j,Ae()},USERAUTH_PASSWD_CHANGEREQ:(Q,j)=>{k.type==="password"&&this.emit("change password",j,Y=>{I.authPassword(this.config.username,this.config.password,Y)})},USERAUTH_PK_OK:Q=>{let j,Y;if(k.keyAlgos&&([j,Y]=k.keyAlgos[0]),k.type==="agent"){const re=k.agentCtx.currentKey();I.authPK(k.username,re,j,(we,me)=>{const ve={hash:Y};k.agentCtx.sign(re,we,ve,(Ne,Je)=>{if(Ne)Ne.level="agent",this.emit("error",Ne);else return me(Je);oe()})})}else k.type==="publickey"&&I.authPK(k.username,k.key,j,(re,we)=>{const me=k.key.sign(re,Y);if(me instanceof Error)return me.message=`Error signing data with key: ${me.message}`,me.level="client-authentication",this.emit("error",me),Ae();we(me)})},USERAUTH_INFO_REQUEST:(Q,j,Y,re)=>{if(k.type==="keyboard-interactive"){if((Array.isArray(re)?re.length:0)===0){i&&i("Client: Sending automatic USERAUTH_INFO_RESPONSE"),I.authInfoRes();return}k.prompt(j,Y,"",re,me=>{I.authInfoRes(me)})}},REQUEST_SUCCESS:(Q,j)=>{o.length&&o.shift()(!1,j)},REQUEST_FAILURE:Q=>{o.length&&o.shift()(!0)},GLOBAL_REQUEST:(Q,j,Y,re)=>{switch(j){case"hostkeys-00@openssh.com":xc(this,re,(we,me)=>{we||this.emit("hostkeys",me)}),Y&&I.requestSuccess();break;default:Y&&I.requestFailure()}},CHANNEL_OPEN:(Q,j)=>{bc(this,j)},CHANNEL_OPEN_CONFIRMATION:(Q,j)=>{const Y=this._chanMgr.get(j.recipient);if(typeof Y!="function")return;const re=Y.type==="sftp",me={type:re?"session":Y.type,incoming:{id:j.recipient,window:Or,packetSize:Dr,state:"open"},outgoing:{id:j.sender,window:j.window,packetSize:j.packetSize,state:"open"}},ve=re?new cc(this,me,{debug:i}):new Ao(this,me);this._chanMgr.update(j.recipient,ve),Y(void 0,ve)},CHANNEL_OPEN_FAILURE:(Q,j,Y,re)=>{const we=this._chanMgr.get(j);if(typeof we!="function")return;Ac(this,j,{reason:Y,description:re},we)},CHANNEL_DATA:(Q,j,Y)=>{const re=this._chanMgr.get(j);if(!(typeof re!="object"||re===null)&&re.incoming.window!==0){if(re.incoming.window-=Y.length,re.push(Y)===!1){re._waitChanDrain=!0;return}re.incoming.window<=_o&&go(re)}},CHANNEL_EXTENDED_DATA:(Q,j,Y,re)=>{if(re!==ec)return;const we=this._chanMgr.get(j);if(!(typeof we!="object"||we===null)&&we.incoming.window!==0){if(we.incoming.window-=Y.length,!we.stderr.push(Y)){we._waitChanDrain=!0;return}we.incoming.window<=_o&&go(we)}},CHANNEL_WINDOW_ADJUST:(Q,j,Y)=>{const re=this._chanMgr.get(j);typeof re!="object"||re===null||(re.outgoing.window+=Y,re._waitWindow&&(re._waitWindow=!1,re._chunk?re._write(re._chunk,null,re._chunkcb):re._chunkcb?re._chunkcb():re._chunkErr?re.stderr._write(re._chunkErr,null,re._chunkcbErr):re._chunkcbErr&&re._chunkcbErr()))},CHANNEL_SUCCESS:(Q,j)=>{const Y=this._chanMgr.get(j);typeof Y!="object"||Y===null||(this._resetKA(),Y._callbacks.length&&Y._callbacks.shift()(!1))},CHANNEL_FAILURE:(Q,j)=>{const Y=this._chanMgr.get(j);typeof Y!="object"||Y===null||(this._resetKA(),Y._callbacks.length&&Y._callbacks.shift()(!0))},CHANNEL_REQUEST:(Q,j,Y,re,we)=>{const me=this._chanMgr.get(j);if(typeof me!="object"||me===null)return;const ve=me._exit;if(ve.code===void 0){switch(Y){case"exit-status":me.emit("exit",ve.code=we);return;case"exit-signal":me.emit("exit",ve.code=null,ve.signal=`SIG${we.signal}`,ve.dump=we.coreDumped,ve.desc=we.errorMessage);return}re&&Q.channelFailure(me.outgoing.id)}},CHANNEL_EOF:(Q,j)=>{const Y=this._chanMgr.get(j);typeof Y!="object"||Y===null||Y.incoming.state==="open"&&(Y.incoming.state="eof",Y.readable&&Y.push(null),Y.stderr.readable&&Y.stderr.push(null))},CHANNEL_CLOSE:(Q,j)=>{gc(this,j,this._chanMgr.get(j))}}});h.pause();const y=this.config.keepaliveInterval,w=this.config.keepaliveCountMax;let R=0,M;const ce=()=>{if(++R>w){if(clearInterval(M),h.readable){const Q=new Error("Keepalive timeout");Q.level="client-timeout",this.emit("error",Q),h.destroy()}return}Bt(h)?(o.push(q),I.ping()):clearInterval(M)};function q(){y>0&&(R=0,clearInterval(M),Bt(h)&&(M=setInterval(ce,y)))}this._resetKA=q;const le=(()=>{let Q=!1;return()=>{if(!Q&&(Q=!0,fe&&!u)){const j=hc("Connection lost before handshake","protocol",!0);this.emit("error",j)}}})(),se=(()=>{let Q=!1;return()=>{Q||(Q=!0,fe=!0,i&&i("Socket connected"),this.emit("connect"),fc.then(()=>{I.start(),h.on("data",j=>{try{I.parse(j,0,j.length)}catch(Y){this.emit("error",Y);try{Bt(h)&&h.end()}catch{}}}),h.stderr&&typeof h.stderr.resume=="function"&&h.stderr.resume(),h.resume()}).catch(j=>{this.emit("error",j);try{Bt(h)&&h.end()}catch{}}))}})();let fe=!1;h.on("connect",se).on("timeout",()=>{this.emit("timeout")}).on("error",Q=>{i&&i(`Socket error: ${Q.message}`),clearTimeout(this._readyTimeout),Q.level="client-socket",this.emit("error",Q)}).on("end",()=>{i&&i("Socket ended"),le(),I.cleanup(),clearTimeout(this._readyTimeout),clearInterval(M),this.emit("end")}).on("close",()=>{i&&i("Socket closed"),le(),I.cleanup(),clearTimeout(this._readyTimeout),clearInterval(M),this.emit("close");const Q=o;o=this._callbacks=[];const j=new Error("No response from server");for(let Y=0;Y<Q.length;++Y)Q[Y](j);this._chanMgr.cleanup(j)});let k,v=null,T=null;const J=["none"];this.config.password!==void 0&&J.push("password"),f!==void 0&&J.push("publickey"),this._agent!==void 0&&J.push("agent"),this.config.tryKeyboard&&J.push("keyboard-interactive"),f!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&J.push("hostbased"),Array.isArray(s)?s=yo(s):typeof s!="function"&&(s=yo(J));let X=!1;const he=Q=>{if(!X){if(X=!0,Q===!1){const j=new Error("All configured authentication methods failed");j.level="client-authentication",this.emit("error",j),this.end();return}if(typeof Q=="string"){const j=Q;if(J.indexOf(j)===-1)return ae(`Authentication method not allowed: ${j}`);const Y=this.config.username;switch(j){case"password":Q={type:j,username:Y,password:this.config.password};break;case"publickey":Q={type:j,username:Y,key:f};break;case"hostbased":Q={type:j,username:Y,key:f,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":Q={type:j,username:Y,agentCtx:new ho(this._agent)};break;case"keyboard-interactive":Q={type:j,username:Y,prompt:(...re)=>this.emit("keyboard-interactive",...re)};break;case"none":Q={type:j,username:Y};break;default:return ae(`Skipping unsupported authentication method: ${Q}`)}}else{if(typeof Q!="object"||Q===null)return ae(`Skipping invalid authentication attempt: ${Q}`);{const j=Q.username;if(typeof j!="string")return ae(`Skipping invalid authentication attempt: ${Q}`);const Y=Q.type;switch(Y){case"password":{const{password:re}=Q;if(typeof re!="string"&&!Buffer.isBuffer(re))return ae("Skipping invalid password auth attempt");Q={type:Y,username:j,password:re};break}case"publickey":{const re=Pr(Q.key,Q.passphrase);if(re instanceof Error)return ae("Skipping invalid key auth attempt");if(!re.isPrivateKey())return ae("Skipping non-private key");Q={type:Y,username:j,key:re};break}case"hostbased":{const{localHostname:re,localUsername:we}=Q,me=Pr(Q.key,Q.passphrase);if(me instanceof Error||typeof re!="string"||typeof we!="string")return ae("Skipping invalid hostbased auth attempt");if(!me.isPrivateKey())return ae("Skipping non-private key");Q={type:Y,username:j,key:me,localHostname:re,localUsername:we};break}case"agent":{let re=Q.agent;if(typeof re=="string"&&re.length)re=uo(re);else if(!lo(re))return ae(`Skipping invalid agent: ${Q.agent}`);Q={type:Y,username:j,agentCtx:new ho(re)};break}case"keyboard-interactive":{const{prompt:re}=Q;if(typeof re!="function")return ae("Skipping invalid keyboard-interactive auth attempt");Q={type:Y,username:j,prompt:re};break}case"none":Q={type:Y,username:j};break;default:return ae(`Skipping unsupported authentication method: ${Q}`)}}}k=Q;try{const j=k.username;switch(k.type){case"password":I.authPassword(j,k.password);break;case"publickey":{let Y;if(k.keyAlgos=vi(this,k.key,A),k.keyAlgos)if(k.keyAlgos.length)Y=k.keyAlgos[0][0];else return ae("Skipping key authentication (no mutual hash algorithm)");I.authPK(j,k.key,Y);break}case"hostbased":{let Y,re;if(k.keyAlgos=vi(this,k.key,A),k.keyAlgos)if(k.keyAlgos.length)[Y,re]=k.keyAlgos[0];else return ae("Skipping hostbased authentication (no mutual hash algorithm)");I.authHostbased(j,k.key,k.localHostname,k.localUsername,Y,(we,me)=>{const ve=k.key.sign(we,re);if(ve instanceof Error)return ve.message=`Error while signing with key: ${ve.message}`,ve.level="client-authentication",this.emit("error",ve),Ae();me(ve)});break}case"agent":k.agentCtx.init(Y=>{if(Y)return Y.level="agent",this.emit("error",Y),Ae();oe()});break;case"keyboard-interactive":I.authKeyboard(j);break;case"none":I.authNone(j);break}}finally{X=!1}}};function ae(Q){i&&i(Q),process.nextTick(Ae)}function Ae(){X=!1;const Q=s(T,v,he);X||Q===void 0||he(Q)}const oe=()=>{if(k.type==="agent"){const Q=k.agentCtx.nextKey();if(Q===!1)i&&i("Agent: No more keys left to try"),i&&i("Client: agent auth failed"),Ae();else{const j=k.agentCtx.pos();let Y;if(k.keyAlgos=vi(this,Q,A),k.keyAlgos)if(k.keyAlgos.length)Y=k.keyAlgos[0][0];else{i&&i(`Agent: Skipping key #${j+1} (no mutual hash algorithm)`),oe();return}i&&i(`Agent: Trying key #${j+1}`),I.authPK(k.username,Q,Y)}}},ge=()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{const Q=new Error("Timed out while waiting for handshake");Q.level="client-timeout",this.emit("error",Q),h.destroy()},this.config.readyTimeout))};if(t.sock)ge(),typeof h.connecting=="boolean"&&h.connecting||se();else{let Q=this.config.host;const j=this.config.forceIPv4,Y=this.config.forceIPv6;i&&i(`Client: Trying ${Q} on port ${this.config.port} ...`);const re=()=>{ge(),h.connect({host:Q,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),h.setMaxListeners(0),h.setTimeout(typeof t.timeout=="number"?t.timeout:0)};!j&&!Y||j&&Y?re():za(Q,j?4:6,(we,me,ve)=>{if(we){const Ne=j?"IPv4":"IPv6",Je=new Error(`Error while looking up ${Ne} address for '${Q}': ${we}`);clearTimeout(this._readyTimeout),Je.level="client-dns",this.emit("error",Je),this.emit("close");return}Q=me,re()})}return this}end(){return this._sock&&Bt(this._sock)&&(this._protocol.disconnect(fo.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&Bt(this._sock)&&this._sock.destroy(),this}exec(t,e,n){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");typeof e=="function"&&(n=e,e={});const s={allowHalfOpen:e.allowHalfOpen!==!1};return Mn(this,"session",s,(i,o)=>{if(i){n(i);return}const f=[];function c(h){if(h){o.close(),n(h);return}f.length&&f.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&f.push(()=>bo(o,c)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&Io(o,e.env),(typeof e.pty=="object"&&e.pty!==null||e.pty===!0)&&f.push(()=>po(o,e.pty,c)),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&f.push(()=>Eo(o,e.x11,c))),f.push(()=>pc(o,t,e,n)),f.shift()()}),this}shell(t,e,n){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");return typeof t=="function"?(n=t,t=e=void 0):typeof e=="function"&&(n=e,e=void 0),t&&(t.x11!==void 0||t.env!==void 0)&&(e=t,t=void 0),Mn(this,"session",(s,i)=>{if(s){n(s);return}const o=[];function f(c){if(c){i.close(),n(c);return}o.length&&o.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&o.push(()=>bo(i,f)),t!==!1&&o.push(()=>po(i,t,f)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&Io(i,e.env),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&o.push(()=>Eo(i,e.x11,f))),o.push(()=>Ec(i,n)),o.shift()()}),this}subsys(t,e){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");return Mn(this,"session",(n,s)=>{if(n){e(n);return}xo(s,t,(i,o)=>{if(i){e(i);return}e(void 0,o)})}),this}forwardIn(t,e,n){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");const s=typeof n=="function";return s&&this._callbacks.push((i,o)=>{if(i){n(i!==!0?i:new Error(`Unable to bind to ${t}:${e}`));return}let f=e;e===0&&o&&o.length>=4&&(f=uc(o,0),this._protocol._compatFlags&to.DYN_RPORT_BUG||(e=f)),this._forwarding[`${t}:${e}`]=f,n(void 0,f)}),this._protocol.tcpipForward(t,e,s),this}unforwardIn(t,e,n){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");const s=typeof n=="function";return s&&this._callbacks.push(i=>{if(i){n(i!==!0?i:new Error(`Unable to unbind from ${t}:${e}`));return}delete this._forwarding[`${t}:${e}`],n()}),this._protocol.cancelTcpipForward(t,e,s),this}forwardOut(t,e,n,s,i){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");const o={srcIP:t,srcPort:e,dstIP:n,dstPort:s};return typeof i!="function"&&(i=Ni),Mn(this,"direct-tcpip",o,i),this}openssh_noMoreSessions(t){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");const e=typeof t=="function";return!this.config.strictVendor||this.config.strictVendor&&ur.test(this._remoteVer)?(e&&this._callbacks.push(n=>{if(n){t(n!==!0?n:new Error("Unable to disable future sessions"));return}t()}),this._protocol.openssh_noMoreSessions(e),this):e?(process.nextTick(t,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardInStreamLocal(t,e){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");const n=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&ur.test(this._remoteVer)?(n&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to bind to ${t}`));return}this._forwardingUnix[t]=!0,e()}),this._protocol.openssh_streamLocalForward(t,n),this):n?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(t,e){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");const n=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&ur.test(this._remoteVer)?(n&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to unbind from ${t}`));return}delete this._forwardingUnix[t],e()}),this._protocol.openssh_cancelStreamLocalForward(t,n),this):n?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(t,e){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");return typeof e!="function"&&(e=Ni),!this.config.strictVendor||this.config.strictVendor&&ur.test(this._remoteVer)?(Mn(this,"direct-streamlocal@openssh.com",{socketPath:t},e),this):(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this)}sftp(t){if(!this._sock||!Bt(this._sock))throw new Error("Not connected");return Mn(this,"sftp",(e,n)=>{if(e){t(e);return}xo(n,"sftp",(s,i)=>{if(s){t(s);return}function o(){n.removeListener("ready",f),n.removeListener("error",c),n.removeListener("exit",h),n.removeListener("close",h)}function f(){o(),t(void 0,n)}function c(g){o(),t(g)}function h(g,u){o();let d;typeof g=="number"?d=`Received exit code ${g} while establishing SFTP session`:u!==void 0?d=`Received signal ${u} while establishing SFTP session`:d="Received unexpected SFTP session termination";const A=new Error(d);A.code=g,A.signal=u,t(A)}n.on("ready",f).on("error",c).on("exit",h).on("close",h),n._init()})}),this}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function Mn(r,t,e,n){const s=Or,i=Dr;typeof e=="function"&&(n=e,e={});const o=(c,h)=>{n(c,h)};o.type=t;const f=r._chanMgr.add(o);if(f===-1){n(new Error("No free channels available"));return}switch(t){case"session":case"sftp":r._protocol.session(f,s,i);break;case"direct-tcpip":r._protocol.directTcpip(f,s,i,e);break;case"direct-streamlocal@openssh.com":r._protocol.openssh_directStreamLocal(f,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Eo(r,t,e){const n={single:!1,protocol:"MIT-MAGIC-COOKIE-1",cookie:void 0,screen:0};typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.single=="boolean"&&(n.single=t.single),typeof t.screen=="number"&&(n.screen=t.screen),typeof t.protocol=="string"&&(n.protocol=t.protocol),typeof t.cookie=="string"?n.cookie=t.cookie:Buffer.isBuffer(t.cookie)&&(n.cookie=t.cookie.hexSlice(0,t.cookie.length))),n.cookie===void 0&&(n.cookie=Ic());const s=typeof e=="function";if(r.outgoing.state!=="open"){s&&e(new Error("Channel is not open"));return}s&&r._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to request X11"));return}r._hasX11=!0,++r._client._acceptX11,r.once("close",()=>{r._client._acceptX11&&--r._client._acceptX11}),e()}),r._client._protocol.x11Forward(r.outgoing.id,n,s)}function po(r,t,e){let n=24,s=80,i=640,o=480,f="vt100",c=null;typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.rows=="number"&&(n=t.rows),typeof t.cols=="number"&&(s=t.cols),typeof t.width=="number"&&(i=t.width),typeof t.height=="number"&&(o=t.height),typeof t.term=="string"&&(f=t.term),typeof t.modes=="object"&&(c=t.modes));const h=typeof e=="function";if(r.outgoing.state!=="open"){h&&e(new Error("Channel is not open"));return}h&&r._callbacks.push(g=>{if(g){e(g!==!0?g:new Error("Unable to request a pseudo-terminal"));return}e()}),r._client._protocol.pty(r.outgoing.id,n,s,o,i,f,c,h)}function bo(r,t){const e=typeof t=="function";if(r.outgoing.state!=="open"){e&&t(new Error("Channel is not open"));return}if(r._client._agentFwdEnabled){e&&t(!1);return}r._client._agentFwdEnabled=!0,r._callbacks.push(n=>{if(n){r._client._agentFwdEnabled=!1,e&&t(n!==!0?n:new Error("Unable to request agent forwarding"));return}e&&t()}),r._client._protocol.openssh_agentForward(r.outgoing.id,!0)}function Ec(r,t){if(r.outgoing.state!=="open"){t(new Error("Channel is not open"));return}r._callbacks.push(e=>{if(e){t(e!==!0?e:new Error("Unable to open shell"));return}r.subtype="shell",t(void 0,r)}),r._client._protocol.shell(r.outgoing.id,!0)}function pc(r,t,e,n){if(r.outgoing.state!=="open"){n(new Error("Channel is not open"));return}r._callbacks.push(s=>{if(s){n(s!==!0?s:new Error("Unable to exec"));return}r.subtype="exec",r.allowHalfOpen=e.allowHalfOpen!==!1,n(void 0,r)}),r._client._protocol.exec(r.outgoing.id,t,!0)}function Io(r,t){if(r.outgoing.state!=="open")return;const e=Object.keys(t||{});for(let n=0;n<e.length;++n){const s=e[n],i=t[s];r._client._protocol.env(r.outgoing.id,s,i,!1)}}function xo(r,t,e){if(r.outgoing.state!=="open"){e(new Error("Channel is not open"));return}r._callbacks.push(n=>{if(n){e(n!==!0?n:new Error(`Unable to start subsystem: ${t}`));return}r.subtype="subsystem",e(void 0,r)}),r._client._protocol.subsystem(r.outgoing.id,t,!0)}function bc(r,t){let e=-1,n;const s=()=>{const c={type:t.type,incoming:{id:e,window:Or,packetSize:Dr,state:"open"},outgoing:{id:t.sender,window:t.window,packetSize:t.packetSize,state:"open"}},h=new Ao(r,c);return r._chanMgr.update(e,h),r._protocol.channelOpenConfirm(t.sender,e,Or,Dr),h},i=()=>{n===void 0&&(e===-1?n=cr.RESOURCE_SHORTAGE:n=cr.CONNECT_FAILED),e!==-1&&r._chanMgr.remove(e),r._protocol.channelOpenFail(t.sender,n,"")},o=()=>(e=r._chanMgr.add(),e===-1&&(n=cr.RESOURCE_SHORTAGE,r.config.debug&&r.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),e!==-1),f=t.data;switch(t.type){case"forwarded-tcpip":{const c=r._forwarding[`${f.destIP}:${f.destPort}`];if(c!==void 0&&o()){f.destPort===0&&(f.destPort=c),r.emit("tcp connection",f,s,i);return}break}case"forwarded-streamlocal@openssh.com":if(r._forwardingUnix[f.socketPath]!==void 0&&o()){r.emit("unix connection",f,s,i);return}break;case"auth-agent@openssh.com":if(r._agentFwdEnabled&&typeof r._agent.getStream=="function"&&o()){r._agent.getStream((c,h)=>{if(c)return i();const g=s();g.pipe(h).pipe(g)});return}break;case"x11":if(r._acceptX11!==0&&o()){r.emit("x11",f,s,i);return}break;default:n=cr.UNKNOWN_CHANNEL_TYPE,r.config.debug&&r.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${t.type}`)}n===void 0&&(n=cr.ADMINISTRATIVELY_PROHIBITED,r.config.debug&&r.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+t.type)),i()}const Ic=(()=>{const r=Buffer.allocUnsafe(16);return()=>(ja(r,0,16),r.hexSlice(0,16))})();function yo(r){if(!Array.isArray(r))throw new Error("authList must be an array");let t=0;return(e,n,s)=>t===r.length?!1:r[t++]}function xc(r,t,e){if(!r._sock||!Bt(r._sock))return;if(typeof e!="function"&&(e=Ni),!Array.isArray(t))throw new TypeError("Invalid keys argument type");const n=[];for(const s of t){const i=Pr(s);if(i instanceof Error)throw i;n.push(i)}if(!r.config.strictVendor||r.config.strictVendor&&ur.test(r._remoteVer)){r._callbacks.push((s,i)=>{if(s){e(s!==!0?s:new Error("Server failed to prove supplied keys"));return}const o=[];let f=0;for(Hr.init(i,0);Hr.avail()&&f!==n.length;){const c=n[f++],h=c.getPublicSSH(),g=Hr.readString();Qr.init(g,0);const u=Qr.readString(!0);let d=Qr.readString(),A;if(u!==c.type)if(c.type==="ssh-rsa")switch(u){case"rsa-sha2-256":A="sha256";break;case"rsa-sha2-512":A="sha512";break;default:continue}else continue;const I=r._protocol._kex.sessionID,y=Buffer.allocUnsafe(4+29+4+I.length+4+h.length);let w=0;Ri(y,29,w),y.utf8Write("hostkeys-prove-00@openssh.com",w+=4,29),Ri(y,I.length,w+=29),ao(I,y,0,I.length,w+=4),Ri(y,h.length,w+=I.length),ao(h,y,0,h.length,w+=4),(d=lc(d,u))&&c.verify(y,d,A)===!0&&o.push(c)}Qr.clear(),Hr.clear(),e(null,o)}),r._protocol.openssh_hostKeysProve(n);return}process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version"))}function vi(r,t,e){switch(t.type){case"ssh-rsa":if(r._protocol._compatFlags&to.IMPLY_RSA_SHA2_SIGALGS&&(Array.isArray(e)?e=["rsa-sha2-256","rsa-sha2-512",...e]:e=["rsa-sha2-256","rsa-sha2-512"]),Array.isArray(e)){if(e.indexOf("rsa-sha2-256")!==-1)return[["rsa-sha2-256","sha256"]];if(e.indexOf("rsa-sha2-512")!==-1)return[["rsa-sha2-512","sha512"]];if(e.indexOf("ssh-rsa")===-1)return[]}return[["ssh-rsa","sha1"]]}}var So=_c;(function(r){const{Agent:t}=tt,{Agent:e}=tt,{connect:n}=tt;let s;for(const f of[t,e]){class c extends f{constructor(g,u){super(u),this._connectCfg=g,this._defaultSrcIP=u&&u.srcIP||"localhost"}createConnection(g,u){const d=g&&g.localAddress||this._defaultSrcIP,A=g&&g.localPort||0,I=g.host,y=g.port;s===void 0&&(s=So);const w=new s;let R=!1;w.on("ready",()=>{w.forwardOut(d,A,I,y,(M,ce)=>{if(R=!0,M)return w.end(),u(M);ce.once("close",()=>w.end()),u(null,o(ce,f,g))})}).on("error",u).on("close",()=>{R||u(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}r[f===t?"SSHTTPAgent":"SSHTTPSAgent"]=c}function i(){}function o(f,c,h){if(c===t)return f.setKeepAlive=i,f.setNoDelay=i,f.setTimeout=i,f.ref=i,f.unref=i,f.destroySoon=f.destroy,f;h.socket=f;const g=n(h),u=(()=>{let d=!1;return()=>{d||(d=!0,f.isPaused()&&f.resume())}})();return g.on("end",u).on("close",u),g}})(hs);var Ti={exports:{}};const{Server:yc}=tt,lr=tt,{listenerCount:Lt}=lr,{CHANNEL_OPEN_FAILURE:Kn,DEFAULT_CIPHER:Sc,DEFAULT_COMPRESSION:wc,DEFAULT_KEX:mc,DEFAULT_MAC:Cc,DEFAULT_SERVER_HOST_KEY:Bc,DISCONNECT_REASON:Wn,DISCONNECT_REASON_BY_VALUE:kc,SUPPORTED_CIPHER:Rc,SUPPORTED_COMPRESSION:Nc,SUPPORTED_KEX:vc,SUPPORTED_MAC:Tc,SUPPORTED_SERVER_HOST_KEY:Lc}=En(),{init:Uc}=Bn(),{KexInit:Pc}=Ai(),{parseKey:wo}=Rn,Oc=Ns,{SFTP:Dc}=Lr,{writeUInt32BE:Hc}=nn(),{Channel:$n,MAX_WINDOW:xn,PACKET_SIZE:yn,windowAdjust:Qc,WINDOW_THRESHOLD:Fc}=zs,{ChannelManager:Mc,generateAlgorithmList:dr,isWritable:Fr,onChannelOpenFailure:Kc,onCHANNEL_CLOSE:Wc}=eo,$c=10;class qn extends lr{constructor(t,e,n,s,i){super(),this.username=this.user=e,this.service=n,this.method=s,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(o,f,c)=>{this._finalResponse||(this._finalResponse=!0,i(this,o,f,c))},this._protocol=t}accept(){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!0)}reject(t,e){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!1,t,e)}}class mo extends qn{constructor(t,e,n,s,i,o){super(t,e,n,s,o),this._multistep=!0,this._cb=void 0,this._onInfoResponse=f=>{const c=this._cb;c&&(this._cb=void 0,c(f))},this.submethods=i,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(t,e,n,s){Array.isArray(t)||(t=[t]),typeof e=="function"?(s=e,e=n=void 0):typeof n=="function"?(s=n,n=void 0):typeof s!="function"&&(s=void 0);for(let i=0;i<t.length;++i)typeof t[i]=="string"&&(t[i]={prompt:t[i],echo:!0});this._cb=s,this._initialResponse=!0,this._protocol.authInfoReq(e,n,t)}}class qc extends qn{constructor(t,e,n,s,i,o){super(t,e,n,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob}accept(){this.signature?qn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}}class Gc extends qn{constructor(t,e,n,s,i,o){super(t,e,n,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob,this.localHostname=i.localHostname,this.localUsername=i.localUsername}}class Co extends qn{constructor(t,e,n,s,i,o){super(t,e,n,s,o),this.password=i,this._changeCb=void 0}requestChange(t,e){if(this._changeCb)throw new Error("Change request already in progress");if(typeof t!="string")throw new Error("prompt argument must be a string");if(typeof e!="function")throw new Error("Callback argument must be a function");this._changeCb=e,this._protocol.authPasswdChg(t)}}class Sn extends lr{constructor(t,e,n){super(),this.type="session",this.subtype=void 0,this.server=!0,this._ending=!1,this._channel=void 0,this._chanInfo={type:"session",incoming:{id:n,window:xn,packetSize:yn,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}}}}class tn extends lr{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new Error("Missing configuration object");const n=Object.create(null),s=[],i=t.hostKeys;if(!Array.isArray(i))throw new Error("hostKeys must be an array");const o=typeof t.algorithms=="object"&&t.algorithms!==null?t.algorithms:{},f=dr(o.serverHostKey,Bc,Lc);for(let d=0;d<i.length;++d){let A;if(Buffer.isBuffer(i[d])||typeof i[d]=="string"?A=wo(i[d]):A=wo(i[d].key,i[d].passphrase),A instanceof Error)throw new Error(`Cannot parse privateKey: ${A.message}`);if(Array.isArray(A)&&(A=A[0]),A.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!s.includes(A.type))if(A.type==="ssh-rsa"){let I=f.indexOf("ssh-rsa");const y=f.indexOf("rsa-sha2-256"),w=f.indexOf("rsa-sha2-512");I===-1&&(I=1/0),[I,y,w].sort(Yc).forEach(R=>{if(R===-1)return;let M;switch(R){case I:M="ssh-rsa";break;case y:M="rsa-sha2-256";break;case w:M="rsa-sha2-512";break;default:return}n[M]=A,s.push(M)})}else n[A.type]=A,s.push(A.type)}const c={kex:dr(o.kex,mc,vc).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:s,cs:{cipher:dr(o.cipher,Sc,Rc),mac:dr(o.hmac,Cc,Tc),compress:dr(o.compress,wc,Nc),lang:[]},sc:void 0};c.sc=c.cs,typeof e=="function"&&this.on("connection",e);const h=typeof t.debug=="function"?t.debug:void 0,g=t.ident?Buffer.from(t.ident):void 0,u=new Pc(c);this._srv=new yc(d=>{if(this._connections>=this.maxConnections){d.destroy();return}++this._connections,d.once("close",()=>{--this._connections});let A;if(h){const I=`[${process.hrtime().join(".")}] `;A=y=>{h(`${I}${y}`)}}new Bo(d,n,g,u,A,this,t)}).on("error",d=>{this.emit("error",d)}).on("listening",()=>{this.emit("listening")}).on("close",()=>{this.emit("close")}),this._connections=0,this.maxConnections=1/0}injectSocket(t){this._srv.emit("connection",t)}listen(...t){return this._srv.listen(...t),this}address(){return this._srv.address()}getConnections(t){return this._srv.getConnections(t),this}close(t){return this._srv.close(t),this}ref(){return this._srv.ref(),this}unref(){return this._srv.unref(),this}}tn.KEEPALIVE_CLIENT_INTERVAL=15e3,tn.KEEPALIVE_CLIENT_COUNT_MAX=3;class Bo extends lr{constructor(t,e,n,s,i,o,f){super();let c=0,h=!1,g=[],u,d,A;const I=[];this._sock=t,this._chanMgr=new Mc(this),this._debug=i,this.noMoreSessions=!1,this.authenticated=!1;function y(fe){}this.on("error",y);const w=i?(fe,k,v)=>{i(`Debug output from client: ${JSON.stringify(v)}`)}:void 0,R=typeof f.keepaliveInterval=="number"&&isFinite(f.keepaliveInterval)&&f.keepaliveInterval>0?f.keepaliveInterval:typeof tn.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(tn.KEEPALIVE_CLIENT_INTERVAL)&&tn.KEEPALIVE_CLIENT_INTERVAL>0?tn.KEEPALIVE_CLIENT_INTERVAL:-1,M=typeof f.keepaliveCountMax=="number"&&isFinite(f.keepaliveCountMax)&&f.keepaliveCountMax>=0?f.keepaliveCountMax:typeof tn.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(tn.KEEPALIVE_CLIENT_COUNT_MAX)&&tn.KEEPALIVE_CLIENT_COUNT_MAX>=0?tn.KEEPALIVE_CLIENT_COUNT_MAX:-1;let ce=0;R!==-1&&M!==-1&&(this.once("ready",()=>{const fe=()=>{clearInterval(d)};this.on("close",fe).on("end",fe),d=setInterval(()=>{if(++ce>M){clearInterval(d);const k=new Error("Keepalive timeout");k.level="client-timeout",this.emit("error",k),this.end()}else q.ping()},R)}),A=()=>{d&&d.refresh(),ce=0});const q=this._protocol=new Oc({server:!0,hostKeys:e,ident:n,offer:s,onPacket:A,greeting:f.greeting,banner:f.banner,onWrite:fe=>{Fr(t)&&t.write(fe)},onError:fe=>{q._destruct||t.removeAllListeners("data"),this.emit("error",fe);try{t.end()}catch{}},onHeader:fe=>{this.removeListener("error",y);const k={ip:t.remoteAddress,family:t.remoteFamily,port:t.remotePort,header:fe};if(!o.emit("connection",this,k)){q.disconnect(Wn.BY_APPLICATION),t.end();return}fe.greeting&&this.emit("greeting",fe.greeting)},onHandshakeComplete:fe=>{++c>1&&this.emit("rekey"),this.emit("handshake",fe)},debug:i,messageHandlers:{DEBUG:w,DISCONNECT:(fe,k,v)=>{if(k!==Wn.BY_APPLICATION){v||(v=kc[k],v===void 0&&(v=`Unexpected disconnection reason: ${k}`));const T=new Error(v);T.code=k,this.emit("error",T)}t.end()},CHANNEL_OPEN:(fe,k)=>{if(k.type==="session"&&this.noMoreSessions||!this.authenticated){const oe=Kn.ADMINISTRATIVELY_PROHIBITED;return q.channelOpenFail(k.sender,oe)}let v=-1,T,J=!1,X;const he=()=>{J||(J=!0,T===void 0&&(v===-1?T=Kn.RESOURCE_SHORTAGE:T=Kn.CONNECT_FAILED),v!==-1&&this._chanMgr.remove(v),q.channelOpenFail(k.sender,T,""))},ae=()=>(v=this._chanMgr.add(),v===-1&&(T=Kn.RESOURCE_SHORTAGE,i&&i("Automatic rejection of incoming channel open: no channels available")),v!==-1),Ae=k.data;switch(k.type){case"session":if(Lt(this,"session")&&ae()){X=()=>{if(J)return;J=!0;const oe=new Sn(this,k,v);return this._chanMgr.update(v,oe),q.channelOpenConfirm(k.sender,v,xn,yn),oe},this.emit("session",X,he);return}break;case"direct-tcpip":if(Lt(this,"tcpip")&&ae()){X=()=>{if(J)return;J=!0;const oe={type:void 0,incoming:{id:v,window:xn,packetSize:yn,state:"open"},outgoing:{id:k.sender,window:k.window,packetSize:k.packetSize,state:"open"}},ge=new $n(this,oe,{server:!0});return this._chanMgr.update(v,ge),q.channelOpenConfirm(k.sender,v,xn,yn),ge},this.emit("tcpip",X,he,Ae);return}break;case"direct-streamlocal@openssh.com":if(Lt(this,"openssh.streamlocal")&&ae()){X=()=>{if(J)return;J=!0;const oe={type:void 0,incoming:{id:v,window:xn,packetSize:yn,state:"open"},outgoing:{id:k.sender,window:k.window,packetSize:k.packetSize,state:"open"}},ge=new $n(this,oe,{server:!0});return this._chanMgr.update(v,ge),q.channelOpenConfirm(k.sender,v,xn,yn),ge},this.emit("openssh.streamlocal",X,he,Ae);return}break;default:T=Kn.UNKNOWN_CHANNEL_TYPE,i&&i(`Automatic rejection of unsupported incoming channel open type: ${k.type}`)}T===void 0&&(T=Kn.ADMINISTRATIVELY_PROHIBITED,i&&i(`Automatic rejection of unexpected incoming channel open for: ${k.type}`)),he()},CHANNEL_OPEN_CONFIRMATION:(fe,k)=>{const v=this._chanMgr.get(k.recipient);if(typeof v!="function")return;const T={type:v.type,incoming:{id:k.recipient,window:xn,packetSize:yn,state:"open"},outgoing:{id:k.sender,window:k.window,packetSize:k.packetSize,state:"open"}},J=new $n(this,T,{server:!0});this._chanMgr.update(k.recipient,J),v(void 0,J)},CHANNEL_OPEN_FAILURE:(fe,k,v,T)=>{const J=this._chanMgr.get(k);if(typeof J!="function")return;Kc(this,k,{reason:v,description:T},J)},CHANNEL_DATA:(fe,k,v)=>{let T=this._chanMgr.get(k);if(!(typeof T!="object"||T===null)&&!(T.constructor===Sn&&(T=T._channel,!T))&&T.incoming.window!==0){if(T.incoming.window-=v.length,T.push(v)===!1){T._waitChanDrain=!0;return}T.incoming.window<=Fc&&Qc(T)}},CHANNEL_EXTENDED_DATA:(fe,k,v,T)=>{},CHANNEL_WINDOW_ADJUST:(fe,k,v)=>{let T=this._chanMgr.get(k);typeof T!="object"||T===null||T.constructor===Sn&&(T=T._channel,!T)||(T.outgoing.window+=v,T._waitWindow&&(T._waitWindow=!1,T._chunk?T._write(T._chunk,null,T._chunkcb):T._chunkcb?T._chunkcb():T._chunkErr?T.stderr._write(T._chunkErr,null,T._chunkcbErr):T._chunkcbErr&&T._chunkcbErr()))},CHANNEL_SUCCESS:(fe,k)=>{let v=this._chanMgr.get(k);typeof v!="object"||v===null||v.constructor===Sn&&(v=v._channel,!v)||v._callbacks.length&&v._callbacks.shift()(!1)},CHANNEL_FAILURE:(fe,k)=>{let v=this._chanMgr.get(k);typeof v!="object"||v===null||v.constructor===Sn&&(v=v._channel,!v)||v._callbacks.length&&v._callbacks.shift()(!0)},CHANNEL_REQUEST:(fe,k,v,T,J)=>{const X=this._chanMgr.get(k);if(typeof X!="object"||X===null)return;let he=!1,ae,Ae;if(X.constructor!==Sn){T&&q.channelFailure(X.outgoing.id);return}if(T&&(v!=="shell"&&v!=="exec"&&v!=="subsystem"&&(ae=()=>{he||X._ending||X._channel||(he=!0,q.channelSuccess(X._chanInfo.outgoing.id))}),Ae=()=>{he||X._ending||X._channel||(he=!0,q.channelFailure(X._chanInfo.outgoing.id))}),X._ending){Ae&&Ae();return}switch(v){case"env":if(Lt(X,"env")){X.emit("env",ae,Ae,{key:J.name,val:J.value});return}break;case"pty-req":if(Lt(X,"pty")){X.emit("pty",ae,Ae,J);return}break;case"window-change":Lt(X,"window-change")?X.emit("window-change",ae,Ae,J):Ae&&Ae();break;case"x11-req":if(Lt(X,"x11")){X.emit("x11",ae,Ae,J);return}break;case"signal":if(Lt(X,"signal")){X.emit("signal",ae,Ae,{name:J});return}break;case"auth-agent-req@openssh.com":if(Lt(X,"auth-agent")){X.emit("auth-agent",ae,Ae);return}break;case"shell":if(Lt(X,"shell")){ae=()=>{if(he||X._ending||X._channel)return;he=!0,T&&q.channelSuccess(X._chanInfo.outgoing.id);const oe=new $n(this,X._chanInfo,{server:!0});return oe.subtype=X.subtype=v,X._channel=oe,oe},X.emit("shell",ae,Ae);return}break;case"exec":if(Lt(X,"exec")){ae=()=>{if(he||X._ending||X._channel)return;he=!0,T&&q.channelSuccess(X._chanInfo.outgoing.id);const oe=new $n(this,X._chanInfo,{server:!0});return oe.subtype=X.subtype=v,X._channel=oe,oe},X.emit("exec",ae,Ae,{command:J});return}break;case"subsystem":{let oe=J==="sftp";if(ae=()=>{if(he||X._ending||X._channel)return;he=!0,T&&q.channelSuccess(X._chanInfo.outgoing.id);let ge;return oe?ge=new Dc(this,X._chanInfo,{server:!0,debug:i}):(ge=new $n(this,X._chanInfo,{server:!0}),ge.subtype=X.subtype=`${v}:${J}`),X._channel=ge,ge},J==="sftp"){if(Lt(X,"sftp")){X.emit("sftp",ae,Ae);return}oe=!1}if(Lt(X,"subsystem")){X.emit("subsystem",ae,Ae,{name:J});return}break}}i&&i(`Automatic rejection of incoming channel request: ${v}`),Ae&&Ae()},CHANNEL_EOF:(fe,k)=>{let v=this._chanMgr.get(k);typeof v!="object"||v===null||v.constructor===Sn&&(v._ending||(v._ending=!0,v.emit("eof"),v.emit("end")),v=v._channel,!v)||v.incoming.state==="open"&&(v.incoming.state="eof",v.readable&&v.push(null))},CHANNEL_CLOSE:(fe,k)=>{let v=this._chanMgr.get(k);typeof v!="object"||v===null||v.constructor===Sn&&(v._ending=!0,v.emit("close"),v=v._channel,!v)||Wc(this,k,v)},SERVICE_REQUEST:(fe,k)=>{if(c===0||h||this.authenticated||k!=="ssh-userauth"){q.disconnect(Wn.SERVICE_NOT_AVAILABLE),t.end();return}h=!0,q.serviceAccept(k)},USERAUTH_REQUEST:(fe,k,v,T,J)=>{if(c===0||this.authenticated||u&&(u.username!==k||u.service!==v)||T!=="password"&&T!=="publickey"&&T!=="hostbased"&&T!=="keyboard-interactive"&&T!=="none"||g.length===$c){q.disconnect(Wn.PROTOCOL_ERROR),t.end();return}else if(v!=="ssh-connection"){q.disconnect(Wn.SERVICE_NOT_AVAILABLE),t.end();return}let X;switch(T){case"keyboard-interactive":X=new mo(q,k,v,T,J,le);break;case"publickey":X=new qc(q,k,v,T,J,le);break;case"hostbased":X=new Gc(q,k,v,T,J,le);break;case"password":if(u&&u instanceof Co&&u._changeCb){const he=u._changeCb;u._changeCb=void 0,he(J.newPassword);return}X=new Co(q,k,v,T,J,le);break;case"none":X=new qn(q,k,v,T,le);break}if(u)if(u._initialResponse)u._multistep&&!u._finalResponse&&(u._cleanup&&u._cleanup(),u.emit("abort"));else return g.push(X);u=X,Lt(this,"authentication")?this.emit("authentication",u):u.reject()},USERAUTH_INFO_RESPONSE:(fe,k)=>{u&&u instanceof mo&&u._onInfoResponse(k)},GLOBAL_REQUEST:(fe,k,v,T)=>{const J={type:null,buf:null};function X(he,ae){J.type=he,J.buf=ae,se()}if(v&&I.push(J),(k==="tcpip-forward"||k==="cancel-tcpip-forward"||k==="no-more-sessions@openssh.com"||k==="streamlocal-forward@openssh.com"||k==="cancel-streamlocal-forward@openssh.com")&&Lt(this,"request")&&this.authenticated){let he,ae;if(v){let Ae=!1;he=oe=>{if(Ae)return;Ae=!0;let ge;k==="tcpip-forward"&&T.bindPort===0&&typeof oe=="number"&&(ge=Buffer.allocUnsafe(4),Hc(ge,oe,0)),X("SUCCESS",ge)},ae=()=>{Ae||(Ae=!0,X("FAILURE"))}}if(k==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,he&&he();return}this.emit("request",he,ae,k,T)}else v&&X("FAILURE")}}});t.pause(),Uc.then(()=>{q.start(),t.on("data",fe=>{try{q.parse(fe,0,fe.length)}catch(k){this.emit("error",k);try{Fr(t)&&t.end()}catch{}}}),t.resume()}).catch(fe=>{this.emit("error",fe);try{Fr(t)&&t.end()}catch{}}),t.on("error",fe=>{fe.level="socket",this.emit("error",fe)}).once("end",()=>{i&&i("Socket ended"),q.cleanup(),this.emit("end")}).once("close",()=>{i&&i("Socket closed"),q.cleanup(),this.emit("close");const fe=new Error("No response from server");this._chanMgr.cleanup(fe)});const le=(fe,k,v,T)=>{u===fe&&!this.authenticated&&(k?(u=void 0,this.authenticated=!0,q.authSuccess(),g=[],this.emit("ready")):(q.authFailure(v,T),g.length&&(u=g.pop(),Lt(this,"authentication")?this.emit("authentication",u):u.reject())))};function se(){for(;I.length>0&&I[0].type;){const fe=I.shift();fe.type==="SUCCESS"&&q.requestSuccess(fe.buf),fe.type==="FAILURE"&&q.requestFailure()}}}end(){return this._sock&&Fr(this._sock)&&(this._protocol.disconnect(Wn.BY_APPLICATION),this._sock.end()),this}x11(t,e,n){return Li(this,"x11",{originAddr:t,originPort:e},n),this}forwardOut(t,e,n,s,i){return Li(this,"forwarded-tcpip",{boundAddr:t,boundPort:e,remoteAddr:n,remotePort:s},i),this}openssh_forwardOutStreamLocal(t,e){return Li(this,"forwarded-streamlocal@openssh.com",{socketPath:t},e),this}rekey(t){let e;try{this._protocol.rekey()}catch(n){e=n}typeof t=="function"&&(e?process.nextTick(t,e):this.once("rekey",t))}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}}function Li(r,t,e,n){const s=xn,i=yn;typeof e=="function"&&(n=e,e={});const o=(c,h)=>{n(c,h)};o.type=t;const f=r._chanMgr.add(o);if(f===-1){n(new Error("No free channels available"));return}switch(t){case"forwarded-tcpip":r._protocol.forwardedTcpip(f,s,i,e);break;case"x11":r._protocol.x11(f,s,i,e);break;case"forwarded-streamlocal@openssh.com":r._protocol.openssh_forwardedStreamLocal(f,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Yc(r,t){return r-t}Ti.exports=tn,Ti.exports.IncomingClient=Bo;var Xc=Ti.exports;const{createCipheriv:jc,generateKeyPair:Vc,generateKeyPairSync:zc,getCurves:Jc,randomBytes:ko}=tt,{Ber:pt}=Ir,Zc=Fi.pbkdf,{CIPHER_INFO:eh}=Bn(),th=16,nh=16,rh=Jc(),ih=new Map(Object.entries(eh));function Ro(r,t){if(typeof r!="string")throw new TypeError("Key type must be a string");const e={type:"spki",format:"der"},n={type:"pkcs8",format:"der"};switch(r.toLowerCase()){case"rsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for RSA key");const s=t.bits;if(!Number.isInteger(s))throw new TypeError("RSA bits must be an integer");if(s<=0||s>16384)throw new RangeError("RSA bits must be non-zero and <= 16384");return["rsa",{modulusLength:s,publicKeyEncoding:e,privateKeyEncoding:n}]}case"ecdsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for ECDSA key");if(!Number.isInteger(t.bits))throw new TypeError("ECDSA bits must be an integer");let s;switch(t.bits){case 256:s="prime256v1";break;case 384:s="secp384r1";break;case 521:s="secp521r1";break;default:throw new Error("ECDSA bits must be 256, 384, or 521")}if(!rh.includes(s))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:s,publicKeyEncoding:e,privateKeyEncoding:n}]}case"ed25519":return["ed25519",{publicKeyEncoding:e,privateKeyEncoding:n}];default:throw new Error(`Unsupported key type: ${r}`)}}function sh(r,t,e){switch(r){case"rsa":{let n=new pt.Reader(e);if(n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in RSA private key");if(n.readSequence(),n.readOID()!=="1.2.840.113549.1.1.1")throw new Error("Bad RSA private OID");if(n.readByte()!==pt.Null)throw new Error("Malformed RSA private key (expected null)");if(n.readByte()!==0)throw new Error("Malformed RSA private key (expected zero-length null)");if(n=new pt.Reader(n.readString(pt.OctetString,!0)),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in RSA private key");const s=n.readString(pt.Integer,!0),i=n.readString(pt.Integer,!0),o=n.readString(pt.Integer,!0),f=n.readString(pt.Integer,!0),c=n.readString(pt.Integer,!0);n.readString(pt.Integer,!0),n.readString(pt.Integer,!0);const h=n.readString(pt.Integer,!0),g=Buffer.from("ssh-rsa"),u=Buffer.allocUnsafe(4+g.length+4+s.length+4+i.length+4+o.length+4+h.length+4+f.length+4+c.length);let d=0;u.writeUInt32BE(g.length,d+=0),u.set(g,d+=4),u.writeUInt32BE(s.length,d+=g.length),u.set(s,d+=4),u.writeUInt32BE(i.length,d+=s.length),u.set(i,d+=4),u.writeUInt32BE(o.length,d+=i.length),u.set(o,d+=4),u.writeUInt32BE(h.length,d+=o.length),u.set(h,d+=4),u.writeUInt32BE(f.length,d+=h.length),u.set(f,d+=4),u.writeUInt32BE(c.length,d+=f.length),u.set(c,d+=4);const A=Buffer.allocUnsafe(4+g.length+4+i.length+4+s.length);return d=0,A.writeUInt32BE(g.length,d+=0),A.set(g,d+=4),A.writeUInt32BE(i.length,d+=g.length),A.set(i,d+=4),A.writeUInt32BE(s.length,d+=i.length),A.set(s,d+=4),{sshName:g.toString(),priv:u,pub:A}}case"ec":{let n=new pt.Reader(t);if(n.readSequence(),n.readSequence(),n.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");n.readOID();let s=n.readString(pt.BitString,!0);{let d=0;for(;d<s.length&&s[d]===0;++d);d>0&&(s=s.slice(d))}if(n=new pt.Reader(e),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(n.readSequence(),n.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");const i=n.readOID();let o;switch(i){case"1.2.840.10045.3.1.7":o="nistp256";break;case"1.3.132.0.34":o="nistp384";break;case"1.3.132.0.35":o="nistp521";break;default:throw new Error("Unsupported curve in ECDSA private key")}if(n=new pt.Reader(n.readString(pt.OctetString,!0)),n.readSequence(),n.readInt()!==1)throw new Error("Unsupported version in ECDSA private key");const f=Buffer.concat([Buffer.from([0]),n.readString(pt.OctetString,!0)]),c=Buffer.from(`ecdsa-sha2-${o}`);o=Buffer.from(o);const h=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length+4+f.length);let g=0;h.writeUInt32BE(c.length,g+=0),h.set(c,g+=4),h.writeUInt32BE(o.length,g+=c.length),h.set(o,g+=4),h.writeUInt32BE(s.length,g+=o.length),h.set(s,g+=4),h.writeUInt32BE(f.length,g+=s.length),h.set(f,g+=4);const u=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length);return g=0,u.writeUInt32BE(c.length,g+=0),u.set(c,g+=4),u.writeUInt32BE(o.length,g+=c.length),u.set(o,g+=4),u.writeUInt32BE(s.length,g+=o.length),u.set(s,g+=4),{sshName:c.toString(),priv:h,pub:u}}case"ed25519":{let n=new pt.Reader(t);if(n.readSequence(),n.readSequence(),n.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let s=n.readString(pt.BitString,!0);{let g=0;for(;g<s.length&&s[g]===0;++g);g>0&&(s=s.slice(g))}if(n=new pt.Reader(e),n.readSequence(),n.readInt()!==0)throw new Error("Unsupported version in ED25519 private key");if(n.readSequence(),n.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 private OID");n=new pt.Reader(n.readString(pt.OctetString,!0));const i=n.readString(pt.OctetString,!0),o=Buffer.from("ssh-ed25519"),f=Buffer.allocUnsafe(4+o.length+4+s.length+4+(i.length+s.length));let c=0;f.writeUInt32BE(o.length,c+=0),f.set(o,c+=4),f.writeUInt32BE(s.length,c+=o.length),f.set(s,c+=4),f.writeUInt32BE(i.length+s.length,c+=s.length),f.set(i,c+=4),f.set(s,c+=i.length);const h=Buffer.allocUnsafe(4+o.length+4+s.length);return c=0,h.writeUInt32BE(o.length,c+=0),h.set(o,c+=4),h.writeUInt32BE(s.length,c+=o.length),h.set(s,c+=4),{sshName:o.toString(),priv:f,pub:h}}}}function No(r,t,e,n){let s="new",i,o="";if(typeof n=="object"&&n!==null&&(typeof n.comment=="string"&&n.comment&&(o=n.comment),typeof n.format=="string"&&n.format&&(s=n.format),n.passphrase)){let f;if(typeof n.passphrase=="string")f=Buffer.from(n.passphrase);else if(Buffer.isBuffer(n.passphrase))f=n.passphrase;else throw new Error("Invalid passphrase");if(n.cipher===void 0)throw new Error("Missing cipher name");const c=ih.get(n.cipher);if(c===void 0)throw new Error("Invalid cipher name");if(s==="new"){let h=nh;if(n.rounds!==void 0){if(!Number.isInteger(n.rounds))throw new TypeError("rounds must be an integer");n.rounds>0&&(h=n.rounds)}const g=Buffer.allocUnsafe(c.keyLen+c.ivLen),u=ko(th);if(Zc(f,f.length,u,u.length,g,g.length,h)!==0)return new Error("Failed to generate information to encrypt key");const A=Buffer.allocUnsafe(4+u.length+4);{let I=0;A.writeUInt32BE(u.length,I+=0),A.set(u,I+=4),A.writeUInt32BE(h,I+=u.length)}i={cipher:c,cipherName:n.cipher,kdfName:"bcrypt",kdfOptions:A,key:g.slice(0,c.keyLen),iv:g.slice(c.keyLen)}}}switch(s){case"new":{let f=`-----BEGIN OPENSSH PRIVATE KEY-----
16
+ `,c;const h=Buffer.from(i?i.cipherName:"none"),g=Buffer.from(i?i.kdfName:"none"),u=i?i.kdfOptions:Buffer.alloc(0),d=i?i.cipher.blockLen:8,A=sh(r,t,e),I=ko(4),y=Buffer.from(o),w=4+4+A.priv.length+4+y.length;let R=[];for(let se=1;(w+R.length)%d;++se)R.push(se&255);R=Buffer.from(R);let M=Buffer.allocUnsafe(w+R.length),ce;{let se=0;M.set(I,se+=0),M.set(I,se+=4),M.set(A.priv,se+=4),M.writeUInt32BE(y.length,se+=A.priv.length),M.set(y,se+=4),M.set(R,se+=y.length)}if(i){const se={authTagLength:i.cipher.authLen},fe=jc(i.cipher.sslName,i.key,i.iv,se);fe.setAutoPadding(!1),M=Buffer.concat([fe.update(M),fe.final()]),i.cipher.authLen>0?ce=fe.getAuthTag():ce=Buffer.alloc(0),i.key.fill(0),i.iv.fill(0)}else ce=Buffer.alloc(0);const q=Buffer.from("openssh-key-v1\0"),le=Buffer.allocUnsafe(q.length+4+h.length+4+g.length+4+u.length+4+4+A.pub.length+4+M.length+ce.length);{let se=0;le.set(q,se+=0),le.writeUInt32BE(h.length,se+=q.length),le.set(h,se+=4),le.writeUInt32BE(g.length,se+=h.length),le.set(g,se+=4),le.writeUInt32BE(u.length,se+=g.length),le.set(u,se+=4),le.writeUInt32BE(1,se+=u.length),le.writeUInt32BE(A.pub.length,se+=4),le.set(A.pub,se+=4),le.writeUInt32BE(M.length,se+=A.pub.length),le.set(M,se+=4),le.set(ce,se+=M.length)}{const se=le.base64Slice(0,le.length);let fe=se.replace(/.{64}/g,`$&
17
+ `);se.length&63&&(fe+=`
18
+ `),f+=fe}{const se=A.pub.base64Slice(0,A.pub.length);c=`${A.sshName} ${se}${o?` ${o}`:""}`}return f+=`-----END OPENSSH PRIVATE KEY-----
19
+ `,{private:f,public:c}}default:throw new Error("Invalid output key format")}}function oh(){}var fh={generateKeyPair:(r,t,e)=>{typeof t=="function"&&(e=t,t=void 0),typeof e!="function"&&(e=oh);const n=Ro(r,t);Vc(...n,(s,i,o)=>{if(s)return e(s);let f;try{f=No(n[0],i,o,t)}catch(c){return e(c)}e(null,f)})},generateKeyPairSync:(r,t)=>{const e=Ro(r,t),{publicKey:n,privateKey:s}=zc(...e);return No(e[0],n,s,t)}};const{AgentProtocol:ah,BaseAgent:ch,createAgent:hh,CygwinAgent:uh,OpenSSHAgent:lh,PageantAgent:dh}=cs,{SSHTTPAgent:Ah,SSHTTPSAgent:gh}=hs,{parseKey:_h}=Rn,{flagsToString:Eh,OPEN_MODE:ph,STATUS_CODE:bh,stringToFlags:Ih}=Lr;var xh={AgentProtocol:ah,BaseAgent:ch,createAgent:hh,Client:So,CygwinAgent:uh,HTTPAgent:Ah,HTTPSAgent:gh,OpenSSHAgent:lh,PageantAgent:dh,Server:Xc,utils:{parseKey:_h,...fh,sftp:{flagsToString:Eh,OPEN_MODE:ph,STATUS_CODE:bh,stringToFlags:Ih}}};class yh{constructor(t){_r(this,"config",{host:"",port:"",username:"",password:"",namespace:"",imageStore:"",delay:0,fileDir:"",dockerfile:{name:"Dockerfile",content:["FROM harbor.yunjingtech.cn:30002/yj-base/nginx:latest","RUN rm -rf /usr/share/nginx/html/*","COPY dist /usr/share/nginx/html/"]},upload:{name:"upload.sh",content:["#!/bin/sh","tag=`basename \\`pwd\\``:`date +%Y%m%d`",'if [ -n "$1" ]; then',' echo "param is $1"'," docker build -t harbor.yunjingtech.cn:30002/$1/$tag ."," docker push harbor.yunjingtech.cn:30002/$1/$tag"," echo 镜像地址: harbor.yunjingtech.cn:30002/$1/$tag","else"," docker build -t harbor.yunjingtech.cn:30002/dev-images/$tag ."," docker push harbor.yunjingtech.cn:30002/dev-images/$tag"," echo 镜像地址: harbor.yunjingtech.cn:30002/dev-images/$tag","fi"]},dist:{name:"dist"}});_r(this,"ssh2Conn",null);_r(this,"uploading",!1);_r(this,"trim",null);return this.config=Object.assign(this.config,t),{name:"yj-deploy",isPut:this.isPut.bind(this),upload:this.upload.bind(this),apply:this.apply.bind(this),closeBundle:this.isPut.bind(this)}}apply(t){return t&&t.hooks&&t.hooks.done&&t.hooks.done.tap("yj-deploy",()=>{this.isPut()}),"build"}isPut(){this.getArgv("--deploy")!=null&&(clearTimeout(this.trim),this.trim=setTimeout(()=>{this.upload()},this.config.delay||0))}upload(){if(console.log("-------------- sftp-start --------------"),!this.config.host){console.log("- 请配置跳板机地址 host");return}if(!this.config.port){console.log("- 请配置跳板机端口 port");return}if(!this.config.username){console.log("- 请配置跳板机账号 username");return}if(!this.config.password){console.log("- 请配置跳板机密码 password");return}this.uploading||(this.ssh2Conn=new xh.Client,this.ssh2Conn.on("ready",()=>{console.log("- 跳板机连接成功!"),this.ssh2Conn.sftp(async(t,e)=>{if(t)throw console.log("- sftp连接失败"),t;if(!this.config.namespace)throw console.log("- 请配置项目命名空间 namespace"),t;this.uploading=!0,this.upLoadProject(e,`/root/${this.config.namespace}`)})}).connect({host:this.config.host,port:this.config.port,username:this.config.username,password:this.config.password}),this.ssh2Conn.on("error",t=>{console.log(`- 连接失败: ${t}`)}),this.ssh2Conn.on("end",()=>{this.uploading=!1,console.log("- 已断开连接"),console.log("-------------- sftp-end --------------")}))}onShell(t){return new Promise((e,n)=>{this.ssh2Conn.shell((s,i)=>{if(s)throw s;let o=[];i.on("close",()=>{e(o.toString())}).on("data",f=>{o.push(`
20
+ `+f)}).stderr.on("data",f=>{console.log(`- 远程命令错误:
21
+ `+f),this.ssh2Conn.end(),n(f)}),i.end(t+`
22
+ exit
23
+ `)})})}projectInit(t,e){return new Promise((n,s)=>{t.mkdir(e,async i=>{if(i)s();else{console.log("- 正在创建dockerfile");const o=`${e}/${this.config.dockerfile.name}`;await this.onShell(`touch ${o}`),await this.onShell(`echo '${this.config.dockerfile.content.join(`
24
+ `)}' > ${o}`),console.log("- 正在创建upload.sh");const f=`${e}/${this.config.upload.name}`;await this.onShell(`touch ${f}`),await this.onShell(`echo '${this.config.upload.content.join(`
25
+ `)}' > ${f}`),n()}})})}upLoadProject(t,e){t.readdir(e,async n=>{if(n){console.log("- 跳板机不存在项目, 开始创建项目"),this.projectInit(t,e).then(()=>{console.log(`- ${this.config.namespace}项目创建成功`),this.upLoadProject(t,e)}).catch(()=>{throw console.log("- 创建项目失败"),n});return}console.log("- 开始上传文件");const s=`${e}/${this.config.dist.name}`;if(await this.onShell(`rm -rf ${s}`),await this.onShell(`mkdir ${s}`),!this.config.fileDir)throw console.log("- 请配置本地文件目录 fileDir"),n;const i=await this.getFilesInDirectory(this.config.fileDir);if(i.length===0)throw console.log("- 待上传目录为空,请检查"),n;let o=0;const f=(A,I=0)=>A.isDirectory?this.onShell(`mkdir ${s}${A.remotePath}`):new Promise((y,w)=>{try{const R=Yn.createReadStream(A.localPath),M=t.createWriteStream(`${e}/dist${A.remotePath}`);M.on("close",()=>{this.progressBar(++o,I),y()}),M.on("error",ce=>{throw console.log(`- 文件 ${A.remotePath} 上传失败:${ce}`),w(ce),ce}),R.pipe(M)}catch(R){w(R)}}),c=i.filter(A=>A.isDirectory);await Promise.all(c.map(A=>f(A))),await new Promise(A=>{setTimeout(()=>{A()},500)});const h=i.filter(A=>!A.isDirectory);await Promise.all(h.map(A=>f(A,h.length))),console.log("- 文件上传成功"),console.log("- 开始推送镜像");let g=`cd ${e} && sh ${this.config.upload.name}`;const u=this.getArgv("--imageStore")||this.config.imageStore;u&&(g+=` ${u}`);const d=await this.onShell(g);console.log(d),console.log("- 镜像推送完成"),this.ssh2Conn.end()})}progressBar(t,e,n=25){let s=(t/e).toFixed(4),i=Math.floor(s*n),o="";for(let h=0;h<i;h++)o+="█";let f="";for(let h=0;h<n-i;h++)f+="░";let c=`- 上传进度: ${o}${f} ${(100*s).toFixed(2)}% (${t}/${e})`;Go.stdout(c),t==e&&console.log("")}getFilesInDirectory(t){const e=[];return new Promise((n,s)=>{const i=(o,f)=>{Yn.readdirSync(o).forEach(h=>{const g=Yn.join(o,h),d=Yn.statSync(g).isDirectory();e.push({isDirectory:d,localPath:g,remotePath:`${f}${h}`}),d&&i(g,`${f}${h}/`)})};i(t,"/"),n(e)})}getArgv(t){const e=process.argv;let n;return e.forEach(s=>{s.indexOf(t)>-1&&(n=s.split("=")[1]||"")}),n}}return yh});