typescript-virtual-container 1.4.5 → 1.4.6
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.
- package/README.md +1 -1
- package/builds/self-standalone.js +2 -2
- package/builds/self-standalone.js.map +2 -2
- package/builds/standalone-wo-sftp.js +38 -37
- package/builds/standalone-wo-sftp.js.map +3 -3
- package/builds/standalone.cjs +491 -0
- package/builds/standalone.cjs.map +7 -0
- package/builds/standalone.js +2 -1
- package/builds/standalone.js.map +3 -3
- package/dist/commands/man.js +1 -1
- package/dist/commands/man.js.map +1 -1
- package/dist/self-standalone.js +1 -0
- package/dist/self-standalone.js.map +1 -1
- package/dist/standalone.js +7 -3
- package/dist/standalone.js.map +1 -1
- package/docs/classes/HoneyPot.html +8 -8
- package/docs/classes/SshClient.html +18 -18
- package/docs/classes/VirtualFileSystem.html +29 -29
- package/docs/classes/VirtualPackageManager.html +12 -12
- package/docs/classes/VirtualSftpServer.html +3 -3
- package/docs/classes/VirtualShell.html +22 -22
- package/docs/classes/VirtualSshServer.html +5 -5
- package/docs/classes/VirtualUserManager.html +26 -26
- package/docs/functions/assertDiff.html +1 -1
- package/docs/functions/diffSnapshots.html +1 -1
- package/docs/functions/formatDiff.html +1 -1
- package/docs/functions/getArg.html +1 -1
- package/docs/functions/getFlag.html +1 -1
- package/docs/functions/ifFlag.html +1 -1
- package/docs/index.html +1 -1
- package/docs/interfaces/AuditLogEntry.html +2 -2
- package/docs/interfaces/CommandContext.html +11 -11
- package/docs/interfaces/CommandResult.html +12 -12
- package/docs/interfaces/ExecStream.html +5 -5
- package/docs/interfaces/HoneyPotStats.html +2 -2
- package/docs/interfaces/InstalledPackage.html +10 -10
- package/docs/interfaces/NanoEditorSession.html +4 -4
- package/docs/interfaces/PackageDefinition.html +13 -13
- package/docs/interfaces/PackageFile.html +4 -4
- package/docs/interfaces/RemoveOptions.html +2 -2
- package/docs/interfaces/ShellEnv.html +3 -3
- package/docs/interfaces/ShellModule.html +7 -7
- package/docs/interfaces/ShellProperties.html +4 -4
- package/docs/interfaces/ShellStream.html +6 -6
- package/docs/interfaces/SudoChallenge.html +8 -8
- package/docs/interfaces/VfsBaseNode.html +6 -6
- package/docs/interfaces/VfsDiff.html +5 -5
- package/docs/interfaces/VfsDiffEntry.html +3 -3
- package/docs/interfaces/VfsDiffModified.html +5 -5
- package/docs/interfaces/VfsDirectoryNode.html +7 -7
- package/docs/interfaces/VfsFileNode.html +8 -8
- package/docs/interfaces/VfsOptions.html +3 -3
- package/docs/interfaces/VfsSnapshot.html +2 -2
- package/docs/interfaces/VfsSnapshotBaseNode.html +3 -3
- package/docs/interfaces/VfsSnapshotDirectoryNode.html +4 -4
- package/docs/interfaces/VfsSnapshotFileNode.html +5 -5
- package/docs/interfaces/WriteFileOptions.html +3 -3
- package/docs/types/CommandMode.html +1 -1
- package/docs/types/CommandOutcome.html +1 -1
- package/docs/types/VfsNodeStats.html +1 -1
- package/docs/types/VfsNodeType.html +1 -1
- package/docs/types/VfsPersistenceMode.html +1 -1
- package/docs/types/VfsSnapshotNode.html +1 -1
- package/package.json +4 -4
- package/src/commands/man.ts +1 -1
- package/src/self-standalone.ts +1 -1
- package/src/standalone.ts +8 -3
- package/docs/docs/.nojekyll +0 -1
- package/docs/docs/assets/hierarchy.js +0 -1
- package/docs/docs/assets/highlight.css +0 -162
- package/docs/docs/assets/icons.js +0 -18
- package/docs/docs/assets/icons.svg +0 -1
- package/docs/docs/assets/main.js +0 -60
- package/docs/docs/assets/navigation.js +0 -1
- package/docs/docs/assets/search.js +0 -1
- package/docs/docs/assets/style.css +0 -1633
- package/docs/docs/hierarchy.html +0 -1
- package/docs/docs/index.html +0 -1842
- package/docs/docs/media/LICENSE +0 -21
- package/docs/docs/modules.html +0 -1
- package/typedoc.json +0 -8
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
"use strict";var np=Object.create;var vc=Object.defineProperty;var rp=Object.getOwnPropertyDescriptor;var ip=Object.getOwnPropertyNames;var sp=Object.getPrototypeOf,op=Object.prototype.hasOwnProperty;var ct=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var ap=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ip(t))!op.call(n,s)&&s!==e&&vc(n,s,{get:()=>t[s],enumerable:!(r=rp(t,s))||r.enumerable});return n};var zt=(n,t,e)=>(e=n!=null?np(sp(n)):{},ap(t||!n||!n.__esModule?vc(e,"default",{value:n,enumerable:!0}):e,n));var qi=ct((Ly,Bc)=>{Bc.exports={newInvalidAsn1Error:function(n){var t=new Error;return t.name="InvalidAsn1Error",t.message=n||"",t}}});var Ki=ct(($y,Rc)=>{Rc.exports={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}});var lo=ct((Dy,Nc)=>{"use strict";var Vi=require("buffer"),wr=Vi.Buffer,dn={},hn;for(hn in Vi)Vi.hasOwnProperty(hn)&&(hn==="SlowBuffer"||hn==="Buffer"||(dn[hn]=Vi[hn]));var Ir=dn.Buffer={};for(hn in wr)wr.hasOwnProperty(hn)&&(hn==="allocUnsafe"||hn==="allocUnsafeSlow"||(Ir[hn]=wr[hn]));dn.Buffer.prototype=wr.prototype;(!Ir.from||Ir.from===Uint8Array.from)&&(Ir.from=function(n,t,e){if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof n);if(n&&typeof n.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);return wr(n,t,e)});Ir.alloc||(Ir.alloc=function(n,t,e){if(typeof n!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof n);if(n<0||n>=2*(1<<30))throw new RangeError('The value "'+n+'" is invalid for option "size"');var r=wr(n);return!t||t.length===0?r.fill(0):typeof e=="string"?r.fill(t,e):r.fill(t),r});if(!dn.kStringMaxLength)try{dn.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}dn.constants||(dn.constants={MAX_LENGTH:dn.kMaxLength},dn.kStringMaxLength&&(dn.constants.MAX_STRING_LENGTH=dn.kStringMaxLength));Nc.exports=dn});var Lc=ct((Uy,Tc)=>{var cp=require("assert"),Pc=lo().Buffer,ii=Ki(),lp=qi(),Cr=lp.newInvalidAsn1Error;function Yt(n){if(!n||!Pc.isBuffer(n))throw new TypeError("data must be a node Buffer");this._buf=n,this._size=n.length,this._len=0,this._offset=0}Object.defineProperty(Yt.prototype,"length",{enumerable:!0,get:function(){return this._len}});Object.defineProperty(Yt.prototype,"offset",{enumerable:!0,get:function(){return this._offset}});Object.defineProperty(Yt.prototype,"remain",{get:function(){return this._size-this._offset}});Object.defineProperty(Yt.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}});Yt.prototype.readByte=function(n){if(this._size-this._offset<1)return null;var t=this._buf[this._offset]&255;return n||(this._offset+=1),t};Yt.prototype.peek=function(){return this.readByte(!0)};Yt.prototype.readLength=function(n){if(n===void 0&&(n=this._offset),n>=this._size)return null;var t=this._buf[n++]&255;if(t===null)return null;if((t&128)===128){if(t&=127,t===0)throw Cr("Indefinite length not supported");if(t>4)throw Cr("encoding too long");if(this._size-n<t)return null;this._len=0;for(var e=0;e<t;e++)this._len=(this._len<<8)+(this._buf[n++]&255)}else this._len=t;return n};Yt.prototype.readSequence=function(n){var t=this.peek();if(t===null)return null;if(n!==void 0&&n!==t)throw Cr("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);return e===null?null:(this._offset=e,t)};Yt.prototype.readInt=function(){return this._readTag(ii.Integer)};Yt.prototype.readBoolean=function(){return this._readTag(ii.Boolean)!==0};Yt.prototype.readEnumeration=function(){return this._readTag(ii.Enumeration)};Yt.prototype.readString=function(n,t){n||(n=ii.OctetString);var e=this.peek();if(e===null)return null;if(e!==n)throw Cr("Expected 0x"+n.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);if(r===null||this.length>this._size-r)return null;if(this._offset=r,this.length===0)return t?Pc.alloc(0):"";var s=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?s:s.toString("utf8")};Yt.prototype.readOID=function(n){n||(n=ii.OID);var t=this.readString(n,!0);if(t===null)return null;for(var e=[],r=0,s=0;s<t.length;s++){var i=t[s]&255;r<<=7,r+=i&127,(i&128)===0&&(e.push(r),r=0)}return r=e.shift(),e.unshift(r%40),e.unshift(r/40>>0),e.join(".")};Yt.prototype._readTag=function(n){cp.ok(n!==void 0);var t=this.peek();if(t===null)return null;if(t!==n)throw Cr("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);if(e===null)return null;if(this.length>4)throw Cr("Integer too long: "+this.length);if(this.length>this._size-e)return null;this._offset=e;for(var r=this._buf[this._offset],s=0,i=0;i<this.length;i++)s<<=8,s|=this._buf[this._offset++]&255;return(r&128)===128&&i!==4&&(s-=1<<i*8),s>>0};Tc.exports=Yt});var Dc=ct((Oy,$c)=>{var Hn=require("assert"),Gi=lo().Buffer,Qn=Ki(),fp=qi(),zi=fp.newInvalidAsn1Error,up={size:1024,growthFactor:8};function dp(n,t){Hn.ok(n),Hn.equal(typeof n,"object"),Hn.ok(t),Hn.equal(typeof t,"object");var e=Object.getOwnPropertyNames(n);return e.forEach(function(r){if(!t[r]){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s)}}),t}function Vt(n){n=dp(up,n||{}),this._buf=Gi.alloc(n.size||1024),this._size=this._buf.length,this._offset=0,this._options=n,this._seq=[]}Object.defineProperty(Vt.prototype,"buffer",{get:function(){if(this._seq.length)throw zi(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}});Vt.prototype.writeByte=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=n};Vt.prototype.writeInt=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");typeof t!="number"&&(t=Qn.Integer);for(var e=4;((n&4286578688)===0||(n&4286578688)===-8388608)&&e>1;)e--,n<<=8;if(e>4)throw zi("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++]=(n&4278190080)>>>24,n<<=8};Vt.prototype.writeNull=function(){this.writeByte(Qn.Null),this.writeByte(0)};Vt.prototype.writeEnumeration=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");return typeof t!="number"&&(t=Qn.Enumeration),this.writeInt(n,t)};Vt.prototype.writeBoolean=function(n,t){if(typeof n!="boolean")throw new TypeError("argument must be a Boolean");typeof t!="number"&&(t=Qn.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=n?255:0};Vt.prototype.writeString=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string (was: "+typeof n+")");typeof t!="number"&&(t=Qn.OctetString);var e=Gi.byteLength(n);this.writeByte(t),this.writeLength(e),e&&(this._ensure(e),this._buf.write(n,this._offset),this._offset+=e)};Vt.prototype.writeBuffer=function(n,t){if(typeof t!="number")throw new TypeError("tag must be a number");if(!Gi.isBuffer(n))throw new TypeError("argument must be a buffer");this.writeByte(t),this.writeLength(n.length),this._ensure(n.length),n.copy(this._buf,this._offset,0,n.length),this._offset+=n.length};Vt.prototype.writeStringArray=function(n){if(!n instanceof Array)throw new TypeError("argument must be an Array[String]");var t=this;n.forEach(function(e){t.writeString(e)})};Vt.prototype.writeOID=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string");if(typeof t!="number"&&(t=Qn.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(n))throw new Error("argument is not a valid OID string");function e(o,a){a<128?o.push(a):a<16384?(o.push(a>>>7|128),o.push(a&127)):a<2097152?(o.push(a>>>14|128),o.push((a>>>7|128)&255),o.push(a&127)):a<268435456?(o.push(a>>>21|128),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127)):(o.push((a>>>28|128)&255),o.push((a>>>21|128)&255),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127))}var r=n.split("."),s=[];s.push(parseInt(r[0],10)*40+parseInt(r[1],10)),r.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)})};Vt.prototype.writeLength=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");if(this._ensure(4),n<=127)this._buf[this._offset++]=n;else if(n<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=n;else if(n<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else if(n<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=n>>16,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else throw zi("Length too long (> 4 bytes)")};Vt.prototype.startSequence=function(n){typeof n!="number"&&(n=Qn.Sequence|Qn.Constructor),this.writeByte(n),this._seq.push(this._offset),this._ensure(3),this._offset+=3};Vt.prototype.endSequence=function(){var n=this._seq.pop(),t=n+3,e=this._offset-t;if(e<=127)this._shift(t,e,-2),this._buf[n]=e;else if(e<=255)this._shift(t,e,-1),this._buf[n]=129,this._buf[n+1]=e;else if(e<=65535)this._buf[n]=130,this._buf[n+1]=e>>8,this._buf[n+2]=e;else if(e<=16777215)this._shift(t,e,1),this._buf[n]=131,this._buf[n+1]=e>>16,this._buf[n+2]=e>>8,this._buf[n+3]=e;else throw zi("Sequence too long")};Vt.prototype._shift=function(n,t,e){Hn.ok(n!==void 0),Hn.ok(t!==void 0),Hn.ok(e),this._buf.copy(this._buf,n+e,n,n+t),this._offset+=e};Vt.prototype._ensure=function(n){if(Hn.ok(n),this._size-this._offset<n){var t=this._size*this._options.growthFactor;t-this._offset<n&&(t+=n);var e=Gi.alloc(t);this._buf.copy(e,0,0,this._offset),this._buf=e,this._size=t}};$c.exports=Vt});var Uc=ct((My,Xi)=>{var fo=qi(),uo=Ki(),hp=Lc(),pp=Dc();Xi.exports={Reader:hp,Writer:pp};for(Yi in uo)uo.hasOwnProperty(Yi)&&(Xi.exports[Yi]=uo[Yi]);var Yi;for(ji in fo)fo.hasOwnProperty(ji)&&(Xi.exports[ji]=fo[ji]);var ji});var si=ct((Fy,Oc)=>{var ho=Uc();Oc.exports={Ber:ho,BerReader:ho.Reader,BerWriter:ho.Writer}});var Mc=ct((Hy,Ji)=>{(function(n){"use strict";var t=function(g){var A,m=new Float64Array(16);if(g)for(A=0;A<g.length;A++)m[A]=g[A];return m},e=function(){throw new Error("no PRNG")},r=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var i=t(),o=t([1]),a=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),f=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),u=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),h=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(g,A,m,d){g[A]=m>>24&255,g[A+1]=m>>16&255,g[A+2]=m>>8&255,g[A+3]=m&255,g[A+4]=d>>24&255,g[A+5]=d>>16&255,g[A+6]=d>>8&255,g[A+7]=d&255}function y(g,A,m,d,E){var $,F=0;for($=0;$<E;$++)F|=g[A+$]^m[d+$];return(1&F-1>>>8)-1}function _(g,A,m,d){return y(g,A,m,d,16)}function x(g,A,m,d){return y(g,A,m,d,32)}function S(g,A,m,d){for(var E=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,$=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,F=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,J=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ae=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,ye=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,ge=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,nt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,Ae=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Le=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,$e=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,He=m[16]&255|(m[17]&255)<<8|(m[18]&255)<<16|(m[19]&255)<<24,Fe=m[20]&255|(m[21]&255)<<8|(m[22]&255)<<16|(m[23]&255)<<24,De=m[24]&255|(m[25]&255)<<8|(m[26]&255)<<16|(m[27]&255)<<24,Oe=m[28]&255|(m[29]&255)<<8|(m[30]&255)<<16|(m[31]&255)<<24,Ue=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,_e=E,xe=$,me=F,Ee=J,be=ae,pe=ye,W=ge,q=nt,re=Ae,X=Le,Z=$e,oe=He,ke=Fe,Qe=De,qe=Oe,We=Ue,I,Ve=0;Ve<20;Ve+=2)I=_e+ke|0,be^=I<<7|I>>>25,I=be+_e|0,re^=I<<9|I>>>23,I=re+be|0,ke^=I<<13|I>>>19,I=ke+re|0,_e^=I<<18|I>>>14,I=pe+xe|0,X^=I<<7|I>>>25,I=X+pe|0,Qe^=I<<9|I>>>23,I=Qe+X|0,xe^=I<<13|I>>>19,I=xe+Qe|0,pe^=I<<18|I>>>14,I=Z+W|0,qe^=I<<7|I>>>25,I=qe+Z|0,me^=I<<9|I>>>23,I=me+qe|0,W^=I<<13|I>>>19,I=W+me|0,Z^=I<<18|I>>>14,I=We+oe|0,Ee^=I<<7|I>>>25,I=Ee+We|0,q^=I<<9|I>>>23,I=q+Ee|0,oe^=I<<13|I>>>19,I=oe+q|0,We^=I<<18|I>>>14,I=_e+Ee|0,xe^=I<<7|I>>>25,I=xe+_e|0,me^=I<<9|I>>>23,I=me+xe|0,Ee^=I<<13|I>>>19,I=Ee+me|0,_e^=I<<18|I>>>14,I=pe+be|0,W^=I<<7|I>>>25,I=W+pe|0,q^=I<<9|I>>>23,I=q+W|0,be^=I<<13|I>>>19,I=be+q|0,pe^=I<<18|I>>>14,I=Z+X|0,oe^=I<<7|I>>>25,I=oe+Z|0,re^=I<<9|I>>>23,I=re+oe|0,X^=I<<13|I>>>19,I=X+re|0,Z^=I<<18|I>>>14,I=We+qe|0,ke^=I<<7|I>>>25,I=ke+We|0,Qe^=I<<9|I>>>23,I=Qe+ke|0,qe^=I<<13|I>>>19,I=qe+Qe|0,We^=I<<18|I>>>14;_e=_e+E|0,xe=xe+$|0,me=me+F|0,Ee=Ee+J|0,be=be+ae|0,pe=pe+ye|0,W=W+ge|0,q=q+nt|0,re=re+Ae|0,X=X+Le|0,Z=Z+$e|0,oe=oe+He|0,ke=ke+Fe|0,Qe=Qe+De|0,qe=qe+Oe|0,We=We+Ue|0,g[0]=_e>>>0&255,g[1]=_e>>>8&255,g[2]=_e>>>16&255,g[3]=_e>>>24&255,g[4]=xe>>>0&255,g[5]=xe>>>8&255,g[6]=xe>>>16&255,g[7]=xe>>>24&255,g[8]=me>>>0&255,g[9]=me>>>8&255,g[10]=me>>>16&255,g[11]=me>>>24&255,g[12]=Ee>>>0&255,g[13]=Ee>>>8&255,g[14]=Ee>>>16&255,g[15]=Ee>>>24&255,g[16]=be>>>0&255,g[17]=be>>>8&255,g[18]=be>>>16&255,g[19]=be>>>24&255,g[20]=pe>>>0&255,g[21]=pe>>>8&255,g[22]=pe>>>16&255,g[23]=pe>>>24&255,g[24]=W>>>0&255,g[25]=W>>>8&255,g[26]=W>>>16&255,g[27]=W>>>24&255,g[28]=q>>>0&255,g[29]=q>>>8&255,g[30]=q>>>16&255,g[31]=q>>>24&255,g[32]=re>>>0&255,g[33]=re>>>8&255,g[34]=re>>>16&255,g[35]=re>>>24&255,g[36]=X>>>0&255,g[37]=X>>>8&255,g[38]=X>>>16&255,g[39]=X>>>24&255,g[40]=Z>>>0&255,g[41]=Z>>>8&255,g[42]=Z>>>16&255,g[43]=Z>>>24&255,g[44]=oe>>>0&255,g[45]=oe>>>8&255,g[46]=oe>>>16&255,g[47]=oe>>>24&255,g[48]=ke>>>0&255,g[49]=ke>>>8&255,g[50]=ke>>>16&255,g[51]=ke>>>24&255,g[52]=Qe>>>0&255,g[53]=Qe>>>8&255,g[54]=Qe>>>16&255,g[55]=Qe>>>24&255,g[56]=qe>>>0&255,g[57]=qe>>>8&255,g[58]=qe>>>16&255,g[59]=qe>>>24&255,g[60]=We>>>0&255,g[61]=We>>>8&255,g[62]=We>>>16&255,g[63]=We>>>24&255}function R(g,A,m,d){for(var E=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,$=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,F=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,J=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ae=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,ye=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,ge=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,nt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,Ae=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Le=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,$e=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,He=m[16]&255|(m[17]&255)<<8|(m[18]&255)<<16|(m[19]&255)<<24,Fe=m[20]&255|(m[21]&255)<<8|(m[22]&255)<<16|(m[23]&255)<<24,De=m[24]&255|(m[25]&255)<<8|(m[26]&255)<<16|(m[27]&255)<<24,Oe=m[28]&255|(m[29]&255)<<8|(m[30]&255)<<16|(m[31]&255)<<24,Ue=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,_e=E,xe=$,me=F,Ee=J,be=ae,pe=ye,W=ge,q=nt,re=Ae,X=Le,Z=$e,oe=He,ke=Fe,Qe=De,qe=Oe,We=Ue,I,Ve=0;Ve<20;Ve+=2)I=_e+ke|0,be^=I<<7|I>>>25,I=be+_e|0,re^=I<<9|I>>>23,I=re+be|0,ke^=I<<13|I>>>19,I=ke+re|0,_e^=I<<18|I>>>14,I=pe+xe|0,X^=I<<7|I>>>25,I=X+pe|0,Qe^=I<<9|I>>>23,I=Qe+X|0,xe^=I<<13|I>>>19,I=xe+Qe|0,pe^=I<<18|I>>>14,I=Z+W|0,qe^=I<<7|I>>>25,I=qe+Z|0,me^=I<<9|I>>>23,I=me+qe|0,W^=I<<13|I>>>19,I=W+me|0,Z^=I<<18|I>>>14,I=We+oe|0,Ee^=I<<7|I>>>25,I=Ee+We|0,q^=I<<9|I>>>23,I=q+Ee|0,oe^=I<<13|I>>>19,I=oe+q|0,We^=I<<18|I>>>14,I=_e+Ee|0,xe^=I<<7|I>>>25,I=xe+_e|0,me^=I<<9|I>>>23,I=me+xe|0,Ee^=I<<13|I>>>19,I=Ee+me|0,_e^=I<<18|I>>>14,I=pe+be|0,W^=I<<7|I>>>25,I=W+pe|0,q^=I<<9|I>>>23,I=q+W|0,be^=I<<13|I>>>19,I=be+q|0,pe^=I<<18|I>>>14,I=Z+X|0,oe^=I<<7|I>>>25,I=oe+Z|0,re^=I<<9|I>>>23,I=re+oe|0,X^=I<<13|I>>>19,I=X+re|0,Z^=I<<18|I>>>14,I=We+qe|0,ke^=I<<7|I>>>25,I=ke+We|0,Qe^=I<<9|I>>>23,I=Qe+ke|0,qe^=I<<13|I>>>19,I=qe+Qe|0,We^=I<<18|I>>>14;g[0]=_e>>>0&255,g[1]=_e>>>8&255,g[2]=_e>>>16&255,g[3]=_e>>>24&255,g[4]=pe>>>0&255,g[5]=pe>>>8&255,g[6]=pe>>>16&255,g[7]=pe>>>24&255,g[8]=Z>>>0&255,g[9]=Z>>>8&255,g[10]=Z>>>16&255,g[11]=Z>>>24&255,g[12]=We>>>0&255,g[13]=We>>>8&255,g[14]=We>>>16&255,g[15]=We>>>24&255,g[16]=W>>>0&255,g[17]=W>>>8&255,g[18]=W>>>16&255,g[19]=W>>>24&255,g[20]=q>>>0&255,g[21]=q>>>8&255,g[22]=q>>>16&255,g[23]=q>>>24&255,g[24]=re>>>0&255,g[25]=re>>>8&255,g[26]=re>>>16&255,g[27]=re>>>24&255,g[28]=X>>>0&255,g[29]=X>>>8&255,g[30]=X>>>16&255,g[31]=X>>>24&255}function H(g,A,m,d){S(g,A,m,d)}function C(g,A,m,d){R(g,A,m,d)}var U=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Q(g,A,m,d,E,$,F){var J=new Uint8Array(16),ae=new Uint8Array(64),ye,ge;for(ge=0;ge<16;ge++)J[ge]=0;for(ge=0;ge<8;ge++)J[ge]=$[ge];for(;E>=64;){for(H(ae,J,F,U),ge=0;ge<64;ge++)g[A+ge]=m[d+ge]^ae[ge];for(ye=1,ge=8;ge<16;ge++)ye=ye+(J[ge]&255)|0,J[ge]=ye&255,ye>>>=8;E-=64,A+=64,d+=64}if(E>0)for(H(ae,J,F,U),ge=0;ge<E;ge++)g[A+ge]=m[d+ge]^ae[ge];return 0}function B(g,A,m,d,E){var $=new Uint8Array(16),F=new Uint8Array(64),J,ae;for(ae=0;ae<16;ae++)$[ae]=0;for(ae=0;ae<8;ae++)$[ae]=d[ae];for(;m>=64;){for(H(F,$,E,U),ae=0;ae<64;ae++)g[A+ae]=F[ae];for(J=1,ae=8;ae<16;ae++)J=J+($[ae]&255)|0,$[ae]=J&255,J>>>=8;m-=64,A+=64}if(m>0)for(H(F,$,E,U),ae=0;ae<m;ae++)g[A+ae]=F[ae];return 0}function b(g,A,m,d,E){var $=new Uint8Array(32);C($,d,E,U);for(var F=new Uint8Array(8),J=0;J<8;J++)F[J]=d[J+16];return B(g,A,m,F,$)}function w(g,A,m,d,E,$,F){var J=new Uint8Array(32);C(J,$,F,U);for(var ae=new Uint8Array(8),ye=0;ye<8;ye++)ae[ye]=$[ye+16];return Q(g,A,m,d,E,ae,J)}var k=function(g){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 A,m,d,E,$,F,J,ae;A=g[0]&255|(g[1]&255)<<8,this.r[0]=A&8191,m=g[2]&255|(g[3]&255)<<8,this.r[1]=(A>>>13|m<<3)&8191,d=g[4]&255|(g[5]&255)<<8,this.r[2]=(m>>>10|d<<6)&7939,E=g[6]&255|(g[7]&255)<<8,this.r[3]=(d>>>7|E<<9)&8191,$=g[8]&255|(g[9]&255)<<8,this.r[4]=(E>>>4|$<<12)&255,this.r[5]=$>>>1&8190,F=g[10]&255|(g[11]&255)<<8,this.r[6]=($>>>14|F<<2)&8191,J=g[12]&255|(g[13]&255)<<8,this.r[7]=(F>>>11|J<<5)&8065,ae=g[14]&255|(g[15]&255)<<8,this.r[8]=(J>>>8|ae<<8)&8191,this.r[9]=ae>>>5&127,this.pad[0]=g[16]&255|(g[17]&255)<<8,this.pad[1]=g[18]&255|(g[19]&255)<<8,this.pad[2]=g[20]&255|(g[21]&255)<<8,this.pad[3]=g[22]&255|(g[23]&255)<<8,this.pad[4]=g[24]&255|(g[25]&255)<<8,this.pad[5]=g[26]&255|(g[27]&255)<<8,this.pad[6]=g[28]&255|(g[29]&255)<<8,this.pad[7]=g[30]&255|(g[31]&255)<<8};k.prototype.blocks=function(g,A,m){for(var d=this.fin?0:2048,E,$,F,J,ae,ye,ge,nt,Ae,Le,$e,He,Fe,De,Oe,Ue,_e,xe,me,Ee=this.h[0],be=this.h[1],pe=this.h[2],W=this.h[3],q=this.h[4],re=this.h[5],X=this.h[6],Z=this.h[7],oe=this.h[8],ke=this.h[9],Qe=this.r[0],qe=this.r[1],We=this.r[2],I=this.r[3],Ve=this.r[4],rt=this.r[5],it=this.r[6],Ke=this.r[7],Ze=this.r[8],et=this.r[9];m>=16;)E=g[A+0]&255|(g[A+1]&255)<<8,Ee+=E&8191,$=g[A+2]&255|(g[A+3]&255)<<8,be+=(E>>>13|$<<3)&8191,F=g[A+4]&255|(g[A+5]&255)<<8,pe+=($>>>10|F<<6)&8191,J=g[A+6]&255|(g[A+7]&255)<<8,W+=(F>>>7|J<<9)&8191,ae=g[A+8]&255|(g[A+9]&255)<<8,q+=(J>>>4|ae<<12)&8191,re+=ae>>>1&8191,ye=g[A+10]&255|(g[A+11]&255)<<8,X+=(ae>>>14|ye<<2)&8191,ge=g[A+12]&255|(g[A+13]&255)<<8,Z+=(ye>>>11|ge<<5)&8191,nt=g[A+14]&255|(g[A+15]&255)<<8,oe+=(ge>>>8|nt<<8)&8191,ke+=nt>>>5|d,Ae=0,Le=Ae,Le+=Ee*Qe,Le+=be*(5*et),Le+=pe*(5*Ze),Le+=W*(5*Ke),Le+=q*(5*it),Ae=Le>>>13,Le&=8191,Le+=re*(5*rt),Le+=X*(5*Ve),Le+=Z*(5*I),Le+=oe*(5*We),Le+=ke*(5*qe),Ae+=Le>>>13,Le&=8191,$e=Ae,$e+=Ee*qe,$e+=be*Qe,$e+=pe*(5*et),$e+=W*(5*Ze),$e+=q*(5*Ke),Ae=$e>>>13,$e&=8191,$e+=re*(5*it),$e+=X*(5*rt),$e+=Z*(5*Ve),$e+=oe*(5*I),$e+=ke*(5*We),Ae+=$e>>>13,$e&=8191,He=Ae,He+=Ee*We,He+=be*qe,He+=pe*Qe,He+=W*(5*et),He+=q*(5*Ze),Ae=He>>>13,He&=8191,He+=re*(5*Ke),He+=X*(5*it),He+=Z*(5*rt),He+=oe*(5*Ve),He+=ke*(5*I),Ae+=He>>>13,He&=8191,Fe=Ae,Fe+=Ee*I,Fe+=be*We,Fe+=pe*qe,Fe+=W*Qe,Fe+=q*(5*et),Ae=Fe>>>13,Fe&=8191,Fe+=re*(5*Ze),Fe+=X*(5*Ke),Fe+=Z*(5*it),Fe+=oe*(5*rt),Fe+=ke*(5*Ve),Ae+=Fe>>>13,Fe&=8191,De=Ae,De+=Ee*Ve,De+=be*I,De+=pe*We,De+=W*qe,De+=q*Qe,Ae=De>>>13,De&=8191,De+=re*(5*et),De+=X*(5*Ze),De+=Z*(5*Ke),De+=oe*(5*it),De+=ke*(5*rt),Ae+=De>>>13,De&=8191,Oe=Ae,Oe+=Ee*rt,Oe+=be*Ve,Oe+=pe*I,Oe+=W*We,Oe+=q*qe,Ae=Oe>>>13,Oe&=8191,Oe+=re*Qe,Oe+=X*(5*et),Oe+=Z*(5*Ze),Oe+=oe*(5*Ke),Oe+=ke*(5*it),Ae+=Oe>>>13,Oe&=8191,Ue=Ae,Ue+=Ee*it,Ue+=be*rt,Ue+=pe*Ve,Ue+=W*I,Ue+=q*We,Ae=Ue>>>13,Ue&=8191,Ue+=re*qe,Ue+=X*Qe,Ue+=Z*(5*et),Ue+=oe*(5*Ze),Ue+=ke*(5*Ke),Ae+=Ue>>>13,Ue&=8191,_e=Ae,_e+=Ee*Ke,_e+=be*it,_e+=pe*rt,_e+=W*Ve,_e+=q*I,Ae=_e>>>13,_e&=8191,_e+=re*We,_e+=X*qe,_e+=Z*Qe,_e+=oe*(5*et),_e+=ke*(5*Ze),Ae+=_e>>>13,_e&=8191,xe=Ae,xe+=Ee*Ze,xe+=be*Ke,xe+=pe*it,xe+=W*rt,xe+=q*Ve,Ae=xe>>>13,xe&=8191,xe+=re*I,xe+=X*We,xe+=Z*qe,xe+=oe*Qe,xe+=ke*(5*et),Ae+=xe>>>13,xe&=8191,me=Ae,me+=Ee*et,me+=be*Ze,me+=pe*Ke,me+=W*it,me+=q*rt,Ae=me>>>13,me&=8191,me+=re*Ve,me+=X*I,me+=Z*We,me+=oe*qe,me+=ke*Qe,Ae+=me>>>13,me&=8191,Ae=(Ae<<2)+Ae|0,Ae=Ae+Le|0,Le=Ae&8191,Ae=Ae>>>13,$e+=Ae,Ee=Le,be=$e,pe=He,W=Fe,q=De,re=Oe,X=Ue,Z=_e,oe=xe,ke=me,A+=16,m-=16;this.h[0]=Ee,this.h[1]=be,this.h[2]=pe,this.h[3]=W,this.h[4]=q,this.h[5]=re,this.h[6]=X,this.h[7]=Z,this.h[8]=oe,this.h[9]=ke},k.prototype.finish=function(g,A){var m=new Uint16Array(10),d,E,$,F;if(this.leftover){for(F=this.leftover,this.buffer[F++]=1;F<16;F++)this.buffer[F]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(d=this.h[1]>>>13,this.h[1]&=8191,F=2;F<10;F++)this.h[F]+=d,d=this.h[F]>>>13,this.h[F]&=8191;for(this.h[0]+=d*5,d=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=d,d=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=d,m[0]=this.h[0]+5,d=m[0]>>>13,m[0]&=8191,F=1;F<10;F++)m[F]=this.h[F]+d,d=m[F]>>>13,m[F]&=8191;for(m[9]-=8192,E=(d^1)-1,F=0;F<10;F++)m[F]&=E;for(E=~E,F=0;F<10;F++)this.h[F]=this.h[F]&E|m[F];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,$=this.h[0]+this.pad[0],this.h[0]=$&65535,F=1;F<8;F++)$=(this.h[F]+this.pad[F]|0)+($>>>16)|0,this.h[F]=$&65535;g[A+0]=this.h[0]>>>0&255,g[A+1]=this.h[0]>>>8&255,g[A+2]=this.h[1]>>>0&255,g[A+3]=this.h[1]>>>8&255,g[A+4]=this.h[2]>>>0&255,g[A+5]=this.h[2]>>>8&255,g[A+6]=this.h[3]>>>0&255,g[A+7]=this.h[3]>>>8&255,g[A+8]=this.h[4]>>>0&255,g[A+9]=this.h[4]>>>8&255,g[A+10]=this.h[5]>>>0&255,g[A+11]=this.h[5]>>>8&255,g[A+12]=this.h[6]>>>0&255,g[A+13]=this.h[6]>>>8&255,g[A+14]=this.h[7]>>>0&255,g[A+15]=this.h[7]>>>8&255},k.prototype.update=function(g,A,m){var d,E;if(this.leftover){for(E=16-this.leftover,E>m&&(E=m),d=0;d<E;d++)this.buffer[this.leftover+d]=g[A+d];if(m-=E,A+=E,this.leftover+=E,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(m>=16&&(E=m-m%16,this.blocks(g,A,E),A+=E,m-=E),m){for(d=0;d<m;d++)this.buffer[this.leftover+d]=g[A+d];this.leftover+=m}};function v(g,A,m,d,E,$){var F=new k($);return F.update(m,d,E),F.finish(g,A),0}function P(g,A,m,d,E,$){var F=new Uint8Array(16);return v(F,0,m,d,E,$),_(g,A,F,0)}function ne(g,A,m,d,E){var $;if(m<32)return-1;for(w(g,0,A,0,m,d,E),v(g,16,g,32,m-32,g),$=0;$<16;$++)g[$]=0;return 0}function z(g,A,m,d,E){var $,F=new Uint8Array(32);if(m<32||(b(F,0,32,d,E),P(A,16,A,32,m-32,F)!==0))return-1;for(w(g,0,A,0,m,d,E),$=0;$<32;$++)g[$]=0;return 0}function Y(g,A){var m;for(m=0;m<16;m++)g[m]=A[m]|0}function te(g){var A,m,d=1;for(A=0;A<16;A++)m=g[A]+d+65535,d=Math.floor(m/65536),g[A]=m-d*65536;g[0]+=d-1+37*(d-1)}function le(g,A,m){for(var d,E=~(m-1),$=0;$<16;$++)d=E&(g[$]^A[$]),g[$]^=d,A[$]^=d}function O(g,A){var m,d,E,$=t(),F=t();for(m=0;m<16;m++)F[m]=A[m];for(te(F),te(F),te(F),d=0;d<2;d++){for($[0]=F[0]-65517,m=1;m<15;m++)$[m]=F[m]-65535-($[m-1]>>16&1),$[m-1]&=65535;$[15]=F[15]-32767-($[14]>>16&1),E=$[15]>>16&1,$[14]&=65535,le(F,$,1-E)}for(m=0;m<16;m++)g[2*m]=F[m]&255,g[2*m+1]=F[m]>>8}function N(g,A){var m=new Uint8Array(32),d=new Uint8Array(32);return O(m,g),O(d,A),x(m,0,d,0)}function L(g){var A=new Uint8Array(32);return O(A,g),A[0]&1}function K(g,A){var m;for(m=0;m<16;m++)g[m]=A[2*m]+(A[2*m+1]<<8);g[15]&=32767}function ee(g,A,m){for(var d=0;d<16;d++)g[d]=A[d]+m[d]}function ue(g,A,m){for(var d=0;d<16;d++)g[d]=A[d]-m[d]}function ie(g,A,m){var d,E,$=0,F=0,J=0,ae=0,ye=0,ge=0,nt=0,Ae=0,Le=0,$e=0,He=0,Fe=0,De=0,Oe=0,Ue=0,_e=0,xe=0,me=0,Ee=0,be=0,pe=0,W=0,q=0,re=0,X=0,Z=0,oe=0,ke=0,Qe=0,qe=0,We=0,I=m[0],Ve=m[1],rt=m[2],it=m[3],Ke=m[4],Ze=m[5],et=m[6],Bt=m[7],ft=m[8],Ct=m[9],kt=m[10],vt=m[11],Dt=m[12],Wt=m[13],qt=m[14],Kt=m[15];d=A[0],$+=d*I,F+=d*Ve,J+=d*rt,ae+=d*it,ye+=d*Ke,ge+=d*Ze,nt+=d*et,Ae+=d*Bt,Le+=d*ft,$e+=d*Ct,He+=d*kt,Fe+=d*vt,De+=d*Dt,Oe+=d*Wt,Ue+=d*qt,_e+=d*Kt,d=A[1],F+=d*I,J+=d*Ve,ae+=d*rt,ye+=d*it,ge+=d*Ke,nt+=d*Ze,Ae+=d*et,Le+=d*Bt,$e+=d*ft,He+=d*Ct,Fe+=d*kt,De+=d*vt,Oe+=d*Dt,Ue+=d*Wt,_e+=d*qt,xe+=d*Kt,d=A[2],J+=d*I,ae+=d*Ve,ye+=d*rt,ge+=d*it,nt+=d*Ke,Ae+=d*Ze,Le+=d*et,$e+=d*Bt,He+=d*ft,Fe+=d*Ct,De+=d*kt,Oe+=d*vt,Ue+=d*Dt,_e+=d*Wt,xe+=d*qt,me+=d*Kt,d=A[3],ae+=d*I,ye+=d*Ve,ge+=d*rt,nt+=d*it,Ae+=d*Ke,Le+=d*Ze,$e+=d*et,He+=d*Bt,Fe+=d*ft,De+=d*Ct,Oe+=d*kt,Ue+=d*vt,_e+=d*Dt,xe+=d*Wt,me+=d*qt,Ee+=d*Kt,d=A[4],ye+=d*I,ge+=d*Ve,nt+=d*rt,Ae+=d*it,Le+=d*Ke,$e+=d*Ze,He+=d*et,Fe+=d*Bt,De+=d*ft,Oe+=d*Ct,Ue+=d*kt,_e+=d*vt,xe+=d*Dt,me+=d*Wt,Ee+=d*qt,be+=d*Kt,d=A[5],ge+=d*I,nt+=d*Ve,Ae+=d*rt,Le+=d*it,$e+=d*Ke,He+=d*Ze,Fe+=d*et,De+=d*Bt,Oe+=d*ft,Ue+=d*Ct,_e+=d*kt,xe+=d*vt,me+=d*Dt,Ee+=d*Wt,be+=d*qt,pe+=d*Kt,d=A[6],nt+=d*I,Ae+=d*Ve,Le+=d*rt,$e+=d*it,He+=d*Ke,Fe+=d*Ze,De+=d*et,Oe+=d*Bt,Ue+=d*ft,_e+=d*Ct,xe+=d*kt,me+=d*vt,Ee+=d*Dt,be+=d*Wt,pe+=d*qt,W+=d*Kt,d=A[7],Ae+=d*I,Le+=d*Ve,$e+=d*rt,He+=d*it,Fe+=d*Ke,De+=d*Ze,Oe+=d*et,Ue+=d*Bt,_e+=d*ft,xe+=d*Ct,me+=d*kt,Ee+=d*vt,be+=d*Dt,pe+=d*Wt,W+=d*qt,q+=d*Kt,d=A[8],Le+=d*I,$e+=d*Ve,He+=d*rt,Fe+=d*it,De+=d*Ke,Oe+=d*Ze,Ue+=d*et,_e+=d*Bt,xe+=d*ft,me+=d*Ct,Ee+=d*kt,be+=d*vt,pe+=d*Dt,W+=d*Wt,q+=d*qt,re+=d*Kt,d=A[9],$e+=d*I,He+=d*Ve,Fe+=d*rt,De+=d*it,Oe+=d*Ke,Ue+=d*Ze,_e+=d*et,xe+=d*Bt,me+=d*ft,Ee+=d*Ct,be+=d*kt,pe+=d*vt,W+=d*Dt,q+=d*Wt,re+=d*qt,X+=d*Kt,d=A[10],He+=d*I,Fe+=d*Ve,De+=d*rt,Oe+=d*it,Ue+=d*Ke,_e+=d*Ze,xe+=d*et,me+=d*Bt,Ee+=d*ft,be+=d*Ct,pe+=d*kt,W+=d*vt,q+=d*Dt,re+=d*Wt,X+=d*qt,Z+=d*Kt,d=A[11],Fe+=d*I,De+=d*Ve,Oe+=d*rt,Ue+=d*it,_e+=d*Ke,xe+=d*Ze,me+=d*et,Ee+=d*Bt,be+=d*ft,pe+=d*Ct,W+=d*kt,q+=d*vt,re+=d*Dt,X+=d*Wt,Z+=d*qt,oe+=d*Kt,d=A[12],De+=d*I,Oe+=d*Ve,Ue+=d*rt,_e+=d*it,xe+=d*Ke,me+=d*Ze,Ee+=d*et,be+=d*Bt,pe+=d*ft,W+=d*Ct,q+=d*kt,re+=d*vt,X+=d*Dt,Z+=d*Wt,oe+=d*qt,ke+=d*Kt,d=A[13],Oe+=d*I,Ue+=d*Ve,_e+=d*rt,xe+=d*it,me+=d*Ke,Ee+=d*Ze,be+=d*et,pe+=d*Bt,W+=d*ft,q+=d*Ct,re+=d*kt,X+=d*vt,Z+=d*Dt,oe+=d*Wt,ke+=d*qt,Qe+=d*Kt,d=A[14],Ue+=d*I,_e+=d*Ve,xe+=d*rt,me+=d*it,Ee+=d*Ke,be+=d*Ze,pe+=d*et,W+=d*Bt,q+=d*ft,re+=d*Ct,X+=d*kt,Z+=d*vt,oe+=d*Dt,ke+=d*Wt,Qe+=d*qt,qe+=d*Kt,d=A[15],_e+=d*I,xe+=d*Ve,me+=d*rt,Ee+=d*it,be+=d*Ke,pe+=d*Ze,W+=d*et,q+=d*Bt,re+=d*ft,X+=d*Ct,Z+=d*kt,oe+=d*vt,ke+=d*Dt,Qe+=d*Wt,qe+=d*qt,We+=d*Kt,$+=38*xe,F+=38*me,J+=38*Ee,ae+=38*be,ye+=38*pe,ge+=38*W,nt+=38*q,Ae+=38*re,Le+=38*X,$e+=38*Z,He+=38*oe,Fe+=38*ke,De+=38*Qe,Oe+=38*qe,Ue+=38*We,E=1,d=$+E+65535,E=Math.floor(d/65536),$=d-E*65536,d=F+E+65535,E=Math.floor(d/65536),F=d-E*65536,d=J+E+65535,E=Math.floor(d/65536),J=d-E*65536,d=ae+E+65535,E=Math.floor(d/65536),ae=d-E*65536,d=ye+E+65535,E=Math.floor(d/65536),ye=d-E*65536,d=ge+E+65535,E=Math.floor(d/65536),ge=d-E*65536,d=nt+E+65535,E=Math.floor(d/65536),nt=d-E*65536,d=Ae+E+65535,E=Math.floor(d/65536),Ae=d-E*65536,d=Le+E+65535,E=Math.floor(d/65536),Le=d-E*65536,d=$e+E+65535,E=Math.floor(d/65536),$e=d-E*65536,d=He+E+65535,E=Math.floor(d/65536),He=d-E*65536,d=Fe+E+65535,E=Math.floor(d/65536),Fe=d-E*65536,d=De+E+65535,E=Math.floor(d/65536),De=d-E*65536,d=Oe+E+65535,E=Math.floor(d/65536),Oe=d-E*65536,d=Ue+E+65535,E=Math.floor(d/65536),Ue=d-E*65536,d=_e+E+65535,E=Math.floor(d/65536),_e=d-E*65536,$+=E-1+37*(E-1),E=1,d=$+E+65535,E=Math.floor(d/65536),$=d-E*65536,d=F+E+65535,E=Math.floor(d/65536),F=d-E*65536,d=J+E+65535,E=Math.floor(d/65536),J=d-E*65536,d=ae+E+65535,E=Math.floor(d/65536),ae=d-E*65536,d=ye+E+65535,E=Math.floor(d/65536),ye=d-E*65536,d=ge+E+65535,E=Math.floor(d/65536),ge=d-E*65536,d=nt+E+65535,E=Math.floor(d/65536),nt=d-E*65536,d=Ae+E+65535,E=Math.floor(d/65536),Ae=d-E*65536,d=Le+E+65535,E=Math.floor(d/65536),Le=d-E*65536,d=$e+E+65535,E=Math.floor(d/65536),$e=d-E*65536,d=He+E+65535,E=Math.floor(d/65536),He=d-E*65536,d=Fe+E+65535,E=Math.floor(d/65536),Fe=d-E*65536,d=De+E+65535,E=Math.floor(d/65536),De=d-E*65536,d=Oe+E+65535,E=Math.floor(d/65536),Oe=d-E*65536,d=Ue+E+65535,E=Math.floor(d/65536),Ue=d-E*65536,d=_e+E+65535,E=Math.floor(d/65536),_e=d-E*65536,$+=E-1+37*(E-1),g[0]=$,g[1]=F,g[2]=J,g[3]=ae,g[4]=ye,g[5]=ge,g[6]=nt,g[7]=Ae,g[8]=Le,g[9]=$e,g[10]=He,g[11]=Fe,g[12]=De,g[13]=Oe,g[14]=Ue,g[15]=_e}function je(g,A){ie(g,A,A)}function lt(g,A){var m=t(),d;for(d=0;d<16;d++)m[d]=A[d];for(d=253;d>=0;d--)je(m,m),d!==2&&d!==4&&ie(m,m,A);for(d=0;d<16;d++)g[d]=m[d]}function sn(g,A){var m=t(),d;for(d=0;d<16;d++)m[d]=A[d];for(d=250;d>=0;d--)je(m,m),d!==1&&ie(m,m,A);for(d=0;d<16;d++)g[d]=m[d]}function mr(g,A,m){var d=new Uint8Array(32),E=new Float64Array(80),$,F,J=t(),ae=t(),ye=t(),ge=t(),nt=t(),Ae=t();for(F=0;F<31;F++)d[F]=A[F];for(d[31]=A[31]&127|64,d[0]&=248,K(E,m),F=0;F<16;F++)ae[F]=E[F],ge[F]=J[F]=ye[F]=0;for(J[0]=ge[0]=1,F=254;F>=0;--F)$=d[F>>>3]>>>(F&7)&1,le(J,ae,$),le(ye,ge,$),ee(nt,J,ye),ue(J,J,ye),ee(ye,ae,ge),ue(ae,ae,ge),je(ge,nt),je(Ae,J),ie(J,ye,J),ie(ye,ae,nt),ee(nt,J,ye),ue(J,J,ye),je(ae,J),ue(ye,ge,Ae),ie(J,ye,a),ee(J,J,ge),ie(ye,ye,J),ie(J,ge,Ae),ie(ge,ae,E),je(ae,nt),le(J,ae,$),le(ye,ge,$);for(F=0;F<16;F++)E[F+16]=J[F],E[F+32]=ye[F],E[F+48]=ae[F],E[F+64]=ge[F];var Le=E.subarray(32),$e=E.subarray(16);return lt(Le,Le),ie($e,$e,Le),O(g,$e),0}function Ar(g,A){return mr(g,A,s)}function Rn(g,A){return e(A,32),Ar(g,A)}function yr(g,A,m){var d=new Uint8Array(32);return mr(d,m,A),C(g,r,d,U)}var Zr=ne,Qi=z;function ei(g,A,m,d,E,$){var F=new Uint8Array(32);return yr(F,E,$),Zr(g,A,m,d,F)}function _r(g,A,m,d,E,$){var F=new Uint8Array(32);return yr(F,E,$),Qi(g,A,m,d,F)}var Er=[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 j(g,A,m,d){for(var E=new Int32Array(16),$=new Int32Array(16),F,J,ae,ye,ge,nt,Ae,Le,$e,He,Fe,De,Oe,Ue,_e,xe,me,Ee,be,pe,W,q,re,X,Z,oe,ke=g[0],Qe=g[1],qe=g[2],We=g[3],I=g[4],Ve=g[5],rt=g[6],it=g[7],Ke=A[0],Ze=A[1],et=A[2],Bt=A[3],ft=A[4],Ct=A[5],kt=A[6],vt=A[7],Dt=0;d>=128;){for(be=0;be<16;be++)pe=8*be+Dt,E[be]=m[pe+0]<<24|m[pe+1]<<16|m[pe+2]<<8|m[pe+3],$[be]=m[pe+4]<<24|m[pe+5]<<16|m[pe+6]<<8|m[pe+7];for(be=0;be<80;be++)if(F=ke,J=Qe,ae=qe,ye=We,ge=I,nt=Ve,Ae=rt,Le=it,$e=Ke,He=Ze,Fe=et,De=Bt,Oe=ft,Ue=Ct,_e=kt,xe=vt,W=it,q=vt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=(I>>>14|ft<<18)^(I>>>18|ft<<14)^(ft>>>9|I<<23),q=(ft>>>14|I<<18)^(ft>>>18|I<<14)^(I>>>9|ft<<23),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=I&Ve^~I&rt,q=ft&Ct^~ft&kt,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=Er[be*2],q=Er[be*2+1],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=E[be%16],q=$[be%16],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,me=Z&65535|oe<<16,Ee=re&65535|X<<16,W=me,q=Ee,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=(ke>>>28|Ke<<4)^(Ke>>>2|ke<<30)^(Ke>>>7|ke<<25),q=(Ke>>>28|ke<<4)^(ke>>>2|Ke<<30)^(ke>>>7|Ke<<25),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=ke&Qe^ke&qe^Qe&qe,q=Ke&Ze^Ke&et^Ze&et,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,Le=Z&65535|oe<<16,xe=re&65535|X<<16,W=ye,q=De,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=me,q=Ee,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,ye=Z&65535|oe<<16,De=re&65535|X<<16,Qe=F,qe=J,We=ae,I=ye,Ve=ge,rt=nt,it=Ae,ke=Le,Ze=$e,et=He,Bt=Fe,ft=De,Ct=Oe,kt=Ue,vt=_e,Ke=xe,be%16===15)for(pe=0;pe<16;pe++)W=E[pe],q=$[pe],re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=E[(pe+9)%16],q=$[(pe+9)%16],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,me=E[(pe+1)%16],Ee=$[(pe+1)%16],W=(me>>>1|Ee<<31)^(me>>>8|Ee<<24)^me>>>7,q=(Ee>>>1|me<<31)^(Ee>>>8|me<<24)^(Ee>>>7|me<<25),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,me=E[(pe+14)%16],Ee=$[(pe+14)%16],W=(me>>>19|Ee<<13)^(Ee>>>29|me<<3)^me>>>6,q=(Ee>>>19|me<<13)^(me>>>29|Ee<<3)^(Ee>>>6|me<<26),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,E[pe]=Z&65535|oe<<16,$[pe]=re&65535|X<<16;W=ke,q=Ke,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[0],q=A[0],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[0]=ke=Z&65535|oe<<16,A[0]=Ke=re&65535|X<<16,W=Qe,q=Ze,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[1],q=A[1],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[1]=Qe=Z&65535|oe<<16,A[1]=Ze=re&65535|X<<16,W=qe,q=et,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[2],q=A[2],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[2]=qe=Z&65535|oe<<16,A[2]=et=re&65535|X<<16,W=We,q=Bt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[3],q=A[3],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[3]=We=Z&65535|oe<<16,A[3]=Bt=re&65535|X<<16,W=I,q=ft,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[4],q=A[4],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[4]=I=Z&65535|oe<<16,A[4]=ft=re&65535|X<<16,W=Ve,q=Ct,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[5],q=A[5],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[5]=Ve=Z&65535|oe<<16,A[5]=Ct=re&65535|X<<16,W=rt,q=kt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[6],q=A[6],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[6]=rt=Z&65535|oe<<16,A[6]=kt=re&65535|X<<16,W=it,q=vt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[7],q=A[7],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[7]=it=Z&65535|oe<<16,A[7]=vt=re&65535|X<<16,Dt+=128,d-=128}return d}function he(g,A,m){var d=new Int32Array(8),E=new Int32Array(8),$=new Uint8Array(256),F,J=m;for(d[0]=1779033703,d[1]=3144134277,d[2]=1013904242,d[3]=2773480762,d[4]=1359893119,d[5]=2600822924,d[6]=528734635,d[7]=1541459225,E[0]=4089235720,E[1]=2227873595,E[2]=4271175723,E[3]=1595750129,E[4]=2917565137,E[5]=725511199,E[6]=4215389547,E[7]=327033209,j(d,E,A,m),m%=128,F=0;F<m;F++)$[F]=A[J-m+F];for($[m]=128,m=256-128*(m<112?1:0),$[m-9]=0,p($,m-8,J/536870912|0,J<<3),j(d,E,$,m),F=0;F<8;F++)p(g,8*F,d[F],E[F]);return 0}function Se(g,A){var m=t(),d=t(),E=t(),$=t(),F=t(),J=t(),ae=t(),ye=t(),ge=t();ue(m,g[1],g[0]),ue(ge,A[1],A[0]),ie(m,m,ge),ee(d,g[0],g[1]),ee(ge,A[0],A[1]),ie(d,d,ge),ie(E,g[3],A[3]),ie(E,E,l),ie($,g[2],A[2]),ee($,$,$),ue(F,d,m),ue(J,$,E),ee(ae,$,E),ee(ye,d,m),ie(g[0],F,J),ie(g[1],ye,ae),ie(g[2],ae,J),ie(g[3],F,ye)}function Te(g,A,m){var d;for(d=0;d<4;d++)le(g[d],A[d],m)}function Xe(g,A){var m=t(),d=t(),E=t();lt(E,A[2]),ie(m,A[0],E),ie(d,A[1],E),O(g,d),g[31]^=L(m)<<7}function Tt(g,A,m){var d,E;for(Y(g[0],i),Y(g[1],o),Y(g[2],o),Y(g[3],i),E=255;E>=0;--E)d=m[E/8|0]>>(E&7)&1,Te(g,A,d),Se(A,g),Se(g,g),Te(g,A,d)}function Sn(g,A){var m=[t(),t(),t(),t()];Y(m[0],f),Y(m[1],u),Y(m[2],o),ie(m[3],f,u),Tt(g,m,A)}function on(g,A,m){var d=new Uint8Array(64),E=[t(),t(),t(),t()],$;for(m||e(A,32),he(d,A,32),d[0]&=248,d[31]&=127,d[31]|=64,Sn(E,d),Xe(g,E),$=0;$<32;$++)A[$+32]=g[$];return 0}var br=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 ot(g,A){var m,d,E,$;for(d=63;d>=32;--d){for(m=0,E=d-32,$=d-12;E<$;++E)A[E]+=m-16*A[d]*br[E-(d-32)],m=A[E]+128>>8,A[E]-=m*256;A[E]+=m,A[d]=0}for(m=0,E=0;E<32;E++)A[E]+=m-(A[31]>>4)*br[E],m=A[E]>>8,A[E]&=255;for(E=0;E<32;E++)A[E]-=m*br[E];for(d=0;d<32;d++)A[d+1]+=A[d]>>8,g[d]=A[d]&255}function Ut(g){var A=new Float64Array(64),m;for(m=0;m<64;m++)A[m]=g[m];for(m=0;m<64;m++)g[m]=0;ot(g,A)}function $t(g,A,m,d){var E=new Uint8Array(64),$=new Uint8Array(64),F=new Uint8Array(64),J,ae,ye=new Float64Array(64),ge=[t(),t(),t(),t()];he(E,d,32),E[0]&=248,E[31]&=127,E[31]|=64;var nt=m+64;for(J=0;J<m;J++)g[64+J]=A[J];for(J=0;J<32;J++)g[32+J]=E[32+J];for(he(F,g.subarray(32),m+32),Ut(F),Sn(ge,F),Xe(g,ge),J=32;J<64;J++)g[J]=d[J];for(he($,g,m+64),Ut($),J=0;J<64;J++)ye[J]=0;for(J=0;J<32;J++)ye[J]=F[J];for(J=0;J<32;J++)for(ae=0;ae<32;ae++)ye[J+ae]+=$[J]*E[ae];return ot(g.subarray(32),ye),nt}function wt(g,A){var m=t(),d=t(),E=t(),$=t(),F=t(),J=t(),ae=t();return Y(g[2],o),K(g[1],A),je(E,g[1]),ie($,E,c),ue(E,E,g[2]),ee($,g[2],$),je(F,$),je(J,F),ie(ae,J,F),ie(m,ae,E),ie(m,m,$),sn(m,m),ie(m,m,E),ie(m,m,$),ie(m,m,$),ie(g[0],m,$),je(d,g[0]),ie(d,d,$),N(d,E)&&ie(g[0],g[0],h),je(d,g[0]),ie(d,d,$),N(d,E)?-1:(L(g[0])===A[31]>>7&&ue(g[0],i,g[0]),ie(g[3],g[0],g[1]),0)}function pt(g,A,m,d){var E,$,F=new Uint8Array(32),J=new Uint8Array(64),ae=[t(),t(),t(),t()],ye=[t(),t(),t(),t()];if($=-1,m<64||wt(ye,d))return-1;for(E=0;E<m;E++)g[E]=A[E];for(E=0;E<32;E++)g[E+32]=d[E];if(he(J,g,m),Ut(J),Tt(ae,ye,J),Sn(ye,A.subarray(32)),Se(ae,ye),Xe(F,ae),m-=64,x(A,0,F,0)){for(E=0;E<m;E++)g[E]=0;return-1}for(E=0;E<m;E++)g[E]=A[E+64];return $=m,$}var un=32,It=24,ir=32,xr=16,ti=32,Wi=32,ni=32,ri=32,oo=32,Ic=It,Zh=ir,ep=xr,Nn=64,sr=32,Sr=64,ao=32,co=64;n.lowlevel={crypto_core_hsalsa20:C,crypto_stream_xor:w,crypto_stream:b,crypto_stream_salsa20_xor:Q,crypto_stream_salsa20:B,crypto_onetimeauth:v,crypto_onetimeauth_verify:P,crypto_verify_16:_,crypto_verify_32:x,crypto_secretbox:ne,crypto_secretbox_open:z,crypto_scalarmult:mr,crypto_scalarmult_base:Ar,crypto_box_beforenm:yr,crypto_box_afternm:Zr,crypto_box:ei,crypto_box_open:_r,crypto_box_keypair:Rn,crypto_hash:he,crypto_sign:$t,crypto_sign_keypair:on,crypto_sign_open:pt,crypto_secretbox_KEYBYTES:un,crypto_secretbox_NONCEBYTES:It,crypto_secretbox_ZEROBYTES:ir,crypto_secretbox_BOXZEROBYTES:xr,crypto_scalarmult_BYTES:ti,crypto_scalarmult_SCALARBYTES:Wi,crypto_box_PUBLICKEYBYTES:ni,crypto_box_SECRETKEYBYTES:ri,crypto_box_BEFORENMBYTES:oo,crypto_box_NONCEBYTES:Ic,crypto_box_ZEROBYTES:Zh,crypto_box_BOXZEROBYTES:ep,crypto_sign_BYTES:Nn,crypto_sign_PUBLICKEYBYTES:sr,crypto_sign_SECRETKEYBYTES:Sr,crypto_sign_SEEDBYTES:ao,crypto_hash_BYTES:co};function Cc(g,A){if(g.length!==un)throw new Error("bad key size");if(A.length!==It)throw new Error("bad nonce size")}function tp(g,A){if(g.length!==ni)throw new Error("bad public key size");if(A.length!==ri)throw new Error("bad secret key size")}function an(){var g,A;for(A=0;A<arguments.length;A++)if((g=Object.prototype.toString.call(arguments[A]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+g+", use Uint8Array")}function kc(g){for(var A=0;A<g.length;A++)g[A]=0}n.util||(n.util={},n.util.decodeUTF8=n.util.encodeUTF8=n.util.encodeBase64=n.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),n.randomBytes=function(g){var A=new Uint8Array(g);return e(A,g),A},n.secretbox=function(g,A,m){an(g,A,m),Cc(m,A);for(var d=new Uint8Array(ir+g.length),E=new Uint8Array(d.length),$=0;$<g.length;$++)d[$+ir]=g[$];return ne(E,d,d.length,A,m),E.subarray(xr)},n.secretbox.open=function(g,A,m){an(g,A,m),Cc(m,A);for(var d=new Uint8Array(xr+g.length),E=new Uint8Array(d.length),$=0;$<g.length;$++)d[$+xr]=g[$];return d.length<32||z(E,d,d.length,A,m)!==0?!1:E.subarray(ir)},n.secretbox.keyLength=un,n.secretbox.nonceLength=It,n.secretbox.overheadLength=xr,n.scalarMult=function(g,A){if(an(g,A),g.length!==Wi)throw new Error("bad n size");if(A.length!==ti)throw new Error("bad p size");var m=new Uint8Array(ti);return mr(m,g,A),m},n.scalarMult.base=function(g){if(an(g),g.length!==Wi)throw new Error("bad n size");var A=new Uint8Array(ti);return Ar(A,g),A},n.scalarMult.scalarLength=Wi,n.scalarMult.groupElementLength=ti,n.box=function(g,A,m,d){var E=n.box.before(m,d);return n.secretbox(g,A,E)},n.box.before=function(g,A){an(g,A),tp(g,A);var m=new Uint8Array(oo);return yr(m,g,A),m},n.box.after=n.secretbox,n.box.open=function(g,A,m,d){var E=n.box.before(m,d);return n.secretbox.open(g,A,E)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var g=new Uint8Array(ni),A=new Uint8Array(ri);return Rn(g,A),{publicKey:g,secretKey:A}},n.box.keyPair.fromSecretKey=function(g){if(an(g),g.length!==ri)throw new Error("bad secret key size");var A=new Uint8Array(ni);return Ar(A,g),{publicKey:A,secretKey:new Uint8Array(g)}},n.box.publicKeyLength=ni,n.box.secretKeyLength=ri,n.box.sharedKeyLength=oo,n.box.nonceLength=Ic,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(g,A){if(an(g,A),A.length!==Sr)throw new Error("bad secret key size");var m=new Uint8Array(Nn+g.length);return $t(m,g,g.length,A),m},n.sign.open=function(g,A){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(an(g,A),A.length!==sr)throw new Error("bad public key size");var m=new Uint8Array(g.length),d=pt(m,g,g.length,A);if(d<0)return null;for(var E=new Uint8Array(d),$=0;$<E.length;$++)E[$]=m[$];return E},n.sign.detached=function(g,A){for(var m=n.sign(g,A),d=new Uint8Array(Nn),E=0;E<d.length;E++)d[E]=m[E];return d},n.sign.detached.verify=function(g,A,m){if(an(g,A,m),A.length!==Nn)throw new Error("bad signature size");if(m.length!==sr)throw new Error("bad public key size");var d=new Uint8Array(Nn+g.length),E=new Uint8Array(Nn+g.length),$;for($=0;$<Nn;$++)d[$]=A[$];for($=0;$<g.length;$++)d[$+Nn]=g[$];return pt(E,d,d.length,m)>=0},n.sign.keyPair=function(){var g=new Uint8Array(sr),A=new Uint8Array(Sr);return on(g,A),{publicKey:g,secretKey:A}},n.sign.keyPair.fromSecretKey=function(g){if(an(g),g.length!==Sr)throw new Error("bad secret key size");for(var A=new Uint8Array(sr),m=0;m<A.length;m++)A[m]=g[32+m];return{publicKey:A,secretKey:new Uint8Array(g)}},n.sign.keyPair.fromSeed=function(g){if(an(g),g.length!==ao)throw new Error("bad seed size");for(var A=new Uint8Array(sr),m=new Uint8Array(Sr),d=0;d<32;d++)m[d]=g[d];return on(A,m,!0),{publicKey:A,secretKey:m}},n.sign.publicKeyLength=sr,n.sign.secretKeyLength=Sr,n.sign.seedLength=ao,n.sign.signatureLength=Nn,n.hash=function(g){an(g);var A=new Uint8Array(co);return he(A,g,g.length),A},n.hash.hashLength=co,n.verify=function(g,A){return an(g,A),g.length===0||A.length===0||g.length!==A.length?!1:y(g,0,A,0,g.length)===0},n.setPRNG=function(g){e=g},(function(){var g=typeof self<"u"?self.crypto||self.msCrypto:null;if(g&&g.getRandomValues){var A=65536;n.setPRNG(function(m,d){var E,$=new Uint8Array(d);for(E=0;E<d;E+=A)g.getRandomValues($.subarray(E,E+Math.min(d-E,A)));for(E=0;E<d;E++)m[E]=$[E];kc($)})}else typeof require<"u"&&(g=require("crypto"),g&&g.randomBytes&&n.setPRNG(function(m,d){var E,$=g.randomBytes(d);for(E=0;E<d;E++)m[E]=$[E];kc($)}))})()})(typeof Ji<"u"&&Ji.exports?Ji.exports:self.nacl=self.nacl||{})});var Ao=ct((Qy,Fc)=>{"use strict";var po=Mc().lowlevel.crypto_hash,Pn=0,ar=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 es(n,t,e){return(n[0][t[e+3]]+n[1][t[e+2]]^n[2][t[e+1]])+n[3][t[e]]}ar.prototype.encipher=function(n,t){t===void 0&&(t=new Uint8Array(n.buffer),n.byteOffset!==0&&(t=t.subarray(n.byteOffset))),n[0]^=this.P[0];for(var e=1;e<16;e+=2)n[1]^=es(this.S,t,0)^this.P[e],n[0]^=es(this.S,t,4)^this.P[e+1];var r=n[0];n[0]=n[1]^this.P[17],n[1]=r};ar.prototype.decipher=function(n){var t=new Uint8Array(n.buffer);n.byteOffset!==0&&(t=t.subarray(n.byteOffset)),n[0]^=this.P[17];for(var e=16;e>0;e-=2)n[1]^=es(this.S,t,0)^this.P[e],n[0]^=es(this.S,t,4)^this.P[e-1];var r=n[0];n[0]=n[1]^this.P[0],n[1]=r};function or(n,t){var e,r=0;for(e=0;e<4;e++,Pn++)Pn>=t&&(Pn=0),r=r<<8|n[Pn];return r}ar.prototype.expand0state=function(n,t){var e=new Uint32Array(2),r,s,i=new Uint8Array(e.buffer);for(r=0,Pn=0;r<18;r++)this.P[r]^=or(n,t);for(Pn=0,r=0;r<18;r+=2)this.encipher(e,i),this.P[r]=e[0],this.P[r+1]=e[1];for(r=0;r<4;r++)for(s=0;s<256;s+=2)this.encipher(e,i),this.S[r][s]=e[0],this.S[r][s+1]=e[1]};ar.prototype.expandstate=function(n,t,e,r){var s=new Uint32Array(2),i,o;for(i=0,Pn=0;i<18;i++)this.P[i]^=or(e,r);for(i=0,Pn=0;i<18;i+=2)s[0]^=or(n,t),s[1]^=or(n,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]^=or(n,t),s[1]^=or(n,t),this.encipher(s),this.S[i][o]=s[0],this.S[i][o+1]=s[1];Pn=0};ar.prototype.enc=function(n,t){for(var e=0;e<t;e++)this.encipher(n.subarray(e*2))};ar.prototype.dec=function(n,t){for(var e=0;e<t;e++)this.decipher(n.subarray(e*2))};var Zi=8,go=32;function mo(n,t,e){var r=new ar,s=new Uint32Array(Zi),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(r.expandstate(t,64,n,64),i=0;i<64;i++)r.expand0state(t,64),r.expand0state(n,64);for(i=0;i<Zi;i++)s[i]=or(o,o.byteLength);for(i=0;i<64;i++)r.enc(s,s.byteLength/8);for(i=0;i<Zi;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 gp(n,t,e,r,s,i,o){var a=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(go),f=new Uint8Array(go),u=new Uint8Array(r+4),h,p,y,_,x,S,R=i;if(o<1||t===0||r===0||i===0||i>l.byteLength*l.byteLength||r>1<<20)return-1;for(_=Math.floor((i+l.byteLength-1)/l.byteLength),y=Math.floor((i+_-1)/_),h=0;h<r;h++)u[h]=e[h];for(po(a,n,t),S=1;i>0;S++){for(u[r+0]=S>>>24,u[r+1]=S>>>16,u[r+2]=S>>>8,u[r+3]=S,po(c,u,r+4),mo(a,c,f),h=l.byteLength;h--;)l[h]=f[h];for(h=1;h<o;h++)for(po(c,f,f.byteLength),mo(a,c,f),p=0;p<l.byteLength;p++)l[p]^=f[p];for(y=Math.min(y,i),h=0;h<y&&(x=h*_+(S-1),!(x>=R));h++)s[x]=l[h];i-=h}return 0}Fc.exports={BLOCKS:Zi,HASHSIZE:go,hash:mo,pbkdf:gp}});var Ln=ct((Wy,ns)=>{"use strict";var Tn=require("crypto"),vr;try{vr=require("cpu-features")()}catch{}var{bindingAvailable:Hc,CIPHER_INFO:mp,MAC_INFO:Ap}=qn(),Qc=(()=>{if(typeof Tn.sign=="function"&&typeof Tn.verify=="function"){let n=`-----BEGIN PRIVATE KEY-----\r
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var np=Object.create;var vc=Object.defineProperty;var rp=Object.getOwnPropertyDescriptor;var ip=Object.getOwnPropertyNames;var sp=Object.getPrototypeOf,op=Object.prototype.hasOwnProperty;var ct=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var ap=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ip(t))!op.call(n,s)&&s!==e&&vc(n,s,{get:()=>t[s],enumerable:!(r=rp(t,s))||r.enumerable});return n};var zt=(n,t,e)=>(e=n!=null?np(sp(n)):{},ap(t||!n||!n.__esModule?vc(e,"default",{value:n,enumerable:!0}):e,n));var qi=ct((Ty,Bc)=>{Bc.exports={newInvalidAsn1Error:function(n){var t=new Error;return t.name="InvalidAsn1Error",t.message=n||"",t}}});var Ki=ct((Ly,Rc)=>{Rc.exports={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}});var lo=ct(($y,Nc)=>{"use strict";var Vi=require("buffer"),wr=Vi.Buffer,dn={},hn;for(hn in Vi)Vi.hasOwnProperty(hn)&&(hn==="SlowBuffer"||hn==="Buffer"||(dn[hn]=Vi[hn]));var Ir=dn.Buffer={};for(hn in wr)wr.hasOwnProperty(hn)&&(hn==="allocUnsafe"||hn==="allocUnsafeSlow"||(Ir[hn]=wr[hn]));dn.Buffer.prototype=wr.prototype;(!Ir.from||Ir.from===Uint8Array.from)&&(Ir.from=function(n,t,e){if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type '+typeof n);if(n&&typeof n.length>"u")throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);return wr(n,t,e)});Ir.alloc||(Ir.alloc=function(n,t,e){if(typeof n!="number")throw new TypeError('The "size" argument must be of type number. Received type '+typeof n);if(n<0||n>=2*(1<<30))throw new RangeError('The value "'+n+'" is invalid for option "size"');var r=wr(n);return!t||t.length===0?r.fill(0):typeof e=="string"?r.fill(t,e):r.fill(t),r});if(!dn.kStringMaxLength)try{dn.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}dn.constants||(dn.constants={MAX_LENGTH:dn.kMaxLength},dn.kStringMaxLength&&(dn.constants.MAX_STRING_LENGTH=dn.kStringMaxLength));Nc.exports=dn});var Lc=ct((Dy,Tc)=>{var cp=require("assert"),Pc=lo().Buffer,ii=Ki(),lp=qi(),Cr=lp.newInvalidAsn1Error;function Yt(n){if(!n||!Pc.isBuffer(n))throw new TypeError("data must be a node Buffer");this._buf=n,this._size=n.length,this._len=0,this._offset=0}Object.defineProperty(Yt.prototype,"length",{enumerable:!0,get:function(){return this._len}});Object.defineProperty(Yt.prototype,"offset",{enumerable:!0,get:function(){return this._offset}});Object.defineProperty(Yt.prototype,"remain",{get:function(){return this._size-this._offset}});Object.defineProperty(Yt.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}});Yt.prototype.readByte=function(n){if(this._size-this._offset<1)return null;var t=this._buf[this._offset]&255;return n||(this._offset+=1),t};Yt.prototype.peek=function(){return this.readByte(!0)};Yt.prototype.readLength=function(n){if(n===void 0&&(n=this._offset),n>=this._size)return null;var t=this._buf[n++]&255;if(t===null)return null;if((t&128)===128){if(t&=127,t===0)throw Cr("Indefinite length not supported");if(t>4)throw Cr("encoding too long");if(this._size-n<t)return null;this._len=0;for(var e=0;e<t;e++)this._len=(this._len<<8)+(this._buf[n++]&255)}else this._len=t;return n};Yt.prototype.readSequence=function(n){var t=this.peek();if(t===null)return null;if(n!==void 0&&n!==t)throw Cr("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);return e===null?null:(this._offset=e,t)};Yt.prototype.readInt=function(){return this._readTag(ii.Integer)};Yt.prototype.readBoolean=function(){return this._readTag(ii.Boolean)!==0};Yt.prototype.readEnumeration=function(){return this._readTag(ii.Enumeration)};Yt.prototype.readString=function(n,t){n||(n=ii.OctetString);var e=this.peek();if(e===null)return null;if(e!==n)throw Cr("Expected 0x"+n.toString(16)+": got 0x"+e.toString(16));var r=this.readLength(this._offset+1);if(r===null||this.length>this._size-r)return null;if(this._offset=r,this.length===0)return t?Pc.alloc(0):"";var s=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?s:s.toString("utf8")};Yt.prototype.readOID=function(n){n||(n=ii.OID);var t=this.readString(n,!0);if(t===null)return null;for(var e=[],r=0,s=0;s<t.length;s++){var i=t[s]&255;r<<=7,r+=i&127,(i&128)===0&&(e.push(r),r=0)}return r=e.shift(),e.unshift(r%40),e.unshift(r/40>>0),e.join(".")};Yt.prototype._readTag=function(n){cp.ok(n!==void 0);var t=this.peek();if(t===null)return null;if(t!==n)throw Cr("Expected 0x"+n.toString(16)+": got 0x"+t.toString(16));var e=this.readLength(this._offset+1);if(e===null)return null;if(this.length>4)throw Cr("Integer too long: "+this.length);if(this.length>this._size-e)return null;this._offset=e;for(var r=this._buf[this._offset],s=0,i=0;i<this.length;i++)s<<=8,s|=this._buf[this._offset++]&255;return(r&128)===128&&i!==4&&(s-=1<<i*8),s>>0};Tc.exports=Yt});var Dc=ct((Uy,$c)=>{var Hn=require("assert"),Gi=lo().Buffer,Qn=Ki(),fp=qi(),zi=fp.newInvalidAsn1Error,up={size:1024,growthFactor:8};function dp(n,t){Hn.ok(n),Hn.equal(typeof n,"object"),Hn.ok(t),Hn.equal(typeof t,"object");var e=Object.getOwnPropertyNames(n);return e.forEach(function(r){if(!t[r]){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s)}}),t}function Vt(n){n=dp(up,n||{}),this._buf=Gi.alloc(n.size||1024),this._size=this._buf.length,this._offset=0,this._options=n,this._seq=[]}Object.defineProperty(Vt.prototype,"buffer",{get:function(){if(this._seq.length)throw zi(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}});Vt.prototype.writeByte=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=n};Vt.prototype.writeInt=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");typeof t!="number"&&(t=Qn.Integer);for(var e=4;((n&4286578688)===0||(n&4286578688)===-8388608)&&e>1;)e--,n<<=8;if(e>4)throw zi("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++]=(n&4278190080)>>>24,n<<=8};Vt.prototype.writeNull=function(){this.writeByte(Qn.Null),this.writeByte(0)};Vt.prototype.writeEnumeration=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");return typeof t!="number"&&(t=Qn.Enumeration),this.writeInt(n,t)};Vt.prototype.writeBoolean=function(n,t){if(typeof n!="boolean")throw new TypeError("argument must be a Boolean");typeof t!="number"&&(t=Qn.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=n?255:0};Vt.prototype.writeString=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string (was: "+typeof n+")");typeof t!="number"&&(t=Qn.OctetString);var e=Gi.byteLength(n);this.writeByte(t),this.writeLength(e),e&&(this._ensure(e),this._buf.write(n,this._offset),this._offset+=e)};Vt.prototype.writeBuffer=function(n,t){if(typeof t!="number")throw new TypeError("tag must be a number");if(!Gi.isBuffer(n))throw new TypeError("argument must be a buffer");this.writeByte(t),this.writeLength(n.length),this._ensure(n.length),n.copy(this._buf,this._offset,0,n.length),this._offset+=n.length};Vt.prototype.writeStringArray=function(n){if(!n instanceof Array)throw new TypeError("argument must be an Array[String]");var t=this;n.forEach(function(e){t.writeString(e)})};Vt.prototype.writeOID=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string");if(typeof t!="number"&&(t=Qn.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(n))throw new Error("argument is not a valid OID string");function e(o,a){a<128?o.push(a):a<16384?(o.push(a>>>7|128),o.push(a&127)):a<2097152?(o.push(a>>>14|128),o.push((a>>>7|128)&255),o.push(a&127)):a<268435456?(o.push(a>>>21|128),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127)):(o.push((a>>>28|128)&255),o.push((a>>>21|128)&255),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127))}var r=n.split("."),s=[];s.push(parseInt(r[0],10)*40+parseInt(r[1],10)),r.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)})};Vt.prototype.writeLength=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");if(this._ensure(4),n<=127)this._buf[this._offset++]=n;else if(n<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=n;else if(n<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else if(n<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=n>>16,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else throw zi("Length too long (> 4 bytes)")};Vt.prototype.startSequence=function(n){typeof n!="number"&&(n=Qn.Sequence|Qn.Constructor),this.writeByte(n),this._seq.push(this._offset),this._ensure(3),this._offset+=3};Vt.prototype.endSequence=function(){var n=this._seq.pop(),t=n+3,e=this._offset-t;if(e<=127)this._shift(t,e,-2),this._buf[n]=e;else if(e<=255)this._shift(t,e,-1),this._buf[n]=129,this._buf[n+1]=e;else if(e<=65535)this._buf[n]=130,this._buf[n+1]=e>>8,this._buf[n+2]=e;else if(e<=16777215)this._shift(t,e,1),this._buf[n]=131,this._buf[n+1]=e>>16,this._buf[n+2]=e>>8,this._buf[n+3]=e;else throw zi("Sequence too long")};Vt.prototype._shift=function(n,t,e){Hn.ok(n!==void 0),Hn.ok(t!==void 0),Hn.ok(e),this._buf.copy(this._buf,n+e,n,n+t),this._offset+=e};Vt.prototype._ensure=function(n){if(Hn.ok(n),this._size-this._offset<n){var t=this._size*this._options.growthFactor;t-this._offset<n&&(t+=n);var e=Gi.alloc(t);this._buf.copy(e,0,0,this._offset),this._buf=e,this._size=t}};$c.exports=Vt});var Uc=ct((Oy,Xi)=>{var fo=qi(),uo=Ki(),hp=Lc(),pp=Dc();Xi.exports={Reader:hp,Writer:pp};for(Yi in uo)uo.hasOwnProperty(Yi)&&(Xi.exports[Yi]=uo[Yi]);var Yi;for(ji in fo)fo.hasOwnProperty(ji)&&(Xi.exports[ji]=fo[ji]);var ji});var si=ct((My,Oc)=>{var ho=Uc();Oc.exports={Ber:ho,BerReader:ho.Reader,BerWriter:ho.Writer}});var Mc=ct((Fy,Ji)=>{(function(n){"use strict";var t=function(g){var A,m=new Float64Array(16);if(g)for(A=0;A<g.length;A++)m[A]=g[A];return m},e=function(){throw new Error("no PRNG")},r=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var i=t(),o=t([1]),a=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),f=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),u=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),h=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(g,A,m,d){g[A]=m>>24&255,g[A+1]=m>>16&255,g[A+2]=m>>8&255,g[A+3]=m&255,g[A+4]=d>>24&255,g[A+5]=d>>16&255,g[A+6]=d>>8&255,g[A+7]=d&255}function y(g,A,m,d,E){var $,F=0;for($=0;$<E;$++)F|=g[A+$]^m[d+$];return(1&F-1>>>8)-1}function _(g,A,m,d){return y(g,A,m,d,16)}function x(g,A,m,d){return y(g,A,m,d,32)}function S(g,A,m,d){for(var E=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,$=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,F=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,J=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ae=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,ye=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,ge=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,nt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,Ae=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Le=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,$e=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,He=m[16]&255|(m[17]&255)<<8|(m[18]&255)<<16|(m[19]&255)<<24,Fe=m[20]&255|(m[21]&255)<<8|(m[22]&255)<<16|(m[23]&255)<<24,De=m[24]&255|(m[25]&255)<<8|(m[26]&255)<<16|(m[27]&255)<<24,Oe=m[28]&255|(m[29]&255)<<8|(m[30]&255)<<16|(m[31]&255)<<24,Ue=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,_e=E,xe=$,me=F,Ee=J,be=ae,pe=ye,W=ge,q=nt,re=Ae,X=Le,Z=$e,oe=He,ke=Fe,Qe=De,qe=Oe,We=Ue,I,Ve=0;Ve<20;Ve+=2)I=_e+ke|0,be^=I<<7|I>>>25,I=be+_e|0,re^=I<<9|I>>>23,I=re+be|0,ke^=I<<13|I>>>19,I=ke+re|0,_e^=I<<18|I>>>14,I=pe+xe|0,X^=I<<7|I>>>25,I=X+pe|0,Qe^=I<<9|I>>>23,I=Qe+X|0,xe^=I<<13|I>>>19,I=xe+Qe|0,pe^=I<<18|I>>>14,I=Z+W|0,qe^=I<<7|I>>>25,I=qe+Z|0,me^=I<<9|I>>>23,I=me+qe|0,W^=I<<13|I>>>19,I=W+me|0,Z^=I<<18|I>>>14,I=We+oe|0,Ee^=I<<7|I>>>25,I=Ee+We|0,q^=I<<9|I>>>23,I=q+Ee|0,oe^=I<<13|I>>>19,I=oe+q|0,We^=I<<18|I>>>14,I=_e+Ee|0,xe^=I<<7|I>>>25,I=xe+_e|0,me^=I<<9|I>>>23,I=me+xe|0,Ee^=I<<13|I>>>19,I=Ee+me|0,_e^=I<<18|I>>>14,I=pe+be|0,W^=I<<7|I>>>25,I=W+pe|0,q^=I<<9|I>>>23,I=q+W|0,be^=I<<13|I>>>19,I=be+q|0,pe^=I<<18|I>>>14,I=Z+X|0,oe^=I<<7|I>>>25,I=oe+Z|0,re^=I<<9|I>>>23,I=re+oe|0,X^=I<<13|I>>>19,I=X+re|0,Z^=I<<18|I>>>14,I=We+qe|0,ke^=I<<7|I>>>25,I=ke+We|0,Qe^=I<<9|I>>>23,I=Qe+ke|0,qe^=I<<13|I>>>19,I=qe+Qe|0,We^=I<<18|I>>>14;_e=_e+E|0,xe=xe+$|0,me=me+F|0,Ee=Ee+J|0,be=be+ae|0,pe=pe+ye|0,W=W+ge|0,q=q+nt|0,re=re+Ae|0,X=X+Le|0,Z=Z+$e|0,oe=oe+He|0,ke=ke+Fe|0,Qe=Qe+De|0,qe=qe+Oe|0,We=We+Ue|0,g[0]=_e>>>0&255,g[1]=_e>>>8&255,g[2]=_e>>>16&255,g[3]=_e>>>24&255,g[4]=xe>>>0&255,g[5]=xe>>>8&255,g[6]=xe>>>16&255,g[7]=xe>>>24&255,g[8]=me>>>0&255,g[9]=me>>>8&255,g[10]=me>>>16&255,g[11]=me>>>24&255,g[12]=Ee>>>0&255,g[13]=Ee>>>8&255,g[14]=Ee>>>16&255,g[15]=Ee>>>24&255,g[16]=be>>>0&255,g[17]=be>>>8&255,g[18]=be>>>16&255,g[19]=be>>>24&255,g[20]=pe>>>0&255,g[21]=pe>>>8&255,g[22]=pe>>>16&255,g[23]=pe>>>24&255,g[24]=W>>>0&255,g[25]=W>>>8&255,g[26]=W>>>16&255,g[27]=W>>>24&255,g[28]=q>>>0&255,g[29]=q>>>8&255,g[30]=q>>>16&255,g[31]=q>>>24&255,g[32]=re>>>0&255,g[33]=re>>>8&255,g[34]=re>>>16&255,g[35]=re>>>24&255,g[36]=X>>>0&255,g[37]=X>>>8&255,g[38]=X>>>16&255,g[39]=X>>>24&255,g[40]=Z>>>0&255,g[41]=Z>>>8&255,g[42]=Z>>>16&255,g[43]=Z>>>24&255,g[44]=oe>>>0&255,g[45]=oe>>>8&255,g[46]=oe>>>16&255,g[47]=oe>>>24&255,g[48]=ke>>>0&255,g[49]=ke>>>8&255,g[50]=ke>>>16&255,g[51]=ke>>>24&255,g[52]=Qe>>>0&255,g[53]=Qe>>>8&255,g[54]=Qe>>>16&255,g[55]=Qe>>>24&255,g[56]=qe>>>0&255,g[57]=qe>>>8&255,g[58]=qe>>>16&255,g[59]=qe>>>24&255,g[60]=We>>>0&255,g[61]=We>>>8&255,g[62]=We>>>16&255,g[63]=We>>>24&255}function R(g,A,m,d){for(var E=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,$=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,F=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,J=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ae=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,ye=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,ge=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,nt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,Ae=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Le=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,$e=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,He=m[16]&255|(m[17]&255)<<8|(m[18]&255)<<16|(m[19]&255)<<24,Fe=m[20]&255|(m[21]&255)<<8|(m[22]&255)<<16|(m[23]&255)<<24,De=m[24]&255|(m[25]&255)<<8|(m[26]&255)<<16|(m[27]&255)<<24,Oe=m[28]&255|(m[29]&255)<<8|(m[30]&255)<<16|(m[31]&255)<<24,Ue=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,_e=E,xe=$,me=F,Ee=J,be=ae,pe=ye,W=ge,q=nt,re=Ae,X=Le,Z=$e,oe=He,ke=Fe,Qe=De,qe=Oe,We=Ue,I,Ve=0;Ve<20;Ve+=2)I=_e+ke|0,be^=I<<7|I>>>25,I=be+_e|0,re^=I<<9|I>>>23,I=re+be|0,ke^=I<<13|I>>>19,I=ke+re|0,_e^=I<<18|I>>>14,I=pe+xe|0,X^=I<<7|I>>>25,I=X+pe|0,Qe^=I<<9|I>>>23,I=Qe+X|0,xe^=I<<13|I>>>19,I=xe+Qe|0,pe^=I<<18|I>>>14,I=Z+W|0,qe^=I<<7|I>>>25,I=qe+Z|0,me^=I<<9|I>>>23,I=me+qe|0,W^=I<<13|I>>>19,I=W+me|0,Z^=I<<18|I>>>14,I=We+oe|0,Ee^=I<<7|I>>>25,I=Ee+We|0,q^=I<<9|I>>>23,I=q+Ee|0,oe^=I<<13|I>>>19,I=oe+q|0,We^=I<<18|I>>>14,I=_e+Ee|0,xe^=I<<7|I>>>25,I=xe+_e|0,me^=I<<9|I>>>23,I=me+xe|0,Ee^=I<<13|I>>>19,I=Ee+me|0,_e^=I<<18|I>>>14,I=pe+be|0,W^=I<<7|I>>>25,I=W+pe|0,q^=I<<9|I>>>23,I=q+W|0,be^=I<<13|I>>>19,I=be+q|0,pe^=I<<18|I>>>14,I=Z+X|0,oe^=I<<7|I>>>25,I=oe+Z|0,re^=I<<9|I>>>23,I=re+oe|0,X^=I<<13|I>>>19,I=X+re|0,Z^=I<<18|I>>>14,I=We+qe|0,ke^=I<<7|I>>>25,I=ke+We|0,Qe^=I<<9|I>>>23,I=Qe+ke|0,qe^=I<<13|I>>>19,I=qe+Qe|0,We^=I<<18|I>>>14;g[0]=_e>>>0&255,g[1]=_e>>>8&255,g[2]=_e>>>16&255,g[3]=_e>>>24&255,g[4]=pe>>>0&255,g[5]=pe>>>8&255,g[6]=pe>>>16&255,g[7]=pe>>>24&255,g[8]=Z>>>0&255,g[9]=Z>>>8&255,g[10]=Z>>>16&255,g[11]=Z>>>24&255,g[12]=We>>>0&255,g[13]=We>>>8&255,g[14]=We>>>16&255,g[15]=We>>>24&255,g[16]=W>>>0&255,g[17]=W>>>8&255,g[18]=W>>>16&255,g[19]=W>>>24&255,g[20]=q>>>0&255,g[21]=q>>>8&255,g[22]=q>>>16&255,g[23]=q>>>24&255,g[24]=re>>>0&255,g[25]=re>>>8&255,g[26]=re>>>16&255,g[27]=re>>>24&255,g[28]=X>>>0&255,g[29]=X>>>8&255,g[30]=X>>>16&255,g[31]=X>>>24&255}function H(g,A,m,d){S(g,A,m,d)}function C(g,A,m,d){R(g,A,m,d)}var U=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Q(g,A,m,d,E,$,F){var J=new Uint8Array(16),ae=new Uint8Array(64),ye,ge;for(ge=0;ge<16;ge++)J[ge]=0;for(ge=0;ge<8;ge++)J[ge]=$[ge];for(;E>=64;){for(H(ae,J,F,U),ge=0;ge<64;ge++)g[A+ge]=m[d+ge]^ae[ge];for(ye=1,ge=8;ge<16;ge++)ye=ye+(J[ge]&255)|0,J[ge]=ye&255,ye>>>=8;E-=64,A+=64,d+=64}if(E>0)for(H(ae,J,F,U),ge=0;ge<E;ge++)g[A+ge]=m[d+ge]^ae[ge];return 0}function B(g,A,m,d,E){var $=new Uint8Array(16),F=new Uint8Array(64),J,ae;for(ae=0;ae<16;ae++)$[ae]=0;for(ae=0;ae<8;ae++)$[ae]=d[ae];for(;m>=64;){for(H(F,$,E,U),ae=0;ae<64;ae++)g[A+ae]=F[ae];for(J=1,ae=8;ae<16;ae++)J=J+($[ae]&255)|0,$[ae]=J&255,J>>>=8;m-=64,A+=64}if(m>0)for(H(F,$,E,U),ae=0;ae<m;ae++)g[A+ae]=F[ae];return 0}function b(g,A,m,d,E){var $=new Uint8Array(32);C($,d,E,U);for(var F=new Uint8Array(8),J=0;J<8;J++)F[J]=d[J+16];return B(g,A,m,F,$)}function w(g,A,m,d,E,$,F){var J=new Uint8Array(32);C(J,$,F,U);for(var ae=new Uint8Array(8),ye=0;ye<8;ye++)ae[ye]=$[ye+16];return Q(g,A,m,d,E,ae,J)}var k=function(g){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 A,m,d,E,$,F,J,ae;A=g[0]&255|(g[1]&255)<<8,this.r[0]=A&8191,m=g[2]&255|(g[3]&255)<<8,this.r[1]=(A>>>13|m<<3)&8191,d=g[4]&255|(g[5]&255)<<8,this.r[2]=(m>>>10|d<<6)&7939,E=g[6]&255|(g[7]&255)<<8,this.r[3]=(d>>>7|E<<9)&8191,$=g[8]&255|(g[9]&255)<<8,this.r[4]=(E>>>4|$<<12)&255,this.r[5]=$>>>1&8190,F=g[10]&255|(g[11]&255)<<8,this.r[6]=($>>>14|F<<2)&8191,J=g[12]&255|(g[13]&255)<<8,this.r[7]=(F>>>11|J<<5)&8065,ae=g[14]&255|(g[15]&255)<<8,this.r[8]=(J>>>8|ae<<8)&8191,this.r[9]=ae>>>5&127,this.pad[0]=g[16]&255|(g[17]&255)<<8,this.pad[1]=g[18]&255|(g[19]&255)<<8,this.pad[2]=g[20]&255|(g[21]&255)<<8,this.pad[3]=g[22]&255|(g[23]&255)<<8,this.pad[4]=g[24]&255|(g[25]&255)<<8,this.pad[5]=g[26]&255|(g[27]&255)<<8,this.pad[6]=g[28]&255|(g[29]&255)<<8,this.pad[7]=g[30]&255|(g[31]&255)<<8};k.prototype.blocks=function(g,A,m){for(var d=this.fin?0:2048,E,$,F,J,ae,ye,ge,nt,Ae,Le,$e,He,Fe,De,Oe,Ue,_e,xe,me,Ee=this.h[0],be=this.h[1],pe=this.h[2],W=this.h[3],q=this.h[4],re=this.h[5],X=this.h[6],Z=this.h[7],oe=this.h[8],ke=this.h[9],Qe=this.r[0],qe=this.r[1],We=this.r[2],I=this.r[3],Ve=this.r[4],rt=this.r[5],it=this.r[6],Ke=this.r[7],Ze=this.r[8],et=this.r[9];m>=16;)E=g[A+0]&255|(g[A+1]&255)<<8,Ee+=E&8191,$=g[A+2]&255|(g[A+3]&255)<<8,be+=(E>>>13|$<<3)&8191,F=g[A+4]&255|(g[A+5]&255)<<8,pe+=($>>>10|F<<6)&8191,J=g[A+6]&255|(g[A+7]&255)<<8,W+=(F>>>7|J<<9)&8191,ae=g[A+8]&255|(g[A+9]&255)<<8,q+=(J>>>4|ae<<12)&8191,re+=ae>>>1&8191,ye=g[A+10]&255|(g[A+11]&255)<<8,X+=(ae>>>14|ye<<2)&8191,ge=g[A+12]&255|(g[A+13]&255)<<8,Z+=(ye>>>11|ge<<5)&8191,nt=g[A+14]&255|(g[A+15]&255)<<8,oe+=(ge>>>8|nt<<8)&8191,ke+=nt>>>5|d,Ae=0,Le=Ae,Le+=Ee*Qe,Le+=be*(5*et),Le+=pe*(5*Ze),Le+=W*(5*Ke),Le+=q*(5*it),Ae=Le>>>13,Le&=8191,Le+=re*(5*rt),Le+=X*(5*Ve),Le+=Z*(5*I),Le+=oe*(5*We),Le+=ke*(5*qe),Ae+=Le>>>13,Le&=8191,$e=Ae,$e+=Ee*qe,$e+=be*Qe,$e+=pe*(5*et),$e+=W*(5*Ze),$e+=q*(5*Ke),Ae=$e>>>13,$e&=8191,$e+=re*(5*it),$e+=X*(5*rt),$e+=Z*(5*Ve),$e+=oe*(5*I),$e+=ke*(5*We),Ae+=$e>>>13,$e&=8191,He=Ae,He+=Ee*We,He+=be*qe,He+=pe*Qe,He+=W*(5*et),He+=q*(5*Ze),Ae=He>>>13,He&=8191,He+=re*(5*Ke),He+=X*(5*it),He+=Z*(5*rt),He+=oe*(5*Ve),He+=ke*(5*I),Ae+=He>>>13,He&=8191,Fe=Ae,Fe+=Ee*I,Fe+=be*We,Fe+=pe*qe,Fe+=W*Qe,Fe+=q*(5*et),Ae=Fe>>>13,Fe&=8191,Fe+=re*(5*Ze),Fe+=X*(5*Ke),Fe+=Z*(5*it),Fe+=oe*(5*rt),Fe+=ke*(5*Ve),Ae+=Fe>>>13,Fe&=8191,De=Ae,De+=Ee*Ve,De+=be*I,De+=pe*We,De+=W*qe,De+=q*Qe,Ae=De>>>13,De&=8191,De+=re*(5*et),De+=X*(5*Ze),De+=Z*(5*Ke),De+=oe*(5*it),De+=ke*(5*rt),Ae+=De>>>13,De&=8191,Oe=Ae,Oe+=Ee*rt,Oe+=be*Ve,Oe+=pe*I,Oe+=W*We,Oe+=q*qe,Ae=Oe>>>13,Oe&=8191,Oe+=re*Qe,Oe+=X*(5*et),Oe+=Z*(5*Ze),Oe+=oe*(5*Ke),Oe+=ke*(5*it),Ae+=Oe>>>13,Oe&=8191,Ue=Ae,Ue+=Ee*it,Ue+=be*rt,Ue+=pe*Ve,Ue+=W*I,Ue+=q*We,Ae=Ue>>>13,Ue&=8191,Ue+=re*qe,Ue+=X*Qe,Ue+=Z*(5*et),Ue+=oe*(5*Ze),Ue+=ke*(5*Ke),Ae+=Ue>>>13,Ue&=8191,_e=Ae,_e+=Ee*Ke,_e+=be*it,_e+=pe*rt,_e+=W*Ve,_e+=q*I,Ae=_e>>>13,_e&=8191,_e+=re*We,_e+=X*qe,_e+=Z*Qe,_e+=oe*(5*et),_e+=ke*(5*Ze),Ae+=_e>>>13,_e&=8191,xe=Ae,xe+=Ee*Ze,xe+=be*Ke,xe+=pe*it,xe+=W*rt,xe+=q*Ve,Ae=xe>>>13,xe&=8191,xe+=re*I,xe+=X*We,xe+=Z*qe,xe+=oe*Qe,xe+=ke*(5*et),Ae+=xe>>>13,xe&=8191,me=Ae,me+=Ee*et,me+=be*Ze,me+=pe*Ke,me+=W*it,me+=q*rt,Ae=me>>>13,me&=8191,me+=re*Ve,me+=X*I,me+=Z*We,me+=oe*qe,me+=ke*Qe,Ae+=me>>>13,me&=8191,Ae=(Ae<<2)+Ae|0,Ae=Ae+Le|0,Le=Ae&8191,Ae=Ae>>>13,$e+=Ae,Ee=Le,be=$e,pe=He,W=Fe,q=De,re=Oe,X=Ue,Z=_e,oe=xe,ke=me,A+=16,m-=16;this.h[0]=Ee,this.h[1]=be,this.h[2]=pe,this.h[3]=W,this.h[4]=q,this.h[5]=re,this.h[6]=X,this.h[7]=Z,this.h[8]=oe,this.h[9]=ke},k.prototype.finish=function(g,A){var m=new Uint16Array(10),d,E,$,F;if(this.leftover){for(F=this.leftover,this.buffer[F++]=1;F<16;F++)this.buffer[F]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(d=this.h[1]>>>13,this.h[1]&=8191,F=2;F<10;F++)this.h[F]+=d,d=this.h[F]>>>13,this.h[F]&=8191;for(this.h[0]+=d*5,d=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=d,d=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=d,m[0]=this.h[0]+5,d=m[0]>>>13,m[0]&=8191,F=1;F<10;F++)m[F]=this.h[F]+d,d=m[F]>>>13,m[F]&=8191;for(m[9]-=8192,E=(d^1)-1,F=0;F<10;F++)m[F]&=E;for(E=~E,F=0;F<10;F++)this.h[F]=this.h[F]&E|m[F];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,$=this.h[0]+this.pad[0],this.h[0]=$&65535,F=1;F<8;F++)$=(this.h[F]+this.pad[F]|0)+($>>>16)|0,this.h[F]=$&65535;g[A+0]=this.h[0]>>>0&255,g[A+1]=this.h[0]>>>8&255,g[A+2]=this.h[1]>>>0&255,g[A+3]=this.h[1]>>>8&255,g[A+4]=this.h[2]>>>0&255,g[A+5]=this.h[2]>>>8&255,g[A+6]=this.h[3]>>>0&255,g[A+7]=this.h[3]>>>8&255,g[A+8]=this.h[4]>>>0&255,g[A+9]=this.h[4]>>>8&255,g[A+10]=this.h[5]>>>0&255,g[A+11]=this.h[5]>>>8&255,g[A+12]=this.h[6]>>>0&255,g[A+13]=this.h[6]>>>8&255,g[A+14]=this.h[7]>>>0&255,g[A+15]=this.h[7]>>>8&255},k.prototype.update=function(g,A,m){var d,E;if(this.leftover){for(E=16-this.leftover,E>m&&(E=m),d=0;d<E;d++)this.buffer[this.leftover+d]=g[A+d];if(m-=E,A+=E,this.leftover+=E,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(m>=16&&(E=m-m%16,this.blocks(g,A,E),A+=E,m-=E),m){for(d=0;d<m;d++)this.buffer[this.leftover+d]=g[A+d];this.leftover+=m}};function v(g,A,m,d,E,$){var F=new k($);return F.update(m,d,E),F.finish(g,A),0}function P(g,A,m,d,E,$){var F=new Uint8Array(16);return v(F,0,m,d,E,$),_(g,A,F,0)}function ne(g,A,m,d,E){var $;if(m<32)return-1;for(w(g,0,A,0,m,d,E),v(g,16,g,32,m-32,g),$=0;$<16;$++)g[$]=0;return 0}function z(g,A,m,d,E){var $,F=new Uint8Array(32);if(m<32||(b(F,0,32,d,E),P(A,16,A,32,m-32,F)!==0))return-1;for(w(g,0,A,0,m,d,E),$=0;$<32;$++)g[$]=0;return 0}function Y(g,A){var m;for(m=0;m<16;m++)g[m]=A[m]|0}function te(g){var A,m,d=1;for(A=0;A<16;A++)m=g[A]+d+65535,d=Math.floor(m/65536),g[A]=m-d*65536;g[0]+=d-1+37*(d-1)}function le(g,A,m){for(var d,E=~(m-1),$=0;$<16;$++)d=E&(g[$]^A[$]),g[$]^=d,A[$]^=d}function O(g,A){var m,d,E,$=t(),F=t();for(m=0;m<16;m++)F[m]=A[m];for(te(F),te(F),te(F),d=0;d<2;d++){for($[0]=F[0]-65517,m=1;m<15;m++)$[m]=F[m]-65535-($[m-1]>>16&1),$[m-1]&=65535;$[15]=F[15]-32767-($[14]>>16&1),E=$[15]>>16&1,$[14]&=65535,le(F,$,1-E)}for(m=0;m<16;m++)g[2*m]=F[m]&255,g[2*m+1]=F[m]>>8}function N(g,A){var m=new Uint8Array(32),d=new Uint8Array(32);return O(m,g),O(d,A),x(m,0,d,0)}function L(g){var A=new Uint8Array(32);return O(A,g),A[0]&1}function K(g,A){var m;for(m=0;m<16;m++)g[m]=A[2*m]+(A[2*m+1]<<8);g[15]&=32767}function ee(g,A,m){for(var d=0;d<16;d++)g[d]=A[d]+m[d]}function ue(g,A,m){for(var d=0;d<16;d++)g[d]=A[d]-m[d]}function ie(g,A,m){var d,E,$=0,F=0,J=0,ae=0,ye=0,ge=0,nt=0,Ae=0,Le=0,$e=0,He=0,Fe=0,De=0,Oe=0,Ue=0,_e=0,xe=0,me=0,Ee=0,be=0,pe=0,W=0,q=0,re=0,X=0,Z=0,oe=0,ke=0,Qe=0,qe=0,We=0,I=m[0],Ve=m[1],rt=m[2],it=m[3],Ke=m[4],Ze=m[5],et=m[6],Bt=m[7],ft=m[8],Ct=m[9],kt=m[10],vt=m[11],Dt=m[12],Wt=m[13],qt=m[14],Kt=m[15];d=A[0],$+=d*I,F+=d*Ve,J+=d*rt,ae+=d*it,ye+=d*Ke,ge+=d*Ze,nt+=d*et,Ae+=d*Bt,Le+=d*ft,$e+=d*Ct,He+=d*kt,Fe+=d*vt,De+=d*Dt,Oe+=d*Wt,Ue+=d*qt,_e+=d*Kt,d=A[1],F+=d*I,J+=d*Ve,ae+=d*rt,ye+=d*it,ge+=d*Ke,nt+=d*Ze,Ae+=d*et,Le+=d*Bt,$e+=d*ft,He+=d*Ct,Fe+=d*kt,De+=d*vt,Oe+=d*Dt,Ue+=d*Wt,_e+=d*qt,xe+=d*Kt,d=A[2],J+=d*I,ae+=d*Ve,ye+=d*rt,ge+=d*it,nt+=d*Ke,Ae+=d*Ze,Le+=d*et,$e+=d*Bt,He+=d*ft,Fe+=d*Ct,De+=d*kt,Oe+=d*vt,Ue+=d*Dt,_e+=d*Wt,xe+=d*qt,me+=d*Kt,d=A[3],ae+=d*I,ye+=d*Ve,ge+=d*rt,nt+=d*it,Ae+=d*Ke,Le+=d*Ze,$e+=d*et,He+=d*Bt,Fe+=d*ft,De+=d*Ct,Oe+=d*kt,Ue+=d*vt,_e+=d*Dt,xe+=d*Wt,me+=d*qt,Ee+=d*Kt,d=A[4],ye+=d*I,ge+=d*Ve,nt+=d*rt,Ae+=d*it,Le+=d*Ke,$e+=d*Ze,He+=d*et,Fe+=d*Bt,De+=d*ft,Oe+=d*Ct,Ue+=d*kt,_e+=d*vt,xe+=d*Dt,me+=d*Wt,Ee+=d*qt,be+=d*Kt,d=A[5],ge+=d*I,nt+=d*Ve,Ae+=d*rt,Le+=d*it,$e+=d*Ke,He+=d*Ze,Fe+=d*et,De+=d*Bt,Oe+=d*ft,Ue+=d*Ct,_e+=d*kt,xe+=d*vt,me+=d*Dt,Ee+=d*Wt,be+=d*qt,pe+=d*Kt,d=A[6],nt+=d*I,Ae+=d*Ve,Le+=d*rt,$e+=d*it,He+=d*Ke,Fe+=d*Ze,De+=d*et,Oe+=d*Bt,Ue+=d*ft,_e+=d*Ct,xe+=d*kt,me+=d*vt,Ee+=d*Dt,be+=d*Wt,pe+=d*qt,W+=d*Kt,d=A[7],Ae+=d*I,Le+=d*Ve,$e+=d*rt,He+=d*it,Fe+=d*Ke,De+=d*Ze,Oe+=d*et,Ue+=d*Bt,_e+=d*ft,xe+=d*Ct,me+=d*kt,Ee+=d*vt,be+=d*Dt,pe+=d*Wt,W+=d*qt,q+=d*Kt,d=A[8],Le+=d*I,$e+=d*Ve,He+=d*rt,Fe+=d*it,De+=d*Ke,Oe+=d*Ze,Ue+=d*et,_e+=d*Bt,xe+=d*ft,me+=d*Ct,Ee+=d*kt,be+=d*vt,pe+=d*Dt,W+=d*Wt,q+=d*qt,re+=d*Kt,d=A[9],$e+=d*I,He+=d*Ve,Fe+=d*rt,De+=d*it,Oe+=d*Ke,Ue+=d*Ze,_e+=d*et,xe+=d*Bt,me+=d*ft,Ee+=d*Ct,be+=d*kt,pe+=d*vt,W+=d*Dt,q+=d*Wt,re+=d*qt,X+=d*Kt,d=A[10],He+=d*I,Fe+=d*Ve,De+=d*rt,Oe+=d*it,Ue+=d*Ke,_e+=d*Ze,xe+=d*et,me+=d*Bt,Ee+=d*ft,be+=d*Ct,pe+=d*kt,W+=d*vt,q+=d*Dt,re+=d*Wt,X+=d*qt,Z+=d*Kt,d=A[11],Fe+=d*I,De+=d*Ve,Oe+=d*rt,Ue+=d*it,_e+=d*Ke,xe+=d*Ze,me+=d*et,Ee+=d*Bt,be+=d*ft,pe+=d*Ct,W+=d*kt,q+=d*vt,re+=d*Dt,X+=d*Wt,Z+=d*qt,oe+=d*Kt,d=A[12],De+=d*I,Oe+=d*Ve,Ue+=d*rt,_e+=d*it,xe+=d*Ke,me+=d*Ze,Ee+=d*et,be+=d*Bt,pe+=d*ft,W+=d*Ct,q+=d*kt,re+=d*vt,X+=d*Dt,Z+=d*Wt,oe+=d*qt,ke+=d*Kt,d=A[13],Oe+=d*I,Ue+=d*Ve,_e+=d*rt,xe+=d*it,me+=d*Ke,Ee+=d*Ze,be+=d*et,pe+=d*Bt,W+=d*ft,q+=d*Ct,re+=d*kt,X+=d*vt,Z+=d*Dt,oe+=d*Wt,ke+=d*qt,Qe+=d*Kt,d=A[14],Ue+=d*I,_e+=d*Ve,xe+=d*rt,me+=d*it,Ee+=d*Ke,be+=d*Ze,pe+=d*et,W+=d*Bt,q+=d*ft,re+=d*Ct,X+=d*kt,Z+=d*vt,oe+=d*Dt,ke+=d*Wt,Qe+=d*qt,qe+=d*Kt,d=A[15],_e+=d*I,xe+=d*Ve,me+=d*rt,Ee+=d*it,be+=d*Ke,pe+=d*Ze,W+=d*et,q+=d*Bt,re+=d*ft,X+=d*Ct,Z+=d*kt,oe+=d*vt,ke+=d*Dt,Qe+=d*Wt,qe+=d*qt,We+=d*Kt,$+=38*xe,F+=38*me,J+=38*Ee,ae+=38*be,ye+=38*pe,ge+=38*W,nt+=38*q,Ae+=38*re,Le+=38*X,$e+=38*Z,He+=38*oe,Fe+=38*ke,De+=38*Qe,Oe+=38*qe,Ue+=38*We,E=1,d=$+E+65535,E=Math.floor(d/65536),$=d-E*65536,d=F+E+65535,E=Math.floor(d/65536),F=d-E*65536,d=J+E+65535,E=Math.floor(d/65536),J=d-E*65536,d=ae+E+65535,E=Math.floor(d/65536),ae=d-E*65536,d=ye+E+65535,E=Math.floor(d/65536),ye=d-E*65536,d=ge+E+65535,E=Math.floor(d/65536),ge=d-E*65536,d=nt+E+65535,E=Math.floor(d/65536),nt=d-E*65536,d=Ae+E+65535,E=Math.floor(d/65536),Ae=d-E*65536,d=Le+E+65535,E=Math.floor(d/65536),Le=d-E*65536,d=$e+E+65535,E=Math.floor(d/65536),$e=d-E*65536,d=He+E+65535,E=Math.floor(d/65536),He=d-E*65536,d=Fe+E+65535,E=Math.floor(d/65536),Fe=d-E*65536,d=De+E+65535,E=Math.floor(d/65536),De=d-E*65536,d=Oe+E+65535,E=Math.floor(d/65536),Oe=d-E*65536,d=Ue+E+65535,E=Math.floor(d/65536),Ue=d-E*65536,d=_e+E+65535,E=Math.floor(d/65536),_e=d-E*65536,$+=E-1+37*(E-1),E=1,d=$+E+65535,E=Math.floor(d/65536),$=d-E*65536,d=F+E+65535,E=Math.floor(d/65536),F=d-E*65536,d=J+E+65535,E=Math.floor(d/65536),J=d-E*65536,d=ae+E+65535,E=Math.floor(d/65536),ae=d-E*65536,d=ye+E+65535,E=Math.floor(d/65536),ye=d-E*65536,d=ge+E+65535,E=Math.floor(d/65536),ge=d-E*65536,d=nt+E+65535,E=Math.floor(d/65536),nt=d-E*65536,d=Ae+E+65535,E=Math.floor(d/65536),Ae=d-E*65536,d=Le+E+65535,E=Math.floor(d/65536),Le=d-E*65536,d=$e+E+65535,E=Math.floor(d/65536),$e=d-E*65536,d=He+E+65535,E=Math.floor(d/65536),He=d-E*65536,d=Fe+E+65535,E=Math.floor(d/65536),Fe=d-E*65536,d=De+E+65535,E=Math.floor(d/65536),De=d-E*65536,d=Oe+E+65535,E=Math.floor(d/65536),Oe=d-E*65536,d=Ue+E+65535,E=Math.floor(d/65536),Ue=d-E*65536,d=_e+E+65535,E=Math.floor(d/65536),_e=d-E*65536,$+=E-1+37*(E-1),g[0]=$,g[1]=F,g[2]=J,g[3]=ae,g[4]=ye,g[5]=ge,g[6]=nt,g[7]=Ae,g[8]=Le,g[9]=$e,g[10]=He,g[11]=Fe,g[12]=De,g[13]=Oe,g[14]=Ue,g[15]=_e}function je(g,A){ie(g,A,A)}function lt(g,A){var m=t(),d;for(d=0;d<16;d++)m[d]=A[d];for(d=253;d>=0;d--)je(m,m),d!==2&&d!==4&&ie(m,m,A);for(d=0;d<16;d++)g[d]=m[d]}function sn(g,A){var m=t(),d;for(d=0;d<16;d++)m[d]=A[d];for(d=250;d>=0;d--)je(m,m),d!==1&&ie(m,m,A);for(d=0;d<16;d++)g[d]=m[d]}function mr(g,A,m){var d=new Uint8Array(32),E=new Float64Array(80),$,F,J=t(),ae=t(),ye=t(),ge=t(),nt=t(),Ae=t();for(F=0;F<31;F++)d[F]=A[F];for(d[31]=A[31]&127|64,d[0]&=248,K(E,m),F=0;F<16;F++)ae[F]=E[F],ge[F]=J[F]=ye[F]=0;for(J[0]=ge[0]=1,F=254;F>=0;--F)$=d[F>>>3]>>>(F&7)&1,le(J,ae,$),le(ye,ge,$),ee(nt,J,ye),ue(J,J,ye),ee(ye,ae,ge),ue(ae,ae,ge),je(ge,nt),je(Ae,J),ie(J,ye,J),ie(ye,ae,nt),ee(nt,J,ye),ue(J,J,ye),je(ae,J),ue(ye,ge,Ae),ie(J,ye,a),ee(J,J,ge),ie(ye,ye,J),ie(J,ge,Ae),ie(ge,ae,E),je(ae,nt),le(J,ae,$),le(ye,ge,$);for(F=0;F<16;F++)E[F+16]=J[F],E[F+32]=ye[F],E[F+48]=ae[F],E[F+64]=ge[F];var Le=E.subarray(32),$e=E.subarray(16);return lt(Le,Le),ie($e,$e,Le),O(g,$e),0}function Ar(g,A){return mr(g,A,s)}function Rn(g,A){return e(A,32),Ar(g,A)}function yr(g,A,m){var d=new Uint8Array(32);return mr(d,m,A),C(g,r,d,U)}var Zr=ne,Qi=z;function ei(g,A,m,d,E,$){var F=new Uint8Array(32);return yr(F,E,$),Zr(g,A,m,d,F)}function _r(g,A,m,d,E,$){var F=new Uint8Array(32);return yr(F,E,$),Qi(g,A,m,d,F)}var Er=[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 j(g,A,m,d){for(var E=new Int32Array(16),$=new Int32Array(16),F,J,ae,ye,ge,nt,Ae,Le,$e,He,Fe,De,Oe,Ue,_e,xe,me,Ee,be,pe,W,q,re,X,Z,oe,ke=g[0],Qe=g[1],qe=g[2],We=g[3],I=g[4],Ve=g[5],rt=g[6],it=g[7],Ke=A[0],Ze=A[1],et=A[2],Bt=A[3],ft=A[4],Ct=A[5],kt=A[6],vt=A[7],Dt=0;d>=128;){for(be=0;be<16;be++)pe=8*be+Dt,E[be]=m[pe+0]<<24|m[pe+1]<<16|m[pe+2]<<8|m[pe+3],$[be]=m[pe+4]<<24|m[pe+5]<<16|m[pe+6]<<8|m[pe+7];for(be=0;be<80;be++)if(F=ke,J=Qe,ae=qe,ye=We,ge=I,nt=Ve,Ae=rt,Le=it,$e=Ke,He=Ze,Fe=et,De=Bt,Oe=ft,Ue=Ct,_e=kt,xe=vt,W=it,q=vt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=(I>>>14|ft<<18)^(I>>>18|ft<<14)^(ft>>>9|I<<23),q=(ft>>>14|I<<18)^(ft>>>18|I<<14)^(I>>>9|ft<<23),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=I&Ve^~I&rt,q=ft&Ct^~ft&kt,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=Er[be*2],q=Er[be*2+1],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=E[be%16],q=$[be%16],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,me=Z&65535|oe<<16,Ee=re&65535|X<<16,W=me,q=Ee,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=(ke>>>28|Ke<<4)^(Ke>>>2|ke<<30)^(Ke>>>7|ke<<25),q=(Ke>>>28|ke<<4)^(ke>>>2|Ke<<30)^(ke>>>7|Ke<<25),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=ke&Qe^ke&qe^Qe&qe,q=Ke&Ze^Ke&et^Ze&et,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,Le=Z&65535|oe<<16,xe=re&65535|X<<16,W=ye,q=De,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=me,q=Ee,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,ye=Z&65535|oe<<16,De=re&65535|X<<16,Qe=F,qe=J,We=ae,I=ye,Ve=ge,rt=nt,it=Ae,ke=Le,Ze=$e,et=He,Bt=Fe,ft=De,Ct=Oe,kt=Ue,vt=_e,Ke=xe,be%16===15)for(pe=0;pe<16;pe++)W=E[pe],q=$[pe],re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=E[(pe+9)%16],q=$[(pe+9)%16],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,me=E[(pe+1)%16],Ee=$[(pe+1)%16],W=(me>>>1|Ee<<31)^(me>>>8|Ee<<24)^me>>>7,q=(Ee>>>1|me<<31)^(Ee>>>8|me<<24)^(Ee>>>7|me<<25),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,me=E[(pe+14)%16],Ee=$[(pe+14)%16],W=(me>>>19|Ee<<13)^(Ee>>>29|me<<3)^me>>>6,q=(Ee>>>19|me<<13)^(me>>>29|Ee<<3)^(Ee>>>6|me<<26),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,E[pe]=Z&65535|oe<<16,$[pe]=re&65535|X<<16;W=ke,q=Ke,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[0],q=A[0],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[0]=ke=Z&65535|oe<<16,A[0]=Ke=re&65535|X<<16,W=Qe,q=Ze,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[1],q=A[1],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[1]=Qe=Z&65535|oe<<16,A[1]=Ze=re&65535|X<<16,W=qe,q=et,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[2],q=A[2],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[2]=qe=Z&65535|oe<<16,A[2]=et=re&65535|X<<16,W=We,q=Bt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[3],q=A[3],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[3]=We=Z&65535|oe<<16,A[3]=Bt=re&65535|X<<16,W=I,q=ft,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[4],q=A[4],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[4]=I=Z&65535|oe<<16,A[4]=ft=re&65535|X<<16,W=Ve,q=Ct,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[5],q=A[5],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[5]=Ve=Z&65535|oe<<16,A[5]=Ct=re&65535|X<<16,W=rt,q=kt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[6],q=A[6],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[6]=rt=Z&65535|oe<<16,A[6]=kt=re&65535|X<<16,W=it,q=vt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[7],q=A[7],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[7]=it=Z&65535|oe<<16,A[7]=vt=re&65535|X<<16,Dt+=128,d-=128}return d}function he(g,A,m){var d=new Int32Array(8),E=new Int32Array(8),$=new Uint8Array(256),F,J=m;for(d[0]=1779033703,d[1]=3144134277,d[2]=1013904242,d[3]=2773480762,d[4]=1359893119,d[5]=2600822924,d[6]=528734635,d[7]=1541459225,E[0]=4089235720,E[1]=2227873595,E[2]=4271175723,E[3]=1595750129,E[4]=2917565137,E[5]=725511199,E[6]=4215389547,E[7]=327033209,j(d,E,A,m),m%=128,F=0;F<m;F++)$[F]=A[J-m+F];for($[m]=128,m=256-128*(m<112?1:0),$[m-9]=0,p($,m-8,J/536870912|0,J<<3),j(d,E,$,m),F=0;F<8;F++)p(g,8*F,d[F],E[F]);return 0}function Se(g,A){var m=t(),d=t(),E=t(),$=t(),F=t(),J=t(),ae=t(),ye=t(),ge=t();ue(m,g[1],g[0]),ue(ge,A[1],A[0]),ie(m,m,ge),ee(d,g[0],g[1]),ee(ge,A[0],A[1]),ie(d,d,ge),ie(E,g[3],A[3]),ie(E,E,l),ie($,g[2],A[2]),ee($,$,$),ue(F,d,m),ue(J,$,E),ee(ae,$,E),ee(ye,d,m),ie(g[0],F,J),ie(g[1],ye,ae),ie(g[2],ae,J),ie(g[3],F,ye)}function Te(g,A,m){var d;for(d=0;d<4;d++)le(g[d],A[d],m)}function Xe(g,A){var m=t(),d=t(),E=t();lt(E,A[2]),ie(m,A[0],E),ie(d,A[1],E),O(g,d),g[31]^=L(m)<<7}function Tt(g,A,m){var d,E;for(Y(g[0],i),Y(g[1],o),Y(g[2],o),Y(g[3],i),E=255;E>=0;--E)d=m[E/8|0]>>(E&7)&1,Te(g,A,d),Se(A,g),Se(g,g),Te(g,A,d)}function Sn(g,A){var m=[t(),t(),t(),t()];Y(m[0],f),Y(m[1],u),Y(m[2],o),ie(m[3],f,u),Tt(g,m,A)}function on(g,A,m){var d=new Uint8Array(64),E=[t(),t(),t(),t()],$;for(m||e(A,32),he(d,A,32),d[0]&=248,d[31]&=127,d[31]|=64,Sn(E,d),Xe(g,E),$=0;$<32;$++)A[$+32]=g[$];return 0}var br=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 ot(g,A){var m,d,E,$;for(d=63;d>=32;--d){for(m=0,E=d-32,$=d-12;E<$;++E)A[E]+=m-16*A[d]*br[E-(d-32)],m=A[E]+128>>8,A[E]-=m*256;A[E]+=m,A[d]=0}for(m=0,E=0;E<32;E++)A[E]+=m-(A[31]>>4)*br[E],m=A[E]>>8,A[E]&=255;for(E=0;E<32;E++)A[E]-=m*br[E];for(d=0;d<32;d++)A[d+1]+=A[d]>>8,g[d]=A[d]&255}function Ut(g){var A=new Float64Array(64),m;for(m=0;m<64;m++)A[m]=g[m];for(m=0;m<64;m++)g[m]=0;ot(g,A)}function $t(g,A,m,d){var E=new Uint8Array(64),$=new Uint8Array(64),F=new Uint8Array(64),J,ae,ye=new Float64Array(64),ge=[t(),t(),t(),t()];he(E,d,32),E[0]&=248,E[31]&=127,E[31]|=64;var nt=m+64;for(J=0;J<m;J++)g[64+J]=A[J];for(J=0;J<32;J++)g[32+J]=E[32+J];for(he(F,g.subarray(32),m+32),Ut(F),Sn(ge,F),Xe(g,ge),J=32;J<64;J++)g[J]=d[J];for(he($,g,m+64),Ut($),J=0;J<64;J++)ye[J]=0;for(J=0;J<32;J++)ye[J]=F[J];for(J=0;J<32;J++)for(ae=0;ae<32;ae++)ye[J+ae]+=$[J]*E[ae];return ot(g.subarray(32),ye),nt}function wt(g,A){var m=t(),d=t(),E=t(),$=t(),F=t(),J=t(),ae=t();return Y(g[2],o),K(g[1],A),je(E,g[1]),ie($,E,c),ue(E,E,g[2]),ee($,g[2],$),je(F,$),je(J,F),ie(ae,J,F),ie(m,ae,E),ie(m,m,$),sn(m,m),ie(m,m,E),ie(m,m,$),ie(m,m,$),ie(g[0],m,$),je(d,g[0]),ie(d,d,$),N(d,E)&&ie(g[0],g[0],h),je(d,g[0]),ie(d,d,$),N(d,E)?-1:(L(g[0])===A[31]>>7&&ue(g[0],i,g[0]),ie(g[3],g[0],g[1]),0)}function pt(g,A,m,d){var E,$,F=new Uint8Array(32),J=new Uint8Array(64),ae=[t(),t(),t(),t()],ye=[t(),t(),t(),t()];if($=-1,m<64||wt(ye,d))return-1;for(E=0;E<m;E++)g[E]=A[E];for(E=0;E<32;E++)g[E+32]=d[E];if(he(J,g,m),Ut(J),Tt(ae,ye,J),Sn(ye,A.subarray(32)),Se(ae,ye),Xe(F,ae),m-=64,x(A,0,F,0)){for(E=0;E<m;E++)g[E]=0;return-1}for(E=0;E<m;E++)g[E]=A[E+64];return $=m,$}var un=32,It=24,ir=32,xr=16,ti=32,Wi=32,ni=32,ri=32,oo=32,Ic=It,Zh=ir,ep=xr,Nn=64,sr=32,Sr=64,ao=32,co=64;n.lowlevel={crypto_core_hsalsa20:C,crypto_stream_xor:w,crypto_stream:b,crypto_stream_salsa20_xor:Q,crypto_stream_salsa20:B,crypto_onetimeauth:v,crypto_onetimeauth_verify:P,crypto_verify_16:_,crypto_verify_32:x,crypto_secretbox:ne,crypto_secretbox_open:z,crypto_scalarmult:mr,crypto_scalarmult_base:Ar,crypto_box_beforenm:yr,crypto_box_afternm:Zr,crypto_box:ei,crypto_box_open:_r,crypto_box_keypair:Rn,crypto_hash:he,crypto_sign:$t,crypto_sign_keypair:on,crypto_sign_open:pt,crypto_secretbox_KEYBYTES:un,crypto_secretbox_NONCEBYTES:It,crypto_secretbox_ZEROBYTES:ir,crypto_secretbox_BOXZEROBYTES:xr,crypto_scalarmult_BYTES:ti,crypto_scalarmult_SCALARBYTES:Wi,crypto_box_PUBLICKEYBYTES:ni,crypto_box_SECRETKEYBYTES:ri,crypto_box_BEFORENMBYTES:oo,crypto_box_NONCEBYTES:Ic,crypto_box_ZEROBYTES:Zh,crypto_box_BOXZEROBYTES:ep,crypto_sign_BYTES:Nn,crypto_sign_PUBLICKEYBYTES:sr,crypto_sign_SECRETKEYBYTES:Sr,crypto_sign_SEEDBYTES:ao,crypto_hash_BYTES:co};function Cc(g,A){if(g.length!==un)throw new Error("bad key size");if(A.length!==It)throw new Error("bad nonce size")}function tp(g,A){if(g.length!==ni)throw new Error("bad public key size");if(A.length!==ri)throw new Error("bad secret key size")}function an(){var g,A;for(A=0;A<arguments.length;A++)if((g=Object.prototype.toString.call(arguments[A]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+g+", use Uint8Array")}function kc(g){for(var A=0;A<g.length;A++)g[A]=0}n.util||(n.util={},n.util.decodeUTF8=n.util.encodeUTF8=n.util.encodeBase64=n.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),n.randomBytes=function(g){var A=new Uint8Array(g);return e(A,g),A},n.secretbox=function(g,A,m){an(g,A,m),Cc(m,A);for(var d=new Uint8Array(ir+g.length),E=new Uint8Array(d.length),$=0;$<g.length;$++)d[$+ir]=g[$];return ne(E,d,d.length,A,m),E.subarray(xr)},n.secretbox.open=function(g,A,m){an(g,A,m),Cc(m,A);for(var d=new Uint8Array(xr+g.length),E=new Uint8Array(d.length),$=0;$<g.length;$++)d[$+xr]=g[$];return d.length<32||z(E,d,d.length,A,m)!==0?!1:E.subarray(ir)},n.secretbox.keyLength=un,n.secretbox.nonceLength=It,n.secretbox.overheadLength=xr,n.scalarMult=function(g,A){if(an(g,A),g.length!==Wi)throw new Error("bad n size");if(A.length!==ti)throw new Error("bad p size");var m=new Uint8Array(ti);return mr(m,g,A),m},n.scalarMult.base=function(g){if(an(g),g.length!==Wi)throw new Error("bad n size");var A=new Uint8Array(ti);return Ar(A,g),A},n.scalarMult.scalarLength=Wi,n.scalarMult.groupElementLength=ti,n.box=function(g,A,m,d){var E=n.box.before(m,d);return n.secretbox(g,A,E)},n.box.before=function(g,A){an(g,A),tp(g,A);var m=new Uint8Array(oo);return yr(m,g,A),m},n.box.after=n.secretbox,n.box.open=function(g,A,m,d){var E=n.box.before(m,d);return n.secretbox.open(g,A,E)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var g=new Uint8Array(ni),A=new Uint8Array(ri);return Rn(g,A),{publicKey:g,secretKey:A}},n.box.keyPair.fromSecretKey=function(g){if(an(g),g.length!==ri)throw new Error("bad secret key size");var A=new Uint8Array(ni);return Ar(A,g),{publicKey:A,secretKey:new Uint8Array(g)}},n.box.publicKeyLength=ni,n.box.secretKeyLength=ri,n.box.sharedKeyLength=oo,n.box.nonceLength=Ic,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(g,A){if(an(g,A),A.length!==Sr)throw new Error("bad secret key size");var m=new Uint8Array(Nn+g.length);return $t(m,g,g.length,A),m},n.sign.open=function(g,A){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(an(g,A),A.length!==sr)throw new Error("bad public key size");var m=new Uint8Array(g.length),d=pt(m,g,g.length,A);if(d<0)return null;for(var E=new Uint8Array(d),$=0;$<E.length;$++)E[$]=m[$];return E},n.sign.detached=function(g,A){for(var m=n.sign(g,A),d=new Uint8Array(Nn),E=0;E<d.length;E++)d[E]=m[E];return d},n.sign.detached.verify=function(g,A,m){if(an(g,A,m),A.length!==Nn)throw new Error("bad signature size");if(m.length!==sr)throw new Error("bad public key size");var d=new Uint8Array(Nn+g.length),E=new Uint8Array(Nn+g.length),$;for($=0;$<Nn;$++)d[$]=A[$];for($=0;$<g.length;$++)d[$+Nn]=g[$];return pt(E,d,d.length,m)>=0},n.sign.keyPair=function(){var g=new Uint8Array(sr),A=new Uint8Array(Sr);return on(g,A),{publicKey:g,secretKey:A}},n.sign.keyPair.fromSecretKey=function(g){if(an(g),g.length!==Sr)throw new Error("bad secret key size");for(var A=new Uint8Array(sr),m=0;m<A.length;m++)A[m]=g[32+m];return{publicKey:A,secretKey:new Uint8Array(g)}},n.sign.keyPair.fromSeed=function(g){if(an(g),g.length!==ao)throw new Error("bad seed size");for(var A=new Uint8Array(sr),m=new Uint8Array(Sr),d=0;d<32;d++)m[d]=g[d];return on(A,m,!0),{publicKey:A,secretKey:m}},n.sign.publicKeyLength=sr,n.sign.secretKeyLength=Sr,n.sign.seedLength=ao,n.sign.signatureLength=Nn,n.hash=function(g){an(g);var A=new Uint8Array(co);return he(A,g,g.length),A},n.hash.hashLength=co,n.verify=function(g,A){return an(g,A),g.length===0||A.length===0||g.length!==A.length?!1:y(g,0,A,0,g.length)===0},n.setPRNG=function(g){e=g},(function(){var g=typeof self<"u"?self.crypto||self.msCrypto:null;if(g&&g.getRandomValues){var A=65536;n.setPRNG(function(m,d){var E,$=new Uint8Array(d);for(E=0;E<d;E+=A)g.getRandomValues($.subarray(E,E+Math.min(d-E,A)));for(E=0;E<d;E++)m[E]=$[E];kc($)})}else typeof require<"u"&&(g=require("crypto"),g&&g.randomBytes&&n.setPRNG(function(m,d){var E,$=g.randomBytes(d);for(E=0;E<d;E++)m[E]=$[E];kc($)}))})()})(typeof Ji<"u"&&Ji.exports?Ji.exports:self.nacl=self.nacl||{})});var Ao=ct((Hy,Fc)=>{"use strict";var po=Mc().lowlevel.crypto_hash,Pn=0,ar=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 es(n,t,e){return(n[0][t[e+3]]+n[1][t[e+2]]^n[2][t[e+1]])+n[3][t[e]]}ar.prototype.encipher=function(n,t){t===void 0&&(t=new Uint8Array(n.buffer),n.byteOffset!==0&&(t=t.subarray(n.byteOffset))),n[0]^=this.P[0];for(var e=1;e<16;e+=2)n[1]^=es(this.S,t,0)^this.P[e],n[0]^=es(this.S,t,4)^this.P[e+1];var r=n[0];n[0]=n[1]^this.P[17],n[1]=r};ar.prototype.decipher=function(n){var t=new Uint8Array(n.buffer);n.byteOffset!==0&&(t=t.subarray(n.byteOffset)),n[0]^=this.P[17];for(var e=16;e>0;e-=2)n[1]^=es(this.S,t,0)^this.P[e],n[0]^=es(this.S,t,4)^this.P[e-1];var r=n[0];n[0]=n[1]^this.P[0],n[1]=r};function or(n,t){var e,r=0;for(e=0;e<4;e++,Pn++)Pn>=t&&(Pn=0),r=r<<8|n[Pn];return r}ar.prototype.expand0state=function(n,t){var e=new Uint32Array(2),r,s,i=new Uint8Array(e.buffer);for(r=0,Pn=0;r<18;r++)this.P[r]^=or(n,t);for(Pn=0,r=0;r<18;r+=2)this.encipher(e,i),this.P[r]=e[0],this.P[r+1]=e[1];for(r=0;r<4;r++)for(s=0;s<256;s+=2)this.encipher(e,i),this.S[r][s]=e[0],this.S[r][s+1]=e[1]};ar.prototype.expandstate=function(n,t,e,r){var s=new Uint32Array(2),i,o;for(i=0,Pn=0;i<18;i++)this.P[i]^=or(e,r);for(i=0,Pn=0;i<18;i+=2)s[0]^=or(n,t),s[1]^=or(n,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]^=or(n,t),s[1]^=or(n,t),this.encipher(s),this.S[i][o]=s[0],this.S[i][o+1]=s[1];Pn=0};ar.prototype.enc=function(n,t){for(var e=0;e<t;e++)this.encipher(n.subarray(e*2))};ar.prototype.dec=function(n,t){for(var e=0;e<t;e++)this.decipher(n.subarray(e*2))};var Zi=8,go=32;function mo(n,t,e){var r=new ar,s=new Uint32Array(Zi),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(r.expandstate(t,64,n,64),i=0;i<64;i++)r.expand0state(t,64),r.expand0state(n,64);for(i=0;i<Zi;i++)s[i]=or(o,o.byteLength);for(i=0;i<64;i++)r.enc(s,s.byteLength/8);for(i=0;i<Zi;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 gp(n,t,e,r,s,i,o){var a=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(go),f=new Uint8Array(go),u=new Uint8Array(r+4),h,p,y,_,x,S,R=i;if(o<1||t===0||r===0||i===0||i>l.byteLength*l.byteLength||r>1<<20)return-1;for(_=Math.floor((i+l.byteLength-1)/l.byteLength),y=Math.floor((i+_-1)/_),h=0;h<r;h++)u[h]=e[h];for(po(a,n,t),S=1;i>0;S++){for(u[r+0]=S>>>24,u[r+1]=S>>>16,u[r+2]=S>>>8,u[r+3]=S,po(c,u,r+4),mo(a,c,f),h=l.byteLength;h--;)l[h]=f[h];for(h=1;h<o;h++)for(po(c,f,f.byteLength),mo(a,c,f),p=0;p<l.byteLength;p++)l[p]^=f[p];for(y=Math.min(y,i),h=0;h<y&&(x=h*_+(S-1),!(x>=R));h++)s[x]=l[h];i-=h}return 0}Fc.exports={BLOCKS:Zi,HASHSIZE:go,hash:mo,pbkdf:gp}});var Ln=ct((Qy,ns)=>{"use strict";var Tn=require("crypto"),vr;try{vr=require("cpu-features")()}catch{}var{bindingAvailable:Hc,CIPHER_INFO:mp,MAC_INFO:Ap}=qn(),Qc=(()=>{if(typeof Tn.sign=="function"&&typeof Tn.verify=="function"){let n=`-----BEGIN PRIVATE KEY-----\r
|
|
2
3
|
MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
|
|
3
|
-
-----END PRIVATE KEY-----`,t=Buffer.from("a"),e,r;try{e=Tn.sign(null,t,n),r=Tn.verify(null,t,n,e)}catch{}return Buffer.isBuffer(e)&&e.length===64&&r===!0}return!1})(),Wc=typeof Tn.diffieHellman=="function"&&typeof Tn.generateKeyPairSync=="function"&&typeof Tn.createPublicKey=="function",ts=["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"];Wc&&(ts.unshift("curve25519-sha256"),ts.unshift("curve25519-sha256@libssh.org"));var yp=ts.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),yo=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];Qc&&yo.unshift("ssh-ed25519");var _p=yo.concat(["ssh-dss"]),qc=(()=>{let n=Tn.getCiphers();return t=>n.includes(mp[t].sslName)})(),Wn=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];vr&&vr.flags&&!vr.flags.aes?Hc?Wn.unshift("chacha20-poly1305@openssh.com"):Wn.push("chacha20-poly1305@openssh.com"):Hc&&vr&&vr.arch==="x86"?Wn.splice(4,0,"chacha20-poly1305@openssh.com"):Wn.push("chacha20-poly1305@openssh.com");Wn=Wn.filter(qc);var Ep=Wn.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(qc)),Kc=(()=>{let n=Tn.getHashes();return t=>n.includes(Ap[t].sslName)})(),Vc=["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(Kc),bp=Vc.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(Kc)),Gc=["none","zlib@openssh.com","zlib"],xp=Gc.concat([]),kr={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};ns.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((n,t)=>({...n,[t]:1}),{}),COMPAT:kr,COMPAT_CHECKS:[["Cisco-1.25",kr.BAD_DHGEX],[/^Cisco-1[.]/,kr.BUG_DHGEX_LARGE],[/^[0-9.]+$/,kr.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,kr.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,kr.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:ts,SUPPORTED_KEX:yp,DEFAULT_SERVER_HOST_KEY:yo,SUPPORTED_SERVER_HOST_KEY:_p,DEFAULT_CIPHER:Wn,SUPPORTED_CIPHER:Ep,DEFAULT_MAC:Vc,SUPPORTED_MAC:bp,DEFAULT_COMPRESSION:Gc,SUPPORTED_COMPRESSION:xp,curve25519Supported:Wc,eddsaSupported:Qc};ns.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(ns.exports.DISCONNECT_REASON)).reduce((n,[t,e])=>({...n,[e]:t}),{})});var mn=ct((qy,Xc)=>{"use strict";var pn=si().Ber,rs,jc=Buffer[Symbol.species],Sp=Object.getPrototypeOf(Uint8Array.prototype).fill;function zc(n,t){return n[t++]*16777216+n[t++]*65536+n[t++]*256+n[t]}function oi(n,t,e,r,s){s||(s=0),r>n.length&&(r=n.length);let i=r-e,o=t.length-s;return i>o&&(i=o),t.set(new Uint8Array(n.buffer,n.byteOffset+e,i),s),i}function ai(n,t,e){return e===void 0&&(e=n.length),new jc(n.buffer,n.byteOffset+t,e-t)}function Eo(){let n=0,t,e={init:(r,s)=>{t=r,n=typeof s=="number"?s:0},pos:()=>n,length:()=>t?t.length:0,avail:()=>t&&n<t.length?t.length-n:0,clear:()=>{t=void 0},readUInt32BE:()=>{if(!(!t||n+3>=t.length))return t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]},readUInt64BE:r=>{if(!(!t||n+7>=t.length))switch(r){case"always":return BigInt(`0x${t.hexSlice(n,n+=8)}`);case"maybe":if(t[n]>31)return BigInt(`0x${t.hexSlice(n,n+=8)}`);default:return t[n++]*72057594037927940+t[n++]*281474976710656+t[n++]*1099511627776+t[n++]*4294967296+t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]}},skip:r=>{t&&r>0&&(n+=r)},skipString:()=>{let r=e.readUInt32BE();if(r!==void 0)return n+=r,n<=t.length?r:void 0},readByte:()=>{if(t&&n<t.length)return t[n++]},readBool:()=>{if(t&&n<t.length)return!!t[n++]},readList:()=>{let r=e.readString(!0);if(r!==void 0)return r?r.split(","):[]},readString:(r,s)=>{typeof r=="number"&&(s=r,r=void 0);let i=e.readUInt32BE();if(i!==void 0&&!(t.length-n<i||typeof s=="number"&&i>s))return r?Buffer.isBuffer(r)?oi(t,r,n,n+=i):t.utf8Slice(n,n+=i):ai(t,n,n+=i)},readRaw:r=>{if(t){if(typeof r!="number")return ai(t,n,n+=t.length-n);if(t.length-n>=r)return ai(t,n,n+=r)}}};return e}function Yc(n,t,e){let r=new Error(n);return typeof t=="boolean"?(e=t,r.level="protocol"):r.level=t||"protocol",r.fatal=!!e,r}function _o(n,t,e){return n[e++]=t>>>24,n[e++]=t>>>16,n[e++]=t>>>8,n[e++]=t,e}var is=Eo();Xc.exports={bufferCopy:oi,bufferSlice:ai,FastBuffer:jc,bufferFill:(n,t,e,r)=>Sp.call(n,t,e,r),makeError:Yc,doFatalError:(n,t,e,r)=>{let s;return rs===void 0&&({DISCONNECT_REASON:rs}=Ln()),t instanceof Error?(s=t,typeof e!="number"?r=rs.PROTOCOL_ERROR:r=e):s=Yc(t,e,!0),typeof r!="number"&&(r=rs.PROTOCOL_ERROR),n.disconnect(r),n._destruct(),n._onError(s),1/0},readUInt32BE:zc,writeUInt32BE:_o,writeUInt32LE:(n,t,e)=>(n[e++]=t,n[e++]=t>>>8,n[e++]=t>>>16,n[e++]=t>>>24,e),makeBufferParser:Eo,bufferParser:Eo(),readString:(n,t,e,r)=>{typeof e=="number"&&(r=e,e=void 0),t===void 0&&(t=0);let s=n.length-t;if(t<0||t>=n.length||s<4)return;let i=zc(n,t);if(s<4+i||typeof r=="number"&&i>r)return;t+=4;let o=t+i;return n._pos=o,e?Buffer.isBuffer(e)?oi(n,e,t,o):n.utf8Slice(t,o):ai(n,t,o)},sigSSHToASN1:(n,t)=>{switch(t){case"ssh-dss":{if(n.length>40)return n;let e=new pn.Writer;e.startSequence();let r=n.slice(0,20),s=n.slice(20);if(r[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,r.copy(i,1),r=i}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(s[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,s.copy(i,1),s=i}else s[0]===0&&!(s[1]&128)&&(s=s.slice(1));return e.writeBuffer(r,pn.Integer),e.writeBuffer(s,pn.Integer),e.endSequence(),e.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{is.init(n,0);let e=is.readString(),r=is.readString();if(is.clear(),e===void 0||r===void 0)return;let s=new pn.Writer;return s.startSequence(),s.writeBuffer(e,pn.Integer),s.writeBuffer(r,pn.Integer),s.endSequence(),s.buffer}default:return n}},convertSignature:(n,t)=>{switch(t){case"ssh-dss":{if(n.length<=40)return n;let e=new pn.Reader(n);e.readSequence();let r=e.readString(pn.Integer,!0),s=e.readString(pn.Integer,!0),i=0,o=0;if(r.length<20){let c=Buffer.allocUnsafe(20);c.set(r,1),r=c,r[0]=0}if(s.length<20){let c=Buffer.allocUnsafe(20);c.set(s,1),s=c,s[0]=0}r.length>20&&r[0]===0&&(i=1),s.length>20&&s[0]===0&&(o=1);let a=Buffer.allocUnsafe(r.length-i+(s.length-o));return oi(r,a,i,r.length,0),oi(s,a,o,s.length,r.length-i),a}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(n[0]===0)return n;let e=new pn.Reader(n);e.readSequence();let r=e.readString(pn.Integer,!0),s=e.readString(pn.Integer,!0);if(r===null||s===null)return;let i=Buffer.allocUnsafe(4+r.length+4+s.length);return _o(i,r.length,0),i.set(r,4),_o(i,s.length,4+r.length),i.set(s,8+r.length),i}}return n},sendPacket:(n,t,e)=>!e&&n._kexinit!==void 0?(n._queue===void 0&&(n._queue=[]),n._queue.push(t),n._debug&&n._debug("Outbound: ... packet queued"),!1):(n._cipher.encrypt(t),!0)}});var Jc=ct((ss,xo)=>{var bo=(function(){var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),(function(t){t=t||{};var e;e||(e=typeof t<"u"?t:{});var r,s;e.ready=new Promise(function(j,he){r=j,s=he});var i={},o;for(o in e)e.hasOwnProperty(o)&&(i[o]=e[o]);var a=typeof window=="object",c=typeof importScripts=="function",l=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",f="",u,h,p,y,_;l?(f=c?require("path").dirname(f)+"/":__dirname+"/",u=function(j,he){var Se=Rn(j);return Se?he?Se:Se.toString():(y||(y=require("fs")),_||(_=require("path")),j=_.normalize(j),y.readFileSync(j,he?null:"utf8"))},p=function(j){return j=u(j,!0),j.buffer||(j=new Uint8Array(j)),U(j.buffer),j},h=function(j,he,Se){var Te=Rn(j);Te&&he(Te),y||(y=require("fs")),_||(_=require("path")),j=_.normalize(j),y.readFile(j,function(Xe,Tt){Xe?Se(Xe):he(Tt.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),e.inspect=function(){return"[Emscripten Module object]"}):(a||c)&&(c?f=self.location.href:typeof document<"u"&&document.currentScript&&(f=document.currentScript.src),n&&(f=n),f.indexOf("blob:")!==0?f=f.substr(0,f.lastIndexOf("/")+1):f="",u=function(j){try{var he=new XMLHttpRequest;return he.open("GET",j,!1),he.send(null),he.responseText}catch(Xe){if(j=Rn(j)){he=[];for(var Se=0;Se<j.length;Se++){var Te=j[Se];255<Te&&(mr&&U(!1,"Character code "+Te+" ("+String.fromCharCode(Te)+") at offset "+Se+" not in 0x00-0xFF."),Te&=255),he.push(String.fromCharCode(Te))}return he.join("")}throw Xe}},c&&(p=function(j){try{var he=new XMLHttpRequest;return he.open("GET",j,!1),he.responseType="arraybuffer",he.send(null),new Uint8Array(he.response)}catch(Se){if(j=Rn(j))return j;throw Se}}),h=function(j,he,Se){var Te=new XMLHttpRequest;Te.open("GET",j,!0),Te.responseType="arraybuffer",Te.onload=function(){if(Te.status==200||Te.status==0&&Te.response)he(Te.response);else{var Xe=Rn(j);Xe?he(Xe.buffer):Se()}},Te.onerror=Se,Te.send(null)}),e.print||console.log.bind(console);var x=e.printErr||console.warn.bind(console);for(o in i)i.hasOwnProperty(o)&&(e[o]=i[o]);i=null;var S;e.wasmBinary&&(S=e.wasmBinary);var R=e.noExitRuntime||!0;typeof WebAssembly!="object"&&K("no native wasm support detected");var H,C=!1;function U(j,he){j||K("Assertion failed: "+he)}function Q(j){var he=e["_"+j];return U(he,"Cannot call unknown function "+j+", make sure it is exported"),he}function B(j,he,Se,Te){var Xe={string:function(ot){var Ut=0;if(ot!=null&&ot!==0){var $t=(ot.length<<2)+1;Ut=ei($t);var wt=Ut,pt=v;if(0<$t){$t=wt+$t-1;for(var un=0;un<ot.length;++un){var It=ot.charCodeAt(un);if(55296<=It&&57343>=It){var ir=ot.charCodeAt(++un);It=65536+((It&1023)<<10)|ir&1023}if(127>=It){if(wt>=$t)break;pt[wt++]=It}else{if(2047>=It){if(wt+1>=$t)break;pt[wt++]=192|It>>6}else{if(65535>=It){if(wt+2>=$t)break;pt[wt++]=224|It>>12}else{if(wt+3>=$t)break;pt[wt++]=240|It>>18,pt[wt++]=128|It>>12&63}pt[wt++]=128|It>>6&63}pt[wt++]=128|It&63}}pt[wt]=0}}return Ut},array:function(ot){var Ut=ei(ot.length);return k.set(ot,Ut),Ut}},Tt=Q(j),Sn=[];if(j=0,Te)for(var on=0;on<Te.length;on++){var br=Xe[Se[on]];br?(j===0&&(j=Zr()),Sn[on]=br(Te[on])):Sn[on]=Te[on]}return Se=Tt.apply(null,Sn),Se=(function(ot){if(he==="string")if(ot){for(var Ut=v,$t=ot+NaN,wt=ot;Ut[wt]&&!(wt>=$t);)++wt;if(16<wt-ot&&Ut.subarray&&b)ot=b.decode(Ut.subarray(ot,wt));else{for($t="";ot<wt;){var pt=Ut[ot++];if(pt&128){var un=Ut[ot++]&63;if((pt&224)==192)$t+=String.fromCharCode((pt&31)<<6|un);else{var It=Ut[ot++]&63;pt=(pt&240)==224?(pt&15)<<12|un<<6|It:(pt&7)<<18|un<<12|It<<6|Ut[ot++]&63,65536>pt?$t+=String.fromCharCode(pt):(pt-=65536,$t+=String.fromCharCode(55296|pt>>10,56320|pt&1023))}}else $t+=String.fromCharCode(pt)}ot=$t}}else ot="";else ot=he==="boolean"?!!ot:ot;return ot})(Se),j!==0&&Qi(j),Se}var b=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,w,k,v;function P(){var j=H.buffer;w=j,e.HEAP8=k=new Int8Array(j),e.HEAP16=new Int16Array(j),e.HEAP32=new Int32Array(j),e.HEAPU8=v=new Uint8Array(j),e.HEAPU16=new Uint16Array(j),e.HEAPU32=new Uint32Array(j),e.HEAPF32=new Float32Array(j),e.HEAPF64=new Float64Array(j)}var ne,z=[],Y=[],te=[];function le(){var j=e.preRun.shift();z.unshift(j)}var O=0,N=null,L=null;e.preloadedImages={},e.preloadedAudios={};function K(j){throw e.onAbort&&e.onAbort(j),x(j),C=!0,j=new WebAssembly.RuntimeError("abort("+j+"). Build with -s ASSERTIONS=1 for more info."),s(j),j}var ee="data:application/octet-stream;base64,",ue;if(ue="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==",!ue.startsWith(ee)){var ie=ue;ue=e.locateFile?e.locateFile(ie,f):f+ie}function je(){var j=ue;try{if(j==ue&&S)return new Uint8Array(S);var he=Rn(j);if(he)return he;if(p)return p(j);throw"both async and sync fetching of the wasm failed"}catch(Se){K(Se)}}function lt(){if(!S&&(a||c)){if(typeof fetch=="function"&&!ue.startsWith("file://"))return fetch(ue,{credentials:"same-origin"}).then(function(j){if(!j.ok)throw"failed to load wasm binary file at '"+ue+"'";return j.arrayBuffer()}).catch(function(){return je()});if(h)return new Promise(function(j,he){h(ue,function(Se){j(new Uint8Array(Se))},he)})}return Promise.resolve().then(function(){return je()})}function sn(j){for(;0<j.length;){var he=j.shift();if(typeof he=="function")he(e);else{var Se=he.m;typeof Se=="number"?he.l===void 0?ne.get(Se)():ne.get(Se)(he.l):Se(he.l===void 0?null:he.l)}}}var mr=!1,Ar=typeof atob=="function"?atob:function(j){var he="",Se=0;j=j.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var Te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(Se++)),Xe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(Se++)),Tt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(Se++)),Sn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(Se++));Te=Te<<2|Xe>>4,Xe=(Xe&15)<<4|Tt>>2;var on=(Tt&3)<<6|Sn;he+=String.fromCharCode(Te),Tt!==64&&(he+=String.fromCharCode(Xe)),Sn!==64&&(he+=String.fromCharCode(on))}while(Se<j.length);return he};function Rn(j){if(j.startsWith(ee)){if(j=j.slice(ee.length),typeof l=="boolean"&&l){var he=Buffer.from(j,"base64");he=new Uint8Array(he.buffer,he.byteOffset,he.byteLength)}else try{var Se=Ar(j),Te=new Uint8Array(Se.length);for(j=0;j<Se.length;++j)Te[j]=Se.charCodeAt(j);he=Te}catch{throw Error("Converting base64 string to bytes failed.")}return he}}var yr={a:function(j){var he=v.length;if(j>>>=0,2147483648<j)return!1;for(var Se=1;4>=Se;Se*=2){var Te=he*(1+.2/Se);Te=Math.min(Te,j+100663296),Te=Math.max(j,Te),0<Te%65536&&(Te+=65536-Te%65536);e:{try{H.grow(Math.min(2147483648,Te)-w.byteLength+65535>>>16),P();var Xe=1;break e}catch{}Xe=void 0}if(Xe)return!0}return!1}};(function(){function j(Xe){e.asm=Xe.exports,H=e.asm.b,P(),ne=e.asm.j,Y.unshift(e.asm.c),O--,e.monitorRunDependencies&&e.monitorRunDependencies(O),O==0&&(N!==null&&(clearInterval(N),N=null),L&&(Xe=L,L=null,Xe()))}function he(Xe){j(Xe.instance)}function Se(Xe){return lt().then(function(Tt){return WebAssembly.instantiate(Tt,Te)}).then(Xe,function(Tt){x("failed to asynchronously prepare wasm: "+Tt),K(Tt)})}var Te={a:yr};if(O++,e.monitorRunDependencies&&e.monitorRunDependencies(O),e.instantiateWasm)try{return e.instantiateWasm(Te,j)}catch(Xe){return x("Module.instantiateWasm callback failed with error: "+Xe),!1}return(function(){return S||typeof WebAssembly.instantiateStreaming!="function"||ue.startsWith(ee)||ue.startsWith("file://")||typeof fetch!="function"?Se(he):fetch(ue,{credentials:"same-origin"}).then(function(Xe){return WebAssembly.instantiateStreaming(Xe,Te).then(he,function(Tt){return x("wasm streaming compile failed: "+Tt),x("falling back to ArrayBuffer instantiation"),Se(he)})})})().catch(s),{}})(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.c).apply(null,arguments)},e._poly1305_auth=function(){return(e._poly1305_auth=e.asm.d).apply(null,arguments)};var Zr=e.stackSave=function(){return(Zr=e.stackSave=e.asm.e).apply(null,arguments)},Qi=e.stackRestore=function(){return(Qi=e.stackRestore=e.asm.f).apply(null,arguments)},ei=e.stackAlloc=function(){return(ei=e.stackAlloc=e.asm.g).apply(null,arguments)};e._malloc=function(){return(e._malloc=e.asm.h).apply(null,arguments)},e._free=function(){return(e._free=e.asm.i).apply(null,arguments)},e.cwrap=function(j,he,Se,Te){Se=Se||[];var Xe=Se.every(function(Tt){return Tt==="number"});return he!=="string"&&Xe&&!Te?Q(j):function(){return B(j,he,Se,arguments)}};var _r;L=function j(){_r||Er(),_r||(L=j)};function Er(){function j(){if(!_r&&(_r=!0,e.calledRun=!0,!C)){if(sn(Y),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;){var he=e.postRun.shift();te.unshift(he)}sn(te)}}if(!(0<O)){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)le();sn(z),0<O||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),j()},1)):j())}}if(e.run=Er,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return Er(),t.ready})})();typeof ss=="object"&&typeof xo=="object"?xo.exports=bo:typeof define=="function"&&define.amd?define([],function(){return bo}):typeof ss=="object"&&(ss.createPoly1305=bo)});var qn=ct((Ky,rl)=>{"use strict";var{createCipheriv:Rr,createDecipheriv:os,createHmac:So,randomFillSync:cr,timingSafeEqual:wo}=require("crypto"),{readUInt32BE:li,writeUInt32BE:cn}=mn(),Kn=Buffer[Symbol.species],Zc=2**32-1,el=Buffer.alloc(0),Br=Buffer.alloc(4),as=new Map,lr=35e3,Io,Fo,Ho,Qo,Wo,qo,Ko;try{Io=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:Fo,ChaChaPolyCipher:Ho,GenericCipher:Qo,AESGCMDecipher:Wo,ChaChaPolyDecipher:qo,GenericDecipher:Ko}=Io}catch{}var Ht=1,wp=(()=>{function n(t,e,r,s,i,o,a){return{sslName:t,blockLen:e,keyLen:r,ivLen:s!==0||a&Ht?s:e,authLen:i,discardLen:o,stream:!!(a&Ht)}}return{"chacha20-poly1305@openssh.com":n("chacha20",8,64,0,16,0,Ht),"aes128-gcm":n("aes-128-gcm",16,16,12,16,0,Ht),"aes256-gcm":n("aes-256-gcm",16,32,12,16,0,Ht),"aes128-gcm@openssh.com":n("aes-128-gcm",16,16,12,16,0,Ht),"aes256-gcm@openssh.com":n("aes-256-gcm",16,32,12,16,0,Ht),"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,Ht),"aes192-ctr":n("aes-192-ctr",16,24,16,0,0,Ht),"aes256-ctr":n("aes-256-ctr",16,32,16,0,0,Ht),"3des-ctr":n("des-ede3",8,24,8,0,0,Ht),"blowfish-ctr":n("bf-ecb",8,16,8,0,0,Ht),"cast128-ctr":n("cast5-ecb",8,16,8,0,0,Ht),arcfour:n("rc4",8,16,0,0,1536,Ht),arcfour128:n("rc4",8,16,0,0,1536,Ht),arcfour256:n("rc4",8,32,0,0,1536,Ht),arcfour512:n("rc4",8,64,0,0,1536,Ht)}})(),Ip=(()=>{function n(t,e,r,s){return{sslName:t,len:e,actualLen:r,isETM:s}}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)}})(),Co=class{constructor(t,e){this.outSeqno=t,this._onWrite=e,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){this._dead||(this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},tl=Buffer.alloc(32),Jt=Buffer.alloc(16),ci,fi,Vo,ko=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encKeyMain=e.cipherKey.slice(0,32),this._encKeyPktLen=e.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){if(this._dead)return;Jt[0]=0,cn(Jt,this.outSeqno,12);let e=Rr("chacha20",this._encKeyMain,Jt).update(tl),r=Rr("chacha20",this._encKeyPktLen,Jt).update(t.slice(0,4));this._onWrite(r),Jt[0]=1;let s=Rr("chacha20",this._encKeyMain,Jt).update(t.slice(4));this._onWrite(s),Vo(fi,r,r.length,s,s.length,e);let i=Buffer.allocUnsafe(16);i.set(new Uint8Array(ci.HEAPU8.buffer,fi,16),0),this._onWrite(i),this.outSeqno=this.outSeqno+1>>>0}},vo=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new Ho(e.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e+16);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},Bo=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encSSLName=e.cipherInfo.sslName,this._encKey=e.cipherKey,this._encIV=e.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){if(this._dead)return;let e=Rr(this._encSSLName,this._encKey,this._encIV);e.setAutoPadding(!1);let r=t.slice(0,4);e.setAAD(r),this._onWrite(r);let s=e.update(t.slice(4));this._onWrite(s);let i=e.final();i.length&&this._onWrite(i);let o=e.getAuthTag();this._onWrite(o),nl(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},Ro=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new Fo(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e+16);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},No=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._cipherInstance=Rr(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let r=e.cipherInfo.discardLen;if(r){let s=as.get(r);s===void 0&&(s=Buffer.alloc(r),as.set(r,s)),this._cipherInstance.update(s)}}free(){this._dead=!0}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r);return cn(i,r-4,0),i[4]=s,cr(i,5+t,s),i}encrypt(t){if(this._dead)return;let e;if(this._macETM){let s=new Uint8Array(t.buffer,t.byteOffset,4),i=this._cipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+4,t.length-4));this._onWrite(s),this._onWrite(i),e=So(this._macSSLName,this._macKey),cn(Br,this.outSeqno,0),e.update(Br),e.update(s),e.update(i)}else{let s=this._cipherInstance.update(t);this._onWrite(s),e=So(this._macSSLName,this._macKey),cn(Br,this.outSeqno,0),e.update(Br),e.update(t)}let r=e.digest();r.length>this._macActualLen&&(r=r.slice(0,this._macActualLen)),this._onWrite(r),this.outSeqno=this.outSeqno+1>>>0}},Po=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._macLen=e.macInfo.len,this._macActualLen=e.macInfo.actualLen,this._aadLen=e.macInfo.isETM?4:0,this._instance=new Qo(e.cipherInfo.sslName,e.cipherKey,e.cipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r+this._macLen);return cn(i,r-4,0),i[4]=s,cr(i,5+t,s),i}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._macActualLen<this._macLen&&(t=new Kn(t.buffer,t.byteOffset,t.length-(this._macLen-this._macActualLen))),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},To=class{constructor(t,e){this.inSeqno=t,this._onPayload=e,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len>lr||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._packetPos<this._len){let i=Math.min(this._len-this._packetPos,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),e+=i,this._packetPos+=i,this._packetPos<this._len)return}let s=this._packet?new Kn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):el;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Lo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decKeyMain=e.decipherKey.slice(0,32),this._decKeyPktLen=e.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(t,e,r){for(;e<r;){if(this._lenPos<4){let a=Math.min(4-this._lenPos,r-e);for(;a--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;Jt[0]=0,cn(Jt,this.inSeqno,12);let c=os("chacha20",this._decKeyPktLen,Jt).update(this._lenBuf);if(this._len=li(c,0),this._len>lr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(e>=r)return;let a=Math.min(this._len-this._pktLen,r-e),c;if(e!==0||a!==r?c=new Uint8Array(t.buffer,t.byteOffset+e,a):c=t,a===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._pktLen)),e+=a,this._pktLen+=a,this._pktLen<this._len||e>=r)return}{let a=Math.min(16-this._macPos,r-e);if(e!==0||a!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,a),this._macPos):this._mac.set(t,this._macPos),e+=a,this._macPos+=a,this._macPos<16)return}Jt[0]=0,cn(Jt,this.inSeqno,12);let s=Rr("chacha20",this._decKeyMain,Jt).update(tl);if(Vo(fi,this._lenBuf,4,this._packet,this._packet.length,s),this._calcMac.set(new Uint8Array(ci.HEAPU8.buffer,fi,16),0),!wo(this._calcMac,this._mac))throw new Error("Invalid MAC");Jt[0]=1;let i=os("chacha20",this._decKeyMain,Jt).update(this._packet),o=new Kn(i.buffer,i.byteOffset+1,i.length-i[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let a=this._onPayload(o);if(a!==void 0)return a===!1?e:a}}}},$o=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new qo(e.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(t,e,r){for(;e<r;){if(this._lenPos<4){let i=Math.min(4-this._lenPos,r-e);for(;i--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>lr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let s=new Kn(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;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Do=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=null,this._decipherSSLName=e.decipherInfo.sslName,this._decipherKey=e.decipherKey,this._decipherIV=e.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(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>lr||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=os(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(Cp(this._len))}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=this._decipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+e,i)):o=this._decipherInstance.update(t),o.length&&(i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),this._packetPos+=o.length),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let i=this._decipherInstance.final();i.length&&(this._packet?this._packet.set(i,this._packetPos):this._packet=i)}let s=this._packet?new Kn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):el;this.inSeqno=this.inSeqno+1>>>0,nl(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Uo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Wo(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>lr||this._len<16||(this._len&15)!==0)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let s=new Kn(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;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Oo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=os(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(e.macInfo.isETM?4:e.decipherInfo.blockLen),this._blockSize=e.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._macInstance=null;let r=e.decipherInfo.discardLen;if(r){let s=as.get(r);s===void 0&&(s=Buffer.alloc(r),as.set(r,s)),this._decipherInstance.update(s)}}free(){}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let o=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||o!==r||o<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._blockPos):this._block.set(t,this._blockPos),e+=o,this._blockPos+=o,this._blockPos<this._block.length)return;let a,c;if(this._macETM?this._len=c=li(this._block,0):(a=this._decipherInstance.update(this._block),this._len=li(a,0),c=4+this._len-this._blockSize),this._len>lr||this._len<5||(c&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=So(this._macSSLName,this._macKey),cn(Br,this.inSeqno,0),this._macInstance.update(Br),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),e>=r)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,r-e),a;e!==0||o!==r?a=new Uint8Array(t.buffer,t.byteOffset+e,o):a=t,this._macETM&&this._macInstance.update(a);let c=this._decipherInstance.update(a);if(c.length&&(o===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._packetPos)),this._packetPos+=c.length),e+=o,this._pktLen+=o,this._pktLen<this._len||e>=r)return}{let o=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||o!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._macPos):this._mac.set(t,this._macPos),e+=o,this._macPos+=o,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let s=this._macInstance.digest();if(this._macActualLen<s.length&&(s=new Uint8Array(s.buffer,s.byteOffset,this._macActualLen)),!kp(s,this._mac))throw new Error("Invalid MAC");let i=new Kn(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;{let o=this._onPayload(i);if(o!==void 0)return o===!1?e:o}}}},Mo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Ko(e.decipherInfo.sslName,e.decipherKey,e.decipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM,e.macInfo.actualLen),this._block=Buffer.allocUnsafe(e.macInfo.isETM||e.decipherInfo.stream?4:e.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let i=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||i!==r||i<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._blockPos):this._block.set(t,this._blockPos),e+=i,this._blockPos+=i,this._blockPos<this._block.length)return;let o;if(this._macETM?this._len=o=li(this._block,0):(this._instance.decryptBlock(this._block),this._len=li(this._block,0),o=4+this._len-this._block.length),this._len>lr||this._len<5||(o&this._block.length-1)!==0)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))),e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let s=new Kn(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;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}};function nl(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}var Cp=(()=>{let n=Buffer.alloc(4);return t=>(n[0]=t>>>24,n[1]=t>>>16,n[2]=t>>>8,n[3]=t,n)})();function kp(n,t){return n.length!==t.length?(wo(n,n),!1):wo(n,t)}function vp(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");let t=n.outbound;if(typeof t.onWrite!="function")throw new Error("Invalid outbound.onWrite");if(typeof t.cipherInfo!="object"||t.cipherInfo===null)throw new Error("Invalid outbound.cipherInfo");if(!Buffer.isBuffer(t.cipherKey)||t.cipherKey.length!==t.cipherInfo.keyLen)throw new Error("Invalid outbound.cipherKey");if(t.cipherInfo.ivLen&&(!Buffer.isBuffer(t.cipherIV)||t.cipherIV.length!==t.cipherInfo.ivLen))throw new Error("Invalid outbound.cipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>Zc)throw new Error("Invalid outbound.seqno");let e=!!t.forceNative;switch(t.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return Fo&&!e?new Ro(n):new Bo(n);case"chacha20":return Ho&&!e?new vo(n):new ko(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid outbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid outbound.macKey");return Qo&&!e?new Po(n):new No(n)}}}function Bp(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");let t=n.inbound;if(typeof t.onPayload!="function")throw new Error("Invalid inbound.onPayload");if(typeof t.decipherInfo!="object"||t.decipherInfo===null)throw new Error("Invalid inbound.decipherInfo");if(!Buffer.isBuffer(t.decipherKey)||t.decipherKey.length!==t.decipherInfo.keyLen)throw new Error("Invalid inbound.decipherKey");if(t.decipherInfo.ivLen&&(!Buffer.isBuffer(t.decipherIV)||t.decipherIV.length!==t.decipherInfo.ivLen))throw new Error("Invalid inbound.decipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>Zc)throw new Error("Invalid inbound.seqno");let e=!!t.forceNative;switch(t.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return Wo&&!e?new Uo(n):new Do(n);case"chacha20":return qo&&!e?new $o(n):new Lo(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid inbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid inbound.macKey");return Ko&&!e?new Mo(n):new Oo(n)}}}rl.exports={CIPHER_INFO:wp,MAC_INFO:Ip,bindingAvailable:!!Io,init:new Promise(async(n,t)=>{try{ci=await Jc()(),fi=ci._malloc(16),Vo=ci.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(e){return t(e)}n()}),NullCipher:Co,createCipher:vp,NullDecipher:To,createDecipher:Bp}});var Gn=ct((Vy,hl)=>{"use strict";var{createDecipheriv:zo,createECDH:Rp,createHash:di,createHmac:Np,createSign:Pp,createVerify:Tp,getCiphers:Lp,sign:il,verify:sl}=require("crypto"),$p=Lp(),{Ber:Re}=si(),Dp=Ao().pbkdf,{CIPHER_INFO:hi}=qn(),{eddsaSupported:Yo,SUPPORTED_CIPHER:Up}=Ln(),{bufferSlice:fr,makeBufferParser:Op,readString:ve,readUInt32BE:ui,writeUInt32BE:Ot}=mn(),$n=Symbol("Hash Algorithm"),An=Symbol("Private key PEM"),wn=Symbol("Public key PEM"),Vn=Symbol("Public key SSH"),Nr=Symbol("Decrypted Key"),Go=Object.create(null);{let n=Object.keys(hi);for(let t=0;t<n.length;++t){let e=hi[n[t]].sslName;!e||Go[e]||(Go[e]=hi[n[t]])}}var cs=Op();function yn(n,t){t=t.base64Slice(0,t.length);let e=t.replace(/.{64}/g,`$&
|
|
4
|
+
-----END PRIVATE KEY-----`,t=Buffer.from("a"),e,r;try{e=Tn.sign(null,t,n),r=Tn.verify(null,t,n,e)}catch{}return Buffer.isBuffer(e)&&e.length===64&&r===!0}return!1})(),Wc=typeof Tn.diffieHellman=="function"&&typeof Tn.generateKeyPairSync=="function"&&typeof Tn.createPublicKey=="function",ts=["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"];Wc&&(ts.unshift("curve25519-sha256"),ts.unshift("curve25519-sha256@libssh.org"));var yp=ts.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),yo=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];Qc&&yo.unshift("ssh-ed25519");var _p=yo.concat(["ssh-dss"]),qc=(()=>{let n=Tn.getCiphers();return t=>n.includes(mp[t].sslName)})(),Wn=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];vr&&vr.flags&&!vr.flags.aes?Hc?Wn.unshift("chacha20-poly1305@openssh.com"):Wn.push("chacha20-poly1305@openssh.com"):Hc&&vr&&vr.arch==="x86"?Wn.splice(4,0,"chacha20-poly1305@openssh.com"):Wn.push("chacha20-poly1305@openssh.com");Wn=Wn.filter(qc);var Ep=Wn.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(qc)),Kc=(()=>{let n=Tn.getHashes();return t=>n.includes(Ap[t].sslName)})(),Vc=["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(Kc),bp=Vc.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(Kc)),Gc=["none","zlib@openssh.com","zlib"],xp=Gc.concat([]),kr={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};ns.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((n,t)=>({...n,[t]:1}),{}),COMPAT:kr,COMPAT_CHECKS:[["Cisco-1.25",kr.BAD_DHGEX],[/^Cisco-1[.]/,kr.BUG_DHGEX_LARGE],[/^[0-9.]+$/,kr.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,kr.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,kr.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:ts,SUPPORTED_KEX:yp,DEFAULT_SERVER_HOST_KEY:yo,SUPPORTED_SERVER_HOST_KEY:_p,DEFAULT_CIPHER:Wn,SUPPORTED_CIPHER:Ep,DEFAULT_MAC:Vc,SUPPORTED_MAC:bp,DEFAULT_COMPRESSION:Gc,SUPPORTED_COMPRESSION:xp,curve25519Supported:Wc,eddsaSupported:Qc};ns.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(ns.exports.DISCONNECT_REASON)).reduce((n,[t,e])=>({...n,[e]:t}),{})});var mn=ct((Wy,Xc)=>{"use strict";var pn=si().Ber,rs,jc=Buffer[Symbol.species],Sp=Object.getPrototypeOf(Uint8Array.prototype).fill;function zc(n,t){return n[t++]*16777216+n[t++]*65536+n[t++]*256+n[t]}function oi(n,t,e,r,s){s||(s=0),r>n.length&&(r=n.length);let i=r-e,o=t.length-s;return i>o&&(i=o),t.set(new Uint8Array(n.buffer,n.byteOffset+e,i),s),i}function ai(n,t,e){return e===void 0&&(e=n.length),new jc(n.buffer,n.byteOffset+t,e-t)}function Eo(){let n=0,t,e={init:(r,s)=>{t=r,n=typeof s=="number"?s:0},pos:()=>n,length:()=>t?t.length:0,avail:()=>t&&n<t.length?t.length-n:0,clear:()=>{t=void 0},readUInt32BE:()=>{if(!(!t||n+3>=t.length))return t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]},readUInt64BE:r=>{if(!(!t||n+7>=t.length))switch(r){case"always":return BigInt(`0x${t.hexSlice(n,n+=8)}`);case"maybe":if(t[n]>31)return BigInt(`0x${t.hexSlice(n,n+=8)}`);default:return t[n++]*72057594037927940+t[n++]*281474976710656+t[n++]*1099511627776+t[n++]*4294967296+t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]}},skip:r=>{t&&r>0&&(n+=r)},skipString:()=>{let r=e.readUInt32BE();if(r!==void 0)return n+=r,n<=t.length?r:void 0},readByte:()=>{if(t&&n<t.length)return t[n++]},readBool:()=>{if(t&&n<t.length)return!!t[n++]},readList:()=>{let r=e.readString(!0);if(r!==void 0)return r?r.split(","):[]},readString:(r,s)=>{typeof r=="number"&&(s=r,r=void 0);let i=e.readUInt32BE();if(i!==void 0&&!(t.length-n<i||typeof s=="number"&&i>s))return r?Buffer.isBuffer(r)?oi(t,r,n,n+=i):t.utf8Slice(n,n+=i):ai(t,n,n+=i)},readRaw:r=>{if(t){if(typeof r!="number")return ai(t,n,n+=t.length-n);if(t.length-n>=r)return ai(t,n,n+=r)}}};return e}function Yc(n,t,e){let r=new Error(n);return typeof t=="boolean"?(e=t,r.level="protocol"):r.level=t||"protocol",r.fatal=!!e,r}function _o(n,t,e){return n[e++]=t>>>24,n[e++]=t>>>16,n[e++]=t>>>8,n[e++]=t,e}var is=Eo();Xc.exports={bufferCopy:oi,bufferSlice:ai,FastBuffer:jc,bufferFill:(n,t,e,r)=>Sp.call(n,t,e,r),makeError:Yc,doFatalError:(n,t,e,r)=>{let s;return rs===void 0&&({DISCONNECT_REASON:rs}=Ln()),t instanceof Error?(s=t,typeof e!="number"?r=rs.PROTOCOL_ERROR:r=e):s=Yc(t,e,!0),typeof r!="number"&&(r=rs.PROTOCOL_ERROR),n.disconnect(r),n._destruct(),n._onError(s),1/0},readUInt32BE:zc,writeUInt32BE:_o,writeUInt32LE:(n,t,e)=>(n[e++]=t,n[e++]=t>>>8,n[e++]=t>>>16,n[e++]=t>>>24,e),makeBufferParser:Eo,bufferParser:Eo(),readString:(n,t,e,r)=>{typeof e=="number"&&(r=e,e=void 0),t===void 0&&(t=0);let s=n.length-t;if(t<0||t>=n.length||s<4)return;let i=zc(n,t);if(s<4+i||typeof r=="number"&&i>r)return;t+=4;let o=t+i;return n._pos=o,e?Buffer.isBuffer(e)?oi(n,e,t,o):n.utf8Slice(t,o):ai(n,t,o)},sigSSHToASN1:(n,t)=>{switch(t){case"ssh-dss":{if(n.length>40)return n;let e=new pn.Writer;e.startSequence();let r=n.slice(0,20),s=n.slice(20);if(r[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,r.copy(i,1),r=i}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(s[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,s.copy(i,1),s=i}else s[0]===0&&!(s[1]&128)&&(s=s.slice(1));return e.writeBuffer(r,pn.Integer),e.writeBuffer(s,pn.Integer),e.endSequence(),e.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{is.init(n,0);let e=is.readString(),r=is.readString();if(is.clear(),e===void 0||r===void 0)return;let s=new pn.Writer;return s.startSequence(),s.writeBuffer(e,pn.Integer),s.writeBuffer(r,pn.Integer),s.endSequence(),s.buffer}default:return n}},convertSignature:(n,t)=>{switch(t){case"ssh-dss":{if(n.length<=40)return n;let e=new pn.Reader(n);e.readSequence();let r=e.readString(pn.Integer,!0),s=e.readString(pn.Integer,!0),i=0,o=0;if(r.length<20){let c=Buffer.allocUnsafe(20);c.set(r,1),r=c,r[0]=0}if(s.length<20){let c=Buffer.allocUnsafe(20);c.set(s,1),s=c,s[0]=0}r.length>20&&r[0]===0&&(i=1),s.length>20&&s[0]===0&&(o=1);let a=Buffer.allocUnsafe(r.length-i+(s.length-o));return oi(r,a,i,r.length,0),oi(s,a,o,s.length,r.length-i),a}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(n[0]===0)return n;let e=new pn.Reader(n);e.readSequence();let r=e.readString(pn.Integer,!0),s=e.readString(pn.Integer,!0);if(r===null||s===null)return;let i=Buffer.allocUnsafe(4+r.length+4+s.length);return _o(i,r.length,0),i.set(r,4),_o(i,s.length,4+r.length),i.set(s,8+r.length),i}}return n},sendPacket:(n,t,e)=>!e&&n._kexinit!==void 0?(n._queue===void 0&&(n._queue=[]),n._queue.push(t),n._debug&&n._debug("Outbound: ... packet queued"),!1):(n._cipher.encrypt(t),!0)}});var Jc=ct((ss,xo)=>{var bo=(function(){var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),(function(t){t=t||{};var e;e||(e=typeof t<"u"?t:{});var r,s;e.ready=new Promise(function(j,he){r=j,s=he});var i={},o;for(o in e)e.hasOwnProperty(o)&&(i[o]=e[o]);var a=typeof window=="object",c=typeof importScripts=="function",l=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",f="",u,h,p,y,_;l?(f=c?require("path").dirname(f)+"/":__dirname+"/",u=function(j,he){var Se=Rn(j);return Se?he?Se:Se.toString():(y||(y=require("fs")),_||(_=require("path")),j=_.normalize(j),y.readFileSync(j,he?null:"utf8"))},p=function(j){return j=u(j,!0),j.buffer||(j=new Uint8Array(j)),U(j.buffer),j},h=function(j,he,Se){var Te=Rn(j);Te&&he(Te),y||(y=require("fs")),_||(_=require("path")),j=_.normalize(j),y.readFile(j,function(Xe,Tt){Xe?Se(Xe):he(Tt.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),e.inspect=function(){return"[Emscripten Module object]"}):(a||c)&&(c?f=self.location.href:typeof document<"u"&&document.currentScript&&(f=document.currentScript.src),n&&(f=n),f.indexOf("blob:")!==0?f=f.substr(0,f.lastIndexOf("/")+1):f="",u=function(j){try{var he=new XMLHttpRequest;return he.open("GET",j,!1),he.send(null),he.responseText}catch(Xe){if(j=Rn(j)){he=[];for(var Se=0;Se<j.length;Se++){var Te=j[Se];255<Te&&(mr&&U(!1,"Character code "+Te+" ("+String.fromCharCode(Te)+") at offset "+Se+" not in 0x00-0xFF."),Te&=255),he.push(String.fromCharCode(Te))}return he.join("")}throw Xe}},c&&(p=function(j){try{var he=new XMLHttpRequest;return he.open("GET",j,!1),he.responseType="arraybuffer",he.send(null),new Uint8Array(he.response)}catch(Se){if(j=Rn(j))return j;throw Se}}),h=function(j,he,Se){var Te=new XMLHttpRequest;Te.open("GET",j,!0),Te.responseType="arraybuffer",Te.onload=function(){if(Te.status==200||Te.status==0&&Te.response)he(Te.response);else{var Xe=Rn(j);Xe?he(Xe.buffer):Se()}},Te.onerror=Se,Te.send(null)}),e.print||console.log.bind(console);var x=e.printErr||console.warn.bind(console);for(o in i)i.hasOwnProperty(o)&&(e[o]=i[o]);i=null;var S;e.wasmBinary&&(S=e.wasmBinary);var R=e.noExitRuntime||!0;typeof WebAssembly!="object"&&K("no native wasm support detected");var H,C=!1;function U(j,he){j||K("Assertion failed: "+he)}function Q(j){var he=e["_"+j];return U(he,"Cannot call unknown function "+j+", make sure it is exported"),he}function B(j,he,Se,Te){var Xe={string:function(ot){var Ut=0;if(ot!=null&&ot!==0){var $t=(ot.length<<2)+1;Ut=ei($t);var wt=Ut,pt=v;if(0<$t){$t=wt+$t-1;for(var un=0;un<ot.length;++un){var It=ot.charCodeAt(un);if(55296<=It&&57343>=It){var ir=ot.charCodeAt(++un);It=65536+((It&1023)<<10)|ir&1023}if(127>=It){if(wt>=$t)break;pt[wt++]=It}else{if(2047>=It){if(wt+1>=$t)break;pt[wt++]=192|It>>6}else{if(65535>=It){if(wt+2>=$t)break;pt[wt++]=224|It>>12}else{if(wt+3>=$t)break;pt[wt++]=240|It>>18,pt[wt++]=128|It>>12&63}pt[wt++]=128|It>>6&63}pt[wt++]=128|It&63}}pt[wt]=0}}return Ut},array:function(ot){var Ut=ei(ot.length);return k.set(ot,Ut),Ut}},Tt=Q(j),Sn=[];if(j=0,Te)for(var on=0;on<Te.length;on++){var br=Xe[Se[on]];br?(j===0&&(j=Zr()),Sn[on]=br(Te[on])):Sn[on]=Te[on]}return Se=Tt.apply(null,Sn),Se=(function(ot){if(he==="string")if(ot){for(var Ut=v,$t=ot+NaN,wt=ot;Ut[wt]&&!(wt>=$t);)++wt;if(16<wt-ot&&Ut.subarray&&b)ot=b.decode(Ut.subarray(ot,wt));else{for($t="";ot<wt;){var pt=Ut[ot++];if(pt&128){var un=Ut[ot++]&63;if((pt&224)==192)$t+=String.fromCharCode((pt&31)<<6|un);else{var It=Ut[ot++]&63;pt=(pt&240)==224?(pt&15)<<12|un<<6|It:(pt&7)<<18|un<<12|It<<6|Ut[ot++]&63,65536>pt?$t+=String.fromCharCode(pt):(pt-=65536,$t+=String.fromCharCode(55296|pt>>10,56320|pt&1023))}}else $t+=String.fromCharCode(pt)}ot=$t}}else ot="";else ot=he==="boolean"?!!ot:ot;return ot})(Se),j!==0&&Qi(j),Se}var b=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,w,k,v;function P(){var j=H.buffer;w=j,e.HEAP8=k=new Int8Array(j),e.HEAP16=new Int16Array(j),e.HEAP32=new Int32Array(j),e.HEAPU8=v=new Uint8Array(j),e.HEAPU16=new Uint16Array(j),e.HEAPU32=new Uint32Array(j),e.HEAPF32=new Float32Array(j),e.HEAPF64=new Float64Array(j)}var ne,z=[],Y=[],te=[];function le(){var j=e.preRun.shift();z.unshift(j)}var O=0,N=null,L=null;e.preloadedImages={},e.preloadedAudios={};function K(j){throw e.onAbort&&e.onAbort(j),x(j),C=!0,j=new WebAssembly.RuntimeError("abort("+j+"). Build with -s ASSERTIONS=1 for more info."),s(j),j}var ee="data:application/octet-stream;base64,",ue;if(ue="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==",!ue.startsWith(ee)){var ie=ue;ue=e.locateFile?e.locateFile(ie,f):f+ie}function je(){var j=ue;try{if(j==ue&&S)return new Uint8Array(S);var he=Rn(j);if(he)return he;if(p)return p(j);throw"both async and sync fetching of the wasm failed"}catch(Se){K(Se)}}function lt(){if(!S&&(a||c)){if(typeof fetch=="function"&&!ue.startsWith("file://"))return fetch(ue,{credentials:"same-origin"}).then(function(j){if(!j.ok)throw"failed to load wasm binary file at '"+ue+"'";return j.arrayBuffer()}).catch(function(){return je()});if(h)return new Promise(function(j,he){h(ue,function(Se){j(new Uint8Array(Se))},he)})}return Promise.resolve().then(function(){return je()})}function sn(j){for(;0<j.length;){var he=j.shift();if(typeof he=="function")he(e);else{var Se=he.m;typeof Se=="number"?he.l===void 0?ne.get(Se)():ne.get(Se)(he.l):Se(he.l===void 0?null:he.l)}}}var mr=!1,Ar=typeof atob=="function"?atob:function(j){var he="",Se=0;j=j.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var Te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(Se++)),Xe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(Se++)),Tt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(Se++)),Sn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(Se++));Te=Te<<2|Xe>>4,Xe=(Xe&15)<<4|Tt>>2;var on=(Tt&3)<<6|Sn;he+=String.fromCharCode(Te),Tt!==64&&(he+=String.fromCharCode(Xe)),Sn!==64&&(he+=String.fromCharCode(on))}while(Se<j.length);return he};function Rn(j){if(j.startsWith(ee)){if(j=j.slice(ee.length),typeof l=="boolean"&&l){var he=Buffer.from(j,"base64");he=new Uint8Array(he.buffer,he.byteOffset,he.byteLength)}else try{var Se=Ar(j),Te=new Uint8Array(Se.length);for(j=0;j<Se.length;++j)Te[j]=Se.charCodeAt(j);he=Te}catch{throw Error("Converting base64 string to bytes failed.")}return he}}var yr={a:function(j){var he=v.length;if(j>>>=0,2147483648<j)return!1;for(var Se=1;4>=Se;Se*=2){var Te=he*(1+.2/Se);Te=Math.min(Te,j+100663296),Te=Math.max(j,Te),0<Te%65536&&(Te+=65536-Te%65536);e:{try{H.grow(Math.min(2147483648,Te)-w.byteLength+65535>>>16),P();var Xe=1;break e}catch{}Xe=void 0}if(Xe)return!0}return!1}};(function(){function j(Xe){e.asm=Xe.exports,H=e.asm.b,P(),ne=e.asm.j,Y.unshift(e.asm.c),O--,e.monitorRunDependencies&&e.monitorRunDependencies(O),O==0&&(N!==null&&(clearInterval(N),N=null),L&&(Xe=L,L=null,Xe()))}function he(Xe){j(Xe.instance)}function Se(Xe){return lt().then(function(Tt){return WebAssembly.instantiate(Tt,Te)}).then(Xe,function(Tt){x("failed to asynchronously prepare wasm: "+Tt),K(Tt)})}var Te={a:yr};if(O++,e.monitorRunDependencies&&e.monitorRunDependencies(O),e.instantiateWasm)try{return e.instantiateWasm(Te,j)}catch(Xe){return x("Module.instantiateWasm callback failed with error: "+Xe),!1}return(function(){return S||typeof WebAssembly.instantiateStreaming!="function"||ue.startsWith(ee)||ue.startsWith("file://")||typeof fetch!="function"?Se(he):fetch(ue,{credentials:"same-origin"}).then(function(Xe){return WebAssembly.instantiateStreaming(Xe,Te).then(he,function(Tt){return x("wasm streaming compile failed: "+Tt),x("falling back to ArrayBuffer instantiation"),Se(he)})})})().catch(s),{}})(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.c).apply(null,arguments)},e._poly1305_auth=function(){return(e._poly1305_auth=e.asm.d).apply(null,arguments)};var Zr=e.stackSave=function(){return(Zr=e.stackSave=e.asm.e).apply(null,arguments)},Qi=e.stackRestore=function(){return(Qi=e.stackRestore=e.asm.f).apply(null,arguments)},ei=e.stackAlloc=function(){return(ei=e.stackAlloc=e.asm.g).apply(null,arguments)};e._malloc=function(){return(e._malloc=e.asm.h).apply(null,arguments)},e._free=function(){return(e._free=e.asm.i).apply(null,arguments)},e.cwrap=function(j,he,Se,Te){Se=Se||[];var Xe=Se.every(function(Tt){return Tt==="number"});return he!=="string"&&Xe&&!Te?Q(j):function(){return B(j,he,Se,arguments)}};var _r;L=function j(){_r||Er(),_r||(L=j)};function Er(){function j(){if(!_r&&(_r=!0,e.calledRun=!0,!C)){if(sn(Y),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;){var he=e.postRun.shift();te.unshift(he)}sn(te)}}if(!(0<O)){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)le();sn(z),0<O||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),j()},1)):j())}}if(e.run=Er,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return Er(),t.ready})})();typeof ss=="object"&&typeof xo=="object"?xo.exports=bo:typeof define=="function"&&define.amd?define([],function(){return bo}):typeof ss=="object"&&(ss.createPoly1305=bo)});var qn=ct((qy,rl)=>{"use strict";var{createCipheriv:Rr,createDecipheriv:os,createHmac:So,randomFillSync:cr,timingSafeEqual:wo}=require("crypto"),{readUInt32BE:li,writeUInt32BE:cn}=mn(),Kn=Buffer[Symbol.species],Zc=2**32-1,el=Buffer.alloc(0),Br=Buffer.alloc(4),as=new Map,lr=35e3,Io,Fo,Ho,Qo,Wo,qo,Ko;try{Io=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:Fo,ChaChaPolyCipher:Ho,GenericCipher:Qo,AESGCMDecipher:Wo,ChaChaPolyDecipher:qo,GenericDecipher:Ko}=Io}catch{}var Ht=1,wp=(()=>{function n(t,e,r,s,i,o,a){return{sslName:t,blockLen:e,keyLen:r,ivLen:s!==0||a&Ht?s:e,authLen:i,discardLen:o,stream:!!(a&Ht)}}return{"chacha20-poly1305@openssh.com":n("chacha20",8,64,0,16,0,Ht),"aes128-gcm":n("aes-128-gcm",16,16,12,16,0,Ht),"aes256-gcm":n("aes-256-gcm",16,32,12,16,0,Ht),"aes128-gcm@openssh.com":n("aes-128-gcm",16,16,12,16,0,Ht),"aes256-gcm@openssh.com":n("aes-256-gcm",16,32,12,16,0,Ht),"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,Ht),"aes192-ctr":n("aes-192-ctr",16,24,16,0,0,Ht),"aes256-ctr":n("aes-256-ctr",16,32,16,0,0,Ht),"3des-ctr":n("des-ede3",8,24,8,0,0,Ht),"blowfish-ctr":n("bf-ecb",8,16,8,0,0,Ht),"cast128-ctr":n("cast5-ecb",8,16,8,0,0,Ht),arcfour:n("rc4",8,16,0,0,1536,Ht),arcfour128:n("rc4",8,16,0,0,1536,Ht),arcfour256:n("rc4",8,32,0,0,1536,Ht),arcfour512:n("rc4",8,64,0,0,1536,Ht)}})(),Ip=(()=>{function n(t,e,r,s){return{sslName:t,len:e,actualLen:r,isETM:s}}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)}})(),Co=class{constructor(t,e){this.outSeqno=t,this._onWrite=e,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){this._dead||(this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},tl=Buffer.alloc(32),Jt=Buffer.alloc(16),ci,fi,Vo,ko=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encKeyMain=e.cipherKey.slice(0,32),this._encKeyPktLen=e.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){if(this._dead)return;Jt[0]=0,cn(Jt,this.outSeqno,12);let e=Rr("chacha20",this._encKeyMain,Jt).update(tl),r=Rr("chacha20",this._encKeyPktLen,Jt).update(t.slice(0,4));this._onWrite(r),Jt[0]=1;let s=Rr("chacha20",this._encKeyMain,Jt).update(t.slice(4));this._onWrite(s),Vo(fi,r,r.length,s,s.length,e);let i=Buffer.allocUnsafe(16);i.set(new Uint8Array(ci.HEAPU8.buffer,fi,16),0),this._onWrite(i),this.outSeqno=this.outSeqno+1>>>0}},vo=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new Ho(e.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e+16);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},Bo=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encSSLName=e.cipherInfo.sslName,this._encKey=e.cipherKey,this._encIV=e.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){if(this._dead)return;let e=Rr(this._encSSLName,this._encKey,this._encIV);e.setAutoPadding(!1);let r=t.slice(0,4);e.setAAD(r),this._onWrite(r);let s=e.update(t.slice(4));this._onWrite(s);let i=e.final();i.length&&this._onWrite(i);let o=e.getAuthTag();this._onWrite(o),nl(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},Ro=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new Fo(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e+16);return cn(s,e-4,0),s[4]=r,cr(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},No=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._cipherInstance=Rr(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let r=e.cipherInfo.discardLen;if(r){let s=as.get(r);s===void 0&&(s=Buffer.alloc(r),as.set(r,s)),this._cipherInstance.update(s)}}free(){this._dead=!0}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r);return cn(i,r-4,0),i[4]=s,cr(i,5+t,s),i}encrypt(t){if(this._dead)return;let e;if(this._macETM){let s=new Uint8Array(t.buffer,t.byteOffset,4),i=this._cipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+4,t.length-4));this._onWrite(s),this._onWrite(i),e=So(this._macSSLName,this._macKey),cn(Br,this.outSeqno,0),e.update(Br),e.update(s),e.update(i)}else{let s=this._cipherInstance.update(t);this._onWrite(s),e=So(this._macSSLName,this._macKey),cn(Br,this.outSeqno,0),e.update(Br),e.update(t)}let r=e.digest();r.length>this._macActualLen&&(r=r.slice(0,this._macActualLen)),this._onWrite(r),this.outSeqno=this.outSeqno+1>>>0}},Po=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._macLen=e.macInfo.len,this._macActualLen=e.macInfo.actualLen,this._aadLen=e.macInfo.isETM?4:0,this._instance=new Qo(e.cipherInfo.sslName,e.cipherKey,e.cipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r+this._macLen);return cn(i,r-4,0),i[4]=s,cr(i,5+t,s),i}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._macActualLen<this._macLen&&(t=new Kn(t.buffer,t.byteOffset,t.length-(this._macLen-this._macActualLen))),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},To=class{constructor(t,e){this.inSeqno=t,this._onPayload=e,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len>lr||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._packetPos<this._len){let i=Math.min(this._len-this._packetPos,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),e+=i,this._packetPos+=i,this._packetPos<this._len)return}let s=this._packet?new Kn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):el;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Lo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decKeyMain=e.decipherKey.slice(0,32),this._decKeyPktLen=e.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(t,e,r){for(;e<r;){if(this._lenPos<4){let a=Math.min(4-this._lenPos,r-e);for(;a--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;Jt[0]=0,cn(Jt,this.inSeqno,12);let c=os("chacha20",this._decKeyPktLen,Jt).update(this._lenBuf);if(this._len=li(c,0),this._len>lr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(e>=r)return;let a=Math.min(this._len-this._pktLen,r-e),c;if(e!==0||a!==r?c=new Uint8Array(t.buffer,t.byteOffset+e,a):c=t,a===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._pktLen)),e+=a,this._pktLen+=a,this._pktLen<this._len||e>=r)return}{let a=Math.min(16-this._macPos,r-e);if(e!==0||a!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,a),this._macPos):this._mac.set(t,this._macPos),e+=a,this._macPos+=a,this._macPos<16)return}Jt[0]=0,cn(Jt,this.inSeqno,12);let s=Rr("chacha20",this._decKeyMain,Jt).update(tl);if(Vo(fi,this._lenBuf,4,this._packet,this._packet.length,s),this._calcMac.set(new Uint8Array(ci.HEAPU8.buffer,fi,16),0),!wo(this._calcMac,this._mac))throw new Error("Invalid MAC");Jt[0]=1;let i=os("chacha20",this._decKeyMain,Jt).update(this._packet),o=new Kn(i.buffer,i.byteOffset+1,i.length-i[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let a=this._onPayload(o);if(a!==void 0)return a===!1?e:a}}}},$o=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new qo(e.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(t,e,r){for(;e<r;){if(this._lenPos<4){let i=Math.min(4-this._lenPos,r-e);for(;i--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>lr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let s=new Kn(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;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Do=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=null,this._decipherSSLName=e.decipherInfo.sslName,this._decipherKey=e.decipherKey,this._decipherIV=e.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(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>lr||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=os(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(Cp(this._len))}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=this._decipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+e,i)):o=this._decipherInstance.update(t),o.length&&(i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),this._packetPos+=o.length),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let i=this._decipherInstance.final();i.length&&(this._packet?this._packet.set(i,this._packetPos):this._packet=i)}let s=this._packet?new Kn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):el;this.inSeqno=this.inSeqno+1>>>0,nl(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Uo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Wo(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>lr||this._len<16||(this._len&15)!==0)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let s=new Kn(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;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Oo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=os(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(e.macInfo.isETM?4:e.decipherInfo.blockLen),this._blockSize=e.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._macInstance=null;let r=e.decipherInfo.discardLen;if(r){let s=as.get(r);s===void 0&&(s=Buffer.alloc(r),as.set(r,s)),this._decipherInstance.update(s)}}free(){}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let o=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||o!==r||o<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._blockPos):this._block.set(t,this._blockPos),e+=o,this._blockPos+=o,this._blockPos<this._block.length)return;let a,c;if(this._macETM?this._len=c=li(this._block,0):(a=this._decipherInstance.update(this._block),this._len=li(a,0),c=4+this._len-this._blockSize),this._len>lr||this._len<5||(c&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=So(this._macSSLName,this._macKey),cn(Br,this.inSeqno,0),this._macInstance.update(Br),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),e>=r)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,r-e),a;e!==0||o!==r?a=new Uint8Array(t.buffer,t.byteOffset+e,o):a=t,this._macETM&&this._macInstance.update(a);let c=this._decipherInstance.update(a);if(c.length&&(o===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._packetPos)),this._packetPos+=c.length),e+=o,this._pktLen+=o,this._pktLen<this._len||e>=r)return}{let o=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||o!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._macPos):this._mac.set(t,this._macPos),e+=o,this._macPos+=o,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let s=this._macInstance.digest();if(this._macActualLen<s.length&&(s=new Uint8Array(s.buffer,s.byteOffset,this._macActualLen)),!kp(s,this._mac))throw new Error("Invalid MAC");let i=new Kn(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;{let o=this._onPayload(i);if(o!==void 0)return o===!1?e:o}}}},Mo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Ko(e.decipherInfo.sslName,e.decipherKey,e.decipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM,e.macInfo.actualLen),this._block=Buffer.allocUnsafe(e.macInfo.isETM||e.decipherInfo.stream?4:e.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let i=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||i!==r||i<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._blockPos):this._block.set(t,this._blockPos),e+=i,this._blockPos+=i,this._blockPos<this._block.length)return;let o;if(this._macETM?this._len=o=li(this._block,0):(this._instance.decryptBlock(this._block),this._len=li(this._block,0),o=4+this._len-this._block.length),this._len>lr||this._len<5||(o&this._block.length-1)!==0)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))),e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let s=new Kn(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;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}};function nl(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}var Cp=(()=>{let n=Buffer.alloc(4);return t=>(n[0]=t>>>24,n[1]=t>>>16,n[2]=t>>>8,n[3]=t,n)})();function kp(n,t){return n.length!==t.length?(wo(n,n),!1):wo(n,t)}function vp(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");let t=n.outbound;if(typeof t.onWrite!="function")throw new Error("Invalid outbound.onWrite");if(typeof t.cipherInfo!="object"||t.cipherInfo===null)throw new Error("Invalid outbound.cipherInfo");if(!Buffer.isBuffer(t.cipherKey)||t.cipherKey.length!==t.cipherInfo.keyLen)throw new Error("Invalid outbound.cipherKey");if(t.cipherInfo.ivLen&&(!Buffer.isBuffer(t.cipherIV)||t.cipherIV.length!==t.cipherInfo.ivLen))throw new Error("Invalid outbound.cipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>Zc)throw new Error("Invalid outbound.seqno");let e=!!t.forceNative;switch(t.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return Fo&&!e?new Ro(n):new Bo(n);case"chacha20":return Ho&&!e?new vo(n):new ko(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid outbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid outbound.macKey");return Qo&&!e?new Po(n):new No(n)}}}function Bp(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");let t=n.inbound;if(typeof t.onPayload!="function")throw new Error("Invalid inbound.onPayload");if(typeof t.decipherInfo!="object"||t.decipherInfo===null)throw new Error("Invalid inbound.decipherInfo");if(!Buffer.isBuffer(t.decipherKey)||t.decipherKey.length!==t.decipherInfo.keyLen)throw new Error("Invalid inbound.decipherKey");if(t.decipherInfo.ivLen&&(!Buffer.isBuffer(t.decipherIV)||t.decipherIV.length!==t.decipherInfo.ivLen))throw new Error("Invalid inbound.decipherIV");if(typeof t.seqno!="number"||t.seqno<0||t.seqno>Zc)throw new Error("Invalid inbound.seqno");let e=!!t.forceNative;switch(t.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return Wo&&!e?new Uo(n):new Do(n);case"chacha20":return qo&&!e?new $o(n):new Lo(n);default:{if(typeof t.macInfo!="object"||t.macInfo===null)throw new Error("Invalid inbound.macInfo");if(!Buffer.isBuffer(t.macKey)||t.macKey.length!==t.macInfo.len)throw new Error("Invalid inbound.macKey");return Ko&&!e?new Mo(n):new Oo(n)}}}rl.exports={CIPHER_INFO:wp,MAC_INFO:Ip,bindingAvailable:!!Io,init:new Promise(async(n,t)=>{try{ci=await Jc()(),fi=ci._malloc(16),Vo=ci.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(e){return t(e)}n()}),NullCipher:Co,createCipher:vp,NullDecipher:To,createDecipher:Bp}});var Gn=ct((Ky,hl)=>{"use strict";var{createDecipheriv:zo,createECDH:Rp,createHash:di,createHmac:Np,createSign:Pp,createVerify:Tp,getCiphers:Lp,sign:il,verify:sl}=require("crypto"),$p=Lp(),{Ber:Re}=si(),Dp=Ao().pbkdf,{CIPHER_INFO:hi}=qn(),{eddsaSupported:Yo,SUPPORTED_CIPHER:Up}=Ln(),{bufferSlice:fr,makeBufferParser:Op,readString:ve,readUInt32BE:ui,writeUInt32BE:Ot}=mn(),$n=Symbol("Hash Algorithm"),An=Symbol("Private key PEM"),wn=Symbol("Public key PEM"),Vn=Symbol("Public key SSH"),Nr=Symbol("Decrypted Key"),Go=Object.create(null);{let n=Object.keys(hi);for(let t=0;t<n.length;++t){let e=hi[n[t]].sslName;!e||Go[e]||(Go[e]=hi[n[t]])}}var cs=Op();function yn(n,t){t=t.base64Slice(0,t.length);let e=t.replace(/.{64}/g,`$&
|
|
4
5
|
`);return t.length&63&&(e+=`
|
|
5
6
|
`),`-----BEGIN ${n} KEY-----
|
|
6
|
-
${e}-----END ${n} KEY-----`}function pi(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return e.set(n,0),e.set(t,n.length),e}function jo(n,t){let e=n.length,r=n._pos||0;for(let s=0;s<t;++s){let i=e-r;if(r>=e||i<4)return!1;let o=ui(n,r);if(i<4+o)return!1;r+=4+o}return n._pos=r,!0}function gi(n,t){let e=new Re.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.113549.1.1.1"),e.writeNull(),e.endSequence(),e.startSequence(Re.BitString),e.writeByte(0),e.startSequence(),e.writeBuffer(n,Re.Integer),e.writeBuffer(t,Re.Integer),e.endSequence(),e.endSequence(),e.endSequence(),yn("PUBLIC",e.buffer)}function mi(n,t){let e=Buffer.allocUnsafe(15+t.length+4+n.length);Ot(e,7,0),e.utf8Write("ssh-rsa",4,7);let r=11;return Ot(e,t.length,r),e.set(t,r+=4),Ot(e,n.length,r+=t.length),e.set(n,r+4),e}var ol=(()=>{function n(r,s,i,o,a,c,l,f){let u=new Re.Writer;return u.startSequence(),u.writeInt(0,Re.Integer),u.writeBuffer(r,Re.Integer),u.writeBuffer(s,Re.Integer),u.writeBuffer(i,Re.Integer),u.writeBuffer(o,Re.Integer),u.writeBuffer(a,Re.Integer),u.writeBuffer(c,Re.Integer),u.writeBuffer(l,Re.Integer),u.writeBuffer(f,Re.Integer),u.endSequence(),u.buffer}function t(r){return BigInt(`0x${r.hexSlice(0,r.length)}`)}function e(r){let s=r.toString(16);if((s.length&1)!==0)s=`0${s}`;else{let 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,a,c,l){let f=t(o),u=e(f%(t(c)-1n)),h=e(f%(t(l)-1n));return yn("RSA PRIVATE",n(s,i,o,c,l,u,h,a))}})();function Ai(n,t,e,r){let s=new Re.Writer;return s.startSequence(),s.startSequence(),s.writeOID("1.2.840.10040.4.1"),s.startSequence(),s.writeBuffer(n,Re.Integer),s.writeBuffer(t,Re.Integer),s.writeBuffer(e,Re.Integer),s.endSequence(),s.endSequence(),s.startSequence(Re.BitString),s.writeByte(0),s.writeBuffer(r,Re.Integer),s.endSequence(),s.endSequence(),yn("PUBLIC",s.buffer)}function yi(n,t,e,r){let s=Buffer.allocUnsafe(15+n.length+4+t.length+4+e.length+4+r.length);Ot(s,7,0),s.utf8Write("ssh-dss",4,7);let i=11;return Ot(s,n.length,i),s.set(n,i+=4),Ot(s,t.length,i+=n.length),s.set(t,i+=4),Ot(s,e.length,i+=t.length),s.set(e,i+=4),Ot(s,r.length,i+=e.length),s.set(r,i+4),s}function al(n,t,e,r,s){let i=new Re.Writer;return i.startSequence(),i.writeInt(0,Re.Integer),i.writeBuffer(n,Re.Integer),i.writeBuffer(t,Re.Integer),i.writeBuffer(e,Re.Integer),i.writeBuffer(r,Re.Integer),i.writeBuffer(s,Re.Integer),i.endSequence(),yn("DSA PRIVATE",i.buffer)}function cl(n){let t=new Re.Writer;return t.startSequence(),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Re.BitString),t.writeByte(0),t._ensure(n.length),t._buf.set(n,t._offset),t._offset+=n.length,t.endSequence(),t.endSequence(),yn("PUBLIC",t.buffer)}function ll(n){let t=Buffer.allocUnsafe(19+n.length);return Ot(t,11,0),t.utf8Write("ssh-ed25519",4,11),Ot(t,n.length,15),t.set(n,19),t}function Mp(n){let t=new Re.Writer;return t.startSequence(),t.writeInt(0,Re.Integer),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Re.OctetString),t.writeBuffer(n,Re.OctetString),t.endSequence(),t.endSequence(),yn("PRIVATE",t.buffer)}function Xo(n,t){let e=new Re.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.10045.2.1"),e.writeOID(n),e.endSequence(),e.startSequence(Re.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),yn("PUBLIC",e.buffer)}function Jo(n,t){let e;switch(n){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}let r=Buffer.allocUnsafe(39+t.length);return Ot(r,19,0),r.utf8Write(`ecdsa-sha2-${e}`,4,19),Ot(r,8,23),r.utf8Write(e,27,8),Ot(r,t.length,35),r.set(t,39),r}function Fp(n,t,e){let r=new Re.Writer;return r.startSequence(),r.writeInt(1,Re.Integer),r.writeBuffer(e,Re.OctetString),r.startSequence(160),r.writeOID(n),r.endSequence(),r.startSequence(161),r.startSequence(Re.BitString),r.writeByte(0),r._ensure(t.length),r._buf.set(t,r._offset),r._offset+=t.length,r.endSequence(),r.endSequence(),r.endSequence(),yn("EC PRIVATE",r.buffer)}function Hp(n,t){let e=Rp(n);return e.setPrivateKey(t),e.getPublicKey()}var _i={sign:typeof il=="function"?function(t,e){let r=this[An];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[$n]);try{return il(e,t,r)}catch(s){return s}}:function(t,e){let r=this[An];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[$n]);let s=Pp(e);s.update(t);try{return s.sign(r)}catch(i){return i}},verify:typeof sl=="function"?function(t,e,r){let s=this[wn];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[$n]);try{return sl(r,t,s,e)}catch(i){return i}}:function(t,e,r){let s=this[wn];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[$n]);let i=Tp(r);i.update(t);try{return i.verify(s,e)}catch(o){return o}},isPrivateKey:function(){return this[An]!==null},getPrivatePEM:function(){return this[An]},getPublicPEM:function(){return this[wn]},getPublicSSH:function(){return this[Vn]},equals:function(t){let e=dl(t);return e instanceof Error?!1:this.type===e.type&&this[An]===e[An]&&this[wn]===e[wn]&&this[Vn].equals(e[Vn])}};function ls(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[An]=e,this[wn]=r,this[Vn]=s,this[$n]=i,this[Nr]=o}ls.prototype=_i;{let t=function(e,r,s){let i=[];if(e.length<8)return new Error("Malformed OpenSSH private key");let o=ui(e,0),a=ui(e,4);if(o!==a)return s?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");e._pos=8;let c,l;for(c=0;c<r;++c){let u,h,p,y,_=ve(e,e._pos,!0);if(_===void 0)return new Error("Malformed OpenSSH private key");switch(_){case"ssh-rsa":{let S=ve(e,e._pos);if(S===void 0)return new Error("Malformed OpenSSH private key");let R=ve(e,e._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");let H=ve(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let C=ve(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let U=ve(e,e._pos);if(U===void 0)return new Error("Malformed OpenSSH private key");let Q=ve(e,e._pos);if(Q===void 0)return new Error("Malformed OpenSSH private key");p=gi(S,R),y=mi(S,R),h=ol(S,R,H,C,U,Q),u="sha1";break}case"ssh-dss":{let S=ve(e,e._pos);if(S===void 0)return new Error("Malformed OpenSSH private key");let R=ve(e,e._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");let H=ve(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let C=ve(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let U=ve(e,e._pos);if(U===void 0)return new Error("Malformed OpenSSH private key");p=Ai(S,R,H,C),y=yi(S,R,H,C),h=al(S,R,H,C,U),u="sha1";break}case"ssh-ed25519":{if(!Yo)return new Error(`Unsupported OpenSSH private key type: ${_}`);let S=ve(e,e._pos);if(S===void 0||S.length!==32)return new Error("Malformed OpenSSH private key");let R=ve(e,e._pos);if(R===void 0||R.length!==64)return new Error("Malformed OpenSSH private key");p=cl(S),y=ll(S),h=Mp(fr(R,0,32)),u=null;break}case"ecdsa-sha2-nistp256":u="sha256",l="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":u===void 0&&(u="sha384",l="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(u===void 0&&(u="sha512",l="1.3.132.0.35"),!jo(e,1))return new Error("Malformed OpenSSH private key");let S=ve(e,e._pos);if(S===void 0)return new Error("Malformed OpenSSH private key");let R=ve(e,e._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");p=Xo(l,S),y=Jo(l,S),h=Fp(l,S,R);break}default:return new Error(`Unsupported OpenSSH private key type: ${_}`)}let x=ve(e,e._pos,!0);if(x===void 0)return new Error("Malformed OpenSSH private key");i.push(new ls(_,x,h,p,y,u,s))}let f=0;for(c=e._pos;c<e.length;++c)if(e[c]!==++f%255)return new Error("Malformed OpenSSH private key");return i},n=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;ls.parse=(e,r)=>{let s=n.exec(e);if(s===null)return null;let i,o=Buffer.from(s[1],"base64");if(o.length<31)return new Error("Malformed OpenSSH private key");let a=o.utf8Slice(0,15);if(a!=="openssh-key-v1\0")return new Error(`Unsupported OpenSSH key magic: ${a}`);let c=ve(o,15,!0);if(c===void 0)return new Error("Malformed OpenSSH private key");if(c!=="none"&&Up.indexOf(c)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${c}`);let l=ve(o,o._pos,!0);if(l===void 0)return new Error("Malformed OpenSSH private key");if(l!=="none"){if(c==="none")return new Error("Malformed OpenSSH private key");if(l!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${l}`);if(!r)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(c!=="none")return new Error("Malformed OpenSSH private key");let f,u,h;c!=="none"&&(f=hi[c]);let p=ve(o,o._pos);if(p===void 0)return new Error("Malformed OpenSSH private key");if(p.length)switch(l){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{let _=ve(p,0);if(_===void 0||p._pos+4>p.length)return new Error("Malformed OpenSSH private key");let x=ui(p,p._pos),S=Buffer.allocUnsafe(f.keyLen+f.ivLen);if(Dp(r,r.length,_,_.length,S,S.length,x)!==0)return new Error("Failed to generate information to decrypt key");u=fr(S,0,f.keyLen),h=fr(S,f.keyLen,S.length);break}}else if(l!=="none")return new Error("Malformed OpenSSH private key");if(o._pos+3>=o.length)return new Error("Malformed OpenSSH private key");let y=ui(o,o._pos);if(o._pos+=4,y>0){for(let x=0;x<y;++x){let S=ve(o,o._pos);if(S===void 0)return new Error("Malformed OpenSSH private key");if(ve(S,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let _=ve(o,o._pos);if(_===void 0)return new Error("Malformed OpenSSH private key");if(u!==void 0){if(_.length<f.blockLen||_.length%f.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let x={authTagLength:f.authLen},S=zo(f.sslName,u,h,x);if(S.setAutoPadding(!1),f.authLen>0){if(o.length-o._pos<f.authLen)return new Error("Malformed OpenSSH private key");S.setAuthTag(fr(o,o._pos,o._pos+=f.authLen))}_=pi(S.update(_),S.final())}catch(x){return x}}if(o._pos!==o.length)return new Error("Malformed OpenSSH private key");i=t(_,y,u!==void 0)}else i=[];return i instanceof Error?i:i[0]}}function fs(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[An]=e,this[wn]=r,this[Vn]=s,this[$n]=i,this[Nr]=o}fs.prototype=_i;{let n=/^-----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-----$/;fs.parse=(t,e)=>{let r=n.exec(t);if(r===null)return null;let s=Buffer.from(r[3],"base64"),i=r[2],o=!1;if(i!==void 0){i=i.split(/\r\n|\n/g);for(let y=0;y<i.length;++y){let _=i[y],x=_.indexOf(":");if(_.slice(0,x)==="DEK-Info"){let S=_.slice(x+2);if(x=S.indexOf(","),x===-1)continue;let R=S.slice(0,x).toLowerCase();if($p.indexOf(R)===-1)return new Error(`Cipher (${R}) not supported for encrypted OpenSSH private key`);let H=Go[R];if(!H)return new Error(`Cipher (${R}) not supported for encrypted OpenSSH private key`);let C=Buffer.from(S.slice(x+1),"hex");if(C.length!==H.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!e)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");let U=fr(C,0,8),Q=di("md5").update(e).update(U).digest();for(;Q.length<H.keyLen;)Q=pi(Q,di("md5").update(Q).update(e).update(U).digest());Q.length>H.keyLen&&(Q=fr(Q,0,H.keyLen));try{let B=zo(R,Q,C);B.setAutoPadding(!1),s=pi(B.update(s),B.final()),o=!0}catch(B){return B}}}}let a,c,l,f,u,h,p="Malformed OpenSSH private key";switch(o&&(p+=". Bad passphrase?"),r[1]){case"RSA":a="ssh-rsa",c=yn("RSA PRIVATE",s);try{h=new Re.Reader(s),h.readSequence(),h.readInt();let y=h.readString(Re.Integer,!0);if(y===null)return new Error(p);let _=h.readString(Re.Integer,!0);if(_===null)return new Error(p);l=gi(y,_),f=mi(y,_)}catch{return new Error(p)}u="sha1";break;case"DSA":a="ssh-dss",c=yn("DSA PRIVATE",s);try{h=new Re.Reader(s),h.readSequence(),h.readInt();let y=h.readString(Re.Integer,!0);if(y===null)return new Error(p);let _=h.readString(Re.Integer,!0);if(_===null)return new Error(p);let x=h.readString(Re.Integer,!0);if(x===null)return new Error(p);let S=h.readString(Re.Integer,!0);if(S===null)return new Error(p);l=Ai(y,_,x,S),f=yi(y,_,x,S)}catch{return new Error(p)}u="sha1";break;case"EC":{let y,_,x;try{h=new Re.Reader(s),h.readSequence(),h.readInt(),_=h.readString(Re.OctetString,!0),h.readByte();let R=h.readLength();if(R!==null){if(h._offset=R,x=h.readOID(),x===null)return new Error(p);switch(x){case"1.2.840.10045.3.1.7":y="prime256v1",a="ecdsa-sha2-nistp256",u="sha256";break;case"1.3.132.0.34":y="secp384r1",a="ecdsa-sha2-nistp384",u="sha384";break;case"1.3.132.0.35":y="secp521r1",a="ecdsa-sha2-nistp521",u="sha512";break;default:return new Error(`Unsupported private key EC OID: ${x}`)}}else return new Error(p)}catch{return new Error(p)}c=yn("EC PRIVATE",s);let S=Hp(y,_);l=Xo(x,S),f=Jo(x,S);break}}return new fs(a,"",c,l,f,u,o)}}function us(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[An]=e,this[wn]=r,this[Vn]=s,this[$n]=i,this[Nr]=o}us.prototype=_i;{let n=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]),r=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]+)/;us.parse=(i,o)=>{let a=s.exec(i);if(a===null)return null;let c=a[2],l=c!=="none";if(l&&!o)return new Error("Encrypted PPK private key detected, but no passphrase given");let f=Buffer.from(a[5],"base64");if(l){let k=hi[c],v=pi(di("sha1").update(e).update(o).digest(),di("sha1").update(r).update(o).digest());v.length>k.keyLen&&(v=fr(v,0,k.keyLen));try{let P=zo(k.sslName,v,t);P.setAutoPadding(!1),f=pi(P.update(f),P.final())}catch(P){return P}}let u=a[1],h=a[3],p=Buffer.from(a[4],"base64"),y=a[6],_=u.length,x=c.length,S=Buffer.byteLength(h),R=p.length,H=f.length,C=Buffer.allocUnsafe(4+_+4+x+4+S+4+R+4+H),U=0;if(Ot(C,_,U),C.utf8Write(u,U+=4,_),Ot(C,x,U+=_),C.utf8Write(c,U+=4,x),Ot(C,S,U+=x),C.utf8Write(h,U+=4,S),Ot(C,R,U+=S),C.set(p,U+=4),Ot(C,H,U+=R),C.set(f,U+4),o||(o=n),Np("sha1",di("sha1").update("putty-private-key-file-mac-key").update(o).digest()).update(C).digest("hex")!==y)return l?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let B,b,w;switch(p._pos=0,jo(p,1),u){case"ssh-rsa":{let k=ve(p,p._pos);if(k===void 0)return new Error("Malformed PPK public key");let v=ve(p,p._pos);if(v===void 0)return new Error("Malformed PPK public key");let P=ve(f,0);if(P===void 0)return new Error("Malformed PPK private key");let ne=ve(f,f._pos);if(ne===void 0)return new Error("Malformed PPK private key");let z=ve(f,f._pos);if(z===void 0)return new Error("Malformed PPK private key");let Y=ve(f,f._pos);if(Y===void 0)return new Error("Malformed PPK private key");B=gi(v,k),b=mi(v,k),w=ol(v,k,P,Y,ne,z);break}case"ssh-dss":{let k=ve(p,p._pos);if(k===void 0)return new Error("Malformed PPK public key");let v=ve(p,p._pos);if(v===void 0)return new Error("Malformed PPK public key");let P=ve(p,p._pos);if(P===void 0)return new Error("Malformed PPK public key");let ne=ve(p,p._pos);if(ne===void 0)return new Error("Malformed PPK public key");let z=ve(f,0);if(z===void 0)return new Error("Malformed PPK private key");B=Ai(k,v,P,ne),b=yi(k,v,P,ne),w=al(k,v,P,ne,z);break}}return new us(u,h,w,B,b,"sha1",l)}}function hs(n,t,e,r,s){this.type=n,this.comment=t,this[An]=null,this[wn]=e,this[Vn]=r,this[$n]=s,this[Nr]=!1}hs.prototype=_i;{let n;Yo?n=/^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/:n=/^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/,hs.parse=t=>{let e=n.exec(t);if(e===null)return null;let r=e[1],s=e[2],i=Buffer.from(e[3],"base64"),o=e[4]||"",a=ve(i,i._pos,!0);return a===void 0||a.indexOf(s)!==0?new Error("Malformed OpenSSH public key"):Zo(i,s,o,r)}}function ds(n,t,e,r,s){this.type=n,this.comment=t,this[An]=null,this[wn]=e,this[Vn]=r,this[$n]=s,this[Nr]=!1}ds.prototype=_i;{let n=/^---- 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,r=/\\\r?\n/g;ds.parse=s=>{let i=n.exec(s);if(i===null)return null;let o=i[1],a=0,c="";for(;i=e.exec(o);){let p=i[1],y=i[2].replace(r,"");if(y.length>1024)return e.lastIndex=0,new Error("Malformed RFC4716 public key");a=e.lastIndex,p.toLowerCase()==="comment"&&(c=y,c.length>1&&c.charCodeAt(0)===34&&c.charCodeAt(c.length-1)===34&&(c=c.slice(1,-1)))}let l=o.slice(a);if(!t.test(l))return new Error("Malformed RFC4716 public key");l=Buffer.from(l,"base64");let f=ve(l,0,!0);if(f===void 0)return new Error("Malformed RFC4716 public key");let u=null,h=null;switch(f){case"ssh-rsa":{let p=ve(l,l._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let y=ve(l,l._pos);if(y===void 0)return new Error("Malformed RFC4716 public key");u=gi(y,p),h=mi(y,p);break}case"ssh-dss":{let p=ve(l,l._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let y=ve(l,l._pos);if(y===void 0)return new Error("Malformed RFC4716 public key");let _=ve(l,l._pos);if(_===void 0)return new Error("Malformed RFC4716 public key");let x=ve(l,l._pos);if(x===void 0)return new Error("Malformed RFC4716 public key");u=Ai(p,y,_,x),h=yi(p,y,_,x);break}default:return new Error("Malformed RFC4716 public key")}return new ds(f,c,u,h,"sha1")}}function Zo(n,t,e,r){if(!fl(t))return new Error(`Unsupported OpenSSH public key type: ${t}`);let s,i,o=null,a=null;switch(t){case"ssh-rsa":{let c=ve(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let l=ve(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");o=gi(l,c),a=mi(l,c),s="sha1";break}case"ssh-dss":{let c=ve(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let l=ve(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");let f=ve(n,n._pos);if(f===void 0)return new Error("Malformed OpenSSH public key");let u=ve(n,n._pos);if(u===void 0)return new Error("Malformed OpenSSH public key");o=Ai(c,l,f,u),a=yi(c,l,f,u),s="sha1";break}case"ssh-ed25519":{let c=ve(n,n._pos||0);if(c===void 0||c.length!==32)return new Error("Malformed OpenSSH public key");o=cl(c),a=ll(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"),!jo(n,1))return new Error("Malformed OpenSSH public key");let c=ve(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");o=Xo(i,c),a=Jo(i,c);break}default:return new Error(`Unsupported OpenSSH public key type: ${t}`)}return new hs(r,e,o,a,s)}function fl(n){switch(n){case"ssh-rsa":case"ssh-dss":case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":return!0;case"ssh-ed25519":if(Yo)return!0;default:return!1}}function ul(n){return n?typeof n[Nr]=="boolean":!1}function dl(n,t){if(ul(n))return n;let e;if(Buffer.isBuffer(n))e=n,n=n.utf8Slice(0,n.length).trim();else if(typeof n=="string")n=n.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 r;if((r=ls.parse(n,t))!==null||(r=fs.parse(n,t))!==null||(r=us.parse(n,t))!==null||(r=hs.parse(n))!==null||(r=ds.parse(n))!==null)return r;if(e){cs.init(e,0);let s=cs.readString(!0);s!==void 0&&(n=cs.readRaw(),n!==void 0&&(r=Zo(n,s,"",s),r instanceof Error&&(r=null))),cs.clear()}return r||new Error("Unsupported key format")}hl.exports={isParsedKey:ul,isSupportedKeyType:fl,parseDERKey:(n,t)=>Zo(n,t,"",t),parseKey:dl}});var sa=ct((jy,Sl)=>{"use strict";var{Socket:Al}=require("net"),{Duplex:yl}=require("stream"),{resolve:Qp}=require("path"),{readFile:pl}=require("fs"),{execFile:Wp,spawn:qp}=require("child_process"),{isParsedKey:gl,parseKey:Ei}=Gn(),{makeBufferParser:Kp,readUInt32BE:ia,writeUInt32BE:Zt,writeUInt32LE:ml}=mn();function bi(n){let t=!1;return(...e)=>{t||(t=!0,n(...e))}}function Vp(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return n.copy(e,0),t.copy(e,n.length),e}function ta(){}var Gp=Buffer.alloc(0),xt=Kp(),xi=class{getIdentities(t){t(new Error("Missing getIdentities() implementation"))}sign(t,e,r,s){typeof r=="function"&&(s=r),s(new Error("Missing sign() implementation"))}},Tr=class extends xi{constructor(t){super(),this.socketPath=t}getStream(t){t=bi(t);let e=new Al;e.on("connect",()=>{t(null,e)}),e.on("close",r).on("end",r).on("error",r),e.connect(this.socketPath);function r(){try{e.destroy()}catch{}t(new Error("Failed to connect to agent"))}}getIdentities(t){t=bi(t),this.getStream((e,r)=>{function s(o){if(r)try{r.destroy()}catch{}o||(o=new Error("Failed to retrieve identities from agent")),t(o)}if(e)return s(e);let i=new na(!0);i.on("error",s),i.pipe(r).pipe(i),r.on("close",s).on("end",s).on("error",s),i.getIdentities((o,a)=>{if(o)return s(o);try{r.destroy()}catch{}t(null,a)})})}sign(t,e,r,s){typeof r=="function"?(s=r,r=void 0):(typeof r!="object"||r===null)&&(r=void 0),s=bi(s),this.getStream((i,o)=>{function a(l){if(o)try{o.destroy()}catch{}l||(l=new Error("Failed to sign data with agent")),s(l)}if(i)return a(i);let c=new na(!0);c.on("error",a),c.pipe(o).pipe(c),o.on("close",a).on("end",a).on("error",a),c.sign(t,e,r,(l,f)=>{if(l)return a(l);try{o.destroy()}catch{}s(null,f)})})}},_l=(()=>{let o=Qp(__dirname,"..","util/pagent.exe"),a={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(f){f.buffer=null,f.proc&&(f.proc.kill(),f.proc=void 0)}class l extends yl{constructor(){super(),this.proc=void 0,this.buffer=null}_read(u){}_write(u,h,p){if(this.buffer===null)this.buffer=u;else{let S=Buffer.allocUnsafe(this.buffer.length+u.length);this.buffer.copy(S,0),u.copy(S,this.buffer.length),this.buffer=S}if(this.buffer.length<4)return p();let y=ia(this.buffer,0);if(this.buffer.length-4<y)return p();if(u=this.buffer.slice(0,4+y),this.buffer.length>4+y)return p(new Error("Unexpected multiple agent requests"));this.buffer=null;let _,x=this.proc=qp(o,[u.length]);x.stdout.on("data",S=>{this.push(S)}),x.on("error",S=>{_=S,p(_)}),x.on("close",S=>{if(this.proc=void 0,!_){if(_=a[S])return p(_);p()}}),x.stdin.end(u)}_final(u){c(this),u()}_destroy(u,h){c(this),h()}}return class extends Tr{getStream(u){u(null,new l)}}})(),El=(()=>{let n=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Tr{getStream(e){e=bi(e);let r=this.socketPath,s=!1;pl(r,function i(o,a){if(o){if(s)return e(new Error("Invalid cygwin unix socket path"));Wp("cygpath",["-w",r],(Q,B,b)=>{if(Q||B.length===0)return e(new Error("Invalid cygwin unix socket path"));s=!0,r=B.toString().replace(/[\r\n]/g,""),pl(r,i)});return}let c=n.exec(a.toString("ascii"));if(!c)return e(new Error("Malformed cygwin unix socket file"));let l,f=0,u=!1,h=[],p,y=Buffer.alloc(12),_=parseInt(c[1],10),x=c[2].replace(/-/g,""),S=Buffer.allocUnsafe(16);for(let Q=0,B=0;B<32;++Q,B+=2)S[Q]=parseInt(x.substring(B,B+2),16);for(let Q=0;Q<16;Q+=4)ml(S,ia(S,Q),Q);U();function R(){f=0,l="secret",p.write(S)}function H(Q){if(f+=Q.length,l==="secret"){f===16&&(f=0,l="creds",p.write(y));return}if(l==="creds"&&(u||h.push(Q),f===12)){if(p.removeListener("connect",R),p.removeListener("data",H),p.removeListener("error",C),p.removeListener("end",C),p.removeListener("close",C),u)return e(null,p);u=!0,y=Buffer.concat(h),ml(y,process.pid,0),p.on("error",()=>{}),p.destroy(),U()}}function C(){e(new Error("Problem negotiating cygwin unix socket security"))}function U(){p=new Al,p.on("connect",R),p.on("data",H),p.on("error",C),p.on("end",C),p.on("close",C),p.connect(_)}})}}})(),zp=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function bl(n){return process.platform==="win32"&&!zp.test(n)?n==="pageant"?new _l:new El(n):new Tr(n)}var na=(()=>{function l(b){let w;for(;b[R].length;){let k=b[R][0][u];if(k===void 0)break;b[R].shift(),w=b.push(k)}return w}let f=Symbol("Inbound Request Type"),u=Symbol("Inbound Request Response"),h=Symbol("Inbound Request Context");class p{constructor(w,k){this[f]=w,this[u]=void 0,this[h]=k}hasResponded(){return this[u]!==void 0}getType(){return this[f]}getContext(){return this[h]}}function y(b,w,k){return w[u]=k,l(b)}function _(b){if(b[C]=null,b[H]===0){let w=b[R];if(w&&w.length){b[R]=[];for(let k of w)k.cb(new Error("No reply from server"))}}try{b.end()}catch{}setImmediate(()=>{b[B]||b.emit("end"),b[Q]||b.emit("close")})}function x(){this[Q]=!0}function S(){this[B]=!0}let R=Symbol("Requests"),H=Symbol("Agent Protocol Role"),C=Symbol("Agent Protocol Buffer"),U=Symbol("Agent Protocol Current Message Length"),Q=Symbol("Agent Protocol Closed"),B=Symbol("Agent Protocol Ended");return class extends yl{constructor(w){super({autoDestroy:!0,emitClose:!1}),this[H]=w?0:1,this[R]=[],this[C]=null,this[U]=-1,this.once("end",S),this.once("close",x)}_read(w){}_write(w,k,v){this[C]===null?this[C]=w:this[C]=Vp(this[C],w);let P=this[C],ne=P.length,z=0;for(;z<ne&&!(ne<5||(this[U]===-1&&(this[U]=ia(P,z)),ne<4+this[U]));){let Y=P[z+=4];if(++z,this[H]===0){if(this[R].length===0)return v(new Error("Received unexpected message from server"));let te=this[R].shift();switch(Y){case 5:te.cb(new Error("Agent responded with failure"));break;case 12:{if(te.type!==11)return v(new Error("Agent responded with wrong message type"));xt.init(P,z);let le=xt.readUInt32BE();if(le===void 0)return xt.clear(),v(new Error("Malformed agent response"));let O=[];for(let N=0;N<le;++N){let L=xt.readString();if(L===void 0)return xt.clear(),v(new Error("Malformed agent response"));let K=xt.readString(!0);if(K===void 0)return xt.clear(),v(new Error("Malformed agent response"));L=Ei(L),!(L instanceof Error)&&(L.comment=L.comment||K,O.push(L))}z=xt.pos(),xt.clear(),te.cb(null,O);break}case 14:{if(te.type!==13)return v(new Error("Agent responded with wrong message type"));xt.init(P,z);let le=xt.readString();if(z=xt.pos(),xt.clear(),le===void 0)return v(new Error("Malformed agent response"));if(xt.init(le,0),xt.readString(!0),le=xt.readString(),xt.clear(),le===void 0)return v(new Error("Malformed OpenSSH signature format"));te.cb(null,le);break}default:return v(new Error("Agent responded with unsupported message type"))}}else switch(Y){case 11:{let te=new p(Y);this[R].push(te),this.emit("identities",te);break}case 13:{xt.init(P,z);let te=xt.readString(),le=xt.readString(),O=xt.readUInt32BE();if(z=xt.pos(),xt.clear(),O===void 0){let ee=new p(Y);return this[R].push(ee),this.failureReply(ee)}if(te=Ei(te),te instanceof Error){let ee=new p(Y);return this[R].push(ee),this.failureReply(ee)}let N={hash:void 0},L;te.type==="ssh-rsa"&&(O&2?(L="rsa-sha2-256",N.hash="sha256"):O&4&&(L="rsa-sha2-512",N.hash="sha512")),L===void 0&&(L=te.type);let K=new p(Y,L);this[R].push(K),this.emit("sign",K,te,le,N);break}default:{let te=new p(Y);this[R].push(te),this.failureReply(te)}}if(this[U]=-1,z===ne){this[C]=null;break}else this[C]=P=P.slice(z),ne=P.length,z=0}v()}_destroy(w,k){_(this),k()}_final(w){_(this),w()}sign(w,k,v,P){if(this[H]!==0)throw new Error("Client-only method called with server role");typeof v=="function"?(P=v,v=void 0):(typeof v!="object"||v===null)&&(v=void 0);let ne=0;if(w=Ei(w),w instanceof Error)throw new Error("Invalid public key argument");if(w.type==="ssh-rsa"&&v)switch(v.hash){case"sha256":ne=2;break;case"sha512":ne=4;break}w=w.getPublicSSH();let z=13,Y=w.length,te=k.length,le=0,O=Buffer.allocUnsafe(9+Y+4+te+4);return Zt(O,O.length-4,le),O[le+=4]=z,Zt(O,Y,++le),w.copy(O,le+=4),Zt(O,te,le+=Y),k.copy(O,le+=4),Zt(O,ne,le+=te),typeof P!="function"&&(P=ta),this[R].push({type:z,cb:P}),this.push(O)}getIdentities(w){if(this[H]!==0)throw new Error("Client-only method called with server role");let k=11,v=0,P=Buffer.allocUnsafe(5);return Zt(P,P.length-4,v),P[v+=4]=k,typeof w!="function"&&(w=ta),this[R].push({type:k,cb:w}),this.push(P)}failureReply(w){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;let k=0,v=Buffer.allocUnsafe(5);return Zt(v,v.length-4,k),v[k+=4]=5,y(this,w,v)}getIdentitiesReply(w,k){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;if(w.getType()!==11)throw new Error("Invalid response to request");if(!Array.isArray(k))throw new Error("Keys argument must be an array");let v=4,P=[];for(let Y=0;Y<k.length;++Y){let te=k[Y];if(typeof te!="object"||te===null)throw new Error(`Invalid key entry: ${te}`);let le,O;if(gl(te))le=te;else if(gl(te.pubKey))le=te.pubKey;else if(typeof te.pubKey!="object"||te.pubKey===null||({pubKey:le,comment:O}=te.pubKey,le=Ei(le),le instanceof Error))continue;O=le.comment||O,le=le.getPublicSSH(),v+=4+le.length,O&&typeof O=="string"?O=Buffer.from(O):Buffer.isBuffer(O)||(O=Gp),v+=4+O.length,P.push({pubKey:le,comment:O})}let ne=0,z=Buffer.allocUnsafe(5+v);Zt(z,z.length-4,ne),z[ne+=4]=12,Zt(z,P.length,++ne),ne+=4;for(let Y=0;Y<P.length;++Y){let{pubKey:te,comment:le}=P[Y];Zt(z,te.length,ne),te.copy(z,ne+=4),Zt(z,le.length,ne+=te.length),ne+=4,le.length&&(le.copy(z,ne),ne+=le.length)}return y(this,w,z)}signReply(w,k){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;if(w.getType()!==13)throw new Error("Invalid response to request");if(!Buffer.isBuffer(k))throw new Error("Signature argument must be a Buffer");if(k.length===0)throw new Error("Signature argument must be non-empty");let v=0,P=w.getContext(),ne=Buffer.byteLength(P),z=Buffer.allocUnsafe(13+ne+4+k.length);return Zt(z,z.length-4,v),z[v+=4]=14,Zt(z,4+ne+4+k.length,++v),Zt(z,ne,v+=4),z.utf8Write(P,v+=4,ne),Zt(z,k.length,v+=ne),k.copy(z,v+=4),y(this,w,z)}}})(),ea=Symbol("Agent"),_n=Symbol("Agent Keys"),Dn=Symbol("Agent Keys Index"),Pr=Symbol("Agent Init Callbacks"),ra=class{constructor(t){if(typeof t=="string")t=bl(t);else if(!xl(t))throw new Error("Invalid agent argument");this[ea]=t,this[_n]=null,this[Dn]=-1,this[Pr]=null}init(t){if(typeof t!="function"&&(t=ta),this[_n]===null)if(this[Pr]===null){this[Pr]=[t];let e=(...r)=>{process.nextTick(()=>{let s=this[Pr];this[Pr]=null;for(let i of s)i(...r)})};this[ea].getIdentities(bi((r,s)=>{if(r)return e(r);if(!Array.isArray(s))return e(new Error("Agent implementation failed to provide keys"));let i=[];for(let o of s)o=Ei(o),!(o instanceof Error)&&i.push(o);this[_n]=i,this[Dn]=-1,e()}))}else this[Pr].push(t);else process.nextTick(t)}nextKey(){return this[_n]===null||++this[Dn]>=this[_n].length?!1:this[_n][this[Dn]]}currentKey(){return this[_n]===null||this[Dn]>=this[_n].length?null:this[_n][this[Dn]]}pos(){return this[_n]===null||this[Dn]>=this[_n].length?-1:this[Dn]}reset(){this[Dn]=-1}sign(...t){this[ea].sign(...t)}};function xl(n){return n instanceof xi}Sl.exports={AgentContext:ra,AgentProtocol:na,BaseAgent:xi,createAgent:bl,CygwinAgent:El,isAgent:xl,OpenSSHAgent:Tr,PageantAgent:_l}});var ua=ct((Xy,wl)=>{"use strict";var{kMaxLength:Yp}=require("buffer"),{createInflate:jp,constants:{DEFLATE:Xp,INFLATE:Jp,Z_DEFAULT_CHUNK:Zp,Z_DEFAULT_COMPRESSION:eg,Z_DEFAULT_MEMLEVEL:tg,Z_DEFAULT_STRATEGY:ng,Z_DEFAULT_WINDOWBITS:rg,Z_PARTIAL_FLUSH:ig}}=require("zlib"),sg=jp()._handle.constructor;function og(){throw new Error("Should not get here")}function ag(n,t,e){let r=this._owner,s=new Error(n);s.errno=t,s.code=e,r._err=s}function fa(n){n._handle&&(n._handle.close(),n._handle=null)}var ps=class{constructor(t){let e=rg,r=eg,s=tg,i=ng,o=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=Zp,this._maxOutputLength=Yp,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new sg(t),this._handle._owner=this,this._handle.onerror=ag,this._handle.init(e,r,s,i,this._writeState,og,o)}writeSync(t,e){let r=this._handle;if(!r)throw new Error("Invalid Zlib instance");let s=t.length,i=this._chunkSize-this._outOffset,o=0,a,c,l,f=0,u=this._writeState,h=this._outBuffer,p=this._outOffset,y=this._chunkSize;for(;;){if(r.writeSync(ig,t,o,s,h,p,i),this._err)throw this._err;a=u[0],c=u[1];let x=s-c,S=i-a;if(S>0){let R=p===0&&S===h.length?h:h.slice(p,p+S);if(p+=S,l?l.push===void 0?l=[l,R]:l.push(R):l=R,f+=R.byteLength,f>this._maxOutputLength)throw fa(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(S!==0)throw new Error("have should not go down");if((a===0||p>=y)&&(i=y,p=0,h=Buffer.allocUnsafe(y)),a===0)o+=x,s=c;else break}if(this._outBuffer=h,this._outOffset=p,f===0&&(l=Buffer.alloc(0)),e)return l.totalLen=f,l;if(l.push===void 0)return l;let _=Buffer.allocUnsafe(f);for(let x=0,S=0;x<l.length;++x){let R=l[x];_.set(R,S),S+=R.length}return _}},oa=class{constructor(t){this.allocStart=0,this.allocStartKEX=0,this._protocol=t,this._zlib=new ps(Xp)}cleanup(){this._zlib&&fa(this._zlib)}alloc(t,e){return Buffer.allocUnsafe(t)}finalize(t,e){if(this._protocol._kexinit===void 0||e){let r=this._zlib.writeSync(t,!0),s=this._protocol._cipher.allocPacket(r.totalLen);if(r.push===void 0)s.set(r,5);else for(let i=0,o=5;i<r.length;++i){let a=r[i];s.set(a,o),o+=a.length}return s}return t}},aa=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}},ca=class{constructor(){this._zlib=new ps(Jp)}cleanup(){this._zlib&&fa(this._zlib)}read(t){return this._zlib.writeSync(t,!1)}},la=class{cleanup(){}read(t){return t}};wl.exports={PacketReader:la,PacketWriter:aa,ZlibPacketReader:ca,ZlibPacketWriter:oa}});var Bl=ct((Jy,vl)=>{"use strict";var{bufferSlice:da,bufferParser:D,doFatalError:gt,sigSSHToASN1:Il,writeUInt32BE:Cl}=mn(),{CHANNEL_OPEN_FAILURE:cg,COMPAT:lg,MESSAGE:At,TERMINAL_MODE:kl}=Ln(),{parseKey:fg}=Gn(),ug=Array.from(Object.entries(kl)).reduce((n,[t,e])=>({...n,[t]:e}),{});vl.exports={[At.DISCONNECT]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readString(!0),s=D.readString();if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed DISCONNECT packet");n._debug&&n._debug(`Inbound: Received DISCONNECT (${e}, "${r}")`);let i=n._handlers.DISCONNECT;i&&i(n,e,r)},[At.IGNORE]:(n,t)=>{n._debug&&n._debug("Inbound: Received IGNORE")},[At.UNIMPLEMENTED]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed UNIMPLEMENTED packet");n._debug&&n._debug(`Inbound: Received UNIMPLEMENTED (seqno ${e})`)},[At.DEBUG]:(n,t)=>{D.init(t,1);let e=D.readBool(),r=D.readString(!0),s=D.readString();if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed DEBUG packet");n._debug&&n._debug("Inbound: Received DEBUG");let i=n._handlers.DEBUG;i&&i(n,e,r)},[At.SERVICE_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readString(!0);if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed SERVICE_REQUEST packet");n._debug&&n._debug(`Inbound: Received SERVICE_REQUEST (${e})`);let r=n._handlers.SERVICE_REQUEST;r&&r(n,e)},[At.SERVICE_ACCEPT]:(n,t)=>{D.init(t,1);let e=D.readString(!0);if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed SERVICE_ACCEPT packet");n._debug&&n._debug(`Inbound: Received SERVICE_ACCEPT (${e})`);let r=n._handlers.SERVICE_ACCEPT;r&&r(n,e)},[At.EXT_INFO]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r;if(e!==void 0){r=[];for(let i=0;i<e;++i){let o=D.readString(!0),a=D.readString();if(a!==void 0)if(o==="server-sig-algs"){let c=a.latin1Slice(0,a.length).split(",");r.push({name:o,algs:c});continue}else continue;r=void 0;break}}if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed EXT_INFO packet");n._debug&&n._debug("Inbound: Received EXT_INFO");let s=n._handlers.EXT_INFO;s&&s(n,r)},[At.USERAUTH_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readString(!0),s=D.readString(!0),i,o;switch(s){case"none":i=null;break;case"password":{let c=D.readBool();if(c!==void 0&&(i=D.readString(!0),i!==void 0&&c)){let l=D.readString(!0);l!==void 0?i={oldPassword:i,newPassword:l}:i=void 0}break}case"publickey":{let c=D.readBool();if(c!==void 0){let l=D.readString(!0),f=l,u=D.readString(),h;switch(l){case"rsa-sha2-256":f="ssh-rsa",h="sha256";break;case"rsa-sha2-512":f="ssh-rsa",h="sha512";break}if(c){let p=D.pos(),y=D.readString();if(y!==void 0&&(y.length>4+l.length+4&&y.utf8Slice(4,4+l.length)===l&&(y=da(y,4+l.length+4)),y=Il(y,f),y)){let _=n._kex.sessionID,x=Buffer.allocUnsafe(4+_.length+p);Cl(x,_.length,0),x.set(_,4),x.set(new Uint8Array(t.buffer,t.byteOffset,p),4+_.length),i={keyAlgo:f,key:u,signature:y,blob:x,hashAlgo:h}}}else i={keyAlgo:f,key:u,hashAlgo:h},o="publickey -- check"}break}case"hostbased":{let c=D.readString(!0),l=c,f=D.readString(),u=D.readString(!0),h=D.readString(!0),p;switch(c){case"rsa-sha2-256":l="ssh-rsa",p="sha256";break;case"rsa-sha2-512":l="ssh-rsa",p="sha512";break}let y=D.pos(),_=D.readString();if(_!==void 0&&(_.length>4+c.length+4&&_.utf8Slice(4,4+c.length)===c&&(_=da(_,4+c.length+4)),_=Il(_,l),_!==void 0)){let x=n._kex.sessionID,S=Buffer.allocUnsafe(4+x.length+y);Cl(S,x.length,0),S.set(x,4),S.set(new Uint8Array(t.buffer,t.byteOffset,y),4+x.length),i={keyAlgo:l,key:f,signature:_,blob:S,localHostname:u,localUsername:h,hashAlgo:p}}break}case"keyboard-interactive":D.skipString(),i=D.readList();break;default:s!==void 0&&(i=D.readRaw())}if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed USERAUTH_REQUEST packet");o===void 0&&(o=s),n._authsQueue.push(s),n._debug&&n._debug(`Inbound: Received USERAUTH_REQUEST (${o})`);let a=n._handlers.USERAUTH_REQUEST;a&&a(n,e,r,s,i)},[At.USERAUTH_FAILURE]:(n,t)=>{D.init(t,1);let e=D.readList(),r=D.readBool();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_FAILURE packet");n._debug&&n._debug(`Inbound: Received USERAUTH_FAILURE (${e})`),n._authsQueue.shift();let s=n._handlers.USERAUTH_FAILURE;s&&s(n,e,r)},[At.USERAUTH_SUCCESS]:(n,t)=>{n._debug&&n._debug("Inbound: Received USERAUTH_SUCCESS"),n._authsQueue.shift();let e=n._handlers.USERAUTH_SUCCESS;e&&e(n)},[At.USERAUTH_BANNER]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_BANNER packet");n._debug&&n._debug("Inbound: Received USERAUTH_BANNER");let s=n._handlers.USERAUTH_BANNER;s&&s(n,e)},60:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 60 without auth");return}switch(n._authsQueue[0]){case"password":{D.init(t,1);let e=D.readString(!0),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");n._debug&&n._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");let s=n._handlers.USERAUTH_PASSWD_CHANGEREQ;s&&s(n,e);break}case"publickey":{D.init(t,1);let e=D.readString(!0),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_PK_OK packet");n._debug&&n._debug("Inbound: Received USERAUTH_PK_OK"),n._authsQueue.shift();let s=n._handlers.USERAUTH_PK_OK;s&&s(n,e,r);break}case"keyboard-interactive":{D.init(t,1);let e=D.readString(!0),r=D.readString(!0);D.readString();let s=D.readUInt32BE(),i;if(s!==void 0){i=new Array(s);let a;for(a=0;a<s;++a){let c=D.readString(!0),l=D.readBool();if(l===void 0)break;i[a]={prompt:c,echo:l}}a!==s&&(i=void 0)}if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed USERAUTH_INFO_REQUEST packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_REQUEST");let o=n._handlers.USERAUTH_INFO_REQUEST;o&&o(n,e,r,i);break}default:n._debug&&n._debug("Inbound: Received unexpected payload type 60")}},61:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 61 without auth");return}if(n._authsQueue[0]!=="keyboard-interactive")return gt(n,"Inbound: Received unexpected payload type 61");D.init(t,1);let e=D.readUInt32BE(),r;if(e!==void 0){r=new Array(e);let i;for(i=0;i<e;++i){let o=D.readString(!0);if(o===void 0)break;r[i]=o}i!==e&&(r=void 0)}if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_RESPONSE");let s=n._handlers.USERAUTH_INFO_RESPONSE;s&&s(n,r)},[At.GLOBAL_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readBool(),s;if(r!==void 0)switch(e){case"tcpip-forward":case"cancel-tcpip-forward":{let o=D.readString(!0),a=D.readUInt32BE();a!==void 0&&(s={bindAddr:o,bindPort:a});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let o=D.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=[];D.avail()>0;){let o=D.readString();if(o===void 0){s=void 0;break}let a=fg(o);a instanceof Error||s.push(a)}break}default:s=D.readRaw()}if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed GLOBAL_REQUEST packet");n._debug&&n._debug(`Inbound: GLOBAL_REQUEST (${e})`);let i=n._handlers.GLOBAL_REQUEST;i?i(n,e,r,s):n.requestFailure()},[At.REQUEST_SUCCESS]:(n,t)=>{let e=t.length>1?da(t,1):null;n._debug&&n._debug("Inbound: REQUEST_SUCCESS");let r=n._handlers.REQUEST_SUCCESS;r&&r(n,e)},[At.REQUEST_FAILURE]:(n,t)=>{n._debug&&n._debug("Inbound: Received REQUEST_FAILURE");let e=n._handlers.REQUEST_FAILURE;e&&e(n)},[At.CHANNEL_OPEN]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readUInt32BE(),s=D.readUInt32BE(),i=D.readUInt32BE(),o;switch(e){case"forwarded-tcpip":case"direct-tcpip":{let c=D.readString(!0),l=D.readUInt32BE(),f=D.readString(!0),u=D.readUInt32BE();u!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{destIP:c,destPort:l,srcIP:f,srcPort:u}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{let c=D.readString(!0);c!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{socketPath:c}});break}case"x11":{let c=D.readString(!0),l=D.readUInt32BE();l!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{srcIP:c,srcPort:l}});break}default:o={type:e,sender:r,window:s,packetSize:i,data:{}}}if(D.clear(),o===void 0)return gt(n,"Inbound: Malformed CHANNEL_OPEN packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN (s:${r}, ${e})`);let a=n._handlers.CHANNEL_OPEN;a?a(n,o):n.channelOpenFail(o.sender,cg.ADMINISTRATIVELY_PROHIBITED,"","")},[At.CHANNEL_OPEN_CONFIRMATION]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE(),s=D.readUInt32BE(),i=D.readUInt32BE(),o=D.avail()?D.readRaw():void 0;if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${e}, s:${r})`);let a=n._handlers.CHANNEL_OPEN_CONFIRMATION;a&&a(n,{recipient:e,sender:r,window:s,packetSize:i,data:o})},[At.CHANNEL_OPEN_FAILURE]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE(),s=D.readString(!0),i=D.readString();if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed CHANNEL_OPEN_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${e})`);let o=n._handlers.CHANNEL_OPEN_FAILURE;o&&o(n,e,r,s)},[At.CHANNEL_WINDOW_ADJUST]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");n._debug&&n._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${e}, ${r})`);let s=n._handlers.CHANNEL_WINDOW_ADJUST;s&&s(n,e,r)},[At.CHANNEL_DATA]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed CHANNEL_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_DATA (r:${e}, ${r.length})`);let s=n._handlers.CHANNEL_DATA;s&&s(n,e,r)},[At.CHANNEL_EXTENDED_DATA]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE(),s=D.readString();if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${e}, ${s.length})`);let i=n._handlers.CHANNEL_EXTENDED_DATA;i&&i(n,e,s,r)},[At.CHANNEL_EOF]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_EOF packet");n._debug&&n._debug(`Inbound: CHANNEL_EOF (r:${e})`);let r=n._handlers.CHANNEL_EOF;r&&r(n,e)},[At.CHANNEL_CLOSE]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_CLOSE packet");n._debug&&n._debug(`Inbound: CHANNEL_CLOSE (r:${e})`);let r=n._handlers.CHANNEL_CLOSE;r&&r(n,e)},[At.CHANNEL_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readString(!0),s=D.readBool(),i;if(s!==void 0)switch(r){case"exit-status":i=D.readUInt32BE(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"exit-signal":{let a,c;if(n._compatFlags&lg.OLD_EXIT){let f=D.readUInt32BE();switch(f){case 1:a="HUP";break;case 2:a="INT";break;case 3:a="QUIT";break;case 6:a="ABRT";break;case 9:a="KILL";break;case 14:a="ALRM";break;case 15:a="TERM";break;default:f!==void 0&&(a=`UNKNOWN (${f})`)}c=!1}else a=D.readString(!0),c=D.readBool(),c===void 0&&(a=void 0);let l=D.readString(!0);D.skipString()!==void 0&&(i={signal:a,coreDumped:c,errorMessage:l}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a})`);break}case"pty-req":{let a=D.readString(!0),c=D.readUInt32BE(),l=D.readUInt32BE(),f=D.readUInt32BE(),u=D.readUInt32BE(),h=D.readString();if(h!==void 0){D.init(h,1);let p={};for(;D.avail();){let y=D.readByte();if(y===kl.TTY_OP_END)break;let _=ug[y],x=D.readUInt32BE();if(y===void 0||_===void 0||x===void 0){p=void 0;break}p[_]=x}p!==void 0&&(i={term:a,cols:c,rows:l,width:f,height:u,modes:p})}n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"window-change":{let a=D.readUInt32BE(),c=D.readUInt32BE(),l=D.readUInt32BE(),f=D.readUInt32BE();f!==void 0&&(i={cols:a,rows:c,width:l,height:f}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"x11-req":{let a=D.readBool(),c=D.readString(!0),l=D.readString(),f=D.readUInt32BE();f!==void 0&&(i={single:a,protocol:c,cookie:l,screen:f}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"env":{let a=D.readString(!0),c=D.readString(!0);c!==void 0&&(i={name:a,value:c}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a}=${c})`);break}case"shell":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;case"exec":i=D.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"subsystem":i=D.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"signal":i=D.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"xon-xoff":i=D.readBool(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"auth-agent-req@openssh.com":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;default:i=D.avail()?D.readRaw():null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`)}if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed CHANNEL_REQUEST packet");let o=n._handlers.CHANNEL_REQUEST;o&&o(n,e,r,s,i)},[At.CHANNEL_SUCCESS]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_SUCCESS packet");n._debug&&n._debug(`Inbound: CHANNEL_SUCCESS (r:${e})`);let r=n._handlers.CHANNEL_SUCCESS;r&&r(n,e)},[At.CHANNEL_FAILURE]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_FAILURE (r:${e})`);let r=n._handlers.CHANNEL_FAILURE;r&&r(n,e)}}});var gs=ct((Zy,Rl)=>{"use strict";var ha=new Array(256);[ms().HANDLERS,Bl()].forEach(n=>{for(let[t,e]of Object.entries(n))t=+t,isFinite(t)&&t>=0&&t<ha.length&&(ha[t]=e)});Rl.exports=ha});var ms=ct((t_,Fl)=>{"use strict";var{createDiffieHellman:dg,createDiffieHellmanGroup:hg,createECDH:pg,createHash:ga,createPublicKey:gg,diffieHellman:mg,generateKeyPairSync:Ag,randomFillSync:yg}=require("crypto"),{Ber:Nl}=si(),{COMPAT:ma,curve25519Supported:_g,DEFAULT_KEX:Pl,DEFAULT_SERVER_HOST_KEY:Tl,DEFAULT_CIPHER:As,DEFAULT_MAC:ys,DEFAULT_COMPRESSION:_s,DISCONNECT_REASON:ze,MESSAGE:ht}=Ln(),{CIPHER_INFO:Dr,createCipher:Eg,createDecipher:bg,MAC_INFO:Ll}=qn(),{parseDERKey:xg}=Gn(),{bufferFill:Sg,bufferParser:Ge,convertSignature:wg,doFatalError:Ye,FastBuffer:Ig,sigSSHToASN1:Cg,writeUInt32BE:Mt}=mn(),{PacketReader:$l,PacketWriter:Dl,ZlibPacketReader:Es,ZlibPacketWriter:bs}=ua(),Lr,kg=2048,vg=8192,Bg=Buffer.alloc(0);function Ul(n){let t;if(n._compatFlags&ma.BAD_DHGEX){let e=n._offer.lists.kex,r=e.array,s=!1;for(let i=0;i<r.length;++i)r[i].includes("group-exchange")&&(s||(s=!0,r=r.slice()),r.splice(i--,1));if(s){let i=17+n._offer.totalSize+1+4,o=Buffer.from(r.join(","));i-=e.buffer.length-o.length;let a=n._offer.lists.all,c=new Uint8Array(a.buffer,a.byteOffset+4+e.buffer.length,a.length-(4+e.buffer.length));t=Buffer.allocUnsafe(i),Mt(t,o.length,17),t.set(o,21),t.set(c,21+o.length)}}t===void 0&&(t=Buffer.allocUnsafe(17+n._offer.totalSize+1+4),n._offer.copyAllTo(t,17)),n._debug&&n._debug("Outbound: Sending KEXINIT"),t[0]=ht.KEXINIT,yg(t,1,16),Sg(t,0,t.length-5),n._kexinit=t,n._packetRW.write.allocStart=0;{let e=n._packetRW.write.allocStartKEX,r=n._packetRW.write.alloc(t.length,!0);r.set(t,e),n._cipher.encrypt(n._packetRW.write.finalize(r,!0))}}function Ol(n,t){let e={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(Ge.init(t,17),(e.kex=Ge.readList())===void 0||(e.serverHostKey=Ge.readList())===void 0||(e.cs.cipher=Ge.readList())===void 0||(e.sc.cipher=Ge.readList())===void 0||(e.cs.mac=Ge.readList())===void 0||(e.sc.mac=Ge.readList())===void 0||(e.cs.compress=Ge.readList())===void 0||(e.sc.compress=Ge.readList())===void 0||(e.cs.lang=Ge.readList())===void 0||(e.sc.lang=Ge.readList())===void 0)return Ge.clear(),Ye(n,"Received malformed KEXINIT","handshake",ze.KEY_EXCHANGE_FAILED);let r=Ge.pos(),s=r<t.length&&t[r]===1;Ge.clear();let i=n._offer,o=e,a=i.lists.kex.array;if(n._compatFlags&ma.BAD_DHGEX){let C=!1;for(let U=0;U<a.length;++U)a[U].indexOf("group-exchange")!==-1&&(C||(C=!0,a=a.slice()),a.splice(U--,1))}let c,l,f,u=n._debug;u&&u("Inbound: Handshake in progress"),u&&u(`Handshake: (local) KEX method: ${a}`),u&&u(`Handshake: (remote) KEX method: ${o.kex}`);let h;if(n._server?(l=a,c=o.kex,h=c.indexOf("ext-info-c")!==-1):(l=o.kex,c=a,h=l.indexOf("ext-info-s")!==-1),n._strictMode===void 0&&(n._server?n._strictMode=c.indexOf("kex-strict-c-v00@openssh.com")!==-1:n._strictMode=l.indexOf("kex-strict-s-v00@openssh.com")!==-1,n._strictMode&&(u&&u("Handshake: strict KEX mode enabled"),n._decipher.inSeqno!==1)))return u&&u("Handshake: KEXINIT not first packet in strict KEX mode"),Ye(n,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",ze.KEY_EXCHANGE_FAILED);for(f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: no matching key exchange algorithm"),Ye(n,"Handshake failed: no matching key exchange algorithm","handshake",ze.KEY_EXCHANGE_FAILED);e.kex=c[f],u&&u(`Handshake: KEX algorithm: ${c[f]}`),s&&(!o.kex.length||c[f]!==o.kex[0])&&(n._skipNextInboundPacket=!0);let p=i.lists.serverHostKey.array;for(u&&u(`Handshake: (local) Host key format: ${p}`),u&&u(`Handshake: (remote) Host key format: ${o.serverHostKey}`),n._server?(l=p,c=o.serverHostKey):(l=o.serverHostKey,c=p),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching host key format"),Ye(n,"Handshake failed: no matching host key format","handshake",ze.KEY_EXCHANGE_FAILED);e.serverHostKey=c[f],u&&u(`Handshake: Host key format: ${c[f]}`);let y=i.lists.cs.cipher.array;for(u&&u(`Handshake: (local) C->S cipher: ${y}`),u&&u(`Handshake: (remote) C->S cipher: ${o.cs.cipher}`),n._server?(l=y,c=o.cs.cipher):(l=o.cs.cipher,c=y),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching C->S cipher"),Ye(n,"Handshake failed: no matching C->S cipher","handshake",ze.KEY_EXCHANGE_FAILED);e.cs.cipher=c[f],u&&u(`Handshake: C->S Cipher: ${c[f]}`);let _=i.lists.sc.cipher.array;for(u&&u(`Handshake: (local) S->C cipher: ${_}`),u&&u(`Handshake: (remote) S->C cipher: ${o.sc.cipher}`),n._server?(l=_,c=o.sc.cipher):(l=o.sc.cipher,c=_),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching S->C cipher"),Ye(n,"Handshake failed: no matching S->C cipher","handshake",ze.KEY_EXCHANGE_FAILED);e.sc.cipher=c[f],u&&u(`Handshake: S->C cipher: ${c[f]}`);let x=i.lists.cs.mac.array;if(u&&u(`Handshake: (local) C->S MAC: ${x}`),u&&u(`Handshake: (remote) C->S MAC: ${o.cs.mac}`),Dr[e.cs.cipher].authLen>0)e.cs.mac="",u&&u("Handshake: C->S MAC: <implicit>");else{for(n._server?(l=x,c=o.cs.mac):(l=o.cs.mac,c=x),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching C->S MAC"),Ye(n,"Handshake failed: no matching C->S MAC","handshake",ze.KEY_EXCHANGE_FAILED);e.cs.mac=c[f],u&&u(`Handshake: C->S MAC: ${c[f]}`)}let S=i.lists.sc.mac.array;if(u&&u(`Handshake: (local) S->C MAC: ${S}`),u&&u(`Handshake: (remote) S->C MAC: ${o.sc.mac}`),Dr[e.sc.cipher].authLen>0)e.sc.mac="",u&&u("Handshake: S->C MAC: <implicit>");else{for(n._server?(l=S,c=o.sc.mac):(l=o.sc.mac,c=S),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching S->C MAC"),Ye(n,"Handshake failed: no matching S->C MAC","handshake",ze.KEY_EXCHANGE_FAILED);e.sc.mac=c[f],u&&u(`Handshake: S->C MAC: ${c[f]}`)}let R=i.lists.cs.compress.array;for(u&&u(`Handshake: (local) C->S compression: ${R}`),u&&u(`Handshake: (remote) C->S compression: ${o.cs.compress}`),n._server?(l=R,c=o.cs.compress):(l=o.cs.compress,c=R),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching C->S compression"),Ye(n,"Handshake failed: no matching C->S compression","handshake",ze.KEY_EXCHANGE_FAILED);e.cs.compress=c[f],u&&u(`Handshake: C->S compression: ${c[f]}`);let H=i.lists.sc.compress.array;for(u&&u(`Handshake: (local) S->C compression: ${H}`),u&&u(`Handshake: (remote) S->C compression: ${o.sc.compress}`),n._server?(l=H,c=o.sc.compress):(l=o.sc.compress,c=H),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching S->C compression"),Ye(n,"Handshake failed: no matching S->C compression","handshake",ze.KEY_EXCHANGE_FAILED);e.sc.compress=c[f],u&&u(`Handshake: S->C compression: ${c[f]}`),e.cs.lang="",e.sc.lang="",n._kex&&(n._kexinit||Ul(n),n._decipher._onPayload=Ml.bind(n,{firstPacket:!1})),n._kex=Rg(e,n,t),n._kex.remoteExtInfoEnabled=h,n._kex.start()}var Rg=(()=>{function n(o){let a=0,c=o.length;for(;o[a]===0;)++a,--c;let l;return o[a]&128?(l=Buffer.allocUnsafe(1+c),l[0]=0,o.copy(l,1,a),o=l):c!==o.length&&(l=Buffer.allocUnsafe(c),o.copy(l,0,a),o=l),o}class t{constructor(a,c,l){this._protocol=c,this.sessionID=c._kex?c._kex.sessionID:void 0,this.negotiated=a,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=c._kexinit,this._remoteKexinit=l,this._identRaw=c._identRaw,this._remoteIdentRaw=c._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(a){if(this._finished)return!1;this._finished=!0;let c=this._protocol._server,l=this.negotiated,f=this.convertPublicKey(this._dhData),u=this.computeSecret(this._dhData);if(u instanceof Error)return u.message=`Error while computing DH secret (${this.type}): ${u.message}`,u.level="handshake",Ye(this._protocol,u,ze.KEY_EXCHANGE_FAILED);let h=ga(this.hashName);In(h,c?this._remoteIdentRaw:this._identRaw),In(h,c?this._identRaw:this._remoteIdentRaw),In(h,c?this._remoteKexinit:this._kexinit),In(h,c?this._kexinit:this._remoteKexinit);let p=c?this._hostKey.getPublicSSH():this._hostKey;if(In(h,p),this.type==="groupex"){let H=this.getDHParams(),C=Buffer.allocUnsafe(4);Mt(C,this._minBits,0),h.update(C),Mt(C,this._prefBits,0),h.update(C),Mt(C,this._maxBits,0),h.update(C),In(h,H.prime),In(h,H.generator)}In(h,c?f:this.getPublicKey());let y=c?this.getPublicKey():f;In(h,y),In(h,u);let _=h.digest();if(c){let H;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":H="sha256";break;case"rsa-sha2-512":H="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let C=this._hostKey.sign(_,H);if(C instanceof Error)return Ye(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${C.message}`,"handshake",ze.KEY_EXCHANGE_FAILED);if(C=wg(C,this._hostKey.type),C===!1)return Ye(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",ze.KEY_EXCHANGE_FAILED);let U=this.negotiated.serverHostKey,Q=Buffer.byteLength(U),B=4+Q+4+C.length,b=this._protocol._packetRW.write.allocStartKEX,w=this._protocol._packetRW.write.alloc(5+p.length+4+y.length+4+B,!0);if(w[b]=ht.KEXDH_REPLY,Mt(w,p.length,++b),w.set(p,b+=4),Mt(w,y.length,b+=p.length),w.set(y,b+=4),Mt(w,B,b+=y.length),Mt(w,Q,b+=4),w.utf8Write(U,b+=4,Q),Mt(w,C.length,b+=Q),w.set(C,b+=4),this._protocol._debug){let k;switch(this.type){case"group":k="KEXDH_REPLY";break;case"groupex":k="KEXDH_GEX_REPLY";break;default:k="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${k}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(w,!0))}else{Ge.init(this._sig,0);let H=Ge.readString(!0);if(!H)return Ye(this._protocol,"Malformed packet while reading signature","handshake",ze.KEY_EXCHANGE_FAILED);if(H!==l.serverHostKey)return Ye(this._protocol,`Wrong signature type: ${H}, expected: ${l.serverHostKey}`,"handshake",ze.KEY_EXCHANGE_FAILED);let C=Ge.readString();if(Ge.clear(),C===void 0)return Ye(this._protocol,"Malformed packet while reading signature","handshake",ze.KEY_EXCHANGE_FAILED);if(!(C=Cg(C,H)))return Ye(this._protocol,"Malformed signature","handshake",ze.KEY_EXCHANGE_FAILED);let U;{Ge.init(this._hostKey,0);let b=Ge.readString(!0),w=this._hostKey.slice(Ge.pos());if(Ge.clear(),U=xg(w,b),U instanceof Error)return U.level="handshake",Ye(this._protocol,U,ze.KEY_EXCHANGE_FAILED)}let Q;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":Q="sha256";break;case"rsa-sha2-512":Q="sha512";break}this._protocol._debug&&this._protocol._debug("Verifying signature ...");let B=U.verify(_,C,Q);if(B!==!0)return B instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${B.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),Ye(this._protocol,"Handshake failed: signature verification failed","handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(c||!a)&&xs(this);let x,S,R=H=>{if(x)return xs(this),x.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=Eg(x),this._protocol._packetRW.write=S,x=void 0,S=void 0,this._protocol._onHandshakeComplete(l),!1;this.sessionID||(this.sessionID=_);{let te=Buffer.allocUnsafe(4+u.length);Mt(te,u.length,0),te.set(u,4),u=te}let C=Dr[l.cs.cipher],U=Dr[l.sc.cipher],Q=$r(C.ivLen,this.hashName,u,_,this.sessionID,"A"),B=$r(U.ivLen,this.hashName,u,_,this.sessionID,"B"),b=$r(C.keyLen,this.hashName,u,_,this.sessionID,"C"),w=$r(U.keyLen,this.hashName,u,_,this.sessionID,"D"),k,v;C.authLen||(k=Ll[l.cs.mac],v=$r(k.len,this.hashName,u,_,this.sessionID,"E"));let P,ne;U.authLen||(P=Ll[l.sc.mac],ne=$r(P.len,this.hashName,u,_,this.sessionID,"F"));let z={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:c?C:U,decipherIV:c?Q:B,decipherKey:c?b:w,macInfo:c?k:P,macKey:c?v:ne},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:c?U:C,cipherIV:c?B:Q,cipherKey:c?w:b,macInfo:c?P:k,macKey:c?ne:v}};this._protocol._decipher.free(),x=z,this._protocol._decipher=bg(z);let Y={read:void 0,write:void 0};switch(l.cs.compress){case"zlib":c?Y.read=new Es:Y.write=new bs(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){c?Y.read=new Es:Y.write=new bs(this._protocol);break}default:c?Y.read=new $l:Y.write=new Dl(this._protocol)}switch(l.sc.compress){case"zlib":c?Y.write=new bs(this._protocol):Y.read=new Es;break;case"zlib@openssh.com":if(this._protocol._authenticated){c?Y.write=new bs(this._protocol):Y.read=new Es;break}default:c?Y.write=new Dl(this._protocol):Y.read=new $l}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=Y.read,S=Y.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,H?!1:R()};if((c||a)&&(this.finish=R),!c)return R(a)}start(){if(!this._protocol._server){if(this._protocol._debug){let f;this.type==="group"?f="KEXDH_INIT":f="KEXECDH_INIT",this._protocol._debug(`Outbound: Sending ${f}`)}let a=this.getPublicKey(),c=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[c]=ht.KEXDH_INIT,Mt(l,a.length,++c),l.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}getPublicKey(){this.generateKeys();let a=this._public;if(a)return this.convertPublicKey(a)}convertPublicKey(a){let c,l=0,f=a.length;for(;a[l]===0;)++l,--f;return a[l]&128?(c=Buffer.allocUnsafe(1+f),c[0]=0,a.copy(c,1,l),c):(f!==a.length&&(c=Buffer.allocUnsafe(f),a.copy(c,0,l),a=c),a)}computeSecret(a){this.generateKeys();try{return n(this._dh.computeSecret(a))}catch(c){return c}}parse(a){let c=a[0];switch(this._step){case 1:if(this._protocol._server){if(c!==ht.KEXDH_INIT)return Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_INIT}`,"handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),Ge.init(a,1);let l=Ge.readString();if(Ge.clear(),l===void 0)return Ye(this._protocol,"Received malformed KEX*_INIT","handshake",ze.KEY_EXCHANGE_FAILED);this._dhData=l;let f=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(f)&&(f=f[0]),this._hostKey=f,this.finish()}else{if(c!==ht.KEXDH_REPLY)return Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_REPLY}`,"handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),Ge.init(a,1);let l,f,u;if((l=Ge.readString())===void 0||(f=Ge.readString())===void 0||(u=Ge.readString())===void 0)return Ge.clear(),Ye(this._protocol,"Received malformed KEX*_REPLY","handshake",ze.KEY_EXCHANGE_FAILED);Ge.clear(),Ge.init(l,0);let h=Ge.readString(!0);if(Ge.clear(),h===void 0)return Ye(this._protocol,"Received malformed host public key","handshake",ze.KEY_EXCHANGE_FAILED);if(h!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(h==="ssh-rsa")break;default:return Ye(this._protocol,"Host key does not match negotiated type","handshake",ze.KEY_EXCHANGE_FAILED)}this._hostKey=l,this._dhData=f,this._sig=u;let p=!1,y;if(this._protocol._hostVerifier===void 0?(y=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):y=this._protocol._hostVerifier(l,_=>{if(!p){if(p=!0,_===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),Ye(this._protocol,"Host denied (verification failed)","handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():xs(this)}}),y===void 0){++this._step;return}if(p=!0,y===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),Ye(this._protocol,"Host denied (verification failed)","handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,xs(this)}++this._step;break;case 2:return c!==ht.NEWKEYS?Ye(this._protocol,`Received packet ${c} instead of ${ht.NEWKEYS}`,"handshake",ze.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 Ye(this._protocol,`Received unexpected packet ${c} after NEWKEYS`,"handshake",ze.KEY_EXCHANGE_FAILED)}}}class e extends t{constructor(a,...c){super(...c),this.type="25519",this.hashName=a,this._keys=null}generateKeys(){this._keys||(this._keys=Ag("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(a){let c,l=0,f=a.length;for(;a[l]===0;)++l,--f;return a.length===32||f!==a.length&&(c=Buffer.allocUnsafe(f),a.copy(c,0,l),a=c),a}computeSecret(a){this.generateKeys();try{let c=new Nl.Writer;return c.startSequence(),c.startSequence(),c.writeOID("1.3.101.110"),c.endSequence(),c.startSequence(Nl.BitString),c.writeByte(0),c._ensure(a.length),a.copy(c._buf,c._offset,0,a.length),c._offset+=a.length,c.endSequence(),c.endSequence(),n(mg({privateKey:this._keys.privateKey,publicKey:gg({key:c.buffer,type:"spki",format:"der"})}))}catch(c){return c}}}class r extends t{constructor(a,c,...l){super(...l),this.type="ecdh",this.curveName=a,this.hashName=c}generateKeys(){this._dh||(this._dh=pg(this.curveName),this._public=this._dh.generateKeys())}}class s extends t{constructor(a,...c){super(...c),this.type="groupex",this.hashName=a,this._prime=null,this._generator=null,this._minBits=kg,this._prefBits=Ng(this.negotiated),this._protocol._compatFlags&ma.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=vg}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let a=this._protocol._packetRW.write.allocStartKEX,c=this._protocol._packetRW.write.alloc(13,!0);c[a]=ht.KEXDH_GEX_REQUEST,Mt(c,this._minBits,++a),Mt(c,this._prefBits,a+=4),Mt(c,this._maxBits,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(c,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=dg(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(a,c){if(!Buffer.isBuffer(a))throw new Error("Invalid prime value");if(!Buffer.isBuffer(c))throw new Error("Invalid generator value");this._prime=a,this._generator=c}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}parse(a){let c=a[0];switch(this._step){case 1:{if(this._protocol._server)return c!==ht.KEXDH_GEX_REQUEST?Ye(this._protocol,`Received packet ${c} instead of `+ht.KEXDH_GEX_REQUEST,"handshake",ze.KEY_EXCHANGE_FAILED):Ye(this._protocol,"Group exchange not implemented for server","handshake",ze.KEY_EXCHANGE_FAILED);if(c!==ht.KEXDH_GEX_GROUP)return Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_GEX_GROUP}`,"handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),Ge.init(a,1);let l,f;if((l=Ge.readString())===void 0||(f=Ge.readString())===void 0)return Ge.clear(),Ye(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",ze.KEY_EXCHANGE_FAILED);Ge.clear(),this.setDHParams(l,f),this.generateKeys();let u=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let h=this._protocol._packetRW.write.allocStartKEX,p=this._protocol._packetRW.write.alloc(5+u.length,!0);p[h]=ht.KEXDH_GEX_INIT,Mt(p,u.length,++h),p.set(u,h+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(p,!0)),++this._step;break}case 2:if(this._protocol._server)return c!==ht.KEXDH_GEX_INIT?Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_GEX_INIT}`,"handshake",ze.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),Ye(this._protocol,"Group exchange not implemented for server","handshake",ze.KEY_EXCHANGE_FAILED));if(c!==ht.KEXDH_GEX_REPLY)return Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_GEX_REPLY}`,"handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,a[0]=ht.KEXDH_REPLY,this.parse=t.prototype.parse,this.parse(a)}}}class i extends t{constructor(a,c,...l){super(...l),this.type="group",this.groupName=a,this.hashName=c}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");let a=this.getPublicKey(),c=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[c]=ht.KEXDH_INIT,Mt(l,a.length,++c),l.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}generateKeys(){this._dh||(this._dh=hg(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}}return(o,...a)=>{if(typeof o!="object"||o===null)throw new Error("Invalid negotiated argument");let c=o.kex;if(typeof c=="string"){switch(a=[o,...a],c){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!_g)break;return new e("sha256",...a);case"ecdh-sha2-nistp256":return new r("prime256v1","sha256",...a);case"ecdh-sha2-nistp384":return new r("secp384r1","sha384",...a);case"ecdh-sha2-nistp521":return new r("secp521r1","sha512",...a);case"diffie-hellman-group1-sha1":return new i("modp2","sha1",...a);case"diffie-hellman-group14-sha1":return new i("modp14","sha1",...a);case"diffie-hellman-group14-sha256":return new i("modp14","sha256",...a);case"diffie-hellman-group15-sha512":return new i("modp15","sha512",...a);case"diffie-hellman-group16-sha512":return new i("modp16","sha512",...a);case"diffie-hellman-group17-sha512":return new i("modp17","sha512",...a);case"diffie-hellman-group18-sha512":return new i("modp18","sha512",...a);case"diffie-hellman-group-exchange-sha1":return new s("sha1",...a);case"diffie-hellman-group-exchange-sha256":return new s("sha256",...a)}throw new Error(`Unsupported key exchange algorithm: ${c}`)}throw new Error(`Invalid key exchange type: ${c}`)}})(),pa=(()=>{let n=["kex","serverHostKey",["cs","cipher"],["sc","cipher"],["cs","mac"],["sc","mac"],["cs","compress"],["sc","compress"],["cs","lang"],["sc","lang"]];return class{constructor(e){if(typeof e!="object"||e===null)throw new TypeError("Argument must be an object");let r={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},s=0;for(let a of n){let c,l,f,u;if(typeof a=="string")c=r,l=e[a],f=u=a;else{let p=a[0];c=r[p],u=a[1],l=e[p][u],f=`${p}.${u}`}let h={array:void 0,buffer:void 0};if(Buffer.isBuffer(l))h.array=(""+l).split(","),h.buffer=l,s+=4+l.length;else{if(typeof l=="string"&&(l=l.split(",")),Array.isArray(l))h.array=l,h.buffer=Buffer.from(l.join(","));else throw new TypeError(`Invalid \`${f}\` type: ${typeof l}`);s+=4+h.buffer.length}c[u]=h}let i=Buffer.allocUnsafe(s);r.all=i;let o=0;for(let a of n){let c;typeof a=="string"?c=r[a].buffer:c=r[a[0]][a[1]].buffer,o=Mt(i,c.length,o),i.set(c,o),o+=c.length}this.totalSize=s,this.lists=r}copyAllTo(e,r){let s=this.lists.all;if(typeof r!="number")throw new TypeError(`Invalid offset value: ${typeof r}`);if(e.length-r<s.length)throw new Error("Insufficient space to copy list");return e.set(s,r),s.length}}})(),In=(()=>{let n=Buffer.allocUnsafe(4);return(t,e)=>{Mt(n,e.length,0),t.update(n),t.update(e)}})();function $r(n,t,e,r,s,i){let o;if(n){let a=ga(t).update(e).update(r).update(i).update(s).digest();for(;a.length<n;){let c=ga(t).update(e).update(r).update(a).digest(),l=Buffer.allocUnsafe(a.length+c.length);l.set(a,0),l.set(c,a.length),a=l}a.length===n?o=a:o=new Ig(a.buffer,a.byteOffset,n)}else o=Bg;return o}function Ml(n,t){if(t.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}if(this._skipNextInboundPacket){this._skipNextInboundPacket=!1;return}t=this._packetRW.read.read(t);let e=t[0];if(!this._strictMode)switch(e){case ht.IGNORE:case ht.UNIMPLEMENTED:case ht.DEBUG:return Lr||(Lr=gs()),Lr[e](this,t)}switch(e){case ht.DISCONNECT:return Lr||(Lr=gs()),Lr[e](this,t);case ht.KEXINIT:return n.firstPacket?(n.firstPacket=!1,Ol(this,t)):Ye(this,"Received extra KEXINIT during handshake","handshake",ze.KEY_EXCHANGE_FAILED);default:if(e<20||e>49)return Ye(this,`Received unexpected packet type ${e}`,"handshake",ze.KEY_EXCHANGE_FAILED)}return this._kex.parse(t)}function Ng(n){let t=Dr[n.cs.cipher],e=Dr[n.sc.cipher],r=Math.max(0,t.sslName==="des-ede3-cbc"?14:t.keyLen,t.blockLen,t.ivLen,e.sslName==="des-ede3-cbc"?14:e.keyLen,e.blockLen,e.ivLen)*8;return r<=112?2048:r<=128?3072:r<=192?7680:8192}function xs(n){if(!n._sentNEWKEYS){n._protocol._debug&&n._protocol._debug("Outbound: Sending NEWKEYS");let t=n._protocol._packetRW.write.allocStartKEX,e=n._protocol._packetRW.write.alloc(1,!0);e[t]=ht.NEWKEYS,n._protocol._cipher.encrypt(n._protocol._packetRW.write.finalize(e,!0)),n._sentNEWKEYS=!0,n._protocol._strictMode&&(n._protocol._cipher.outSeqno=0)}}Fl.exports={KexInit:pa,kexinit:Ul,onKEXPayload:Ml,DEFAULT_KEXINIT_CLIENT:new pa({kex:Pl.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:Tl,cs:{cipher:As,mac:ys,compress:_s,lang:[]},sc:{cipher:As,mac:ys,compress:_s,lang:[]}}),DEFAULT_KEXINIT_SERVER:new pa({kex:Pl.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:Tl,cs:{cipher:As,mac:ys,compress:_s,lang:[]},sc:{cipher:As,mac:ys,compress:_s,lang:[]}}),HANDLERS:{[ht.KEXINIT]:Ol}}});var Hl=ct((n_,Pg)=>{Pg.exports={name:"ssh2",version:"1.17.0",author:"Brian White <mscdex@mscdex.net>",description:"SSH2 client and server modules written in pure JavaScript for node.js",main:"./lib/index.js",engines:{node:">=10.16.0"},dependencies:{asn1:"^0.2.6","bcrypt-pbkdf":"^1.0.2"},devDependencies:{"@mscdex/eslint-config":"^1.1.0",eslint:"^7.32.0"},optionalDependencies:{"cpu-features":"~0.0.10",nan:"^2.23.0"},scripts:{install:"node install.js",rebuild:"node install.js",test:"node test/test.js",lint:"eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js examples lib test","lint:fix":"npm run lint -- --fix"},keywords:["ssh","ssh2","sftp","secure","shell","exec","remote","client"],licenses:[{type:"MIT",url:"http://github.com/mscdex/ssh2/raw/master/LICENSE"}],repository:{type:"git",url:"http://github.com/mscdex/ssh2.git"}}});var Ea=ct((r_,ef)=>{"use strict";var{inspect:Gl}=require("util"),{bindingAvailable:Tg,NullCipher:Lg,NullDecipher:$g}=qn(),{COMPAT_CHECKS:Dg,DISCONNECT_REASON:zl,eddsaSupported:Ug,MESSAGE:we,SIGNALS:Ql,TERMINAL_MODE:ya}=Ln(),{DEFAULT_KEXINIT_CLIENT:Og,DEFAULT_KEXINIT_SERVER:Mg,KexInit:Wl,kexinit:Yl,onKEXPayload:Fg}=ms(),{parseKey:ql}=Gn(),Hg=gs(),{bufferCopy:Ss,bufferFill:Qg,bufferSlice:jl,convertSignature:Kl,sendPacket:Ie,writeUInt32BE:T}=mn(),{PacketReader:Wg,PacketWriter:qg,ZlibPacketReader:Xl,ZlibPacketWriter:Jl}=ua(),Kg=Hl().version,Vg=new Map(Object.values(zl).map(n=>[n,1])),Zl=Buffer.from(`SSH-2.0-ssh2js${Kg}`),Gg=Buffer.from(`${Zl}\r
|
|
7
|
+
${e}-----END ${n} KEY-----`}function pi(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return e.set(n,0),e.set(t,n.length),e}function jo(n,t){let e=n.length,r=n._pos||0;for(let s=0;s<t;++s){let i=e-r;if(r>=e||i<4)return!1;let o=ui(n,r);if(i<4+o)return!1;r+=4+o}return n._pos=r,!0}function gi(n,t){let e=new Re.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.113549.1.1.1"),e.writeNull(),e.endSequence(),e.startSequence(Re.BitString),e.writeByte(0),e.startSequence(),e.writeBuffer(n,Re.Integer),e.writeBuffer(t,Re.Integer),e.endSequence(),e.endSequence(),e.endSequence(),yn("PUBLIC",e.buffer)}function mi(n,t){let e=Buffer.allocUnsafe(15+t.length+4+n.length);Ot(e,7,0),e.utf8Write("ssh-rsa",4,7);let r=11;return Ot(e,t.length,r),e.set(t,r+=4),Ot(e,n.length,r+=t.length),e.set(n,r+4),e}var ol=(()=>{function n(r,s,i,o,a,c,l,f){let u=new Re.Writer;return u.startSequence(),u.writeInt(0,Re.Integer),u.writeBuffer(r,Re.Integer),u.writeBuffer(s,Re.Integer),u.writeBuffer(i,Re.Integer),u.writeBuffer(o,Re.Integer),u.writeBuffer(a,Re.Integer),u.writeBuffer(c,Re.Integer),u.writeBuffer(l,Re.Integer),u.writeBuffer(f,Re.Integer),u.endSequence(),u.buffer}function t(r){return BigInt(`0x${r.hexSlice(0,r.length)}`)}function e(r){let s=r.toString(16);if((s.length&1)!==0)s=`0${s}`;else{let 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,a,c,l){let f=t(o),u=e(f%(t(c)-1n)),h=e(f%(t(l)-1n));return yn("RSA PRIVATE",n(s,i,o,c,l,u,h,a))}})();function Ai(n,t,e,r){let s=new Re.Writer;return s.startSequence(),s.startSequence(),s.writeOID("1.2.840.10040.4.1"),s.startSequence(),s.writeBuffer(n,Re.Integer),s.writeBuffer(t,Re.Integer),s.writeBuffer(e,Re.Integer),s.endSequence(),s.endSequence(),s.startSequence(Re.BitString),s.writeByte(0),s.writeBuffer(r,Re.Integer),s.endSequence(),s.endSequence(),yn("PUBLIC",s.buffer)}function yi(n,t,e,r){let s=Buffer.allocUnsafe(15+n.length+4+t.length+4+e.length+4+r.length);Ot(s,7,0),s.utf8Write("ssh-dss",4,7);let i=11;return Ot(s,n.length,i),s.set(n,i+=4),Ot(s,t.length,i+=n.length),s.set(t,i+=4),Ot(s,e.length,i+=t.length),s.set(e,i+=4),Ot(s,r.length,i+=e.length),s.set(r,i+4),s}function al(n,t,e,r,s){let i=new Re.Writer;return i.startSequence(),i.writeInt(0,Re.Integer),i.writeBuffer(n,Re.Integer),i.writeBuffer(t,Re.Integer),i.writeBuffer(e,Re.Integer),i.writeBuffer(r,Re.Integer),i.writeBuffer(s,Re.Integer),i.endSequence(),yn("DSA PRIVATE",i.buffer)}function cl(n){let t=new Re.Writer;return t.startSequence(),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Re.BitString),t.writeByte(0),t._ensure(n.length),t._buf.set(n,t._offset),t._offset+=n.length,t.endSequence(),t.endSequence(),yn("PUBLIC",t.buffer)}function ll(n){let t=Buffer.allocUnsafe(19+n.length);return Ot(t,11,0),t.utf8Write("ssh-ed25519",4,11),Ot(t,n.length,15),t.set(n,19),t}function Mp(n){let t=new Re.Writer;return t.startSequence(),t.writeInt(0,Re.Integer),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Re.OctetString),t.writeBuffer(n,Re.OctetString),t.endSequence(),t.endSequence(),yn("PRIVATE",t.buffer)}function Xo(n,t){let e=new Re.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.10045.2.1"),e.writeOID(n),e.endSequence(),e.startSequence(Re.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),yn("PUBLIC",e.buffer)}function Jo(n,t){let e;switch(n){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}let r=Buffer.allocUnsafe(39+t.length);return Ot(r,19,0),r.utf8Write(`ecdsa-sha2-${e}`,4,19),Ot(r,8,23),r.utf8Write(e,27,8),Ot(r,t.length,35),r.set(t,39),r}function Fp(n,t,e){let r=new Re.Writer;return r.startSequence(),r.writeInt(1,Re.Integer),r.writeBuffer(e,Re.OctetString),r.startSequence(160),r.writeOID(n),r.endSequence(),r.startSequence(161),r.startSequence(Re.BitString),r.writeByte(0),r._ensure(t.length),r._buf.set(t,r._offset),r._offset+=t.length,r.endSequence(),r.endSequence(),r.endSequence(),yn("EC PRIVATE",r.buffer)}function Hp(n,t){let e=Rp(n);return e.setPrivateKey(t),e.getPublicKey()}var _i={sign:typeof il=="function"?function(t,e){let r=this[An];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[$n]);try{return il(e,t,r)}catch(s){return s}}:function(t,e){let r=this[An];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[$n]);let s=Pp(e);s.update(t);try{return s.sign(r)}catch(i){return i}},verify:typeof sl=="function"?function(t,e,r){let s=this[wn];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[$n]);try{return sl(r,t,s,e)}catch(i){return i}}:function(t,e,r){let s=this[wn];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[$n]);let i=Tp(r);i.update(t);try{return i.verify(s,e)}catch(o){return o}},isPrivateKey:function(){return this[An]!==null},getPrivatePEM:function(){return this[An]},getPublicPEM:function(){return this[wn]},getPublicSSH:function(){return this[Vn]},equals:function(t){let e=dl(t);return e instanceof Error?!1:this.type===e.type&&this[An]===e[An]&&this[wn]===e[wn]&&this[Vn].equals(e[Vn])}};function ls(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[An]=e,this[wn]=r,this[Vn]=s,this[$n]=i,this[Nr]=o}ls.prototype=_i;{let t=function(e,r,s){let i=[];if(e.length<8)return new Error("Malformed OpenSSH private key");let o=ui(e,0),a=ui(e,4);if(o!==a)return s?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");e._pos=8;let c,l;for(c=0;c<r;++c){let u,h,p,y,_=ve(e,e._pos,!0);if(_===void 0)return new Error("Malformed OpenSSH private key");switch(_){case"ssh-rsa":{let S=ve(e,e._pos);if(S===void 0)return new Error("Malformed OpenSSH private key");let R=ve(e,e._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");let H=ve(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let C=ve(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let U=ve(e,e._pos);if(U===void 0)return new Error("Malformed OpenSSH private key");let Q=ve(e,e._pos);if(Q===void 0)return new Error("Malformed OpenSSH private key");p=gi(S,R),y=mi(S,R),h=ol(S,R,H,C,U,Q),u="sha1";break}case"ssh-dss":{let S=ve(e,e._pos);if(S===void 0)return new Error("Malformed OpenSSH private key");let R=ve(e,e._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");let H=ve(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let C=ve(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let U=ve(e,e._pos);if(U===void 0)return new Error("Malformed OpenSSH private key");p=Ai(S,R,H,C),y=yi(S,R,H,C),h=al(S,R,H,C,U),u="sha1";break}case"ssh-ed25519":{if(!Yo)return new Error(`Unsupported OpenSSH private key type: ${_}`);let S=ve(e,e._pos);if(S===void 0||S.length!==32)return new Error("Malformed OpenSSH private key");let R=ve(e,e._pos);if(R===void 0||R.length!==64)return new Error("Malformed OpenSSH private key");p=cl(S),y=ll(S),h=Mp(fr(R,0,32)),u=null;break}case"ecdsa-sha2-nistp256":u="sha256",l="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":u===void 0&&(u="sha384",l="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(u===void 0&&(u="sha512",l="1.3.132.0.35"),!jo(e,1))return new Error("Malformed OpenSSH private key");let S=ve(e,e._pos);if(S===void 0)return new Error("Malformed OpenSSH private key");let R=ve(e,e._pos);if(R===void 0)return new Error("Malformed OpenSSH private key");p=Xo(l,S),y=Jo(l,S),h=Fp(l,S,R);break}default:return new Error(`Unsupported OpenSSH private key type: ${_}`)}let x=ve(e,e._pos,!0);if(x===void 0)return new Error("Malformed OpenSSH private key");i.push(new ls(_,x,h,p,y,u,s))}let f=0;for(c=e._pos;c<e.length;++c)if(e[c]!==++f%255)return new Error("Malformed OpenSSH private key");return i},n=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;ls.parse=(e,r)=>{let s=n.exec(e);if(s===null)return null;let i,o=Buffer.from(s[1],"base64");if(o.length<31)return new Error("Malformed OpenSSH private key");let a=o.utf8Slice(0,15);if(a!=="openssh-key-v1\0")return new Error(`Unsupported OpenSSH key magic: ${a}`);let c=ve(o,15,!0);if(c===void 0)return new Error("Malformed OpenSSH private key");if(c!=="none"&&Up.indexOf(c)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${c}`);let l=ve(o,o._pos,!0);if(l===void 0)return new Error("Malformed OpenSSH private key");if(l!=="none"){if(c==="none")return new Error("Malformed OpenSSH private key");if(l!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${l}`);if(!r)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(c!=="none")return new Error("Malformed OpenSSH private key");let f,u,h;c!=="none"&&(f=hi[c]);let p=ve(o,o._pos);if(p===void 0)return new Error("Malformed OpenSSH private key");if(p.length)switch(l){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{let _=ve(p,0);if(_===void 0||p._pos+4>p.length)return new Error("Malformed OpenSSH private key");let x=ui(p,p._pos),S=Buffer.allocUnsafe(f.keyLen+f.ivLen);if(Dp(r,r.length,_,_.length,S,S.length,x)!==0)return new Error("Failed to generate information to decrypt key");u=fr(S,0,f.keyLen),h=fr(S,f.keyLen,S.length);break}}else if(l!=="none")return new Error("Malformed OpenSSH private key");if(o._pos+3>=o.length)return new Error("Malformed OpenSSH private key");let y=ui(o,o._pos);if(o._pos+=4,y>0){for(let x=0;x<y;++x){let S=ve(o,o._pos);if(S===void 0)return new Error("Malformed OpenSSH private key");if(ve(S,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let _=ve(o,o._pos);if(_===void 0)return new Error("Malformed OpenSSH private key");if(u!==void 0){if(_.length<f.blockLen||_.length%f.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let x={authTagLength:f.authLen},S=zo(f.sslName,u,h,x);if(S.setAutoPadding(!1),f.authLen>0){if(o.length-o._pos<f.authLen)return new Error("Malformed OpenSSH private key");S.setAuthTag(fr(o,o._pos,o._pos+=f.authLen))}_=pi(S.update(_),S.final())}catch(x){return x}}if(o._pos!==o.length)return new Error("Malformed OpenSSH private key");i=t(_,y,u!==void 0)}else i=[];return i instanceof Error?i:i[0]}}function fs(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[An]=e,this[wn]=r,this[Vn]=s,this[$n]=i,this[Nr]=o}fs.prototype=_i;{let n=/^-----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-----$/;fs.parse=(t,e)=>{let r=n.exec(t);if(r===null)return null;let s=Buffer.from(r[3],"base64"),i=r[2],o=!1;if(i!==void 0){i=i.split(/\r\n|\n/g);for(let y=0;y<i.length;++y){let _=i[y],x=_.indexOf(":");if(_.slice(0,x)==="DEK-Info"){let S=_.slice(x+2);if(x=S.indexOf(","),x===-1)continue;let R=S.slice(0,x).toLowerCase();if($p.indexOf(R)===-1)return new Error(`Cipher (${R}) not supported for encrypted OpenSSH private key`);let H=Go[R];if(!H)return new Error(`Cipher (${R}) not supported for encrypted OpenSSH private key`);let C=Buffer.from(S.slice(x+1),"hex");if(C.length!==H.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!e)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");let U=fr(C,0,8),Q=di("md5").update(e).update(U).digest();for(;Q.length<H.keyLen;)Q=pi(Q,di("md5").update(Q).update(e).update(U).digest());Q.length>H.keyLen&&(Q=fr(Q,0,H.keyLen));try{let B=zo(R,Q,C);B.setAutoPadding(!1),s=pi(B.update(s),B.final()),o=!0}catch(B){return B}}}}let a,c,l,f,u,h,p="Malformed OpenSSH private key";switch(o&&(p+=". Bad passphrase?"),r[1]){case"RSA":a="ssh-rsa",c=yn("RSA PRIVATE",s);try{h=new Re.Reader(s),h.readSequence(),h.readInt();let y=h.readString(Re.Integer,!0);if(y===null)return new Error(p);let _=h.readString(Re.Integer,!0);if(_===null)return new Error(p);l=gi(y,_),f=mi(y,_)}catch{return new Error(p)}u="sha1";break;case"DSA":a="ssh-dss",c=yn("DSA PRIVATE",s);try{h=new Re.Reader(s),h.readSequence(),h.readInt();let y=h.readString(Re.Integer,!0);if(y===null)return new Error(p);let _=h.readString(Re.Integer,!0);if(_===null)return new Error(p);let x=h.readString(Re.Integer,!0);if(x===null)return new Error(p);let S=h.readString(Re.Integer,!0);if(S===null)return new Error(p);l=Ai(y,_,x,S),f=yi(y,_,x,S)}catch{return new Error(p)}u="sha1";break;case"EC":{let y,_,x;try{h=new Re.Reader(s),h.readSequence(),h.readInt(),_=h.readString(Re.OctetString,!0),h.readByte();let R=h.readLength();if(R!==null){if(h._offset=R,x=h.readOID(),x===null)return new Error(p);switch(x){case"1.2.840.10045.3.1.7":y="prime256v1",a="ecdsa-sha2-nistp256",u="sha256";break;case"1.3.132.0.34":y="secp384r1",a="ecdsa-sha2-nistp384",u="sha384";break;case"1.3.132.0.35":y="secp521r1",a="ecdsa-sha2-nistp521",u="sha512";break;default:return new Error(`Unsupported private key EC OID: ${x}`)}}else return new Error(p)}catch{return new Error(p)}c=yn("EC PRIVATE",s);let S=Hp(y,_);l=Xo(x,S),f=Jo(x,S);break}}return new fs(a,"",c,l,f,u,o)}}function us(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[An]=e,this[wn]=r,this[Vn]=s,this[$n]=i,this[Nr]=o}us.prototype=_i;{let n=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]),r=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]+)/;us.parse=(i,o)=>{let a=s.exec(i);if(a===null)return null;let c=a[2],l=c!=="none";if(l&&!o)return new Error("Encrypted PPK private key detected, but no passphrase given");let f=Buffer.from(a[5],"base64");if(l){let k=hi[c],v=pi(di("sha1").update(e).update(o).digest(),di("sha1").update(r).update(o).digest());v.length>k.keyLen&&(v=fr(v,0,k.keyLen));try{let P=zo(k.sslName,v,t);P.setAutoPadding(!1),f=pi(P.update(f),P.final())}catch(P){return P}}let u=a[1],h=a[3],p=Buffer.from(a[4],"base64"),y=a[6],_=u.length,x=c.length,S=Buffer.byteLength(h),R=p.length,H=f.length,C=Buffer.allocUnsafe(4+_+4+x+4+S+4+R+4+H),U=0;if(Ot(C,_,U),C.utf8Write(u,U+=4,_),Ot(C,x,U+=_),C.utf8Write(c,U+=4,x),Ot(C,S,U+=x),C.utf8Write(h,U+=4,S),Ot(C,R,U+=S),C.set(p,U+=4),Ot(C,H,U+=R),C.set(f,U+4),o||(o=n),Np("sha1",di("sha1").update("putty-private-key-file-mac-key").update(o).digest()).update(C).digest("hex")!==y)return l?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let B,b,w;switch(p._pos=0,jo(p,1),u){case"ssh-rsa":{let k=ve(p,p._pos);if(k===void 0)return new Error("Malformed PPK public key");let v=ve(p,p._pos);if(v===void 0)return new Error("Malformed PPK public key");let P=ve(f,0);if(P===void 0)return new Error("Malformed PPK private key");let ne=ve(f,f._pos);if(ne===void 0)return new Error("Malformed PPK private key");let z=ve(f,f._pos);if(z===void 0)return new Error("Malformed PPK private key");let Y=ve(f,f._pos);if(Y===void 0)return new Error("Malformed PPK private key");B=gi(v,k),b=mi(v,k),w=ol(v,k,P,Y,ne,z);break}case"ssh-dss":{let k=ve(p,p._pos);if(k===void 0)return new Error("Malformed PPK public key");let v=ve(p,p._pos);if(v===void 0)return new Error("Malformed PPK public key");let P=ve(p,p._pos);if(P===void 0)return new Error("Malformed PPK public key");let ne=ve(p,p._pos);if(ne===void 0)return new Error("Malformed PPK public key");let z=ve(f,0);if(z===void 0)return new Error("Malformed PPK private key");B=Ai(k,v,P,ne),b=yi(k,v,P,ne),w=al(k,v,P,ne,z);break}}return new us(u,h,w,B,b,"sha1",l)}}function hs(n,t,e,r,s){this.type=n,this.comment=t,this[An]=null,this[wn]=e,this[Vn]=r,this[$n]=s,this[Nr]=!1}hs.prototype=_i;{let n;Yo?n=/^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/:n=/^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/,hs.parse=t=>{let e=n.exec(t);if(e===null)return null;let r=e[1],s=e[2],i=Buffer.from(e[3],"base64"),o=e[4]||"",a=ve(i,i._pos,!0);return a===void 0||a.indexOf(s)!==0?new Error("Malformed OpenSSH public key"):Zo(i,s,o,r)}}function ds(n,t,e,r,s){this.type=n,this.comment=t,this[An]=null,this[wn]=e,this[Vn]=r,this[$n]=s,this[Nr]=!1}ds.prototype=_i;{let n=/^---- 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,r=/\\\r?\n/g;ds.parse=s=>{let i=n.exec(s);if(i===null)return null;let o=i[1],a=0,c="";for(;i=e.exec(o);){let p=i[1],y=i[2].replace(r,"");if(y.length>1024)return e.lastIndex=0,new Error("Malformed RFC4716 public key");a=e.lastIndex,p.toLowerCase()==="comment"&&(c=y,c.length>1&&c.charCodeAt(0)===34&&c.charCodeAt(c.length-1)===34&&(c=c.slice(1,-1)))}let l=o.slice(a);if(!t.test(l))return new Error("Malformed RFC4716 public key");l=Buffer.from(l,"base64");let f=ve(l,0,!0);if(f===void 0)return new Error("Malformed RFC4716 public key");let u=null,h=null;switch(f){case"ssh-rsa":{let p=ve(l,l._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let y=ve(l,l._pos);if(y===void 0)return new Error("Malformed RFC4716 public key");u=gi(y,p),h=mi(y,p);break}case"ssh-dss":{let p=ve(l,l._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let y=ve(l,l._pos);if(y===void 0)return new Error("Malformed RFC4716 public key");let _=ve(l,l._pos);if(_===void 0)return new Error("Malformed RFC4716 public key");let x=ve(l,l._pos);if(x===void 0)return new Error("Malformed RFC4716 public key");u=Ai(p,y,_,x),h=yi(p,y,_,x);break}default:return new Error("Malformed RFC4716 public key")}return new ds(f,c,u,h,"sha1")}}function Zo(n,t,e,r){if(!fl(t))return new Error(`Unsupported OpenSSH public key type: ${t}`);let s,i,o=null,a=null;switch(t){case"ssh-rsa":{let c=ve(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let l=ve(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");o=gi(l,c),a=mi(l,c),s="sha1";break}case"ssh-dss":{let c=ve(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let l=ve(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");let f=ve(n,n._pos);if(f===void 0)return new Error("Malformed OpenSSH public key");let u=ve(n,n._pos);if(u===void 0)return new Error("Malformed OpenSSH public key");o=Ai(c,l,f,u),a=yi(c,l,f,u),s="sha1";break}case"ssh-ed25519":{let c=ve(n,n._pos||0);if(c===void 0||c.length!==32)return new Error("Malformed OpenSSH public key");o=cl(c),a=ll(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"),!jo(n,1))return new Error("Malformed OpenSSH public key");let c=ve(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");o=Xo(i,c),a=Jo(i,c);break}default:return new Error(`Unsupported OpenSSH public key type: ${t}`)}return new hs(r,e,o,a,s)}function fl(n){switch(n){case"ssh-rsa":case"ssh-dss":case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":return!0;case"ssh-ed25519":if(Yo)return!0;default:return!1}}function ul(n){return n?typeof n[Nr]=="boolean":!1}function dl(n,t){if(ul(n))return n;let e;if(Buffer.isBuffer(n))e=n,n=n.utf8Slice(0,n.length).trim();else if(typeof n=="string")n=n.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 r;if((r=ls.parse(n,t))!==null||(r=fs.parse(n,t))!==null||(r=us.parse(n,t))!==null||(r=hs.parse(n))!==null||(r=ds.parse(n))!==null)return r;if(e){cs.init(e,0);let s=cs.readString(!0);s!==void 0&&(n=cs.readRaw(),n!==void 0&&(r=Zo(n,s,"",s),r instanceof Error&&(r=null))),cs.clear()}return r||new Error("Unsupported key format")}hl.exports={isParsedKey:ul,isSupportedKeyType:fl,parseDERKey:(n,t)=>Zo(n,t,"",t),parseKey:dl}});var sa=ct((Yy,Sl)=>{"use strict";var{Socket:Al}=require("net"),{Duplex:yl}=require("stream"),{resolve:Qp}=require("path"),{readFile:pl}=require("fs"),{execFile:Wp,spawn:qp}=require("child_process"),{isParsedKey:gl,parseKey:Ei}=Gn(),{makeBufferParser:Kp,readUInt32BE:ia,writeUInt32BE:Zt,writeUInt32LE:ml}=mn();function bi(n){let t=!1;return(...e)=>{t||(t=!0,n(...e))}}function Vp(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return n.copy(e,0),t.copy(e,n.length),e}function ta(){}var Gp=Buffer.alloc(0),xt=Kp(),xi=class{getIdentities(t){t(new Error("Missing getIdentities() implementation"))}sign(t,e,r,s){typeof r=="function"&&(s=r),s(new Error("Missing sign() implementation"))}},Tr=class extends xi{constructor(t){super(),this.socketPath=t}getStream(t){t=bi(t);let e=new Al;e.on("connect",()=>{t(null,e)}),e.on("close",r).on("end",r).on("error",r),e.connect(this.socketPath);function r(){try{e.destroy()}catch{}t(new Error("Failed to connect to agent"))}}getIdentities(t){t=bi(t),this.getStream((e,r)=>{function s(o){if(r)try{r.destroy()}catch{}o||(o=new Error("Failed to retrieve identities from agent")),t(o)}if(e)return s(e);let i=new na(!0);i.on("error",s),i.pipe(r).pipe(i),r.on("close",s).on("end",s).on("error",s),i.getIdentities((o,a)=>{if(o)return s(o);try{r.destroy()}catch{}t(null,a)})})}sign(t,e,r,s){typeof r=="function"?(s=r,r=void 0):(typeof r!="object"||r===null)&&(r=void 0),s=bi(s),this.getStream((i,o)=>{function a(l){if(o)try{o.destroy()}catch{}l||(l=new Error("Failed to sign data with agent")),s(l)}if(i)return a(i);let c=new na(!0);c.on("error",a),c.pipe(o).pipe(c),o.on("close",a).on("end",a).on("error",a),c.sign(t,e,r,(l,f)=>{if(l)return a(l);try{o.destroy()}catch{}s(null,f)})})}},_l=(()=>{let o=Qp(__dirname,"..","util/pagent.exe"),a={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(f){f.buffer=null,f.proc&&(f.proc.kill(),f.proc=void 0)}class l extends yl{constructor(){super(),this.proc=void 0,this.buffer=null}_read(u){}_write(u,h,p){if(this.buffer===null)this.buffer=u;else{let S=Buffer.allocUnsafe(this.buffer.length+u.length);this.buffer.copy(S,0),u.copy(S,this.buffer.length),this.buffer=S}if(this.buffer.length<4)return p();let y=ia(this.buffer,0);if(this.buffer.length-4<y)return p();if(u=this.buffer.slice(0,4+y),this.buffer.length>4+y)return p(new Error("Unexpected multiple agent requests"));this.buffer=null;let _,x=this.proc=qp(o,[u.length]);x.stdout.on("data",S=>{this.push(S)}),x.on("error",S=>{_=S,p(_)}),x.on("close",S=>{if(this.proc=void 0,!_){if(_=a[S])return p(_);p()}}),x.stdin.end(u)}_final(u){c(this),u()}_destroy(u,h){c(this),h()}}return class extends Tr{getStream(u){u(null,new l)}}})(),El=(()=>{let n=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Tr{getStream(e){e=bi(e);let r=this.socketPath,s=!1;pl(r,function i(o,a){if(o){if(s)return e(new Error("Invalid cygwin unix socket path"));Wp("cygpath",["-w",r],(Q,B,b)=>{if(Q||B.length===0)return e(new Error("Invalid cygwin unix socket path"));s=!0,r=B.toString().replace(/[\r\n]/g,""),pl(r,i)});return}let c=n.exec(a.toString("ascii"));if(!c)return e(new Error("Malformed cygwin unix socket file"));let l,f=0,u=!1,h=[],p,y=Buffer.alloc(12),_=parseInt(c[1],10),x=c[2].replace(/-/g,""),S=Buffer.allocUnsafe(16);for(let Q=0,B=0;B<32;++Q,B+=2)S[Q]=parseInt(x.substring(B,B+2),16);for(let Q=0;Q<16;Q+=4)ml(S,ia(S,Q),Q);U();function R(){f=0,l="secret",p.write(S)}function H(Q){if(f+=Q.length,l==="secret"){f===16&&(f=0,l="creds",p.write(y));return}if(l==="creds"&&(u||h.push(Q),f===12)){if(p.removeListener("connect",R),p.removeListener("data",H),p.removeListener("error",C),p.removeListener("end",C),p.removeListener("close",C),u)return e(null,p);u=!0,y=Buffer.concat(h),ml(y,process.pid,0),p.on("error",()=>{}),p.destroy(),U()}}function C(){e(new Error("Problem negotiating cygwin unix socket security"))}function U(){p=new Al,p.on("connect",R),p.on("data",H),p.on("error",C),p.on("end",C),p.on("close",C),p.connect(_)}})}}})(),zp=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function bl(n){return process.platform==="win32"&&!zp.test(n)?n==="pageant"?new _l:new El(n):new Tr(n)}var na=(()=>{function l(b){let w;for(;b[R].length;){let k=b[R][0][u];if(k===void 0)break;b[R].shift(),w=b.push(k)}return w}let f=Symbol("Inbound Request Type"),u=Symbol("Inbound Request Response"),h=Symbol("Inbound Request Context");class p{constructor(w,k){this[f]=w,this[u]=void 0,this[h]=k}hasResponded(){return this[u]!==void 0}getType(){return this[f]}getContext(){return this[h]}}function y(b,w,k){return w[u]=k,l(b)}function _(b){if(b[C]=null,b[H]===0){let w=b[R];if(w&&w.length){b[R]=[];for(let k of w)k.cb(new Error("No reply from server"))}}try{b.end()}catch{}setImmediate(()=>{b[B]||b.emit("end"),b[Q]||b.emit("close")})}function x(){this[Q]=!0}function S(){this[B]=!0}let R=Symbol("Requests"),H=Symbol("Agent Protocol Role"),C=Symbol("Agent Protocol Buffer"),U=Symbol("Agent Protocol Current Message Length"),Q=Symbol("Agent Protocol Closed"),B=Symbol("Agent Protocol Ended");return class extends yl{constructor(w){super({autoDestroy:!0,emitClose:!1}),this[H]=w?0:1,this[R]=[],this[C]=null,this[U]=-1,this.once("end",S),this.once("close",x)}_read(w){}_write(w,k,v){this[C]===null?this[C]=w:this[C]=Vp(this[C],w);let P=this[C],ne=P.length,z=0;for(;z<ne&&!(ne<5||(this[U]===-1&&(this[U]=ia(P,z)),ne<4+this[U]));){let Y=P[z+=4];if(++z,this[H]===0){if(this[R].length===0)return v(new Error("Received unexpected message from server"));let te=this[R].shift();switch(Y){case 5:te.cb(new Error("Agent responded with failure"));break;case 12:{if(te.type!==11)return v(new Error("Agent responded with wrong message type"));xt.init(P,z);let le=xt.readUInt32BE();if(le===void 0)return xt.clear(),v(new Error("Malformed agent response"));let O=[];for(let N=0;N<le;++N){let L=xt.readString();if(L===void 0)return xt.clear(),v(new Error("Malformed agent response"));let K=xt.readString(!0);if(K===void 0)return xt.clear(),v(new Error("Malformed agent response"));L=Ei(L),!(L instanceof Error)&&(L.comment=L.comment||K,O.push(L))}z=xt.pos(),xt.clear(),te.cb(null,O);break}case 14:{if(te.type!==13)return v(new Error("Agent responded with wrong message type"));xt.init(P,z);let le=xt.readString();if(z=xt.pos(),xt.clear(),le===void 0)return v(new Error("Malformed agent response"));if(xt.init(le,0),xt.readString(!0),le=xt.readString(),xt.clear(),le===void 0)return v(new Error("Malformed OpenSSH signature format"));te.cb(null,le);break}default:return v(new Error("Agent responded with unsupported message type"))}}else switch(Y){case 11:{let te=new p(Y);this[R].push(te),this.emit("identities",te);break}case 13:{xt.init(P,z);let te=xt.readString(),le=xt.readString(),O=xt.readUInt32BE();if(z=xt.pos(),xt.clear(),O===void 0){let ee=new p(Y);return this[R].push(ee),this.failureReply(ee)}if(te=Ei(te),te instanceof Error){let ee=new p(Y);return this[R].push(ee),this.failureReply(ee)}let N={hash:void 0},L;te.type==="ssh-rsa"&&(O&2?(L="rsa-sha2-256",N.hash="sha256"):O&4&&(L="rsa-sha2-512",N.hash="sha512")),L===void 0&&(L=te.type);let K=new p(Y,L);this[R].push(K),this.emit("sign",K,te,le,N);break}default:{let te=new p(Y);this[R].push(te),this.failureReply(te)}}if(this[U]=-1,z===ne){this[C]=null;break}else this[C]=P=P.slice(z),ne=P.length,z=0}v()}_destroy(w,k){_(this),k()}_final(w){_(this),w()}sign(w,k,v,P){if(this[H]!==0)throw new Error("Client-only method called with server role");typeof v=="function"?(P=v,v=void 0):(typeof v!="object"||v===null)&&(v=void 0);let ne=0;if(w=Ei(w),w instanceof Error)throw new Error("Invalid public key argument");if(w.type==="ssh-rsa"&&v)switch(v.hash){case"sha256":ne=2;break;case"sha512":ne=4;break}w=w.getPublicSSH();let z=13,Y=w.length,te=k.length,le=0,O=Buffer.allocUnsafe(9+Y+4+te+4);return Zt(O,O.length-4,le),O[le+=4]=z,Zt(O,Y,++le),w.copy(O,le+=4),Zt(O,te,le+=Y),k.copy(O,le+=4),Zt(O,ne,le+=te),typeof P!="function"&&(P=ta),this[R].push({type:z,cb:P}),this.push(O)}getIdentities(w){if(this[H]!==0)throw new Error("Client-only method called with server role");let k=11,v=0,P=Buffer.allocUnsafe(5);return Zt(P,P.length-4,v),P[v+=4]=k,typeof w!="function"&&(w=ta),this[R].push({type:k,cb:w}),this.push(P)}failureReply(w){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;let k=0,v=Buffer.allocUnsafe(5);return Zt(v,v.length-4,k),v[k+=4]=5,y(this,w,v)}getIdentitiesReply(w,k){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;if(w.getType()!==11)throw new Error("Invalid response to request");if(!Array.isArray(k))throw new Error("Keys argument must be an array");let v=4,P=[];for(let Y=0;Y<k.length;++Y){let te=k[Y];if(typeof te!="object"||te===null)throw new Error(`Invalid key entry: ${te}`);let le,O;if(gl(te))le=te;else if(gl(te.pubKey))le=te.pubKey;else if(typeof te.pubKey!="object"||te.pubKey===null||({pubKey:le,comment:O}=te.pubKey,le=Ei(le),le instanceof Error))continue;O=le.comment||O,le=le.getPublicSSH(),v+=4+le.length,O&&typeof O=="string"?O=Buffer.from(O):Buffer.isBuffer(O)||(O=Gp),v+=4+O.length,P.push({pubKey:le,comment:O})}let ne=0,z=Buffer.allocUnsafe(5+v);Zt(z,z.length-4,ne),z[ne+=4]=12,Zt(z,P.length,++ne),ne+=4;for(let Y=0;Y<P.length;++Y){let{pubKey:te,comment:le}=P[Y];Zt(z,te.length,ne),te.copy(z,ne+=4),Zt(z,le.length,ne+=te.length),ne+=4,le.length&&(le.copy(z,ne),ne+=le.length)}return y(this,w,z)}signReply(w,k){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;if(w.getType()!==13)throw new Error("Invalid response to request");if(!Buffer.isBuffer(k))throw new Error("Signature argument must be a Buffer");if(k.length===0)throw new Error("Signature argument must be non-empty");let v=0,P=w.getContext(),ne=Buffer.byteLength(P),z=Buffer.allocUnsafe(13+ne+4+k.length);return Zt(z,z.length-4,v),z[v+=4]=14,Zt(z,4+ne+4+k.length,++v),Zt(z,ne,v+=4),z.utf8Write(P,v+=4,ne),Zt(z,k.length,v+=ne),k.copy(z,v+=4),y(this,w,z)}}})(),ea=Symbol("Agent"),_n=Symbol("Agent Keys"),Dn=Symbol("Agent Keys Index"),Pr=Symbol("Agent Init Callbacks"),ra=class{constructor(t){if(typeof t=="string")t=bl(t);else if(!xl(t))throw new Error("Invalid agent argument");this[ea]=t,this[_n]=null,this[Dn]=-1,this[Pr]=null}init(t){if(typeof t!="function"&&(t=ta),this[_n]===null)if(this[Pr]===null){this[Pr]=[t];let e=(...r)=>{process.nextTick(()=>{let s=this[Pr];this[Pr]=null;for(let i of s)i(...r)})};this[ea].getIdentities(bi((r,s)=>{if(r)return e(r);if(!Array.isArray(s))return e(new Error("Agent implementation failed to provide keys"));let i=[];for(let o of s)o=Ei(o),!(o instanceof Error)&&i.push(o);this[_n]=i,this[Dn]=-1,e()}))}else this[Pr].push(t);else process.nextTick(t)}nextKey(){return this[_n]===null||++this[Dn]>=this[_n].length?!1:this[_n][this[Dn]]}currentKey(){return this[_n]===null||this[Dn]>=this[_n].length?null:this[_n][this[Dn]]}pos(){return this[_n]===null||this[Dn]>=this[_n].length?-1:this[Dn]}reset(){this[Dn]=-1}sign(...t){this[ea].sign(...t)}};function xl(n){return n instanceof xi}Sl.exports={AgentContext:ra,AgentProtocol:na,BaseAgent:xi,createAgent:bl,CygwinAgent:El,isAgent:xl,OpenSSHAgent:Tr,PageantAgent:_l}});var ua=ct((jy,wl)=>{"use strict";var{kMaxLength:Yp}=require("buffer"),{createInflate:jp,constants:{DEFLATE:Xp,INFLATE:Jp,Z_DEFAULT_CHUNK:Zp,Z_DEFAULT_COMPRESSION:eg,Z_DEFAULT_MEMLEVEL:tg,Z_DEFAULT_STRATEGY:ng,Z_DEFAULT_WINDOWBITS:rg,Z_PARTIAL_FLUSH:ig}}=require("zlib"),sg=jp()._handle.constructor;function og(){throw new Error("Should not get here")}function ag(n,t,e){let r=this._owner,s=new Error(n);s.errno=t,s.code=e,r._err=s}function fa(n){n._handle&&(n._handle.close(),n._handle=null)}var ps=class{constructor(t){let e=rg,r=eg,s=tg,i=ng,o=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=Zp,this._maxOutputLength=Yp,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new sg(t),this._handle._owner=this,this._handle.onerror=ag,this._handle.init(e,r,s,i,this._writeState,og,o)}writeSync(t,e){let r=this._handle;if(!r)throw new Error("Invalid Zlib instance");let s=t.length,i=this._chunkSize-this._outOffset,o=0,a,c,l,f=0,u=this._writeState,h=this._outBuffer,p=this._outOffset,y=this._chunkSize;for(;;){if(r.writeSync(ig,t,o,s,h,p,i),this._err)throw this._err;a=u[0],c=u[1];let x=s-c,S=i-a;if(S>0){let R=p===0&&S===h.length?h:h.slice(p,p+S);if(p+=S,l?l.push===void 0?l=[l,R]:l.push(R):l=R,f+=R.byteLength,f>this._maxOutputLength)throw fa(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(S!==0)throw new Error("have should not go down");if((a===0||p>=y)&&(i=y,p=0,h=Buffer.allocUnsafe(y)),a===0)o+=x,s=c;else break}if(this._outBuffer=h,this._outOffset=p,f===0&&(l=Buffer.alloc(0)),e)return l.totalLen=f,l;if(l.push===void 0)return l;let _=Buffer.allocUnsafe(f);for(let x=0,S=0;x<l.length;++x){let R=l[x];_.set(R,S),S+=R.length}return _}},oa=class{constructor(t){this.allocStart=0,this.allocStartKEX=0,this._protocol=t,this._zlib=new ps(Xp)}cleanup(){this._zlib&&fa(this._zlib)}alloc(t,e){return Buffer.allocUnsafe(t)}finalize(t,e){if(this._protocol._kexinit===void 0||e){let r=this._zlib.writeSync(t,!0),s=this._protocol._cipher.allocPacket(r.totalLen);if(r.push===void 0)s.set(r,5);else for(let i=0,o=5;i<r.length;++i){let a=r[i];s.set(a,o),o+=a.length}return s}return t}},aa=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}},ca=class{constructor(){this._zlib=new ps(Jp)}cleanup(){this._zlib&&fa(this._zlib)}read(t){return this._zlib.writeSync(t,!1)}},la=class{cleanup(){}read(t){return t}};wl.exports={PacketReader:la,PacketWriter:aa,ZlibPacketReader:ca,ZlibPacketWriter:oa}});var Bl=ct((Xy,vl)=>{"use strict";var{bufferSlice:da,bufferParser:D,doFatalError:gt,sigSSHToASN1:Il,writeUInt32BE:Cl}=mn(),{CHANNEL_OPEN_FAILURE:cg,COMPAT:lg,MESSAGE:At,TERMINAL_MODE:kl}=Ln(),{parseKey:fg}=Gn(),ug=Array.from(Object.entries(kl)).reduce((n,[t,e])=>({...n,[t]:e}),{});vl.exports={[At.DISCONNECT]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readString(!0),s=D.readString();if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed DISCONNECT packet");n._debug&&n._debug(`Inbound: Received DISCONNECT (${e}, "${r}")`);let i=n._handlers.DISCONNECT;i&&i(n,e,r)},[At.IGNORE]:(n,t)=>{n._debug&&n._debug("Inbound: Received IGNORE")},[At.UNIMPLEMENTED]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed UNIMPLEMENTED packet");n._debug&&n._debug(`Inbound: Received UNIMPLEMENTED (seqno ${e})`)},[At.DEBUG]:(n,t)=>{D.init(t,1);let e=D.readBool(),r=D.readString(!0),s=D.readString();if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed DEBUG packet");n._debug&&n._debug("Inbound: Received DEBUG");let i=n._handlers.DEBUG;i&&i(n,e,r)},[At.SERVICE_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readString(!0);if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed SERVICE_REQUEST packet");n._debug&&n._debug(`Inbound: Received SERVICE_REQUEST (${e})`);let r=n._handlers.SERVICE_REQUEST;r&&r(n,e)},[At.SERVICE_ACCEPT]:(n,t)=>{D.init(t,1);let e=D.readString(!0);if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed SERVICE_ACCEPT packet");n._debug&&n._debug(`Inbound: Received SERVICE_ACCEPT (${e})`);let r=n._handlers.SERVICE_ACCEPT;r&&r(n,e)},[At.EXT_INFO]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r;if(e!==void 0){r=[];for(let i=0;i<e;++i){let o=D.readString(!0),a=D.readString();if(a!==void 0)if(o==="server-sig-algs"){let c=a.latin1Slice(0,a.length).split(",");r.push({name:o,algs:c});continue}else continue;r=void 0;break}}if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed EXT_INFO packet");n._debug&&n._debug("Inbound: Received EXT_INFO");let s=n._handlers.EXT_INFO;s&&s(n,r)},[At.USERAUTH_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readString(!0),s=D.readString(!0),i,o;switch(s){case"none":i=null;break;case"password":{let c=D.readBool();if(c!==void 0&&(i=D.readString(!0),i!==void 0&&c)){let l=D.readString(!0);l!==void 0?i={oldPassword:i,newPassword:l}:i=void 0}break}case"publickey":{let c=D.readBool();if(c!==void 0){let l=D.readString(!0),f=l,u=D.readString(),h;switch(l){case"rsa-sha2-256":f="ssh-rsa",h="sha256";break;case"rsa-sha2-512":f="ssh-rsa",h="sha512";break}if(c){let p=D.pos(),y=D.readString();if(y!==void 0&&(y.length>4+l.length+4&&y.utf8Slice(4,4+l.length)===l&&(y=da(y,4+l.length+4)),y=Il(y,f),y)){let _=n._kex.sessionID,x=Buffer.allocUnsafe(4+_.length+p);Cl(x,_.length,0),x.set(_,4),x.set(new Uint8Array(t.buffer,t.byteOffset,p),4+_.length),i={keyAlgo:f,key:u,signature:y,blob:x,hashAlgo:h}}}else i={keyAlgo:f,key:u,hashAlgo:h},o="publickey -- check"}break}case"hostbased":{let c=D.readString(!0),l=c,f=D.readString(),u=D.readString(!0),h=D.readString(!0),p;switch(c){case"rsa-sha2-256":l="ssh-rsa",p="sha256";break;case"rsa-sha2-512":l="ssh-rsa",p="sha512";break}let y=D.pos(),_=D.readString();if(_!==void 0&&(_.length>4+c.length+4&&_.utf8Slice(4,4+c.length)===c&&(_=da(_,4+c.length+4)),_=Il(_,l),_!==void 0)){let x=n._kex.sessionID,S=Buffer.allocUnsafe(4+x.length+y);Cl(S,x.length,0),S.set(x,4),S.set(new Uint8Array(t.buffer,t.byteOffset,y),4+x.length),i={keyAlgo:l,key:f,signature:_,blob:S,localHostname:u,localUsername:h,hashAlgo:p}}break}case"keyboard-interactive":D.skipString(),i=D.readList();break;default:s!==void 0&&(i=D.readRaw())}if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed USERAUTH_REQUEST packet");o===void 0&&(o=s),n._authsQueue.push(s),n._debug&&n._debug(`Inbound: Received USERAUTH_REQUEST (${o})`);let a=n._handlers.USERAUTH_REQUEST;a&&a(n,e,r,s,i)},[At.USERAUTH_FAILURE]:(n,t)=>{D.init(t,1);let e=D.readList(),r=D.readBool();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_FAILURE packet");n._debug&&n._debug(`Inbound: Received USERAUTH_FAILURE (${e})`),n._authsQueue.shift();let s=n._handlers.USERAUTH_FAILURE;s&&s(n,e,r)},[At.USERAUTH_SUCCESS]:(n,t)=>{n._debug&&n._debug("Inbound: Received USERAUTH_SUCCESS"),n._authsQueue.shift();let e=n._handlers.USERAUTH_SUCCESS;e&&e(n)},[At.USERAUTH_BANNER]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_BANNER packet");n._debug&&n._debug("Inbound: Received USERAUTH_BANNER");let s=n._handlers.USERAUTH_BANNER;s&&s(n,e)},60:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 60 without auth");return}switch(n._authsQueue[0]){case"password":{D.init(t,1);let e=D.readString(!0),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");n._debug&&n._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");let s=n._handlers.USERAUTH_PASSWD_CHANGEREQ;s&&s(n,e);break}case"publickey":{D.init(t,1);let e=D.readString(!0),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_PK_OK packet");n._debug&&n._debug("Inbound: Received USERAUTH_PK_OK"),n._authsQueue.shift();let s=n._handlers.USERAUTH_PK_OK;s&&s(n,e,r);break}case"keyboard-interactive":{D.init(t,1);let e=D.readString(!0),r=D.readString(!0);D.readString();let s=D.readUInt32BE(),i;if(s!==void 0){i=new Array(s);let a;for(a=0;a<s;++a){let c=D.readString(!0),l=D.readBool();if(l===void 0)break;i[a]={prompt:c,echo:l}}a!==s&&(i=void 0)}if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed USERAUTH_INFO_REQUEST packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_REQUEST");let o=n._handlers.USERAUTH_INFO_REQUEST;o&&o(n,e,r,i);break}default:n._debug&&n._debug("Inbound: Received unexpected payload type 60")}},61:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 61 without auth");return}if(n._authsQueue[0]!=="keyboard-interactive")return gt(n,"Inbound: Received unexpected payload type 61");D.init(t,1);let e=D.readUInt32BE(),r;if(e!==void 0){r=new Array(e);let i;for(i=0;i<e;++i){let o=D.readString(!0);if(o===void 0)break;r[i]=o}i!==e&&(r=void 0)}if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_RESPONSE");let s=n._handlers.USERAUTH_INFO_RESPONSE;s&&s(n,r)},[At.GLOBAL_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readBool(),s;if(r!==void 0)switch(e){case"tcpip-forward":case"cancel-tcpip-forward":{let o=D.readString(!0),a=D.readUInt32BE();a!==void 0&&(s={bindAddr:o,bindPort:a});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let o=D.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=[];D.avail()>0;){let o=D.readString();if(o===void 0){s=void 0;break}let a=fg(o);a instanceof Error||s.push(a)}break}default:s=D.readRaw()}if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed GLOBAL_REQUEST packet");n._debug&&n._debug(`Inbound: GLOBAL_REQUEST (${e})`);let i=n._handlers.GLOBAL_REQUEST;i?i(n,e,r,s):n.requestFailure()},[At.REQUEST_SUCCESS]:(n,t)=>{let e=t.length>1?da(t,1):null;n._debug&&n._debug("Inbound: REQUEST_SUCCESS");let r=n._handlers.REQUEST_SUCCESS;r&&r(n,e)},[At.REQUEST_FAILURE]:(n,t)=>{n._debug&&n._debug("Inbound: Received REQUEST_FAILURE");let e=n._handlers.REQUEST_FAILURE;e&&e(n)},[At.CHANNEL_OPEN]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readUInt32BE(),s=D.readUInt32BE(),i=D.readUInt32BE(),o;switch(e){case"forwarded-tcpip":case"direct-tcpip":{let c=D.readString(!0),l=D.readUInt32BE(),f=D.readString(!0),u=D.readUInt32BE();u!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{destIP:c,destPort:l,srcIP:f,srcPort:u}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{let c=D.readString(!0);c!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{socketPath:c}});break}case"x11":{let c=D.readString(!0),l=D.readUInt32BE();l!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{srcIP:c,srcPort:l}});break}default:o={type:e,sender:r,window:s,packetSize:i,data:{}}}if(D.clear(),o===void 0)return gt(n,"Inbound: Malformed CHANNEL_OPEN packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN (s:${r}, ${e})`);let a=n._handlers.CHANNEL_OPEN;a?a(n,o):n.channelOpenFail(o.sender,cg.ADMINISTRATIVELY_PROHIBITED,"","")},[At.CHANNEL_OPEN_CONFIRMATION]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE(),s=D.readUInt32BE(),i=D.readUInt32BE(),o=D.avail()?D.readRaw():void 0;if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${e}, s:${r})`);let a=n._handlers.CHANNEL_OPEN_CONFIRMATION;a&&a(n,{recipient:e,sender:r,window:s,packetSize:i,data:o})},[At.CHANNEL_OPEN_FAILURE]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE(),s=D.readString(!0),i=D.readString();if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed CHANNEL_OPEN_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${e})`);let o=n._handlers.CHANNEL_OPEN_FAILURE;o&&o(n,e,r,s)},[At.CHANNEL_WINDOW_ADJUST]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");n._debug&&n._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${e}, ${r})`);let s=n._handlers.CHANNEL_WINDOW_ADJUST;s&&s(n,e,r)},[At.CHANNEL_DATA]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed CHANNEL_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_DATA (r:${e}, ${r.length})`);let s=n._handlers.CHANNEL_DATA;s&&s(n,e,r)},[At.CHANNEL_EXTENDED_DATA]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE(),s=D.readString();if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${e}, ${s.length})`);let i=n._handlers.CHANNEL_EXTENDED_DATA;i&&i(n,e,s,r)},[At.CHANNEL_EOF]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_EOF packet");n._debug&&n._debug(`Inbound: CHANNEL_EOF (r:${e})`);let r=n._handlers.CHANNEL_EOF;r&&r(n,e)},[At.CHANNEL_CLOSE]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_CLOSE packet");n._debug&&n._debug(`Inbound: CHANNEL_CLOSE (r:${e})`);let r=n._handlers.CHANNEL_CLOSE;r&&r(n,e)},[At.CHANNEL_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readString(!0),s=D.readBool(),i;if(s!==void 0)switch(r){case"exit-status":i=D.readUInt32BE(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"exit-signal":{let a,c;if(n._compatFlags&lg.OLD_EXIT){let f=D.readUInt32BE();switch(f){case 1:a="HUP";break;case 2:a="INT";break;case 3:a="QUIT";break;case 6:a="ABRT";break;case 9:a="KILL";break;case 14:a="ALRM";break;case 15:a="TERM";break;default:f!==void 0&&(a=`UNKNOWN (${f})`)}c=!1}else a=D.readString(!0),c=D.readBool(),c===void 0&&(a=void 0);let l=D.readString(!0);D.skipString()!==void 0&&(i={signal:a,coreDumped:c,errorMessage:l}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a})`);break}case"pty-req":{let a=D.readString(!0),c=D.readUInt32BE(),l=D.readUInt32BE(),f=D.readUInt32BE(),u=D.readUInt32BE(),h=D.readString();if(h!==void 0){D.init(h,1);let p={};for(;D.avail();){let y=D.readByte();if(y===kl.TTY_OP_END)break;let _=ug[y],x=D.readUInt32BE();if(y===void 0||_===void 0||x===void 0){p=void 0;break}p[_]=x}p!==void 0&&(i={term:a,cols:c,rows:l,width:f,height:u,modes:p})}n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"window-change":{let a=D.readUInt32BE(),c=D.readUInt32BE(),l=D.readUInt32BE(),f=D.readUInt32BE();f!==void 0&&(i={cols:a,rows:c,width:l,height:f}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"x11-req":{let a=D.readBool(),c=D.readString(!0),l=D.readString(),f=D.readUInt32BE();f!==void 0&&(i={single:a,protocol:c,cookie:l,screen:f}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"env":{let a=D.readString(!0),c=D.readString(!0);c!==void 0&&(i={name:a,value:c}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a}=${c})`);break}case"shell":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;case"exec":i=D.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"subsystem":i=D.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"signal":i=D.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"xon-xoff":i=D.readBool(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"auth-agent-req@openssh.com":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;default:i=D.avail()?D.readRaw():null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`)}if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed CHANNEL_REQUEST packet");let o=n._handlers.CHANNEL_REQUEST;o&&o(n,e,r,s,i)},[At.CHANNEL_SUCCESS]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_SUCCESS packet");n._debug&&n._debug(`Inbound: CHANNEL_SUCCESS (r:${e})`);let r=n._handlers.CHANNEL_SUCCESS;r&&r(n,e)},[At.CHANNEL_FAILURE]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_FAILURE (r:${e})`);let r=n._handlers.CHANNEL_FAILURE;r&&r(n,e)}}});var gs=ct((Jy,Rl)=>{"use strict";var ha=new Array(256);[ms().HANDLERS,Bl()].forEach(n=>{for(let[t,e]of Object.entries(n))t=+t,isFinite(t)&&t>=0&&t<ha.length&&(ha[t]=e)});Rl.exports=ha});var ms=ct((e_,Fl)=>{"use strict";var{createDiffieHellman:dg,createDiffieHellmanGroup:hg,createECDH:pg,createHash:ga,createPublicKey:gg,diffieHellman:mg,generateKeyPairSync:Ag,randomFillSync:yg}=require("crypto"),{Ber:Nl}=si(),{COMPAT:ma,curve25519Supported:_g,DEFAULT_KEX:Pl,DEFAULT_SERVER_HOST_KEY:Tl,DEFAULT_CIPHER:As,DEFAULT_MAC:ys,DEFAULT_COMPRESSION:_s,DISCONNECT_REASON:ze,MESSAGE:ht}=Ln(),{CIPHER_INFO:Dr,createCipher:Eg,createDecipher:bg,MAC_INFO:Ll}=qn(),{parseDERKey:xg}=Gn(),{bufferFill:Sg,bufferParser:Ge,convertSignature:wg,doFatalError:Ye,FastBuffer:Ig,sigSSHToASN1:Cg,writeUInt32BE:Mt}=mn(),{PacketReader:$l,PacketWriter:Dl,ZlibPacketReader:Es,ZlibPacketWriter:bs}=ua(),Lr,kg=2048,vg=8192,Bg=Buffer.alloc(0);function Ul(n){let t;if(n._compatFlags&ma.BAD_DHGEX){let e=n._offer.lists.kex,r=e.array,s=!1;for(let i=0;i<r.length;++i)r[i].includes("group-exchange")&&(s||(s=!0,r=r.slice()),r.splice(i--,1));if(s){let i=17+n._offer.totalSize+1+4,o=Buffer.from(r.join(","));i-=e.buffer.length-o.length;let a=n._offer.lists.all,c=new Uint8Array(a.buffer,a.byteOffset+4+e.buffer.length,a.length-(4+e.buffer.length));t=Buffer.allocUnsafe(i),Mt(t,o.length,17),t.set(o,21),t.set(c,21+o.length)}}t===void 0&&(t=Buffer.allocUnsafe(17+n._offer.totalSize+1+4),n._offer.copyAllTo(t,17)),n._debug&&n._debug("Outbound: Sending KEXINIT"),t[0]=ht.KEXINIT,yg(t,1,16),Sg(t,0,t.length-5),n._kexinit=t,n._packetRW.write.allocStart=0;{let e=n._packetRW.write.allocStartKEX,r=n._packetRW.write.alloc(t.length,!0);r.set(t,e),n._cipher.encrypt(n._packetRW.write.finalize(r,!0))}}function Ol(n,t){let e={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(Ge.init(t,17),(e.kex=Ge.readList())===void 0||(e.serverHostKey=Ge.readList())===void 0||(e.cs.cipher=Ge.readList())===void 0||(e.sc.cipher=Ge.readList())===void 0||(e.cs.mac=Ge.readList())===void 0||(e.sc.mac=Ge.readList())===void 0||(e.cs.compress=Ge.readList())===void 0||(e.sc.compress=Ge.readList())===void 0||(e.cs.lang=Ge.readList())===void 0||(e.sc.lang=Ge.readList())===void 0)return Ge.clear(),Ye(n,"Received malformed KEXINIT","handshake",ze.KEY_EXCHANGE_FAILED);let r=Ge.pos(),s=r<t.length&&t[r]===1;Ge.clear();let i=n._offer,o=e,a=i.lists.kex.array;if(n._compatFlags&ma.BAD_DHGEX){let C=!1;for(let U=0;U<a.length;++U)a[U].indexOf("group-exchange")!==-1&&(C||(C=!0,a=a.slice()),a.splice(U--,1))}let c,l,f,u=n._debug;u&&u("Inbound: Handshake in progress"),u&&u(`Handshake: (local) KEX method: ${a}`),u&&u(`Handshake: (remote) KEX method: ${o.kex}`);let h;if(n._server?(l=a,c=o.kex,h=c.indexOf("ext-info-c")!==-1):(l=o.kex,c=a,h=l.indexOf("ext-info-s")!==-1),n._strictMode===void 0&&(n._server?n._strictMode=c.indexOf("kex-strict-c-v00@openssh.com")!==-1:n._strictMode=l.indexOf("kex-strict-s-v00@openssh.com")!==-1,n._strictMode&&(u&&u("Handshake: strict KEX mode enabled"),n._decipher.inSeqno!==1)))return u&&u("Handshake: KEXINIT not first packet in strict KEX mode"),Ye(n,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",ze.KEY_EXCHANGE_FAILED);for(f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: no matching key exchange algorithm"),Ye(n,"Handshake failed: no matching key exchange algorithm","handshake",ze.KEY_EXCHANGE_FAILED);e.kex=c[f],u&&u(`Handshake: KEX algorithm: ${c[f]}`),s&&(!o.kex.length||c[f]!==o.kex[0])&&(n._skipNextInboundPacket=!0);let p=i.lists.serverHostKey.array;for(u&&u(`Handshake: (local) Host key format: ${p}`),u&&u(`Handshake: (remote) Host key format: ${o.serverHostKey}`),n._server?(l=p,c=o.serverHostKey):(l=o.serverHostKey,c=p),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching host key format"),Ye(n,"Handshake failed: no matching host key format","handshake",ze.KEY_EXCHANGE_FAILED);e.serverHostKey=c[f],u&&u(`Handshake: Host key format: ${c[f]}`);let y=i.lists.cs.cipher.array;for(u&&u(`Handshake: (local) C->S cipher: ${y}`),u&&u(`Handshake: (remote) C->S cipher: ${o.cs.cipher}`),n._server?(l=y,c=o.cs.cipher):(l=o.cs.cipher,c=y),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching C->S cipher"),Ye(n,"Handshake failed: no matching C->S cipher","handshake",ze.KEY_EXCHANGE_FAILED);e.cs.cipher=c[f],u&&u(`Handshake: C->S Cipher: ${c[f]}`);let _=i.lists.sc.cipher.array;for(u&&u(`Handshake: (local) S->C cipher: ${_}`),u&&u(`Handshake: (remote) S->C cipher: ${o.sc.cipher}`),n._server?(l=_,c=o.sc.cipher):(l=o.sc.cipher,c=_),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching S->C cipher"),Ye(n,"Handshake failed: no matching S->C cipher","handshake",ze.KEY_EXCHANGE_FAILED);e.sc.cipher=c[f],u&&u(`Handshake: S->C cipher: ${c[f]}`);let x=i.lists.cs.mac.array;if(u&&u(`Handshake: (local) C->S MAC: ${x}`),u&&u(`Handshake: (remote) C->S MAC: ${o.cs.mac}`),Dr[e.cs.cipher].authLen>0)e.cs.mac="",u&&u("Handshake: C->S MAC: <implicit>");else{for(n._server?(l=x,c=o.cs.mac):(l=o.cs.mac,c=x),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching C->S MAC"),Ye(n,"Handshake failed: no matching C->S MAC","handshake",ze.KEY_EXCHANGE_FAILED);e.cs.mac=c[f],u&&u(`Handshake: C->S MAC: ${c[f]}`)}let S=i.lists.sc.mac.array;if(u&&u(`Handshake: (local) S->C MAC: ${S}`),u&&u(`Handshake: (remote) S->C MAC: ${o.sc.mac}`),Dr[e.sc.cipher].authLen>0)e.sc.mac="",u&&u("Handshake: S->C MAC: <implicit>");else{for(n._server?(l=S,c=o.sc.mac):(l=o.sc.mac,c=S),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching S->C MAC"),Ye(n,"Handshake failed: no matching S->C MAC","handshake",ze.KEY_EXCHANGE_FAILED);e.sc.mac=c[f],u&&u(`Handshake: S->C MAC: ${c[f]}`)}let R=i.lists.cs.compress.array;for(u&&u(`Handshake: (local) C->S compression: ${R}`),u&&u(`Handshake: (remote) C->S compression: ${o.cs.compress}`),n._server?(l=R,c=o.cs.compress):(l=o.cs.compress,c=R),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching C->S compression"),Ye(n,"Handshake failed: no matching C->S compression","handshake",ze.KEY_EXCHANGE_FAILED);e.cs.compress=c[f],u&&u(`Handshake: C->S compression: ${c[f]}`);let H=i.lists.sc.compress.array;for(u&&u(`Handshake: (local) S->C compression: ${H}`),u&&u(`Handshake: (remote) S->C compression: ${o.sc.compress}`),n._server?(l=H,c=o.sc.compress):(l=o.sc.compress,c=H),f=0;f<c.length&&l.indexOf(c[f])===-1;++f);if(f===c.length)return u&&u("Handshake: No matching S->C compression"),Ye(n,"Handshake failed: no matching S->C compression","handshake",ze.KEY_EXCHANGE_FAILED);e.sc.compress=c[f],u&&u(`Handshake: S->C compression: ${c[f]}`),e.cs.lang="",e.sc.lang="",n._kex&&(n._kexinit||Ul(n),n._decipher._onPayload=Ml.bind(n,{firstPacket:!1})),n._kex=Rg(e,n,t),n._kex.remoteExtInfoEnabled=h,n._kex.start()}var Rg=(()=>{function n(o){let a=0,c=o.length;for(;o[a]===0;)++a,--c;let l;return o[a]&128?(l=Buffer.allocUnsafe(1+c),l[0]=0,o.copy(l,1,a),o=l):c!==o.length&&(l=Buffer.allocUnsafe(c),o.copy(l,0,a),o=l),o}class t{constructor(a,c,l){this._protocol=c,this.sessionID=c._kex?c._kex.sessionID:void 0,this.negotiated=a,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=c._kexinit,this._remoteKexinit=l,this._identRaw=c._identRaw,this._remoteIdentRaw=c._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(a){if(this._finished)return!1;this._finished=!0;let c=this._protocol._server,l=this.negotiated,f=this.convertPublicKey(this._dhData),u=this.computeSecret(this._dhData);if(u instanceof Error)return u.message=`Error while computing DH secret (${this.type}): ${u.message}`,u.level="handshake",Ye(this._protocol,u,ze.KEY_EXCHANGE_FAILED);let h=ga(this.hashName);In(h,c?this._remoteIdentRaw:this._identRaw),In(h,c?this._identRaw:this._remoteIdentRaw),In(h,c?this._remoteKexinit:this._kexinit),In(h,c?this._kexinit:this._remoteKexinit);let p=c?this._hostKey.getPublicSSH():this._hostKey;if(In(h,p),this.type==="groupex"){let H=this.getDHParams(),C=Buffer.allocUnsafe(4);Mt(C,this._minBits,0),h.update(C),Mt(C,this._prefBits,0),h.update(C),Mt(C,this._maxBits,0),h.update(C),In(h,H.prime),In(h,H.generator)}In(h,c?f:this.getPublicKey());let y=c?this.getPublicKey():f;In(h,y),In(h,u);let _=h.digest();if(c){let H;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":H="sha256";break;case"rsa-sha2-512":H="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let C=this._hostKey.sign(_,H);if(C instanceof Error)return Ye(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${C.message}`,"handshake",ze.KEY_EXCHANGE_FAILED);if(C=wg(C,this._hostKey.type),C===!1)return Ye(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",ze.KEY_EXCHANGE_FAILED);let U=this.negotiated.serverHostKey,Q=Buffer.byteLength(U),B=4+Q+4+C.length,b=this._protocol._packetRW.write.allocStartKEX,w=this._protocol._packetRW.write.alloc(5+p.length+4+y.length+4+B,!0);if(w[b]=ht.KEXDH_REPLY,Mt(w,p.length,++b),w.set(p,b+=4),Mt(w,y.length,b+=p.length),w.set(y,b+=4),Mt(w,B,b+=y.length),Mt(w,Q,b+=4),w.utf8Write(U,b+=4,Q),Mt(w,C.length,b+=Q),w.set(C,b+=4),this._protocol._debug){let k;switch(this.type){case"group":k="KEXDH_REPLY";break;case"groupex":k="KEXDH_GEX_REPLY";break;default:k="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${k}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(w,!0))}else{Ge.init(this._sig,0);let H=Ge.readString(!0);if(!H)return Ye(this._protocol,"Malformed packet while reading signature","handshake",ze.KEY_EXCHANGE_FAILED);if(H!==l.serverHostKey)return Ye(this._protocol,`Wrong signature type: ${H}, expected: ${l.serverHostKey}`,"handshake",ze.KEY_EXCHANGE_FAILED);let C=Ge.readString();if(Ge.clear(),C===void 0)return Ye(this._protocol,"Malformed packet while reading signature","handshake",ze.KEY_EXCHANGE_FAILED);if(!(C=Cg(C,H)))return Ye(this._protocol,"Malformed signature","handshake",ze.KEY_EXCHANGE_FAILED);let U;{Ge.init(this._hostKey,0);let b=Ge.readString(!0),w=this._hostKey.slice(Ge.pos());if(Ge.clear(),U=xg(w,b),U instanceof Error)return U.level="handshake",Ye(this._protocol,U,ze.KEY_EXCHANGE_FAILED)}let Q;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":Q="sha256";break;case"rsa-sha2-512":Q="sha512";break}this._protocol._debug&&this._protocol._debug("Verifying signature ...");let B=U.verify(_,C,Q);if(B!==!0)return B instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${B.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),Ye(this._protocol,"Handshake failed: signature verification failed","handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(c||!a)&&xs(this);let x,S,R=H=>{if(x)return xs(this),x.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=Eg(x),this._protocol._packetRW.write=S,x=void 0,S=void 0,this._protocol._onHandshakeComplete(l),!1;this.sessionID||(this.sessionID=_);{let te=Buffer.allocUnsafe(4+u.length);Mt(te,u.length,0),te.set(u,4),u=te}let C=Dr[l.cs.cipher],U=Dr[l.sc.cipher],Q=$r(C.ivLen,this.hashName,u,_,this.sessionID,"A"),B=$r(U.ivLen,this.hashName,u,_,this.sessionID,"B"),b=$r(C.keyLen,this.hashName,u,_,this.sessionID,"C"),w=$r(U.keyLen,this.hashName,u,_,this.sessionID,"D"),k,v;C.authLen||(k=Ll[l.cs.mac],v=$r(k.len,this.hashName,u,_,this.sessionID,"E"));let P,ne;U.authLen||(P=Ll[l.sc.mac],ne=$r(P.len,this.hashName,u,_,this.sessionID,"F"));let z={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:c?C:U,decipherIV:c?Q:B,decipherKey:c?b:w,macInfo:c?k:P,macKey:c?v:ne},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:c?U:C,cipherIV:c?B:Q,cipherKey:c?w:b,macInfo:c?P:k,macKey:c?ne:v}};this._protocol._decipher.free(),x=z,this._protocol._decipher=bg(z);let Y={read:void 0,write:void 0};switch(l.cs.compress){case"zlib":c?Y.read=new Es:Y.write=new bs(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){c?Y.read=new Es:Y.write=new bs(this._protocol);break}default:c?Y.read=new $l:Y.write=new Dl(this._protocol)}switch(l.sc.compress){case"zlib":c?Y.write=new bs(this._protocol):Y.read=new Es;break;case"zlib@openssh.com":if(this._protocol._authenticated){c?Y.write=new bs(this._protocol):Y.read=new Es;break}default:c?Y.write=new Dl(this._protocol):Y.read=new $l}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=Y.read,S=Y.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,H?!1:R()};if((c||a)&&(this.finish=R),!c)return R(a)}start(){if(!this._protocol._server){if(this._protocol._debug){let f;this.type==="group"?f="KEXDH_INIT":f="KEXECDH_INIT",this._protocol._debug(`Outbound: Sending ${f}`)}let a=this.getPublicKey(),c=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[c]=ht.KEXDH_INIT,Mt(l,a.length,++c),l.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}getPublicKey(){this.generateKeys();let a=this._public;if(a)return this.convertPublicKey(a)}convertPublicKey(a){let c,l=0,f=a.length;for(;a[l]===0;)++l,--f;return a[l]&128?(c=Buffer.allocUnsafe(1+f),c[0]=0,a.copy(c,1,l),c):(f!==a.length&&(c=Buffer.allocUnsafe(f),a.copy(c,0,l),a=c),a)}computeSecret(a){this.generateKeys();try{return n(this._dh.computeSecret(a))}catch(c){return c}}parse(a){let c=a[0];switch(this._step){case 1:if(this._protocol._server){if(c!==ht.KEXDH_INIT)return Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_INIT}`,"handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),Ge.init(a,1);let l=Ge.readString();if(Ge.clear(),l===void 0)return Ye(this._protocol,"Received malformed KEX*_INIT","handshake",ze.KEY_EXCHANGE_FAILED);this._dhData=l;let f=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(f)&&(f=f[0]),this._hostKey=f,this.finish()}else{if(c!==ht.KEXDH_REPLY)return Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_REPLY}`,"handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),Ge.init(a,1);let l,f,u;if((l=Ge.readString())===void 0||(f=Ge.readString())===void 0||(u=Ge.readString())===void 0)return Ge.clear(),Ye(this._protocol,"Received malformed KEX*_REPLY","handshake",ze.KEY_EXCHANGE_FAILED);Ge.clear(),Ge.init(l,0);let h=Ge.readString(!0);if(Ge.clear(),h===void 0)return Ye(this._protocol,"Received malformed host public key","handshake",ze.KEY_EXCHANGE_FAILED);if(h!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(h==="ssh-rsa")break;default:return Ye(this._protocol,"Host key does not match negotiated type","handshake",ze.KEY_EXCHANGE_FAILED)}this._hostKey=l,this._dhData=f,this._sig=u;let p=!1,y;if(this._protocol._hostVerifier===void 0?(y=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):y=this._protocol._hostVerifier(l,_=>{if(!p){if(p=!0,_===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),Ye(this._protocol,"Host denied (verification failed)","handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():xs(this)}}),y===void 0){++this._step;return}if(p=!0,y===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),Ye(this._protocol,"Host denied (verification failed)","handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,xs(this)}++this._step;break;case 2:return c!==ht.NEWKEYS?Ye(this._protocol,`Received packet ${c} instead of ${ht.NEWKEYS}`,"handshake",ze.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 Ye(this._protocol,`Received unexpected packet ${c} after NEWKEYS`,"handshake",ze.KEY_EXCHANGE_FAILED)}}}class e extends t{constructor(a,...c){super(...c),this.type="25519",this.hashName=a,this._keys=null}generateKeys(){this._keys||(this._keys=Ag("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(a){let c,l=0,f=a.length;for(;a[l]===0;)++l,--f;return a.length===32||f!==a.length&&(c=Buffer.allocUnsafe(f),a.copy(c,0,l),a=c),a}computeSecret(a){this.generateKeys();try{let c=new Nl.Writer;return c.startSequence(),c.startSequence(),c.writeOID("1.3.101.110"),c.endSequence(),c.startSequence(Nl.BitString),c.writeByte(0),c._ensure(a.length),a.copy(c._buf,c._offset,0,a.length),c._offset+=a.length,c.endSequence(),c.endSequence(),n(mg({privateKey:this._keys.privateKey,publicKey:gg({key:c.buffer,type:"spki",format:"der"})}))}catch(c){return c}}}class r extends t{constructor(a,c,...l){super(...l),this.type="ecdh",this.curveName=a,this.hashName=c}generateKeys(){this._dh||(this._dh=pg(this.curveName),this._public=this._dh.generateKeys())}}class s extends t{constructor(a,...c){super(...c),this.type="groupex",this.hashName=a,this._prime=null,this._generator=null,this._minBits=kg,this._prefBits=Ng(this.negotiated),this._protocol._compatFlags&ma.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=vg}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let a=this._protocol._packetRW.write.allocStartKEX,c=this._protocol._packetRW.write.alloc(13,!0);c[a]=ht.KEXDH_GEX_REQUEST,Mt(c,this._minBits,++a),Mt(c,this._prefBits,a+=4),Mt(c,this._maxBits,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(c,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=dg(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(a,c){if(!Buffer.isBuffer(a))throw new Error("Invalid prime value");if(!Buffer.isBuffer(c))throw new Error("Invalid generator value");this._prime=a,this._generator=c}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}parse(a){let c=a[0];switch(this._step){case 1:{if(this._protocol._server)return c!==ht.KEXDH_GEX_REQUEST?Ye(this._protocol,`Received packet ${c} instead of `+ht.KEXDH_GEX_REQUEST,"handshake",ze.KEY_EXCHANGE_FAILED):Ye(this._protocol,"Group exchange not implemented for server","handshake",ze.KEY_EXCHANGE_FAILED);if(c!==ht.KEXDH_GEX_GROUP)return Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_GEX_GROUP}`,"handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),Ge.init(a,1);let l,f;if((l=Ge.readString())===void 0||(f=Ge.readString())===void 0)return Ge.clear(),Ye(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",ze.KEY_EXCHANGE_FAILED);Ge.clear(),this.setDHParams(l,f),this.generateKeys();let u=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let h=this._protocol._packetRW.write.allocStartKEX,p=this._protocol._packetRW.write.alloc(5+u.length,!0);p[h]=ht.KEXDH_GEX_INIT,Mt(p,u.length,++h),p.set(u,h+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(p,!0)),++this._step;break}case 2:if(this._protocol._server)return c!==ht.KEXDH_GEX_INIT?Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_GEX_INIT}`,"handshake",ze.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),Ye(this._protocol,"Group exchange not implemented for server","handshake",ze.KEY_EXCHANGE_FAILED));if(c!==ht.KEXDH_GEX_REPLY)return Ye(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_GEX_REPLY}`,"handshake",ze.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,a[0]=ht.KEXDH_REPLY,this.parse=t.prototype.parse,this.parse(a)}}}class i extends t{constructor(a,c,...l){super(...l),this.type="group",this.groupName=a,this.hashName=c}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");let a=this.getPublicKey(),c=this._protocol._packetRW.write.allocStartKEX,l=this._protocol._packetRW.write.alloc(5+a.length,!0);l[c]=ht.KEXDH_INIT,Mt(l,a.length,++c),l.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(l,!0))}}generateKeys(){this._dh||(this._dh=hg(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}}return(o,...a)=>{if(typeof o!="object"||o===null)throw new Error("Invalid negotiated argument");let c=o.kex;if(typeof c=="string"){switch(a=[o,...a],c){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!_g)break;return new e("sha256",...a);case"ecdh-sha2-nistp256":return new r("prime256v1","sha256",...a);case"ecdh-sha2-nistp384":return new r("secp384r1","sha384",...a);case"ecdh-sha2-nistp521":return new r("secp521r1","sha512",...a);case"diffie-hellman-group1-sha1":return new i("modp2","sha1",...a);case"diffie-hellman-group14-sha1":return new i("modp14","sha1",...a);case"diffie-hellman-group14-sha256":return new i("modp14","sha256",...a);case"diffie-hellman-group15-sha512":return new i("modp15","sha512",...a);case"diffie-hellman-group16-sha512":return new i("modp16","sha512",...a);case"diffie-hellman-group17-sha512":return new i("modp17","sha512",...a);case"diffie-hellman-group18-sha512":return new i("modp18","sha512",...a);case"diffie-hellman-group-exchange-sha1":return new s("sha1",...a);case"diffie-hellman-group-exchange-sha256":return new s("sha256",...a)}throw new Error(`Unsupported key exchange algorithm: ${c}`)}throw new Error(`Invalid key exchange type: ${c}`)}})(),pa=(()=>{let n=["kex","serverHostKey",["cs","cipher"],["sc","cipher"],["cs","mac"],["sc","mac"],["cs","compress"],["sc","compress"],["cs","lang"],["sc","lang"]];return class{constructor(e){if(typeof e!="object"||e===null)throw new TypeError("Argument must be an object");let r={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},s=0;for(let a of n){let c,l,f,u;if(typeof a=="string")c=r,l=e[a],f=u=a;else{let p=a[0];c=r[p],u=a[1],l=e[p][u],f=`${p}.${u}`}let h={array:void 0,buffer:void 0};if(Buffer.isBuffer(l))h.array=(""+l).split(","),h.buffer=l,s+=4+l.length;else{if(typeof l=="string"&&(l=l.split(",")),Array.isArray(l))h.array=l,h.buffer=Buffer.from(l.join(","));else throw new TypeError(`Invalid \`${f}\` type: ${typeof l}`);s+=4+h.buffer.length}c[u]=h}let i=Buffer.allocUnsafe(s);r.all=i;let o=0;for(let a of n){let c;typeof a=="string"?c=r[a].buffer:c=r[a[0]][a[1]].buffer,o=Mt(i,c.length,o),i.set(c,o),o+=c.length}this.totalSize=s,this.lists=r}copyAllTo(e,r){let s=this.lists.all;if(typeof r!="number")throw new TypeError(`Invalid offset value: ${typeof r}`);if(e.length-r<s.length)throw new Error("Insufficient space to copy list");return e.set(s,r),s.length}}})(),In=(()=>{let n=Buffer.allocUnsafe(4);return(t,e)=>{Mt(n,e.length,0),t.update(n),t.update(e)}})();function $r(n,t,e,r,s,i){let o;if(n){let a=ga(t).update(e).update(r).update(i).update(s).digest();for(;a.length<n;){let c=ga(t).update(e).update(r).update(a).digest(),l=Buffer.allocUnsafe(a.length+c.length);l.set(a,0),l.set(c,a.length),a=l}a.length===n?o=a:o=new Ig(a.buffer,a.byteOffset,n)}else o=Bg;return o}function Ml(n,t){if(t.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}if(this._skipNextInboundPacket){this._skipNextInboundPacket=!1;return}t=this._packetRW.read.read(t);let e=t[0];if(!this._strictMode)switch(e){case ht.IGNORE:case ht.UNIMPLEMENTED:case ht.DEBUG:return Lr||(Lr=gs()),Lr[e](this,t)}switch(e){case ht.DISCONNECT:return Lr||(Lr=gs()),Lr[e](this,t);case ht.KEXINIT:return n.firstPacket?(n.firstPacket=!1,Ol(this,t)):Ye(this,"Received extra KEXINIT during handshake","handshake",ze.KEY_EXCHANGE_FAILED);default:if(e<20||e>49)return Ye(this,`Received unexpected packet type ${e}`,"handshake",ze.KEY_EXCHANGE_FAILED)}return this._kex.parse(t)}function Ng(n){let t=Dr[n.cs.cipher],e=Dr[n.sc.cipher],r=Math.max(0,t.sslName==="des-ede3-cbc"?14:t.keyLen,t.blockLen,t.ivLen,e.sslName==="des-ede3-cbc"?14:e.keyLen,e.blockLen,e.ivLen)*8;return r<=112?2048:r<=128?3072:r<=192?7680:8192}function xs(n){if(!n._sentNEWKEYS){n._protocol._debug&&n._protocol._debug("Outbound: Sending NEWKEYS");let t=n._protocol._packetRW.write.allocStartKEX,e=n._protocol._packetRW.write.alloc(1,!0);e[t]=ht.NEWKEYS,n._protocol._cipher.encrypt(n._protocol._packetRW.write.finalize(e,!0)),n._sentNEWKEYS=!0,n._protocol._strictMode&&(n._protocol._cipher.outSeqno=0)}}Fl.exports={KexInit:pa,kexinit:Ul,onKEXPayload:Ml,DEFAULT_KEXINIT_CLIENT:new pa({kex:Pl.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:Tl,cs:{cipher:As,mac:ys,compress:_s,lang:[]},sc:{cipher:As,mac:ys,compress:_s,lang:[]}}),DEFAULT_KEXINIT_SERVER:new pa({kex:Pl.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:Tl,cs:{cipher:As,mac:ys,compress:_s,lang:[]},sc:{cipher:As,mac:ys,compress:_s,lang:[]}}),HANDLERS:{[ht.KEXINIT]:Ol}}});var Hl=ct((t_,Pg)=>{Pg.exports={name:"ssh2",version:"1.17.0",author:"Brian White <mscdex@mscdex.net>",description:"SSH2 client and server modules written in pure JavaScript for node.js",main:"./lib/index.js",engines:{node:">=10.16.0"},dependencies:{asn1:"^0.2.6","bcrypt-pbkdf":"^1.0.2"},devDependencies:{"@mscdex/eslint-config":"^1.1.0",eslint:"^7.32.0"},optionalDependencies:{"cpu-features":"~0.0.10",nan:"^2.23.0"},scripts:{install:"node install.js",rebuild:"node install.js",test:"node test/test.js",lint:"eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js examples lib test","lint:fix":"npm run lint -- --fix"},keywords:["ssh","ssh2","sftp","secure","shell","exec","remote","client"],licenses:[{type:"MIT",url:"http://github.com/mscdex/ssh2/raw/master/LICENSE"}],repository:{type:"git",url:"http://github.com/mscdex/ssh2.git"}}});var Ea=ct((n_,ef)=>{"use strict";var{inspect:Gl}=require("util"),{bindingAvailable:Tg,NullCipher:Lg,NullDecipher:$g}=qn(),{COMPAT_CHECKS:Dg,DISCONNECT_REASON:zl,eddsaSupported:Ug,MESSAGE:we,SIGNALS:Ql,TERMINAL_MODE:ya}=Ln(),{DEFAULT_KEXINIT_CLIENT:Og,DEFAULT_KEXINIT_SERVER:Mg,KexInit:Wl,kexinit:Yl,onKEXPayload:Fg}=ms(),{parseKey:ql}=Gn(),Hg=gs(),{bufferCopy:Ss,bufferFill:Qg,bufferSlice:jl,convertSignature:Kl,sendPacket:Ie,writeUInt32BE:T}=mn(),{PacketReader:Wg,PacketWriter:qg,ZlibPacketReader:Xl,ZlibPacketWriter:Jl}=ua(),Kg=Hl().version,Vg=new Map(Object.values(zl).map(n=>[n,1])),Zl=Buffer.from(`SSH-2.0-ssh2js${Kg}`),Gg=Buffer.from(`${Zl}\r
|
|
7
8
|
`),zg=8192,Yg=1024,Vl=Buffer.from([we.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]),jg=Buffer.from([ya.TTY_OP_END]);function Aa(){}var _a=class{constructor(t){let e=t.onWrite;if(typeof e!="function")throw new Error("Missing onWrite function");this._onWrite=p=>{e(p)};let r=t.onError;if(typeof r!="function")throw new Error("Missing onError function");this._onError=p=>{r(p)};let s=t.debug;this._debug=typeof s=="function"?p=>{s(p)}:void 0;let i=t.onHeader;this._onHeader=typeof i=="function"?(...p)=>{i(...p)}:Aa;let o=t.onPacket;this._onPacket=typeof o=="function"?()=>{o()}:Aa;let a=t.onHandshakeComplete;typeof a!="function"&&(a=Aa);let c;this._onHandshakeComplete=(...p)=>{this._debug&&this._debug("Handshake completed"),c===void 0?c=!0:c=!1;let y=this._queue;if(y){this._queue=void 0,this._debug&&this._debug(`Draining outbound queue (${y.length}) ...`);for(let _=0;_<y.length;++_){let x=y[_],S=this._packetRW.write.finalize(x);if(S===x){let R=this._cipher.allocPacket(x.length);R.set(x,5),S=R}Ie(this,S)}this._debug&&this._debug("... finished draining outbound queue")}c&&this._server&&this._kex.remoteExtInfoEnabled&&r0(this),a(...p)},this._queue=void 0;let l=t.messageHandlers;typeof l=="object"&&l!==null?this._handlers=l:this._handlers={},this._onPayload=e0.bind(this),this._server=!!t.server,this._banner=void 0;let f;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&&(f=t.greeting.slice(-2)===`\r
|
|
8
9
|
`?t.greeting:`${t.greeting}\r
|
|
9
10
|
`),typeof t.banner=="string"&&t.banner.length&&(this._banner=t.banner.slice(-2)===`\r
|
|
@@ -11,11 +12,11 @@ ${e}-----END ${n} KEY-----`}function pi(n,t){let e=Buffer.allocUnsafe(n.length+t
|
|
|
11
12
|
`)}else this._hostKeys=void 0;let u=t.offer;typeof u!="object"||u===null?u=this._server?Mg:Og:u.constructor!==Wl&&(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 Wl(u)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=u,this._cipher=new Lg(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new Wg,write:new qg(this)},this._hostVerifier=!this._server&&typeof t.hostVerifier=="function"?t.hostVerifier:void 0,this._parse=Jg,this._buffer=void 0,this._authsQueue=[],this._authenticated=!1,this._remoteIdentRaw=void 0;let h;if(typeof t.ident=="string")this._identRaw=Buffer.from(`SSH-2.0-${t.ident}`),h=Buffer.allocUnsafe(this._identRaw.length+2),h.set(this._identRaw,0),h[h.length-2]=13,h[h.length-1]=10;else if(Buffer.isBuffer(t.ident)){let p=Buffer.allocUnsafe(8+t.ident.length);p.latin1Write("SSH-2.0-",0,8),p.set(t.ident,8),this._identRaw=p,h=Buffer.allocUnsafe(p.length+2),h.set(p,0),h[h.length-2]=13,h[h.length-1]=10}else this._identRaw=Zl,h=Gg;this._compatFlags=0,this._debug&&(Tg?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${Gl(this._identRaw.toString())}`),this.start=()=>{this.start=void 0,f&&this._onWrite(f),this._onWrite(h)}}_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,r){for(;e<r;)e=this._parse(t,e,r)}disconnect(t){let r=this._packetRW.write.allocStartKEX,s=this._packetRW.write.alloc(13,!0),i=r+13;Vg.has(t)||(t=zl.PROTOCOL_ERROR),s[r]=we.DISCONNECT,T(s,t,++r),s.fill(0,r+=4,i),this._debug&&this._debug(`Outbound: Sending DISCONNECT (${t})`),Ie(this,this._packetRW.write.finalize(s,!0),!0)}ping(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(Vl.length);e.set(Vl,t),this._debug&&this._debug("Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)"),Ie(this,this._packetRW.write.finalize(e))}rekey(){this._kexinit===void 0?(this._debug&&this._debug("Outbound: Initiated explicit rekey"),this._queue=[],Yl(this)):this._debug&&this._debug("Outbound: Ignoring rekey during handshake")}requestSuccess(t){let e=this._packetRW.write.allocStart,r;Buffer.isBuffer(t)?(r=this._packetRW.write.alloc(1+t.length),r[e]=we.REQUEST_SUCCESS,r.set(t,++e)):(r=this._packetRW.write.alloc(1),r[e]=we.REQUEST_SUCCESS),this._debug&&this._debug("Outbound: Sending REQUEST_SUCCESS"),Ie(this,this._packetRW.write.finalize(r))}requestFailure(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=we.REQUEST_FAILURE,this._debug&&this._debug("Outbound: Sending REQUEST_FAILURE"),Ie(this,this._packetRW.write.finalize(e))}channelSuccess(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=we.CHANNEL_SUCCESS,T(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${t})`),Ie(this,this._packetRW.write.finalize(r))}channelFailure(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=we.CHANNEL_FAILURE,T(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${t})`),Ie(this,this._packetRW.write.finalize(r))}channelEOF(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=we.CHANNEL_EOF,T(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_EOF (r:${t})`),Ie(this,this._packetRW.write.finalize(r))}channelClose(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=we.CHANNEL_CLOSE,T(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${t})`),Ie(this,this._packetRW.write.finalize(r))}channelWindowAdjust(t,e){let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(9);s[r]=we.CHANNEL_WINDOW_ADJUST,T(s,t,++r),T(s,e,r+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${t}, ${e})`),Ie(this,this._packetRW.write.finalize(s))}channelData(t,e){let r=Buffer.isBuffer(e),s=r?e.length:Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(9+s);o[i]=we.CHANNEL_DATA,T(o,t,++i),T(o,s,i+=4),r?o.set(e,i+=4):o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_DATA (r:${t}, ${s})`),Ie(this,this._packetRW.write.finalize(o))}channelExtData(t,e,r){let s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(13+i);a[o]=we.CHANNEL_EXTENDED_DATA,T(a,t,++o),T(a,r,o+=4),T(a,i,o+=4),s?a.set(e,o+=4):a.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${t})`),Ie(this,this._packetRW.write.finalize(a))}channelOpenConfirm(t,e,r,s){let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(17);o[i]=we.CHANNEL_OPEN_CONFIRMATION,T(o,t,++i),T(o,e,i+=4),T(o,r,i+=4),T(o,s,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${t}, l:${e})`),Ie(this,this._packetRW.write.finalize(o))}channelOpenFail(t,e,r){typeof r!="string"&&(r="");let s=Buffer.byteLength(r),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(13+s+4);o[i]=we.CHANNEL_OPEN_FAILURE,T(o,t,++i),T(o,e,i+=4),T(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),T(o,0,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${t})`),Ie(this,this._packetRW.write.finalize(o))}service(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);s[r]=we.SERVICE_REQUEST,T(s,e,++r),s.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_REQUEST (${t})`),Ie(this,this._packetRW.write.finalize(s))}authPassword(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=r?Buffer.byteLength(r):0,a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(5+s+4+14+4+8+1+4+i+(r?4+o:0));c[a]=we.USERAUTH_REQUEST,T(c,s,++a),c.utf8Write(t,a+=4,s),T(c,14,a+=s),c.utf8Write("ssh-connection",a+=4,14),T(c,8,a+=14),c.utf8Write("password",a+=4,8),c[a+=8]=r?1:0,T(c,i,++a),Buffer.isBuffer(e)?Ss(e,c,0,i,a+=4):c.utf8Write(e,a+=4,i),r?(T(c,o,a+=i),Buffer.isBuffer(r)?Ss(r,c,0,o,a+=4):c.utf8Write(r,a+=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"),Ie(this,this._packetRW.write.finalize(c))}authPK(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");if(e=ql(e),e instanceof Error)throw new Error("Invalid key");let i=e.type;e=e.getPublicSSH(),typeof r=="function"&&(s=r,r=void 0),r||(r=i);let o=Buffer.byteLength(t),a=Buffer.byteLength(r),c=e.length,l=this._kex.sessionID,f=l.length,u=(s?4+f:0)+1+4+o+4+14+4+9+1+4+a+4+c,h,p;if(s?(h=Buffer.allocUnsafe(u),p=0,T(h,f,p),h.set(l,p+=4),p+=f):(h=this._packetRW.write.alloc(u),p=this._packetRW.write.allocStart),h[p]=we.USERAUTH_REQUEST,T(h,o,++p),h.utf8Write(t,p+=4,o),T(h,14,p+=o),h.utf8Write("ssh-connection",p+=4,14),T(h,9,p+=14),h.utf8Write("publickey",p+=4,9),h[p+=9]=s?1:0,T(h,a,++p),h.utf8Write(r,p+=4,a),T(h,c,p+=a),h.set(e,p+=4),!s){this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),Ie(this,this._packetRW.write.finalize(h));return}s(h,y=>{if(y=Kl(y,i),y===!1)throw new Error("Error while converting handshake signature");let _=y.length;p=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(5+o+4+14+4+9+1+4+a+4+c+4+4+a+4+_),h[p]=we.USERAUTH_REQUEST,T(h,o,++p),h.utf8Write(t,p+=4,o),T(h,14,p+=o),h.utf8Write("ssh-connection",p+=4,14),T(h,9,p+=14),h.utf8Write("publickey",p+=4,9),h[p+=9]=1,T(h,a,++p),h.utf8Write(r,p+=4,a),T(h,c,p+=a),h.set(e,p+=4),T(h,4+a+4+_,p+=c),T(h,a,p+=4),h.utf8Write(r,p+=4,a),T(h,_,p+=a),h.set(y,p+=4),this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey)"),Ie(this,this._packetRW.write.finalize(h))})}authHostbased(t,e,r,s,i,o){if(this._server)throw new Error("Client-only method called in server mode");if(e=ql(e),e instanceof Error)throw new Error("Invalid key");let a=e.type;e=e.getPublicSSH(),typeof i=="function"&&(o=i,i=void 0),i||(i=a);let c=Buffer.byteLength(t),l=Buffer.byteLength(i),f=e.length,u=this._kex.sessionID,h=u.length,p=Buffer.byteLength(r),y=Buffer.byteLength(s),_=Buffer.allocUnsafe(4+h+1+4+c+4+14+4+9+4+l+4+f+4+p+4+y),x=0;T(_,h,x),_.set(u,x+=4),_[x+=h]=we.USERAUTH_REQUEST,T(_,c,++x),_.utf8Write(t,x+=4,c),T(_,14,x+=c),_.utf8Write("ssh-connection",x+=4,14),T(_,9,x+=14),_.utf8Write("hostbased",x+=4,9),T(_,l,x+=9),_.utf8Write(i,x+=4,l),T(_,f,x+=l),_.set(e,x+=4),T(_,p,x+=f),_.utf8Write(r,x+=4,p),T(_,y,x+=p),_.utf8Write(s,x+=4,y),o(_,S=>{if(S=Kl(S,a),!S)throw new Error("Error while converting handshake signature");let R=S.length,H=_.length-h-4;x=this._packetRW.write.allocStart;let C=this._packetRW.write.alloc(H+4+4+l+4+R);Ss(_,C,4+h,_.length,x),T(C,4+l+4+R,x+=H),T(C,l,x+=4),C.utf8Write(i,x+=4,l),T(C,R,x+=l),C.set(S,x+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),Ie(this,this._packetRW.write.finalize(C))})}authKeyboard(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4+14+4+20+4+4);s[r]=we.USERAUTH_REQUEST,T(s,e,++r),s.utf8Write(t,r+=4,e),T(s,14,r+=e),s.utf8Write("ssh-connection",r+=4,14),T(s,20,r+=14),s.utf8Write("keyboard-interactive",r+=4,20),T(s,0,r+=20),T(s,0,r+=4),this._authsQueue.push("keyboard-interactive"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)"),Ie(this,this._packetRW.write.finalize(s))}authNone(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4+14+4+4);s[r]=we.USERAUTH_REQUEST,T(s,e,++r),s.utf8Write(t,r+=4,e),T(s,14,r+=e),s.utf8Write("ssh-connection",r+=4,14),T(s,4,r+=14),s.utf8Write("none",r+=4,4),this._authsQueue.push("none"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (none)"),Ie(this,this._packetRW.write.finalize(s))}authInfoRes(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,r;if(t){r=new Array(t.length);for(let o=0;o<t.length;++o){let a=Buffer.byteLength(t[o]);r[o]=a,e+=4+a}}let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+e);if(i[s]=we.USERAUTH_INFO_RESPONSE,t){T(i,t.length,++s),s+=4;for(let o=0;o<t.length;++o){let a=r[o];T(i,a,s),s+=4,a&&(i.utf8Write(t[o],s,a),s+=a)}}else T(i,0,++s);this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_RESPONSE"),Ie(this,this._packetRW.write.finalize(i))}tcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+s+4);o[i]=we.GLOBAL_REQUEST,T(o,13,++i),o.utf8Write("tcpip-forward",i+=4,13),o[i+=13]=r===void 0||r===!0?1:0,T(o,s,++i),o.utf8Write(t,i+=4,s),T(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (tcpip-forward)"),Ie(this,this._packetRW.write.finalize(o))}cancelTcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(30+s+4);o[i]=we.GLOBAL_REQUEST,T(o,20,++i),o.utf8Write("cancel-tcpip-forward",i+=4,20),o[i+=20]=r===void 0||r===!0?1:0,T(o,s,++i),o.utf8Write(t,i+=4,s),T(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)"),Ie(this,this._packetRW.write.finalize(o))}openssh_streamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(41+r);i[s]=we.GLOBAL_REQUEST,T(i,31,++s),i.utf8Write("streamlocal-forward@openssh.com",s+=4,31),i[s+=31]=e===void 0||e===!0?1:0,T(i,r,++s),i.utf8Write(t,s+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)"),Ie(this,this._packetRW.write.finalize(i))}openssh_cancelStreamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(48+r);i[s]=we.GLOBAL_REQUEST,T(i,38,++s),i.utf8Write("cancel-streamlocal-forward@openssh.com",s+=4,38),i[s+=38]=e===void 0||e===!0?1:0,T(i,r,++s),i.utf8Write(t,s+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-streamlocal-forward@openssh.com)"),Ie(this,this._packetRW.write.finalize(i))}directTcpip(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(s.srcIP),o=Buffer.byteLength(s.dstIP),a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(33+i+4+4+o+4);c[a]=we.CHANNEL_OPEN,T(c,12,++a),c.utf8Write("direct-tcpip",a+=4,12),T(c,t,a+=12),T(c,e,a+=4),T(c,r,a+=4),T(c,o,a+=4),c.utf8Write(s.dstIP,a+=4,o),T(c,s.dstPort,a+=o),T(c,i,a+=4),c.utf8Write(s.srcIP,a+=4,i),T(c,s.srcPort,a+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-tcpip)`),Ie(this,this._packetRW.write.finalize(c))}openssh_directStreamLocal(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(s.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(51+i+4+4);a[o]=we.CHANNEL_OPEN,T(a,30,++o),a.utf8Write("direct-streamlocal@openssh.com",o+=4,30),T(a,t,o+=30),T(a,e,o+=4),T(a,r,o+=4),T(a,i,o+=4),a.utf8Write(s.socketPath,o+=4,i),Qg(a,0,o+=i,o+8),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-streamlocal@openssh.com)`),Ie(this,this._packetRW.write.finalize(a))}openssh_noMoreSessions(t){if(this._server)throw new Error("Client-only method called in server mode");let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(34);r[e]=we.GLOBAL_REQUEST,T(r,28,++e),r.utf8Write("no-more-sessions@openssh.com",e+=4,28),r[e+=28]=t===void 0||t===!0?1:0,this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)"),Ie(this,this._packetRW.write.finalize(r))}session(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(24);i[s]=we.CHANNEL_OPEN,T(i,7,++s),i.utf8Write("session",s+=4,7),T(i,t,s+=7),T(i,e,s+=4),T(i,r,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, session)`),Ie(this,this._packetRW.write.finalize(i))}windowChange(t,e,r,s,i){if(this._server)throw new Error("Client-only method called in server mode");let o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(39);a[o]=we.CHANNEL_REQUEST,T(a,t,++o),T(a,13,o+=4),a.utf8Write("window-change",o+=4,13),a[o+=13]=0,T(a,r,++o),T(a,e,o+=4),T(a,i,o+=4),T(a,s,o+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, window-change)`),Ie(this,this._packetRW.write.finalize(a))}pty(t,e,r,s,i,o,a,c){if(this._server)throw new Error("Client-only method called in server mode");(!o||!o.length)&&(o="vt100"),a&&!Buffer.isBuffer(a)&&!Array.isArray(a)&&typeof a=="object"&&a!==null&&(a=n0(a)),(!a||!a.length)&&(a=jg);let l=o.length,f=a.length,u=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(21+l+4+4+4+4+4+f);if(h[u]=we.CHANNEL_REQUEST,T(h,t,++u),T(h,7,u+=4),h.utf8Write("pty-req",u+=4,7),h[u+=7]=c===void 0||c===!0?1:0,T(h,l,++u),h.utf8Write(o,u+=4,l),T(h,r,u+=l),T(h,e,u+=4),T(h,i,u+=4),T(h,s,u+=4),T(h,f,u+=4),u+=4,Array.isArray(a))for(let p=0;p<f;++p)h[u++]=a[p];else Buffer.isBuffer(a)&&h.set(a,u);this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, pty-req)`),Ie(this,this._packetRW.write.finalize(h))}shell(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(15);s[r]=we.CHANNEL_REQUEST,T(s,t,++r),T(s,5,r+=4),s.utf8Write("shell",r+=4,5),s[r+=5]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, shell)`),Ie(this,this._packetRW.write.finalize(s))}exec(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(18+i);a[o]=we.CHANNEL_REQUEST,T(a,t,++o),T(a,4,o+=4),a.utf8Write("exec",o+=4,4),a[o+=4]=r===void 0||r===!0?1:0,T(a,i,++o),s?a.set(e,o+=4):a.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exec: ${e})`),Ie(this,this._packetRW.write.finalize(a))}signal(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=e;if(e=e.toUpperCase(),e.slice(0,3)==="SIG"&&(e=e.slice(3)),Ql[e]!==1)throw new Error(`Invalid signal: ${r}`);let s=e.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(20+s);o[i]=we.CHANNEL_REQUEST,T(o,t,++i),T(o,6,i+=4),o.utf8Write("signal",i+=4,6),o[i+=6]=0,T(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, signal: ${e})`),Ie(this,this._packetRW.write.finalize(o))}env(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=Buffer.isBuffer(r),a=o?r.length:Buffer.byteLength(r),c=this._packetRW.write.allocStart,l=this._packetRW.write.alloc(17+i+4+a);l[c]=we.CHANNEL_REQUEST,T(l,t,++c),T(l,3,c+=4),l.utf8Write("env",c+=4,3),l[c+=3]=s===void 0||s===!0?1:0,T(l,i,++c),l.utf8Write(e,c+=4,i),T(l,a,c+=i),o?l.set(r,c+=4):l.utf8Write(r,c+=4,a),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, env: ${e}=${r})`),Ie(this,this._packetRW.write.finalize(l))}x11Forward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=e.protocol,i=e.cookie,o=Buffer.isBuffer(s),a=o?s.length:Buffer.byteLength(s),c=Buffer.isBuffer(i),l=c?i.length:Buffer.byteLength(i),f=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(22+a+4+l+4);u[f]=we.CHANNEL_REQUEST,T(u,t,++f),T(u,7,f+=4),u.utf8Write("x11-req",f+=4,7),u[f+=7]=r===void 0||r===!0?1:0,u[++f]=e.single?1:0,T(u,a,++f),o?u.set(s,f+=4):u.utf8Write(s,f+=4,a),T(u,l,f+=a),c?u.set(i,f+=4):u.latin1Write(i,f+=4,l),T(u,e.screen||0,f+=l),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, x11-req)`),Ie(this,this._packetRW.write.finalize(u))}subsystem(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+s);o[i]=we.CHANNEL_REQUEST,T(o,t,++i),T(o,9,i+=4),o.utf8Write("subsystem",i+=4,9),o[i+=9]=r===void 0||r===!0?1:0,T(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, subsystem: ${e})`),Ie(this,this._packetRW.write.finalize(o))}openssh_agentForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(36);s[r]=we.CHANNEL_REQUEST,T(s,t,++r),T(s,26,r+=4),s.utf8Write("auth-agent-req@openssh.com",r+=4,26),s[r+=26]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, auth-agent-req@openssh.com)`),Ie(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,r=[];for(let o of t){let a=o.getPublicSSH();e+=4+a.length,r.push(a)}let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(35+e);i[s]=we.GLOBAL_REQUEST,T(i,29,++s),i.utf8Write("hostkeys-prove-00@openssh.com",s+=4,29),i[s+=29]=1,++s;for(let o of r)T(i,o.length,s),Ss(o,i,0,o.length,s+=4),s+=o.length;this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)"),Ie(this,this._packetRW.write.finalize(i))}serviceAccept(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);if(s[r]=we.SERVICE_ACCEPT,T(s,e,++r),s.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_ACCEPT (${t})`),Ie(this,this._packetRW.write.finalize(s)),this._server&&this._banner&&t==="ssh-userauth"){let i=this._banner;this._banner=void 0;let o=Buffer.byteLength(i);r=this._packetRW.write.allocStart;let a=this._packetRW.write.alloc(5+o+4);a[r]=we.USERAUTH_BANNER,T(a,o,++r),a.utf8Write(i,r+=4,o),T(a,0,r+=o),this._debug&&this._debug("Outbound: Sending USERAUTH_BANNER"),Ie(this,this._packetRW.write.finalize(a))}}forwardedTcpip(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.boundAddr),o=Buffer.byteLength(s.remoteAddr),a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(36+i+4+4+o+4);c[a]=we.CHANNEL_OPEN,T(c,15,++a),c.utf8Write("forwarded-tcpip",a+=4,15),T(c,t,a+=15),T(c,e,a+=4),T(c,r,a+=4),T(c,i,a+=4),c.utf8Write(s.boundAddr,a+=4,i),T(c,s.boundPort,a+=i),T(c,o,a+=4),c.utf8Write(s.remoteAddr,a+=4,o),T(c,s.remotePort,a+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-tcpip)`),Ie(this,this._packetRW.write.finalize(c))}x11(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.originAddr),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(24+i+4);a[o]=we.CHANNEL_OPEN,T(a,3,++o),a.utf8Write("x11",o+=4,3),T(a,t,o+=3),T(a,e,o+=4),T(a,r,o+=4),T(a,i,o+=4),a.utf8Write(s.originAddr,o+=4,i),T(a,s.originPort,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, x11)`),Ie(this,this._packetRW.write.finalize(a))}openssh_authAgent(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(39);i[s]=we.CHANNEL_OPEN,T(i,22,++s),i.utf8Write("auth-agent@openssh.com",s+=4,22),T(i,t,s+=22),T(i,e,s+=4),T(i,r,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, auth-agent@openssh.com)`),Ie(this,this._packetRW.write.finalize(i))}openssh_forwardedStreamLocal(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(54+i+4);a[o]=we.CHANNEL_OPEN,T(a,33,++o),a.utf8Write("forwarded-streamlocal@openssh.com",o+=4,33),T(a,t,o+=33),T(a,e,o+=4),T(a,r,o+=4),T(a,i,o+=4),a.utf8Write(s.socketPath,o+=4,i),T(a,0,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-streamlocal@openssh.com)`),Ie(this,this._packetRW.write.finalize(a))}exitStatus(t,e){if(!this._server)throw new Error("Server-only method called in client mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(25);s[r]=we.CHANNEL_REQUEST,T(s,t,++r),T(s,11,r+=4),s.utf8Write("exit-status",r+=4,11),s[r+=11]=0,T(s,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-status: ${e})`),Ie(this,this._packetRW.write.finalize(s))}exitSignal(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let 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)),Ql[o]!==1)throw new Error(`Invalid signal: ${i}`);let a=Buffer.byteLength(o),c=s?Buffer.byteLength(s):0,l=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(25+a+1+4+c+4);f[l]=we.CHANNEL_REQUEST,T(f,t,++l),T(f,11,l+=4),f.utf8Write("exit-signal",l+=4,11),f[l+=11]=0,T(f,a,++l),f.utf8Write(o,l+=4,a),f[l+=a]=r?1:0,T(f,c,++l),l+=4,c&&(f.utf8Write(s,l,c),l+=c),T(f,0,l),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-signal: ${e})`),Ie(this,this._packetRW.write.finalize(f))}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 r;if(typeof t=="boolean"&&(e=t,t=void 0),t){r=[];for(let a=0;a<t.length;++a)t[a].toLowerCase()!=="none"&&r.push(t[a]);r=r.join(",")}else r="";let s=r.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+s+1);o[i]=we.USERAUTH_FAILURE,T(o,s,++i),o.utf8Write(r,i+=4,s),o[i+=s]=e===!0?1:0,this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_FAILURE"),Ie(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");let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=we.USERAUTH_SUCCESS,this._authsQueue.shift(),this._authenticated=!0,this._debug&&this._debug("Outbound: Sending USERAUTH_SUCCESS"),Ie(this,this._packetRW.write.finalize(e)),this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.read=new Xl),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new Jl(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');let r=Buffer.byteLength(t),s=e.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+r+4+s);o[i]=we.USERAUTH_PK_OK,T(o,r,++i),o.utf8Write(t,i+=4,r),T(o,s,i+=r),o.set(e,i+=4),this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_PK_OK"),Ie(this,this._packetRW.write.finalize(o))}authPasswdChg(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4);s[r]=we.USERAUTH_PASSWD_CHANGEREQ,T(s,e,++r),s.utf8Write(t,r+=4,e),T(s,0,r+=e),this._debug&&this._debug("Outbound: Sending USERAUTH_PASSWD_CHANGEREQ"),Ie(this,this._packetRW.write.finalize(s))}authInfoReq(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let s=0,i=t?Buffer.byteLength(t):0,o=e?Buffer.byteLength(e):0;for(let l=0;l<r.length;++l)s+=4+Buffer.byteLength(r[l].prompt)+1;let a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(5+i+4+o+4+4+s);c[a]=we.USERAUTH_INFO_REQUEST,T(c,i,++a),a+=4,t&&(c.utf8Write(t,a,i),a+=i),T(c,o,a),a+=4,e&&(c.utf8Write(e,a,o),a+=o),T(c,0,a),T(c,r.length,a+=4),a+=4;for(let l=0;l<r.length;++l){let f=r[l],u=Buffer.byteLength(f.prompt);T(c,u,a),a+=4,u&&(c.utf8Write(f.prompt,a,u),a+=u),c[a++]=f.echo?1:0}this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_REQUEST"),Ie(this,this._packetRW.write.finalize(c))}},Xg=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function Jg(n,t,e){let r,s;this._buffer?(r=Buffer.allocUnsafe(this._buffer.length+(e-t)),r.set(this._buffer,0),t===0?r.set(n,this._buffer.length):r.set(new Uint8Array(n.buffer,n.byteOffset+t,e-t),this._buffer.length),s=this._buffer.length,t=0):(r=n,s=0);let i=t,o=t,a=t,c=!1,l=0,f=0;for(;t<r.length;++t){let u=r[t];if(u===13){c=!0;continue}if(u===10){if(a>o&&a-o>4&&r[o]===83&&r[o+1]===83&&r[o+2]===72&&r[o+3]===45){let h=r.latin1Slice(i,a+1),p=o===i?h:h.slice(o-i),y=Xg.exec(p);if(!y)throw new Error("Invalid identification string");let _={greeting:o===i?"":h.slice(0,o-i),identRaw:p,versions:{protocol:y[1],software:y[2]},comments:y[3]};return this._remoteIdentRaw=Buffer.from(p),this._debug&&this._debug(`Remote ident: ${Gl(p)}`),this._compatFlags=t0(_),this._buffer=void 0,this._decipher=new $g(0,Fg.bind(this,{firstPacket:!0})),this._parse=Zg,this._onHeader(_),this._destruct?(Yl(this),t+1-s):e}if(this._server)throw new Error("Greetings from clients not permitted");if(++f>Yg)throw new Error("Max greeting lines exceeded");c=!1,o=t+1,l=0}else{if(c)throw new Error("Invalid header: expected newline");if(++l>=zg)throw new Error("Header line too long")}a=t}return this._buffer||(this._buffer=jl(r,i)),t-s}function Zg(n,t,e){return this._decipher.decrypt(n,t,e)}function e0(n){if(this._onPacket(),n.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}n=this._packetRW.read.read(n);let t=n[0];t===we.USERAUTH_SUCCESS&&!this._server&&!this._authenticated&&(this._authenticated=!0,this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.write=new Jl(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new Xl));let e=Hg[t];if(e===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${t}`);return}return e(this,n)}function t0(n){let t=n.versions.software,e=0;for(let r of Dg)typeof r[0]=="string"?t===r[0]&&(e|=r[1]):r[0].test(t)&&(e|=r[1]);return e}function n0(n){let t=Object.keys(n),e=Buffer.allocUnsafe(5*t.length+1),r=0;for(let s=0;s<t.length;++s){let i=t[s];if(i==="TTY_OP_END")continue;let o=ya[i];if(o===void 0)continue;let a=n[i];typeof a=="number"&&isFinite(a)&&(e[r++]=o,e[r++]=a>>>24,e[r++]=a>>>16,e[r++]=a>>>8,e[r++]=a)}return e[r++]=ya.TTY_OP_END,r<e.length?jl(e,0,r):e}function r0(n){let t="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";Ug&&(t=`ssh-ed25519,${t}`);let e=Buffer.byteLength(t),r=n._packetRW.write.allocStart,s=n._packetRW.write.alloc(28+e);s[r]=we.EXT_INFO,T(s,1,++r),T(s,15,r+=4),s.utf8Write("server-sig-algs",r+=4,15),T(s,e,r+=15),s.utf8Write(t,r+=4,e),n._debug&&n._debug("Outbound: Sending EXT_INFO"),Ie(n,n._packetRW.write.finalize(s))}ef.exports=_a});var af=ct(Si=>{"use strict";var ws=require("assert"),{inspect:i0}=require("util");function tf(n){let t="",e=n.length,r=n[0]==="-"?1:0;for(;e>=r+4;e-=3)t=`_${n.slice(e-3,e)}${t}`;return`${n.slice(0,e)}${t}`}function nf(n,t){if(ws(typeof t=="string","`thing` has to be of type string"),Array.isArray(n)){let e=n.length;return ws(e>0,"At least one expected value needs to be specified"),n=n.map(r=>String(r)),e>2?`one of ${t} ${n.slice(0,e-1).join(", ")}, or `+n[e-1]:e===2?`one of ${t} ${n[0]} or ${n[1]}`:`of ${t} ${n[0]}`}return`of ${t} ${String(n)}`}Si.ERR_INTERNAL_ASSERTION=class sf extends Error{constructor(t){super(),Error.captureStackTrace(this,sf);let e=`This is caused by either a bug in ssh2 or incorrect usage of ssh2 internals.
|
|
12
13
|
Please open an issue with this stack trace at https://github.com/mscdex/ssh2/issues
|
|
13
14
|
`;this.message=t===void 0?e:`${t}
|
|
14
|
-
${e}`}};var s0=2**32,rf=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();Si.ERR_OUT_OF_RANGE=class of extends RangeError{constructor(t,e,r,s){super(),Error.captureStackTrace(this,of),ws(e,'Missing "range" argument');let i=s?t:`The value of "${t}" is out of range.`,o;Number.isInteger(r)&&Math.abs(r)>s0?o=tf(String(r)):typeof r=="bigint"?(o=String(r),(r>rf||r<-rf)&&(o=tf(o)),o+="n"):o=i0(r),i+=` It must be ${e}. Received ${o}`,this.message=i}};var Is=class n extends TypeError{constructor(t,e,r){super(),Error.captureStackTrace(this,n),ws(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} ${nf(e,"type")}`;else{let o=t.includes(".")?"property":"argument";i=`The "${t}" ${o} ${s} ${nf(e,"type")}`}i+=`. Received type ${typeof r}`,this.message=i}};Si.ERR_INVALID_ARG_TYPE=Is;Si.validateNumber=function(t,e){if(typeof t!="number")throw new Is(e,"number",t)}});var wi=ct((s_,Ef)=>{"use strict";var o0=require("events"),Yn=require("fs"),{constants:en}=Yn,{Readable:hf,Writable:Ba}=require("stream"),{inherits:pf,types:{isDate:Sa}}=require("util"),a0=Buffer[Symbol.species],{bufferCopy:zn,bufferSlice:Mr,makeBufferParser:c0,writeUInt32BE:V}=mn(),Un={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},Ne=Buffer.alloc(28),tt={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},l0=new Map(Object.values(tt).map(n=>[n,1])),f0={[tt.OK]:"No error",[tt.EOF]:"End of file",[tt.NO_SUCH_FILE]:"No such file or directory",[tt.PERMISSION_DENIED]:"Permission denied",[tt.FAILURE]:"Failure",[tt.BAD_MESSAGE]:"Bad message",[tt.NO_CONNECTION]:"No connection",[tt.CONNECTION_LOST]:"Connection lost",[tt.OP_UNSUPPORTED]:"Operation unsupported"},Be={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},tn={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},Ce={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},cf=2*1024,ut=2**32-1,u0=Buffer.from([0,0,0,5,Be.INIT,0,0,0,3]),d0=Buffer.from([0,0,0,5,tn.VERSION,0,0,0,3]),h0=/^SSH-2.0-(?:OpenSSH|dropbear)/,ba=256*1024,M=c0(),p0={readable:!1,writable:!1,push:n=>{},once:()=>{},on:()=>{},emit:()=>{},end:()=>{}};function gf(){}var wa=class extends o0{constructor(t,e,r){super(),(typeof r!="object"||!r)&&(r={});let s=t._protocol._remoteIdentRaw;this.server=!!r.server,this._debug=typeof r.debug=="function"?r.debug:void 0,this._isOpenSSH=s&&h0.test(s),this._version=-1,this._extensions={},this._biOpt=r.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=ba,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?ba:34e3)-cf,this._maxWriteLen=(this._isOpenSSH?ba:34e3)-cf,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=p0,this.readable=!0}push(t){if(t===null){if(_f(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 st(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return st(this,`Packet length ${this._pktLen} exceeds max length of ${a}`)}if(e>=t.length)return}if(this._pktPos<this._pktLen){let o=Math.min(this._pktLen-this._pktPos,t.length-e);if(e!==0||o!==t.length?o===this._pktLen?this._pkt=new a0(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}let r=this._pkt[0],s=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let i=this.server?_0[r]:y0[r];if(!i)return st(this,`Unknown packet type ${r}`);if(this._version===-1){if(this.server){if(r!==Be.INIT)return st(this,`Expected INIT packet, got ${r}`)}else if(r!==tn.VERSION)return st(this,`Expected VERSION packet, got ${r}`)}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=gf,this.server||Je(this,u0)}createReadStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new On(this,t,e)}createWriteStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new gn(this,t,e)}open(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(s=r,r=void 0);let i=typeof e=="number"?e:Af(e);if(i===null)throw new Error(`Unknown flags string: ${e}`);let o=0,a=0;(typeof r=="string"||typeof r=="number")&&(r={mode:r}),typeof r=="object"&&r!==null&&(r=ur(r),o=r.flags,a=r.nb);let c=Buffer.byteLength(t),l=9,f=Buffer.allocUnsafe(13+c+4+4+a);V(f,f.length-4,0),f[4]=Be.OPEN;let u=this._writeReqid=this._writeReqid+1&ut;V(f,u,5),V(f,c,l),f.utf8Write(t,l+=4,c),V(f,i,l+=c),V(f,o,l+=4),a&&(l+=4,a===Ne.length?f.set(Ne,l):zn(Ne,f,0,a,l),l+=a),this._requests[u]={cb:s};let h=Je(this,f);this._debug&&this._debug(`SFTP: Outbound: ${h?"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");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.CLOSE;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} CLOSE`)}read(t,e,r,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(r>=e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");mf(this,t,e,r,s,i,o)}readData(t,e,r,s,i,o){this.read(t,e,r,s,i,o)}write(t,e,r,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(r>e.length)throw new Error("offset is out of bounds");if(r+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}let a=this._maxWriteLen,c=Math.max(s-a,0),l=i;c&&(s=a);let f=t.length,u=9,h=Buffer.allocUnsafe(13+f+8+4+s);V(h,h.length-4,0),h[4]=Be.WRITE;let p=this._writeReqid=this._writeReqid+1&ut;V(h,p,5),V(h,f,u),h.set(t,u+=4),u+=f;for(let _=7;_>=0;--_)h[u+_]=i&255,i/=256;V(h,s,u+=8),zn(e,h,r,r+s,u+=4),this._requests[p]={cb:_=>{_?typeof o=="function"&&o(_):c?this.write(t,e,r+s,c,l+s,o):typeof o=="function"&&o(void 0,r+s)}};let y=Je(this,h);if(this._debug){let _=y?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${_} WRITE (id:${p})`)}}writeData(t,e,r,s,i,o){this.write(t,e,r,s,i,o)}fastGet(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");lf(this,Yn,t,e,r,s)}fastPut(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");lf(Yn,this,t,e,r,s)}readFile(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof r=="function"?s=r: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");let i=e.encoding;if(i&&!Buffer.isEncoding(i))throw new Error(`Unknown encoding: ${i}`);let o,a,c,l=0,f,u=0,h=e.flag||"r",p=()=>{o===0?(a=Buffer.allocUnsafe(8192),this.read(f,a,0,8192,u,y)):this.read(f,a,l,o-l,u,y)},y=(x,S)=>{let R;if(x){if(R=x.code===tt.EOF,!R)return this.close(f,()=>s&&s(x))}else R=!1;if(R||o===0&&S===0)return _();u+=S,l+=S,o!==0?l===o?_():p():(c.push(Mr(a,0,S)),p())};y._wantEOFError=!0;let _=()=>{this.close(f,x=>(o===0?a=Buffer.concat(c,l):l<o&&(a=Mr(a,0,l)),i&&(a=a.toString(i)),s&&s(x,a)))};this.open(t,h,438,(x,S)=>{if(x)return s&&s(x);f=S;let R=(H,C)=>{if(H){this.stat(t,(U,Q)=>{if(U)return this.close(f,()=>{s&&s(H)});R(null,Q)});return}if(o=C.size||0,o===0)return c=[],p();a=Buffer.allocUnsafe(o),p()};this.fstat(f,R)})}writeFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"w"};else if(!r)r={encoding:"utf8",mode:438,flag:"w"};else if(typeof r!="object")throw new TypeError("Bad arguments");if(r.encoding&&!Buffer.isEncoding(r.encoding))throw new Error(`Unknown encoding: ${r.encoding}`);let o=r.flag||"w";this.open(t,o,r.mode,(a,c)=>{if(a)i&&i(a);else{let l=Buffer.isBuffer(e)?e:Buffer.from(""+e,r.encoding||"utf8"),f=/a/.test(o)?null:0;if(f===null){let u=(h,p)=>{if(h){this.stat(t,(y,_)=>{if(y)return this.close(c,()=>{i&&i(h)});u(null,_)});return}Ia(this,c,l,0,l.length,p.size,i)};this.fstat(c,u);return}Ia(this,c,l,0,l.length,f,i)}})}appendFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"a"};else if(!r)r={encoding:"utf8",mode:438,flag:"a"};else if(typeof r!="object")throw new TypeError("Bad arguments");r.flag||(r=Object.assign({flag:"a"},r)),this.writeFile(t,e,r,i)}exists(t,e){if(this.server)throw new Error("Client-only method called in server mode");this.stat(t,r=>{e&&e(!r)})}unlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.REMOVE;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REMOVE`)}rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=9,a=Buffer.allocUnsafe(13+s+4+i);V(a,a.length-4,0),a[4]=Be.RENAME;let c=this._writeReqid=this._writeReqid+1&ut;V(a,c,5),V(a,s,o),a.utf8Write(t,o+=4,s),V(a,i,o+=s),a.utf8Write(e,o+=4,i),this._requests[c]={cb:r};let l=Je(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} RENAME`)}mkdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="function"&&(r=e,e=void 0),typeof e=="object"&&e!==null&&(e=ur(e),s=e.flags,i=e.nb);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);V(c,c.length-4,0),c[4]=Be.MKDIR;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,o,a),c.utf8Write(t,a+=4,o),V(c,s,a+=o),i&&(a+=4,i===Ne.length?c.set(Ne,a):zn(Ne,c,0,i,a),a+=i),this._requests[l]={cb:r};let f=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} MKDIR`)}rmdir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.RMDIR;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} RMDIR`)}readdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");typeof e=="function"&&(r=e,e={}),(typeof e!="object"||e===null)&&(e={});let s=!(e&&e.full);if(!Buffer.isBuffer(t)&&typeof t!="string")throw new Error("missing directory handle or path");if(typeof t=="string"){let f=[],u=0,h=(p,y)=>{if(p)return r(p);this.readdir(y,e,(_,x)=>{let S=_&&_.code===tt.EOF;if(_&&!S)return this.close(y,()=>r(_));if(S)return this.close(y,R=>{if(R)return r(R);r(void 0,f)});for(let R=0;R<x.length;++R,++u)f[u]=x[R];h(void 0,y)})};return this.opendir(t,h)}let i=t.length,o=9,a=Buffer.allocUnsafe(13+i);V(a,a.length-4,0),a[4]=Be.READDIR;let c=this._writeReqid=this._writeReqid+1&ut;V(a,c,5),V(a,i,o),a.set(t,o+=4),this._requests[c]={cb:s?(f,u)=>{if(typeof r=="function"){if(f)return r(f);for(let h=u.length-1;h>=0;--h)(u[h].filename==="."||u[h].filename==="..")&&u.splice(h,1);r(void 0,u)}}:r};let l=Je(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"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");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.FSTAT;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} FSTAT`)}stat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.STAT;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STAT`)}lstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.LSTAT;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} LSTAT`)}opendir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.OPENDIR;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} OPENDIR`)}setstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="object"&&e!==null?(e=ur(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);V(c,c.length-4,0),c[4]=Be.SETSTAT;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,o,a),c.utf8Write(t,a+=4,o),V(c,s,a+=o),i&&(a+=4,i===Ne.length?c.set(Ne,a):zn(Ne,c,0,i,a),a+=i),this._requests[l]={cb:r};let f=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} SETSTAT`)}fsetstat(t,e,r){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=ur(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=t.length,a=9,c=Buffer.allocUnsafe(13+o+4+i);V(c,c.length-4,0),c[4]=Be.FSETSTAT;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,o,a),c.set(t,a+=4),V(c,s,a+=o),i&&(a+=4,i===Ne.length?c.set(Ne,a):zn(Ne,c,0,i,a),a+=i),this._requests[l]={cb:r};let f=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} FSETSTAT`)}futimes(t,e,r,s){return this.fsetstat(t,{atime:Ur(e),mtime:Ur(r)},s)}utimes(t,e,r,s){return this.setstat(t,{atime:Ur(e),mtime:Ur(r)},s)}fchown(t,e,r,s){return this.fsetstat(t,{uid:e,gid:r},s)}chown(t,e,r,s){return this.setstat(t,{uid:e,gid:r},s)}fchmod(t,e,r){return this.fsetstat(t,{mode:e},r)}chmod(t,e,r){return this.setstat(t,{mode:e},r)}readlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.READLINK;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing link info"));e(void 0,l[0].filename)}}};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} READLINK`)}symlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=Buffer.byteLength(t),o=9,a=Buffer.allocUnsafe(13+s+4+i);V(a,a.length-4,0),a[4]=Be.SYMLINK;let c=this._writeReqid=this._writeReqid+1&ut;V(a,c,5),this._isOpenSSH?(V(a,i,o),a.utf8Write(t,o+=4,i),V(a,s,o+=i),a.utf8Write(e,o+=4,s)):(V(a,s,o),a.utf8Write(e,o+=4,s),V(a,i,o+=s),a.utf8Write(t,o+=4,i)),this._requests[c]={cb:r};let l=Je(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} SYMLINK`)}realpath(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.REALPATH;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing path info"));e(void 0,l[0].filename)}}};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=this._extensions["posix-rename@openssh.com"];if(!s||s!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(41+i+4+o);V(c,c.length-4,0),c[4]=Be.EXTENDED;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,24,a),c.utf8Write("posix-rename@openssh.com",a+=4,24),V(c,i,a+=24),c.utf8Write(t,a+=4,i),V(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[l]={cb:r};let f=Je(this,c);if(this._debug){let u=f?"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");let r=this._extensions["statvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(36+s);V(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,19,i),o.utf8Write("statvfs@openssh.com",i+=4,19),V(o,s,i+=19),o.utf8Write(t,i+=4,s),this._requests[a]={extended:"statvfs@openssh.com",cb:e};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} statvfs@openssh.com`)}}ext_openssh_fstatvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["fstatvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(37+s);V(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,20,i),o.utf8Write("fstatvfs@openssh.com",i+=4,20),V(o,s,i+=20),o.set(t,i+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:e};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} fstatvfs@openssh.com`)}}ext_openssh_hardlink(t,e,r){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");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(37+i+4+o);V(c,c.length-4,0),c[4]=Be.EXTENDED;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,20,a),c.utf8Write("hardlink@openssh.com",a+=4,20),V(c,i,a+=20),c.utf8Write(t,a+=4,i),V(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[l]={cb:r};let f=Je(this,c);if(this._debug){let u=f?"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");let s=t.length,i=9,o=Buffer.allocUnsafe(34+s);V(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,17,i),o.utf8Write("fsync@openssh.com",i+=4,17),V(o,s,i+=17),o.set(t,i+=4),this._requests[a]={cb:e};let c=Je(this,o);this._debug&&this._debug(`SFTP: Outbound: ${c?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(t,e,r){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=ur(e),i=e.flags,o=e.nb):typeof e=="function"&&(r=e);let a=Buffer.byteLength(t),c=9,l=Buffer.allocUnsafe(37+a+4+o);V(l,l.length-4,0),l[4]=Be.EXTENDED;let f=this._writeReqid=this._writeReqid+1&ut;V(l,f,5),V(l,20,c),l.utf8Write("lsetstat@openssh.com",c+=4,20),V(l,a,c+=20),l.utf8Write(t,c+=4,a),V(l,i,c+=a),o&&(c+=4,o===Ne.length?l.set(Ne,c):zn(Ne,l,0,o,c),c+=o),this._requests[f]={cb:r};let u=Je(this,l);if(this._debug){let h=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} 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");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(40+s);V(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,23,i),o.utf8Write("expand-path@openssh.com",i+=4,23),V(o,s,i+=20),o.utf8Write(t,i+=4,s),this._requests[a]={cb:(l,f)=>{if(typeof e=="function"){if(l)return e(l);if(!f||!f.length)return e(new Error("Response missing expanded path"));e(void 0,f[0].filename)}}};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} expand-path@openssh.com`)}}ext_copy_data(t,e,r,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,l=Buffer.allocUnsafe(26+t.length+8+8+4+s.length+8);V(l,l.length-4,c),c+=4,l[c]=Be.EXTENDED,++c;let f=this._writeReqid=this._writeReqid+1&ut;V(l,f,c),c+=4,V(l,9,c),c+=4,l.utf8Write("copy-data",c,9),c+=9,V(l,t.length,c),c+=4,l.set(t,c),c+=t.length;for(let h=7;h>=0;--h)l[c+h]=e&255,e/=256;c+=8;for(let h=7;h>=0;--h)l[c+h]=r&255,r/=256;c+=8,V(l,s.length,c),c+=4,l.set(s,c),c+=s.length;for(let h=7;h>=0;--h)l[c+h]=i&255,i/=256;this._requests[f]={cb:o};let u=Je(this,l);if(this._debug){let h=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} 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,i=Buffer.byteLength(t),o=Buffer.allocUnsafe(31+i);V(o,o.length-4,s),s+=4,o[s]=Be.EXTENDED,++s;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,s),s+=4,V(o,14,s),s+=4,o.utf8Write("home-directory",s,14),s+=14,V(o,i,s),s+=4,o.utf8Write(t,s,i),s+=i,this._requests[a]={cb:(l,f)=>{if(typeof e=="function"){if(l)return e(l);if(!f||!f.length)return e(new Error("Response missing home directory"));e(void 0,f[0].filename)}}};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} home-directory`)}}ext_users_groups(t,e,r){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(let l of t)if(!Number.isInteger(l)||l<0||l>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(let l of e)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let i=0,o=Buffer.allocUnsafe(47+4*t.length+4+4*e.length);V(o,o.length-4,i),i+=4,o[i]=Be.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,i),i+=4,V(o,30,i),i+=4,o.utf8Write("users-groups-by-id@openssh.com",i,30),i+=30,V(o,4*t.length,i),i+=4;for(let l of t)V(o,l,i),i+=4;V(o,4*e.length,i),i+=4;for(let l of e)V(o,l,i),i+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:r};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} 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");let r=e.length;if(r>256)throw new Error("handle too large (> 256 bytes)");let s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=tn.HANDLE,V(i,t,5),V(i,r,s),r&&i.set(e,s+=4);let o=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${o?"Buffered":"Sending"} HANDLE`)}status(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!l0.has(e))throw new Error(`Bad status code: ${e}`);r||(r="");let s=Buffer.byteLength(r),i=9,o=Buffer.allocUnsafe(17+s+4);V(o,o.length-4,0),o[4]=tn.STATUS,V(o,t,5),V(o,e,i),V(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),V(o,0,i);let a=Je(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STATUS`)}data(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");let s=Buffer.isBuffer(e);if(!s&&typeof e!="string")throw new Error("data is not a Buffer or string");let i;!s&&!r&&(r=void 0,i=!0);let o=s?e.length:Buffer.byteLength(e,r),a=9,c=Buffer.allocUnsafe(13+o);V(c,c.length-4,0),c[4]=tn.DATA,V(c,t,5),V(c,o,a),o&&(s?c.set(e,a+=4):i?c.utf8Write(e,a+=4,o):c.write(e,a+=4,o,r));let l=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"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]}let r=e.length,s=0,i,o=[];for(let f=0;f<r;++f){let u=e[f],h=!u||!u.filename||typeof u.filename!="string"?"":u.filename;s+=4+Buffer.byteLength(h);let p=!u||!u.longname||typeof u.longname!="string"?"":u.longname;if(s+=4+Buffer.byteLength(p),typeof u.attrs=="object"&&u.attrs!==null){if(i=ur(u.attrs),s+=4+i.nb,i.nb){let y;i.nb===Ne.length?y=new Uint8Array(Ne):(y=new Uint8Array(i.nb),zn(Ne,y,0,i.nb,0)),i.bytes=y}o.push(i)}else s+=4,o.push(null)}let a=9,c=Buffer.allocUnsafe(13+s);V(c,c.length-4,0),c[4]=tn.NAME,V(c,t,5),V(c,r,a),a+=4;for(let f=0;f<r;++f){let u=e[f];{let p=!u||!u.filename||typeof u.filename!="string"?"":u.filename,y=Buffer.byteLength(p);V(c,y,a),a+=4,y&&(c.utf8Write(p,a,y),a+=y)}{let p=!u||!u.longname||typeof u.longname!="string"?"":u.longname,y=Buffer.byteLength(p);V(c,y,a),a+=4,y&&(c.utf8Write(p,a,y),a+=y)}let h=o[f];h?(V(c,h.flags,a),a+=4,h.flags&&h.bytes&&(c.set(h.bytes,a),a+=h.nb)):(V(c,0,a),a+=4)}let l=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"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=ur(e);let r=e.flags,s=e.nb,i=9,o=Buffer.allocUnsafe(13+s);V(o,o.length-4,0),o[4]=tn.ATTRS,V(o,t,5),V(o,r,i),s&&(i+=4,s===Ne.length?o.set(Ne,i):zn(Ne,o,0,s,i),i+=s);let a=Je(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function g0(n){try{return Buffer.allocUnsafe(n)}catch(t){return t}}function mf(n,t,e,r,s,i,o,a){let c=n._maxReadLen,l=Math.max(s-c,0);l&&(s=c);let f=t.length,u=9,h=i,p=Buffer.allocUnsafe(13+f+8+4);V(p,p.length-4,0),p[4]=Be.READ;let y=n._writeReqid=n._writeReqid+1&ut;V(p,y,5),V(p,f,u),p.set(t,u+=4),u+=f;for(let S=7;S>=0;--S)p[u+S]=h&255,h/=256;V(p,s,u+=8),typeof o!="function"&&(o=gf);let _=a||{nb:0,position:i,off:r,origOff:r,len:void 0,overflow:void 0,cb:(S,R,H)=>{let C=_.len,U=_.overflow;if(S){if(o._wantEOFError||S.code!==tt.EOF)return o(S)}else{if(H>C)return o(new Error("Received more data than requested"));if(H===C&&U){_.nb+=H,_.position+=H,_.off+=H,mf(n,t,e,_.off,U,_.position,o,_);return}}H=H||0,_.origOff===0&&e.length===_.nb?R=e:R=Mr(e,_.origOff,_.origOff+_.nb+H),o(void 0,_.nb+H,R,_.position)},buffer:void 0};_.len=s,_.overflow=l,_.buffer=Mr(e,r,r+s),n._requests[y]=_;let x=Je(n,p);n._debug&&n._debug(`SFTP: Outbound: ${x?"Buffered":"Sending"} READ`)}function lf(n,t,e,r,s,i){let o=64,a=32768,c,l,f;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)&&(a=s.chunkSize),typeof s.fileSize=="number"&&s.fileSize>0&&!isNaN(s.fileSize)&&(f=s.fileSize),typeof s.step=="function"&&(c=s.step),(typeof s.mode=="string"||typeof s.mode=="number")&&(l=Ra(s.mode)));let u,h=0,p=0,y=!1,_,x,S,R=a*o;function H(C){if(y)return;y=!0;let U=0,Q;_||x?(Q=()=>{--U===0&&i(C)},_&&(n===Yn||n.outgoing.state==="open")&&++U,x&&(t===Yn||t.outgoing.state==="open")&&++U,_&&(n===Yn||n.outgoing.state==="open")&&n.close(_,Q),x&&(t===Yn||t.outgoing.state==="open")&&t.close(x,Q)):i(C)}n.open(e,"r",(C,U)=>{if(C)return H(C);_=U,f===void 0?n.fstat(_,Q):Q(null,{size:f});function Q(B,b){if(B){if(n!==Yn){n.stat(e,(w,k)=>{if(w)return H(B);Q(null,k)});return}return H(B)}u=b.size,t.open(r,"w",(w,k)=>{if(w)return H(w);if(x=k,u<=0)return H();for(;R>u;){if(o===1){R=u;break}R-=a,--o}if(S=g0(R),S instanceof Error)return H(S);l!==void 0?t.fchmod(x,l,function Y(te){if(te){t.chmod(r,l,le=>Y());return}z()}):z();function v(Y,te,le,O,N,L){if(Y)return H(Y);N=N||0,t.write(x,S,N,te,O,K);function K(ee){if(ee)return H(ee);if(p+=te,c&&c(p,te,u),te<L)return ne(N,O+te,L-te);if(p===u){t.close(x,ie=>{if(x=void 0,ie)return H(ie);n.close(_,je=>{if(_=void 0,je)return H(je);i()})});return}if(h>=u)return;let ue=h+a>u?u-h:a;ne(N,h,ue),h+=ue}}function P(Y,te,le){return(O,N,L)=>{v(O,N,L,te,Y,le)}}function ne(Y,te,le){n.read(_,S,Y,le,te,P(Y,te,le))}function z(){let Y=0,te=0;for(;h<u&&Y<o;){let le=h+a>u?u-h:a;ne(te,h,le),te+=le,h+=le,++Y}}})}})}function Ia(n,t,e,r,s,i,o){let a=typeof o=="function"?o:void 0;n.write(t,e,r,s,i,(c,l)=>{if(c)return n.close(t,()=>{a&&a(c)});l===s?n.close(t,a):(r+=l,s-=l,i+=l,Ia(n,t,e,r,s,i,a))})}var ks=class{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&en.S_IFMT)===en.S_IFDIR}isFile(){return(this.mode&en.S_IFMT)===en.S_IFREG}isBlockDevice(){return(this.mode&en.S_IFMT)===en.S_IFBLK}isCharacterDevice(){return(this.mode&en.S_IFMT)===en.S_IFCHR}isSymbolicLink(){return(this.mode&en.S_IFMT)===en.S_IFLNK}isFIFO(){return(this.mode&en.S_IFMT)===en.S_IFIFO}isSocket(){return(this.mode&en.S_IFMT)===en.S_IFSOCK}};function ur(n){let t=0,e=0;if(typeof n=="object"&&n!==null){if(typeof n.size=="number"){t|=Un.SIZE;let r=n.size;Ne[e++]=r/72057594037927940,Ne[e++]=r/281474976710656,Ne[e++]=r/1099511627776,Ne[e++]=r/4294967296,Ne[e++]=r/16777216,Ne[e++]=r/65536,Ne[e++]=r/256,Ne[e++]=r}if(typeof n.uid=="number"&&typeof n.gid=="number"){t|=Un.UIDGID;let r=n.uid,s=n.gid;Ne[e++]=r>>>24,Ne[e++]=r>>>16,Ne[e++]=r>>>8,Ne[e++]=r,Ne[e++]=s>>>24,Ne[e++]=s>>>16,Ne[e++]=s>>>8,Ne[e++]=s}if(typeof n.mode=="number"||typeof n.mode=="string"){let r=Ra(n.mode);t|=Un.PERMISSIONS,Ne[e++]=r>>>24,Ne[e++]=r>>>16,Ne[e++]=r>>>8,Ne[e++]=r}if((typeof n.atime=="number"||Sa(n.atime))&&(typeof n.mtime=="number"||Sa(n.mtime))){let r=Ur(n.atime),s=Ur(n.mtime);t|=Un.ACMODTIME,Ne[e++]=r>>>24,Ne[e++]=r>>>16,Ne[e++]=r>>>8,Ne[e++]=r,Ne[e++]=s>>>24,Ne[e++]=s>>>16,Ne[e++]=s>>>8,Ne[e++]=s}}return{flags:t,nb:e}}function Ur(n){if(typeof n=="number"&&n===n)return n;if(Sa(n))return parseInt(n.getTime()/1e3,10);throw new Error(`Cannot parse time: ${n}`)}function Ra(n){if(typeof n=="number"&&n===n)return n;if(typeof n=="string")return Ra(parseInt(n,8));throw new Error(`Cannot parse mode: ${n}`)}var Ca={r:Ce.READ,"r+":Ce.READ|Ce.WRITE,w:Ce.TRUNC|Ce.CREAT|Ce.WRITE,wx:Ce.TRUNC|Ce.CREAT|Ce.WRITE|Ce.EXCL,xw:Ce.TRUNC|Ce.CREAT|Ce.WRITE|Ce.EXCL,"w+":Ce.TRUNC|Ce.CREAT|Ce.READ|Ce.WRITE,"wx+":Ce.TRUNC|Ce.CREAT|Ce.READ|Ce.WRITE|Ce.EXCL,"xw+":Ce.TRUNC|Ce.CREAT|Ce.READ|Ce.WRITE|Ce.EXCL,a:Ce.APPEND|Ce.CREAT|Ce.WRITE,ax:Ce.APPEND|Ce.CREAT|Ce.WRITE|Ce.EXCL,xa:Ce.APPEND|Ce.CREAT|Ce.WRITE|Ce.EXCL,"a+":Ce.APPEND|Ce.CREAT|Ce.READ|Ce.WRITE,"ax+":Ce.APPEND|Ce.CREAT|Ce.READ|Ce.WRITE|Ce.EXCL,"xa+":Ce.APPEND|Ce.CREAT|Ce.READ|Ce.WRITE|Ce.EXCL};function Af(n){let t=Ca[n];return t!==void 0?t:null}var m0=(()=>{let n=Object.keys(Ca);return t=>{for(let e=0;e<n.length;++e){let r=n[e];if(Ca[r]===t)return r}return null}})();function Or(n){let t=M.readUInt32BE();if(t===void 0)return;let e=new ks;if(t&Un.SIZE){let r=M.readUInt64BE(n);if(r===void 0)return;e.size=r}if(t&Un.UIDGID){let r=M.readUInt32BE(),s=M.readUInt32BE();if(s===void 0)return;e.uid=r,e.gid=s}if(t&Un.PERMISSIONS){let r=M.readUInt32BE();if(r===void 0)return;e.mode=r}if(t&Un.ACMODTIME){let r=M.readUInt32BE(),s=M.readUInt32BE();if(s===void 0)return;e.atime=r,e.mtime=s}if(t&Un.EXTENDED){let r=M.readUInt32BE();if(r===void 0)return;let s={};for(let i=0;i<r;++i){let o=M.readString(!0),a=M.readString();if(a===void 0)return;s[o]=a}e.extended=s}return e}function Je(n,t){let e=yf(n,t);return e!==void 0?(n._buffer.push(e),!1):!0}function yf(n,t){let e=n.outgoing;if(e.state!=="open")return;if(e.window===0)return n._waitWindow=!0,n._chunkcb=ff,t;let r,s=t.length,i=0;for(;s-i>0&&e.window>0;){let o=Math.min(s-i,e.window,e.packetSize);e.window-=o,e.window===0&&(n._waitWindow=!0,n._chunkcb=ff),i===0&&o===s?n._protocol.channelData(n.outgoing.id,t):n._protocol.channelData(n.outgoing.id,Mr(t,i,i+o)),i+=o}return s-i>0&&(i>0?r=Mr(t,i,s):r=t),r}function ff(){this._chunkcb=void 0;let n=this._buffer,t=0;for(;t<n.length;){let e=n[t],r=yf(this,e);if(r!==void 0){r!==e&&(n[t]=r),t>0&&(this._buffer=n.slice(t));return}++t}t>0&&(this._buffer=[])}function st(n,t,e){let r=new Error(t);return r.level="sftp-protocol",!e&&n._debug&&n._debug(`SFTP: Inbound: ${t}`),n.emit("error",r),n.destroy(),_f(n),!1}function _f(n){let t=Object.keys(n._requests);if(t.length===0)return;let e=n._requests;n._requests={};let r=new Error("No response from server");for(let s=0;s<t.length;++s){let i=e[t[s]];typeof i.cb=="function"&&i.cb(r)}}function A0(n,t){let e=9,r=Buffer.allocUnsafe(31);V(r,r.length-4,0),r[4]=Be.EXTENDED;let s=n._writeReqid=n._writeReqid+1&ut;V(r,s,5),V(r,18,e),r.utf8Write("limits@openssh.com",e+=4,18),n._requests[s]={extended:"limits@openssh.com",cb:t};let i=Je(n,r);if(n._debug){let o=i?"Buffered":"Sending";n._debug(`SFTP: Outbound: ${o} limits@openssh.com`)}}var y0={[tn.VERSION]:(n,t)=>{if(n._version!==-1)return st(n,"Duplicate VERSION packet");let e={};M.init(t,1);let r=M.readUInt32BE();for(;M.avail();){let s=M.readString(!0),i=M.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(M.clear(),r===void 0)return st(n,"Malformed VERSION packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received VERSION (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received VERSION (v${r})`)}if(n._version=r,n._extensions=e,e["limits@openssh.com"]==="1")return A0(n,(s,i)=>{s||(i.maxPktLen>0&&(n._maxOutPktLen=i.maxPktLen),i.maxReadLen>0&&(n._maxReadLen=i.maxReadLen),i.maxWriteLen>0&&(n._maxWriteLen=i.maxWriteLen),n.maxOpenHandles=i.maxOpenHandles>0?i.maxOpenHandles:1/0),n.emit("ready")});n.emit("ready")},[tn.STATUS]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readUInt32BE(),s=M.readString(!0);if(M.clear(),n._debug){let o=JSON.stringify(s);n._debug(`SFTP: Inbound: Received STATUS (id:${e}, ${r}, ${o})`)}let i=n._requests[e];if(delete n._requests[e],i&&typeof i.cb=="function"){if(r===tt.OK){i.cb();return}let o=new Error(s||f0[r]||"Unknown status");o.code=r,i.cb(o)}},[tn.HANDLE]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString();if(M.clear(),r===void 0)return e!==void 0&&delete n._requests[e],st(n,"Malformed HANDLE packet");n._debug&&n._debug(`SFTP: Inbound: Received HANDLE (id:${e})`);let s=n._requests[e];delete n._requests[e],s&&typeof s.cb=="function"&&s.cb(void 0,r)},[tn.DATA]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r;if(e!==void 0&&(r=n._requests[e],delete n._requests[e]),r&&typeof r.cb=="function")if(r.buffer){let s=M.readString(r.buffer);if(M.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`),r.cb(void 0,r.buffer,s);return}}else{let s=M.readString();if(M.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s.length})`),r.cb(void 0,s);return}}else{let s=M.skipString();if(M.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`);return}}return st(n,"Malformed DATA packet")},[tn.NAME]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=M.readUInt32BE();if(s!==void 0){let i=[];for(let o=0;o<s;++o){let a=M.readString(!0),c=M.readString(!0),l=Or(n._biOpt);if(l===void 0){i=void 0;break}i.push({filename:a,longname:c,attrs:l})}if(i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received NAME (id:${e}, ${i.length})`),M.clear(),r&&typeof r.cb=="function"&&r.cb(void 0,i);return}}return M.clear(),st(n,"Malformed NAME packet")},[tn.ATTRS]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=Or(n._biOpt);if(M.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received ATTRS (id:${e})`),r&&typeof r.cb=="function"&&r.cb(void 0,s);return}return st(n,"Malformed ATTRS packet")},[tn.EXTENDED]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE();if(e!==void 0){let r=n._requests[e];if(r)switch(delete n._requests[e],r.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{let s=n._biOpt,i={f_bsize:M.readUInt64BE(s),f_frsize:M.readUInt64BE(s),f_blocks:M.readUInt64BE(s),f_bfree:M.readUInt64BE(s),f_bavail:M.readUInt64BE(s),f_files:M.readUInt64BE(s),f_ffree:M.readUInt64BE(s),f_favail:M.readUInt64BE(s),f_sid:M.readUInt64BE(s),f_flag:M.readUInt64BE(s),f_namemax:M.readUInt64BE(s)};if(i.f_namemax===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),M.clear(),typeof r.cb=="function"&&r.cb(void 0,i);return}case"limits@openssh.com":{let s={maxPktLen:M.readUInt64BE(),maxReadLen:M.readUInt64BE(),maxWriteLen:M.readUInt64BE(),maxOpenHandles:M.readUInt64BE()};if(s.maxOpenHandles===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),M.clear(),typeof r.cb=="function"&&r.cb(void 0,s);return}case"users-groups-by-id@openssh.com":{let s=M.readUInt32BE();if(s===void 0)break;let i=new Array(s);for(let c=0;c<i.length;++c)i[c]=M.readString(!0);let o=M.readUInt32BE();if(o===void 0)break;let a=new Array(o);for(let c=0;c<a.length;++c)a[c]=M.readString(!0);if(a.length>0&&a[a.length-1]===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),M.clear(),typeof r.cb=="function"&&r.cb(void 0,i,a);return}default:n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),M.clear(),typeof r.cb=="function"&&r.cb();return}else{n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),M.clear();return}}return M.clear(),st(n,"Malformed EXTENDED_REPLY packet")}},_0={[Be.INIT]:(n,t)=>{if(n._version!==-1)return st(n,"Duplicate INIT packet");let e={};M.init(t,1);let r=M.readUInt32BE();for(;M.avail();){let s=M.readString(!0),i=M.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(M.clear(),r===void 0)return st(n,"Malformed INIT packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received INIT (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received INIT (v${r})`)}Je(n,d0),n._version=r,n._extensions=e,n.emit("ready")},[Be.OPEN]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=M.readUInt32BE(),i=Or(n._biOpt);if(M.clear(),i===void 0)return st(n,"Malformed OPEN packet");n._debug&&n._debug(`SFTP: Inbound: Received OPEN (id:${e})`),n.emit("OPEN",e,r,s,i)||n.status(e,tt.OP_UNSUPPORTED)},[Be.CLOSE]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString();if(M.clear(),r===void 0||r.length>256)return st(n,"Malformed CLOSE packet");n._debug&&n._debug(`SFTP: Inbound: Received CLOSE (id:${e})`),n.emit("CLOSE",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.READ]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(),s=M.readUInt64BE(n._biOpt),i=M.readUInt32BE();if(M.clear(),i===void 0||r.length>256)return st(n,"Malformed READ packet");n._debug&&n._debug(`SFTP: Inbound: Received READ (id:${e})`),n.emit("READ",e,r,s,i)||n.status(e,tt.OP_UNSUPPORTED)},[Be.WRITE]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(),s=M.readUInt64BE(n._biOpt),i=M.readString();if(M.clear(),i===void 0||r.length>256)return st(n,"Malformed WRITE packet");n._debug&&n._debug(`SFTP: Inbound: Received WRITE (id:${e})`),n.emit("WRITE",e,r,s,i)||n.status(e,tt.OP_UNSUPPORTED)},[Be.LSTAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed LSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received LSTAT (id:${e})`),n.emit("LSTAT",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.FSTAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString();if(M.clear(),r===void 0||r.length>256)return st(n,"Malformed FSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSTAT (id:${e})`),n.emit("FSTAT",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.SETSTAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=Or(n._biOpt);if(M.clear(),s===void 0)return st(n,"Malformed SETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received SETSTAT (id:${e})`),n.emit("SETSTAT",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)},[Be.FSETSTAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(),s=Or(n._biOpt);if(M.clear(),s===void 0||r.length>256)return st(n,"Malformed FSETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSETSTAT (id:${e})`),n.emit("FSETSTAT",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)},[Be.OPENDIR]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed OPENDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received OPENDIR (id:${e})`),n.emit("OPENDIR",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.READDIR]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString();if(M.clear(),r===void 0||r.length>256)return st(n,"Malformed READDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received READDIR (id:${e})`),n.emit("READDIR",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.REMOVE]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed REMOVE packet");n._debug&&n._debug(`SFTP: Inbound: Received REMOVE (id:${e})`),n.emit("REMOVE",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.MKDIR]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=Or(n._biOpt);if(M.clear(),s===void 0)return st(n,"Malformed MKDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received MKDIR (id:${e})`),n.emit("MKDIR",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)},[Be.RMDIR]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed RMDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received RMDIR (id:${e})`),n.emit("RMDIR",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.REALPATH]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed REALPATH packet");n._debug&&n._debug(`SFTP: Inbound: Received REALPATH (id:${e})`),n.emit("REALPATH",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.STAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed STAT packet");n._debug&&n._debug(`SFTP: Inbound: Received STAT (id:${e})`),n.emit("STAT",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.RENAME]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=M.readString(!0);if(M.clear(),s===void 0)return st(n,"Malformed RENAME packet");n._debug&&n._debug(`SFTP: Inbound: Received RENAME (id:${e})`),n.emit("RENAME",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)},[Be.READLINK]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed READLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received READLINK (id:${e})`),n.emit("READLINK",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.SYMLINK]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=M.readString(!0);if(M.clear(),s===void 0)return st(n,"Malformed SYMLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received SYMLINK (id:${e})`);let i;n._isOpenSSH?i=n.emit("SYMLINK",e,s,r):i=n.emit("SYMLINK",e,r,s),i||n.status(e,tt.OP_UNSUPPORTED)},[Be.EXTENDED]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(r===void 0)return M.clear(),st(n,"Malformed EXTENDED packet");let s;M.avail()&&(s=M.readRaw()),M.clear(),n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED (id:${e})`),n.emit("EXTENDED",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:E0,ERR_OUT_OF_RANGE:Cs,validateNumber:b0}=af(),uf=128,jt,ka=[];function x0(n){ka.length>0?jt=ka.pop():jt=Buffer.allocUnsafe(n),jt.used=0}function va(n,t){if(!Number.isSafeInteger(n))throw b0(n,t),Number.isInteger(n)?new Cs(t,">= 0 and <= 2 ** 53 - 1",n):new Cs(t,"an integer",n);if(n<0)throw new Cs(t,">= 0 and <= 2 ** 53 - 1",n)}function xa(n){return n+7&-8}function On(n,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,hf.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=n,this._opening=!1,this.start!==void 0&&(va(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(va(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new Cs("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}pf(On,hf);On.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t,this.emit("open",t),this.emit("ready"),this.read()}))};On.prototype._read=function(n){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(n));if(this.destroyed)return;(!jt||jt.length-jt.used<uf)&&x0(this.readableHighWaterMark||this._readableState.highWaterMark);let t=jt,e=Math.min(jt.length-jt.used,n),r=jt.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,jt,jt.used,e,this.pos,(s,i)=>{if(s){this.emit("error",s),this.autoClose&&this.destroy();return}let o=null;if(r+e===t.used&&t===jt)t.used=xa(t.used+i-e);else{let a=r+e&-8,c=xa(r+i);a-c>=uf&&ka.push(t.slice(c,a))}i>0&&(this.bytesRead+=i,o=t.slice(r,r+i)),this.pos+=i,this.push(o)}),jt.used=xa(jt.used+e)};On.prototype._destroy=function(n,t){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",df.bind(null,this,t,n));return}df(this,t,n),this.handle=null,this._opening=!1};function df(n,t,e){if(!n.handle)return r();n.sftp.close(n.handle,r);function r(s){s=s||e,t(s),n.isClosed=!0,s||n.emit("close")}}On.prototype.close=function(n){this.destroy(null,n)};Object.defineProperty(On.prototype,"pending",{get(){return this.handle===null},configurable:!0});function gn(n,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,Ba.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=n,this._opening=!1,this.start!==void 0&&(va(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()}pf(gn,Ba);gn.prototype._final=function(n){this.autoClose&&this.destroy(),n()};gn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t;let e=r=>{if(r){this.sftp.chmod(this.path,this.mode,s=>e());return}if(this.flags[0]==="a"){let s=(i,o)=>{if(i){this.sftp.stat(this.path,(a,c)=>{if(a){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)}))};gn.prototype._write=function(n,t,e){if(!Buffer.isBuffer(n)){let r=new E0("data","Buffer",n);return this.emit("error",r)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(n,t,e)});this.sftp.write(this.handle,n,0,n.length,this.pos,(r,s)=>{if(r)return this.autoClose&&this.destroy(),e(r);this.bytesWritten+=s,e()}),this.pos+=n.length};gn.prototype._writev=function(n,t){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(n,t)});let e=this.sftp,r=this.handle,s=n.length,i=(o,a)=>{if(o)return this.destroy(),t(o);this.bytesWritten+=a,--s===0&&t()};for(let o=0;o<n.length;++o){let a=n[o].chunk;e.write(r,a,0,a.length,this.pos,i),this.pos+=a.length}};typeof Ba.prototype.destroy!="function"&&(gn.prototype.destroy=On.prototype.destroy);gn.prototype._destroy=On.prototype._destroy;gn.prototype.close=function(n){if(n){if(this.isClosed){process.nextTick(n);return}this.on("close",n)}this.autoClose||this.on("finish",this.destroy.bind(this)),this.end()};gn.prototype.destroySoon=gn.prototype.end;Object.defineProperty(gn.prototype,"pending",{get(){return this.handle===null},configurable:!0});Ef.exports={flagsToString:m0,OPEN_MODE:Ce,SFTP:wa,Stats:ks,STATUS_CODE:tt,stringToFlags:Af}});var Da=ct((o_,wf)=>{"use strict";var{Duplex:S0,Readable:w0,Writable:I0}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:bf}}=Ln(),{bufferSlice:vs}=mn(),C0=32*1024,Ii=2*1024*1024,La=Ii/2,Na=class extends w0{constructor(t,e){super(e),this._channel=t}_read(t){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=La&&$a(this._channel))}},Pa=class extends I0{constructor(t){super({highWaterMark:Ii}),this._channel=t}_write(t,e,r){let s=this._channel,i=s._client._protocol,o=s.outgoing,a=o.packetSize,c=o.id,l=o.window,f=t.length,u=0;if(o.state==="open"){for(;f-u>0&&l>0;){let h=f-u;h>l&&(h=l),h>a&&(h=a),u===0&&h===f?i.channelExtData(c,t,bf):i.channelExtData(c,vs(t,u,u+h),bf),u+=h,l-=h}if(o.window=l,f-u>0){l===0&&(s._waitWindow=!0),u>0?s._chunkErr=vs(t,u,f):s._chunkErr=t,s._chunkcbErr=r;return}r()}}},Ta=class extends S0{constructor(t,e,r){let s={highWaterMark:Ii,allowHalfOpen:!r||r&&r.allowHalfOpen!==!1,emitClose:!1};super(s),this.allowHalfOpen=s.allowHalfOpen;let i=!!(r&&r.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 Pa(this):this.stderr=new Na(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",xf).on("prefinish",xf),this.on("end",Sf).on("close",Sf)}_read(t){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=La&&$a(this))}_write(t,e,r){let s=this._client._protocol,i=this.outgoing,o=i.packetSize,a=i.id,c=i.window,l=t.length,f=0;if(i.state==="open"){for(;l-f>0&&c>0;){let u=l-f;u>c&&(u=c),u>o&&(u=o),f===0&&u===l?s.channelData(a,t):s.channelData(a,vs(t,f,f+u)),f+=u,c-=u}if(i.window=c,l-f>0){c===0&&(this._waitWindow=!0),f>0?this._chunk=vs(t,f,l):this._chunk=t,this._chunkcb=r;return}r()}}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,r,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,r,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,r){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,r))}};function xf(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}function Sf(){this.readable=!1}function $a(n){if(n.outgoing.state==="closed")return;let t=Ii-n.incoming.window;t<=0||(n.incoming.window+=t,n._client._protocol.channelWindowAdjust(n.outgoing.id,t))}wf.exports={Channel:Ta,MAX_WINDOW:Ii,PACKET_SIZE:C0,windowAdjust:$a,WINDOW_THRESHOLD:La}});var Ma=ct((a_,kf)=>{"use strict";var{SFTP:k0}=wi(),Ci=2**32-1;function If(n,t,e,r){if(n._chanMgr.remove(t),typeof r!="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=""),r(s)}function Cf(n,t,e,r,s){if(typeof e=="function"){If(n,t,r,e);return}if(typeof e!="object"||e===null||e.incoming&&e.incoming.state==="closed"||(n._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!==k0&&(e.outgoing.state==="open"||e.outgoing.state==="eof")&&!s&&e.close(),e.outgoing.state==="closing"&&(e.outgoing.state="closed");let i=e._readableState,o=e._writableState;o&&!o.ending&&!o.finished&&!s&&e.end();let a=e._callbacks;e._callbacks=[];for(let c=0;c<a.length;++c)a[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:{let f=e._exit;c=()=>{f.code===null?e.emit("close",f.code,f.signal,f.dump,f.desc):e.emit("close",f.code)}}}!e.readable||e.destroyed||i&&i.endEmitted?c():e.once("end",c);let l=e.stderr._readableState;!e.stderr.readable||e.stderr.destroyed||l&&l.endEmitted?e.stderr.emit("close"):e.stderr.once("end",()=>e.stderr.emit("close"))}}var Oa=class{constructor(t){this._client=t,this._channels={},this._cur=-1,this._count=0}add(t){let e;if(this._cur<Ci)e=++this._cur;else if(this._count===0)this._cur=0,e=0;else{let r=this._channels;for(let s=0;s<Ci;++s)if(r[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>=Ci||!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>=Ci||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);return this._channels[t]}remove(t){if(typeof t!="number"||t<0||t>=Ci||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);this._channels[t]&&(delete this._channels[t],this._count&&--this._count)}cleanup(t){let e=this._channels;this._channels={},this._cur=-1,this._count=0;let r=Object.keys(e),s=this._client;for(let i=0;i<r.length;++i){let o=+r[i],a=e[o];Cf(s,o,a._channel||a,t,!0)}}},Ua=(()=>{let n=Object.prototype.toString;return t=>n.call(t)==="[object RegExp]"})();function v0(n,t,e){if(Array.isArray(n)&&n.length>0){for(let r=0;r<n.length;++r)if(e.indexOf(n[r])===-1)throw new Error(`Unsupported algorithm: ${n[r]}`);return n}if(typeof n=="object"&&n!==null){let r=Object.keys(n),s=t;for(let i=0;i<r.length;++i){let o=r[i],a=n[o];switch(o){case"append":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let l=a[c];if(typeof l=="string"){if(!l||s.indexOf(l)!==-1)continue;if(e.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);s===t&&(s=s.slice()),s.push(l)}else if(Ua(l))for(let f=0;f<e.length;++f){let u=e[f];if(l.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.push(u)}}}break;case"prepend":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=a.length;c>=0;--c){let l=a[c];if(typeof l=="string"){if(!l||s.indexOf(l)!==-1)continue;if(e.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);s===t&&(s=s.slice()),s.unshift(l)}else if(Ua(l))for(let f=e.length;f>=0;--f){let u=e[f];if(l.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.unshift(u)}}}break;case"remove":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let l=a[c];if(typeof l=="string"){if(!l)continue;let f=s.indexOf(l);if(f===-1)continue;s===t&&(s=s.slice()),s.splice(f,1)}else if(Ua(l))for(let f=0;f<s.length;++f)l.test(s[f])&&(s===t&&(s=s.slice()),s.splice(f,1),--f)}break}}return s}return t}kf.exports={ChannelManager:Oa,generateAlgorithmList:v0,onChannelOpenFailure:If,onCHANNEL_CLOSE:Cf,isWritable:n=>n&&n.writable&&n._readableState&&n._readableState.ended===!1}});var Va=ct((c_,Gf)=>{"use strict";var{createHash:B0,getHashes:R0,randomFillSync:N0}=require("crypto"),{Socket:P0}=require("net"),{lookup:T0}=require("dns"),L0=require("events"),$0=R0(),{COMPAT:qf,CHANNEL_EXTENDED_DATATYPE:{STDERR:D0},CHANNEL_OPEN_FAILURE:ki,DEFAULT_CIPHER:vf,DEFAULT_COMPRESSION:Bf,DEFAULT_KEX:Rf,DEFAULT_MAC:Nf,DEFAULT_SERVER_HOST_KEY:Pf,DISCONNECT_REASON:Tf,DISCONNECT_REASON_BY_VALUE:U0,SUPPORTED_CIPHER:O0,SUPPORTED_COMPRESSION:M0,SUPPORTED_KEX:F0,SUPPORTED_MAC:H0,SUPPORTED_SERVER_HOST_KEY:Q0}=Ln(),{init:W0}=qn(),q0=Ea(),{parseKey:Ns}=Gn(),{SFTP:K0}=wi(),{bufferCopy:Lf,makeBufferParser:Kf,makeError:V0,readUInt32BE:G0,sigSSHToASN1:z0,writeUInt32BE:Fa}=mn(),{AgentContext:$f,createAgent:Df,isAgent:Uf}=sa(),{Channel:Vf,MAX_WINDOW:Ps,PACKET_SIZE:Ts,windowAdjust:Of,WINDOW_THRESHOLD:Mf}=Da(),{ChannelManager:Y0,generateAlgorithmList:vi,isWritable:Lt,onChannelOpenFailure:j0,onCHANNEL_CLOSE:X0}=Ma(),Bs=Kf(),Rs=Kf(),Bi=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,qa=n=>{},Ka=class extends L0{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&&Lt(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;let e={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:[]},sc:void 0},r=!0;if(typeof t.algorithms=="object"&&t.algorithms!==null&&(e.kex=vi(t.algorithms.kex,Rf,F0),e.kex!==Rf&&(r=!1),e.serverHostKey=vi(t.algorithms.serverHostKey,Pf,Q0),e.serverHostKey!==Pf&&(r=!1),e.cs.cipher=vi(t.algorithms.cipher,vf,O0),e.cs.cipher!==vf&&(r=!1),e.cs.mac=vi(t.algorithms.hmac,Nf,H0),e.cs.mac!==Nf&&(r=!1),e.cs.compress=vi(t.algorithms.compress,Bf,M0),e.cs.compress!==Bf&&(r=!1),r||(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=Df(t.agent):Uf(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;let 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 Y0(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 a;if(this.config.privateKey){if(a=Ns(this.config.privateKey,t.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 does not contain a (valid) private key")}let c;if(typeof t.hostVerifier=="function"){let O=t.hostVerifier,N;$0.indexOf(t.hostHash)!==-1&&(N=t.hostHash),c=(L,K)=>{N&&(L=B0(N).update(L).digest("hex"));let ee=O(L,K);ee!==void 0&&K(ee)}}let l=this._sock=t.sock||new P0,f=!1,u=!1;this._protocol&&this._protocol.cleanup();let h=i?(O,N,L)=>{i(`Debug output from server: ${JSON.stringify(L)}`)}:void 0,p,y=this._protocol=new q0({ident:this.config.ident,offer:r?void 0:e,onWrite:O=>{Lt(l)&&l.write(O)},onError:O=>{O.level==="handshake"&&clearTimeout(this._readyTimeout),y._destruct||l.removeAllListeners("data"),this.emit("error",O);try{l.end()}catch{}},onHeader:O=>{u=!0,this._remoteVer=O.versions.software,O.greeting&&this.emit("greeting",O.greeting)},onHandshakeComplete:O=>{this.emit("handshake",O),f||(f=!0,y.service("ssh-userauth"))},debug:i,hostVerifier:c,messageHandlers:{DEBUG:h,DISCONNECT:(O,N,L)=>{if(N!==Tf.BY_APPLICATION){L||(L=U0[N],L===void 0&&(L=`Unexpected disconnection reason: ${N}`));let K=new Error(L);K.code=N,this.emit("error",K)}l.end()},SERVICE_ACCEPT:(O,N)=>{N==="ssh-userauth"&&Y()},EXT_INFO:(O,N)=>{if(p===void 0){for(let L of N)if(L.name==="server-sig-algs"){p=L.algs;return}p=null}},USERAUTH_BANNER:(O,N)=>{this.emit("banner",N)},USERAUTH_SUCCESS:O=>{C(),clearTimeout(this._readyTimeout),this.emit("ready")},USERAUTH_FAILURE:(O,N,L)=>{if(b.keyAlgos){let K=b.keyAlgos[0][0];if(i&&i(`Client: ${b.type} (${K}) auth failed`),b.keyAlgos.shift(),b.keyAlgos.length){let[ee,ue]=b.keyAlgos[0];switch(b.type){case"agent":y.authPK(b.username,b.agentCtx.currentKey(),ee);return;case"publickey":y.authPK(b.username,b.key,ee);return;case"hostbased":y.authHostbased(b.username,b.key,b.localHostname,b.localUsername,ee,(ie,je)=>{let lt=b.key.sign(ie,ue);if(lt instanceof Error)return lt.message=`Error while signing with key: ${lt.message}`,lt.level="client-authentication",this.emit("error",lt),Y();je(lt)});return}}else b.keyAlgos=void 0}if(b.type==="agent"){let K=b.agentCtx.pos();return i&&i(`Client: Agent key #${K+1} failed`),te()}i&&i(`Client: ${b.type} auth failed`),w=L,k=N,Y()},USERAUTH_PASSWD_CHANGEREQ:(O,N)=>{b.type==="password"&&this.emit("change password",N,L=>{y.authPassword(this.config.username,this.config.password,L)})},USERAUTH_PK_OK:O=>{let N,L;if(b.keyAlgos&&([N,L]=b.keyAlgos[0]),b.type==="agent"){let K=b.agentCtx.currentKey();y.authPK(b.username,K,N,(ee,ue)=>{let ie={hash:L};b.agentCtx.sign(K,ee,ie,(je,lt)=>{if(je)je.level="agent",this.emit("error",je);else return ue(lt);te()})})}else b.type==="publickey"&&y.authPK(b.username,b.key,N,(K,ee)=>{let ue=b.key.sign(K,L);if(ue instanceof Error)return ue.message=`Error signing data with key: ${ue.message}`,ue.level="client-authentication",this.emit("error",ue),Y();ee(ue)})},USERAUTH_INFO_REQUEST:(O,N,L,K)=>{if(b.type==="keyboard-interactive"){if((Array.isArray(K)?K.length:0)===0){i&&i("Client: Sending automatic USERAUTH_INFO_RESPONSE"),y.authInfoRes();return}b.prompt(N,L,"",K,ue=>{y.authInfoRes(ue)})}},REQUEST_SUCCESS:(O,N)=>{o.length&&o.shift()(!1,N)},REQUEST_FAILURE:O=>{o.length&&o.shift()(!0)},GLOBAL_REQUEST:(O,N,L,K)=>{N==="hostkeys-00@openssh.com"?(nm(this,K,(ee,ue)=>{ee||this.emit("hostkeys",ue)}),L&&y.requestSuccess()):L&&y.requestFailure()},CHANNEL_OPEN:(O,N)=>{em(this,N)},CHANNEL_OPEN_CONFIRMATION:(O,N)=>{let L=this._chanMgr.get(N.recipient);if(typeof L!="function")return;let K=L.type==="sftp",ue={type:K?"session":L.type,incoming:{id:N.recipient,window:Ps,packetSize:Ts,state:"open"},outgoing:{id:N.sender,window:N.window,packetSize:N.packetSize,state:"open"}},ie=K?new K0(this,ue,{debug:i}):new Vf(this,ue);this._chanMgr.update(N.recipient,ie),L(void 0,ie)},CHANNEL_OPEN_FAILURE:(O,N,L,K)=>{let ee=this._chanMgr.get(N);if(typeof ee!="function")return;j0(this,N,{reason:L,description:K},ee)},CHANNEL_DATA:(O,N,L)=>{let K=this._chanMgr.get(N);if(!(typeof K!="object"||K===null)&&K.incoming.window!==0){if(K.incoming.window-=L.length,K.push(L)===!1){K._waitChanDrain=!0;return}K.incoming.window<=Mf&&Of(K)}},CHANNEL_EXTENDED_DATA:(O,N,L,K)=>{if(K!==D0)return;let ee=this._chanMgr.get(N);if(!(typeof ee!="object"||ee===null)&&ee.incoming.window!==0){if(ee.incoming.window-=L.length,!ee.stderr.push(L)){ee._waitChanDrain=!0;return}ee.incoming.window<=Mf&&Of(ee)}},CHANNEL_WINDOW_ADJUST:(O,N,L)=>{let K=this._chanMgr.get(N);typeof K!="object"||K===null||(K.outgoing.window+=L,K._waitWindow&&(K._waitWindow=!1,K._chunk?K._write(K._chunk,null,K._chunkcb):K._chunkcb?K._chunkcb():K._chunkErr?K.stderr._write(K._chunkErr,null,K._chunkcbErr):K._chunkcbErr&&K._chunkcbErr()))},CHANNEL_SUCCESS:(O,N)=>{let L=this._chanMgr.get(N);typeof L!="object"||L===null||(this._resetKA(),L._callbacks.length&&L._callbacks.shift()(!1))},CHANNEL_FAILURE:(O,N)=>{let L=this._chanMgr.get(N);typeof L!="object"||L===null||(this._resetKA(),L._callbacks.length&&L._callbacks.shift()(!0))},CHANNEL_REQUEST:(O,N,L,K,ee)=>{let ue=this._chanMgr.get(N);if(typeof ue!="object"||ue===null)return;let ie=ue._exit;if(ie.code===void 0){switch(L){case"exit-status":ue.emit("exit",ie.code=ee);return;case"exit-signal":ue.emit("exit",ie.code=null,ie.signal=`SIG${ee.signal}`,ie.dump=ee.coreDumped,ie.desc=ee.errorMessage);return}K&&O.channelFailure(ue.outgoing.id)}},CHANNEL_EOF:(O,N)=>{let L=this._chanMgr.get(N);typeof L!="object"||L===null||L.incoming.state==="open"&&(L.incoming.state="eof",L.readable&&L.push(null),L.stderr.readable&&L.stderr.push(null))},CHANNEL_CLOSE:(O,N)=>{X0(this,N,this._chanMgr.get(N))}}});l.pause();let _=this.config.keepaliveInterval,x=this.config.keepaliveCountMax,S=0,R,H=()=>{if(++S>x){if(clearInterval(R),l.readable){let O=new Error("Keepalive timeout");O.level="client-timeout",this.emit("error",O),l.destroy()}return}Lt(l)?(o.push(C),y.ping()):clearInterval(R)};function C(){_>0&&(S=0,clearInterval(R),Lt(l)&&(R=setInterval(H,_)))}this._resetKA=C;let U=(()=>{let O=!1;return()=>{if(!O&&(O=!0,B&&!u)){let N=V0("Connection lost before handshake","protocol",!0);this.emit("error",N)}}})(),Q=(()=>{let O=!1;return()=>{O||(O=!0,B=!0,i&&i("Socket connected"),this.emit("connect"),W0.then(()=>{y.start(),l.on("data",N=>{try{y.parse(N,0,N.length)}catch(L){this.emit("error",L);try{Lt(l)&&l.end()}catch{}}}),l.stderr&&typeof l.stderr.resume=="function"&&l.stderr.resume(),l.resume()}).catch(N=>{this.emit("error",N);try{Lt(l)&&l.end()}catch{}}))}})(),B=!1;l.on("connect",Q).on("timeout",()=>{this.emit("timeout")}).on("error",O=>{i&&i(`Socket error: ${O.message}`),clearTimeout(this._readyTimeout),O.level="client-socket",this.emit("error",O)}).on("end",()=>{i&&i("Socket ended"),U(),y.cleanup(),clearTimeout(this._readyTimeout),clearInterval(R),this.emit("end")}).on("close",()=>{i&&i("Socket closed"),U(),y.cleanup(),clearTimeout(this._readyTimeout),clearInterval(R),this.emit("close");let O=o;o=this._callbacks=[];let N=new Error("No response from server");for(let L=0;L<O.length;++L)O[L](N);this._chanMgr.cleanup(N)});let b,w=null,k=null,v=["none"];this.config.password!==void 0&&v.push("password"),a!==void 0&&v.push("publickey"),this._agent!==void 0&&v.push("agent"),this.config.tryKeyboard&&v.push("keyboard-interactive"),a!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&v.push("hostbased"),Array.isArray(s)?s=Wf(s):typeof s!="function"&&(s=Wf(v));let P=!1,ne=O=>{if(!P){if(P=!0,O===!1){let N=new Error("All configured authentication methods failed");N.level="client-authentication",this.emit("error",N),this.end();return}if(typeof O=="string"){let N=O;if(v.indexOf(N)===-1)return z(`Authentication method not allowed: ${N}`);let L=this.config.username;switch(N){case"password":O={type:N,username:L,password:this.config.password};break;case"publickey":O={type:N,username:L,key:a};break;case"hostbased":O={type:N,username:L,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":O={type:N,username:L,agentCtx:new $f(this._agent)};break;case"keyboard-interactive":O={type:N,username:L,prompt:(...K)=>this.emit("keyboard-interactive",...K)};break;case"none":O={type:N,username:L};break;default:return z(`Skipping unsupported authentication method: ${O}`)}}else{if(typeof O!="object"||O===null)return z(`Skipping invalid authentication attempt: ${O}`);{let N=O.username;if(typeof N!="string")return z(`Skipping invalid authentication attempt: ${O}`);let L=O.type;switch(L){case"password":{let{password:K}=O;if(typeof K!="string"&&!Buffer.isBuffer(K))return z("Skipping invalid password auth attempt");O={type:L,username:N,password:K};break}case"publickey":{let K=Ns(O.key,O.passphrase);if(K instanceof Error)return z("Skipping invalid key auth attempt");if(!K.isPrivateKey())return z("Skipping non-private key");O={type:L,username:N,key:K};break}case"hostbased":{let{localHostname:K,localUsername:ee}=O,ue=Ns(O.key,O.passphrase);if(ue instanceof Error||typeof K!="string"||typeof ee!="string")return z("Skipping invalid hostbased auth attempt");if(!ue.isPrivateKey())return z("Skipping non-private key");O={type:L,username:N,key:ue,localHostname:K,localUsername:ee};break}case"agent":{let K=O.agent;if(typeof K=="string"&&K.length)K=Df(K);else if(!Uf(K))return z(`Skipping invalid agent: ${O.agent}`);O={type:L,username:N,agentCtx:new $f(K)};break}case"keyboard-interactive":{let{prompt:K}=O;if(typeof K!="function")return z("Skipping invalid keyboard-interactive auth attempt");O={type:L,username:N,prompt:K};break}case"none":O={type:L,username:N};break;default:return z(`Skipping unsupported authentication method: ${O}`)}}}b=O;try{let N=b.username;switch(b.type){case"password":y.authPassword(N,b.password);break;case"publickey":{let L;if(b.keyAlgos=Wa(this,b.key,p),b.keyAlgos)if(b.keyAlgos.length)L=b.keyAlgos[0][0];else return z("Skipping key authentication (no mutual hash algorithm)");y.authPK(N,b.key,L);break}case"hostbased":{let L,K;if(b.keyAlgos=Wa(this,b.key,p),b.keyAlgos)if(b.keyAlgos.length)[L,K]=b.keyAlgos[0];else return z("Skipping hostbased authentication (no mutual hash algorithm)");y.authHostbased(N,b.key,b.localHostname,b.localUsername,L,(ee,ue)=>{let ie=b.key.sign(ee,K);if(ie instanceof Error)return ie.message=`Error while signing with key: ${ie.message}`,ie.level="client-authentication",this.emit("error",ie),Y();ue(ie)});break}case"agent":b.agentCtx.init(L=>{if(L)return L.level="agent",this.emit("error",L),Y();te()});break;case"keyboard-interactive":y.authKeyboard(N);break;case"none":y.authNone(N);break}}finally{P=!1}}};function z(O){i&&i(O),process.nextTick(Y)}function Y(){P=!1;let O=s(k,w,ne);P||O===void 0||ne(O)}let te=()=>{if(b.type==="agent"){let O=b.agentCtx.nextKey();if(O===!1)i&&i("Agent: No more keys left to try"),i&&i("Client: agent auth failed"),Y();else{let N=b.agentCtx.pos(),L;if(b.keyAlgos=Wa(this,O,p),b.keyAlgos)if(b.keyAlgos.length)L=b.keyAlgos[0][0];else{i&&i(`Agent: Skipping key #${N+1} (no mutual hash algorithm)`),te();return}i&&i(`Agent: Trying key #${N+1}`),y.authPK(b.username,O,L)}}},le=()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let O=new Error("Timed out while waiting for handshake");O.level="client-timeout",this.emit("error",O),l.destroy()},this.config.readyTimeout))};if(t.sock)le(),typeof l.connecting=="boolean"&&l.connecting||Q();else{let O=this.config.host,N=this.config.forceIPv4,L=this.config.forceIPv6;i&&i(`Client: Trying ${O} on port ${this.config.port} ...`);let K=()=>{le(),l.connect({host:O,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),l.setMaxListeners(0),l.setTimeout(typeof t.timeout=="number"?t.timeout:0)};!N&&!L||N&&L?K():T0(O,N?4:6,(ee,ue,ie)=>{if(ee){let je=N?"IPv4":"IPv6",lt=new Error(`Error while looking up ${je} address for '${O}': ${ee}`);clearTimeout(this._readyTimeout),lt.level="client-dns",this.emit("error",lt),this.emit("close");return}O=ue,K()})}return this}end(){return this._sock&&Lt(this._sock)&&(this._protocol.disconnect(Tf.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&Lt(this._sock)&&this._sock.destroy(),this}exec(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");typeof e=="function"&&(r=e,e={});let s={allowHalfOpen:e.allowHalfOpen!==!1};return Fr(this,"session",s,(i,o)=>{if(i){r(i);return}let a=[];function c(l){if(l){o.close(),r(l);return}a.length&&a.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&a.push(()=>Qf(o,c)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&Ha(o,e.env),(typeof e.pty=="object"&&e.pty!==null||e.pty===!0)&&a.push(()=>Hf(o,e.pty,c)),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&a.push(()=>Ff(o,e.x11,c))),a.push(()=>Z0(o,t,e,r)),a.shift()()}),this}shell(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return typeof t=="function"?(r=t,t=e=void 0):typeof e=="function"&&(r=e,e=void 0),t&&(t.x11!==void 0||t.env!==void 0)&&(e=t,t=void 0),Fr(this,"session",(s,i)=>{if(s){r(s);return}let o=[];function a(c){if(c){i.close(),r(c);return}o.length&&o.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&o.push(()=>Qf(i,a)),t!==!1&&o.push(()=>Hf(i,t,a)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&Ha(i,e.env),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&o.push(()=>Ff(i,e.x11,a))),o.push(()=>J0(i,r)),o.shift()()}),this}subsys(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return Fr(this,"session",(r,s)=>{if(r){e(r);return}Qa(s,t,(i,o)=>{if(i){e(i);return}e(void 0,o)})}),this}forwardIn(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push((i,o)=>{if(i){r(i!==!0?i:new Error(`Unable to bind to ${t}:${e}`));return}let a=e;e===0&&o&&o.length>=4&&(a=G0(o,0),this._protocol._compatFlags&qf.DYN_RPORT_BUG||(e=a)),this._forwarding[`${t}:${e}`]=a,r(void 0,a)}),this._protocol.tcpipForward(t,e,s),this}unforwardIn(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to unbind from ${t}:${e}`));return}delete this._forwarding[`${t}:${e}`],r()}),this._protocol.cancelTcpipForward(t,e,s),this}forwardOut(t,e,r,s,i){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let o={srcIP:t,srcPort:e,dstIP:r,dstPort:s};return typeof i!="function"&&(i=qa),Fr(this,"direct-tcpip",o,i),this}openssh_noMoreSessions(t){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let e=typeof t=="function";return!this.config.strictVendor||this.config.strictVendor&&Bi.test(this._remoteVer)?(e&&this._callbacks.push(r=>{if(r){t(r!==!0?r: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||!Lt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Bi.test(this._remoteVer)?(r&&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,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Bi.test(this._remoteVer)?(r&&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,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return typeof e!="function"&&(e=qa),!this.config.strictVendor||this.config.strictVendor&&Bi.test(this._remoteVer)?(Fr(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,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return typeof t=="function"&&(e=t,t=void 0),Fr(this,"sftp",(r,s)=>{if(r){e(r);return}let i=(o,a)=>{if(o){e(o);return}function c(){s.removeListener("ready",l),s.removeListener("error",f),s.removeListener("exit",u),s.removeListener("close",u)}function l(){c(),e(void 0,s)}function f(h){c(),e(h)}function u(h,p){c();let y;typeof h=="number"?y=`Received exit code ${h} while establishing SFTP session`:p!==void 0?y=`Received signal ${p} while establishing SFTP session`:y="Received unexpected SFTP session termination";let _=new Error(y);_.code=h,_.signal=p,e(_)}s.on("ready",l).on("error",f).on("exit",u).on("close",u),s._init()};typeof t=="object"&&t!==null?Ha(s,t,o=>{if(o){e(o);return}Qa(s,"sftp",i)}):Qa(s,"sftp",i)}),this}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function Fr(n,t,e,r){let s=Ps,i=Ts;typeof e=="function"&&(r=e,e={});let o=(c,l)=>{r(c,l)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"session":case"sftp":n._protocol.session(a,s,i);break;case"direct-tcpip":n._protocol.directTcpip(a,s,i,e);break;case"direct-streamlocal@openssh.com":n._protocol.openssh_directStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Ff(n,t,e){let r={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"&&(r.single=t.single),typeof t.screen=="number"&&(r.screen=t.screen),typeof t.protocol=="string"&&(r.protocol=t.protocol),typeof t.cookie=="string"?r.cookie=t.cookie:Buffer.isBuffer(t.cookie)&&(r.cookie=t.cookie.hexSlice(0,t.cookie.length))),r.cookie===void 0&&(r.cookie=tm());let s=typeof e=="function";if(n.outgoing.state!=="open"){s&&e(new Error("Channel is not open"));return}s&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to request X11"));return}n._hasX11=!0,++n._client._acceptX11,n.once("close",()=>{n._client._acceptX11&&--n._client._acceptX11}),e()}),n._client._protocol.x11Forward(n.outgoing.id,r,s)}function Hf(n,t,e){let r=24,s=80,i=640,o=480,a="vt100",c=null;typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.rows=="number"&&(r=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"&&(a=t.term),typeof t.modes=="object"&&(c=t.modes));let l=typeof e=="function";if(n.outgoing.state!=="open"){l&&e(new Error("Channel is not open"));return}l&&n._callbacks.push(f=>{if(f){e(f!==!0?f:new Error("Unable to request a pseudo-terminal"));return}e()}),n._client._protocol.pty(n.outgoing.id,r,s,o,i,a,c,l)}function Qf(n,t){let e=typeof t=="function";if(n.outgoing.state!=="open"){e&&t(new Error("Channel is not open"));return}if(n._client._agentFwdEnabled){e&&t(!1);return}n._client._agentFwdEnabled=!0,n._callbacks.push(r=>{if(r){n._client._agentFwdEnabled=!1,e&&t(r!==!0?r:new Error("Unable to request agent forwarding"));return}e&&t()}),n._client._protocol.openssh_agentForward(n.outgoing.id,!0)}function J0(n,t){if(n.outgoing.state!=="open"){t(new Error("Channel is not open"));return}n._callbacks.push(e=>{if(e){t(e!==!0?e:new Error("Unable to open shell"));return}n.subtype="shell",t(void 0,n)}),n._client._protocol.shell(n.outgoing.id,!0)}function Z0(n,t,e,r){if(n.outgoing.state!=="open"){r(new Error("Channel is not open"));return}n._callbacks.push(s=>{if(s){r(s!==!0?s:new Error("Unable to exec"));return}n.subtype="exec",n.allowHalfOpen=e.allowHalfOpen!==!1,r(void 0,n)}),n._client._protocol.exec(n.outgoing.id,t,!0)}function Ha(n,t,e){let r=typeof e=="function";if(n.outgoing.state!=="open"){r&&e(new Error("Channel is not open"));return}r&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to set environment"));return}e()});let s=Object.keys(t||{});for(let i=0;i<s.length;++i){let o=s[i],a=t[o];n._client._protocol.env(n.outgoing.id,o,a,r)}}function Qa(n,t,e){if(n.outgoing.state!=="open"){e(new Error("Channel is not open"));return}n._callbacks.push(r=>{if(r){e(r!==!0?r:new Error(`Unable to start subsystem: ${t}`));return}n.subtype="subsystem",e(void 0,n)}),n._client._protocol.subsystem(n.outgoing.id,t,!0)}function em(n,t){let e=-1,r,s=()=>{let c={type:t.type,incoming:{id:e,window:Ps,packetSize:Ts,state:"open"},outgoing:{id:t.sender,window:t.window,packetSize:t.packetSize,state:"open"}},l=new Vf(n,c);return n._chanMgr.update(e,l),n._protocol.channelOpenConfirm(t.sender,e,Ps,Ts),l},i=()=>{r===void 0&&(e===-1?r=ki.RESOURCE_SHORTAGE:r=ki.CONNECT_FAILED),e!==-1&&n._chanMgr.remove(e),n._protocol.channelOpenFail(t.sender,r,"")},o=()=>(e=n._chanMgr.add(),e===-1&&(r=ki.RESOURCE_SHORTAGE,n.config.debug&&n.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),e!==-1),a=t.data;switch(t.type){case"forwarded-tcpip":{let c=n._forwarding[`${a.destIP}:${a.destPort}`];if(c!==void 0&&o()){a.destPort===0&&(a.destPort=c),n.emit("tcp connection",a,s,i);return}break}case"forwarded-streamlocal@openssh.com":if(n._forwardingUnix[a.socketPath]!==void 0&&o()){n.emit("unix connection",a,s,i);return}break;case"auth-agent@openssh.com":if(n._agentFwdEnabled&&typeof n._agent.getStream=="function"&&o()){n._agent.getStream((c,l)=>{if(c)return i();let f=s();f.pipe(l).pipe(f)});return}break;case"x11":if(n._acceptX11!==0&&o()){n.emit("x11",a,s,i);return}break;default:r=ki.UNKNOWN_CHANNEL_TYPE,n.config.debug&&n.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${t.type}`)}r===void 0&&(r=ki.ADMINISTRATIVELY_PROHIBITED,n.config.debug&&n.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+t.type)),i()}var tm=(()=>{let n=Buffer.allocUnsafe(16);return()=>(N0(n,0,16),n.hexSlice(0,16))})();function Wf(n){if(!Array.isArray(n))throw new Error("authList must be an array");let t=0;return(e,r,s)=>t===n.length?!1:n[t++]}function nm(n,t,e){if(!n._sock||!Lt(n._sock))return;if(typeof e!="function"&&(e=qa),!Array.isArray(t))throw new TypeError("Invalid keys argument type");let r=[];for(let s of t){let i=Ns(s);if(i instanceof Error)throw i;r.push(i)}if(!n.config.strictVendor||n.config.strictVendor&&Bi.test(n._remoteVer)){n._callbacks.push((s,i)=>{if(s){e(s!==!0?s:new Error("Server failed to prove supplied keys"));return}let o=[],a=0;for(Bs.init(i,0);Bs.avail()&&a!==r.length;){let c=r[a++],l=c.getPublicSSH(),f=Bs.readString();Rs.init(f,0);let u=Rs.readString(!0),h=Rs.readString(),p;if(u!==c.type)if(c.type==="ssh-rsa")switch(u){case"rsa-sha2-256":p="sha256";break;case"rsa-sha2-512":p="sha512";break;default:continue}else continue;let y=n._protocol._kex.sessionID,_=Buffer.allocUnsafe(37+y.length+4+l.length),x=0;Fa(_,29,x),_.utf8Write("hostkeys-prove-00@openssh.com",x+=4,29),Fa(_,y.length,x+=29),Lf(y,_,0,y.length,x+=4),Fa(_,l.length,x+=y.length),Lf(l,_,0,l.length,x+=4),(h=z0(h,u))&&c.verify(_,h,p)===!0&&o.push(c)}Rs.clear(),Bs.clear(),e(null,o)}),n._protocol.openssh_hostKeysProve(r);return}process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version"))}function Wa(n,t,e){switch(t.type){case"ssh-rsa":if(n._protocol._compatFlags&qf.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"]]}}Gf.exports=Ka});var Yf=ct(zf=>{"use strict";var{Agent:za}=require("http"),{Agent:rm}=require("https"),{connect:im}=require("tls"),Ga;for(let n of[za,rm]){class t extends n{constructor(r,s){super(s),this._connectCfg=r,this._defaultSrcIP=s&&s.srcIP||"localhost"}createConnection(r,s){let i=r&&r.localAddress||this._defaultSrcIP,o=r&&r.localPort||0,a=r.host,c=r.port;Ga===void 0&&(Ga=Va());let l=new Ga,f=!1;l.on("ready",()=>{l.forwardOut(i,o,a,c,(u,h)=>{if(f=!0,u)return l.end(),s(u);h.once("close",()=>l.end()),s(null,sm(h,n,r))})}).on("error",s).on("close",()=>{f||s(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}zf[n===za?"SSHTTPAgent":"SSHTTPSAgent"]=t}function Ri(){}function sm(n,t,e){if(t===za)return n.setKeepAlive=Ri,n.setNoDelay=Ri,n.setTimeout=Ri,n.ref=Ri,n.unref=Ri,n.destroySoon=n.destroy,n;e.socket=n;let r=im(e),s=(()=>{let i=!1;return()=>{i||(i=!0,n.isPaused()&&n.resume())}})();return r.on("end",s).on("close",s),r}});var Xf=ct((f_,Ja)=>{"use strict";var{Server:om}=require("net"),Pi=require("events"),{listenerCount:Gt}=Pi,{CHANNEL_OPEN_FAILURE:Hr,DEFAULT_CIPHER:am,DEFAULT_COMPRESSION:cm,DEFAULT_KEX:lm,DEFAULT_MAC:fm,DEFAULT_SERVER_HOST_KEY:um,DISCONNECT_REASON:Qr,DISCONNECT_REASON_BY_VALUE:dm,SUPPORTED_CIPHER:hm,SUPPORTED_COMPRESSION:pm,SUPPORTED_KEX:gm,SUPPORTED_MAC:mm,SUPPORTED_SERVER_HOST_KEY:Am}=Ln(),{init:ym}=qn(),{KexInit:_m}=ms(),{parseKey:jf}=Gn(),Em=Ea(),{SFTP:bm}=wi(),{writeUInt32BE:xm}=mn(),{Channel:Wr,MAX_WINDOW:jn,PACKET_SIZE:Xn,windowAdjust:Sm,WINDOW_THRESHOLD:wm}=Da(),{ChannelManager:Im,generateAlgorithmList:Ni,isWritable:Ls,onChannelOpenFailure:Cm,onCHANNEL_CLOSE:km}=Ma(),vm=10,Jn=class extends Pi{constructor(t,e,r,s,i){super(),this.username=this.user=e,this.service=r,this.method=s,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(o,a,c)=>{this._finalResponse||(this._finalResponse=!0,i(this,o,a,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)}},$s=class extends Jn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this._multistep=!0,this._cb=void 0,this._onInfoResponse=a=>{let c=this._cb;c&&(this._cb=void 0,c(a))},this.submethods=i,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(t,e,r,s){Array.isArray(t)||(t=[t]),typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"?(s=r,r=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,r,t)}},ja=class extends Jn{constructor(t,e,r,s,i,o){super(t,e,r,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?Jn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},Xa=class extends Jn{constructor(t,e,r,s,i,o){super(t,e,r,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}},Ds=class extends Jn{constructor(t,e,r,s,i,o){super(t,e,r,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)}},Cn=class extends Pi{constructor(t,e,r){super(),this.type="session",this.subtype=void 0,this.server=!0,this._ending=!1,this._channel=void 0,this._chanInfo={type:"session",incoming:{id:r,window:jn,packetSize:Xn,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}}}},ln=class extends Pi{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new Error("Missing configuration object");let r=Object.create(null),s=[],i=t.hostKeys;if(!Array.isArray(i))throw new Error("hostKeys must be an array");let o=typeof t.algorithms=="object"&&t.algorithms!==null?t.algorithms:{},a=Ni(o.serverHostKey,um,Am);for(let h=0;h<i.length;++h){let p;if(Buffer.isBuffer(i[h])||typeof i[h]=="string"?p=jf(i[h]):p=jf(i[h].key,i[h].passphrase),p instanceof Error)throw new Error(`Cannot parse privateKey: ${p.message}`);if(Array.isArray(p)&&(p=p[0]),p.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!s.includes(p.type))if(p.type==="ssh-rsa"){let y=a.indexOf("ssh-rsa"),_=a.indexOf("rsa-sha2-256"),x=a.indexOf("rsa-sha2-512");y===-1&&(y=1/0),[y,_,x].sort(Bm).forEach(S=>{if(S===-1)return;let R;switch(S){case y:R="ssh-rsa";break;case _:R="rsa-sha2-256";break;case x:R="rsa-sha2-512";break;default:return}r[R]=p,s.push(R)})}else r[p.type]=p,s.push(p.type)}let c={kex:Ni(o.kex,lm,gm).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:s,cs:{cipher:Ni(o.cipher,am,hm),mac:Ni(o.hmac,fm,mm),compress:Ni(o.compress,cm,pm),lang:[]},sc:void 0};c.sc=c.cs,typeof e=="function"&&this.on("connection",e);let l=typeof t.debug=="function"?t.debug:void 0,f=t.ident?Buffer.from(t.ident):void 0,u=new _m(c);this._srv=new om(h=>{if(this._connections>=this.maxConnections){h.destroy();return}++this._connections,h.once("close",()=>{--this._connections});let p;if(l){let y=`[${process.hrtime().join(".")}] `;p=_=>{l(`${y}${_}`)}}new Us(h,r,f,u,p,this,t)}).on("error",h=>{this.emit("error",h)}).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}};ln.KEEPALIVE_CLIENT_INTERVAL=15e3;ln.KEEPALIVE_CLIENT_COUNT_MAX=3;var Us=class extends Pi{constructor(t,e,r,s,i,o,a){super();let c=0,l=!1,f=[],u,h,p,y=[];this._sock=t,this._chanMgr=new Im(this),this._debug=i,this.noMoreSessions=!1,this.authenticated=!1;function _(B){}this.on("error",_);let x=i?(B,b,w)=>{i(`Debug output from client: ${JSON.stringify(w)}`)}:void 0,S=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof ln.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(ln.KEEPALIVE_CLIENT_INTERVAL)&&ln.KEEPALIVE_CLIENT_INTERVAL>0?ln.KEEPALIVE_CLIENT_INTERVAL:-1,R=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof ln.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(ln.KEEPALIVE_CLIENT_COUNT_MAX)&&ln.KEEPALIVE_CLIENT_COUNT_MAX>=0?ln.KEEPALIVE_CLIENT_COUNT_MAX:-1,H=0;S!==-1&&R!==-1&&(this.once("ready",()=>{let B=()=>{clearInterval(h)};this.on("close",B).on("end",B),h=setInterval(()=>{if(++H>R){clearInterval(h);let b=new Error("Keepalive timeout");b.level="client-timeout",this.emit("error",b),this.end()}else C.ping()},S)}),p=()=>{h&&h.refresh(),H=0});let C=this._protocol=new Em({server:!0,hostKeys:e,ident:r,offer:s,onPacket:p,greeting:a.greeting,banner:a.banner,onWrite:B=>{Ls(t)&&t.write(B)},onError:B=>{C._destruct||t.removeAllListeners("data"),this.emit("error",B);try{t.end()}catch{}},onHeader:B=>{this.removeListener("error",_);let b={ip:t.remoteAddress,family:t.remoteFamily,port:t.remotePort,header:B};if(!o.emit("connection",this,b)){C.disconnect(Qr.BY_APPLICATION),t.end();return}B.greeting&&this.emit("greeting",B.greeting)},onHandshakeComplete:B=>{++c>1&&this.emit("rekey"),this.emit("handshake",B)},debug:i,messageHandlers:{DEBUG:x,DISCONNECT:(B,b,w)=>{if(b!==Qr.BY_APPLICATION){w||(w=dm[b],w===void 0&&(w=`Unexpected disconnection reason: ${b}`));let k=new Error(w);k.code=b,this.emit("error",k)}t.end()},CHANNEL_OPEN:(B,b)=>{if(b.type==="session"&&this.noMoreSessions||!this.authenticated){let te=Hr.ADMINISTRATIVELY_PROHIBITED;return C.channelOpenFail(b.sender,te)}let w=-1,k,v=!1,P,ne=()=>{v||(v=!0,k===void 0&&(w===-1?k=Hr.RESOURCE_SHORTAGE:k=Hr.CONNECT_FAILED),w!==-1&&this._chanMgr.remove(w),C.channelOpenFail(b.sender,k,""))},z=()=>(w=this._chanMgr.add(),w===-1&&(k=Hr.RESOURCE_SHORTAGE,i&&i("Automatic rejection of incoming channel open: no channels available")),w!==-1),Y=b.data;switch(b.type){case"session":if(Gt(this,"session")&&z()){P=()=>{if(v)return;v=!0;let te=new Cn(this,b,w);return this._chanMgr.update(w,te),C.channelOpenConfirm(b.sender,w,jn,Xn),te},this.emit("session",P,ne);return}break;case"direct-tcpip":if(Gt(this,"tcpip")&&z()){P=()=>{if(v)return;v=!0;let te={type:void 0,incoming:{id:w,window:jn,packetSize:Xn,state:"open"},outgoing:{id:b.sender,window:b.window,packetSize:b.packetSize,state:"open"}},le=new Wr(this,te,{server:!0});return this._chanMgr.update(w,le),C.channelOpenConfirm(b.sender,w,jn,Xn),le},this.emit("tcpip",P,ne,Y);return}break;case"direct-streamlocal@openssh.com":if(Gt(this,"openssh.streamlocal")&&z()){P=()=>{if(v)return;v=!0;let te={type:void 0,incoming:{id:w,window:jn,packetSize:Xn,state:"open"},outgoing:{id:b.sender,window:b.window,packetSize:b.packetSize,state:"open"}},le=new Wr(this,te,{server:!0});return this._chanMgr.update(w,le),C.channelOpenConfirm(b.sender,w,jn,Xn),le},this.emit("openssh.streamlocal",P,ne,Y);return}break;default:k=Hr.UNKNOWN_CHANNEL_TYPE,i&&i(`Automatic rejection of unsupported incoming channel open type: ${b.type}`)}k===void 0&&(k=Hr.ADMINISTRATIVELY_PROHIBITED,i&&i(`Automatic rejection of unexpected incoming channel open for: ${b.type}`)),ne()},CHANNEL_OPEN_CONFIRMATION:(B,b)=>{let w=this._chanMgr.get(b.recipient);if(typeof w!="function")return;let k={type:w.type,incoming:{id:b.recipient,window:jn,packetSize:Xn,state:"open"},outgoing:{id:b.sender,window:b.window,packetSize:b.packetSize,state:"open"}},v=new Wr(this,k,{server:!0});this._chanMgr.update(b.recipient,v),w(void 0,v)},CHANNEL_OPEN_FAILURE:(B,b,w,k)=>{let v=this._chanMgr.get(b);if(typeof v!="function")return;Cm(this,b,{reason:w,description:k},v)},CHANNEL_DATA:(B,b,w)=>{let k=this._chanMgr.get(b);if(!(typeof k!="object"||k===null)&&!(k.constructor===Cn&&(k=k._channel,!k))&&k.incoming.window!==0){if(k.incoming.window-=w.length,k.push(w)===!1){k._waitChanDrain=!0;return}k.incoming.window<=wm&&Sm(k)}},CHANNEL_EXTENDED_DATA:(B,b,w,k)=>{},CHANNEL_WINDOW_ADJUST:(B,b,w)=>{let k=this._chanMgr.get(b);typeof k!="object"||k===null||k.constructor===Cn&&(k=k._channel,!k)||(k.outgoing.window+=w,k._waitWindow&&(k._waitWindow=!1,k._chunk?k._write(k._chunk,null,k._chunkcb):k._chunkcb?k._chunkcb():k._chunkErr?k.stderr._write(k._chunkErr,null,k._chunkcbErr):k._chunkcbErr&&k._chunkcbErr()))},CHANNEL_SUCCESS:(B,b)=>{let w=this._chanMgr.get(b);typeof w!="object"||w===null||w.constructor===Cn&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!1)},CHANNEL_FAILURE:(B,b)=>{let w=this._chanMgr.get(b);typeof w!="object"||w===null||w.constructor===Cn&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!0)},CHANNEL_REQUEST:(B,b,w,k,v)=>{let P=this._chanMgr.get(b);if(typeof P!="object"||P===null)return;let ne=!1,z,Y;if(P.constructor!==Cn){k&&C.channelFailure(P.outgoing.id);return}if(k&&(w!=="shell"&&w!=="exec"&&w!=="subsystem"&&(z=()=>{ne||P._ending||P._channel||(ne=!0,C.channelSuccess(P._chanInfo.outgoing.id))}),Y=()=>{ne||P._ending||P._channel||(ne=!0,C.channelFailure(P._chanInfo.outgoing.id))}),P._ending){Y&&Y();return}switch(w){case"env":if(Gt(P,"env")){P.emit("env",z,Y,{key:v.name,val:v.value});return}break;case"pty-req":if(Gt(P,"pty")){P.emit("pty",z,Y,v);return}break;case"window-change":Gt(P,"window-change")?P.emit("window-change",z,Y,v):Y&&Y();break;case"x11-req":if(Gt(P,"x11")){P.emit("x11",z,Y,v);return}break;case"signal":if(Gt(P,"signal")){P.emit("signal",z,Y,{name:v});return}break;case"auth-agent-req@openssh.com":if(Gt(P,"auth-agent")){P.emit("auth-agent",z,Y);return}break;case"shell":if(Gt(P,"shell")){z=()=>{if(ne||P._ending||P._channel)return;ne=!0,k&&C.channelSuccess(P._chanInfo.outgoing.id);let te=new Wr(this,P._chanInfo,{server:!0});return te.subtype=P.subtype=w,P._channel=te,te},P.emit("shell",z,Y);return}break;case"exec":if(Gt(P,"exec")){z=()=>{if(ne||P._ending||P._channel)return;ne=!0,k&&C.channelSuccess(P._chanInfo.outgoing.id);let te=new Wr(this,P._chanInfo,{server:!0});return te.subtype=P.subtype=w,P._channel=te,te},P.emit("exec",z,Y,{command:v});return}break;case"subsystem":{let te=v==="sftp";if(z=()=>{if(ne||P._ending||P._channel)return;ne=!0,k&&C.channelSuccess(P._chanInfo.outgoing.id);let le;return te?le=new bm(this,P._chanInfo,{server:!0,debug:i}):(le=new Wr(this,P._chanInfo,{server:!0}),le.subtype=P.subtype=`${w}:${v}`),P._channel=le,le},v==="sftp"){if(Gt(P,"sftp")){P.emit("sftp",z,Y);return}te=!1}if(Gt(P,"subsystem")){P.emit("subsystem",z,Y,{name:v});return}break}}i&&i(`Automatic rejection of incoming channel request: ${w}`),Y&&Y()},CHANNEL_EOF:(B,b)=>{let w=this._chanMgr.get(b);typeof w!="object"||w===null||w.constructor===Cn&&(w._ending||(w._ending=!0,w.emit("eof"),w.emit("end")),w=w._channel,!w)||w.incoming.state==="open"&&(w.incoming.state="eof",w.readable&&w.push(null))},CHANNEL_CLOSE:(B,b)=>{let w=this._chanMgr.get(b);typeof w!="object"||w===null||w.constructor===Cn&&(w._ending=!0,w.emit("close"),w=w._channel,!w)||km(this,b,w)},SERVICE_REQUEST:(B,b)=>{if(c===0||l||this.authenticated||b!=="ssh-userauth"){C.disconnect(Qr.SERVICE_NOT_AVAILABLE),t.end();return}l=!0,C.serviceAccept(b)},USERAUTH_REQUEST:(B,b,w,k,v)=>{if(c===0||this.authenticated||u&&(u.username!==b||u.service!==w)||k!=="password"&&k!=="publickey"&&k!=="hostbased"&&k!=="keyboard-interactive"&&k!=="none"||f.length===vm){C.disconnect(Qr.PROTOCOL_ERROR),t.end();return}else if(w!=="ssh-connection"){C.disconnect(Qr.SERVICE_NOT_AVAILABLE),t.end();return}let P;switch(k){case"keyboard-interactive":P=new $s(C,b,w,k,v,U);break;case"publickey":P=new ja(C,b,w,k,v,U);break;case"hostbased":P=new Xa(C,b,w,k,v,U);break;case"password":if(u&&u instanceof Ds&&u._changeCb){let ne=u._changeCb;u._changeCb=void 0,ne(v.newPassword);return}P=new Ds(C,b,w,k,v,U);break;case"none":P=new Jn(C,b,w,k,U);break}if(u)if(u._initialResponse)u._multistep&&!u._finalResponse&&(u._cleanup&&u._cleanup(),u.emit("abort"));else return f.push(P);u=P,Gt(this,"authentication")?this.emit("authentication",u):u.reject()},USERAUTH_INFO_RESPONSE:(B,b)=>{u&&u instanceof $s&&u._onInfoResponse(b)},GLOBAL_REQUEST:(B,b,w,k)=>{let v={type:null,buf:null};function P(ne,z){v.type=ne,v.buf=z,Q()}if(w&&y.push(v),(b==="tcpip-forward"||b==="cancel-tcpip-forward"||b==="no-more-sessions@openssh.com"||b==="streamlocal-forward@openssh.com"||b==="cancel-streamlocal-forward@openssh.com")&&Gt(this,"request")&&this.authenticated){let ne,z;if(w){let Y=!1;ne=te=>{if(Y)return;Y=!0;let le;b==="tcpip-forward"&&k.bindPort===0&&typeof te=="number"&&(le=Buffer.allocUnsafe(4),xm(le,te,0)),P("SUCCESS",le)},z=()=>{Y||(Y=!0,P("FAILURE"))}}if(b==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,ne&&ne();return}this.emit("request",ne,z,b,k)}else w&&P("FAILURE")}}});t.pause(),ym.then(()=>{C.start(),t.on("data",B=>{try{C.parse(B,0,B.length)}catch(b){this.emit("error",b);try{Ls(t)&&t.end()}catch{}}}),t.resume()}).catch(B=>{this.emit("error",B);try{Ls(t)&&t.end()}catch{}}),t.on("error",B=>{B.level="socket",this.emit("error",B)}).once("end",()=>{i&&i("Socket ended"),C.cleanup(),this.emit("end")}).once("close",()=>{i&&i("Socket closed"),C.cleanup(),this.emit("close");let B=new Error("No response from server");this._chanMgr.cleanup(B)});let U=(B,b,w,k)=>{u===B&&!this.authenticated&&(b?(u=void 0,this.authenticated=!0,C.authSuccess(),f=[],this.emit("ready")):(C.authFailure(w,k),f.length&&(u=f.pop(),Gt(this,"authentication")?this.emit("authentication",u):u.reject())))};function Q(){for(;y.length>0&&y[0].type;){let B=y.shift();B.type==="SUCCESS"&&C.requestSuccess(B.buf),B.type==="FAILURE"&&C.requestFailure()}}}end(){return this._sock&&Ls(this._sock)&&(this._protocol.disconnect(Qr.BY_APPLICATION),this._sock.end()),this}x11(t,e,r){return Ya(this,"x11",{originAddr:t,originPort:e},r),this}forwardOut(t,e,r,s,i){return Ya(this,"forwarded-tcpip",{boundAddr:t,boundPort:e,remoteAddr:r,remotePort:s},i),this}openssh_forwardOutStreamLocal(t,e){return Ya(this,"forwarded-streamlocal@openssh.com",{socketPath:t},e),this}rekey(t){let e;try{this._protocol.rekey()}catch(r){e=r}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 Ya(n,t,e,r){let s=jn,i=Xn;typeof e=="function"&&(r=e,e={});let o=(c,l)=>{r(c,l)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"forwarded-tcpip":n._protocol.forwardedTcpip(a,s,i,e);break;case"x11":n._protocol.x11(a,s,i,e);break;case"forwarded-streamlocal@openssh.com":n._protocol.openssh_forwardedStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Bm(n,t){return n-t}Ja.exports=ln;Ja.exports.IncomingClient=Us});var nu=ct((u_,tu)=>{"use strict";var{createCipheriv:Rm,generateKeyPair:Nm,generateKeyPairSync:Pm,getCurves:Tm,randomBytes:Jf}=require("crypto"),{Ber:bt}=si(),Lm=Ao().pbkdf,{CIPHER_INFO:$m}=qn(),Dm=16,Um=16,Om=Tm(),Mm=new Map(Object.entries($m));function Zf(n,t){if(typeof n!="string")throw new TypeError("Key type must be a string");let e={type:"spki",format:"der"},r={type:"pkcs8",format:"der"};switch(n.toLowerCase()){case"rsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for RSA key");let 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:r}]}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(!Om.includes(s))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ed25519":return["ed25519",{publicKeyEncoding:e,privateKeyEncoding:r}];default:throw new Error(`Unsupported key type: ${n}`)}}function Fm(n,t,e){switch(n){case"rsa":{let r=new bt.Reader(e);if(r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.113549.1.1.1")throw new Error("Bad RSA private OID");if(r.readByte()!==bt.Null)throw new Error("Malformed RSA private key (expected null)");if(r.readByte()!==0)throw new Error("Malformed RSA private key (expected zero-length null)");if(r=new bt.Reader(r.readString(bt.OctetString,!0)),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");let s=r.readString(bt.Integer,!0),i=r.readString(bt.Integer,!0),o=r.readString(bt.Integer,!0),a=r.readString(bt.Integer,!0),c=r.readString(bt.Integer,!0);r.readString(bt.Integer,!0),r.readString(bt.Integer,!0);let l=r.readString(bt.Integer,!0),f=Buffer.from("ssh-rsa"),u=Buffer.allocUnsafe(4+f.length+4+s.length+4+i.length+4+o.length+4+l.length+4+a.length+4+c.length),h=0;u.writeUInt32BE(f.length,h+=0),u.set(f,h+=4),u.writeUInt32BE(s.length,h+=f.length),u.set(s,h+=4),u.writeUInt32BE(i.length,h+=s.length),u.set(i,h+=4),u.writeUInt32BE(o.length,h+=i.length),u.set(o,h+=4),u.writeUInt32BE(l.length,h+=o.length),u.set(l,h+=4),u.writeUInt32BE(a.length,h+=l.length),u.set(a,h+=4),u.writeUInt32BE(c.length,h+=a.length),u.set(c,h+=4);let p=Buffer.allocUnsafe(4+f.length+4+i.length+4+s.length);return h=0,p.writeUInt32BE(f.length,h+=0),p.set(f,h+=4),p.writeUInt32BE(i.length,h+=f.length),p.set(i,h+=4),p.writeUInt32BE(s.length,h+=i.length),p.set(s,h+=4),{sshName:f.toString(),priv:u,pub:p}}case"ec":{let r=new bt.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");r.readOID();let s=r.readString(bt.BitString,!0);{let h=0;for(;h<s.length&&s[h]===0;++h);h>0&&(s=s.slice(h))}if(r=new bt.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");let i=r.readOID(),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(r=new bt.Reader(r.readString(bt.OctetString,!0)),r.readSequence(),r.readInt()!==1)throw new Error("Unsupported version in ECDSA private key");let a=Buffer.concat([Buffer.from([0]),r.readString(bt.OctetString,!0)]),c=Buffer.from(`ecdsa-sha2-${o}`);o=Buffer.from(o);let l=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length+4+a.length),f=0;l.writeUInt32BE(c.length,f+=0),l.set(c,f+=4),l.writeUInt32BE(o.length,f+=c.length),l.set(o,f+=4),l.writeUInt32BE(s.length,f+=o.length),l.set(s,f+=4),l.writeUInt32BE(a.length,f+=s.length),l.set(a,f+=4);let u=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length);return f=0,u.writeUInt32BE(c.length,f+=0),u.set(c,f+=4),u.writeUInt32BE(o.length,f+=c.length),u.set(o,f+=4),u.writeUInt32BE(s.length,f+=o.length),u.set(s,f+=4),{sshName:c.toString(),priv:l,pub:u}}case"ed25519":{let r=new bt.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let s=r.readString(bt.BitString,!0);{let f=0;for(;f<s.length&&s[f]===0;++f);f>0&&(s=s.slice(f))}if(r=new bt.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ED25519 private key");if(r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 private OID");r=new bt.Reader(r.readString(bt.OctetString,!0));let i=r.readString(bt.OctetString,!0),o=Buffer.from("ssh-ed25519"),a=Buffer.allocUnsafe(4+o.length+4+s.length+4+(i.length+s.length)),c=0;a.writeUInt32BE(o.length,c+=0),a.set(o,c+=4),a.writeUInt32BE(s.length,c+=o.length),a.set(s,c+=4),a.writeUInt32BE(i.length+s.length,c+=s.length),a.set(i,c+=4),a.set(s,c+=i.length);let l=Buffer.allocUnsafe(4+o.length+4+s.length);return c=0,l.writeUInt32BE(o.length,c+=0),l.set(o,c+=4),l.writeUInt32BE(s.length,c+=o.length),l.set(s,c+=4),{sshName:o.toString(),priv:a,pub:l}}}}function eu(n,t,e,r){let s="new",i,o="";if(typeof r=="object"&&r!==null&&(typeof r.comment=="string"&&r.comment&&(o=r.comment),typeof r.format=="string"&&r.format&&(s=r.format),r.passphrase)){let a;if(typeof r.passphrase=="string")a=Buffer.from(r.passphrase);else if(Buffer.isBuffer(r.passphrase))a=r.passphrase;else throw new Error("Invalid passphrase");if(r.cipher===void 0)throw new Error("Missing cipher name");let c=Mm.get(r.cipher);if(c===void 0)throw new Error("Invalid cipher name");if(s==="new"){let l=Um;if(r.rounds!==void 0){if(!Number.isInteger(r.rounds))throw new TypeError("rounds must be an integer");r.rounds>0&&(l=r.rounds)}let f=Buffer.allocUnsafe(c.keyLen+c.ivLen),u=Jf(Dm);if(Lm(a,a.length,u,u.length,f,f.length,l)!==0)return new Error("Failed to generate information to encrypt key");let p=Buffer.allocUnsafe(4+u.length+4);{let y=0;p.writeUInt32BE(u.length,y+=0),p.set(u,y+=4),p.writeUInt32BE(l,y+=u.length)}i={cipher:c,cipherName:r.cipher,kdfName:"bcrypt",kdfOptions:p,key:f.slice(0,c.keyLen),iv:f.slice(c.keyLen)}}}switch(s){case"new":{let a=`-----BEGIN OPENSSH PRIVATE KEY-----
|
|
15
|
+
${e}`}};var s0=2**32,rf=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();Si.ERR_OUT_OF_RANGE=class of extends RangeError{constructor(t,e,r,s){super(),Error.captureStackTrace(this,of),ws(e,'Missing "range" argument');let i=s?t:`The value of "${t}" is out of range.`,o;Number.isInteger(r)&&Math.abs(r)>s0?o=tf(String(r)):typeof r=="bigint"?(o=String(r),(r>rf||r<-rf)&&(o=tf(o)),o+="n"):o=i0(r),i+=` It must be ${e}. Received ${o}`,this.message=i}};var Is=class n extends TypeError{constructor(t,e,r){super(),Error.captureStackTrace(this,n),ws(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} ${nf(e,"type")}`;else{let o=t.includes(".")?"property":"argument";i=`The "${t}" ${o} ${s} ${nf(e,"type")}`}i+=`. Received type ${typeof r}`,this.message=i}};Si.ERR_INVALID_ARG_TYPE=Is;Si.validateNumber=function(t,e){if(typeof t!="number")throw new Is(e,"number",t)}});var wi=ct((i_,Ef)=>{"use strict";var o0=require("events"),Yn=require("fs"),{constants:en}=Yn,{Readable:hf,Writable:Ba}=require("stream"),{inherits:pf,types:{isDate:Sa}}=require("util"),a0=Buffer[Symbol.species],{bufferCopy:zn,bufferSlice:Mr,makeBufferParser:c0,writeUInt32BE:V}=mn(),Un={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},Ne=Buffer.alloc(28),tt={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},l0=new Map(Object.values(tt).map(n=>[n,1])),f0={[tt.OK]:"No error",[tt.EOF]:"End of file",[tt.NO_SUCH_FILE]:"No such file or directory",[tt.PERMISSION_DENIED]:"Permission denied",[tt.FAILURE]:"Failure",[tt.BAD_MESSAGE]:"Bad message",[tt.NO_CONNECTION]:"No connection",[tt.CONNECTION_LOST]:"Connection lost",[tt.OP_UNSUPPORTED]:"Operation unsupported"},Be={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},tn={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},Ce={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},cf=2*1024,ut=2**32-1,u0=Buffer.from([0,0,0,5,Be.INIT,0,0,0,3]),d0=Buffer.from([0,0,0,5,tn.VERSION,0,0,0,3]),h0=/^SSH-2.0-(?:OpenSSH|dropbear)/,ba=256*1024,M=c0(),p0={readable:!1,writable:!1,push:n=>{},once:()=>{},on:()=>{},emit:()=>{},end:()=>{}};function gf(){}var wa=class extends o0{constructor(t,e,r){super(),(typeof r!="object"||!r)&&(r={});let s=t._protocol._remoteIdentRaw;this.server=!!r.server,this._debug=typeof r.debug=="function"?r.debug:void 0,this._isOpenSSH=s&&h0.test(s),this._version=-1,this._extensions={},this._biOpt=r.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=ba,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?ba:34e3)-cf,this._maxWriteLen=(this._isOpenSSH?ba:34e3)-cf,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=p0,this.readable=!0}push(t){if(t===null){if(_f(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 st(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return st(this,`Packet length ${this._pktLen} exceeds max length of ${a}`)}if(e>=t.length)return}if(this._pktPos<this._pktLen){let o=Math.min(this._pktLen-this._pktPos,t.length-e);if(e!==0||o!==t.length?o===this._pktLen?this._pkt=new a0(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}let r=this._pkt[0],s=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let i=this.server?_0[r]:y0[r];if(!i)return st(this,`Unknown packet type ${r}`);if(this._version===-1){if(this.server){if(r!==Be.INIT)return st(this,`Expected INIT packet, got ${r}`)}else if(r!==tn.VERSION)return st(this,`Expected VERSION packet, got ${r}`)}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=gf,this.server||Je(this,u0)}createReadStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new On(this,t,e)}createWriteStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new gn(this,t,e)}open(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(s=r,r=void 0);let i=typeof e=="number"?e:Af(e);if(i===null)throw new Error(`Unknown flags string: ${e}`);let o=0,a=0;(typeof r=="string"||typeof r=="number")&&(r={mode:r}),typeof r=="object"&&r!==null&&(r=ur(r),o=r.flags,a=r.nb);let c=Buffer.byteLength(t),l=9,f=Buffer.allocUnsafe(13+c+4+4+a);V(f,f.length-4,0),f[4]=Be.OPEN;let u=this._writeReqid=this._writeReqid+1&ut;V(f,u,5),V(f,c,l),f.utf8Write(t,l+=4,c),V(f,i,l+=c),V(f,o,l+=4),a&&(l+=4,a===Ne.length?f.set(Ne,l):zn(Ne,f,0,a,l),l+=a),this._requests[u]={cb:s};let h=Je(this,f);this._debug&&this._debug(`SFTP: Outbound: ${h?"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");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.CLOSE;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} CLOSE`)}read(t,e,r,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(r>=e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");mf(this,t,e,r,s,i,o)}readData(t,e,r,s,i,o){this.read(t,e,r,s,i,o)}write(t,e,r,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(r>e.length)throw new Error("offset is out of bounds");if(r+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}let a=this._maxWriteLen,c=Math.max(s-a,0),l=i;c&&(s=a);let f=t.length,u=9,h=Buffer.allocUnsafe(13+f+8+4+s);V(h,h.length-4,0),h[4]=Be.WRITE;let p=this._writeReqid=this._writeReqid+1&ut;V(h,p,5),V(h,f,u),h.set(t,u+=4),u+=f;for(let _=7;_>=0;--_)h[u+_]=i&255,i/=256;V(h,s,u+=8),zn(e,h,r,r+s,u+=4),this._requests[p]={cb:_=>{_?typeof o=="function"&&o(_):c?this.write(t,e,r+s,c,l+s,o):typeof o=="function"&&o(void 0,r+s)}};let y=Je(this,h);if(this._debug){let _=y?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${_} WRITE (id:${p})`)}}writeData(t,e,r,s,i,o){this.write(t,e,r,s,i,o)}fastGet(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");lf(this,Yn,t,e,r,s)}fastPut(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");lf(Yn,this,t,e,r,s)}readFile(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof r=="function"?s=r: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");let i=e.encoding;if(i&&!Buffer.isEncoding(i))throw new Error(`Unknown encoding: ${i}`);let o,a,c,l=0,f,u=0,h=e.flag||"r",p=()=>{o===0?(a=Buffer.allocUnsafe(8192),this.read(f,a,0,8192,u,y)):this.read(f,a,l,o-l,u,y)},y=(x,S)=>{let R;if(x){if(R=x.code===tt.EOF,!R)return this.close(f,()=>s&&s(x))}else R=!1;if(R||o===0&&S===0)return _();u+=S,l+=S,o!==0?l===o?_():p():(c.push(Mr(a,0,S)),p())};y._wantEOFError=!0;let _=()=>{this.close(f,x=>(o===0?a=Buffer.concat(c,l):l<o&&(a=Mr(a,0,l)),i&&(a=a.toString(i)),s&&s(x,a)))};this.open(t,h,438,(x,S)=>{if(x)return s&&s(x);f=S;let R=(H,C)=>{if(H){this.stat(t,(U,Q)=>{if(U)return this.close(f,()=>{s&&s(H)});R(null,Q)});return}if(o=C.size||0,o===0)return c=[],p();a=Buffer.allocUnsafe(o),p()};this.fstat(f,R)})}writeFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"w"};else if(!r)r={encoding:"utf8",mode:438,flag:"w"};else if(typeof r!="object")throw new TypeError("Bad arguments");if(r.encoding&&!Buffer.isEncoding(r.encoding))throw new Error(`Unknown encoding: ${r.encoding}`);let o=r.flag||"w";this.open(t,o,r.mode,(a,c)=>{if(a)i&&i(a);else{let l=Buffer.isBuffer(e)?e:Buffer.from(""+e,r.encoding||"utf8"),f=/a/.test(o)?null:0;if(f===null){let u=(h,p)=>{if(h){this.stat(t,(y,_)=>{if(y)return this.close(c,()=>{i&&i(h)});u(null,_)});return}Ia(this,c,l,0,l.length,p.size,i)};this.fstat(c,u);return}Ia(this,c,l,0,l.length,f,i)}})}appendFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"a"};else if(!r)r={encoding:"utf8",mode:438,flag:"a"};else if(typeof r!="object")throw new TypeError("Bad arguments");r.flag||(r=Object.assign({flag:"a"},r)),this.writeFile(t,e,r,i)}exists(t,e){if(this.server)throw new Error("Client-only method called in server mode");this.stat(t,r=>{e&&e(!r)})}unlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.REMOVE;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REMOVE`)}rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=9,a=Buffer.allocUnsafe(13+s+4+i);V(a,a.length-4,0),a[4]=Be.RENAME;let c=this._writeReqid=this._writeReqid+1&ut;V(a,c,5),V(a,s,o),a.utf8Write(t,o+=4,s),V(a,i,o+=s),a.utf8Write(e,o+=4,i),this._requests[c]={cb:r};let l=Je(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} RENAME`)}mkdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="function"&&(r=e,e=void 0),typeof e=="object"&&e!==null&&(e=ur(e),s=e.flags,i=e.nb);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);V(c,c.length-4,0),c[4]=Be.MKDIR;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,o,a),c.utf8Write(t,a+=4,o),V(c,s,a+=o),i&&(a+=4,i===Ne.length?c.set(Ne,a):zn(Ne,c,0,i,a),a+=i),this._requests[l]={cb:r};let f=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} MKDIR`)}rmdir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.RMDIR;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} RMDIR`)}readdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");typeof e=="function"&&(r=e,e={}),(typeof e!="object"||e===null)&&(e={});let s=!(e&&e.full);if(!Buffer.isBuffer(t)&&typeof t!="string")throw new Error("missing directory handle or path");if(typeof t=="string"){let f=[],u=0,h=(p,y)=>{if(p)return r(p);this.readdir(y,e,(_,x)=>{let S=_&&_.code===tt.EOF;if(_&&!S)return this.close(y,()=>r(_));if(S)return this.close(y,R=>{if(R)return r(R);r(void 0,f)});for(let R=0;R<x.length;++R,++u)f[u]=x[R];h(void 0,y)})};return this.opendir(t,h)}let i=t.length,o=9,a=Buffer.allocUnsafe(13+i);V(a,a.length-4,0),a[4]=Be.READDIR;let c=this._writeReqid=this._writeReqid+1&ut;V(a,c,5),V(a,i,o),a.set(t,o+=4),this._requests[c]={cb:s?(f,u)=>{if(typeof r=="function"){if(f)return r(f);for(let h=u.length-1;h>=0;--h)(u[h].filename==="."||u[h].filename==="..")&&u.splice(h,1);r(void 0,u)}}:r};let l=Je(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"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");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.FSTAT;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} FSTAT`)}stat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.STAT;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STAT`)}lstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.LSTAT;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} LSTAT`)}opendir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.OPENDIR;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} OPENDIR`)}setstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="object"&&e!==null?(e=ur(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);V(c,c.length-4,0),c[4]=Be.SETSTAT;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,o,a),c.utf8Write(t,a+=4,o),V(c,s,a+=o),i&&(a+=4,i===Ne.length?c.set(Ne,a):zn(Ne,c,0,i,a),a+=i),this._requests[l]={cb:r};let f=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} SETSTAT`)}fsetstat(t,e,r){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=ur(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=t.length,a=9,c=Buffer.allocUnsafe(13+o+4+i);V(c,c.length-4,0),c[4]=Be.FSETSTAT;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,o,a),c.set(t,a+=4),V(c,s,a+=o),i&&(a+=4,i===Ne.length?c.set(Ne,a):zn(Ne,c,0,i,a),a+=i),this._requests[l]={cb:r};let f=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} FSETSTAT`)}futimes(t,e,r,s){return this.fsetstat(t,{atime:Ur(e),mtime:Ur(r)},s)}utimes(t,e,r,s){return this.setstat(t,{atime:Ur(e),mtime:Ur(r)},s)}fchown(t,e,r,s){return this.fsetstat(t,{uid:e,gid:r},s)}chown(t,e,r,s){return this.setstat(t,{uid:e,gid:r},s)}fchmod(t,e,r){return this.fsetstat(t,{mode:e},r)}chmod(t,e,r){return this.setstat(t,{mode:e},r)}readlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.READLINK;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing link info"));e(void 0,l[0].filename)}}};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} READLINK`)}symlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=Buffer.byteLength(t),o=9,a=Buffer.allocUnsafe(13+s+4+i);V(a,a.length-4,0),a[4]=Be.SYMLINK;let c=this._writeReqid=this._writeReqid+1&ut;V(a,c,5),this._isOpenSSH?(V(a,i,o),a.utf8Write(t,o+=4,i),V(a,s,o+=i),a.utf8Write(e,o+=4,s)):(V(a,s,o),a.utf8Write(e,o+=4,s),V(a,i,o+=s),a.utf8Write(t,o+=4,i)),this._requests[c]={cb:r};let l=Je(this,a);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} SYMLINK`)}realpath(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=Be.REALPATH;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing path info"));e(void 0,l[0].filename)}}};let a=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=this._extensions["posix-rename@openssh.com"];if(!s||s!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(41+i+4+o);V(c,c.length-4,0),c[4]=Be.EXTENDED;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,24,a),c.utf8Write("posix-rename@openssh.com",a+=4,24),V(c,i,a+=24),c.utf8Write(t,a+=4,i),V(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[l]={cb:r};let f=Je(this,c);if(this._debug){let u=f?"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");let r=this._extensions["statvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(36+s);V(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,19,i),o.utf8Write("statvfs@openssh.com",i+=4,19),V(o,s,i+=19),o.utf8Write(t,i+=4,s),this._requests[a]={extended:"statvfs@openssh.com",cb:e};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} statvfs@openssh.com`)}}ext_openssh_fstatvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["fstatvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(37+s);V(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,20,i),o.utf8Write("fstatvfs@openssh.com",i+=4,20),V(o,s,i+=20),o.set(t,i+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:e};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} fstatvfs@openssh.com`)}}ext_openssh_hardlink(t,e,r){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");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(37+i+4+o);V(c,c.length-4,0),c[4]=Be.EXTENDED;let l=this._writeReqid=this._writeReqid+1&ut;V(c,l,5),V(c,20,a),c.utf8Write("hardlink@openssh.com",a+=4,20),V(c,i,a+=20),c.utf8Write(t,a+=4,i),V(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[l]={cb:r};let f=Je(this,c);if(this._debug){let u=f?"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");let s=t.length,i=9,o=Buffer.allocUnsafe(34+s);V(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,17,i),o.utf8Write("fsync@openssh.com",i+=4,17),V(o,s,i+=17),o.set(t,i+=4),this._requests[a]={cb:e};let c=Je(this,o);this._debug&&this._debug(`SFTP: Outbound: ${c?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(t,e,r){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=ur(e),i=e.flags,o=e.nb):typeof e=="function"&&(r=e);let a=Buffer.byteLength(t),c=9,l=Buffer.allocUnsafe(37+a+4+o);V(l,l.length-4,0),l[4]=Be.EXTENDED;let f=this._writeReqid=this._writeReqid+1&ut;V(l,f,5),V(l,20,c),l.utf8Write("lsetstat@openssh.com",c+=4,20),V(l,a,c+=20),l.utf8Write(t,c+=4,a),V(l,i,c+=a),o&&(c+=4,o===Ne.length?l.set(Ne,c):zn(Ne,l,0,o,c),c+=o),this._requests[f]={cb:r};let u=Je(this,l);if(this._debug){let h=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} 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");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(40+s);V(o,o.length-4,0),o[4]=Be.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,23,i),o.utf8Write("expand-path@openssh.com",i+=4,23),V(o,s,i+=20),o.utf8Write(t,i+=4,s),this._requests[a]={cb:(l,f)=>{if(typeof e=="function"){if(l)return e(l);if(!f||!f.length)return e(new Error("Response missing expanded path"));e(void 0,f[0].filename)}}};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} expand-path@openssh.com`)}}ext_copy_data(t,e,r,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,l=Buffer.allocUnsafe(26+t.length+8+8+4+s.length+8);V(l,l.length-4,c),c+=4,l[c]=Be.EXTENDED,++c;let f=this._writeReqid=this._writeReqid+1&ut;V(l,f,c),c+=4,V(l,9,c),c+=4,l.utf8Write("copy-data",c,9),c+=9,V(l,t.length,c),c+=4,l.set(t,c),c+=t.length;for(let h=7;h>=0;--h)l[c+h]=e&255,e/=256;c+=8;for(let h=7;h>=0;--h)l[c+h]=r&255,r/=256;c+=8,V(l,s.length,c),c+=4,l.set(s,c),c+=s.length;for(let h=7;h>=0;--h)l[c+h]=i&255,i/=256;this._requests[f]={cb:o};let u=Je(this,l);if(this._debug){let h=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} 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,i=Buffer.byteLength(t),o=Buffer.allocUnsafe(31+i);V(o,o.length-4,s),s+=4,o[s]=Be.EXTENDED,++s;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,s),s+=4,V(o,14,s),s+=4,o.utf8Write("home-directory",s,14),s+=14,V(o,i,s),s+=4,o.utf8Write(t,s,i),s+=i,this._requests[a]={cb:(l,f)=>{if(typeof e=="function"){if(l)return e(l);if(!f||!f.length)return e(new Error("Response missing home directory"));e(void 0,f[0].filename)}}};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} home-directory`)}}ext_users_groups(t,e,r){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(let l of t)if(!Number.isInteger(l)||l<0||l>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(let l of e)if(!Number.isInteger(l)||l<0||l>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let i=0,o=Buffer.allocUnsafe(47+4*t.length+4+4*e.length);V(o,o.length-4,i),i+=4,o[i]=Be.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,i),i+=4,V(o,30,i),i+=4,o.utf8Write("users-groups-by-id@openssh.com",i,30),i+=30,V(o,4*t.length,i),i+=4;for(let l of t)V(o,l,i),i+=4;V(o,4*e.length,i),i+=4;for(let l of e)V(o,l,i),i+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:r};let c=Je(this,o);if(this._debug){let l=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${l} 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");let r=e.length;if(r>256)throw new Error("handle too large (> 256 bytes)");let s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=tn.HANDLE,V(i,t,5),V(i,r,s),r&&i.set(e,s+=4);let o=Je(this,i);this._debug&&this._debug(`SFTP: Outbound: ${o?"Buffered":"Sending"} HANDLE`)}status(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!l0.has(e))throw new Error(`Bad status code: ${e}`);r||(r="");let s=Buffer.byteLength(r),i=9,o=Buffer.allocUnsafe(17+s+4);V(o,o.length-4,0),o[4]=tn.STATUS,V(o,t,5),V(o,e,i),V(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),V(o,0,i);let a=Je(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STATUS`)}data(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");let s=Buffer.isBuffer(e);if(!s&&typeof e!="string")throw new Error("data is not a Buffer or string");let i;!s&&!r&&(r=void 0,i=!0);let o=s?e.length:Buffer.byteLength(e,r),a=9,c=Buffer.allocUnsafe(13+o);V(c,c.length-4,0),c[4]=tn.DATA,V(c,t,5),V(c,o,a),o&&(s?c.set(e,a+=4):i?c.utf8Write(e,a+=4,o):c.write(e,a+=4,o,r));let l=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"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]}let r=e.length,s=0,i,o=[];for(let f=0;f<r;++f){let u=e[f],h=!u||!u.filename||typeof u.filename!="string"?"":u.filename;s+=4+Buffer.byteLength(h);let p=!u||!u.longname||typeof u.longname!="string"?"":u.longname;if(s+=4+Buffer.byteLength(p),typeof u.attrs=="object"&&u.attrs!==null){if(i=ur(u.attrs),s+=4+i.nb,i.nb){let y;i.nb===Ne.length?y=new Uint8Array(Ne):(y=new Uint8Array(i.nb),zn(Ne,y,0,i.nb,0)),i.bytes=y}o.push(i)}else s+=4,o.push(null)}let a=9,c=Buffer.allocUnsafe(13+s);V(c,c.length-4,0),c[4]=tn.NAME,V(c,t,5),V(c,r,a),a+=4;for(let f=0;f<r;++f){let u=e[f];{let p=!u||!u.filename||typeof u.filename!="string"?"":u.filename,y=Buffer.byteLength(p);V(c,y,a),a+=4,y&&(c.utf8Write(p,a,y),a+=y)}{let p=!u||!u.longname||typeof u.longname!="string"?"":u.longname,y=Buffer.byteLength(p);V(c,y,a),a+=4,y&&(c.utf8Write(p,a,y),a+=y)}let h=o[f];h?(V(c,h.flags,a),a+=4,h.flags&&h.bytes&&(c.set(h.bytes,a),a+=h.nb)):(V(c,0,a),a+=4)}let l=Je(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"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=ur(e);let r=e.flags,s=e.nb,i=9,o=Buffer.allocUnsafe(13+s);V(o,o.length-4,0),o[4]=tn.ATTRS,V(o,t,5),V(o,r,i),s&&(i+=4,s===Ne.length?o.set(Ne,i):zn(Ne,o,0,s,i),i+=s);let a=Je(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function g0(n){try{return Buffer.allocUnsafe(n)}catch(t){return t}}function mf(n,t,e,r,s,i,o,a){let c=n._maxReadLen,l=Math.max(s-c,0);l&&(s=c);let f=t.length,u=9,h=i,p=Buffer.allocUnsafe(13+f+8+4);V(p,p.length-4,0),p[4]=Be.READ;let y=n._writeReqid=n._writeReqid+1&ut;V(p,y,5),V(p,f,u),p.set(t,u+=4),u+=f;for(let S=7;S>=0;--S)p[u+S]=h&255,h/=256;V(p,s,u+=8),typeof o!="function"&&(o=gf);let _=a||{nb:0,position:i,off:r,origOff:r,len:void 0,overflow:void 0,cb:(S,R,H)=>{let C=_.len,U=_.overflow;if(S){if(o._wantEOFError||S.code!==tt.EOF)return o(S)}else{if(H>C)return o(new Error("Received more data than requested"));if(H===C&&U){_.nb+=H,_.position+=H,_.off+=H,mf(n,t,e,_.off,U,_.position,o,_);return}}H=H||0,_.origOff===0&&e.length===_.nb?R=e:R=Mr(e,_.origOff,_.origOff+_.nb+H),o(void 0,_.nb+H,R,_.position)},buffer:void 0};_.len=s,_.overflow=l,_.buffer=Mr(e,r,r+s),n._requests[y]=_;let x=Je(n,p);n._debug&&n._debug(`SFTP: Outbound: ${x?"Buffered":"Sending"} READ`)}function lf(n,t,e,r,s,i){let o=64,a=32768,c,l,f;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)&&(a=s.chunkSize),typeof s.fileSize=="number"&&s.fileSize>0&&!isNaN(s.fileSize)&&(f=s.fileSize),typeof s.step=="function"&&(c=s.step),(typeof s.mode=="string"||typeof s.mode=="number")&&(l=Ra(s.mode)));let u,h=0,p=0,y=!1,_,x,S,R=a*o;function H(C){if(y)return;y=!0;let U=0,Q;_||x?(Q=()=>{--U===0&&i(C)},_&&(n===Yn||n.outgoing.state==="open")&&++U,x&&(t===Yn||t.outgoing.state==="open")&&++U,_&&(n===Yn||n.outgoing.state==="open")&&n.close(_,Q),x&&(t===Yn||t.outgoing.state==="open")&&t.close(x,Q)):i(C)}n.open(e,"r",(C,U)=>{if(C)return H(C);_=U,f===void 0?n.fstat(_,Q):Q(null,{size:f});function Q(B,b){if(B){if(n!==Yn){n.stat(e,(w,k)=>{if(w)return H(B);Q(null,k)});return}return H(B)}u=b.size,t.open(r,"w",(w,k)=>{if(w)return H(w);if(x=k,u<=0)return H();for(;R>u;){if(o===1){R=u;break}R-=a,--o}if(S=g0(R),S instanceof Error)return H(S);l!==void 0?t.fchmod(x,l,function Y(te){if(te){t.chmod(r,l,le=>Y());return}z()}):z();function v(Y,te,le,O,N,L){if(Y)return H(Y);N=N||0,t.write(x,S,N,te,O,K);function K(ee){if(ee)return H(ee);if(p+=te,c&&c(p,te,u),te<L)return ne(N,O+te,L-te);if(p===u){t.close(x,ie=>{if(x=void 0,ie)return H(ie);n.close(_,je=>{if(_=void 0,je)return H(je);i()})});return}if(h>=u)return;let ue=h+a>u?u-h:a;ne(N,h,ue),h+=ue}}function P(Y,te,le){return(O,N,L)=>{v(O,N,L,te,Y,le)}}function ne(Y,te,le){n.read(_,S,Y,le,te,P(Y,te,le))}function z(){let Y=0,te=0;for(;h<u&&Y<o;){let le=h+a>u?u-h:a;ne(te,h,le),te+=le,h+=le,++Y}}})}})}function Ia(n,t,e,r,s,i,o){let a=typeof o=="function"?o:void 0;n.write(t,e,r,s,i,(c,l)=>{if(c)return n.close(t,()=>{a&&a(c)});l===s?n.close(t,a):(r+=l,s-=l,i+=l,Ia(n,t,e,r,s,i,a))})}var ks=class{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&en.S_IFMT)===en.S_IFDIR}isFile(){return(this.mode&en.S_IFMT)===en.S_IFREG}isBlockDevice(){return(this.mode&en.S_IFMT)===en.S_IFBLK}isCharacterDevice(){return(this.mode&en.S_IFMT)===en.S_IFCHR}isSymbolicLink(){return(this.mode&en.S_IFMT)===en.S_IFLNK}isFIFO(){return(this.mode&en.S_IFMT)===en.S_IFIFO}isSocket(){return(this.mode&en.S_IFMT)===en.S_IFSOCK}};function ur(n){let t=0,e=0;if(typeof n=="object"&&n!==null){if(typeof n.size=="number"){t|=Un.SIZE;let r=n.size;Ne[e++]=r/72057594037927940,Ne[e++]=r/281474976710656,Ne[e++]=r/1099511627776,Ne[e++]=r/4294967296,Ne[e++]=r/16777216,Ne[e++]=r/65536,Ne[e++]=r/256,Ne[e++]=r}if(typeof n.uid=="number"&&typeof n.gid=="number"){t|=Un.UIDGID;let r=n.uid,s=n.gid;Ne[e++]=r>>>24,Ne[e++]=r>>>16,Ne[e++]=r>>>8,Ne[e++]=r,Ne[e++]=s>>>24,Ne[e++]=s>>>16,Ne[e++]=s>>>8,Ne[e++]=s}if(typeof n.mode=="number"||typeof n.mode=="string"){let r=Ra(n.mode);t|=Un.PERMISSIONS,Ne[e++]=r>>>24,Ne[e++]=r>>>16,Ne[e++]=r>>>8,Ne[e++]=r}if((typeof n.atime=="number"||Sa(n.atime))&&(typeof n.mtime=="number"||Sa(n.mtime))){let r=Ur(n.atime),s=Ur(n.mtime);t|=Un.ACMODTIME,Ne[e++]=r>>>24,Ne[e++]=r>>>16,Ne[e++]=r>>>8,Ne[e++]=r,Ne[e++]=s>>>24,Ne[e++]=s>>>16,Ne[e++]=s>>>8,Ne[e++]=s}}return{flags:t,nb:e}}function Ur(n){if(typeof n=="number"&&n===n)return n;if(Sa(n))return parseInt(n.getTime()/1e3,10);throw new Error(`Cannot parse time: ${n}`)}function Ra(n){if(typeof n=="number"&&n===n)return n;if(typeof n=="string")return Ra(parseInt(n,8));throw new Error(`Cannot parse mode: ${n}`)}var Ca={r:Ce.READ,"r+":Ce.READ|Ce.WRITE,w:Ce.TRUNC|Ce.CREAT|Ce.WRITE,wx:Ce.TRUNC|Ce.CREAT|Ce.WRITE|Ce.EXCL,xw:Ce.TRUNC|Ce.CREAT|Ce.WRITE|Ce.EXCL,"w+":Ce.TRUNC|Ce.CREAT|Ce.READ|Ce.WRITE,"wx+":Ce.TRUNC|Ce.CREAT|Ce.READ|Ce.WRITE|Ce.EXCL,"xw+":Ce.TRUNC|Ce.CREAT|Ce.READ|Ce.WRITE|Ce.EXCL,a:Ce.APPEND|Ce.CREAT|Ce.WRITE,ax:Ce.APPEND|Ce.CREAT|Ce.WRITE|Ce.EXCL,xa:Ce.APPEND|Ce.CREAT|Ce.WRITE|Ce.EXCL,"a+":Ce.APPEND|Ce.CREAT|Ce.READ|Ce.WRITE,"ax+":Ce.APPEND|Ce.CREAT|Ce.READ|Ce.WRITE|Ce.EXCL,"xa+":Ce.APPEND|Ce.CREAT|Ce.READ|Ce.WRITE|Ce.EXCL};function Af(n){let t=Ca[n];return t!==void 0?t:null}var m0=(()=>{let n=Object.keys(Ca);return t=>{for(let e=0;e<n.length;++e){let r=n[e];if(Ca[r]===t)return r}return null}})();function Or(n){let t=M.readUInt32BE();if(t===void 0)return;let e=new ks;if(t&Un.SIZE){let r=M.readUInt64BE(n);if(r===void 0)return;e.size=r}if(t&Un.UIDGID){let r=M.readUInt32BE(),s=M.readUInt32BE();if(s===void 0)return;e.uid=r,e.gid=s}if(t&Un.PERMISSIONS){let r=M.readUInt32BE();if(r===void 0)return;e.mode=r}if(t&Un.ACMODTIME){let r=M.readUInt32BE(),s=M.readUInt32BE();if(s===void 0)return;e.atime=r,e.mtime=s}if(t&Un.EXTENDED){let r=M.readUInt32BE();if(r===void 0)return;let s={};for(let i=0;i<r;++i){let o=M.readString(!0),a=M.readString();if(a===void 0)return;s[o]=a}e.extended=s}return e}function Je(n,t){let e=yf(n,t);return e!==void 0?(n._buffer.push(e),!1):!0}function yf(n,t){let e=n.outgoing;if(e.state!=="open")return;if(e.window===0)return n._waitWindow=!0,n._chunkcb=ff,t;let r,s=t.length,i=0;for(;s-i>0&&e.window>0;){let o=Math.min(s-i,e.window,e.packetSize);e.window-=o,e.window===0&&(n._waitWindow=!0,n._chunkcb=ff),i===0&&o===s?n._protocol.channelData(n.outgoing.id,t):n._protocol.channelData(n.outgoing.id,Mr(t,i,i+o)),i+=o}return s-i>0&&(i>0?r=Mr(t,i,s):r=t),r}function ff(){this._chunkcb=void 0;let n=this._buffer,t=0;for(;t<n.length;){let e=n[t],r=yf(this,e);if(r!==void 0){r!==e&&(n[t]=r),t>0&&(this._buffer=n.slice(t));return}++t}t>0&&(this._buffer=[])}function st(n,t,e){let r=new Error(t);return r.level="sftp-protocol",!e&&n._debug&&n._debug(`SFTP: Inbound: ${t}`),n.emit("error",r),n.destroy(),_f(n),!1}function _f(n){let t=Object.keys(n._requests);if(t.length===0)return;let e=n._requests;n._requests={};let r=new Error("No response from server");for(let s=0;s<t.length;++s){let i=e[t[s]];typeof i.cb=="function"&&i.cb(r)}}function A0(n,t){let e=9,r=Buffer.allocUnsafe(31);V(r,r.length-4,0),r[4]=Be.EXTENDED;let s=n._writeReqid=n._writeReqid+1&ut;V(r,s,5),V(r,18,e),r.utf8Write("limits@openssh.com",e+=4,18),n._requests[s]={extended:"limits@openssh.com",cb:t};let i=Je(n,r);if(n._debug){let o=i?"Buffered":"Sending";n._debug(`SFTP: Outbound: ${o} limits@openssh.com`)}}var y0={[tn.VERSION]:(n,t)=>{if(n._version!==-1)return st(n,"Duplicate VERSION packet");let e={};M.init(t,1);let r=M.readUInt32BE();for(;M.avail();){let s=M.readString(!0),i=M.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(M.clear(),r===void 0)return st(n,"Malformed VERSION packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received VERSION (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received VERSION (v${r})`)}if(n._version=r,n._extensions=e,e["limits@openssh.com"]==="1")return A0(n,(s,i)=>{s||(i.maxPktLen>0&&(n._maxOutPktLen=i.maxPktLen),i.maxReadLen>0&&(n._maxReadLen=i.maxReadLen),i.maxWriteLen>0&&(n._maxWriteLen=i.maxWriteLen),n.maxOpenHandles=i.maxOpenHandles>0?i.maxOpenHandles:1/0),n.emit("ready")});n.emit("ready")},[tn.STATUS]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readUInt32BE(),s=M.readString(!0);if(M.clear(),n._debug){let o=JSON.stringify(s);n._debug(`SFTP: Inbound: Received STATUS (id:${e}, ${r}, ${o})`)}let i=n._requests[e];if(delete n._requests[e],i&&typeof i.cb=="function"){if(r===tt.OK){i.cb();return}let o=new Error(s||f0[r]||"Unknown status");o.code=r,i.cb(o)}},[tn.HANDLE]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString();if(M.clear(),r===void 0)return e!==void 0&&delete n._requests[e],st(n,"Malformed HANDLE packet");n._debug&&n._debug(`SFTP: Inbound: Received HANDLE (id:${e})`);let s=n._requests[e];delete n._requests[e],s&&typeof s.cb=="function"&&s.cb(void 0,r)},[tn.DATA]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r;if(e!==void 0&&(r=n._requests[e],delete n._requests[e]),r&&typeof r.cb=="function")if(r.buffer){let s=M.readString(r.buffer);if(M.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`),r.cb(void 0,r.buffer,s);return}}else{let s=M.readString();if(M.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s.length})`),r.cb(void 0,s);return}}else{let s=M.skipString();if(M.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`);return}}return st(n,"Malformed DATA packet")},[tn.NAME]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=M.readUInt32BE();if(s!==void 0){let i=[];for(let o=0;o<s;++o){let a=M.readString(!0),c=M.readString(!0),l=Or(n._biOpt);if(l===void 0){i=void 0;break}i.push({filename:a,longname:c,attrs:l})}if(i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received NAME (id:${e}, ${i.length})`),M.clear(),r&&typeof r.cb=="function"&&r.cb(void 0,i);return}}return M.clear(),st(n,"Malformed NAME packet")},[tn.ATTRS]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=Or(n._biOpt);if(M.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received ATTRS (id:${e})`),r&&typeof r.cb=="function"&&r.cb(void 0,s);return}return st(n,"Malformed ATTRS packet")},[tn.EXTENDED]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE();if(e!==void 0){let r=n._requests[e];if(r)switch(delete n._requests[e],r.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{let s=n._biOpt,i={f_bsize:M.readUInt64BE(s),f_frsize:M.readUInt64BE(s),f_blocks:M.readUInt64BE(s),f_bfree:M.readUInt64BE(s),f_bavail:M.readUInt64BE(s),f_files:M.readUInt64BE(s),f_ffree:M.readUInt64BE(s),f_favail:M.readUInt64BE(s),f_sid:M.readUInt64BE(s),f_flag:M.readUInt64BE(s),f_namemax:M.readUInt64BE(s)};if(i.f_namemax===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),M.clear(),typeof r.cb=="function"&&r.cb(void 0,i);return}case"limits@openssh.com":{let s={maxPktLen:M.readUInt64BE(),maxReadLen:M.readUInt64BE(),maxWriteLen:M.readUInt64BE(),maxOpenHandles:M.readUInt64BE()};if(s.maxOpenHandles===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),M.clear(),typeof r.cb=="function"&&r.cb(void 0,s);return}case"users-groups-by-id@openssh.com":{let s=M.readUInt32BE();if(s===void 0)break;let i=new Array(s);for(let c=0;c<i.length;++c)i[c]=M.readString(!0);let o=M.readUInt32BE();if(o===void 0)break;let a=new Array(o);for(let c=0;c<a.length;++c)a[c]=M.readString(!0);if(a.length>0&&a[a.length-1]===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),M.clear(),typeof r.cb=="function"&&r.cb(void 0,i,a);return}default:n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),M.clear(),typeof r.cb=="function"&&r.cb();return}else{n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),M.clear();return}}return M.clear(),st(n,"Malformed EXTENDED_REPLY packet")}},_0={[Be.INIT]:(n,t)=>{if(n._version!==-1)return st(n,"Duplicate INIT packet");let e={};M.init(t,1);let r=M.readUInt32BE();for(;M.avail();){let s=M.readString(!0),i=M.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(M.clear(),r===void 0)return st(n,"Malformed INIT packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received INIT (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received INIT (v${r})`)}Je(n,d0),n._version=r,n._extensions=e,n.emit("ready")},[Be.OPEN]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=M.readUInt32BE(),i=Or(n._biOpt);if(M.clear(),i===void 0)return st(n,"Malformed OPEN packet");n._debug&&n._debug(`SFTP: Inbound: Received OPEN (id:${e})`),n.emit("OPEN",e,r,s,i)||n.status(e,tt.OP_UNSUPPORTED)},[Be.CLOSE]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString();if(M.clear(),r===void 0||r.length>256)return st(n,"Malformed CLOSE packet");n._debug&&n._debug(`SFTP: Inbound: Received CLOSE (id:${e})`),n.emit("CLOSE",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.READ]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(),s=M.readUInt64BE(n._biOpt),i=M.readUInt32BE();if(M.clear(),i===void 0||r.length>256)return st(n,"Malformed READ packet");n._debug&&n._debug(`SFTP: Inbound: Received READ (id:${e})`),n.emit("READ",e,r,s,i)||n.status(e,tt.OP_UNSUPPORTED)},[Be.WRITE]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(),s=M.readUInt64BE(n._biOpt),i=M.readString();if(M.clear(),i===void 0||r.length>256)return st(n,"Malformed WRITE packet");n._debug&&n._debug(`SFTP: Inbound: Received WRITE (id:${e})`),n.emit("WRITE",e,r,s,i)||n.status(e,tt.OP_UNSUPPORTED)},[Be.LSTAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed LSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received LSTAT (id:${e})`),n.emit("LSTAT",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.FSTAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString();if(M.clear(),r===void 0||r.length>256)return st(n,"Malformed FSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSTAT (id:${e})`),n.emit("FSTAT",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.SETSTAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=Or(n._biOpt);if(M.clear(),s===void 0)return st(n,"Malformed SETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received SETSTAT (id:${e})`),n.emit("SETSTAT",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)},[Be.FSETSTAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(),s=Or(n._biOpt);if(M.clear(),s===void 0||r.length>256)return st(n,"Malformed FSETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSETSTAT (id:${e})`),n.emit("FSETSTAT",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)},[Be.OPENDIR]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed OPENDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received OPENDIR (id:${e})`),n.emit("OPENDIR",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.READDIR]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString();if(M.clear(),r===void 0||r.length>256)return st(n,"Malformed READDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received READDIR (id:${e})`),n.emit("READDIR",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.REMOVE]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed REMOVE packet");n._debug&&n._debug(`SFTP: Inbound: Received REMOVE (id:${e})`),n.emit("REMOVE",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.MKDIR]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=Or(n._biOpt);if(M.clear(),s===void 0)return st(n,"Malformed MKDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received MKDIR (id:${e})`),n.emit("MKDIR",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)},[Be.RMDIR]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed RMDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received RMDIR (id:${e})`),n.emit("RMDIR",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.REALPATH]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed REALPATH packet");n._debug&&n._debug(`SFTP: Inbound: Received REALPATH (id:${e})`),n.emit("REALPATH",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.STAT]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed STAT packet");n._debug&&n._debug(`SFTP: Inbound: Received STAT (id:${e})`),n.emit("STAT",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.RENAME]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=M.readString(!0);if(M.clear(),s===void 0)return st(n,"Malformed RENAME packet");n._debug&&n._debug(`SFTP: Inbound: Received RENAME (id:${e})`),n.emit("RENAME",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)},[Be.READLINK]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(M.clear(),r===void 0)return st(n,"Malformed READLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received READLINK (id:${e})`),n.emit("READLINK",e,r)||n.status(e,tt.OP_UNSUPPORTED)},[Be.SYMLINK]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0),s=M.readString(!0);if(M.clear(),s===void 0)return st(n,"Malformed SYMLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received SYMLINK (id:${e})`);let i;n._isOpenSSH?i=n.emit("SYMLINK",e,s,r):i=n.emit("SYMLINK",e,r,s),i||n.status(e,tt.OP_UNSUPPORTED)},[Be.EXTENDED]:(n,t)=>{M.init(t,1);let e=M.readUInt32BE(),r=M.readString(!0);if(r===void 0)return M.clear(),st(n,"Malformed EXTENDED packet");let s;M.avail()&&(s=M.readRaw()),M.clear(),n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED (id:${e})`),n.emit("EXTENDED",e,r,s)||n.status(e,tt.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:E0,ERR_OUT_OF_RANGE:Cs,validateNumber:b0}=af(),uf=128,jt,ka=[];function x0(n){ka.length>0?jt=ka.pop():jt=Buffer.allocUnsafe(n),jt.used=0}function va(n,t){if(!Number.isSafeInteger(n))throw b0(n,t),Number.isInteger(n)?new Cs(t,">= 0 and <= 2 ** 53 - 1",n):new Cs(t,"an integer",n);if(n<0)throw new Cs(t,">= 0 and <= 2 ** 53 - 1",n)}function xa(n){return n+7&-8}function On(n,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,hf.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=n,this._opening=!1,this.start!==void 0&&(va(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(va(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new Cs("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}pf(On,hf);On.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t,this.emit("open",t),this.emit("ready"),this.read()}))};On.prototype._read=function(n){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(n));if(this.destroyed)return;(!jt||jt.length-jt.used<uf)&&x0(this.readableHighWaterMark||this._readableState.highWaterMark);let t=jt,e=Math.min(jt.length-jt.used,n),r=jt.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,jt,jt.used,e,this.pos,(s,i)=>{if(s){this.emit("error",s),this.autoClose&&this.destroy();return}let o=null;if(r+e===t.used&&t===jt)t.used=xa(t.used+i-e);else{let a=r+e&-8,c=xa(r+i);a-c>=uf&&ka.push(t.slice(c,a))}i>0&&(this.bytesRead+=i,o=t.slice(r,r+i)),this.pos+=i,this.push(o)}),jt.used=xa(jt.used+e)};On.prototype._destroy=function(n,t){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",df.bind(null,this,t,n));return}df(this,t,n),this.handle=null,this._opening=!1};function df(n,t,e){if(!n.handle)return r();n.sftp.close(n.handle,r);function r(s){s=s||e,t(s),n.isClosed=!0,s||n.emit("close")}}On.prototype.close=function(n){this.destroy(null,n)};Object.defineProperty(On.prototype,"pending",{get(){return this.handle===null},configurable:!0});function gn(n,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,Ba.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=n,this._opening=!1,this.start!==void 0&&(va(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()}pf(gn,Ba);gn.prototype._final=function(n){this.autoClose&&this.destroy(),n()};gn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t;let e=r=>{if(r){this.sftp.chmod(this.path,this.mode,s=>e());return}if(this.flags[0]==="a"){let s=(i,o)=>{if(i){this.sftp.stat(this.path,(a,c)=>{if(a){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)}))};gn.prototype._write=function(n,t,e){if(!Buffer.isBuffer(n)){let r=new E0("data","Buffer",n);return this.emit("error",r)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(n,t,e)});this.sftp.write(this.handle,n,0,n.length,this.pos,(r,s)=>{if(r)return this.autoClose&&this.destroy(),e(r);this.bytesWritten+=s,e()}),this.pos+=n.length};gn.prototype._writev=function(n,t){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(n,t)});let e=this.sftp,r=this.handle,s=n.length,i=(o,a)=>{if(o)return this.destroy(),t(o);this.bytesWritten+=a,--s===0&&t()};for(let o=0;o<n.length;++o){let a=n[o].chunk;e.write(r,a,0,a.length,this.pos,i),this.pos+=a.length}};typeof Ba.prototype.destroy!="function"&&(gn.prototype.destroy=On.prototype.destroy);gn.prototype._destroy=On.prototype._destroy;gn.prototype.close=function(n){if(n){if(this.isClosed){process.nextTick(n);return}this.on("close",n)}this.autoClose||this.on("finish",this.destroy.bind(this)),this.end()};gn.prototype.destroySoon=gn.prototype.end;Object.defineProperty(gn.prototype,"pending",{get(){return this.handle===null},configurable:!0});Ef.exports={flagsToString:m0,OPEN_MODE:Ce,SFTP:wa,Stats:ks,STATUS_CODE:tt,stringToFlags:Af}});var Da=ct((s_,wf)=>{"use strict";var{Duplex:S0,Readable:w0,Writable:I0}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:bf}}=Ln(),{bufferSlice:vs}=mn(),C0=32*1024,Ii=2*1024*1024,La=Ii/2,Na=class extends w0{constructor(t,e){super(e),this._channel=t}_read(t){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=La&&$a(this._channel))}},Pa=class extends I0{constructor(t){super({highWaterMark:Ii}),this._channel=t}_write(t,e,r){let s=this._channel,i=s._client._protocol,o=s.outgoing,a=o.packetSize,c=o.id,l=o.window,f=t.length,u=0;if(o.state==="open"){for(;f-u>0&&l>0;){let h=f-u;h>l&&(h=l),h>a&&(h=a),u===0&&h===f?i.channelExtData(c,t,bf):i.channelExtData(c,vs(t,u,u+h),bf),u+=h,l-=h}if(o.window=l,f-u>0){l===0&&(s._waitWindow=!0),u>0?s._chunkErr=vs(t,u,f):s._chunkErr=t,s._chunkcbErr=r;return}r()}}},Ta=class extends S0{constructor(t,e,r){let s={highWaterMark:Ii,allowHalfOpen:!r||r&&r.allowHalfOpen!==!1,emitClose:!1};super(s),this.allowHalfOpen=s.allowHalfOpen;let i=!!(r&&r.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 Pa(this):this.stderr=new Na(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",xf).on("prefinish",xf),this.on("end",Sf).on("close",Sf)}_read(t){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=La&&$a(this))}_write(t,e,r){let s=this._client._protocol,i=this.outgoing,o=i.packetSize,a=i.id,c=i.window,l=t.length,f=0;if(i.state==="open"){for(;l-f>0&&c>0;){let u=l-f;u>c&&(u=c),u>o&&(u=o),f===0&&u===l?s.channelData(a,t):s.channelData(a,vs(t,f,f+u)),f+=u,c-=u}if(i.window=c,l-f>0){c===0&&(this._waitWindow=!0),f>0?this._chunk=vs(t,f,l):this._chunk=t,this._chunkcb=r;return}r()}}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,r,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,r,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,r){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,r))}};function xf(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}function Sf(){this.readable=!1}function $a(n){if(n.outgoing.state==="closed")return;let t=Ii-n.incoming.window;t<=0||(n.incoming.window+=t,n._client._protocol.channelWindowAdjust(n.outgoing.id,t))}wf.exports={Channel:Ta,MAX_WINDOW:Ii,PACKET_SIZE:C0,windowAdjust:$a,WINDOW_THRESHOLD:La}});var Ma=ct((o_,kf)=>{"use strict";var{SFTP:k0}=wi(),Ci=2**32-1;function If(n,t,e,r){if(n._chanMgr.remove(t),typeof r!="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=""),r(s)}function Cf(n,t,e,r,s){if(typeof e=="function"){If(n,t,r,e);return}if(typeof e!="object"||e===null||e.incoming&&e.incoming.state==="closed"||(n._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!==k0&&(e.outgoing.state==="open"||e.outgoing.state==="eof")&&!s&&e.close(),e.outgoing.state==="closing"&&(e.outgoing.state="closed");let i=e._readableState,o=e._writableState;o&&!o.ending&&!o.finished&&!s&&e.end();let a=e._callbacks;e._callbacks=[];for(let c=0;c<a.length;++c)a[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:{let f=e._exit;c=()=>{f.code===null?e.emit("close",f.code,f.signal,f.dump,f.desc):e.emit("close",f.code)}}}!e.readable||e.destroyed||i&&i.endEmitted?c():e.once("end",c);let l=e.stderr._readableState;!e.stderr.readable||e.stderr.destroyed||l&&l.endEmitted?e.stderr.emit("close"):e.stderr.once("end",()=>e.stderr.emit("close"))}}var Oa=class{constructor(t){this._client=t,this._channels={},this._cur=-1,this._count=0}add(t){let e;if(this._cur<Ci)e=++this._cur;else if(this._count===0)this._cur=0,e=0;else{let r=this._channels;for(let s=0;s<Ci;++s)if(r[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>=Ci||!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>=Ci||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);return this._channels[t]}remove(t){if(typeof t!="number"||t<0||t>=Ci||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);this._channels[t]&&(delete this._channels[t],this._count&&--this._count)}cleanup(t){let e=this._channels;this._channels={},this._cur=-1,this._count=0;let r=Object.keys(e),s=this._client;for(let i=0;i<r.length;++i){let o=+r[i],a=e[o];Cf(s,o,a._channel||a,t,!0)}}},Ua=(()=>{let n=Object.prototype.toString;return t=>n.call(t)==="[object RegExp]"})();function v0(n,t,e){if(Array.isArray(n)&&n.length>0){for(let r=0;r<n.length;++r)if(e.indexOf(n[r])===-1)throw new Error(`Unsupported algorithm: ${n[r]}`);return n}if(typeof n=="object"&&n!==null){let r=Object.keys(n),s=t;for(let i=0;i<r.length;++i){let o=r[i],a=n[o];switch(o){case"append":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let l=a[c];if(typeof l=="string"){if(!l||s.indexOf(l)!==-1)continue;if(e.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);s===t&&(s=s.slice()),s.push(l)}else if(Ua(l))for(let f=0;f<e.length;++f){let u=e[f];if(l.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.push(u)}}}break;case"prepend":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=a.length;c>=0;--c){let l=a[c];if(typeof l=="string"){if(!l||s.indexOf(l)!==-1)continue;if(e.indexOf(l)===-1)throw new Error(`Unsupported algorithm: ${l}`);s===t&&(s=s.slice()),s.unshift(l)}else if(Ua(l))for(let f=e.length;f>=0;--f){let u=e[f];if(l.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.unshift(u)}}}break;case"remove":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let l=a[c];if(typeof l=="string"){if(!l)continue;let f=s.indexOf(l);if(f===-1)continue;s===t&&(s=s.slice()),s.splice(f,1)}else if(Ua(l))for(let f=0;f<s.length;++f)l.test(s[f])&&(s===t&&(s=s.slice()),s.splice(f,1),--f)}break}}return s}return t}kf.exports={ChannelManager:Oa,generateAlgorithmList:v0,onChannelOpenFailure:If,onCHANNEL_CLOSE:Cf,isWritable:n=>n&&n.writable&&n._readableState&&n._readableState.ended===!1}});var Va=ct((a_,Gf)=>{"use strict";var{createHash:B0,getHashes:R0,randomFillSync:N0}=require("crypto"),{Socket:P0}=require("net"),{lookup:T0}=require("dns"),L0=require("events"),$0=R0(),{COMPAT:qf,CHANNEL_EXTENDED_DATATYPE:{STDERR:D0},CHANNEL_OPEN_FAILURE:ki,DEFAULT_CIPHER:vf,DEFAULT_COMPRESSION:Bf,DEFAULT_KEX:Rf,DEFAULT_MAC:Nf,DEFAULT_SERVER_HOST_KEY:Pf,DISCONNECT_REASON:Tf,DISCONNECT_REASON_BY_VALUE:U0,SUPPORTED_CIPHER:O0,SUPPORTED_COMPRESSION:M0,SUPPORTED_KEX:F0,SUPPORTED_MAC:H0,SUPPORTED_SERVER_HOST_KEY:Q0}=Ln(),{init:W0}=qn(),q0=Ea(),{parseKey:Ns}=Gn(),{SFTP:K0}=wi(),{bufferCopy:Lf,makeBufferParser:Kf,makeError:V0,readUInt32BE:G0,sigSSHToASN1:z0,writeUInt32BE:Fa}=mn(),{AgentContext:$f,createAgent:Df,isAgent:Uf}=sa(),{Channel:Vf,MAX_WINDOW:Ps,PACKET_SIZE:Ts,windowAdjust:Of,WINDOW_THRESHOLD:Mf}=Da(),{ChannelManager:Y0,generateAlgorithmList:vi,isWritable:Lt,onChannelOpenFailure:j0,onCHANNEL_CLOSE:X0}=Ma(),Bs=Kf(),Rs=Kf(),Bi=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,qa=n=>{},Ka=class extends L0{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&&Lt(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;let e={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:[]},sc:void 0},r=!0;if(typeof t.algorithms=="object"&&t.algorithms!==null&&(e.kex=vi(t.algorithms.kex,Rf,F0),e.kex!==Rf&&(r=!1),e.serverHostKey=vi(t.algorithms.serverHostKey,Pf,Q0),e.serverHostKey!==Pf&&(r=!1),e.cs.cipher=vi(t.algorithms.cipher,vf,O0),e.cs.cipher!==vf&&(r=!1),e.cs.mac=vi(t.algorithms.hmac,Nf,H0),e.cs.mac!==Nf&&(r=!1),e.cs.compress=vi(t.algorithms.compress,Bf,M0),e.cs.compress!==Bf&&(r=!1),r||(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=Df(t.agent):Uf(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;let 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 Y0(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 a;if(this.config.privateKey){if(a=Ns(this.config.privateKey,t.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 does not contain a (valid) private key")}let c;if(typeof t.hostVerifier=="function"){let O=t.hostVerifier,N;$0.indexOf(t.hostHash)!==-1&&(N=t.hostHash),c=(L,K)=>{N&&(L=B0(N).update(L).digest("hex"));let ee=O(L,K);ee!==void 0&&K(ee)}}let l=this._sock=t.sock||new P0,f=!1,u=!1;this._protocol&&this._protocol.cleanup();let h=i?(O,N,L)=>{i(`Debug output from server: ${JSON.stringify(L)}`)}:void 0,p,y=this._protocol=new q0({ident:this.config.ident,offer:r?void 0:e,onWrite:O=>{Lt(l)&&l.write(O)},onError:O=>{O.level==="handshake"&&clearTimeout(this._readyTimeout),y._destruct||l.removeAllListeners("data"),this.emit("error",O);try{l.end()}catch{}},onHeader:O=>{u=!0,this._remoteVer=O.versions.software,O.greeting&&this.emit("greeting",O.greeting)},onHandshakeComplete:O=>{this.emit("handshake",O),f||(f=!0,y.service("ssh-userauth"))},debug:i,hostVerifier:c,messageHandlers:{DEBUG:h,DISCONNECT:(O,N,L)=>{if(N!==Tf.BY_APPLICATION){L||(L=U0[N],L===void 0&&(L=`Unexpected disconnection reason: ${N}`));let K=new Error(L);K.code=N,this.emit("error",K)}l.end()},SERVICE_ACCEPT:(O,N)=>{N==="ssh-userauth"&&Y()},EXT_INFO:(O,N)=>{if(p===void 0){for(let L of N)if(L.name==="server-sig-algs"){p=L.algs;return}p=null}},USERAUTH_BANNER:(O,N)=>{this.emit("banner",N)},USERAUTH_SUCCESS:O=>{C(),clearTimeout(this._readyTimeout),this.emit("ready")},USERAUTH_FAILURE:(O,N,L)=>{if(b.keyAlgos){let K=b.keyAlgos[0][0];if(i&&i(`Client: ${b.type} (${K}) auth failed`),b.keyAlgos.shift(),b.keyAlgos.length){let[ee,ue]=b.keyAlgos[0];switch(b.type){case"agent":y.authPK(b.username,b.agentCtx.currentKey(),ee);return;case"publickey":y.authPK(b.username,b.key,ee);return;case"hostbased":y.authHostbased(b.username,b.key,b.localHostname,b.localUsername,ee,(ie,je)=>{let lt=b.key.sign(ie,ue);if(lt instanceof Error)return lt.message=`Error while signing with key: ${lt.message}`,lt.level="client-authentication",this.emit("error",lt),Y();je(lt)});return}}else b.keyAlgos=void 0}if(b.type==="agent"){let K=b.agentCtx.pos();return i&&i(`Client: Agent key #${K+1} failed`),te()}i&&i(`Client: ${b.type} auth failed`),w=L,k=N,Y()},USERAUTH_PASSWD_CHANGEREQ:(O,N)=>{b.type==="password"&&this.emit("change password",N,L=>{y.authPassword(this.config.username,this.config.password,L)})},USERAUTH_PK_OK:O=>{let N,L;if(b.keyAlgos&&([N,L]=b.keyAlgos[0]),b.type==="agent"){let K=b.agentCtx.currentKey();y.authPK(b.username,K,N,(ee,ue)=>{let ie={hash:L};b.agentCtx.sign(K,ee,ie,(je,lt)=>{if(je)je.level="agent",this.emit("error",je);else return ue(lt);te()})})}else b.type==="publickey"&&y.authPK(b.username,b.key,N,(K,ee)=>{let ue=b.key.sign(K,L);if(ue instanceof Error)return ue.message=`Error signing data with key: ${ue.message}`,ue.level="client-authentication",this.emit("error",ue),Y();ee(ue)})},USERAUTH_INFO_REQUEST:(O,N,L,K)=>{if(b.type==="keyboard-interactive"){if((Array.isArray(K)?K.length:0)===0){i&&i("Client: Sending automatic USERAUTH_INFO_RESPONSE"),y.authInfoRes();return}b.prompt(N,L,"",K,ue=>{y.authInfoRes(ue)})}},REQUEST_SUCCESS:(O,N)=>{o.length&&o.shift()(!1,N)},REQUEST_FAILURE:O=>{o.length&&o.shift()(!0)},GLOBAL_REQUEST:(O,N,L,K)=>{N==="hostkeys-00@openssh.com"?(nm(this,K,(ee,ue)=>{ee||this.emit("hostkeys",ue)}),L&&y.requestSuccess()):L&&y.requestFailure()},CHANNEL_OPEN:(O,N)=>{em(this,N)},CHANNEL_OPEN_CONFIRMATION:(O,N)=>{let L=this._chanMgr.get(N.recipient);if(typeof L!="function")return;let K=L.type==="sftp",ue={type:K?"session":L.type,incoming:{id:N.recipient,window:Ps,packetSize:Ts,state:"open"},outgoing:{id:N.sender,window:N.window,packetSize:N.packetSize,state:"open"}},ie=K?new K0(this,ue,{debug:i}):new Vf(this,ue);this._chanMgr.update(N.recipient,ie),L(void 0,ie)},CHANNEL_OPEN_FAILURE:(O,N,L,K)=>{let ee=this._chanMgr.get(N);if(typeof ee!="function")return;j0(this,N,{reason:L,description:K},ee)},CHANNEL_DATA:(O,N,L)=>{let K=this._chanMgr.get(N);if(!(typeof K!="object"||K===null)&&K.incoming.window!==0){if(K.incoming.window-=L.length,K.push(L)===!1){K._waitChanDrain=!0;return}K.incoming.window<=Mf&&Of(K)}},CHANNEL_EXTENDED_DATA:(O,N,L,K)=>{if(K!==D0)return;let ee=this._chanMgr.get(N);if(!(typeof ee!="object"||ee===null)&&ee.incoming.window!==0){if(ee.incoming.window-=L.length,!ee.stderr.push(L)){ee._waitChanDrain=!0;return}ee.incoming.window<=Mf&&Of(ee)}},CHANNEL_WINDOW_ADJUST:(O,N,L)=>{let K=this._chanMgr.get(N);typeof K!="object"||K===null||(K.outgoing.window+=L,K._waitWindow&&(K._waitWindow=!1,K._chunk?K._write(K._chunk,null,K._chunkcb):K._chunkcb?K._chunkcb():K._chunkErr?K.stderr._write(K._chunkErr,null,K._chunkcbErr):K._chunkcbErr&&K._chunkcbErr()))},CHANNEL_SUCCESS:(O,N)=>{let L=this._chanMgr.get(N);typeof L!="object"||L===null||(this._resetKA(),L._callbacks.length&&L._callbacks.shift()(!1))},CHANNEL_FAILURE:(O,N)=>{let L=this._chanMgr.get(N);typeof L!="object"||L===null||(this._resetKA(),L._callbacks.length&&L._callbacks.shift()(!0))},CHANNEL_REQUEST:(O,N,L,K,ee)=>{let ue=this._chanMgr.get(N);if(typeof ue!="object"||ue===null)return;let ie=ue._exit;if(ie.code===void 0){switch(L){case"exit-status":ue.emit("exit",ie.code=ee);return;case"exit-signal":ue.emit("exit",ie.code=null,ie.signal=`SIG${ee.signal}`,ie.dump=ee.coreDumped,ie.desc=ee.errorMessage);return}K&&O.channelFailure(ue.outgoing.id)}},CHANNEL_EOF:(O,N)=>{let L=this._chanMgr.get(N);typeof L!="object"||L===null||L.incoming.state==="open"&&(L.incoming.state="eof",L.readable&&L.push(null),L.stderr.readable&&L.stderr.push(null))},CHANNEL_CLOSE:(O,N)=>{X0(this,N,this._chanMgr.get(N))}}});l.pause();let _=this.config.keepaliveInterval,x=this.config.keepaliveCountMax,S=0,R,H=()=>{if(++S>x){if(clearInterval(R),l.readable){let O=new Error("Keepalive timeout");O.level="client-timeout",this.emit("error",O),l.destroy()}return}Lt(l)?(o.push(C),y.ping()):clearInterval(R)};function C(){_>0&&(S=0,clearInterval(R),Lt(l)&&(R=setInterval(H,_)))}this._resetKA=C;let U=(()=>{let O=!1;return()=>{if(!O&&(O=!0,B&&!u)){let N=V0("Connection lost before handshake","protocol",!0);this.emit("error",N)}}})(),Q=(()=>{let O=!1;return()=>{O||(O=!0,B=!0,i&&i("Socket connected"),this.emit("connect"),W0.then(()=>{y.start(),l.on("data",N=>{try{y.parse(N,0,N.length)}catch(L){this.emit("error",L);try{Lt(l)&&l.end()}catch{}}}),l.stderr&&typeof l.stderr.resume=="function"&&l.stderr.resume(),l.resume()}).catch(N=>{this.emit("error",N);try{Lt(l)&&l.end()}catch{}}))}})(),B=!1;l.on("connect",Q).on("timeout",()=>{this.emit("timeout")}).on("error",O=>{i&&i(`Socket error: ${O.message}`),clearTimeout(this._readyTimeout),O.level="client-socket",this.emit("error",O)}).on("end",()=>{i&&i("Socket ended"),U(),y.cleanup(),clearTimeout(this._readyTimeout),clearInterval(R),this.emit("end")}).on("close",()=>{i&&i("Socket closed"),U(),y.cleanup(),clearTimeout(this._readyTimeout),clearInterval(R),this.emit("close");let O=o;o=this._callbacks=[];let N=new Error("No response from server");for(let L=0;L<O.length;++L)O[L](N);this._chanMgr.cleanup(N)});let b,w=null,k=null,v=["none"];this.config.password!==void 0&&v.push("password"),a!==void 0&&v.push("publickey"),this._agent!==void 0&&v.push("agent"),this.config.tryKeyboard&&v.push("keyboard-interactive"),a!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&v.push("hostbased"),Array.isArray(s)?s=Wf(s):typeof s!="function"&&(s=Wf(v));let P=!1,ne=O=>{if(!P){if(P=!0,O===!1){let N=new Error("All configured authentication methods failed");N.level="client-authentication",this.emit("error",N),this.end();return}if(typeof O=="string"){let N=O;if(v.indexOf(N)===-1)return z(`Authentication method not allowed: ${N}`);let L=this.config.username;switch(N){case"password":O={type:N,username:L,password:this.config.password};break;case"publickey":O={type:N,username:L,key:a};break;case"hostbased":O={type:N,username:L,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":O={type:N,username:L,agentCtx:new $f(this._agent)};break;case"keyboard-interactive":O={type:N,username:L,prompt:(...K)=>this.emit("keyboard-interactive",...K)};break;case"none":O={type:N,username:L};break;default:return z(`Skipping unsupported authentication method: ${O}`)}}else{if(typeof O!="object"||O===null)return z(`Skipping invalid authentication attempt: ${O}`);{let N=O.username;if(typeof N!="string")return z(`Skipping invalid authentication attempt: ${O}`);let L=O.type;switch(L){case"password":{let{password:K}=O;if(typeof K!="string"&&!Buffer.isBuffer(K))return z("Skipping invalid password auth attempt");O={type:L,username:N,password:K};break}case"publickey":{let K=Ns(O.key,O.passphrase);if(K instanceof Error)return z("Skipping invalid key auth attempt");if(!K.isPrivateKey())return z("Skipping non-private key");O={type:L,username:N,key:K};break}case"hostbased":{let{localHostname:K,localUsername:ee}=O,ue=Ns(O.key,O.passphrase);if(ue instanceof Error||typeof K!="string"||typeof ee!="string")return z("Skipping invalid hostbased auth attempt");if(!ue.isPrivateKey())return z("Skipping non-private key");O={type:L,username:N,key:ue,localHostname:K,localUsername:ee};break}case"agent":{let K=O.agent;if(typeof K=="string"&&K.length)K=Df(K);else if(!Uf(K))return z(`Skipping invalid agent: ${O.agent}`);O={type:L,username:N,agentCtx:new $f(K)};break}case"keyboard-interactive":{let{prompt:K}=O;if(typeof K!="function")return z("Skipping invalid keyboard-interactive auth attempt");O={type:L,username:N,prompt:K};break}case"none":O={type:L,username:N};break;default:return z(`Skipping unsupported authentication method: ${O}`)}}}b=O;try{let N=b.username;switch(b.type){case"password":y.authPassword(N,b.password);break;case"publickey":{let L;if(b.keyAlgos=Wa(this,b.key,p),b.keyAlgos)if(b.keyAlgos.length)L=b.keyAlgos[0][0];else return z("Skipping key authentication (no mutual hash algorithm)");y.authPK(N,b.key,L);break}case"hostbased":{let L,K;if(b.keyAlgos=Wa(this,b.key,p),b.keyAlgos)if(b.keyAlgos.length)[L,K]=b.keyAlgos[0];else return z("Skipping hostbased authentication (no mutual hash algorithm)");y.authHostbased(N,b.key,b.localHostname,b.localUsername,L,(ee,ue)=>{let ie=b.key.sign(ee,K);if(ie instanceof Error)return ie.message=`Error while signing with key: ${ie.message}`,ie.level="client-authentication",this.emit("error",ie),Y();ue(ie)});break}case"agent":b.agentCtx.init(L=>{if(L)return L.level="agent",this.emit("error",L),Y();te()});break;case"keyboard-interactive":y.authKeyboard(N);break;case"none":y.authNone(N);break}}finally{P=!1}}};function z(O){i&&i(O),process.nextTick(Y)}function Y(){P=!1;let O=s(k,w,ne);P||O===void 0||ne(O)}let te=()=>{if(b.type==="agent"){let O=b.agentCtx.nextKey();if(O===!1)i&&i("Agent: No more keys left to try"),i&&i("Client: agent auth failed"),Y();else{let N=b.agentCtx.pos(),L;if(b.keyAlgos=Wa(this,O,p),b.keyAlgos)if(b.keyAlgos.length)L=b.keyAlgos[0][0];else{i&&i(`Agent: Skipping key #${N+1} (no mutual hash algorithm)`),te();return}i&&i(`Agent: Trying key #${N+1}`),y.authPK(b.username,O,L)}}},le=()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let O=new Error("Timed out while waiting for handshake");O.level="client-timeout",this.emit("error",O),l.destroy()},this.config.readyTimeout))};if(t.sock)le(),typeof l.connecting=="boolean"&&l.connecting||Q();else{let O=this.config.host,N=this.config.forceIPv4,L=this.config.forceIPv6;i&&i(`Client: Trying ${O} on port ${this.config.port} ...`);let K=()=>{le(),l.connect({host:O,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),l.setMaxListeners(0),l.setTimeout(typeof t.timeout=="number"?t.timeout:0)};!N&&!L||N&&L?K():T0(O,N?4:6,(ee,ue,ie)=>{if(ee){let je=N?"IPv4":"IPv6",lt=new Error(`Error while looking up ${je} address for '${O}': ${ee}`);clearTimeout(this._readyTimeout),lt.level="client-dns",this.emit("error",lt),this.emit("close");return}O=ue,K()})}return this}end(){return this._sock&&Lt(this._sock)&&(this._protocol.disconnect(Tf.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&Lt(this._sock)&&this._sock.destroy(),this}exec(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");typeof e=="function"&&(r=e,e={});let s={allowHalfOpen:e.allowHalfOpen!==!1};return Fr(this,"session",s,(i,o)=>{if(i){r(i);return}let a=[];function c(l){if(l){o.close(),r(l);return}a.length&&a.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&a.push(()=>Qf(o,c)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&Ha(o,e.env),(typeof e.pty=="object"&&e.pty!==null||e.pty===!0)&&a.push(()=>Hf(o,e.pty,c)),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&a.push(()=>Ff(o,e.x11,c))),a.push(()=>Z0(o,t,e,r)),a.shift()()}),this}shell(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return typeof t=="function"?(r=t,t=e=void 0):typeof e=="function"&&(r=e,e=void 0),t&&(t.x11!==void 0||t.env!==void 0)&&(e=t,t=void 0),Fr(this,"session",(s,i)=>{if(s){r(s);return}let o=[];function a(c){if(c){i.close(),r(c);return}o.length&&o.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&o.push(()=>Qf(i,a)),t!==!1&&o.push(()=>Hf(i,t,a)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&Ha(i,e.env),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&o.push(()=>Ff(i,e.x11,a))),o.push(()=>J0(i,r)),o.shift()()}),this}subsys(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return Fr(this,"session",(r,s)=>{if(r){e(r);return}Qa(s,t,(i,o)=>{if(i){e(i);return}e(void 0,o)})}),this}forwardIn(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push((i,o)=>{if(i){r(i!==!0?i:new Error(`Unable to bind to ${t}:${e}`));return}let a=e;e===0&&o&&o.length>=4&&(a=G0(o,0),this._protocol._compatFlags&qf.DYN_RPORT_BUG||(e=a)),this._forwarding[`${t}:${e}`]=a,r(void 0,a)}),this._protocol.tcpipForward(t,e,s),this}unforwardIn(t,e,r){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to unbind from ${t}:${e}`));return}delete this._forwarding[`${t}:${e}`],r()}),this._protocol.cancelTcpipForward(t,e,s),this}forwardOut(t,e,r,s,i){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let o={srcIP:t,srcPort:e,dstIP:r,dstPort:s};return typeof i!="function"&&(i=qa),Fr(this,"direct-tcpip",o,i),this}openssh_noMoreSessions(t){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let e=typeof t=="function";return!this.config.strictVendor||this.config.strictVendor&&Bi.test(this._remoteVer)?(e&&this._callbacks.push(r=>{if(r){t(r!==!0?r: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||!Lt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Bi.test(this._remoteVer)?(r&&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,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Bi.test(this._remoteVer)?(r&&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,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(t,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return typeof e!="function"&&(e=qa),!this.config.strictVendor||this.config.strictVendor&&Bi.test(this._remoteVer)?(Fr(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,e){if(!this._sock||!Lt(this._sock))throw new Error("Not connected");return typeof t=="function"&&(e=t,t=void 0),Fr(this,"sftp",(r,s)=>{if(r){e(r);return}let i=(o,a)=>{if(o){e(o);return}function c(){s.removeListener("ready",l),s.removeListener("error",f),s.removeListener("exit",u),s.removeListener("close",u)}function l(){c(),e(void 0,s)}function f(h){c(),e(h)}function u(h,p){c();let y;typeof h=="number"?y=`Received exit code ${h} while establishing SFTP session`:p!==void 0?y=`Received signal ${p} while establishing SFTP session`:y="Received unexpected SFTP session termination";let _=new Error(y);_.code=h,_.signal=p,e(_)}s.on("ready",l).on("error",f).on("exit",u).on("close",u),s._init()};typeof t=="object"&&t!==null?Ha(s,t,o=>{if(o){e(o);return}Qa(s,"sftp",i)}):Qa(s,"sftp",i)}),this}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function Fr(n,t,e,r){let s=Ps,i=Ts;typeof e=="function"&&(r=e,e={});let o=(c,l)=>{r(c,l)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"session":case"sftp":n._protocol.session(a,s,i);break;case"direct-tcpip":n._protocol.directTcpip(a,s,i,e);break;case"direct-streamlocal@openssh.com":n._protocol.openssh_directStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Ff(n,t,e){let r={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"&&(r.single=t.single),typeof t.screen=="number"&&(r.screen=t.screen),typeof t.protocol=="string"&&(r.protocol=t.protocol),typeof t.cookie=="string"?r.cookie=t.cookie:Buffer.isBuffer(t.cookie)&&(r.cookie=t.cookie.hexSlice(0,t.cookie.length))),r.cookie===void 0&&(r.cookie=tm());let s=typeof e=="function";if(n.outgoing.state!=="open"){s&&e(new Error("Channel is not open"));return}s&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to request X11"));return}n._hasX11=!0,++n._client._acceptX11,n.once("close",()=>{n._client._acceptX11&&--n._client._acceptX11}),e()}),n._client._protocol.x11Forward(n.outgoing.id,r,s)}function Hf(n,t,e){let r=24,s=80,i=640,o=480,a="vt100",c=null;typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.rows=="number"&&(r=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"&&(a=t.term),typeof t.modes=="object"&&(c=t.modes));let l=typeof e=="function";if(n.outgoing.state!=="open"){l&&e(new Error("Channel is not open"));return}l&&n._callbacks.push(f=>{if(f){e(f!==!0?f:new Error("Unable to request a pseudo-terminal"));return}e()}),n._client._protocol.pty(n.outgoing.id,r,s,o,i,a,c,l)}function Qf(n,t){let e=typeof t=="function";if(n.outgoing.state!=="open"){e&&t(new Error("Channel is not open"));return}if(n._client._agentFwdEnabled){e&&t(!1);return}n._client._agentFwdEnabled=!0,n._callbacks.push(r=>{if(r){n._client._agentFwdEnabled=!1,e&&t(r!==!0?r:new Error("Unable to request agent forwarding"));return}e&&t()}),n._client._protocol.openssh_agentForward(n.outgoing.id,!0)}function J0(n,t){if(n.outgoing.state!=="open"){t(new Error("Channel is not open"));return}n._callbacks.push(e=>{if(e){t(e!==!0?e:new Error("Unable to open shell"));return}n.subtype="shell",t(void 0,n)}),n._client._protocol.shell(n.outgoing.id,!0)}function Z0(n,t,e,r){if(n.outgoing.state!=="open"){r(new Error("Channel is not open"));return}n._callbacks.push(s=>{if(s){r(s!==!0?s:new Error("Unable to exec"));return}n.subtype="exec",n.allowHalfOpen=e.allowHalfOpen!==!1,r(void 0,n)}),n._client._protocol.exec(n.outgoing.id,t,!0)}function Ha(n,t,e){let r=typeof e=="function";if(n.outgoing.state!=="open"){r&&e(new Error("Channel is not open"));return}r&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to set environment"));return}e()});let s=Object.keys(t||{});for(let i=0;i<s.length;++i){let o=s[i],a=t[o];n._client._protocol.env(n.outgoing.id,o,a,r)}}function Qa(n,t,e){if(n.outgoing.state!=="open"){e(new Error("Channel is not open"));return}n._callbacks.push(r=>{if(r){e(r!==!0?r:new Error(`Unable to start subsystem: ${t}`));return}n.subtype="subsystem",e(void 0,n)}),n._client._protocol.subsystem(n.outgoing.id,t,!0)}function em(n,t){let e=-1,r,s=()=>{let c={type:t.type,incoming:{id:e,window:Ps,packetSize:Ts,state:"open"},outgoing:{id:t.sender,window:t.window,packetSize:t.packetSize,state:"open"}},l=new Vf(n,c);return n._chanMgr.update(e,l),n._protocol.channelOpenConfirm(t.sender,e,Ps,Ts),l},i=()=>{r===void 0&&(e===-1?r=ki.RESOURCE_SHORTAGE:r=ki.CONNECT_FAILED),e!==-1&&n._chanMgr.remove(e),n._protocol.channelOpenFail(t.sender,r,"")},o=()=>(e=n._chanMgr.add(),e===-1&&(r=ki.RESOURCE_SHORTAGE,n.config.debug&&n.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),e!==-1),a=t.data;switch(t.type){case"forwarded-tcpip":{let c=n._forwarding[`${a.destIP}:${a.destPort}`];if(c!==void 0&&o()){a.destPort===0&&(a.destPort=c),n.emit("tcp connection",a,s,i);return}break}case"forwarded-streamlocal@openssh.com":if(n._forwardingUnix[a.socketPath]!==void 0&&o()){n.emit("unix connection",a,s,i);return}break;case"auth-agent@openssh.com":if(n._agentFwdEnabled&&typeof n._agent.getStream=="function"&&o()){n._agent.getStream((c,l)=>{if(c)return i();let f=s();f.pipe(l).pipe(f)});return}break;case"x11":if(n._acceptX11!==0&&o()){n.emit("x11",a,s,i);return}break;default:r=ki.UNKNOWN_CHANNEL_TYPE,n.config.debug&&n.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${t.type}`)}r===void 0&&(r=ki.ADMINISTRATIVELY_PROHIBITED,n.config.debug&&n.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+t.type)),i()}var tm=(()=>{let n=Buffer.allocUnsafe(16);return()=>(N0(n,0,16),n.hexSlice(0,16))})();function Wf(n){if(!Array.isArray(n))throw new Error("authList must be an array");let t=0;return(e,r,s)=>t===n.length?!1:n[t++]}function nm(n,t,e){if(!n._sock||!Lt(n._sock))return;if(typeof e!="function"&&(e=qa),!Array.isArray(t))throw new TypeError("Invalid keys argument type");let r=[];for(let s of t){let i=Ns(s);if(i instanceof Error)throw i;r.push(i)}if(!n.config.strictVendor||n.config.strictVendor&&Bi.test(n._remoteVer)){n._callbacks.push((s,i)=>{if(s){e(s!==!0?s:new Error("Server failed to prove supplied keys"));return}let o=[],a=0;for(Bs.init(i,0);Bs.avail()&&a!==r.length;){let c=r[a++],l=c.getPublicSSH(),f=Bs.readString();Rs.init(f,0);let u=Rs.readString(!0),h=Rs.readString(),p;if(u!==c.type)if(c.type==="ssh-rsa")switch(u){case"rsa-sha2-256":p="sha256";break;case"rsa-sha2-512":p="sha512";break;default:continue}else continue;let y=n._protocol._kex.sessionID,_=Buffer.allocUnsafe(37+y.length+4+l.length),x=0;Fa(_,29,x),_.utf8Write("hostkeys-prove-00@openssh.com",x+=4,29),Fa(_,y.length,x+=29),Lf(y,_,0,y.length,x+=4),Fa(_,l.length,x+=y.length),Lf(l,_,0,l.length,x+=4),(h=z0(h,u))&&c.verify(_,h,p)===!0&&o.push(c)}Rs.clear(),Bs.clear(),e(null,o)}),n._protocol.openssh_hostKeysProve(r);return}process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version"))}function Wa(n,t,e){switch(t.type){case"ssh-rsa":if(n._protocol._compatFlags&qf.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"]]}}Gf.exports=Ka});var Yf=ct(zf=>{"use strict";var{Agent:za}=require("http"),{Agent:rm}=require("https"),{connect:im}=require("tls"),Ga;for(let n of[za,rm]){class t extends n{constructor(r,s){super(s),this._connectCfg=r,this._defaultSrcIP=s&&s.srcIP||"localhost"}createConnection(r,s){let i=r&&r.localAddress||this._defaultSrcIP,o=r&&r.localPort||0,a=r.host,c=r.port;Ga===void 0&&(Ga=Va());let l=new Ga,f=!1;l.on("ready",()=>{l.forwardOut(i,o,a,c,(u,h)=>{if(f=!0,u)return l.end(),s(u);h.once("close",()=>l.end()),s(null,sm(h,n,r))})}).on("error",s).on("close",()=>{f||s(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}zf[n===za?"SSHTTPAgent":"SSHTTPSAgent"]=t}function Ri(){}function sm(n,t,e){if(t===za)return n.setKeepAlive=Ri,n.setNoDelay=Ri,n.setTimeout=Ri,n.ref=Ri,n.unref=Ri,n.destroySoon=n.destroy,n;e.socket=n;let r=im(e),s=(()=>{let i=!1;return()=>{i||(i=!0,n.isPaused()&&n.resume())}})();return r.on("end",s).on("close",s),r}});var Xf=ct((l_,Ja)=>{"use strict";var{Server:om}=require("net"),Pi=require("events"),{listenerCount:Gt}=Pi,{CHANNEL_OPEN_FAILURE:Hr,DEFAULT_CIPHER:am,DEFAULT_COMPRESSION:cm,DEFAULT_KEX:lm,DEFAULT_MAC:fm,DEFAULT_SERVER_HOST_KEY:um,DISCONNECT_REASON:Qr,DISCONNECT_REASON_BY_VALUE:dm,SUPPORTED_CIPHER:hm,SUPPORTED_COMPRESSION:pm,SUPPORTED_KEX:gm,SUPPORTED_MAC:mm,SUPPORTED_SERVER_HOST_KEY:Am}=Ln(),{init:ym}=qn(),{KexInit:_m}=ms(),{parseKey:jf}=Gn(),Em=Ea(),{SFTP:bm}=wi(),{writeUInt32BE:xm}=mn(),{Channel:Wr,MAX_WINDOW:jn,PACKET_SIZE:Xn,windowAdjust:Sm,WINDOW_THRESHOLD:wm}=Da(),{ChannelManager:Im,generateAlgorithmList:Ni,isWritable:Ls,onChannelOpenFailure:Cm,onCHANNEL_CLOSE:km}=Ma(),vm=10,Jn=class extends Pi{constructor(t,e,r,s,i){super(),this.username=this.user=e,this.service=r,this.method=s,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(o,a,c)=>{this._finalResponse||(this._finalResponse=!0,i(this,o,a,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)}},$s=class extends Jn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this._multistep=!0,this._cb=void 0,this._onInfoResponse=a=>{let c=this._cb;c&&(this._cb=void 0,c(a))},this.submethods=i,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(t,e,r,s){Array.isArray(t)||(t=[t]),typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"?(s=r,r=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,r,t)}},ja=class extends Jn{constructor(t,e,r,s,i,o){super(t,e,r,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?Jn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},Xa=class extends Jn{constructor(t,e,r,s,i,o){super(t,e,r,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}},Ds=class extends Jn{constructor(t,e,r,s,i,o){super(t,e,r,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)}},Cn=class extends Pi{constructor(t,e,r){super(),this.type="session",this.subtype=void 0,this.server=!0,this._ending=!1,this._channel=void 0,this._chanInfo={type:"session",incoming:{id:r,window:jn,packetSize:Xn,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}}}},ln=class extends Pi{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new Error("Missing configuration object");let r=Object.create(null),s=[],i=t.hostKeys;if(!Array.isArray(i))throw new Error("hostKeys must be an array");let o=typeof t.algorithms=="object"&&t.algorithms!==null?t.algorithms:{},a=Ni(o.serverHostKey,um,Am);for(let h=0;h<i.length;++h){let p;if(Buffer.isBuffer(i[h])||typeof i[h]=="string"?p=jf(i[h]):p=jf(i[h].key,i[h].passphrase),p instanceof Error)throw new Error(`Cannot parse privateKey: ${p.message}`);if(Array.isArray(p)&&(p=p[0]),p.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!s.includes(p.type))if(p.type==="ssh-rsa"){let y=a.indexOf("ssh-rsa"),_=a.indexOf("rsa-sha2-256"),x=a.indexOf("rsa-sha2-512");y===-1&&(y=1/0),[y,_,x].sort(Bm).forEach(S=>{if(S===-1)return;let R;switch(S){case y:R="ssh-rsa";break;case _:R="rsa-sha2-256";break;case x:R="rsa-sha2-512";break;default:return}r[R]=p,s.push(R)})}else r[p.type]=p,s.push(p.type)}let c={kex:Ni(o.kex,lm,gm).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:s,cs:{cipher:Ni(o.cipher,am,hm),mac:Ni(o.hmac,fm,mm),compress:Ni(o.compress,cm,pm),lang:[]},sc:void 0};c.sc=c.cs,typeof e=="function"&&this.on("connection",e);let l=typeof t.debug=="function"?t.debug:void 0,f=t.ident?Buffer.from(t.ident):void 0,u=new _m(c);this._srv=new om(h=>{if(this._connections>=this.maxConnections){h.destroy();return}++this._connections,h.once("close",()=>{--this._connections});let p;if(l){let y=`[${process.hrtime().join(".")}] `;p=_=>{l(`${y}${_}`)}}new Us(h,r,f,u,p,this,t)}).on("error",h=>{this.emit("error",h)}).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}};ln.KEEPALIVE_CLIENT_INTERVAL=15e3;ln.KEEPALIVE_CLIENT_COUNT_MAX=3;var Us=class extends Pi{constructor(t,e,r,s,i,o,a){super();let c=0,l=!1,f=[],u,h,p,y=[];this._sock=t,this._chanMgr=new Im(this),this._debug=i,this.noMoreSessions=!1,this.authenticated=!1;function _(B){}this.on("error",_);let x=i?(B,b,w)=>{i(`Debug output from client: ${JSON.stringify(w)}`)}:void 0,S=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof ln.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(ln.KEEPALIVE_CLIENT_INTERVAL)&&ln.KEEPALIVE_CLIENT_INTERVAL>0?ln.KEEPALIVE_CLIENT_INTERVAL:-1,R=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof ln.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(ln.KEEPALIVE_CLIENT_COUNT_MAX)&&ln.KEEPALIVE_CLIENT_COUNT_MAX>=0?ln.KEEPALIVE_CLIENT_COUNT_MAX:-1,H=0;S!==-1&&R!==-1&&(this.once("ready",()=>{let B=()=>{clearInterval(h)};this.on("close",B).on("end",B),h=setInterval(()=>{if(++H>R){clearInterval(h);let b=new Error("Keepalive timeout");b.level="client-timeout",this.emit("error",b),this.end()}else C.ping()},S)}),p=()=>{h&&h.refresh(),H=0});let C=this._protocol=new Em({server:!0,hostKeys:e,ident:r,offer:s,onPacket:p,greeting:a.greeting,banner:a.banner,onWrite:B=>{Ls(t)&&t.write(B)},onError:B=>{C._destruct||t.removeAllListeners("data"),this.emit("error",B);try{t.end()}catch{}},onHeader:B=>{this.removeListener("error",_);let b={ip:t.remoteAddress,family:t.remoteFamily,port:t.remotePort,header:B};if(!o.emit("connection",this,b)){C.disconnect(Qr.BY_APPLICATION),t.end();return}B.greeting&&this.emit("greeting",B.greeting)},onHandshakeComplete:B=>{++c>1&&this.emit("rekey"),this.emit("handshake",B)},debug:i,messageHandlers:{DEBUG:x,DISCONNECT:(B,b,w)=>{if(b!==Qr.BY_APPLICATION){w||(w=dm[b],w===void 0&&(w=`Unexpected disconnection reason: ${b}`));let k=new Error(w);k.code=b,this.emit("error",k)}t.end()},CHANNEL_OPEN:(B,b)=>{if(b.type==="session"&&this.noMoreSessions||!this.authenticated){let te=Hr.ADMINISTRATIVELY_PROHIBITED;return C.channelOpenFail(b.sender,te)}let w=-1,k,v=!1,P,ne=()=>{v||(v=!0,k===void 0&&(w===-1?k=Hr.RESOURCE_SHORTAGE:k=Hr.CONNECT_FAILED),w!==-1&&this._chanMgr.remove(w),C.channelOpenFail(b.sender,k,""))},z=()=>(w=this._chanMgr.add(),w===-1&&(k=Hr.RESOURCE_SHORTAGE,i&&i("Automatic rejection of incoming channel open: no channels available")),w!==-1),Y=b.data;switch(b.type){case"session":if(Gt(this,"session")&&z()){P=()=>{if(v)return;v=!0;let te=new Cn(this,b,w);return this._chanMgr.update(w,te),C.channelOpenConfirm(b.sender,w,jn,Xn),te},this.emit("session",P,ne);return}break;case"direct-tcpip":if(Gt(this,"tcpip")&&z()){P=()=>{if(v)return;v=!0;let te={type:void 0,incoming:{id:w,window:jn,packetSize:Xn,state:"open"},outgoing:{id:b.sender,window:b.window,packetSize:b.packetSize,state:"open"}},le=new Wr(this,te,{server:!0});return this._chanMgr.update(w,le),C.channelOpenConfirm(b.sender,w,jn,Xn),le},this.emit("tcpip",P,ne,Y);return}break;case"direct-streamlocal@openssh.com":if(Gt(this,"openssh.streamlocal")&&z()){P=()=>{if(v)return;v=!0;let te={type:void 0,incoming:{id:w,window:jn,packetSize:Xn,state:"open"},outgoing:{id:b.sender,window:b.window,packetSize:b.packetSize,state:"open"}},le=new Wr(this,te,{server:!0});return this._chanMgr.update(w,le),C.channelOpenConfirm(b.sender,w,jn,Xn),le},this.emit("openssh.streamlocal",P,ne,Y);return}break;default:k=Hr.UNKNOWN_CHANNEL_TYPE,i&&i(`Automatic rejection of unsupported incoming channel open type: ${b.type}`)}k===void 0&&(k=Hr.ADMINISTRATIVELY_PROHIBITED,i&&i(`Automatic rejection of unexpected incoming channel open for: ${b.type}`)),ne()},CHANNEL_OPEN_CONFIRMATION:(B,b)=>{let w=this._chanMgr.get(b.recipient);if(typeof w!="function")return;let k={type:w.type,incoming:{id:b.recipient,window:jn,packetSize:Xn,state:"open"},outgoing:{id:b.sender,window:b.window,packetSize:b.packetSize,state:"open"}},v=new Wr(this,k,{server:!0});this._chanMgr.update(b.recipient,v),w(void 0,v)},CHANNEL_OPEN_FAILURE:(B,b,w,k)=>{let v=this._chanMgr.get(b);if(typeof v!="function")return;Cm(this,b,{reason:w,description:k},v)},CHANNEL_DATA:(B,b,w)=>{let k=this._chanMgr.get(b);if(!(typeof k!="object"||k===null)&&!(k.constructor===Cn&&(k=k._channel,!k))&&k.incoming.window!==0){if(k.incoming.window-=w.length,k.push(w)===!1){k._waitChanDrain=!0;return}k.incoming.window<=wm&&Sm(k)}},CHANNEL_EXTENDED_DATA:(B,b,w,k)=>{},CHANNEL_WINDOW_ADJUST:(B,b,w)=>{let k=this._chanMgr.get(b);typeof k!="object"||k===null||k.constructor===Cn&&(k=k._channel,!k)||(k.outgoing.window+=w,k._waitWindow&&(k._waitWindow=!1,k._chunk?k._write(k._chunk,null,k._chunkcb):k._chunkcb?k._chunkcb():k._chunkErr?k.stderr._write(k._chunkErr,null,k._chunkcbErr):k._chunkcbErr&&k._chunkcbErr()))},CHANNEL_SUCCESS:(B,b)=>{let w=this._chanMgr.get(b);typeof w!="object"||w===null||w.constructor===Cn&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!1)},CHANNEL_FAILURE:(B,b)=>{let w=this._chanMgr.get(b);typeof w!="object"||w===null||w.constructor===Cn&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!0)},CHANNEL_REQUEST:(B,b,w,k,v)=>{let P=this._chanMgr.get(b);if(typeof P!="object"||P===null)return;let ne=!1,z,Y;if(P.constructor!==Cn){k&&C.channelFailure(P.outgoing.id);return}if(k&&(w!=="shell"&&w!=="exec"&&w!=="subsystem"&&(z=()=>{ne||P._ending||P._channel||(ne=!0,C.channelSuccess(P._chanInfo.outgoing.id))}),Y=()=>{ne||P._ending||P._channel||(ne=!0,C.channelFailure(P._chanInfo.outgoing.id))}),P._ending){Y&&Y();return}switch(w){case"env":if(Gt(P,"env")){P.emit("env",z,Y,{key:v.name,val:v.value});return}break;case"pty-req":if(Gt(P,"pty")){P.emit("pty",z,Y,v);return}break;case"window-change":Gt(P,"window-change")?P.emit("window-change",z,Y,v):Y&&Y();break;case"x11-req":if(Gt(P,"x11")){P.emit("x11",z,Y,v);return}break;case"signal":if(Gt(P,"signal")){P.emit("signal",z,Y,{name:v});return}break;case"auth-agent-req@openssh.com":if(Gt(P,"auth-agent")){P.emit("auth-agent",z,Y);return}break;case"shell":if(Gt(P,"shell")){z=()=>{if(ne||P._ending||P._channel)return;ne=!0,k&&C.channelSuccess(P._chanInfo.outgoing.id);let te=new Wr(this,P._chanInfo,{server:!0});return te.subtype=P.subtype=w,P._channel=te,te},P.emit("shell",z,Y);return}break;case"exec":if(Gt(P,"exec")){z=()=>{if(ne||P._ending||P._channel)return;ne=!0,k&&C.channelSuccess(P._chanInfo.outgoing.id);let te=new Wr(this,P._chanInfo,{server:!0});return te.subtype=P.subtype=w,P._channel=te,te},P.emit("exec",z,Y,{command:v});return}break;case"subsystem":{let te=v==="sftp";if(z=()=>{if(ne||P._ending||P._channel)return;ne=!0,k&&C.channelSuccess(P._chanInfo.outgoing.id);let le;return te?le=new bm(this,P._chanInfo,{server:!0,debug:i}):(le=new Wr(this,P._chanInfo,{server:!0}),le.subtype=P.subtype=`${w}:${v}`),P._channel=le,le},v==="sftp"){if(Gt(P,"sftp")){P.emit("sftp",z,Y);return}te=!1}if(Gt(P,"subsystem")){P.emit("subsystem",z,Y,{name:v});return}break}}i&&i(`Automatic rejection of incoming channel request: ${w}`),Y&&Y()},CHANNEL_EOF:(B,b)=>{let w=this._chanMgr.get(b);typeof w!="object"||w===null||w.constructor===Cn&&(w._ending||(w._ending=!0,w.emit("eof"),w.emit("end")),w=w._channel,!w)||w.incoming.state==="open"&&(w.incoming.state="eof",w.readable&&w.push(null))},CHANNEL_CLOSE:(B,b)=>{let w=this._chanMgr.get(b);typeof w!="object"||w===null||w.constructor===Cn&&(w._ending=!0,w.emit("close"),w=w._channel,!w)||km(this,b,w)},SERVICE_REQUEST:(B,b)=>{if(c===0||l||this.authenticated||b!=="ssh-userauth"){C.disconnect(Qr.SERVICE_NOT_AVAILABLE),t.end();return}l=!0,C.serviceAccept(b)},USERAUTH_REQUEST:(B,b,w,k,v)=>{if(c===0||this.authenticated||u&&(u.username!==b||u.service!==w)||k!=="password"&&k!=="publickey"&&k!=="hostbased"&&k!=="keyboard-interactive"&&k!=="none"||f.length===vm){C.disconnect(Qr.PROTOCOL_ERROR),t.end();return}else if(w!=="ssh-connection"){C.disconnect(Qr.SERVICE_NOT_AVAILABLE),t.end();return}let P;switch(k){case"keyboard-interactive":P=new $s(C,b,w,k,v,U);break;case"publickey":P=new ja(C,b,w,k,v,U);break;case"hostbased":P=new Xa(C,b,w,k,v,U);break;case"password":if(u&&u instanceof Ds&&u._changeCb){let ne=u._changeCb;u._changeCb=void 0,ne(v.newPassword);return}P=new Ds(C,b,w,k,v,U);break;case"none":P=new Jn(C,b,w,k,U);break}if(u)if(u._initialResponse)u._multistep&&!u._finalResponse&&(u._cleanup&&u._cleanup(),u.emit("abort"));else return f.push(P);u=P,Gt(this,"authentication")?this.emit("authentication",u):u.reject()},USERAUTH_INFO_RESPONSE:(B,b)=>{u&&u instanceof $s&&u._onInfoResponse(b)},GLOBAL_REQUEST:(B,b,w,k)=>{let v={type:null,buf:null};function P(ne,z){v.type=ne,v.buf=z,Q()}if(w&&y.push(v),(b==="tcpip-forward"||b==="cancel-tcpip-forward"||b==="no-more-sessions@openssh.com"||b==="streamlocal-forward@openssh.com"||b==="cancel-streamlocal-forward@openssh.com")&&Gt(this,"request")&&this.authenticated){let ne,z;if(w){let Y=!1;ne=te=>{if(Y)return;Y=!0;let le;b==="tcpip-forward"&&k.bindPort===0&&typeof te=="number"&&(le=Buffer.allocUnsafe(4),xm(le,te,0)),P("SUCCESS",le)},z=()=>{Y||(Y=!0,P("FAILURE"))}}if(b==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,ne&&ne();return}this.emit("request",ne,z,b,k)}else w&&P("FAILURE")}}});t.pause(),ym.then(()=>{C.start(),t.on("data",B=>{try{C.parse(B,0,B.length)}catch(b){this.emit("error",b);try{Ls(t)&&t.end()}catch{}}}),t.resume()}).catch(B=>{this.emit("error",B);try{Ls(t)&&t.end()}catch{}}),t.on("error",B=>{B.level="socket",this.emit("error",B)}).once("end",()=>{i&&i("Socket ended"),C.cleanup(),this.emit("end")}).once("close",()=>{i&&i("Socket closed"),C.cleanup(),this.emit("close");let B=new Error("No response from server");this._chanMgr.cleanup(B)});let U=(B,b,w,k)=>{u===B&&!this.authenticated&&(b?(u=void 0,this.authenticated=!0,C.authSuccess(),f=[],this.emit("ready")):(C.authFailure(w,k),f.length&&(u=f.pop(),Gt(this,"authentication")?this.emit("authentication",u):u.reject())))};function Q(){for(;y.length>0&&y[0].type;){let B=y.shift();B.type==="SUCCESS"&&C.requestSuccess(B.buf),B.type==="FAILURE"&&C.requestFailure()}}}end(){return this._sock&&Ls(this._sock)&&(this._protocol.disconnect(Qr.BY_APPLICATION),this._sock.end()),this}x11(t,e,r){return Ya(this,"x11",{originAddr:t,originPort:e},r),this}forwardOut(t,e,r,s,i){return Ya(this,"forwarded-tcpip",{boundAddr:t,boundPort:e,remoteAddr:r,remotePort:s},i),this}openssh_forwardOutStreamLocal(t,e){return Ya(this,"forwarded-streamlocal@openssh.com",{socketPath:t},e),this}rekey(t){let e;try{this._protocol.rekey()}catch(r){e=r}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 Ya(n,t,e,r){let s=jn,i=Xn;typeof e=="function"&&(r=e,e={});let o=(c,l)=>{r(c,l)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"forwarded-tcpip":n._protocol.forwardedTcpip(a,s,i,e);break;case"x11":n._protocol.x11(a,s,i,e);break;case"forwarded-streamlocal@openssh.com":n._protocol.openssh_forwardedStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Bm(n,t){return n-t}Ja.exports=ln;Ja.exports.IncomingClient=Us});var nu=ct((f_,tu)=>{"use strict";var{createCipheriv:Rm,generateKeyPair:Nm,generateKeyPairSync:Pm,getCurves:Tm,randomBytes:Jf}=require("crypto"),{Ber:bt}=si(),Lm=Ao().pbkdf,{CIPHER_INFO:$m}=qn(),Dm=16,Um=16,Om=Tm(),Mm=new Map(Object.entries($m));function Zf(n,t){if(typeof n!="string")throw new TypeError("Key type must be a string");let e={type:"spki",format:"der"},r={type:"pkcs8",format:"der"};switch(n.toLowerCase()){case"rsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for RSA key");let 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:r}]}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(!Om.includes(s))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ed25519":return["ed25519",{publicKeyEncoding:e,privateKeyEncoding:r}];default:throw new Error(`Unsupported key type: ${n}`)}}function Fm(n,t,e){switch(n){case"rsa":{let r=new bt.Reader(e);if(r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.113549.1.1.1")throw new Error("Bad RSA private OID");if(r.readByte()!==bt.Null)throw new Error("Malformed RSA private key (expected null)");if(r.readByte()!==0)throw new Error("Malformed RSA private key (expected zero-length null)");if(r=new bt.Reader(r.readString(bt.OctetString,!0)),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");let s=r.readString(bt.Integer,!0),i=r.readString(bt.Integer,!0),o=r.readString(bt.Integer,!0),a=r.readString(bt.Integer,!0),c=r.readString(bt.Integer,!0);r.readString(bt.Integer,!0),r.readString(bt.Integer,!0);let l=r.readString(bt.Integer,!0),f=Buffer.from("ssh-rsa"),u=Buffer.allocUnsafe(4+f.length+4+s.length+4+i.length+4+o.length+4+l.length+4+a.length+4+c.length),h=0;u.writeUInt32BE(f.length,h+=0),u.set(f,h+=4),u.writeUInt32BE(s.length,h+=f.length),u.set(s,h+=4),u.writeUInt32BE(i.length,h+=s.length),u.set(i,h+=4),u.writeUInt32BE(o.length,h+=i.length),u.set(o,h+=4),u.writeUInt32BE(l.length,h+=o.length),u.set(l,h+=4),u.writeUInt32BE(a.length,h+=l.length),u.set(a,h+=4),u.writeUInt32BE(c.length,h+=a.length),u.set(c,h+=4);let p=Buffer.allocUnsafe(4+f.length+4+i.length+4+s.length);return h=0,p.writeUInt32BE(f.length,h+=0),p.set(f,h+=4),p.writeUInt32BE(i.length,h+=f.length),p.set(i,h+=4),p.writeUInt32BE(s.length,h+=i.length),p.set(s,h+=4),{sshName:f.toString(),priv:u,pub:p}}case"ec":{let r=new bt.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");r.readOID();let s=r.readString(bt.BitString,!0);{let h=0;for(;h<s.length&&s[h]===0;++h);h>0&&(s=s.slice(h))}if(r=new bt.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");let i=r.readOID(),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(r=new bt.Reader(r.readString(bt.OctetString,!0)),r.readSequence(),r.readInt()!==1)throw new Error("Unsupported version in ECDSA private key");let a=Buffer.concat([Buffer.from([0]),r.readString(bt.OctetString,!0)]),c=Buffer.from(`ecdsa-sha2-${o}`);o=Buffer.from(o);let l=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length+4+a.length),f=0;l.writeUInt32BE(c.length,f+=0),l.set(c,f+=4),l.writeUInt32BE(o.length,f+=c.length),l.set(o,f+=4),l.writeUInt32BE(s.length,f+=o.length),l.set(s,f+=4),l.writeUInt32BE(a.length,f+=s.length),l.set(a,f+=4);let u=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length);return f=0,u.writeUInt32BE(c.length,f+=0),u.set(c,f+=4),u.writeUInt32BE(o.length,f+=c.length),u.set(o,f+=4),u.writeUInt32BE(s.length,f+=o.length),u.set(s,f+=4),{sshName:c.toString(),priv:l,pub:u}}case"ed25519":{let r=new bt.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let s=r.readString(bt.BitString,!0);{let f=0;for(;f<s.length&&s[f]===0;++f);f>0&&(s=s.slice(f))}if(r=new bt.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ED25519 private key");if(r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 private OID");r=new bt.Reader(r.readString(bt.OctetString,!0));let i=r.readString(bt.OctetString,!0),o=Buffer.from("ssh-ed25519"),a=Buffer.allocUnsafe(4+o.length+4+s.length+4+(i.length+s.length)),c=0;a.writeUInt32BE(o.length,c+=0),a.set(o,c+=4),a.writeUInt32BE(s.length,c+=o.length),a.set(s,c+=4),a.writeUInt32BE(i.length+s.length,c+=s.length),a.set(i,c+=4),a.set(s,c+=i.length);let l=Buffer.allocUnsafe(4+o.length+4+s.length);return c=0,l.writeUInt32BE(o.length,c+=0),l.set(o,c+=4),l.writeUInt32BE(s.length,c+=o.length),l.set(s,c+=4),{sshName:o.toString(),priv:a,pub:l}}}}function eu(n,t,e,r){let s="new",i,o="";if(typeof r=="object"&&r!==null&&(typeof r.comment=="string"&&r.comment&&(o=r.comment),typeof r.format=="string"&&r.format&&(s=r.format),r.passphrase)){let a;if(typeof r.passphrase=="string")a=Buffer.from(r.passphrase);else if(Buffer.isBuffer(r.passphrase))a=r.passphrase;else throw new Error("Invalid passphrase");if(r.cipher===void 0)throw new Error("Missing cipher name");let c=Mm.get(r.cipher);if(c===void 0)throw new Error("Invalid cipher name");if(s==="new"){let l=Um;if(r.rounds!==void 0){if(!Number.isInteger(r.rounds))throw new TypeError("rounds must be an integer");r.rounds>0&&(l=r.rounds)}let f=Buffer.allocUnsafe(c.keyLen+c.ivLen),u=Jf(Dm);if(Lm(a,a.length,u,u.length,f,f.length,l)!==0)return new Error("Failed to generate information to encrypt key");let p=Buffer.allocUnsafe(4+u.length+4);{let y=0;p.writeUInt32BE(u.length,y+=0),p.set(u,y+=4),p.writeUInt32BE(l,y+=u.length)}i={cipher:c,cipherName:r.cipher,kdfName:"bcrypt",kdfOptions:p,key:f.slice(0,c.keyLen),iv:f.slice(c.keyLen)}}}switch(s){case"new":{let a=`-----BEGIN OPENSSH PRIVATE KEY-----
|
|
15
16
|
`,c,l=Buffer.from(i?i.cipherName:"none"),f=Buffer.from(i?i.kdfName:"none"),u=i?i.kdfOptions:Buffer.alloc(0),h=i?i.cipher.blockLen:8,p=Fm(n,t,e),y=Jf(4),_=Buffer.from(o),x=8+p.priv.length+4+_.length,S=[];for(let Q=1;(x+S.length)%h;++Q)S.push(Q&255);S=Buffer.from(S);let R=Buffer.allocUnsafe(x+S.length),H;{let Q=0;R.set(y,Q+=0),R.set(y,Q+=4),R.set(p.priv,Q+=4),R.writeUInt32BE(_.length,Q+=p.priv.length),R.set(_,Q+=4),R.set(S,Q+=_.length)}if(i){let Q={authTagLength:i.cipher.authLen},B=Rm(i.cipher.sslName,i.key,i.iv,Q);B.setAutoPadding(!1),R=Buffer.concat([B.update(R),B.final()]),i.cipher.authLen>0?H=B.getAuthTag():H=Buffer.alloc(0),i.key.fill(0),i.iv.fill(0)}else H=Buffer.alloc(0);let C=Buffer.from("openssh-key-v1\0"),U=Buffer.allocUnsafe(C.length+4+l.length+4+f.length+4+u.length+4+4+p.pub.length+4+R.length+H.length);{let Q=0;U.set(C,Q+=0),U.writeUInt32BE(l.length,Q+=C.length),U.set(l,Q+=4),U.writeUInt32BE(f.length,Q+=l.length),U.set(f,Q+=4),U.writeUInt32BE(u.length,Q+=f.length),U.set(u,Q+=4),U.writeUInt32BE(1,Q+=u.length),U.writeUInt32BE(p.pub.length,Q+=4),U.set(p.pub,Q+=4),U.writeUInt32BE(R.length,Q+=p.pub.length),U.set(R,Q+=4),U.set(H,Q+=R.length)}{let Q=U.base64Slice(0,U.length),B=Q.replace(/.{64}/g,`$&
|
|
16
17
|
`);Q.length&63&&(B+=`
|
|
17
18
|
`),a+=B}{let Q=p.pub.base64Slice(0,p.pub.length);c=`${p.sshName} ${Q}${o?` ${o}`:""}`}return a+=`-----END OPENSSH PRIVATE KEY-----
|
|
18
|
-
`,{private:a,public:c}}default:throw new Error("Invalid output key format")}}function Hm(){}tu.exports={generateKeyPair:(n,t,e)=>{typeof t=="function"&&(e=t,t=void 0),typeof e!="function"&&(e=Hm);let r=Zf(n,t);Nm(...r,(s,i,o)=>{if(s)return e(s);let a;try{a=eu(r[0],i,o,t)}catch(c){return e(c)}e(null,a)})},generateKeyPairSync:(n,t)=>{let e=Zf(n,t),{publicKey:r,privateKey:s}=Pm(...e);return eu(e[0],r,s,t)}}});var Za=ct((
|
|
19
|
+
`,{private:a,public:c}}default:throw new Error("Invalid output key format")}}function Hm(){}tu.exports={generateKeyPair:(n,t,e)=>{typeof t=="function"&&(e=t,t=void 0),typeof e!="function"&&(e=Hm);let r=Zf(n,t);Nm(...r,(s,i,o)=>{if(s)return e(s);let a;try{a=eu(r[0],i,o,t)}catch(c){return e(c)}e(null,a)})},generateKeyPairSync:(n,t)=>{let e=Zf(n,t),{publicKey:r,privateKey:s}=Pm(...e);return eu(e[0],r,s,t)}}});var Za=ct((u_,ru)=>{"use strict";var{AgentProtocol:Qm,BaseAgent:Wm,createAgent:qm,CygwinAgent:Km,OpenSSHAgent:Vm,PageantAgent:Gm}=sa(),{SSHTTPAgent:zm,SSHTTPSAgent:Ym}=Yf(),{parseKey:jm}=Gn(),{flagsToString:Xm,OPEN_MODE:Jm,STATUS_CODE:Zm,stringToFlags:eA}=wi();ru.exports={AgentProtocol:Qm,BaseAgent:Wm,createAgent:qm,Client:Va(),CygwinAgent:Km,HTTPAgent:zm,HTTPSAgent:Ym,OpenSSHAgent:Vm,PageantAgent:Gm,Server:Xf(),utils:{parseKey:jm,...nu(),sftp:{flagsToString:Xm,OPEN_MODE:Jm,STATUS_CODE:Zm,stringToFlags:eA}}}});var Yh=require("node:events"),jh=zt(Za(),1);var Wh=require("node:events");var iu={name:"adduser",description:"Add a new user",category:"users",params:["<username>"],run:({authUser:n,shell:t,args:e})=>{if(n!=="root")return{stderr:`adduser: permission denied
|
|
19
20
|
`,exitCode:1};let r=e[0];if(!r)return{stderr:`Usage: adduser <username>
|
|
20
21
|
`,exitCode:1};if(t.users.listUsers().includes(r))return{stderr:`adduser: user '${r}' already exists
|
|
21
22
|
`,exitCode:1};let s="",i="new";return{sudoChallenge:{username:r,targetUser:r,commandLine:null,loginShell:!1,prompt:"New password: ",mode:"passwd",onPassword:async(a,c)=>i==="new"?a.length<1?{result:{stderr:`adduser: password cannot be empty
|
|
@@ -127,17 +128,17 @@ ${f.join(`
|
|
|
127
128
|
`,exitCode:0}}};var nd={name:"lsb_release",description:"Print distribution-specific information",category:"system",params:["[-a] [-i] [-d] [-r] [-c]"],run:({args:n,shell:t})=>{let e=t.properties?.os??"Fortune GNU/Linux x64",r="aurora",s="1.0";try{let u=t.vfs.readFile("/etc/os-release");for(let h of u.split(`
|
|
128
129
|
`))h.startsWith("PRETTY_NAME=")&&(e=h.slice(12).replace(/^"|"$/g,"").trim()),h.startsWith("VERSION_CODENAME=")&&(r=h.slice(17).trim()),h.startsWith("VERSION_ID=")&&(s=h.slice(11).replace(/^"|"$/g,"").trim())}catch{}let i=se(n,["-a","--all"]),o=se(n,["-i","--id"]),a=se(n,["-d","--description"]),c=se(n,["-r","--release"]),l=se(n,["-c","--codename"]);if(i||n.length===0)return{stdout:["Distributor ID: Fortune",`Description: ${e}`,`Release: ${s}`,`Codename: ${r}`].join(`
|
|
129
130
|
`),exitCode:0};let f=[];return o&&f.push("Distributor ID: Fortune"),a&&f.push(`Description: ${e}`),c&&f.push(`Release: ${s}`),l&&f.push(`Codename: ${r}`),{stdout:f.join(`
|
|
130
|
-
`),exitCode:0}}};var
|
|
131
|
+
`),exitCode:0}}};var kA={gunzip:"gzip"},qs=new Map,vA=`${__dirname}/manuals/`;async function BA(n){return new Function("moduleName","return import(moduleName)")(n)}async function RA(n){let t=n.toLowerCase(),e=kA[t]??t,r=`builtin:${e}`;if(qs.has(r))return qs.get(r)??null;try{let s=await BA("node:fs/promises"),i=new URL(`${e}.txt`,vA),a=(await s.readFile(i,"utf8")).replace(/\n$/,"");return qs.set(r,a),a}catch{return qs.set(r,null),null}}var rd={name:"man",description:"Interface to the system reference manuals",category:"shell",params:["<command>"],run:async({args:n,shell:t})=>{let e=n[0];if(!e)return{stderr:"What manual page do you want?",exitCode:1};let r=`/usr/share/man/man1/${e}.1`;if(t.vfs.exists(r))return{stdout:t.vfs.readFile(r),exitCode:0};let s=await RA(e);return s?{stdout:s,exitCode:0}:{stderr:`No manual entry for ${e}`,exitCode:16}}};var id={name:"mkdir",description:"Make directories",category:"files",params:["<dir>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"mkdir: missing operand",exitCode:1};for(let s=0;s<r.length;s++){let i=Zn(r,s);if(!i)return{stderr:"mkdir: missing operand",exitCode:1};let o=de(e,i);Me(n,o,"mkdir"),t.vfs.mkdir(o)}return{exitCode:0}}};var sd={name:"mv",description:"Move or rename files",category:"files",params:["<source> <dest>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=r.filter(l=>!l.startsWith("-")),[i,o]=s;if(!i||!o)return{stderr:"mv: missing operand",exitCode:1};let a=de(e,i),c=de(e,o);try{if(Me(n,a,"mv"),Me(n,c,"mv"),!t.vfs.exists(a))return{stderr:`mv: ${i}: No such file or directory`,exitCode:1};let l=t.vfs.exists(c)&&t.vfs.stat(c).type==="directory"?`${c}/${i.split("/").pop()}`:c;return t.vfs.move(a,l),{exitCode:0}}catch(l){return{stderr:`mv: ${l instanceof Error?l.message:String(l)}`,exitCode:1}}}};var od=zt(require("node:path"),1);var ad={name:"nano",description:"Text editor",category:"files",params:["<file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=r[0];if(!s)return{stderr:"nano: missing file operand",exitCode:1};let i=de(e,s);Me(n,i,"nano");let o=t.vfs.exists(i)?t.vfs.readFile(i):"",a=od.posix.basename(i)||"buffer",c=`/tmp/sshmimic-nano-${Date.now()}-${a}.tmp`;return{openEditor:{targetPath:i,tempPath:c,initialContent:o},exitCode:0}}};var Mn=require("node:fs"),Ft=zt(require("node:os"),1),pd=zt(require("node:path"),1);function NA(n){let t=Math.max(1,Math.floor(n/60)),e=Math.floor(t/1440),r=Math.floor(t%1440/60),s=t%60,i=[];return e>0&&i.push(`${e} day${e>1?"s":""}`),r>0&&i.push(`${r} hour${r>1?"s":""}`),(s>0||i.length===0)&&i.push(`${s} min${s>1?"s":""}`),i.join(", ")}function cd(n){return`\x1B[${n}m \x1B[0m`}function PA(){let n=[40,41,42,43,44,45,46,47].map(cd).join(""),t=[100,101,102,103,104,105,106,107].map(cd).join("");return[n,t]}function ld(n,t,e){if(n.trim().length===0)return n;let r={r:255,g:255,b:255},s={r:168,g:85,b:247},i=e<=1?0:t/(e-1),o=Math.round(r.r+(s.r-r.r)*i),a=Math.round(r.g+(s.g-r.g)*i),c=Math.round(r.b+(s.b-r.b)*i);return`\x1B[38;2;${o};${a};${c}m${n}\x1B[0m`}function TA(n){if(n.trim().length===0)return n;let t=n.indexOf(":");if(t===-1)return n.includes("@")?fd(n):n;let e=n.substring(0,t+1),r=n.substring(t+1);return fd(e)+r}function fd(n){let t=new RegExp("\x1B\\[[\\d;]*m","g"),e=n.replace(t,"");if(e.trim().length===0)return n;let r={r:255,g:255,b:255},s={r:168,g:85,b:247},i="";for(let o=0;o<e.length;o+=1){let a=e.length<=1?0:o/(e.length-1),c=Math.round(r.r+(s.r-r.r)*a),l=Math.round(r.g+(s.g-r.g)*a),f=Math.round(r.b+(s.b-r.b)*a);i+=`\x1B[38;2;${c};${l};${f}m${e[o]}\x1B[0m`}return i}function ud(n){return Math.max(0,Math.round(n/(1024*1024)))}function dd(){try{let n=(0,Mn.readFileSync)("/etc/os-release","utf8");for(let t of n.split(`
|
|
131
132
|
`)){if(!t.startsWith("PRETTY_NAME="))continue;return t.slice(12).trim().replace(/^"|"$/g,"")}}catch{return}}function hd(n){try{let t=(0,Mn.readFileSync)(n,"utf8").split(`
|
|
132
|
-
`)[0]?.trim();return!t||t.length===0?void 0:t}catch{return}}function
|
|
133
|
+
`)[0]?.trim();return!t||t.length===0?void 0:t}catch{return}}function LA(n){let t=hd("/sys/devices/virtual/dmi/id/sys_vendor"),e=hd("/sys/devices/virtual/dmi/id/product_name");return t&&e?`${t} ${e}`:e||n}function $A(){let n=["/var/lib/dpkg/status","/usr/local/var/lib/dpkg/status"];for(let t of n)if((0,Mn.existsSync)(t))try{return(0,Mn.readFileSync)(t,"utf8").match(/^Package:\s+/gm)?.length??0}catch{}}function DA(){let n=["/snap","/var/lib/snapd/snaps"];for(let t of n)if((0,Mn.existsSync)(t))try{return(0,Mn.readdirSync)(t,{withFileTypes:!0}).filter(s=>s.isDirectory()).length}catch{}}function UA(){let n=$A(),t=DA();return n!==void 0&&t!==void 0?`${n} (dpkg), ${t} (snap)`:n!==void 0?`${n} (dpkg)`:t!==void 0?`${t} (snap)`:"n/a"}function OA(){let n=Ft.cpus();if(n.length===0)return"unknown";let t=n[0];if(!t)return"unknown";let e=(t.speed/1e3).toFixed(2);return`${t.model} (${n.length}) @ ${e}GHz`}function MA(n){return!n||n.trim().length===0?"unknown":pd.posix.basename(n.trim())}function FA(n){let t=Ft.totalmem(),e=Ft.freemem(),r=Math.max(0,t-e),s=n.shellProps,i=process.uptime();return n.uptimeSeconds===void 0&&(n.uptimeSeconds=Math.round(i)),{user:n.user,host:n.host,osName:s?.os??n.osName??`${dd()??Ft.type()} ${Ft.arch()}`,kernel:s?.kernel??n.kernel??Ft.release(),uptimeSeconds:n.uptimeSeconds??Ft.uptime(),packages:n.packages??UA(),shell:MA(n.shell),shellProps:n.shellProps??{kernel:n.kernel??Ft.release(),os:n.osName??`${dd()??Ft.type()} ${Ft.arch()}`,arch:Ft.arch()},resolution:n.resolution??"n/a (ssh)",terminal:n.terminal??"unknown",cpu:n.cpu??OA(),gpu:n.gpu??"n/a",memoryUsedMiB:n.memoryUsedMiB??ud(r),memoryTotalMiB:n.memoryTotalMiB??ud(t)}}function gd(n){let t=FA(n),e=NA(t.uptimeSeconds),r=PA(),s=[" .. .:. "," .::.. .. .. ",". .... ... .. ",": .... .:. .. ",": .:.:........:. .. ",": .. ",". : ",". : ",".. : "," :. .. "," .. .. "," :-. :: "," .:. :. "," ..: ... "," ..: :.. "," :... :...."," .. ...."," . .. "," .:. .: "," :. .. "," ::. .. ","..... ..:... ","...:. .. ",".:...:. ::. .. "," ... ..:::::.. ..:::::::.. "],i=[`${t.user}@${t.host}`,"-------------------------",`OS: ${t.osName}`,`Host: ${LA(t.host)}`,`Kernel: ${t.kernel}`,`Uptime: ${e}`,`Packages: ${t.packages}`,`Shell: ${t.shell}`,`Resolution: ${t.resolution}`,`Terminal: ${t.terminal}`,`CPU: ${t.cpu}`,`GPU: ${t.gpu}`,`Memory: ${t.memoryUsedMiB}MiB / ${t.memoryTotalMiB}MiB`,"",r[0],r[1]],o=Math.max(s.length,i.length),a=[];for(let c=0;c<o;c+=1){let l=s[c]??"",f=i[c]??"";if(f.length>0){let u=ld(l.padEnd(31," "),c,s.length),h=TA(f);a.push(`${u} ${h}`);continue}a.push(ld(l,c,s.length))}return a.join(`
|
|
133
134
|
`)}var md={name:"neofetch",description:"System info display",category:"system",params:["[--off]"],run:({args:n,authUser:t,hostname:e,shell:r,env:s})=>r.packageManager.isInstalled("neofetch")?se(n,"--help")?{stdout:"Usage: neofetch [--off]",exitCode:0}:se(n,"--off")?{stdout:`${t}@${e}`,exitCode:0}:{stdout:gd({user:t,host:e,shell:s.vars.SHELL,shellProps:r.properties,terminal:s.vars.TERM,uptimeSeconds:Math.floor((Date.now()-r.startTime)/1e3),packages:`${r.packageManager?.installedCount()??0} (dpkg)`}),exitCode:0}:{stderr:`bash: neofetch: command not found
|
|
134
135
|
Hint: install it with: apt install neofetch
|
|
135
|
-
`,exitCode:127}};var ic=zt(require("node:vm"),1);var Ks="v18.19.0",Ad={node:Ks,npm:"9.2.0",v8:"10.2.154.26-node.22"};function
|
|
136
|
-
`};case"util":return{format:(...o)=>o.map(vn).join(" "),inspect:o=>vn(o)};case"fs":case"fs/promises":throw new Error(`Cannot require '${i}': filesystem access not available in virtual runtime`);case"child_process":case"net":case"http":case"https":throw new Error(`Cannot require '${i}': not available in virtual runtime`);default:throw new Error(`Cannot find module '${i}'`)}};return s.resolve=i=>{throw new Error(`Cannot resolve '${i}'`)},s.cache={},s.extensions={},ic.default.createContext({console:r,process:e,require:s,Math,JSON,Object,Array,String,Number,Boolean,Symbol,Date,RegExp,Error,TypeError,RangeError,SyntaxError,Promise,Map,Set,WeakMap,WeakSet,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,encodeURI,decodeURI,setTimeout:()=>{},clearTimeout:()=>{},setInterval:()=>{},clearInterval:()=>{},queueMicrotask:()=>{},globalThis:void 0,undefined:void 0,Infinity:1/0,NaN:NaN})}var Vs=class{constructor(t){this.code=t}code};function vn(n){if(n===null)return"null";if(n===void 0)return"undefined";if(typeof n=="string")return n;if(typeof n=="function")return`[Function: ${n.name||"(anonymous)"}]`;if(Array.isArray(n))return`[ ${n.map(vn).join(", ")} ]`;if(n instanceof Error)return`${n.name}: ${n.message}`;if(typeof n=="object")try{return`{ ${Object.entries(n).map(([e,r])=>`${e}: ${vn(r)}`).join(", ")} }`}catch{return"[Object]"}return String(n)}function Gs(n){let t=[],e=[],r=
|
|
136
|
+
`,exitCode:127}};var ic=zt(require("node:vm"),1);var Ks="v18.19.0",Ad={node:Ks,npm:"9.2.0",v8:"10.2.154.26-node.22"};function HA(n,t){let e={version:Ks,versions:Ad,platform:"linux",arch:"x64",env:{NODE_ENV:"production",HOME:"/root",PATH:"/usr/local/bin:/usr/bin:/bin"},argv:["node"],stdout:{write:i=>(n.push(i),!0)},stderr:{write:i=>(t.push(i),!0)},exit:(i=0)=>{throw new Vs(i)},cwd:()=>"/root",hrtime:()=>[0,0]},r={log:(...i)=>n.push(i.map(vn).join(" ")),error:(...i)=>t.push(i.map(vn).join(" ")),warn:(...i)=>t.push(i.map(vn).join(" ")),info:(...i)=>n.push(i.map(vn).join(" ")),dir:i=>n.push(vn(i))},s=i=>{switch(i){case"path":return{join:(...o)=>o.join("/").replace(/\/+/g,"/"),resolve:(...o)=>`/${o.join("/").replace(/^\/+/,"")}`,dirname:o=>o.split("/").slice(0,-1).join("/")||"/",basename:o=>o.split("/").pop()??"",extname:o=>{let a=o.split("/").pop()??"",c=a.lastIndexOf(".");return c>0?a.slice(c):""},sep:"/",delimiter:":"};case"os":return{platform:()=>"linux",arch:()=>"x64",type:()=>"Linux",hostname:()=>"fortune-vm",homedir:()=>"/root",tmpdir:()=>"/tmp",EOL:`
|
|
137
|
+
`};case"util":return{format:(...o)=>o.map(vn).join(" "),inspect:o=>vn(o)};case"fs":case"fs/promises":throw new Error(`Cannot require '${i}': filesystem access not available in virtual runtime`);case"child_process":case"net":case"http":case"https":throw new Error(`Cannot require '${i}': not available in virtual runtime`);default:throw new Error(`Cannot find module '${i}'`)}};return s.resolve=i=>{throw new Error(`Cannot resolve '${i}'`)},s.cache={},s.extensions={},ic.default.createContext({console:r,process:e,require:s,Math,JSON,Object,Array,String,Number,Boolean,Symbol,Date,RegExp,Error,TypeError,RangeError,SyntaxError,Promise,Map,Set,WeakMap,WeakSet,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,encodeURI,decodeURI,setTimeout:()=>{},clearTimeout:()=>{},setInterval:()=>{},clearInterval:()=>{},queueMicrotask:()=>{},globalThis:void 0,undefined:void 0,Infinity:1/0,NaN:NaN})}var Vs=class{constructor(t){this.code=t}code};function vn(n){if(n===null)return"null";if(n===void 0)return"undefined";if(typeof n=="string")return n;if(typeof n=="function")return`[Function: ${n.name||"(anonymous)"}]`;if(Array.isArray(n))return`[ ${n.map(vn).join(", ")} ]`;if(n instanceof Error)return`${n.name}: ${n.message}`;if(typeof n=="object")try{return`{ ${Object.entries(n).map(([e,r])=>`${e}: ${vn(r)}`).join(", ")} }`}catch{return"[Object]"}return String(n)}function Gs(n){let t=[],e=[],r=HA(t,e),s=0;try{let i=ic.default.runInContext(n,r,{timeout:5e3});i!==void 0&&t.length===0&&t.push(vn(i))}catch(i){i instanceof Vs?s=i.code:i instanceof Error?(e.push(`${i.name}: ${i.message}`),s=1):(e.push(String(i)),s=1)}return{stdout:t.length?`${t.join(`
|
|
137
138
|
`)}
|
|
138
139
|
`:"",stderr:e.length?`${e.join(`
|
|
139
140
|
`)}
|
|
140
|
-
`:"",exitCode:s}}function
|
|
141
|
+
`:"",exitCode:s}}function QA(n){let t=n.trim();return!t.includes(`
|
|
141
142
|
`)&&!t.startsWith("const ")&&!t.startsWith("let ")&&!t.startsWith("var ")&&!t.startsWith("function ")&&!t.startsWith("class ")&&!t.startsWith("if ")&&!t.startsWith("for ")&&!t.startsWith("while ")&&!t.startsWith("import ")&&!t.startsWith("//")?Gs(t):Gs(`(async () => { ${n} })()`)}var yd={name:"node",description:"JavaScript runtime (virtual)",category:"system",params:["[--version] [-e <expr>] [-p <expr>] [file]"],run:({args:n,shell:t,cwd:e})=>{if(!t.packageManager.isInstalled("nodejs"))return{stderr:`bash: node: command not found
|
|
142
143
|
Hint: install it with: apt install nodejs
|
|
143
144
|
`,exitCode:127};if(se(n,["--version","-v"]))return{stdout:`${Ks}
|
|
@@ -146,11 +147,11 @@ Hint: install it with: apt install nodejs
|
|
|
146
147
|
`,exitCode:1};let{stdout:a,stderr:c,exitCode:l}=Gs(o);return{stdout:a||void 0,stderr:c||void 0,exitCode:l}}let s=n.findIndex(o=>o==="-p"||o==="--print");if(s!==-1){let o=n[s+1];if(!o)return{stderr:`node: -p requires an argument
|
|
147
148
|
`,exitCode:1};let{stdout:a,stderr:c,exitCode:l}=Gs(o);return{stdout:a||(l===0?`
|
|
148
149
|
`:void 0),stderr:c||void 0,exitCode:l}}let i=n.find(o=>!o.startsWith("-"));if(i){let o=de(e,i);if(!t.vfs.exists(o))return{stderr:`node: cannot open file '${i}': No such file or directory
|
|
149
|
-
`,exitCode:1};let a=t.vfs.readFile(o),{stdout:c,stderr:l,exitCode:f}=
|
|
150
|
-
`),exitCode:0}}};var zs="9.2.0",
|
|
150
|
+
`,exitCode:1};let a=t.vfs.readFile(o),{stdout:c,stderr:l,exitCode:f}=QA(a);return{stdout:c||void 0,stderr:l||void 0,exitCode:f}}return{stdout:[`Welcome to Node.js ${Ks}.`,'Type ".exit" to exit the REPL.',"> "].join(`
|
|
151
|
+
`),exitCode:0}}};var zs="9.2.0",WA="18.19.0",_d={name:"npm",description:"Node.js package manager (virtual)",category:"system",params:["<command> [args]"],run:({args:n,shell:t})=>{if(!t.packageManager.isInstalled("npm"))return{stderr:`bash: npm: command not found
|
|
151
152
|
Hint: install it with: apt install npm
|
|
152
153
|
`,exitCode:127};if(se(n,["--version","-v"]))return{stdout:`${zs}
|
|
153
|
-
`,exitCode:0};let e=n[0]?.toLowerCase();switch(e){case"version":case"-version":return{stdout:`{ npm: '${zs}', node: '${
|
|
154
|
+
`,exitCode:0};let e=n[0]?.toLowerCase();switch(e){case"version":case"-version":return{stdout:`{ npm: '${zs}', node: '${WA}', v8: '10.2.154.26' }
|
|
154
155
|
`,exitCode:0};case"install":case"i":case"add":return{stderr:`npm warn: package installation is not available in the virtual runtime.
|
|
155
156
|
npm warn: This environment simulates npm CLI behaviour only.
|
|
156
157
|
`,exitCode:1};case"run":case"exec":case"x":return{stderr:`npm error: script execution is not available in the virtual runtime.
|
|
@@ -167,12 +168,12 @@ Hint: install it with: apt install npm
|
|
|
167
168
|
`,exitCode:127}};var bd={name:"passwd",description:"Change user password",category:"users",params:["[username]"],run:async({authUser:n,args:t,shell:e,stdin:r})=>{let s=t[0]??n;if(n!=="root"&&n!==s)return{stderr:"passwd: permission denied",exitCode:1};if(!e.users.listUsers().includes(s))return{stderr:`passwd: user '${s}' does not exist`,exitCode:1};if(r!==void 0&&r.trim().length>0){let i=r.trim().split(`
|
|
168
169
|
`)[0];return await e.users.setPassword(s,i),{stdout:`passwd: password updated successfully
|
|
169
170
|
`,exitCode:0}}return{passwordChallenge:{prompt:"New password: ",confirmPrompt:"Retype new password: ",action:"passwd",targetUsername:s},exitCode:0}}};var xd={name:"ping",description:"Send ICMP ECHO_REQUEST (mock)",category:"network",params:["[-c <count>] <host>"],run:({args:n})=>{let{flagsWithValues:t,positionals:e}=Xt(n,{flagsWithValue:["-c","-i","-W"]}),r=e[0]??"localhost",s=t.get("-c"),i=s?Math.max(1,parseInt(s,10)||4):4,o=[`PING ${r}: 56 data bytes`];for(let a=0;a<i;a++){let c=(Math.random()*10+1).toFixed(3);o.push(`64 bytes from ${r}: icmp_seq=${a} ttl=64 time=${c} ms`)}return o.push(`--- ${r} ping statistics ---`),o.push(`${i} packets transmitted, ${i} received, 0% packet loss`),{stdout:o.join(`
|
|
170
|
-
`),exitCode:0}}};function
|
|
171
|
-
`,s+=2;continue;case"t":r+=" ",s+=2;continue;case"r":r+="\r",s+=2;continue;case"\\":r+="\\",s+=2;continue;case"a":r+="\x07",s+=2;continue;case"b":r+="\b",s+=2;continue;case"f":r+="\f",s+=2;continue;case"v":r+="\v",s+=2;continue;default:r+=n[s],s++;continue}if(n[s]==="%"&&s+1<n.length){let i=s+1,o=!1;n[i]==="-"&&(o=!0,i++);let a=!1;n[i]==="0"&&(a=!0,i++);let c=0;for(;i<n.length&&/\d/.test(n[i]);)c=c*10+parseInt(n[i],10),i++;let l=-1;if(n[i]===".")for(i++,l=0;i<n.length&&/\d/.test(n[i]);)l=l*10+parseInt(n[i],10),i++;let f=n[i],u=t[e++]??"",h=(p,y=" ")=>{if(c<=0||p.length>=c)return p;let _=y.repeat(c-p.length);return o?p+_:_+p};switch(f){case"s":{let p=String(u);l>=0&&(p=p.slice(0,l)),r+=h(p);break}case"d":case"i":r+=h(String(parseInt(u,10)||0),a?"0":" ");break;case"f":{let p=l>=0?l:6;r+=h((parseFloat(u)||0).toFixed(p));break}case"o":r+=h((parseInt(u,10)||0).toString(8),a?"0":" ");break;case"x":r+=h((parseInt(u,10)||0).toString(16),a?"0":" ");break;case"X":r+=h((parseInt(u,10)||0).toString(16).toUpperCase(),a?"0":" ");break;case"%":r+="%",e--;break;default:r+=n[s],s++;continue}s=i+1;continue}r+=n[s],s++}return r}var Sd={name:"printf",description:"Format and print data",category:"shell",params:["<format> [args...]"],run:({args:n})=>{let t=n[0];return t?{stdout:
|
|
171
|
+
`),exitCode:0}}};function qA(n,t){let e=0,r="",s=0;for(;s<n.length;){if(n[s]==="\\"&&s+1<n.length)switch(n[s+1]){case"n":r+=`
|
|
172
|
+
`,s+=2;continue;case"t":r+=" ",s+=2;continue;case"r":r+="\r",s+=2;continue;case"\\":r+="\\",s+=2;continue;case"a":r+="\x07",s+=2;continue;case"b":r+="\b",s+=2;continue;case"f":r+="\f",s+=2;continue;case"v":r+="\v",s+=2;continue;default:r+=n[s],s++;continue}if(n[s]==="%"&&s+1<n.length){let i=s+1,o=!1;n[i]==="-"&&(o=!0,i++);let a=!1;n[i]==="0"&&(a=!0,i++);let c=0;for(;i<n.length&&/\d/.test(n[i]);)c=c*10+parseInt(n[i],10),i++;let l=-1;if(n[i]===".")for(i++,l=0;i<n.length&&/\d/.test(n[i]);)l=l*10+parseInt(n[i],10),i++;let f=n[i],u=t[e++]??"",h=(p,y=" ")=>{if(c<=0||p.length>=c)return p;let _=y.repeat(c-p.length);return o?p+_:_+p};switch(f){case"s":{let p=String(u);l>=0&&(p=p.slice(0,l)),r+=h(p);break}case"d":case"i":r+=h(String(parseInt(u,10)||0),a?"0":" ");break;case"f":{let p=l>=0?l:6;r+=h((parseFloat(u)||0).toFixed(p));break}case"o":r+=h((parseInt(u,10)||0).toString(8),a?"0":" ");break;case"x":r+=h((parseInt(u,10)||0).toString(16),a?"0":" ");break;case"X":r+=h((parseInt(u,10)||0).toString(16).toUpperCase(),a?"0":" ");break;case"%":r+="%",e--;break;default:r+=n[s],s++;continue}s=i+1;continue}r+=n[s],s++}return r}var Sd={name:"printf",description:"Format and print data",category:"shell",params:["<format> [args...]"],run:({args:n})=>{let t=n[0];return t?{stdout:qA(t,n.slice(1)),exitCode:0}:{stderr:"printf: missing format string",exitCode:1}}};var wd={name:"ps",description:"Report process status",category:"system",params:["[-a] [-u] [-x] [aux]"],run:({authUser:n,shell:t,args:e})=>{let r=t.users.listActiveSessions(),s=se(e,["-u"])||e.includes("u")||e.includes("aux")||e.includes("au"),i=se(e,["-a","-x"])||e.includes("a")||e.includes("aux");if(s){let f=["USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND"],u=1e3;for(let h of r){let p=h.username.padEnd(10).slice(0,10),y=(Math.random()*.5).toFixed(1),_=Math.floor(Math.random()*2e4+5e3),x=Math.floor(Math.random()*5e3+1e3);f.push(`${p} ${String(u).padStart(6)} 0.0 ${y.padStart(4)} ${String(_).padStart(6)} ${String(x).padStart(5)} ${h.tty.padEnd(8)} Ss 00:00 0:00 bash`),u++}return f.push(`root ${String(u).padStart(6)} 0.0 0.0 0 0 ? S 00:00 0:00 ps`),{stdout:f.join(`
|
|
172
173
|
`),exitCode:0}}let a=[" PID TTY TIME CMD"],c=1e3;for(let l of r)!i&&l.username!==n||(a.push(`${String(c).padStart(5)} ${l.tty.padEnd(12)} 00:00:00 ${l.username===n?"bash":`bash (${l.username})`}`),c++);return a.push(`${String(c).padStart(5)} pts/0 00:00:00 ps`),{stdout:a.join(`
|
|
173
|
-
`),exitCode:0}}};var Id={name:"pwd",description:"Print working directory",category:"navigation",params:[],run:({cwd:n})=>({stdout:n,exitCode:0})};var
|
|
174
|
-
`],["curdir","."],["pardir",".."]]);return e.__methods__={getcwd:()=>n,getenv:r=>typeof r=="string"?process.env[r]??G:G,path:_t([["join",G],["exists",G],["dirname",G],["basename",G]]),listdir:()=>[]},t.set("__builtins__",G),t.set("__name__","__main__"),t.set("__cwd__",n),t}function
|
|
175
|
-
`],["name","posix"]]);return e._cwd=n,t._cwd=n,e.path=t,e}function
|
|
174
|
+
`),exitCode:0}}};var Id={name:"pwd",description:"Print working directory",category:"navigation",params:[],run:({cwd:n})=>({stdout:n,exitCode:0})};var KA="Python 3.11.2";var Ys="3.11.2 (default, Mar 13 2023, 12:18:29) [GCC 12.2.0]",G={__pytype__:"none"};function _t(n=[]){return{__pytype__:"dict",data:new Map(n)}}function sc(n,t,e=1){return{__pytype__:"range",start:n,stop:t,step:e}}function mt(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="dict"}function Gr(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="range"}function Bn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="func"}function oc(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="class"}function Li(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="instance"}function Fn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="none"}function Nt(n){return n===null||Fn(n)?"None":n===!0?"True":n===!1?"False":typeof n=="number"?Number.isInteger(n)?String(n):n.toPrecision(12).replace(/\.?0+$/,""):typeof n=="string"?`'${n.replace(/'/g,"\\'")}'`:Array.isArray(n)?`[${n.map(Nt).join(", ")}]`:mt(n)?`{${[...n.data.entries()].map(([t,e])=>`'${t}': ${Nt(e)}`).join(", ")}}`:Gr(n)?`range(${n.start}, ${n.stop}${n.step!==1?`, ${n.step}`:""})`:Bn(n)?`<function ${n.name} at 0x...>`:oc(n)?`<class '${n.name}'>`:Li(n)?`<${n.cls.name} object at 0x...>`:String(n)}function Pe(n){return n===null||Fn(n)?"None":n===!0?"True":n===!1?"False":typeof n=="number"?Number.isInteger(n)?String(n):n.toPrecision(12).replace(/\.?0+$/,""):typeof n=="string"?n:Array.isArray(n)?`[${n.map(Nt).join(", ")}]`:mt(n)?`{${[...n.data.entries()].map(([t,e])=>`'${t}': ${Nt(e)}`).join(", ")}}`:Gr(n)?`range(${n.start}, ${n.stop}${n.step!==1?`, ${n.step}`:""})`:Nt(n)}function fn(n){return n===null||Fn(n)?!1:typeof n=="boolean"?n:typeof n=="number"?n!==0:typeof n=="string"||Array.isArray(n)?n.length>0:mt(n)?n.data.size>0:Gr(n)?kd(n)>0:!0}function kd(n){if(n.step===0)return 0;let t=Math.ceil((n.stop-n.start)/n.step);return Math.max(0,t)}function VA(n){let t=[];for(let e=n.start;(n.step>0?e<n.stop:e>n.stop)&&(t.push(e),!(t.length>1e4));e+=n.step);return t}function Rt(n){if(Array.isArray(n))return n;if(typeof n=="string")return[...n];if(Gr(n))return VA(n);if(mt(n))return[...n.data.keys()];throw new yt("TypeError",`'${dr(n)}' object is not iterable`)}function dr(n){return n===null||Fn(n)?"NoneType":typeof n=="boolean"?"bool":typeof n=="number"?Number.isInteger(n)?"int":"float":typeof n=="string"?"str":Array.isArray(n)?"list":mt(n)?"dict":Gr(n)?"range":Bn(n)?"function":oc(n)?"type":Li(n)?n.cls.name:"object"}var yt=class{constructor(t,e){this.type=t;this.message=e}type;message;toString(){return`${this.type}: ${this.message}`}},Vr=class{constructor(t){this.value=t}value},$i=class{},Di=class{},Ui=class{constructor(t){this.code=t}code};function GA(n){let t=new Map,e=_t([["sep","/"],["linesep",`
|
|
175
|
+
`],["curdir","."],["pardir",".."]]);return e.__methods__={getcwd:()=>n,getenv:r=>typeof r=="string"?process.env[r]??G:G,path:_t([["join",G],["exists",G],["dirname",G],["basename",G]]),listdir:()=>[]},t.set("__builtins__",G),t.set("__name__","__main__"),t.set("__cwd__",n),t}function zA(n){let t=_t([["sep","/"],["curdir","."]]),e=_t([["sep","/"],["linesep",`
|
|
176
|
+
`],["name","posix"]]);return e._cwd=n,t._cwd=n,e.path=t,e}function YA(){return _t([["version",Ys],["version_info",_t([["major",3],["minor",11],["micro",2]].map(([n,t])=>[n,t]))],["platform","linux"],["executable","/usr/bin/python3"],["prefix","/usr"],["path",["/usr/lib/python3.11","/usr/lib/python3.11/lib-dynload"]],["argv",[""]],["maxsize",9007199254740991]])}function jA(){return _t([["pi",Math.PI],["e",Math.E],["tau",Math.PI*2],["inf",1/0],["nan",NaN],["sqrt",G],["floor",G],["ceil",G],["log",G],["pow",G],["sin",G],["cos",G],["tan",G],["fabs",G],["factorial",G]])}function XA(){return _t([["dumps",G],["loads",G]])}function JA(){return _t([["match",G],["search",G],["findall",G],["sub",G],["split",G],["compile",G]])}var Cd={os:zA,sys:()=>YA(),math:()=>jA(),json:()=>XA(),re:()=>JA(),random:()=>_t([["random",G],["randint",G],["choice",G],["shuffle",G]]),time:()=>_t([["time",G],["sleep",G],["ctime",G]]),datetime:()=>_t([["datetime",G],["date",G],["timedelta",G]]),collections:()=>_t([["Counter",G],["defaultdict",G],["OrderedDict",G]]),itertools:()=>_t([["chain",G],["product",G],["combinations",G],["permutations",G]]),functools:()=>_t([["reduce",G],["partial",G],["lru_cache",G]]),string:()=>_t([["ascii_letters","abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"],["digits","0123456789"],["punctuation","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"]])},js=class{constructor(t){this.cwd=t}cwd;output=[];stderr=[];modules=new Map;getOutput(){return this.output.join(`
|
|
176
177
|
`)+(this.output.length?`
|
|
177
178
|
`:"")}getStderr(){return this.stderr.join(`
|
|
178
179
|
`)+(this.stderr.length?`
|
|
@@ -180,9 +181,9 @@ Hint: install it with: apt install npm
|
|
|
180
181
|
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');let r=t.match(/^f(['"])([\s\S]*)\1$/);if(r){let l=r[2];return l=l.replace(/\{([^{}]+)\}/g,(f,u)=>{try{return Pe(this.pyEval(u.trim(),e))}catch{return`{${u}}`}}),l}let s=t.match(/^b(['"])(.*)\1$/s);if(s)return s[2];if(t.startsWith("[")&&t.endsWith("]")){let l=t.slice(1,-1).trim();if(!l)return[];let f=l.match(/^(.+?)\s+for\s+(\w+)\s+in\s+(.+?)(?:\s+if\s+(.+))?$/);if(f){let[,u,h,p,y]=f,_=Rt(this.pyEval(p.trim(),e)),x=[];for(let S of _){let R=new Map(e);R.set(h,S),!(y&&!fn(this.pyEval(y,R)))&&x.push(this.pyEval(u.trim(),R))}return x}return this.splitArgs(l).map(u=>this.pyEval(u,e))}if(t.startsWith("(")&&t.endsWith(")")){let l=t.slice(1,-1).trim();if(!l)return[];let f=this.splitArgs(l);return f.length===1&&!l.endsWith(",")?this.pyEval(f[0],e):f.map(u=>this.pyEval(u,e))}if(t.startsWith("{")&&t.endsWith("}")){let l=t.slice(1,-1).trim();if(!l)return _t();let f=_t();for(let u of this.splitArgs(l)){let h=u.indexOf(":");if(h===-1)continue;let p=Pe(this.pyEval(u.slice(0,h).trim(),e)),y=this.pyEval(u.slice(h+1).trim(),e);f.data.set(p,y)}return f}let i=t.match(/^not\s+(.+)$/);if(i)return!fn(this.pyEval(i[1],e));let o=[["or"],["and"],["in","not in","is not","is","==","!=","<=",">=","<",">"],["+","-"],["**"],["*","//","/","%"]];for(let l of o){let f=this.tryBinaryOp(t,l,e);if(f!==void 0)return f}if(t.startsWith("-")){let l=this.pyEval(t.slice(1),e);if(typeof l=="number")return-l}if(process.env.PY_DEBUG&&console.error("eval:",JSON.stringify(t)),t.endsWith("]")&&!t.startsWith("[")){let l=this.findMatchingBracket(t,"[");if(l!==-1){let f=this.pyEval(t.slice(0,l),e),u=t.slice(l+1,-1);return this.subscript(f,u,e)}}let a=t.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/);if(a){let[,l,f]=a,u=(f?.trim()?this.splitArgs(f):[]).map(h=>this.pyEval(h,e));return this.callBuiltin(l,u,e)}let c=this.findDotAccess(t);if(c){let{objExpr:l,attr:f,callPart:u}=c,h=this.pyEval(l,e);if(u!==void 0){let p=u.slice(1,-1),y=p.trim()?this.splitArgs(p).map(_=>this.pyEval(_,e)):[];return this.callMethod(h,f,y,e)}return this.getAttr(h,f,e)}if(/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)){if(e.has(t))return e.get(t);throw new yt("NameError",`name '${t}' is not defined`)}if(/^[A-Za-z_][A-Za-z0-9_.]+$/.test(t)){let l=t.split("."),f=e.get(l[0])??(()=>{throw new yt("NameError",`name '${l[0]}' is not defined`)})();for(let u of l.slice(1))f=this.getAttr(f,u,e);return f}return G}findMatchingBracket(t,e){let r=e==="["?"]":e==="("?")":"}",s=0;for(let i=t.length-1;i>=0;i--)if(t[i]===r&&s++,t[i]===e&&(s--,s===0))return i;return-1}findDotAccess(t){let e=0,r=!1,s="";for(let i=t.length-1;i>0;i--){let o=t[i];if(r){o===s&&t[i-1]!=="\\"&&(r=!1);continue}if(o==='"'||o==="'"){r=!0,s=o;continue}if(")]}".includes(o)){e++;continue}if("([{".includes(o)){e--;continue}if(e!==0||o!==".")continue;let a=t.slice(0,i).trim(),l=t.slice(i+1).match(/^(\w+)(\([\s\S]*\))?$/);if(l&&!/^-?\d+$/.test(a))return{objExpr:a,attr:l[1],callPart:l[2]}}return null}tryBinaryOp(t,e,r){let s=0,i=!1,o="";for(let a=t.length-1;a>=0;a--){let c=t[a];if(i){c===o&&t[a-1]!=="\\"&&(i=!1);continue}if(c==='"'||c==="'"){i=!0,o=c;continue}if(")]}".includes(c)){s++;continue}if("([{".includes(c)){s--;continue}if(s===0){for(let l of e)if(t.slice(a,a+l.length)===l){if(l==="*"&&(t[a+1]==="*"||t[a-1]==="*"))continue;let f=t[a-1],u=t[a+l.length];if(/^[a-z]/.test(l)&&(f&&/\w/.test(f)||u&&/\w/.test(u)))continue;let p=t.slice(0,a).trim(),y=t.slice(a+l.length).trim();if(!p||!y)continue;return this.applyBinaryOp(l,p,y,r)}}}}applyBinaryOp(t,e,r,s){if(t==="and"){let a=this.pyEval(e,s);return fn(a)?this.pyEval(r,s):a}if(t==="or"){let a=this.pyEval(e,s);return fn(a)?a:this.pyEval(r,s)}let i=this.pyEval(e,s),o=this.pyEval(r,s);switch(t){case"+":return typeof i=="string"&&typeof o=="string"?i+o:Array.isArray(i)&&Array.isArray(o)?[...i,...o]:i+o;case"-":return i-o;case"*":if(typeof i=="string"&&typeof o=="number")return i.repeat(o);if(Array.isArray(i)&&typeof o=="number"){let a=[];for(let c=0;c<o;c++)a.push(...i);return a}return i*o;case"/":{if(o===0)throw new yt("ZeroDivisionError","division by zero");return i/o}case"//":{if(o===0)throw new yt("ZeroDivisionError","integer division or modulo by zero");return Math.floor(i/o)}case"%":{if(typeof i=="string")return this.pyStringFormat(i,Array.isArray(o)?o:[o]);if(o===0)throw new yt("ZeroDivisionError","integer division or modulo by zero");return i%o}case"**":return i**o;case"==":return Nt(i)===Nt(o)||i===o;case"!=":return Nt(i)!==Nt(o)&&i!==o;case"<":return i<o;case"<=":return i<=o;case">":return i>o;case">=":return i>=o;case"in":return this.pyIn(o,i);case"not in":return!this.pyIn(o,i);case"is":return i===o||Fn(i)&&Fn(o);case"is not":return!(i===o||Fn(i)&&Fn(o))}return G}pyIn(t,e){return typeof t=="string"?typeof e=="string"&&t.includes(e):Array.isArray(t)?t.some(r=>Nt(r)===Nt(e)):mt(t)?t.data.has(Pe(e)):!1}subscript(t,e,r){if(e.includes(":")){let i=e.split(":").map(c=>c.trim()),o=i[0]?this.pyEval(i[0],r):void 0,a=i[1]?this.pyEval(i[1],r):void 0;return typeof t=="string"||Array.isArray(t)?t.slice(o,a):G}let s=this.pyEval(e,r);if(Array.isArray(t)){let i=s;return i<0&&(i=t.length+i),t[i]??G}if(typeof t=="string"){let i=s;return i<0&&(i=t.length+i),t[i]??G}if(mt(t))return t.data.get(Pe(s))??G;throw new yt("TypeError",`'${dr(t)}' is not subscriptable`)}getAttr(t,e,r){return mt(t)?t.data.has(e)?t.data.get(e):e==="path"&&t.path?t.path:G:Li(t)?t.attrs.get(e)??G:typeof t=="string"?{__class__:{__pytype__:"class",name:"str"}}[e]??G:G}callMethod(t,e,r,s){if(typeof t=="string")switch(e){case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();case"strip":return(r[0]?t.replace(new RegExp(`[${r[0]}]+`,"g"),""):t).trim();case"lstrip":return t.trimStart();case"rstrip":return t.trimEnd();case"split":return t.split(typeof r[0]=="string"?r[0]:/\s+/).filter((i,o)=>o>0||i!=="");case"splitlines":return t.split(`
|
|
181
182
|
`);case"join":return Rt(r[0]??[]).map(Pe).join(t);case"replace":return t.replaceAll(Pe(r[0]??""),Pe(r[1]??""));case"startswith":return t.startsWith(Pe(r[0]??""));case"endswith":return t.endsWith(Pe(r[0]??""));case"find":return t.indexOf(Pe(r[0]??""));case"index":{let i=t.indexOf(Pe(r[0]??""));if(i===-1)throw new yt("ValueError","substring not found");return i}case"count":return t.split(Pe(r[0]??"")).length-1;case"format":return this.pyStringFormat(t,r);case"encode":return t;case"decode":return t;case"isdigit":return/^\d+$/.test(t);case"isalpha":return/^[a-zA-Z]+$/.test(t);case"isalnum":return/^[a-zA-Z0-9]+$/.test(t);case"isspace":return/^\s+$/.test(t);case"isupper":return t===t.toUpperCase()&&t!==t.toLowerCase();case"islower":return t===t.toLowerCase()&&t!==t.toUpperCase();case"center":{let i=r[0]??0,o=Pe(r[1]??" ");return t.padStart(Math.floor((i+t.length)/2),o).padEnd(i,o)}case"ljust":return t.padEnd(r[0]??0,Pe(r[1]??" "));case"rjust":return t.padStart(r[0]??0,Pe(r[1]??" "));case"zfill":return t.padStart(r[0]??0,"0");case"title":return t.replace(/\b\w/g,i=>i.toUpperCase());case"capitalize":return t[0]?.toUpperCase()+t.slice(1).toLowerCase();case"swapcase":return[...t].map(i=>i===i.toUpperCase()?i.toLowerCase():i.toUpperCase()).join("")}if(Array.isArray(t))switch(e){case"append":return t.push(r[0]??G),G;case"extend":for(let i of Rt(r[0]??[]))t.push(i);return G;case"insert":return t.splice(r[0]??0,0,r[1]??G),G;case"pop":{let i=r[0]!==void 0?r[0]:-1,o=i<0?t.length+i:i;return t.splice(o,1)[0]??G}case"remove":{let i=t.findIndex(o=>Nt(o)===Nt(r[0]??G));return i!==-1&&t.splice(i,1),G}case"index":{let i=t.findIndex(o=>Nt(o)===Nt(r[0]??G));if(i===-1)throw new yt("ValueError","is not in list");return i}case"count":return t.filter(i=>Nt(i)===Nt(r[0]??G)).length;case"sort":return t.sort((i,o)=>typeof i=="number"&&typeof o=="number"?i-o:Pe(i).localeCompare(Pe(o))),G;case"reverse":return t.reverse(),G;case"copy":return[...t];case"clear":return t.splice(0),G}if(mt(t))switch(e){case"keys":return[...t.data.keys()];case"values":return[...t.data.values()];case"items":return[...t.data.entries()].map(([i,o])=>[i,o]);case"get":return t.data.get(Pe(r[0]??""))??r[1]??G;case"update":{if(mt(r[0]??G))for(let[i,o]of r[0].data)t.data.set(i,o);return G}case"pop":{let i=Pe(r[0]??""),o=t.data.get(i)??r[1]??G;return t.data.delete(i),o}case"clear":return t.data.clear(),G;case"copy":return _t([...t.data.entries()]);case"setdefault":{let i=Pe(r[0]??"");return t.data.has(i)||t.data.set(i,r[1]??G),t.data.get(i)??G}}if(mt(t)&&t.data.has("name")&&t.data.get("name")==="posix")switch(e){case"getcwd":return this.cwd;case"getenv":return typeof r[0]=="string"?process.env[r[0]]??r[1]??G:G;case"listdir":return[];case"path":return t}if(mt(t))switch(e){case"join":return r.map(Pe).join("/").replace(/\/+/g,"/");case"exists":return!1;case"dirname":return Pe(r[0]??"").split("/").slice(0,-1).join("/")||"/";case"basename":return Pe(r[0]??"").split("/").pop()??"";case"abspath":return Pe(r[0]??"");case"splitext":{let i=Pe(r[0]??""),o=i.lastIndexOf(".");return o>0?[i.slice(0,o),i.slice(o)]:[i,""]}case"isfile":return!1;case"isdir":return!1}if(mt(t)&&t.data.has("version")&&t.data.get("version")===Ys&&e==="exit")throw new Ui(r[0]??0);if(mt(t)){let i={sqrt:Math.sqrt,floor:Math.floor,ceil:Math.ceil,fabs:Math.abs,log:Math.log,log2:Math.log2,log10:Math.log10,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,pow:Math.pow,exp:Math.exp,hypot:Math.hypot};if(e in i){let o=i[e];return o(...r.map(a=>a))}if(e==="factorial"){let o=r[0]??0,a=1;for(;o>1;)a*=o--;return a}if(e==="gcd"){let o=Math.abs(r[0]??0),a=Math.abs(r[1]??0);for(;a;)[o,a]=[a,o%a];return o}}if(mt(t)){if(e==="dumps"){let i=mt(r[1]??G)?r[1]:void 0,o=i?i.data.get("indent"):void 0;return JSON.stringify(this.pyToJs(r[0]??G),null,o)}if(e==="loads")return this.jsToPy(JSON.parse(Pe(r[0]??"")))}if(Li(t)){let i=t.attrs.get(e)??t.cls.methods.get(e)??G;if(Bn(i)){let o=new Map(i.closure);return o.set("self",t),i.params.slice(1).forEach((a,c)=>o.set(a,r[c]??G)),this.execBlock(i.body,o)}}throw new yt("AttributeError",`'${dr(t)}' object has no attribute '${e}'`)}pyStringFormat(t,e){let r=0;return t.replace(/%([diouxXeEfFgGcrs%])/g,(s,i)=>{if(i==="%")return"%";let o=e[r++];switch(i){case"d":case"i":return String(Math.trunc(o));case"f":return o.toFixed(6);case"s":return Pe(o??G);case"r":return Nt(o??G);default:return String(o)}})}pyToJs(t){return Fn(t)?null:mt(t)?Object.fromEntries([...t.data.entries()].map(([e,r])=>[e,this.pyToJs(r)])):Array.isArray(t)?t.map(e=>this.pyToJs(e)):t}jsToPy(t){return t==null?G:typeof t=="boolean"||typeof t=="number"||typeof t=="string"?t:Array.isArray(t)?t.map(e=>this.jsToPy(e)):typeof t=="object"?_t(Object.entries(t).map(([e,r])=>[e,this.jsToPy(r)])):G}callBuiltin(t,e,r){if(r.has(t)){let s=r.get(t)??G;return Bn(s)?this.callFunc(s,e,r):oc(s)?this.instantiate(s,e,r):s}switch(t){case"print":return this.output.push(e.map(Pe).join(" ")+`
|
|
182
183
|
`.replace(/\\n/g,"")),G;case"input":return this.output.push(Pe(e[0]??"")),"";case"int":{if(e.length===0)return 0;let s=e[1]??10,i=parseInt(Pe(e[0]??0),s);return Number.isNaN(i)?(()=>{throw new yt("ValueError","invalid literal for int()")})():i}case"float":{if(e.length===0)return 0;let s=parseFloat(Pe(e[0]??0));return Number.isNaN(s)?(()=>{throw new yt("ValueError","could not convert to float")})():s}case"str":return e.length===0?"":Pe(e[0]??G);case"bool":return e.length===0?!1:fn(e[0]??G);case"list":return e.length===0?[]:Rt(e[0]??[]);case"tuple":return e.length===0?[]:Rt(e[0]??[]);case"set":return e.length===0?[]:[...new Set(Rt(e[0]??[]).map(Nt))].map(s=>Rt(e[0]??[]).find(o=>Nt(o)===s)??G);case"dict":return e.length===0?_t():mt(e[0]??G)?e[0]:_t();case"bytes":return typeof e[0]=="string"?e[0]:Pe(e[0]??"");case"bytearray":return e.length===0?"":Pe(e[0]??"");case"type":return e.length===1?`<class '${dr(e[0]??G)}'>`:G;case"isinstance":return dr(e[0]??G)===Pe(e[1]??"");case"issubclass":return!1;case"callable":return Bn(e[0]??G);case"hasattr":return mt(e[0]??G)?e[0].data.has(Pe(e[1]??"")):!1;case"getattr":return mt(e[0]??G)?e[0].data.get(Pe(e[1]??""))??e[2]??G:e[2]??G;case"setattr":return mt(e[0]??G)&&e[0].data.set(Pe(e[1]??""),e[2]??G),G;case"len":{let s=e[0]??G;if(typeof s=="string"||Array.isArray(s))return s.length;if(mt(s))return s.data.size;if(Gr(s))return kd(s);throw new yt("TypeError",`object of type '${dr(s)}' has no len()`)}case"range":return e.length===1?sc(0,e[0]):e.length===2?sc(e[0],e[1]):sc(e[0],e[1],e[2]);case"enumerate":{let s=e[1]??0;return Rt(e[0]??[]).map((i,o)=>[o+s,i])}case"zip":{let s=e.map(Rt),i=Math.min(...s.map(o=>o.length));return Array.from({length:i},(o,a)=>s.map(c=>c[a]??G))}case"map":{let s=e[0]??G;return Rt(e[1]??[]).map(i=>Bn(s)?this.callFunc(s,[i],r):G)}case"filter":{let s=e[0]??G;return Rt(e[1]??[]).filter(i=>Bn(s)?fn(this.callFunc(s,[i],r)):fn(i))}case"reduce":{let s=e[0]??G,i=Rt(e[1]??[]);if(i.length===0)return e[2]??G;let o=e[2]!==void 0?e[2]:i[0];for(let a of e[2]!==void 0?i:i.slice(1))o=Bn(s)?this.callFunc(s,[o,a],r):G;return o}case"sorted":{let s=[...Rt(e[0]??[])],i=e[1]??G,o=mt(i)?i.data.get("key")??G:i;return s.sort((a,c)=>{let l=Bn(o)?this.callFunc(o,[a],r):a,f=Bn(o)?this.callFunc(o,[c],r):c;return typeof l=="number"&&typeof f=="number"?l-f:Pe(l).localeCompare(Pe(f))}),s}case"reversed":return[...Rt(e[0]??[])].reverse();case"any":return Rt(e[0]??[]).some(fn);case"all":return Rt(e[0]??[]).every(fn);case"sum":return Rt(e[0]??[]).reduce((s,i)=>s+i,e[1]??0);case"max":return(e.length===1?Rt(e[0]??[]):e).reduce((i,o)=>i>=o?i:o);case"min":return(e.length===1?Rt(e[0]??[]):e).reduce((i,o)=>i<=o?i:o);case"abs":return Math.abs(e[0]??0);case"round":return e[1]!==void 0?parseFloat(e[0].toFixed(e[1])):Math.round(e[0]??0);case"divmod":{let s=e[0],i=e[1];return[Math.floor(s/i),s%i]}case"pow":return e[0]**e[1];case"hex":return`0x${e[0].toString(16)}`;case"oct":return`0o${e[0].toString(8)}`;case"bin":return`0b${e[0].toString(2)}`;case"ord":return Pe(e[0]??"").charCodeAt(0);case"chr":return String.fromCharCode(e[0]??0);case"id":return Math.floor(Math.random()*4294967295);case"hash":return typeof e[0]=="number"?e[0]:Pe(e[0]??"").split("").reduce((s,i)=>s*31+i.charCodeAt(0)|0,0);case"open":throw new yt("PermissionError","open() not available in virtual runtime");case"repr":return Nt(e[0]??G);case"iter":return e[0]??G;case"next":return Array.isArray(e[0])&&e[0].length>0?e[0].shift():e[1]??(()=>{throw new yt("StopIteration","")})();case"vars":return _t([...r.entries()].map(([s,i])=>[s,i]));case"globals":return _t([...r.entries()].map(([s,i])=>[s,i]));case"locals":return _t([...r.entries()].map(([s,i])=>[s,i]));case"dir":{if(e.length===0)return[...r.keys()];let s=e[0]??G;return typeof s=="string"?["upper","lower","strip","split","join","replace","find","format","encode","startswith","endswith","count","isdigit","isalpha","title","capitalize"]:Array.isArray(s)?["append","extend","insert","pop","remove","index","count","sort","reverse","copy","clear"]:mt(s)?["keys","values","items","get","update","pop","clear","copy","setdefault"]:[]}case"Exception":case"ValueError":case"TypeError":case"KeyError":case"IndexError":case"AttributeError":case"NameError":case"RuntimeError":case"StopIteration":case"NotImplementedError":case"OSError":case"IOError":throw new yt(t,Pe(e[0]??""));case"exec":return this.execScript(Pe(e[0]??""),r),G;case"eval":return this.pyEval(Pe(e[0]??""),r);default:throw new yt("NameError",`name '${t}' is not defined`)}}callFunc(t,e,r){let s=new Map(t.closure);t.params.forEach((i,o)=>{if(i.startsWith("*")){s.set(i.slice(1),e.slice(o));return}s.set(i,e[o]??G)});try{return this.execBlock(t.body,s)}catch(i){if(i instanceof Vr)return i.value;throw i}}instantiate(t,e,r){let s={__pytype__:"instance",cls:t,attrs:new Map};return t.methods.get("__init__")&&this.callMethod(s,"__init__",e,r),s}execScript(t,e){let r=t.split(`
|
|
183
|
-
`);this.execLines(r,0,e)}execLines(t,e,r){let s=e;for(;s<t.length;){let i=t[s];if(!i.trim()||i.trim().startsWith("#")){s++;continue}s=this.execStatement(t,s,r)}return s}execBlock(t,e){try{this.execLines(t,0,e)}catch(r){if(r instanceof Vr)return r.value;throw r}return G}getIndent(t){let e=0;for(let r of t)if(r===" ")e++;else if(r===" ")e+=4;else break;return e}collectBlock(t,e,r){let s=[];for(let i=e;i<t.length;i++){let o=t[i];if(!o.trim()){s.push("");continue}if(this.getIndent(o)<=r)break;s.push(o.slice(r+4))}return s}execStatement(t,e,r){let s=t[e],i=s.trim(),o=this.getIndent(s);if(i==="pass")return e+1;if(i==="break")throw new $i;if(i==="continue")throw new Di;let a=i.match(/^return(?:\s+(.+))?$/);if(a)throw new Vr(a[1]?this.pyEval(a[1],r):G);let c=i.match(/^raise(?:\s+(.+))?$/);if(c){if(c[1]){let B=this.pyEval(c[1],r);throw new yt(typeof B=="string"?B:dr(B),Pe(B))}throw new yt("RuntimeError","")}let l=i.match(/^assert\s+(.+?)(?:,\s*(.+))?$/);if(l){if(!fn(this.pyEval(l[1],r)))throw new yt("AssertionError",l[2]?Pe(this.pyEval(l[2],r)):"");return e+1}let f=i.match(/^del\s+(.+)$/);if(f)return r.delete(f[1].trim()),e+1;let u=i.match(/^import\s+(\w+)(?:\s+as\s+(\w+))?$/);if(u){let[,B,b]=u,w=Cd[B];if(w){let k=w(this.cwd);this.modules.set(B,k),r.set(b??B,k)}return e+1}let h=i.match(/^from\s+(\w+)\s+import\s+(.+)$/);if(h){let[,B,b]=h,w=Cd[B];if(w){let k=w(this.cwd);if(b?.trim()==="*")for(let[v,P]of k.data)r.set(v,P);else for(let v of b.split(",").map(P=>P.trim()))r.set(v,k.data.get(v)??G)}return e+1}let p=i.match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(p){let[,B,b]=p,w=b.split(",").map(P=>P.trim()).filter(Boolean),k=this.collectBlock(t,e+1,o),v={__pytype__:"func",name:B,params:w,body:k,closure:new Map(r)};return r.set(B,v),e+1+k.length}let y=i.match(/^class\s+(\w+)(?:\(([^)]*)\))?\s*:$/);if(y){let[,B,b]=y,w=b?b.split(",").map(ne=>ne.trim()):[],k=this.collectBlock(t,e+1,o),v={__pytype__:"class",name:B,methods:new Map,bases:w},P=0;for(;P<k.length;){let z=k[P].trim().match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(z){let[,Y,te]=z,le=te.split(",").map(N=>N.trim()).filter(Boolean),O=this.collectBlock(k,P+1,0);v.methods.set(Y,{__pytype__:"func",name:Y,params:le,body:O,closure:new Map(r)}),P+=1+O.length}else P++}return r.set(B,v),e+1+k.length}if(i.startsWith("if ")&&i.endsWith(":")){let B=i.slice(3,-1).trim(),b=this.collectBlock(t,e+1,o),w=b.length+1;if(fn(this.pyEval(B,r))){this.execBlock(b,new Map(r).also?.(P=>{for(let[ne,z]of r)P.set(ne,z)})??r),this.runBlockInScope(b,r);let v=e+1+b.length;for(;v<t.length;){let P=t[v].trim();if(this.getIndent(t[v])<o||!P.startsWith("elif")&&!P.startsWith("else"))break;let ne=this.collectBlock(t,v+1,o);v+=1+ne.length}return v}let k=e+1+b.length;for(;k<t.length;){let v=t[k],P=v.trim();if(this.getIndent(v)!==o)break;let ne=P.match(/^elif\s+(.+):$/);if(ne){let z=this.collectBlock(t,k+1,o);if(fn(this.pyEval(ne[1],r))){for(this.runBlockInScope(z,r),k+=1+z.length;k<t.length;){let Y=t[k].trim();if(this.getIndent(t[k])!==o||!Y.startsWith("elif")&&!Y.startsWith("else"))break;let te=this.collectBlock(t,k+1,o);k+=1+te.length}return k}k+=1+z.length;continue}if(P==="else:"){let z=this.collectBlock(t,k+1,o);return this.runBlockInScope(z,r),k+1+z.length}break}return k}let _=i.match(/^for\s+(.+?)\s+in\s+(.+?)\s*:$/);if(_){let[,B,b]=_,w=Rt(this.pyEval(b.trim(),r)),k=this.collectBlock(t,e+1,o),v=[],P=e+1+k.length;P<t.length&&t[P]?.trim()==="else:"&&(v=this.collectBlock(t,P+1,o),P+=1+v.length);let ne=!1;for(let z of w){if(B.includes(",")){let Y=B.split(",").map(le=>le.trim()),te=Array.isArray(z)?z:[z];Y.forEach((le,O)=>r.set(le,te[O]??G))}else r.set(B.trim(),z);try{this.runBlockInScope(k,r)}catch(Y){if(Y instanceof $i){ne=!0;break}if(Y instanceof Di)continue;throw Y}}return!ne&&v.length&&this.runBlockInScope(v,r),P}let x=i.match(/^while\s+(.+?)\s*:$/);if(x){let B=x[1],b=this.collectBlock(t,e+1,o),w=0;for(;fn(this.pyEval(B,r))&&w++<1e5;)try{this.runBlockInScope(b,r)}catch(k){if(k instanceof $i)break;if(k instanceof Di)continue;throw k}return e+1+b.length}if(i==="try:"){let B=this.collectBlock(t,e+1,o),b=e+1+B.length,w=[],k=[],v=[];for(;b<t.length;){let ne=t[b],z=ne.trim();if(this.getIndent(ne)!==o)break;if(z.startsWith("except")){let Y=z.match(/^except(?:\s+(\w+)(?:\s+as\s+(\w+))?)?\s*:$/),te=Y?.[1]??null,le=Y?.[2],O=this.collectBlock(t,b+1,o);w.push({exc:te,body:O}),le&&r.set(le,""),b+=1+O.length}else if(z==="else:")v=this.collectBlock(t,b+1,o),b+=1+v.length;else if(z==="finally:")k=this.collectBlock(t,b+1,o),b+=1+k.length;else break}let P=null;try{this.runBlockInScope(B,r),v.length&&this.runBlockInScope(v,r)}catch(ne){if(ne instanceof yt){P=ne;let z=!1;for(let Y of w)if(Y.exc===null||Y.exc===ne.type||Y.exc==="Exception"){this.runBlockInScope(Y.body,r),z=!0;break}if(!z)throw ne}else throw ne}finally{k.length&&this.runBlockInScope(k,r)}return b}let S=i.match(/^with\s+(.+?)\s+as\s+(\w+)\s*:$/);if(S){let B=this.collectBlock(t,e+1,o);return r.set(S[2],G),this.runBlockInScope(B,r),e+1+B.length}let R=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(\+=|-=|\*=|\/\/=|\/=|%=|\*\*=|&=|\|=)\s*(.+)$/);if(R){let[,B,b,w]=R,k=r.get(B)??0,v=this.pyEval(w,r),P;switch(b){case"+=":P=typeof k=="string"?k+Pe(v):k+v;break;case"-=":P=k-v;break;case"*=":P=k*v;break;case"/=":P=k/v;break;case"//=":P=Math.floor(k/v);break;case"%=":P=k%v;break;case"**=":P=k**v;break;default:P=v}return r.set(B,P),e+1}let H=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\[(.+)\]\s*=\s*(.+)$/);if(H){let[,B,b,w]=H,k=r.get(B)??G,v=this.pyEval(w,r)??G,P=this.pyEval(b,r)??G;return Array.isArray(k)?k[P]=v:mt(k)&&k.data.set(Pe(P),v),e+1}let C=i.match(/^([A-Za-z_][A-Za-z0-9_.]+)\s*=\s*(.+)$/);if(C){let B=C[1].lastIndexOf(".");if(B!==-1){let b=C[1].slice(0,B),w=C[1].slice(B+1),k=this.pyEval(C[2],r),v=this.pyEval(b,r);return mt(v)?v.data.set(w,k):Li(v)&&v.attrs.set(w,k),e+1}}let U=i.match(/^([A-Za-z_][A-Za-z0-9_,\s]*),\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.+)$/);if(U){let B=this.pyEval(U[3],r),b=i.split("=")[0].split(",").map(k=>k.trim()),w=Rt(B);return b.forEach((k,v)=>r.set(k,w[v]??G)),e+1}let Q=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?::[^=]+)?\s*=\s*(.+)$/);if(Q){let[,B,b]=Q;return r.set(B,this.pyEval(b,r)),e+1}try{this.pyEval(i,r)}catch(B){if(B instanceof yt||B instanceof Ui)throw B}return e+1}runBlockInScope(t,e){this.execLines(t,0,e)}run(t){let e=
|
|
184
|
+
`);this.execLines(r,0,e)}execLines(t,e,r){let s=e;for(;s<t.length;){let i=t[s];if(!i.trim()||i.trim().startsWith("#")){s++;continue}s=this.execStatement(t,s,r)}return s}execBlock(t,e){try{this.execLines(t,0,e)}catch(r){if(r instanceof Vr)return r.value;throw r}return G}getIndent(t){let e=0;for(let r of t)if(r===" ")e++;else if(r===" ")e+=4;else break;return e}collectBlock(t,e,r){let s=[];for(let i=e;i<t.length;i++){let o=t[i];if(!o.trim()){s.push("");continue}if(this.getIndent(o)<=r)break;s.push(o.slice(r+4))}return s}execStatement(t,e,r){let s=t[e],i=s.trim(),o=this.getIndent(s);if(i==="pass")return e+1;if(i==="break")throw new $i;if(i==="continue")throw new Di;let a=i.match(/^return(?:\s+(.+))?$/);if(a)throw new Vr(a[1]?this.pyEval(a[1],r):G);let c=i.match(/^raise(?:\s+(.+))?$/);if(c){if(c[1]){let B=this.pyEval(c[1],r);throw new yt(typeof B=="string"?B:dr(B),Pe(B))}throw new yt("RuntimeError","")}let l=i.match(/^assert\s+(.+?)(?:,\s*(.+))?$/);if(l){if(!fn(this.pyEval(l[1],r)))throw new yt("AssertionError",l[2]?Pe(this.pyEval(l[2],r)):"");return e+1}let f=i.match(/^del\s+(.+)$/);if(f)return r.delete(f[1].trim()),e+1;let u=i.match(/^import\s+(\w+)(?:\s+as\s+(\w+))?$/);if(u){let[,B,b]=u,w=Cd[B];if(w){let k=w(this.cwd);this.modules.set(B,k),r.set(b??B,k)}return e+1}let h=i.match(/^from\s+(\w+)\s+import\s+(.+)$/);if(h){let[,B,b]=h,w=Cd[B];if(w){let k=w(this.cwd);if(b?.trim()==="*")for(let[v,P]of k.data)r.set(v,P);else for(let v of b.split(",").map(P=>P.trim()))r.set(v,k.data.get(v)??G)}return e+1}let p=i.match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(p){let[,B,b]=p,w=b.split(",").map(P=>P.trim()).filter(Boolean),k=this.collectBlock(t,e+1,o),v={__pytype__:"func",name:B,params:w,body:k,closure:new Map(r)};return r.set(B,v),e+1+k.length}let y=i.match(/^class\s+(\w+)(?:\(([^)]*)\))?\s*:$/);if(y){let[,B,b]=y,w=b?b.split(",").map(ne=>ne.trim()):[],k=this.collectBlock(t,e+1,o),v={__pytype__:"class",name:B,methods:new Map,bases:w},P=0;for(;P<k.length;){let z=k[P].trim().match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(z){let[,Y,te]=z,le=te.split(",").map(N=>N.trim()).filter(Boolean),O=this.collectBlock(k,P+1,0);v.methods.set(Y,{__pytype__:"func",name:Y,params:le,body:O,closure:new Map(r)}),P+=1+O.length}else P++}return r.set(B,v),e+1+k.length}if(i.startsWith("if ")&&i.endsWith(":")){let B=i.slice(3,-1).trim(),b=this.collectBlock(t,e+1,o),w=b.length+1;if(fn(this.pyEval(B,r))){this.execBlock(b,new Map(r).also?.(P=>{for(let[ne,z]of r)P.set(ne,z)})??r),this.runBlockInScope(b,r);let v=e+1+b.length;for(;v<t.length;){let P=t[v].trim();if(this.getIndent(t[v])<o||!P.startsWith("elif")&&!P.startsWith("else"))break;let ne=this.collectBlock(t,v+1,o);v+=1+ne.length}return v}let k=e+1+b.length;for(;k<t.length;){let v=t[k],P=v.trim();if(this.getIndent(v)!==o)break;let ne=P.match(/^elif\s+(.+):$/);if(ne){let z=this.collectBlock(t,k+1,o);if(fn(this.pyEval(ne[1],r))){for(this.runBlockInScope(z,r),k+=1+z.length;k<t.length;){let Y=t[k].trim();if(this.getIndent(t[k])!==o||!Y.startsWith("elif")&&!Y.startsWith("else"))break;let te=this.collectBlock(t,k+1,o);k+=1+te.length}return k}k+=1+z.length;continue}if(P==="else:"){let z=this.collectBlock(t,k+1,o);return this.runBlockInScope(z,r),k+1+z.length}break}return k}let _=i.match(/^for\s+(.+?)\s+in\s+(.+?)\s*:$/);if(_){let[,B,b]=_,w=Rt(this.pyEval(b.trim(),r)),k=this.collectBlock(t,e+1,o),v=[],P=e+1+k.length;P<t.length&&t[P]?.trim()==="else:"&&(v=this.collectBlock(t,P+1,o),P+=1+v.length);let ne=!1;for(let z of w){if(B.includes(",")){let Y=B.split(",").map(le=>le.trim()),te=Array.isArray(z)?z:[z];Y.forEach((le,O)=>r.set(le,te[O]??G))}else r.set(B.trim(),z);try{this.runBlockInScope(k,r)}catch(Y){if(Y instanceof $i){ne=!0;break}if(Y instanceof Di)continue;throw Y}}return!ne&&v.length&&this.runBlockInScope(v,r),P}let x=i.match(/^while\s+(.+?)\s*:$/);if(x){let B=x[1],b=this.collectBlock(t,e+1,o),w=0;for(;fn(this.pyEval(B,r))&&w++<1e5;)try{this.runBlockInScope(b,r)}catch(k){if(k instanceof $i)break;if(k instanceof Di)continue;throw k}return e+1+b.length}if(i==="try:"){let B=this.collectBlock(t,e+1,o),b=e+1+B.length,w=[],k=[],v=[];for(;b<t.length;){let ne=t[b],z=ne.trim();if(this.getIndent(ne)!==o)break;if(z.startsWith("except")){let Y=z.match(/^except(?:\s+(\w+)(?:\s+as\s+(\w+))?)?\s*:$/),te=Y?.[1]??null,le=Y?.[2],O=this.collectBlock(t,b+1,o);w.push({exc:te,body:O}),le&&r.set(le,""),b+=1+O.length}else if(z==="else:")v=this.collectBlock(t,b+1,o),b+=1+v.length;else if(z==="finally:")k=this.collectBlock(t,b+1,o),b+=1+k.length;else break}let P=null;try{this.runBlockInScope(B,r),v.length&&this.runBlockInScope(v,r)}catch(ne){if(ne instanceof yt){P=ne;let z=!1;for(let Y of w)if(Y.exc===null||Y.exc===ne.type||Y.exc==="Exception"){this.runBlockInScope(Y.body,r),z=!0;break}if(!z)throw ne}else throw ne}finally{k.length&&this.runBlockInScope(k,r)}return b}let S=i.match(/^with\s+(.+?)\s+as\s+(\w+)\s*:$/);if(S){let B=this.collectBlock(t,e+1,o);return r.set(S[2],G),this.runBlockInScope(B,r),e+1+B.length}let R=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(\+=|-=|\*=|\/\/=|\/=|%=|\*\*=|&=|\|=)\s*(.+)$/);if(R){let[,B,b,w]=R,k=r.get(B)??0,v=this.pyEval(w,r),P;switch(b){case"+=":P=typeof k=="string"?k+Pe(v):k+v;break;case"-=":P=k-v;break;case"*=":P=k*v;break;case"/=":P=k/v;break;case"//=":P=Math.floor(k/v);break;case"%=":P=k%v;break;case"**=":P=k**v;break;default:P=v}return r.set(B,P),e+1}let H=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\[(.+)\]\s*=\s*(.+)$/);if(H){let[,B,b,w]=H,k=r.get(B)??G,v=this.pyEval(w,r)??G,P=this.pyEval(b,r)??G;return Array.isArray(k)?k[P]=v:mt(k)&&k.data.set(Pe(P),v),e+1}let C=i.match(/^([A-Za-z_][A-Za-z0-9_.]+)\s*=\s*(.+)$/);if(C){let B=C[1].lastIndexOf(".");if(B!==-1){let b=C[1].slice(0,B),w=C[1].slice(B+1),k=this.pyEval(C[2],r),v=this.pyEval(b,r);return mt(v)?v.data.set(w,k):Li(v)&&v.attrs.set(w,k),e+1}}let U=i.match(/^([A-Za-z_][A-Za-z0-9_,\s]*),\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.+)$/);if(U){let B=this.pyEval(U[3],r),b=i.split("=")[0].split(",").map(k=>k.trim()),w=Rt(B);return b.forEach((k,v)=>r.set(k,w[v]??G)),e+1}let Q=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?::[^=]+)?\s*=\s*(.+)$/);if(Q){let[,B,b]=Q;return r.set(B,this.pyEval(b,r)),e+1}try{this.pyEval(i,r)}catch(B){if(B instanceof yt||B instanceof Ui)throw B}return e+1}runBlockInScope(t,e){this.execLines(t,0,e)}run(t){let e=GA(this.cwd);try{this.execScript(t,e)}catch(r){return r instanceof Ui?{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:r.code}:r instanceof yt?(this.stderr.push(r.toString()),{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:1}):r instanceof Vr?{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:0}:(this.stderr.push(`RuntimeError: ${r}`),{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:1})}return{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:0}}},vd={name:"python3",aliases:["python"],description:"Python 3 interpreter (virtual)",category:"system",params:["[--version] [-c <code>] [-V] [file]"],run:({args:n,shell:t,cwd:e})=>{if(!t.packageManager.isInstalled("python3"))return{stderr:`bash: python3: command not found
|
|
184
185
|
Hint: install it with: apt install python3
|
|
185
|
-
`,exitCode:127};if(se(n,["--version","-V"]))return{stdout:`${
|
|
186
|
+
`,exitCode:127};if(se(n,["--version","-V"]))return{stdout:`${KA}
|
|
186
187
|
`,exitCode:0};if(se(n,["--version-full"]))return{stdout:`${Ys}
|
|
187
188
|
`,exitCode:0};let r=n.indexOf("-c");if(r!==-1){let i=n[r+1];if(!i)return{stderr:`python3: -c requires a code argument
|
|
188
189
|
`,exitCode:1};let o=i.replace(/\\n/g,`
|
|
@@ -192,7 +193,7 @@ Type "help", "copyright", "credits" or "license" for more information.
|
|
|
192
193
|
>>> `,exitCode:0}}};var Bd={name:"read",description:"Read a line from stdin into variables",category:"shell",params:["[-r] [-p prompt] <var...>"],run:({args:n,stdin:t,env:e})=>{let r=n.indexOf("-p"),s=n.filter((a,c)=>a!=="-r"&&a!=="-p"&&n[c-1]!=="-p"),i=(t??"").split(`
|
|
193
194
|
`)[0]??"",o=se(n,["-r"])?i:i.replace(/\\(?:\r?\n|.)/g,a=>a[1]===`
|
|
194
195
|
`||a[1]==="\r"?"":a[1]);if(!e)return{exitCode:0};if(s.length===0)e.vars.REPLY=o;else if(s.length===1)e.vars[s[0]]=o;else{let a=o.split(/\s+/);for(let c=0;c<s.length;c++)e.vars[s[c]]=c<s.length-1?a[c]??"":a.slice(c).join(" ")}return{exitCode:0}}};var Rd={name:"rm",description:"Remove files or directories",category:"files",params:["[-r|-rf] <path>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"rm: missing operand",exitCode:1};let s=se(r,["-r","-rf","-fr"]),i=[];for(let o=0;;o+=1){let a=Zn(r,o,{flags:["-r","-rf","-fr"]});if(!a)break;i.push(a)}if(i.length===0)return{stderr:"rm: missing operand",exitCode:1};for(let o of i){let a=de(e,o);Me(n,a,"rm"),t.vfs.remove(a,{recursive:s})}return{exitCode:0}}};var Nd={name:"sed",description:"Stream editor for filtering and transforming text",category:"text",params:["-e <expr> [file]","s/pattern/replace/[g]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-i"]),o=nn(r,["-e"])??r.find(x=>!x.startsWith("-")),a=r.filter(x=>!x.startsWith("-")&&x!==o).pop();if(!o)return{stderr:"sed: no expression",exitCode:1};let c=s??"";if(a){let x=de(e,a);try{c=t.vfs.readFile(x)}catch{return{stderr:`sed: ${a}: No such file or directory`,exitCode:1}}}let l=o.match(/^s([^a-zA-Z0-9])(.+?)\1(.*?)\1([gi]*)$/);if(!l)return{stderr:`sed: unrecognized command: ${o}`,exitCode:1};let[,,f,u,h]=l,p=(h??"").includes("i")?"gi":(h??"").includes("g")?"g":"",y;try{y=new RegExp(f,p||"")}catch{return{stderr:`sed: invalid regex: ${f}`,exitCode:1}}let _=((h??"").includes("g")||p.includes("g"),c.replace(y,u??""));if(i&&a){let x=de(e,a);return t.writeFileAsUser(n,x,_),{exitCode:0}}return{stdout:_,exitCode:0}}};var Pd={name:"set",description:"Display or set shell variables",category:"shell",params:["[VAR=value]"],run:({args:n,env:t})=>{if(n.length===0)return{stdout:Object.entries(t.vars).map(([r,s])=>`${r}=${s}`).join(`
|
|
195
|
-
`),exitCode:0};for(let e of n)if(e.includes("=")){let r=e.indexOf("=");t.vars[e.slice(0,r)]=e.slice(r+1)}return{exitCode:0}}};async function Td(n,t,e,r,s,i,o){let a={exitCode:0},c=[],l=s,f=0;for(;f<n.length;){let h=n[f];if(a=await ey(h.pipeline,t,e,r,l,i,o),o.lastExitCode=a.exitCode??0,a.nextCwd&&(a.exitCode??0)===0&&(l=a.nextCwd),a.stdout&&c.push(a.stdout),a.closeSession||a.switchUser)return{...a,stdout:c.join("")||a.stdout};let p=h.op;if(!(!p||p===";")){if(p==="&&"){if((a.exitCode??0)!==0)for(;f<n.length&&n[f]?.op==="&&";)f++}else if(p==="||"&&(a.exitCode??0)===0)for(;f<n.length&&n[f]?.op==="||";)f++}f++}let u=c.join("");return{...a,stdout:u||a.stdout,nextCwd:l!==s?l:void 0}}async function ey(n,t,e,r,s,i,o){if(!n.isValid)return{stderr:n.error||"Syntax error",exitCode:1};if(n.commands.length===0)return{exitCode:0};let a=o??{vars:{},lastExitCode:0};return n.commands.length===1?ty(n.commands[0],t,e,r,s,i,a):ny(n.commands,t,e,r,s,i,a)}async function ty(n,t,e,r,s,i,o){let a;if(n.inputFile){let l=de(s,n.inputFile);try{a=i.vfs.readFile(l)}catch{return{stderr:`${n.inputFile}: No such file or directory`,exitCode:1}}}let c=await Yr(n.name,n.args,t,e,r,s,i,a,o);if(n.outputFile){let l=de(s,n.outputFile),f=c.stdout||"";try{if(n.appendOutput){let u=(()=>{try{return i.vfs.readFile(l)}catch{return""}})();i.writeFileAsUser(t,l,u+f)}else i.writeFileAsUser(t,l,f);return{...c,stdout:""}}catch{return{...c,stderr:`Failed to write to ${n.outputFile}`,exitCode:1}}}return c}async function ny(n,t,e,r,s,i,o){let a="",c=0;for(let l=0;l<n.length;l++){let f=n[l];if(l===0&&f.inputFile){let h=de(s,f.inputFile);try{a=i.vfs.readFile(h)}catch{return{stderr:`${f.inputFile}: No such file or directory`,exitCode:1}}}let u=await Yr(f.name,f.args,t,e,r,s,i,a,o);if(c=u.exitCode??0,l===n.length-1&&f.outputFile){let h=de(s,f.outputFile),p=u.stdout||"";try{if(f.appendOutput){let y=(()=>{try{return i.vfs.readFile(h)}catch{return""}})();i.writeFileAsUser(t,h,y+p)}else i.writeFileAsUser(t,h,p);a=""}catch{return{stderr:`Failed to write to ${f.outputFile}`,exitCode:1}}}else a=u.stdout||"";if(u.stderr&&c!==0)return{stderr:u.stderr,exitCode:c};if(u.closeSession||u.switchUser)return u}return{stdout:a,exitCode:c}}function Oi(n){let t=[],e="",r=!1,s="",i=0;for(;i<n.length;){let o=n[i],a=n[i+1];if((o==='"'||o==="'")&&!r){r=!0,s=o,i++;continue}if(r&&o===s){r=!1,s="",i++;continue}if(r){e+=o,i++;continue}if(o===" "){e&&(t.push(e),e=""),i++;continue}if(!r&&o==="2"&&a===">"){let c=n.slice(i+1);if(c.startsWith(">>&1")||c.startsWith(">> &1")){e&&(t.push(e),e=""),t.push("2>>&1"),i+=5;continue}if(c.startsWith(">&1")){e&&(t.push(e),e=""),t.push("2>&1"),i+=4;continue}if(c.startsWith(">>")){e&&(t.push(e),e=""),t.push("2>>"),i+=3;continue}if(c.startsWith(">")){e&&(t.push(e),e=""),t.push("2>"),i+=2;continue}}if((o===">"||o==="<")&&!r){e&&(t.push(e),e=""),o===">"&&a===">"?(t.push(">>"),i+=2):(t.push(o),i++);continue}e+=o,i++}return e&&t.push(e),t}function Ld(n){let t=n.trim();if(!t)return{statements:[],isValid:!0};try{return{statements:ry(t),isValid:!0}}catch(e){return{statements:[],isValid:!1,error:e.message}}}function ry(n){let t=iy(n),e=[];for(let r of t){let i={pipeline:{commands:sy(r.text.trim()),isValid:!0}};r.op&&(i.op=r.op),e.push(i)}return e}function iy(n){let t=[],e="",r=0,s=!1,i="",o=0,a=c=>{e.trim()&&t.push({text:e,op:c}),e=""};for(;o<n.length;){let c=n[o],l=n.slice(o,o+2);if((c==='"'||c==="'")&&!s){s=!0,i=c,e+=c,o++;continue}if(s&&c===i){s=!1,e+=c,o++;continue}if(s){e+=c,o++;continue}if(c==="("){r++,e+=c,o++;continue}if(c===")"){r--,e+=c,o++;continue}if(r>0){e+=c,o++;continue}if(l==="&&"){a("&&"),o+=2;continue}if(l==="||"){a("||"),o+=2;continue}if(c===";"){a(";"),o++;continue}e+=c,o++}return a(),t}function sy(n){return oy(n).map(ay)}function oy(n){let t=[],e="",r=!1,s="";for(let o=0;o<n.length;o++){let a=n[o];if((a==='"'||a==="'")&&!r){r=!0,s=a,e+=a;continue}if(r&&a===s){r=!1,e+=a;continue}if(r){e+=a;continue}if(a==="|"&&n[o+1]!=="|"){if(!e.trim())throw new Error("Syntax error near unexpected token '|'");t.push(e.trim()),e=""}else e+=a}let i=e.trim();if(!i&&t.length>0)throw new Error("Syntax error near unexpected token '|'");return i&&t.push(i),t}function ay(n){let t=Oi(n);if(t.length===0)return{name:"",args:[]};let e=[],r,s,i=!1,o=0,a,c=!1,l=!1;for(;o<t.length;){let h=t[o];if(h==="<"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after <");r=t[o],o++}else if(h===">>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after >>");s=t[o],i=!0,o++}else if(h===">"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after >");s=t[o],i=!1,o++}else if(h==="2>&1")l=!0,o++;else if(h==="2>>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after 2>>");a=t[o],c=!0,o++}else if(h==="2>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after 2>");a=t[o],c=!1,o++}else e.push(h),o++}let f=e[0]??"";return{name:/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.test(f)?f:f.toLowerCase(),args:e.slice(1),inputFile:r,outputFile:s,appendOutput:i,stderrFile:a,stderrAppend:c,stderrToStdout:l}}function zr(n,t){return{vars:{PATH:"/usr/local/bin:/usr/bin:/bin",HOME:`/home/${n}`,USER:n,LOGNAME:n,SHELL:"/bin/sh",TERM:"xterm-256color",HOSTNAME:t,PS1:"\\u@\\h:\\w\\$ "},lastExitCode:0}}function $d(n,t,e,r){if(n.startsWith("/")){if(!e.vfs.exists(n))return null;try{let i=e.vfs.stat(n);return i.type!=="file"||!(i.mode&73)||(n.startsWith("/sbin/")||n.startsWith("/usr/sbin/"))&&r!=="root"?null:n}catch{return null}}let s=(t.vars.PATH??"/usr/local/bin:/usr/bin:/bin").split(":");for(let i of s){if((i==="/sbin"||i==="/usr/sbin")&&r!=="root")continue;let o=`${i}/${n}`;if(e.vfs.exists(o))try{let a=e.vfs.stat(o);if(a.type!=="file"||!(a.mode&73))continue;return o}catch{}}return null}async function Yr(n,t,e,r,s,i,o,a,c){let l=/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/,f=[n,...t],u=0;for(;u<f.length&&l.test(f[u]);)u+=1;if(u>0){let y=f.slice(0,u).map(S=>S.match(l)),_=f.slice(u),x=[];for(let[,S,R]of y)x.push([S,c.vars[S]]),c.vars[S]=R;if(_.length===0)return{exitCode:0};try{return await Yr(_[0],_.slice(1),e,r,s,i,o,a,c)}finally{for(let[S,R]of x)R===void 0?delete c.vars[S]:c.vars[S]=R}}let h=c.vars[`__alias_${n}`];if(h)return St(`${h} ${t.join(" ")}`,e,r,s,i,o,a,c);let p=bn(n);if(!p){let y=$d(n,c,o,e);if(y){let _=o.vfs.readFile(y),x=_.match(/exec\s+builtin\s+(\S+)/);if(x){let R=bn(x[1]);if(R)return await R.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:[n,...t].join(" "),mode:s,args:t,stdin:a,cwd:i,shell:o,env:c})}let S=bn("sh");if(S)return await S.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:`sh -c ${JSON.stringify(_)}`,mode:s,args:["-c",_,"--",...t],stdin:a,cwd:i,shell:o,env:c})}return{stderr:`${n}: command not found`,exitCode:127}}try{return await p.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:[n,...t].join(" "),mode:s,args:t,stdin:a,cwd:i,shell:o,env:c})}catch(y){return{stderr:y instanceof Error?y.message:"Command failed",exitCode:1}}}async function St(n,t,e,r,s,i,o,a){let c=n.trim();if(c.length===0)return{exitCode:0};let l=a??zr(t,e),u=Oi(c)[0]?.toLowerCase()??"",h=l.vars[`__alias_${u}`],p=h?c.replace(u,h):c,y=/\bfor\s+\w+\s+in\b/.test(p)||/\bwhile\s+/.test(p)||/\bif\s+/.test(p)||/\w+\s*\(\s*\)\s*\{/.test(p)||/\bfunction\s+\w+/.test(p)||/\(\(\s*.+\s*\)\)/.test(p),_=/(?<![|&])[|](?![|])/.test(p)||p.includes(">")||p.includes("<")||p.includes("&&")||p.includes("||")||p.includes(";");if(y&&u!=="sh"&&u!=="bash"||_){if(y&&u!=="sh"&&u!=="bash"){let B=bn("sh");if(B)return await B.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:p,mode:r,args:["-c",p],stdin:void 0,cwd:s,shell:i,env:l})}let Q=Ld(p);if(!Q.isValid)return{stderr:Q.error||"Syntax error",exitCode:1};try{return await Td(Q.statements,t,e,r,s,i,l)}catch(B){return{stderr:B instanceof Error?B.message:"Execution failed",exitCode:1}}}let x=await Hs(p,l.vars,l.lastExitCode,Q=>St(Q,t,e,r,s,i,void 0,l).then(B=>B.stdout??"")),S=Oi(x.trim());if(S.length===0)return{exitCode:0};if(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.test(S[0]))return Yr(S[0],S.slice(1),t,e,r,s,i,o,l);let H=S[0]?.toLowerCase()??"",C=S.slice(1).flatMap(Fs),U=bn(H);if(!U){let Q=$d(H,l,i,t);if(Q){let B=i.vfs.readFile(Q),b=B.match(/exec\s+builtin\s+(\S+)/);if(b){let k=b[1],v=bn(k);if(v)return await v.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:[H,...C].join(" "),mode:r,args:C,stdin:o,cwd:s,shell:i,env:l})}let w=bn("sh");if(w)return await w.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:`sh -c ${JSON.stringify(B)}`,mode:r,args:["-c",B,"--",...C],stdin:o,cwd:s,shell:i,env:l})}return{stderr:`${H}: command not found`,exitCode:127}}try{return await U.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:x,mode:r,args:C,stdin:o,cwd:s,shell:i,env:l})}catch(Q){return{stderr:Q instanceof Error?Q.message:"Command failed",exitCode:1}}}async function uc(n,t,e,r){return Hs(n,t,e,s=>St(s,r.authUser,r.hostname,r.mode,r.cwd,r.shell,void 0,r.env).then(i=>i.stdout??""))}function er(n){let t=[],e=0;for(;e<n.length;){let r=n[e].trim();if(!r||r.startsWith("#")){e++;continue}let s=r.match(/^(?:function\s+)?(\w+)\s*\(\s*\)\s*\{(.+)\}\s*$/),i=s??(r.match(/^(?:function\s+)?(\w+)\s*\(\s*\)\s*\{?\s*$/)||r.match(/^function\s+(\w+)\s*\{?\s*$/));if(i){let a=i[1],c=[];if(s){c.push(...s[2].split(";").map(l=>l.trim()).filter(Boolean)),t.push({type:"func",name:a,body:c}),e++;continue}for(e++;e<n.length&&n[e]?.trim()!=="}"&&e<n.length+1;){let l=n[e].trim().replace(/^do\s+/,"");l&&l!=="{"&&c.push(l),e++}e++,t.push({type:"func",name:a,body:c});continue}let o=r.match(/^\(\(\s*(.+?)\s*\)\)$/);if(o){t.push({type:"arith",expr:o[1]}),e++;continue}if(r.startsWith("if ")||r==="if"){let a=r.replace(/^if\s+/,"").replace(/;\s*then\s*$/,"").trim(),c=[],l=[],f=[],u="then",h="";for(e++;e<n.length&&n[e]?.trim()!=="fi";){let p=n[e].trim();p.startsWith("elif ")?(u="elif",h=p.replace(/^elif\s+/,"").replace(/;\s*then\s*$/,"").trim(),l.push({cond:h,body:[]})):p==="else"?u="else":p!=="then"&&(u==="then"?c.push(p):u==="elif"&&l.length>0?l[l.length-1].body.push(p):f.push(p)),e++}t.push({type:"if",cond:a,then_:c,elif:l,else_:f})}else if(r.startsWith("for ")){let a=r.match(/^for\s+(\w+)\s+in\s+(.+?)(?:\s*;\s*do)?$/);if(a){let c=[];for(e++;e<n.length&&n[e]?.trim()!=="done";){let l=n[e].trim().replace(/^do\s+/,"");l&&l!=="do"&&c.push(l),e++}t.push({type:"for",var:a[1],list:a[2],body:c})}else t.push({type:"cmd",line:r})}else if(r.startsWith("while ")){let a=r.replace(/^while\s+/,"").replace(/;\s*do\s*$/,"").trim(),c=[];for(e++;e<n.length&&n[e]?.trim()!=="done";){let l=n[e].trim().replace(/^do\s+/,"");l&&l!=="do"&&c.push(l),e++}t.push({type:"while",cond:a,body:c})}else t.push({type:"cmd",line:r});e++}return t}async function fc(n,t){let e=await uc(n,t.env.vars,t.env.lastExitCode,t),r=e.match(/^\[?\s*(.+?)\s*\]?$/);if(r){let i=r[1],o=i.match(/^-([fdeznr])\s+(.+)$/);if(o){let[,l,f]=o,u=de(t.cwd,f);if(l==="f")return t.shell.vfs.exists(u)&&t.shell.vfs.stat(u).type==="file";if(l==="d")return t.shell.vfs.exists(u)&&t.shell.vfs.stat(u).type==="directory";if(l==="e")return t.shell.vfs.exists(u);if(l==="z")return(f??"").length===0;if(l==="n")return(f??"").length>0}let a=i.match(/^"?([^"]*)"?\s*(==|!=|=|<|>)\s*"?([^"]*)"?$/);if(a){let[,l,f,u]=a;if(f==="=="||f==="=")return l===u;if(f==="!=")return l!==u}let c=i.match(/^(\S+)\s+(-eq|-ne|-lt|-le|-gt|-ge)\s+(\S+)$/);if(c){let[,l,f,u]=c,h=Number(l),p=Number(u);if(f==="-eq")return h===p;if(f==="-ne")return h!==p;if(f==="-lt")return h<p;if(f==="-le")return h<=p;if(f==="-gt")return h>p;if(f==="-ge")return h>=p}}return((await St(e,t.authUser,t.hostname,t.mode,t.cwd,t.shell,void 0,t.env)).exitCode??0)===0}async function tr(n,t){let e={exitCode:0},r="";for(let s of n)if(s.type==="cmd"){let i=await uc(s.line,t.env.vars,t.env.lastExitCode,t),o=/^([A-Za-z_][A-Za-z0-9_]*)=(.*)/,a=i.trim().split(/\s+/);if(a.length>0&&o.test(a[0])&&a.every(f=>o.test(f))){for(let f of a){let u=f.match(o);t.env.vars[u[1]]=u[2]}t.env.lastExitCode=0;continue}let c=await(async()=>{let l=i.trim().split(/\s+/)[0]??"",f=t.env.vars[`__func_${l}`];if(f){let u=i.trim().split(/\s+/).slice(1),h={...t.env.vars};u.forEach((_,x)=>{t.env.vars[String(x+1)]=_}),t.env.vars[0]=l;let p=f.split(`
|
|
196
|
+
`),exitCode:0};for(let e of n)if(e.includes("=")){let r=e.indexOf("=");t.vars[e.slice(0,r)]=e.slice(r+1)}return{exitCode:0}}};async function Td(n,t,e,r,s,i,o){let a={exitCode:0},c=[],l=s,f=0;for(;f<n.length;){let h=n[f];if(a=await ZA(h.pipeline,t,e,r,l,i,o),o.lastExitCode=a.exitCode??0,a.nextCwd&&(a.exitCode??0)===0&&(l=a.nextCwd),a.stdout&&c.push(a.stdout),a.closeSession||a.switchUser)return{...a,stdout:c.join("")||a.stdout};let p=h.op;if(!(!p||p===";")){if(p==="&&"){if((a.exitCode??0)!==0)for(;f<n.length&&n[f]?.op==="&&";)f++}else if(p==="||"&&(a.exitCode??0)===0)for(;f<n.length&&n[f]?.op==="||";)f++}f++}let u=c.join("");return{...a,stdout:u||a.stdout,nextCwd:l!==s?l:void 0}}async function ZA(n,t,e,r,s,i,o){if(!n.isValid)return{stderr:n.error||"Syntax error",exitCode:1};if(n.commands.length===0)return{exitCode:0};let a=o??{vars:{},lastExitCode:0};return n.commands.length===1?ey(n.commands[0],t,e,r,s,i,a):ty(n.commands,t,e,r,s,i,a)}async function ey(n,t,e,r,s,i,o){let a;if(n.inputFile){let l=de(s,n.inputFile);try{a=i.vfs.readFile(l)}catch{return{stderr:`${n.inputFile}: No such file or directory`,exitCode:1}}}let c=await Yr(n.name,n.args,t,e,r,s,i,a,o);if(n.outputFile){let l=de(s,n.outputFile),f=c.stdout||"";try{if(n.appendOutput){let u=(()=>{try{return i.vfs.readFile(l)}catch{return""}})();i.writeFileAsUser(t,l,u+f)}else i.writeFileAsUser(t,l,f);return{...c,stdout:""}}catch{return{...c,stderr:`Failed to write to ${n.outputFile}`,exitCode:1}}}return c}async function ty(n,t,e,r,s,i,o){let a="",c=0;for(let l=0;l<n.length;l++){let f=n[l];if(l===0&&f.inputFile){let h=de(s,f.inputFile);try{a=i.vfs.readFile(h)}catch{return{stderr:`${f.inputFile}: No such file or directory`,exitCode:1}}}let u=await Yr(f.name,f.args,t,e,r,s,i,a,o);if(c=u.exitCode??0,l===n.length-1&&f.outputFile){let h=de(s,f.outputFile),p=u.stdout||"";try{if(f.appendOutput){let y=(()=>{try{return i.vfs.readFile(h)}catch{return""}})();i.writeFileAsUser(t,h,y+p)}else i.writeFileAsUser(t,h,p);a=""}catch{return{stderr:`Failed to write to ${f.outputFile}`,exitCode:1}}}else a=u.stdout||"";if(u.stderr&&c!==0)return{stderr:u.stderr,exitCode:c};if(u.closeSession||u.switchUser)return u}return{stdout:a,exitCode:c}}function Oi(n){let t=[],e="",r=!1,s="",i=0;for(;i<n.length;){let o=n[i],a=n[i+1];if((o==='"'||o==="'")&&!r){r=!0,s=o,i++;continue}if(r&&o===s){r=!1,s="",i++;continue}if(r){e+=o,i++;continue}if(o===" "){e&&(t.push(e),e=""),i++;continue}if(!r&&o==="2"&&a===">"){let c=n.slice(i+1);if(c.startsWith(">>&1")||c.startsWith(">> &1")){e&&(t.push(e),e=""),t.push("2>>&1"),i+=5;continue}if(c.startsWith(">&1")){e&&(t.push(e),e=""),t.push("2>&1"),i+=4;continue}if(c.startsWith(">>")){e&&(t.push(e),e=""),t.push("2>>"),i+=3;continue}if(c.startsWith(">")){e&&(t.push(e),e=""),t.push("2>"),i+=2;continue}}if((o===">"||o==="<")&&!r){e&&(t.push(e),e=""),o===">"&&a===">"?(t.push(">>"),i+=2):(t.push(o),i++);continue}e+=o,i++}return e&&t.push(e),t}function Ld(n){let t=n.trim();if(!t)return{statements:[],isValid:!0};try{return{statements:ny(t),isValid:!0}}catch(e){return{statements:[],isValid:!1,error:e.message}}}function ny(n){let t=ry(n),e=[];for(let r of t){let i={pipeline:{commands:iy(r.text.trim()),isValid:!0}};r.op&&(i.op=r.op),e.push(i)}return e}function ry(n){let t=[],e="",r=0,s=!1,i="",o=0,a=c=>{e.trim()&&t.push({text:e,op:c}),e=""};for(;o<n.length;){let c=n[o],l=n.slice(o,o+2);if((c==='"'||c==="'")&&!s){s=!0,i=c,e+=c,o++;continue}if(s&&c===i){s=!1,e+=c,o++;continue}if(s){e+=c,o++;continue}if(c==="("){r++,e+=c,o++;continue}if(c===")"){r--,e+=c,o++;continue}if(r>0){e+=c,o++;continue}if(l==="&&"){a("&&"),o+=2;continue}if(l==="||"){a("||"),o+=2;continue}if(c===";"){a(";"),o++;continue}e+=c,o++}return a(),t}function iy(n){return sy(n).map(oy)}function sy(n){let t=[],e="",r=!1,s="";for(let o=0;o<n.length;o++){let a=n[o];if((a==='"'||a==="'")&&!r){r=!0,s=a,e+=a;continue}if(r&&a===s){r=!1,e+=a;continue}if(r){e+=a;continue}if(a==="|"&&n[o+1]!=="|"){if(!e.trim())throw new Error("Syntax error near unexpected token '|'");t.push(e.trim()),e=""}else e+=a}let i=e.trim();if(!i&&t.length>0)throw new Error("Syntax error near unexpected token '|'");return i&&t.push(i),t}function oy(n){let t=Oi(n);if(t.length===0)return{name:"",args:[]};let e=[],r,s,i=!1,o=0,a,c=!1,l=!1;for(;o<t.length;){let h=t[o];if(h==="<"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after <");r=t[o],o++}else if(h===">>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after >>");s=t[o],i=!0,o++}else if(h===">"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after >");s=t[o],i=!1,o++}else if(h==="2>&1")l=!0,o++;else if(h==="2>>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after 2>>");a=t[o],c=!0,o++}else if(h==="2>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after 2>");a=t[o],c=!1,o++}else e.push(h),o++}let f=e[0]??"";return{name:/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.test(f)?f:f.toLowerCase(),args:e.slice(1),inputFile:r,outputFile:s,appendOutput:i,stderrFile:a,stderrAppend:c,stderrToStdout:l}}function zr(n,t){return{vars:{PATH:"/usr/local/bin:/usr/bin:/bin",HOME:`/home/${n}`,USER:n,LOGNAME:n,SHELL:"/bin/sh",TERM:"xterm-256color",HOSTNAME:t,PS1:"\\u@\\h:\\w\\$ "},lastExitCode:0}}function $d(n,t,e,r){if(n.startsWith("/")){if(!e.vfs.exists(n))return null;try{let i=e.vfs.stat(n);return i.type!=="file"||!(i.mode&73)||(n.startsWith("/sbin/")||n.startsWith("/usr/sbin/"))&&r!=="root"?null:n}catch{return null}}let s=(t.vars.PATH??"/usr/local/bin:/usr/bin:/bin").split(":");for(let i of s){if((i==="/sbin"||i==="/usr/sbin")&&r!=="root")continue;let o=`${i}/${n}`;if(e.vfs.exists(o))try{let a=e.vfs.stat(o);if(a.type!=="file"||!(a.mode&73))continue;return o}catch{}}return null}async function Yr(n,t,e,r,s,i,o,a,c){let l=/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/,f=[n,...t],u=0;for(;u<f.length&&l.test(f[u]);)u+=1;if(u>0){let y=f.slice(0,u).map(S=>S.match(l)),_=f.slice(u),x=[];for(let[,S,R]of y)x.push([S,c.vars[S]]),c.vars[S]=R;if(_.length===0)return{exitCode:0};try{return await Yr(_[0],_.slice(1),e,r,s,i,o,a,c)}finally{for(let[S,R]of x)R===void 0?delete c.vars[S]:c.vars[S]=R}}let h=c.vars[`__alias_${n}`];if(h)return St(`${h} ${t.join(" ")}`,e,r,s,i,o,a,c);let p=bn(n);if(!p){let y=$d(n,c,o,e);if(y){let _=o.vfs.readFile(y),x=_.match(/exec\s+builtin\s+(\S+)/);if(x){let R=bn(x[1]);if(R)return await R.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:[n,...t].join(" "),mode:s,args:t,stdin:a,cwd:i,shell:o,env:c})}let S=bn("sh");if(S)return await S.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:`sh -c ${JSON.stringify(_)}`,mode:s,args:["-c",_,"--",...t],stdin:a,cwd:i,shell:o,env:c})}return{stderr:`${n}: command not found`,exitCode:127}}try{return await p.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:[n,...t].join(" "),mode:s,args:t,stdin:a,cwd:i,shell:o,env:c})}catch(y){return{stderr:y instanceof Error?y.message:"Command failed",exitCode:1}}}async function St(n,t,e,r,s,i,o,a){let c=n.trim();if(c.length===0)return{exitCode:0};let l=a??zr(t,e),u=Oi(c)[0]?.toLowerCase()??"",h=l.vars[`__alias_${u}`],p=h?c.replace(u,h):c,y=/\bfor\s+\w+\s+in\b/.test(p)||/\bwhile\s+/.test(p)||/\bif\s+/.test(p)||/\w+\s*\(\s*\)\s*\{/.test(p)||/\bfunction\s+\w+/.test(p)||/\(\(\s*.+\s*\)\)/.test(p),_=/(?<![|&])[|](?![|])/.test(p)||p.includes(">")||p.includes("<")||p.includes("&&")||p.includes("||")||p.includes(";");if(y&&u!=="sh"&&u!=="bash"||_){if(y&&u!=="sh"&&u!=="bash"){let B=bn("sh");if(B)return await B.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:p,mode:r,args:["-c",p],stdin:void 0,cwd:s,shell:i,env:l})}let Q=Ld(p);if(!Q.isValid)return{stderr:Q.error||"Syntax error",exitCode:1};try{return await Td(Q.statements,t,e,r,s,i,l)}catch(B){return{stderr:B instanceof Error?B.message:"Execution failed",exitCode:1}}}let x=await Hs(p,l.vars,l.lastExitCode,Q=>St(Q,t,e,r,s,i,void 0,l).then(B=>B.stdout??"")),S=Oi(x.trim());if(S.length===0)return{exitCode:0};if(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.test(S[0]))return Yr(S[0],S.slice(1),t,e,r,s,i,o,l);let H=S[0]?.toLowerCase()??"",C=S.slice(1).flatMap(Fs),U=bn(H);if(!U){let Q=$d(H,l,i,t);if(Q){let B=i.vfs.readFile(Q),b=B.match(/exec\s+builtin\s+(\S+)/);if(b){let k=b[1],v=bn(k);if(v)return await v.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:[H,...C].join(" "),mode:r,args:C,stdin:o,cwd:s,shell:i,env:l})}let w=bn("sh");if(w)return await w.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:`sh -c ${JSON.stringify(B)}`,mode:r,args:["-c",B,"--",...C],stdin:o,cwd:s,shell:i,env:l})}return{stderr:`${H}: command not found`,exitCode:127}}try{return await U.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:x,mode:r,args:C,stdin:o,cwd:s,shell:i,env:l})}catch(Q){return{stderr:Q instanceof Error?Q.message:"Command failed",exitCode:1}}}async function uc(n,t,e,r){return Hs(n,t,e,s=>St(s,r.authUser,r.hostname,r.mode,r.cwd,r.shell,void 0,r.env).then(i=>i.stdout??""))}function er(n){let t=[],e=0;for(;e<n.length;){let r=n[e].trim();if(!r||r.startsWith("#")){e++;continue}let s=r.match(/^(?:function\s+)?(\w+)\s*\(\s*\)\s*\{(.+)\}\s*$/),i=s??(r.match(/^(?:function\s+)?(\w+)\s*\(\s*\)\s*\{?\s*$/)||r.match(/^function\s+(\w+)\s*\{?\s*$/));if(i){let a=i[1],c=[];if(s){c.push(...s[2].split(";").map(l=>l.trim()).filter(Boolean)),t.push({type:"func",name:a,body:c}),e++;continue}for(e++;e<n.length&&n[e]?.trim()!=="}"&&e<n.length+1;){let l=n[e].trim().replace(/^do\s+/,"");l&&l!=="{"&&c.push(l),e++}e++,t.push({type:"func",name:a,body:c});continue}let o=r.match(/^\(\(\s*(.+?)\s*\)\)$/);if(o){t.push({type:"arith",expr:o[1]}),e++;continue}if(r.startsWith("if ")||r==="if"){let a=r.replace(/^if\s+/,"").replace(/;\s*then\s*$/,"").trim(),c=[],l=[],f=[],u="then",h="";for(e++;e<n.length&&n[e]?.trim()!=="fi";){let p=n[e].trim();p.startsWith("elif ")?(u="elif",h=p.replace(/^elif\s+/,"").replace(/;\s*then\s*$/,"").trim(),l.push({cond:h,body:[]})):p==="else"?u="else":p!=="then"&&(u==="then"?c.push(p):u==="elif"&&l.length>0?l[l.length-1].body.push(p):f.push(p)),e++}t.push({type:"if",cond:a,then_:c,elif:l,else_:f})}else if(r.startsWith("for ")){let a=r.match(/^for\s+(\w+)\s+in\s+(.+?)(?:\s*;\s*do)?$/);if(a){let c=[];for(e++;e<n.length&&n[e]?.trim()!=="done";){let l=n[e].trim().replace(/^do\s+/,"");l&&l!=="do"&&c.push(l),e++}t.push({type:"for",var:a[1],list:a[2],body:c})}else t.push({type:"cmd",line:r})}else if(r.startsWith("while ")){let a=r.replace(/^while\s+/,"").replace(/;\s*do\s*$/,"").trim(),c=[];for(e++;e<n.length&&n[e]?.trim()!=="done";){let l=n[e].trim().replace(/^do\s+/,"");l&&l!=="do"&&c.push(l),e++}t.push({type:"while",cond:a,body:c})}else t.push({type:"cmd",line:r});e++}return t}async function fc(n,t){let e=await uc(n,t.env.vars,t.env.lastExitCode,t),r=e.match(/^\[?\s*(.+?)\s*\]?$/);if(r){let i=r[1],o=i.match(/^-([fdeznr])\s+(.+)$/);if(o){let[,l,f]=o,u=de(t.cwd,f);if(l==="f")return t.shell.vfs.exists(u)&&t.shell.vfs.stat(u).type==="file";if(l==="d")return t.shell.vfs.exists(u)&&t.shell.vfs.stat(u).type==="directory";if(l==="e")return t.shell.vfs.exists(u);if(l==="z")return(f??"").length===0;if(l==="n")return(f??"").length>0}let a=i.match(/^"?([^"]*)"?\s*(==|!=|=|<|>)\s*"?([^"]*)"?$/);if(a){let[,l,f,u]=a;if(f==="=="||f==="=")return l===u;if(f==="!=")return l!==u}let c=i.match(/^(\S+)\s+(-eq|-ne|-lt|-le|-gt|-ge)\s+(\S+)$/);if(c){let[,l,f,u]=c,h=Number(l),p=Number(u);if(f==="-eq")return h===p;if(f==="-ne")return h!==p;if(f==="-lt")return h<p;if(f==="-le")return h<=p;if(f==="-gt")return h>p;if(f==="-ge")return h>=p}}return((await St(e,t.authUser,t.hostname,t.mode,t.cwd,t.shell,void 0,t.env)).exitCode??0)===0}async function tr(n,t){let e={exitCode:0},r="";for(let s of n)if(s.type==="cmd"){let i=await uc(s.line,t.env.vars,t.env.lastExitCode,t),o=/^([A-Za-z_][A-Za-z0-9_]*)=(.*)/,a=i.trim().split(/\s+/);if(a.length>0&&o.test(a[0])&&a.every(f=>o.test(f))){for(let f of a){let u=f.match(o);t.env.vars[u[1]]=u[2]}t.env.lastExitCode=0;continue}let c=await(async()=>{let l=i.trim().split(/\s+/)[0]??"",f=t.env.vars[`__func_${l}`];if(f){let u=i.trim().split(/\s+/).slice(1),h={...t.env.vars};u.forEach((_,x)=>{t.env.vars[String(x+1)]=_}),t.env.vars[0]=l;let p=f.split(`
|
|
196
197
|
`),y=await tr(er(p),t);for(let _=1;_<=u.length;_++)delete t.env.vars[String(_)];return Object.assign(t.env.vars,{...h,...t.env.vars}),y}return St(i,t.authUser,t.hostname,t.mode,t.cwd,t.shell,void 0,t.env)})();if(t.env.lastExitCode=c.exitCode??0,c.stdout&&(r+=`${c.stdout}
|
|
197
198
|
`),c.stderr)return{...c,stdout:r.trim()};e=c}else if(s.type==="if"){let i=!1;if(await fc(s.cond,t)){let o=await tr(er(s.then_),t);o.stdout&&(r+=`${o.stdout}
|
|
198
199
|
`),i=!0}else{for(let o of s.elif)if(await fc(o.cond,t)){let a=await tr(er(o.body),t);a.stdout&&(r+=`${a.stdout}
|
|
@@ -207,7 +208,7 @@ Type "help", "copyright", "credits" or "license" for more information.
|
|
|
207
208
|
`),exitCode:0}}};var Wd={name:"source",aliases:["."],description:"Execute commands from a file in the current shell environment",category:"shell",params:["<file> [args...]"],run:async({args:n,authUser:t,hostname:e,cwd:r,shell:s,env:i})=>{let o=n[0];if(!o)return{stderr:"source: missing filename",exitCode:1};let a=de(r,o);if(!s.vfs.exists(a))return{stderr:`source: ${o}: No such file or directory`,exitCode:1};let c=s.vfs.readFile(a),l=0;for(let f of c.split(`
|
|
208
209
|
`)){let u=f.trim();if(!u||u.startsWith("#"))continue;let h=await St(u,t,e,"shell",r,s,void 0,i);if(l=h.exitCode??0,h.closeSession||h.switchUser)return h}return{exitCode:l}}};var qd={name:"su",description:"Switch user",category:"users",params:["[-] [-c <cmd>] [username]"],run:async({authUser:n,shell:t,args:e,hostname:r,mode:s,cwd:i})=>{let o=e.includes("-")||e.includes("-l")||e.includes("--login"),a=e.indexOf("-c"),c=a!==-1?e[a+1]:void 0,f=e.filter((u,h)=>h!==a&&h!==a+1).filter(u=>u!=="-"&&u!=="-l"&&u!=="--login").find(u=>!u.startsWith("-"))??"root";return t.users.listUsers().includes(f)?n==="root"?c?St(c,f,r,s,o?`/home/${f}`:i,t):{switchUser:f,nextCwd:o?`/home/${f}`:void 0,exitCode:0}:t.users.isSudoer(n)?{sudoChallenge:{username:f,targetUser:f,commandLine:c??null,loginShell:o,prompt:"Password: "},exitCode:0}:{stderr:`su: permission denied
|
|
209
210
|
`,exitCode:1}:{stderr:`su: user '${f}' does not exist
|
|
210
|
-
`,exitCode:1}}};function
|
|
211
|
+
`,exitCode:1}}};function ay(n){let{flags:t,flagsWithValues:e,positionals:r}=Xt(n,{flags:["-i","-S"],flagsWithValue:["-u","--user"]}),s=t.has("-i"),i=e.get("-u")||e.get("--user")||"root",o=r.length>0?r.join(" "):null;return{targetUser:i,loginShell:s,commandLine:o}}var Kd={name:"sudo",description:"Execute as superuser",category:"users",params:["<command...>"],run:async({authUser:n,hostname:t,mode:e,cwd:r,shell:s,args:i})=>{let{targetUser:o,loginShell:a,commandLine:c}=ay(i);if(n!=="root"&&!s.users.isSudoer(n))return{stderr:"sudo: permission denied",exitCode:1};let l=o||"root",f=`[sudo] password for ${n}: `;return n==="root"?!c&&a?{switchUser:l,nextCwd:`/home/${l}`,exitCode:0}:c?St(c,l,t,e,a?`/home/${l}`:r,s):{stderr:"sudo: missing command",exitCode:1}:{sudoChallenge:{username:n,targetUser:l,commandLine:c,loginShell:a,prompt:f},exitCode:0}}};var Vd={name:"tail",description:"Output last lines",category:"text",params:["[-n <lines>] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=nn(r,["-n"]),o=r.find(u=>/^-\d+$/.test(u)),a=typeof i=="string"?parseInt(i,10):o?parseInt(o.slice(1),10):10,c=r.filter(u=>!u.startsWith("-")&&u!==i&&u!==String(a)),l=u=>{let h=u.split(`
|
|
211
212
|
`),p=u.endsWith(`
|
|
212
213
|
`),y=p?h.slice(0,-1):h;return y.slice(Math.max(0,y.length-a)).join(`
|
|
213
214
|
`)+(p?`
|
|
@@ -215,8 +216,8 @@ Type "help", "copyright", "credits" or "license" for more information.
|
|
|
215
216
|
`),exitCode:0}}};var Gd={name:"tar",description:"Archive utility",category:"archive",params:["[-czf|-xzf|-tf] <archive> [files...]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=[],i=!1;for(let h of r)if(/^-[a-zA-Z]{2,}$/.test(h))for(let p of h.slice(1))s.push(`-${p}`);else if(!i&&/^[cxtdru]{1,}[a-zA-Z]*$/.test(h)&&!h.includes("/")&&!h.startsWith("-")){i=!0;for(let p of h)s.push(`-${p}`)}else s.push(h);let o=s.includes("-c"),a=s.includes("-x"),c=s.includes("-t"),l=s.indexOf("-f"),f=l!==-1?s[l+1]:s.find(h=>h.endsWith(".tar")||h.endsWith(".tar.gz")||h.endsWith(".tgz"));if(!o&&!a&&!c)return{stderr:`tar: must specify -c, -x, or -t
|
|
216
217
|
`,exitCode:1};if(!f)return{stderr:`tar: no archive specified
|
|
217
218
|
`,exitCode:1};let u=de(e,f);if(o){let h=new Set;l!==-1&&h.add(l+1);let p=s.filter((_,x)=>!_.startsWith("-")&&_!==f&&!h.has(x)),y={};for(let _ of p){let x=de(e,_);try{if(t.vfs.stat(x).type==="file")y[_]=t.vfs.readFile(x);else{let R=(H,C)=>{for(let U of t.vfs.list(H)){let Q=`${H}/${U}`,B=`${C}/${U}`;t.vfs.stat(Q).type==="file"?y[B]=t.vfs.readFile(Q):R(Q,B)}};R(x,_)}}catch{return{stderr:`tar: ${_}: No such file or directory`,exitCode:1}}}return t.writeFileAsUser(n,u,JSON.stringify(y)),{exitCode:0}}if(c||a){let h;try{h=JSON.parse(t.vfs.readFile(u))}catch{return{stderr:`tar: ${f}: cannot open archive`,exitCode:1}}if(c)return{stdout:Object.keys(h).join(`
|
|
218
|
-
`),exitCode:0};for(let[p,y]of Object.entries(h))t.writeFileAsUser(n,de(e,p),y);return{exitCode:0}}return{stderr:"tar: must specify -c, -x, or -t",exitCode:1}}};var zd={name:"tee",description:"Read stdin, write to stdout and files",category:"text",params:["[-a] <file...>"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-a"]),o=r.filter(c=>!c.startsWith("-")),a=s??"";for(let c of o){let l=de(e,c);if(i){let f=(()=>{try{return t.vfs.readFile(l)}catch{return""}})();t.writeFileAsUser(n,l,f+a)}else t.writeFileAsUser(n,l,a)}return{stdout:a,exitCode:0}}};function jr(n,t,e){if(n[n.length-1]==="]"&&(n=n.slice(0,-1)),n[0]==="["&&(n=n.slice(1)),n.length===0)return!1;if(n[0]==="!")return!jr(n.slice(1),t,e);let r=n.indexOf("-a");if(r!==-1)return jr(n.slice(0,r),t,e)&&jr(n.slice(r+1),t,e);let s=n.indexOf("-o");if(s!==-1)return jr(n.slice(0,s),t,e)||jr(n.slice(s+1),t,e);if(n.length===2){let[i,o=""]=n,c=(l=>l.startsWith("/")?l:`${e}/${l}`.replace(/\/+/g,"/"))(o);switch(i){case"-e":return t.vfs.exists(c);case"-f":return t.vfs.exists(c)&&t.vfs.stat(c).type==="file";case"-d":return t.vfs.exists(c)&&t.vfs.stat(c).type==="directory";case"-r":return t.vfs.exists(c);case"-w":return t.vfs.exists(c);case"-x":return t.vfs.exists(c)&&!!(t.vfs.stat(c).mode&73);case"-s":return t.vfs.exists(c)&&t.vfs.stat(c).type==="file"&&t.vfs.stat(c).size>0;case"-z":return o.length===0;case"-n":return o.length>0;case"-L":return t.vfs.isSymlink(c)}}if(n.length===3){let[i="",o,a=""]=n,c=Number(i),l=Number(a);switch(o){case"=":case"==":return i===a;case"!=":return i!==a;case"<":return i<a;case">":return i>a;case"-eq":return c===l;case"-ne":return c!==l;case"-lt":return c<l;case"-le":return c<=l;case"-gt":return c>l;case"-ge":return c>=l}}return n.length===1?(n[0]??"").length>0:!1}var Yd={name:"test",aliases:["["],description:"Evaluate conditional expression",category:"shell",params:["<expression>"],run:({args:n,shell:t,cwd:e})=>{try{return{exitCode:jr([...n],t,e)?0:1}}catch{return{stderr:"test: malformed expression",exitCode:2}}}};var jd={name:"touch",description:"Create or update files",category:"files",params:["<file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"touch: missing file operand",exitCode:1};for(let s of r){let i=de(e,s);Me(n,i,"touch"),t.vfs.exists(i)||t.writeFileAsUser(n,i,"")}return{exitCode:0}}};function
|
|
219
|
-
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function Xd(n){let t=[],e=
|
|
219
|
+
`),exitCode:0};for(let[p,y]of Object.entries(h))t.writeFileAsUser(n,de(e,p),y);return{exitCode:0}}return{stderr:"tar: must specify -c, -x, or -t",exitCode:1}}};var zd={name:"tee",description:"Read stdin, write to stdout and files",category:"text",params:["[-a] <file...>"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-a"]),o=r.filter(c=>!c.startsWith("-")),a=s??"";for(let c of o){let l=de(e,c);if(i){let f=(()=>{try{return t.vfs.readFile(l)}catch{return""}})();t.writeFileAsUser(n,l,f+a)}else t.writeFileAsUser(n,l,a)}return{stdout:a,exitCode:0}}};function jr(n,t,e){if(n[n.length-1]==="]"&&(n=n.slice(0,-1)),n[0]==="["&&(n=n.slice(1)),n.length===0)return!1;if(n[0]==="!")return!jr(n.slice(1),t,e);let r=n.indexOf("-a");if(r!==-1)return jr(n.slice(0,r),t,e)&&jr(n.slice(r+1),t,e);let s=n.indexOf("-o");if(s!==-1)return jr(n.slice(0,s),t,e)||jr(n.slice(s+1),t,e);if(n.length===2){let[i,o=""]=n,c=(l=>l.startsWith("/")?l:`${e}/${l}`.replace(/\/+/g,"/"))(o);switch(i){case"-e":return t.vfs.exists(c);case"-f":return t.vfs.exists(c)&&t.vfs.stat(c).type==="file";case"-d":return t.vfs.exists(c)&&t.vfs.stat(c).type==="directory";case"-r":return t.vfs.exists(c);case"-w":return t.vfs.exists(c);case"-x":return t.vfs.exists(c)&&!!(t.vfs.stat(c).mode&73);case"-s":return t.vfs.exists(c)&&t.vfs.stat(c).type==="file"&&t.vfs.stat(c).size>0;case"-z":return o.length===0;case"-n":return o.length>0;case"-L":return t.vfs.isSymlink(c)}}if(n.length===3){let[i="",o,a=""]=n,c=Number(i),l=Number(a);switch(o){case"=":case"==":return i===a;case"!=":return i!==a;case"<":return i<a;case">":return i>a;case"-eq":return c===l;case"-ne":return c!==l;case"-lt":return c<l;case"-le":return c<=l;case"-gt":return c>l;case"-ge":return c>=l}}return n.length===1?(n[0]??"").length>0:!1}var Yd={name:"test",aliases:["["],description:"Evaluate conditional expression",category:"shell",params:["<expression>"],run:({args:n,shell:t,cwd:e})=>{try{return{exitCode:jr([...n],t,e)?0:1}}catch{return{stderr:"test: malformed expression",exitCode:2}}}};var jd={name:"touch",description:"Create or update files",category:"files",params:["<file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"touch: missing file operand",exitCode:1};for(let s of r){let i=de(e,s);Me(n,i,"touch"),t.vfs.exists(i)||t.writeFileAsUser(n,i,"")}return{exitCode:0}}};function cy(n){return n.replace(/\\n/g,`
|
|
220
|
+
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function Xd(n){let t=[],e=cy(n),r=0;for(;r<e.length;){if(r+2<e.length&&e[r+1]==="-"){let s=e.charCodeAt(r),i=e.charCodeAt(r+2);if(s<=i){for(let o=s;o<=i;o++)t.push(String.fromCharCode(o));r+=3;continue}}t.push(e[r]),r++}return t}var Jd={name:"tr",description:"Translate or delete characters",category:"text",params:["[-d] [-s] <set1> [set2]"],run:({args:n,stdin:t})=>{let e=se(n,["-d"]),r=se(n,["-s"]),s=n.filter(c=>!c.startsWith("-")),i=Xd(s[0]??""),o=Xd(s[1]??""),a=t??"";if(e){let c=new Set(i);a=[...a].filter(l=>!c.has(l)).join("")}else if(o.length>0){let c=new Map;for(let l=0;l<i.length;l++)c.set(i[l],o[l]??o[o.length-1]??"");a=[...a].map(l=>c.get(l)??l).join("")}if(r&&o.length>0){let c=new Set(o);a=a.replace(/(.)\1+/g,(l,f)=>c.has(f)?f:l)}return{stdout:a,exitCode:0}}};var Zd={name:"tree",description:"Display directory tree",category:"navigation",params:["[path]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=de(e,Zn(r,0)??e);return Me(n,s,"tree"),{stdout:t.vfs.tree(s),exitCode:0}}};var eh={name:"true",description:"Return success exit code",category:"shell",params:[],run:()=>({exitCode:0})},th={name:"false",description:"Return failure exit code",category:"shell",params:[],run:()=>({exitCode:1})};var nh={name:"type",description:"Describe how a command would be interpreted",category:"shell",params:["<command...>"],run:({args:n,shell:t,env:e})=>{if(n.length===0)return{stderr:"type: missing argument",exitCode:1};let r=(e?.vars?.PATH??"/usr/local/bin:/usr/bin:/bin").split(":"),s=[],i=0;for(let o of n){if(bn(o)){s.push(`${o} is a shell builtin`);continue}let a=!1;for(let c of r){let l=`${c}/${o}`;if(t.vfs.exists(l)){s.push(`${o} is ${l}`),a=!0;break}}a||(s.push(`${o}: not found`),i=1)}return{stdout:s.join(`
|
|
220
221
|
`),exitCode:i}}};var rh={name:"uname",description:"Print system information",category:"system",params:["[-a] [-s] [-r] [-m]"],run:({shell:n,args:t})=>{let e=se(t,["-a"]),r="Linux",s=n.properties?.kernel??"5.15.0",i=n.properties?.arch??"x86_64",o=n.hostname;return e?{stdout:`${r} ${o} ${s} #1 SMP ${i} GNU/Linux`,exitCode:0}:se(t,["-r"])?{stdout:s,exitCode:0}:se(t,["-m"])?{stdout:i,exitCode:0}:{stdout:r,exitCode:0}}};var ih={name:"uniq",description:"Report or filter out repeated lines",category:"text",params:["[-c] [-d] [-u] [file]"],run:({args:n,stdin:t})=>{let e=se(n,["-c"]),r=se(n,["-d"]),s=se(n,["-u"]),i=(t??"").split(`
|
|
221
222
|
`),o=[],a=0;for(;a<i.length;){let c=a;for(;c<i.length&&i[c]===i[a];)c++;let l=c-a,f=i[a];if(r&&l===1){a=c;continue}if(s&&l>1){a=c;continue}o.push(e?`${String(l).padStart(4)} ${f}`:f),a=c}return{stdout:o.join(`
|
|
222
223
|
`),exitCode:0}}};var sh={name:"unset",description:"Remove shell variable",category:"shell",params:["<VAR>"],run:({args:n,env:t})=>{for(let e of n)delete t.vars[e];return{exitCode:0}}};var oh={name:"uptime",description:"Tell how long the system has been running",category:"system",params:["[-p] [-s]"],run:({args:n,shell:t})=>{let e=se(n,["-p"]),r=se(n,["-s"]),s=Math.floor((Date.now()-t.startTime)/1e3),i=Math.floor(s/86400),o=Math.floor(s%86400/3600),a=Math.floor(s%3600/60);if(r)return{stdout:new Date(t.startTime).toISOString().slice(0,19).replace("T"," "),exitCode:0};if(e){let h=[];return i>0&&h.push(`${i} day${i>1?"s":""}`),o>0&&h.push(`${o} hour${o>1?"s":""}`),h.push(`${a} minute${a!==1?"s":""}`),{stdout:`up ${h.join(", ")}`,exitCode:0}}let c=new Date().toTimeString().slice(0,8),l=i>0?`${i} day${i>1?"s":""}, ${String(o).padStart(2)}:${String(a).padStart(2,"0")}`:`${String(o).padStart(2)}:${String(a).padStart(2,"0")}`,f=t.users.listActiveSessions().length,u=(Math.random()*.5).toFixed(2);return{stdout:` ${c} up ${l}, ${f} user${f!==1?"s":""}, load average: ${u}, ${u}, ${u}`,exitCode:0}}};var ah={name:"wc",description:"Count words/lines/bytes",category:"text",params:["[-l] [-w] [-c] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-l"]),o=se(r,["-w"]),a=se(r,["-c"]),c=!i&&!o&&!a,l=r.filter(h=>!h.startsWith("-")),f=(h,p)=>{let y=h.length===0?0:h.trim().split(`
|
|
@@ -231,7 +232,7 @@ Usage: wget [OPTION]... [URL]...`,exitCode:1};let c=s.get("-O")??s.get("--output
|
|
|
231
232
|
${h} 100%[==================>] ${_.length} B`),{stderr:p.join(`
|
|
232
233
|
`)||void 0,exitCode:0}):{stdout:_,exitCode:0}}};var lh={name:"which",description:"Locate a command in PATH",category:"shell",params:["<command...>"],run:({args:n,shell:t,env:e})=>{if(n.length===0)return{stderr:"which: missing argument",exitCode:1};let r=(e?.vars?.PATH??"/usr/local/bin:/usr/bin:/bin").split(":"),s=[],i=!1;for(let o of n){let a=!1;for(let c of r){let l=`${c}/${o}`;if(t.vfs.exists(l)&&t.vfs.stat(l).type==="file"){s.push(l),a=!0;break}}a||(i=!0)}return s.length===0?{exitCode:1}:{stdout:s.join(`
|
|
233
234
|
`),exitCode:i?1:0}}};function Xs(n){let t=n.toLocaleString("en-US",{weekday:"short"}),e=n.toLocaleString("en-US",{month:"short"}),r=n.getDate().toString().padStart(2,"0"),s=n.getHours().toString().padStart(2,"0"),i=n.getMinutes().toString().padStart(2,"0"),o=n.getSeconds().toString().padStart(2,"0"),a=n.getFullYear();return`${t} ${e} ${r} ${s}:${i}:${o} ${a}`}var fh={name:"who",description:"Show active sessions",category:"system",params:[],run:({shell:n})=>({stdout:n.users.listActiveSessions().map(e=>{let r=new Date(e.startedAt),s=Number.isNaN(r.getTime())?e.startedAt:Xs(r);return`${e.username} ${e.tty} ${s} (${e.remoteAddress||"unknown"})`}).join(`
|
|
234
|
-
`),exitCode:0})};var uh={name:"whoami",description:"Print current user",category:"system",params:[],run:({authUser:n})=>({stdout:n,exitCode:0})};var dh={name:"xargs",description:"Build and execute command lines from stdin",category:"text",params:["[command] [args...]"],run:async({authUser:n,hostname:t,mode:e,cwd:r,args:s,stdin:i,shell:o,env:a})=>{let c=s[0]??"echo",l=s.slice(1),f=(i??"").trim().split(/\s+/).filter(Boolean);if(f.length===0)return{exitCode:0};let u=[c,...l,...f].join(" ");return St(u,n,t,e,r,o,void 0,a)}};var
|
|
235
|
+
`),exitCode:0})};var uh={name:"whoami",description:"Print current user",category:"system",params:[],run:({authUser:n})=>({stdout:n,exitCode:0})};var dh={name:"xargs",description:"Build and execute command lines from stdin",category:"text",params:["[command] [args...]"],run:async({authUser:n,hostname:t,mode:e,cwd:r,args:s,stdin:i,shell:o,env:a})=>{let c=s[0]??"echo",l=s.slice(1),f=(i??"").trim().split(/\s+/).filter(Boolean);if(f.length===0)return{exitCode:0};let u=[c,...l,...f].join(" ");return St(u,n,t,e,r,o,void 0,a)}};var ly=[Id,gu,td,Zd,pu,jd,Rd,id,yu,sd,ju,Xu,mu,Ju,Zu,Tu,$u,Nd,du,Qd,ih,ah,Mu,Vd,Eu,Jd,zd,dh,Iu,Gd,Uu,Ou,hu,uh,fh,Vu,zu,Du,rh,wd,Yu,wu,vu,bu,Hd,xd,Bu,Ru,Pu,Pd,sh,Ud,Au,Nu,ad,Gu,_u,ch,iu,bd,Su,Kd,qd,md,fu,uu,Cu,ku,lh,nh,rd,ou,au,Yd,Wd,Ku,Sd,Bd,xu,Od,Md,Fd,eh,th,_d,Ed,yd,vd,oh,Lu,nd],hh=[],Mi=new Map,Js=null,fy=qu(()=>hc().map(n=>n.name));function dc(){Mi.clear();for(let n of hc()){Mi.set(n.name,n);for(let t of n.aliases??[])Mi.set(t,n)}Js=Array.from(Mi.keys()).sort()}function hc(){return[...ly,...hh,fy]}function ac(n){let t={...n,name:n.name.trim().toLowerCase(),aliases:n.aliases?.map(r=>r.trim().toLowerCase())};if([t.name,...t.aliases??[]].some(r=>r.length===0||/\s/.test(r)))throw new Error("Command names must be non-empty and contain no spaces");hh.push(t),dc()}function cc(n,t,e){return{name:n,params:t,run:e}}function lc(){return Js||dc(),Js}function tc(){return hc()}function bn(n){return Js||dc(),Mi.get(n.toLowerCase())}var hr=zt(require("node:os"),1);function ce(n,t,e=493){n.exists(t)||n.mkdir(t,e)}function fe(n,t,e,r=420){n.exists(t)||n.writeFile(t,e,{mode:r})}function Et(n,t,e){n.writeFile(t,e)}function uy(n){let t=2166136261;for(let e=0;e<n.length;e++)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return t>>>0}function dy(n,t,e){ce(n,"/etc"),fe(n,"/etc/os-release",`${['NAME="Fortune GNU/Linux"',`PRETTY_NAME="${e.os}"`,"ID=fortune","ID_LIKE=debian",'HOME_URL="https://github.com/itsrealfortune/typescript-virtual-container"',"VERSION_CODENAME=aurora",'VERSION_ID="1.0"'].join(`
|
|
235
236
|
`)}
|
|
236
237
|
`),fe(n,"/etc/debian_version",`12.0
|
|
237
238
|
`),fe(n,"/etc/hostname",`${t}
|
|
@@ -280,7 +281,7 @@ nameserver 8.8.8.8
|
|
|
280
281
|
`,{mode:416})}function ph(n){let t=n.match(/(\d+)$/);return 1e3+(t?.[1]?parseInt(t[1],10):0)}function gh(n,t,e,r,s,i,o){let a=`/proc/${t}`;ce(n,a),ce(n,`${a}/fd`),ce(n,`${a}/fdinfo`);let c=Math.floor((Date.now()-new Date(i).getTime())/1e3),l=s.split(/\s+/)[0]??"bash";Et(n,`${a}/cmdline`,`${s.replace(/\s+/g,"\0")}\0`),Et(n,`${a}/comm`,l),Et(n,`${a}/status`,`${[`Name: ${l}`,"State: S (sleeping)",`Pid: ${t}`,"PPid: 1","Uid: 0 0 0 0","Gid: 0 0 0 0","VmRSS: 4096 kB","VmSize: 16384 kB","Threads: 1"].join(`
|
|
281
282
|
`)}
|
|
282
283
|
`),Et(n,`${a}/stat`,`${t} (${l}) S 1 ${t} ${t} 0 -1 4194304 0 0 0 0 ${c} 0 0 0 20 0 1 0 0 16384 4096 0
|
|
283
|
-
`),Et(n,`${a}/environ`,`${Object.entries(o).map(([f,u])=>`${f}=${u}`).join("\0")}\0`),Et(n,`${a}/cwd`,`/home/${e}\0`),Et(n,`${a}/exe`,"/bin/bash\0");for(let f of["0","1","2"])fe(n,`${a}/fd/${f}`,"")}function
|
|
284
|
+
`),Et(n,`${a}/environ`,`${Object.entries(o).map(([f,u])=>`${f}=${u}`).join("\0")}\0`),Et(n,`${a}/cwd`,`/home/${e}\0`),Et(n,`${a}/exe`,"/bin/bash\0");for(let f of["0","1","2"])fe(n,`${a}/fd/${f}`,"")}function hy(n,t){ce(n,"/proc/boot"),fe(n,"/proc/boot/log",`${["[ 0.000000] Linux virtual kernel booting...","[ 0.000120] init memory subsystem","[ 0.000240] mount /proc /sys /dev","[ 0.000420] start init","[ 0.000680] system ready"].join(`
|
|
284
285
|
`)}
|
|
285
286
|
`),fe(n,"/proc/boot/version",`Linux ${t.kernel} (virtual)
|
|
286
287
|
`)}function Zs(n,t,e,r,s=[]){ce(n,"/proc");let i=Math.floor((Date.now()-r)/1e3),o=Math.floor(i*.9);Et(n,"/proc/uptime",`${i}.00 ${o}.00
|
|
@@ -318,23 +319,23 @@ nameserver 8.8.8.8
|
|
|
318
319
|
State: S (sleeping)
|
|
319
320
|
Pid: 1
|
|
320
321
|
PPid: 0
|
|
321
|
-
`),Et(n,"/proc/self/environ",""),Et(n,"/proc/self/cwd","/root\0"),Et(n,"/proc/self/exe","/bin/bash\0")}function
|
|
322
|
+
`),Et(n,"/proc/self/environ",""),Et(n,"/proc/self/cwd","/root\0"),Et(n,"/proc/self/exe","/bin/bash\0")}function py(n,t,e){ce(n,"/sys"),ce(n,"/sys/devices"),ce(n,"/sys/devices/virtual"),ce(n,"/sys/devices/virtual/dmi"),ce(n,"/sys/devices/virtual/dmi/id");let r=uy(t),s=`VirtualNode-${(r%1e4).toString().padStart(4,"0")}`,i={bios_vendor:"Virtual BIOS",bios_version:"1.0",bios_date:"01/01/2025",sys_vendor:"Fortune Systems",product_name:s,product_family:"VirtualContainer",product_version:"v1",product_uuid:`${r.toString(16).padStart(8,"0")}-0000-0000-0000-000000000000`,product_serial:`SN-${r}`,chassis_type:"3",chassis_vendor:"Virtual",chassis_version:"v1",board_name:"fortune-board",modalias:`dmi:bvnVirtual:bvr1.0:svnFortune:pn${s}`};for(let[o,a]of Object.entries(i))fe(n,`/sys/devices/virtual/dmi/id/${o}`,`${a}
|
|
322
323
|
`);ce(n,"/sys/class"),ce(n,"/sys/class/net"),ce(n,"/sys/kernel"),fe(n,"/sys/kernel/hostname",`${t}
|
|
323
324
|
`),fe(n,"/sys/kernel/osrelease",`${e.kernel}
|
|
324
325
|
`),fe(n,"/sys/kernel/ostype",`Linux
|
|
325
|
-
`)}function
|
|
326
|
+
`)}function gy(n){ce(n,"/dev"),fe(n,"/dev/null","",438),fe(n,"/dev/zero","",438),fe(n,"/dev/full","",438),fe(n,"/dev/random","",292),fe(n,"/dev/urandom","",292),fe(n,"/dev/mem","",416),fe(n,"/dev/console","",384),fe(n,"/dev/tty","",438),fe(n,"/dev/tty0","",400),fe(n,"/dev/tty1","",400),fe(n,"/dev/ttyS0","",432);for(let t=0;t<8;t++)fe(n,`/dev/loop${t}`,"",432);ce(n,"/dev/loop-control"),fe(n,"/dev/sda","",432),fe(n,"/dev/sda1","",432),fe(n,"/dev/sda2","",432),ce(n,"/dev/pts"),ce(n,"/dev/shm"),fe(n,"/dev/stdin","",438),fe(n,"/dev/stdout","",438),fe(n,"/dev/stderr","",438)}function my(n){ce(n,"/usr"),ce(n,"/usr/bin"),ce(n,"/usr/sbin"),ce(n,"/usr/local"),ce(n,"/usr/local/bin"),ce(n,"/usr/local/lib"),ce(n,"/usr/local/share"),ce(n,"/usr/share"),ce(n,"/usr/share/doc"),ce(n,"/usr/share/man"),ce(n,"/usr/share/man/man1"),ce(n,"/usr/lib");let t=["sh","bash","ls","cat","echo","grep","find","sort","head","tail","cut","tr","sed","awk","wc","tee","tar","gzip","gunzip","touch","mkdir","rm","mv","cp","chmod","ln","pwd","env","date","sleep","id","whoami","hostname","uname","ps","kill","df","du","curl","wget","nano","diff","uniq","xargs","base64"];for(let e of t)fe(n,`/usr/bin/${e}`,`#!/bin/sh
|
|
326
327
|
exec builtin ${e} "$@"
|
|
327
328
|
`,493);fe(n,"/usr/bin/lsb_release",`#!/bin/sh
|
|
328
329
|
exec lsb_release "$@"
|
|
329
|
-
`,493)}function
|
|
330
|
-
`),fe(n,"/var/log/auth.log",""),fe(n,"/var/log/kern.log",""),fe(n,"/var/log/dpkg.log",""),fe(n,"/var/log/apt/history.log",""),fe(n,"/var/log/apt/term.log",""),ce(n,"/run"),ce(n,"/run/lock"),ce(n,"/run/systemd"),ce(n,"/run/user"),fe(n,"/run/utmp","")}function
|
|
330
|
+
`,493)}function Ay(n){ce(n,"/var"),ce(n,"/var/log"),ce(n,"/var/log/apt"),ce(n,"/var/tmp"),ce(n,"/var/cache"),ce(n,"/var/cache/apt"),ce(n,"/var/cache/apt/archives"),ce(n,"/var/lib"),ce(n,"/var/lib/apt"),ce(n,"/var/lib/apt/lists"),ce(n,"/var/lib/dpkg"),ce(n,"/var/lib/dpkg/info"),ce(n,"/var/lib/misc"),ce(n,"/var/spool"),ce(n,"/var/spool/cron"),ce(n,"/var/mail"),fe(n,"/var/lib/dpkg/status",""),fe(n,"/var/lib/dpkg/available",""),fe(n,"/var/log/syslog",`${new Date().toUTCString()} fortune kernel: Virtual container started
|
|
331
|
+
`),fe(n,"/var/log/auth.log",""),fe(n,"/var/log/kern.log",""),fe(n,"/var/log/dpkg.log",""),fe(n,"/var/log/apt/history.log",""),fe(n,"/var/log/apt/term.log",""),ce(n,"/run"),ce(n,"/run/lock"),ce(n,"/run/systemd"),ce(n,"/run/user"),fe(n,"/run/utmp","")}function yy(n){n.exists("/bin")||n.symlink("/usr/bin","/bin"),n.exists("/sbin")||n.symlink("/usr/sbin","/sbin"),n.exists("/var/run")||n.symlink("/run","/var/run"),ce(n,"/lib"),ce(n,"/lib64"),ce(n,"/lib/x86_64-linux-gnu"),ce(n,"/lib/modules")}function _y(n){ce(n,"/tmp",1023)}function Ey(n){ce(n,"/root",448),fe(n,"/root/.bashrc",`${["# root .bashrc","export PS1='\\[\\033[0;31m\\]\\u@\\h\\[\\033[0m\\]:\\[\\033[0;34m\\]\\w\\[\\033[0m\\]# '","export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","alias ll='ls -la'","alias la='ls -A'"].join(`
|
|
331
332
|
`)}
|
|
332
333
|
`),fe(n,"/root/.profile",`[ -f ~/.bashrc ] && . ~/.bashrc
|
|
333
|
-
`)}function
|
|
334
|
+
`)}function by(n,t){ce(n,"/opt"),ce(n,"/srv"),ce(n,"/mnt"),ce(n,"/media"),ce(n,"/home"),ce(n,"/boot"),ce(n,"/boot/grub"),ce(n,"/boot/grub/grub.cfg.d"),fe(n,"/boot/grub/grub.cfg",`${["# GRUB configuration (virtual)","set default=0","set timeout=5","",'menuentry "Fortune GNU/Linux" {'," linux /vmlinuz root=/dev/sda2 ro quiet splash"," initrd /initrd.img","}"].join(`
|
|
334
335
|
`)}
|
|
335
336
|
`);let e=t.kernel;fe(n,`/boot/vmlinuz-${e}`,"",420),fe(n,`/boot/initrd.img-${e}`,"",420),fe(n,`/boot/System.map-${e}`,`${e} virtual
|
|
336
337
|
`,420),fe(n,`/boot/config-${e}`,`# Linux kernel config ${e}
|
|
337
|
-
`,420),n.exists("/vmlinuz")||n.symlink(`/boot/vmlinuz-${e}`,"/vmlinuz"),n.exists("/vmlinuz.old")||n.symlink(`/boot/vmlinuz-${e}`,"/vmlinuz.old"),n.exists("/initrd.img")||n.symlink(`/boot/initrd.img-${e}`,"/initrd.img"),n.exists("/initrd.img.old")||n.symlink(`/boot/initrd.img-${e}`,"/initrd.img.old"),ce(n,"/snap"),ce(n,"/snap/bin"),ce(n,"/lost+found",448)}function mh(n,t,e,r,s,i=[]){hy(n,e,r),gy(n,e,r),my(n),Ay(n),yy(n),_y(n),Ey(n),by(n),xy(n,r),py(n,r),Zs(n,r,e,s,i),pc(n,t)}function Ah(n){return n==="1"||n==="true"}function yh(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Sy(){return Ah(process.env.DEV_MODE)||Ah(process.env.RENDER_PERF)}function nr(n){let t=Sy();if(!t)return{enabled:t,mark:()=>{},done:()=>{}};let e=yh(),r=i=>{let o=yh()-e;console.log(`[perf][${n}] ${i}: ${o.toFixed(1)}ms`)};return{enabled:t,mark:r,done:(i="done")=>{r(i)}}}var Ch=require("node:events"),at=zt(require("node:fs"),1),rn=zt(require("node:path"),1),pr=require("node:zlib");var Ac=Buffer.from([86,70,83,33]),wy=1,_h=1,Eh=2,gc=class{chunks=[];write(t){this.chunks.push(t)}writeUint8(t){let e=Buffer.allocUnsafe(1);e.writeUInt8(t,0),this.chunks.push(e)}writeUint16(t){let e=Buffer.allocUnsafe(2);e.writeUInt16LE(t,0),this.chunks.push(e)}writeUint32(t){let e=Buffer.allocUnsafe(4);e.writeUInt32LE(t,0),this.chunks.push(e)}writeFloat64(t){let e=Buffer.allocUnsafe(8);e.writeDoubleBE(t,0),this.chunks.push(e)}writeString(t){let e=Buffer.from(t,"utf8");this.writeUint16(e.length),this.chunks.push(e)}writeBytes(t){this.writeUint32(t.length),this.chunks.push(t)}toBuffer(){return Buffer.concat(this.chunks)}};function bh(n,t){if(t.type==="file"){let e=t;n.writeUint8(_h),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt.getTime()),n.writeFloat64(e.updatedAt.getTime()),n.writeUint8(e.compressed?1:0),n.writeBytes(e.content)}else{let e=t;n.writeUint8(Eh),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt.getTime()),n.writeFloat64(e.updatedAt.getTime());let r=Array.from(e.children.values());n.writeUint32(r.length);for(let s of r)bh(n,s)}}function xh(n){let t=new gc;return t.write(Ac),t.writeUint8(wy),bh(t,n),t.toBuffer()}var mc=class{constructor(t){this.buf=t}buf;pos=0;readUint8(){return this.buf.readUInt8(this.pos++)}readUint16(){let t=this.buf.readUInt16LE(this.pos);return this.pos+=2,t}readUint32(){let t=this.buf.readUInt32LE(this.pos);return this.pos+=4,t}readFloat64(){let t=this.buf.readDoubleBE(this.pos);return this.pos+=8,t}readString(){let t=this.readUint16(),e=this.buf.toString("utf8",this.pos,this.pos+t);return this.pos+=t,e}readBytes(){let t=this.readUint32(),e=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,e}remaining(){return this.buf.length-this.pos}};function Sh(n){let t=n.readUint8(),e=n.readString(),r=n.readUint32(),s=new Date(n.readFloat64()),i=new Date(n.readFloat64());if(t===_h){let o=n.readUint8()===1,a=n.readBytes();return{type:"file",name:e,mode:r,createdAt:s,updatedAt:i,compressed:o,content:a}}if(t===Eh){let o=n.readUint32(),a=new Map;for(let c=0;c<o;c++){let l=Sh(n);a.set(l.name,l)}return{type:"directory",name:e,mode:r,createdAt:s,updatedAt:i,children:a}}throw new Error(`[VFS binary] Unknown node type: 0x${t.toString(16)}`)}function wh(n){if(n.length<5)throw new Error("[VFS binary] Buffer too short");if(!n.slice(0,4).equals(Ac))throw new Error("[VFS binary] Invalid magic \u2014 not a VFS binary snapshot");let e=new mc(n);for(let s=0;s<5;s++)e.readUint8();let r=Sh(e);if(r.type!=="directory")throw new Error("[VFS binary] Root node must be a directory");return r}function Ih(n){return n.length>=4&&n.slice(0,4).equals(Ac)}var eo=zt(require("node:path"),1);function dt(n){if(!n||n.trim()==="")return"/";let t=eo.posix.normalize(n.startsWith("/")?n:`/${n}`);return t===""?"/":t}function Iy(n){return n.split("/").filter(Boolean)}function Qt(n,t){let e=dt(t);if(e==="/")return n;let r=Iy(e),s=n;for(let i of r){if(s.type!=="directory")throw new Error(`Path '${e}' does not exist.`);let o=s.children.get(i);if(!o)throw new Error(`Path '${e}' does not exist.`);s=o}return s}function Xr(n,t,e,r){let s=dt(t);if(s==="/")throw new Error("Root path has no parent directory.");let i=eo.posix.dirname(s),o=eo.posix.basename(s);if(!o)throw new Error(`Invalid path '${t}'.`);e&&r(i);let a=Qt(n,i);if(a.type!=="directory")throw new Error(`Parent path '${i}' is not a directory.`);return{parent:a,name:o}}var yc=class n extends Ch.EventEmitter{root;mode;snapshotFile;mounts=new Map;static isBrowser=typeof process>"u"||typeof process.versions?.node>"u";constructor(t={}){if(super(),this.mode=t.mode??"memory",this.mode==="fs"){if(!t.snapshotPath)throw new Error('VirtualFileSystem: "snapshotPath" is required when mode is "fs".');this.snapshotFile=rn.resolve(t.snapshotPath,"vfs-snapshot.vfsb")}else this.snapshotFile=null;this.root=this.makeDir("",493)}makeDir(t,e){let r=new Date;return{type:"directory",name:t,mode:e,createdAt:r,updatedAt:r,children:new Map}}makeFile(t,e,r,s){let i=new Date;return{type:"file",name:t,content:e,mode:r,compressed:s,createdAt:i,updatedAt:i}}mkdirRecursive(t,e){let r=dt(t);if(r==="/")return;let s=r.split("/").filter(Boolean),i=this.root,o="";for(let a of s){o+=`/${a}`;let c=i.children.get(a);if(!c)c=this.makeDir(a,e),i.children.set(a,c),this.emit("dir:create",{path:o,mode:e});else if(c.type!=="directory")throw new Error(`Cannot create directory '${o}': path is a file.`);i=c}}async restoreMirror(){if(!(this.mode!=="fs"||!this.snapshotFile)&&at.existsSync(this.snapshotFile))try{let t=at.readFileSync(this.snapshotFile);if(Ih(t))this.root=wh(t);else{let e=JSON.parse(t.toString("utf8"));this.root=this.deserializeDir(e.root,""),console.info("[VirtualFileSystem] Migrating legacy JSON snapshot to binary format.")}this.emit("snapshot:restore",{path:this.snapshotFile})}catch(t){console.warn(`[VirtualFileSystem] Could not restore snapshot from ${this.snapshotFile}:`,t instanceof Error?t.message:String(t))}}async flushMirror(){if(this.mode!=="fs"||!this.snapshotFile){this.emit("mirror:flush");return}let t=rn.dirname(this.snapshotFile);at.mkdirSync(t,{recursive:!0});let e=xh(this.root);at.writeFileSync(this.snapshotFile,e),this.emit("mirror:flush",{path:this.snapshotFile})}getMode(){return this.mode}getSnapshotPath(){return this.snapshotFile}mount(t,e,{readOnly:r=!0}={}){if(n.isBrowser)return;let s=dt(t),i=rn.resolve(e);if(!at.existsSync(i))throw new Error(`VirtualFileSystem.mount: host path does not exist: "${i}"`);if(!at.statSync(i).isDirectory())throw new Error(`VirtualFileSystem.mount: host path is not a directory: "${i}"`);this.mkdir(s),this.mounts.set(s,{hostPath:i,readOnly:r}),this.emit("mount",{vPath:s,hostPath:i,readOnly:r})}unmount(t){let e=dt(t);this.mounts.delete(e)&&this.emit("unmount",{vPath:e})}getMounts(){return[...this.mounts.entries()].map(([t,e])=>({vPath:t,...e}))}resolveMount(t){let e=dt(t),r=[...this.mounts.entries()].sort(([s],[i])=>i.length-s.length);for(let[s,i]of r)if(e===s||e.startsWith(`${s}/`)){let o=e.slice(s.length).replace(/^\//,""),a=o?rn.join(i.hostPath,o):i.hostPath;return{hostPath:i.hostPath,readOnly:i.readOnly,relPath:o,fullHostPath:a}}return null}mkdir(t,e=493){let r=dt(t),s=(()=>{try{return Qt(this.root,r)}catch{return null}})();if(s&&s.type!=="directory")throw new Error(`Cannot create directory '${r}': path is a file.`);this.mkdirRecursive(r,e)}writeFile(t,e,r={}){let s=this.resolveMount(t);if(s){if(s.readOnly)throw new Error(`EROFS: read-only file system, open '${s.fullHostPath}'`);let p=rn.dirname(s.fullHostPath);at.existsSync(p)||at.mkdirSync(p,{recursive:!0}),at.writeFileSync(s.fullHostPath,Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"));return}let i=dt(t),{parent:o,name:a}=Xr(this.root,i,!0,p=>this.mkdirRecursive(p,493)),c=o.children.get(a);if(c?.type==="directory")throw new Error(`Cannot write file '${i}': path is a directory.`);let l=Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"),f=r.compress??!1,u=f?(0,pr.gzipSync)(l):l,h=r.mode??420;if(c){let p=c;p.content=u,p.compressed=f,p.mode=h,p.updatedAt=new Date}else o.children.set(a,this.makeFile(a,u,h,f));this.emit("file:write",{path:i,size:u.length})}readFile(t){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return at.readFileSync(e.fullHostPath,"utf8")}let r=dt(t),s=Qt(this.root,r);if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s,o=i.compressed?(0,pr.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o.toString("utf8")}readFileRaw(t){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return at.readFileSync(e.fullHostPath)}let r=dt(t),s=Qt(this.root,r);if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s,o=i.compressed?(0,pr.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o}exists(t){let e=this.resolveMount(t);if(e)return at.existsSync(e.fullHostPath);try{return Qt(this.root,dt(t)),!0}catch{return!1}}chmod(t,e){Qt(this.root,dt(t)).mode=e}stat(t){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))throw new Error(`ENOENT: stat '${e.fullHostPath}'`);let a=at.statSync(e.fullHostPath),c=e.relPath.split("/").pop()??e.fullHostPath.split("/").pop()??"",l=a.mtime;return a.isDirectory()?{type:"directory",name:c,path:dt(t),mode:493,createdAt:a.birthtime,updatedAt:l,childrenCount:at.readdirSync(e.fullHostPath).length}:{type:"file",name:c,path:dt(t),mode:e.readOnly?292:420,createdAt:a.birthtime,updatedAt:l,compressed:!1,size:a.size}}let r=dt(t),s=Qt(this.root,r),i=r==="/"?"":rn.posix.basename(r);if(s.type==="file"){let a=s;return{type:"file",name:i,path:r,mode:a.mode,createdAt:a.createdAt,updatedAt:a.updatedAt,compressed:a.compressed,size:a.content.length}}let o=s;return{type:"directory",name:i,path:r,mode:o.mode,createdAt:o.createdAt,updatedAt:o.updatedAt,childrenCount:o.children.size}}list(t="/"){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))return[];try{return at.readdirSync(e.fullHostPath).sort()}catch{return[]}}let r=dt(t),s=Qt(this.root,r);if(s.type!=="directory")throw new Error(`Cannot list '${t}': not a directory.`);return Array.from(s.children.keys()).sort()}tree(t="/"){let e=dt(t),r=Qt(this.root,e);if(r.type!=="directory")throw new Error(`Cannot render tree for '${t}': not a directory.`);let s=t==="/"?"/":rn.posix.basename(e);return this.renderTreeLines(r,s)}renderTreeLines(t,e){let r=[e],s=Array.from(t.children.keys()).sort();for(let i=0;i<s.length;i++){let o=s[i],a=t.children.get(o),c=i===s.length-1,l=c?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",f=c?" ":"\u2502 ";if(r.push(`${l}${o}`),a.type==="directory"){let u=this.renderTreeLines(a,"").split(`
|
|
338
|
+
`,420),n.exists("/vmlinuz")||n.symlink(`/boot/vmlinuz-${e}`,"/vmlinuz"),n.exists("/vmlinuz.old")||n.symlink(`/boot/vmlinuz-${e}`,"/vmlinuz.old"),n.exists("/initrd.img")||n.symlink(`/boot/initrd.img-${e}`,"/initrd.img"),n.exists("/initrd.img.old")||n.symlink(`/boot/initrd.img-${e}`,"/initrd.img.old"),ce(n,"/snap"),ce(n,"/snap/bin"),ce(n,"/lost+found",448)}function mh(n,t,e,r,s,i=[]){dy(n,e,r),py(n,e,r),gy(n),my(n),Ay(n),yy(n),_y(n),Ey(n),by(n,r),hy(n,r),Zs(n,r,e,s,i),pc(n,t)}function Ah(n){return n==="1"||n==="true"}function yh(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function xy(){return Ah(process.env.DEV_MODE)||Ah(process.env.RENDER_PERF)}function nr(n){let t=xy();if(!t)return{enabled:t,mark:()=>{},done:()=>{}};let e=yh(),r=i=>{let o=yh()-e;console.log(`[perf][${n}] ${i}: ${o.toFixed(1)}ms`)};return{enabled:t,mark:r,done:(i="done")=>{r(i)}}}var Ch=require("node:events"),at=zt(require("node:fs"),1),rn=zt(require("node:path"),1),pr=require("node:zlib");var Ac=Buffer.from([86,70,83,33]),Sy=1,_h=1,Eh=2,gc=class{chunks=[];write(t){this.chunks.push(t)}writeUint8(t){let e=Buffer.allocUnsafe(1);e.writeUInt8(t,0),this.chunks.push(e)}writeUint16(t){let e=Buffer.allocUnsafe(2);e.writeUInt16LE(t,0),this.chunks.push(e)}writeUint32(t){let e=Buffer.allocUnsafe(4);e.writeUInt32LE(t,0),this.chunks.push(e)}writeFloat64(t){let e=Buffer.allocUnsafe(8);e.writeDoubleBE(t,0),this.chunks.push(e)}writeString(t){let e=Buffer.from(t,"utf8");this.writeUint16(e.length),this.chunks.push(e)}writeBytes(t){this.writeUint32(t.length),this.chunks.push(t)}toBuffer(){return Buffer.concat(this.chunks)}};function bh(n,t){if(t.type==="file"){let e=t;n.writeUint8(_h),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt.getTime()),n.writeFloat64(e.updatedAt.getTime()),n.writeUint8(e.compressed?1:0),n.writeBytes(e.content)}else{let e=t;n.writeUint8(Eh),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt.getTime()),n.writeFloat64(e.updatedAt.getTime());let r=Array.from(e.children.values());n.writeUint32(r.length);for(let s of r)bh(n,s)}}function xh(n){let t=new gc;return t.write(Ac),t.writeUint8(Sy),bh(t,n),t.toBuffer()}var mc=class{constructor(t){this.buf=t}buf;pos=0;readUint8(){return this.buf.readUInt8(this.pos++)}readUint16(){let t=this.buf.readUInt16LE(this.pos);return this.pos+=2,t}readUint32(){let t=this.buf.readUInt32LE(this.pos);return this.pos+=4,t}readFloat64(){let t=this.buf.readDoubleBE(this.pos);return this.pos+=8,t}readString(){let t=this.readUint16(),e=this.buf.toString("utf8",this.pos,this.pos+t);return this.pos+=t,e}readBytes(){let t=this.readUint32(),e=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,e}remaining(){return this.buf.length-this.pos}};function Sh(n){let t=n.readUint8(),e=n.readString(),r=n.readUint32(),s=new Date(n.readFloat64()),i=new Date(n.readFloat64());if(t===_h){let o=n.readUint8()===1,a=n.readBytes();return{type:"file",name:e,mode:r,createdAt:s,updatedAt:i,compressed:o,content:a}}if(t===Eh){let o=n.readUint32(),a=new Map;for(let c=0;c<o;c++){let l=Sh(n);a.set(l.name,l)}return{type:"directory",name:e,mode:r,createdAt:s,updatedAt:i,children:a}}throw new Error(`[VFS binary] Unknown node type: 0x${t.toString(16)}`)}function wh(n){if(n.length<5)throw new Error("[VFS binary] Buffer too short");if(!n.slice(0,4).equals(Ac))throw new Error("[VFS binary] Invalid magic \u2014 not a VFS binary snapshot");let e=new mc(n);for(let s=0;s<5;s++)e.readUint8();let r=Sh(e);if(r.type!=="directory")throw new Error("[VFS binary] Root node must be a directory");return r}function Ih(n){return n.length>=4&&n.slice(0,4).equals(Ac)}var eo=zt(require("node:path"),1);function dt(n){if(!n||n.trim()==="")return"/";let t=eo.posix.normalize(n.startsWith("/")?n:`/${n}`);return t===""?"/":t}function wy(n){return n.split("/").filter(Boolean)}function Qt(n,t){let e=dt(t);if(e==="/")return n;let r=wy(e),s=n;for(let i of r){if(s.type!=="directory")throw new Error(`Path '${e}' does not exist.`);let o=s.children.get(i);if(!o)throw new Error(`Path '${e}' does not exist.`);s=o}return s}function Xr(n,t,e,r){let s=dt(t);if(s==="/")throw new Error("Root path has no parent directory.");let i=eo.posix.dirname(s),o=eo.posix.basename(s);if(!o)throw new Error(`Invalid path '${t}'.`);e&&r(i);let a=Qt(n,i);if(a.type!=="directory")throw new Error(`Parent path '${i}' is not a directory.`);return{parent:a,name:o}}var yc=class n extends Ch.EventEmitter{root;mode;snapshotFile;mounts=new Map;static isBrowser=typeof process>"u"||typeof process.versions?.node>"u";constructor(t={}){if(super(),this.mode=t.mode??"memory",this.mode==="fs"){if(!t.snapshotPath)throw new Error('VirtualFileSystem: "snapshotPath" is required when mode is "fs".');this.snapshotFile=rn.resolve(t.snapshotPath,"vfs-snapshot.vfsb")}else this.snapshotFile=null;this.root=this.makeDir("",493)}makeDir(t,e){let r=new Date;return{type:"directory",name:t,mode:e,createdAt:r,updatedAt:r,children:new Map}}makeFile(t,e,r,s){let i=new Date;return{type:"file",name:t,content:e,mode:r,compressed:s,createdAt:i,updatedAt:i}}mkdirRecursive(t,e){let r=dt(t);if(r==="/")return;let s=r.split("/").filter(Boolean),i=this.root,o="";for(let a of s){o+=`/${a}`;let c=i.children.get(a);if(!c)c=this.makeDir(a,e),i.children.set(a,c),this.emit("dir:create",{path:o,mode:e});else if(c.type!=="directory")throw new Error(`Cannot create directory '${o}': path is a file.`);i=c}}async restoreMirror(){if(!(this.mode!=="fs"||!this.snapshotFile)&&at.existsSync(this.snapshotFile))try{let t=at.readFileSync(this.snapshotFile);if(Ih(t))this.root=wh(t);else{let e=JSON.parse(t.toString("utf8"));this.root=this.deserializeDir(e.root,""),console.info("[VirtualFileSystem] Migrating legacy JSON snapshot to binary format.")}this.emit("snapshot:restore",{path:this.snapshotFile})}catch(t){console.warn(`[VirtualFileSystem] Could not restore snapshot from ${this.snapshotFile}:`,t instanceof Error?t.message:String(t))}}async flushMirror(){if(this.mode!=="fs"||!this.snapshotFile){this.emit("mirror:flush");return}let t=rn.dirname(this.snapshotFile);at.mkdirSync(t,{recursive:!0});let e=xh(this.root);at.writeFileSync(this.snapshotFile,e),this.emit("mirror:flush",{path:this.snapshotFile})}getMode(){return this.mode}getSnapshotPath(){return this.snapshotFile}mount(t,e,{readOnly:r=!0}={}){if(n.isBrowser)return;let s=dt(t),i=rn.resolve(e);if(!at.existsSync(i))throw new Error(`VirtualFileSystem.mount: host path does not exist: "${i}"`);if(!at.statSync(i).isDirectory())throw new Error(`VirtualFileSystem.mount: host path is not a directory: "${i}"`);this.mkdir(s),this.mounts.set(s,{hostPath:i,readOnly:r}),this.emit("mount",{vPath:s,hostPath:i,readOnly:r})}unmount(t){let e=dt(t);this.mounts.delete(e)&&this.emit("unmount",{vPath:e})}getMounts(){return[...this.mounts.entries()].map(([t,e])=>({vPath:t,...e}))}resolveMount(t){let e=dt(t),r=[...this.mounts.entries()].sort(([s],[i])=>i.length-s.length);for(let[s,i]of r)if(e===s||e.startsWith(`${s}/`)){let o=e.slice(s.length).replace(/^\//,""),a=o?rn.join(i.hostPath,o):i.hostPath;return{hostPath:i.hostPath,readOnly:i.readOnly,relPath:o,fullHostPath:a}}return null}mkdir(t,e=493){let r=dt(t),s=(()=>{try{return Qt(this.root,r)}catch{return null}})();if(s&&s.type!=="directory")throw new Error(`Cannot create directory '${r}': path is a file.`);this.mkdirRecursive(r,e)}writeFile(t,e,r={}){let s=this.resolveMount(t);if(s){if(s.readOnly)throw new Error(`EROFS: read-only file system, open '${s.fullHostPath}'`);let p=rn.dirname(s.fullHostPath);at.existsSync(p)||at.mkdirSync(p,{recursive:!0}),at.writeFileSync(s.fullHostPath,Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"));return}let i=dt(t),{parent:o,name:a}=Xr(this.root,i,!0,p=>this.mkdirRecursive(p,493)),c=o.children.get(a);if(c?.type==="directory")throw new Error(`Cannot write file '${i}': path is a directory.`);let l=Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"),f=r.compress??!1,u=f?(0,pr.gzipSync)(l):l,h=r.mode??420;if(c){let p=c;p.content=u,p.compressed=f,p.mode=h,p.updatedAt=new Date}else o.children.set(a,this.makeFile(a,u,h,f));this.emit("file:write",{path:i,size:u.length})}readFile(t){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return at.readFileSync(e.fullHostPath,"utf8")}let r=dt(t),s=Qt(this.root,r);if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s,o=i.compressed?(0,pr.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o.toString("utf8")}readFileRaw(t){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return at.readFileSync(e.fullHostPath)}let r=dt(t),s=Qt(this.root,r);if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s,o=i.compressed?(0,pr.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o}exists(t){let e=this.resolveMount(t);if(e)return at.existsSync(e.fullHostPath);try{return Qt(this.root,dt(t)),!0}catch{return!1}}chmod(t,e){Qt(this.root,dt(t)).mode=e}stat(t){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))throw new Error(`ENOENT: stat '${e.fullHostPath}'`);let a=at.statSync(e.fullHostPath),c=e.relPath.split("/").pop()??e.fullHostPath.split("/").pop()??"",l=a.mtime;return a.isDirectory()?{type:"directory",name:c,path:dt(t),mode:493,createdAt:a.birthtime,updatedAt:l,childrenCount:at.readdirSync(e.fullHostPath).length}:{type:"file",name:c,path:dt(t),mode:e.readOnly?292:420,createdAt:a.birthtime,updatedAt:l,compressed:!1,size:a.size}}let r=dt(t),s=Qt(this.root,r),i=r==="/"?"":rn.posix.basename(r);if(s.type==="file"){let a=s;return{type:"file",name:i,path:r,mode:a.mode,createdAt:a.createdAt,updatedAt:a.updatedAt,compressed:a.compressed,size:a.content.length}}let o=s;return{type:"directory",name:i,path:r,mode:o.mode,createdAt:o.createdAt,updatedAt:o.updatedAt,childrenCount:o.children.size}}list(t="/"){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))return[];try{return at.readdirSync(e.fullHostPath).sort()}catch{return[]}}let r=dt(t),s=Qt(this.root,r);if(s.type!=="directory")throw new Error(`Cannot list '${t}': not a directory.`);return Array.from(s.children.keys()).sort()}tree(t="/"){let e=dt(t),r=Qt(this.root,e);if(r.type!=="directory")throw new Error(`Cannot render tree for '${t}': not a directory.`);let s=t==="/"?"/":rn.posix.basename(e);return this.renderTreeLines(r,s)}renderTreeLines(t,e){let r=[e],s=Array.from(t.children.keys()).sort();for(let i=0;i<s.length;i++){let o=s[i],a=t.children.get(o),c=i===s.length-1,l=c?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",f=c?" ":"\u2502 ";if(r.push(`${l}${o}`),a.type==="directory"){let u=this.renderTreeLines(a,"").split(`
|
|
338
339
|
`).slice(1).map(h=>`${f}${h}`);r.push(...u)}}return r.join(`
|
|
339
340
|
`)}getUsageBytes(t="/"){return this.computeUsage(Qt(this.root,dt(t)))}computeUsage(t){if(t.type==="file")return t.content.length;let e=0;for(let r of t.children.values())e+=this.computeUsage(r);return e}compressFile(t){let e=Qt(this.root,dt(t));if(e.type!=="file")throw new Error(`Cannot compress '${t}': not a file.`);let r=e;r.compressed||(r.content=(0,pr.gzipSync)(r.content),r.compressed=!0,r.updatedAt=new Date)}decompressFile(t){let e=Qt(this.root,dt(t));if(e.type!=="file")throw new Error(`Cannot decompress '${t}': not a file.`);let r=e;r.compressed&&(r.content=(0,pr.gunzipSync)(r.content),r.compressed=!1,r.updatedAt=new Date)}symlink(t,e){let r=dt(e),s=t.startsWith("/")?dt(t):t,{parent:i,name:o}=Xr(this.root,r,!0,c=>this.mkdirRecursive(c,493)),a={type:"file",name:o,content:Buffer.from(s,"utf8"),mode:41471,compressed:!1,createdAt:new Date,updatedAt:new Date};i.children.set(o,a),this.emit("symlink:create",{link:r,target:s})}isSymlink(t){try{let e=Qt(this.root,dt(t));return e.type==="file"&&e.mode===41471}catch{return!1}}resolveSymlink(t,e=8){let r=dt(t);for(let s=0;s<e;s++){try{let i=Qt(this.root,r);if(i.type==="file"&&i.mode===41471){let o=i.content.toString("utf8");r=o.startsWith("/")?o:dt(rn.posix.join(rn.posix.dirname(r),o));continue}}catch{break}return r}throw new Error(`Too many levels of symbolic links: ${t}`)}remove(t,e={}){let r=this.resolveMount(t);if(r){if(r.readOnly)throw new Error(`EROFS: read-only file system, unlink '${r.fullHostPath}'`);if(!at.existsSync(r.fullHostPath))throw new Error(`ENOENT: no such file or directory, unlink '${r.fullHostPath}'`);at.statSync(r.fullHostPath).isDirectory()?at.rmSync(r.fullHostPath,{recursive:e.recursive??!1}):at.unlinkSync(r.fullHostPath);return}let s=dt(t);if(s==="/")throw new Error("Cannot remove root directory.");let i=Qt(this.root,s);if(i.type==="directory"){let c=i;if(!e.recursive&&c.children.size>0)throw new Error(`Directory '${s}' is not empty. Use recursive option.`)}let{parent:o,name:a}=Xr(this.root,s,!1,()=>{});o.children.delete(a),this.emit("node:remove",{path:s})}move(t,e){let r=dt(t),s=dt(e);if(r==="/"||s==="/")throw new Error("Cannot move root directory.");let i=Qt(this.root,r);if(this.exists(s))throw new Error(`Destination '${s}' already exists.`);this.mkdirRecursive(rn.posix.dirname(s),493);let{parent:o,name:a}=Xr(this.root,s,!1,()=>{}),{parent:c,name:l}=Xr(this.root,r,!1,()=>{});c.children.delete(l),i.name=a,o.children.set(a,i)}toSnapshot(){return{root:this.serializeDir(this.root)}}serializeDir(t){let e=[];for(let r of t.children.values())e.push(r.type==="file"?this.serializeFile(r):this.serializeDir(r));return{type:"directory",name:t.name,mode:t.mode,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),children:e}}serializeFile(t){return{type:"file",name:t.name,mode:t.mode,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),compressed:t.compressed,contentBase64:t.content.toString("base64")}}static fromSnapshot(t){let e=new n;return e.root=e.deserializeDir(t.root,""),e}importSnapshot(t){this.root=this.deserializeDir(t.root,""),this.emit("snapshot:import")}deserializeDir(t,e){let r={type:"directory",name:e,mode:t.mode,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt),children:new Map};for(let s of t.children)if(s.type==="file"){let i=s;r.children.set(i.name,{type:"file",name:i.name,mode:i.mode,createdAt:new Date(i.createdAt),updatedAt:new Date(i.updatedAt),compressed:i.compressed,content:Buffer.from(i.contentBase64,"base64")})}else{let i=this.deserializeDir(s,s.name);r.children.set(s.name,i)}return r}},kh=yc;var _c=[{name:"vim",version:"2:9.0.1378-2",section:"editors",description:"Vi IMproved - enhanced vi editor",shortDesc:"Vi IMproved",installedSizeKb:3812,files:[{path:"/usr/bin/vim",content:`#!/bin/sh
|
|
340
341
|
echo 'vim: use nano for editing in this environment'
|
|
@@ -437,7 +438,7 @@ echo 'neofetch: virtual stub'
|
|
|
437
438
|
`),exitCode:0}}remove(t,e={}){let r=[],s=[];for(let i of t){let o=this.installed.get(i.toLowerCase());o?s.push(o):r.push(`Package '${i}' is not installed, so not removed`)}if(s.length===0)return{output:r.join(`
|
|
438
439
|
`)||"Nothing to remove.",exitCode:0};e.quiet||r.push("Reading package lists... Done","Building dependency tree... Done","The following packages will be REMOVED:",` ${s.map(i=>i.name).join(" ")}`,`0 upgraded, 0 newly installed, ${s.length} to remove and 0 not upgraded.`);for(let i of s){e.quiet||r.push(`Removing ${i.name} (${i.version}) ...`);for(let a of i.files)if(!(!e.purge&&(a.startsWith("/etc/")||a.endsWith(".conf"))))try{this.vfs.exists(a)&&this.vfs.remove(a)}catch{}this.findInRegistry(i.name)?.onRemove?.(this.vfs),this.installed.delete(i.name),this.log(`remove ${i.name} ${i.version}`)}return this.aptLog("remove",s.map(i=>i.name)),this.persist(),{output:r.join(`
|
|
439
440
|
`),exitCode:0}}search(t){let e=t.toLowerCase();return _c.filter(r=>r.name.includes(e)||r.description.toLowerCase().includes(e)||(r.shortDesc??"").toLowerCase().includes(e)).sort((r,s)=>r.name.localeCompare(s.name))}show(t){let e=this.findInRegistry(t);if(!e)return null;let r=this.installed.get(t);return[`Package: ${e.name}`,`Version: ${e.version}`,`Architecture: ${e.architecture??"amd64"}`,`Maintainer: ${e.maintainer??"Fortune Maintainers <pkg@fortune.local>"}`,`Installed-Size: ${e.installedSizeKb??0}`,`Depends: ${(e.depends??[]).join(", ")||"(none)"}`,`Section: ${e.section??"misc"}`,"Priority: optional",`Description: ${e.description}`,`Status: ${r?"install ok installed":"install ok not-installed"}`].join(`
|
|
440
|
-
`)}};var xn=require("node:crypto"),Bh=require("node:events"),Rh=zt(require("node:path"),1);function
|
|
441
|
+
`)}};var xn=require("node:crypto"),Bh=require("node:events"),Rh=zt(require("node:path"),1);function Iy(){let n=process.env.SSH_MIMIC_FAST_PASSWORD_HASH;return!!n&&!["0","false","no","off"].includes(n.toLowerCase())}var Pt=nr("VirtualUserManager"),no=class n extends Bh.EventEmitter{constructor(e,r=!0){super();this.vfs=e;this.autoSudoForNewUsers=r;Pt.mark("constructor")}vfs;autoSudoForNewUsers;static recordCache=new Map;static fastPasswordHash=Iy();usersPath="/etc/htpasswd";sudoersPath="/etc/sudoers";quotasPath="/etc/quotas";authDirPath="/.virtual-env-js/.auth";users=new Map;sudoers=new Set;quotas=new Map;activeSessions=new Map;nextTty=0;async initialize(){Pt.mark("initialize"),this.loadFromVfs(),this.loadSudoersFromVfs(),this.loadQuotasFromVfs();let e=!1;this.users.has("root")||(this.users.set("root",this.createRecord("root","")),e=!0),this.sudoers.add("root"),e&&await this.persist(),this.emit("initialized")}async setQuotaBytes(e,r){if(Pt.mark("setQuotaBytes"),this.validateUsername(e),!this.users.has(e))throw new Error(`quota: user '${e}' does not exist`);if(!Number.isFinite(r)||r<0)throw new Error("quota: maxBytes must be a non-negative number");this.quotas.set(e,Math.floor(r)),await this.persist()}async clearQuota(e){Pt.mark("clearQuota"),this.validateUsername(e),this.quotas.delete(e),await this.persist()}getQuotaBytes(e){return Pt.mark("getQuotaBytes"),this.quotas.get(e)??null}getUsageBytes(e){Pt.mark("getUsageBytes");let r=`/home/${e}`;return this.vfs.exists(r)?this.vfs.getUsageBytes(r):0}assertWriteWithinQuota(e,r,s){Pt.mark("assertWriteWithinQuota");let i=this.quotas.get(e);if(i===void 0)return;let o=vh(r),a=vh(`/home/${e}`);if(!(o===a||o.startsWith(`${a}/`)))return;let l=this.getUsageBytes(e),f=0;if(this.vfs.exists(o)){let p=this.vfs.stat(o);p.type==="file"&&(f=p.size)}let u=Buffer.isBuffer(s)?s.length:Buffer.byteLength(s,"utf8"),h=l-f+u;if(h>i)throw new Error(`quota exceeded for '${e}': ${h}/${i} bytes`)}verifyPassword(e,r){Pt.mark("verifyPassword");let s=this.users.get(e);if(!s)return this.hashPassword(r,""),!1;let i=this.hashPassword(r,s.salt),o=s.passwordHash;try{let a=Buffer.from(i,"hex"),c=Buffer.from(o,"hex");return a.length!==c.length?!1:(0,xn.timingSafeEqual)(a,c)}catch{return i===o}}async addUser(e,r){if(Pt.mark("addUser"),this.validateUsername(e),this.validatePassword(r),this.users.has(e))return;this.users.set(e,this.createRecord(e,r)),this.autoSudoForNewUsers&&this.sudoers.add(e);let s=`/home/${e}`;this.vfs.exists(s)||(this.vfs.mkdir(s,493),this.vfs.writeFile(`${s}/README.txt`,`Welcome to the virtual environment, ${e}`)),await this.persist(),this.emit("user:add",{username:e})}getPasswordHash(e){Pt.mark("getPasswordHash");let r=this.users.get(e);return r?r.passwordHash:null}async setPassword(e,r){if(Pt.mark("setPassword"),this.validateUsername(e),this.validatePassword(r),!this.users.has(e))throw new Error(`passwd: user '${e}' does not exist`);this.users.set(e,this.createRecord(e,r)),await this.persist()}async deleteUser(e){if(Pt.mark("deleteUser"),this.validateUsername(e),e==="root")throw new Error("deluser: cannot delete root");if(!this.users.delete(e))throw new Error(`deluser: user '${e}' does not exist`);this.sudoers.delete(e),this.emit("user:delete",{username:e}),await this.persist()}isSudoer(e){return Pt.mark("isSudoer"),this.sudoers.has(e)}async addSudoer(e){if(Pt.mark("addSudoer"),this.validateUsername(e),!this.users.has(e))throw new Error(`sudoers: user '${e}' does not exist`);this.sudoers.add(e),await this.persist()}async removeSudoer(e){if(Pt.mark("removeSudoer"),this.validateUsername(e),e==="root")throw new Error("sudoers: cannot remove root");this.sudoers.delete(e),await this.persist()}registerSession(e,r){Pt.mark("registerSession");let s={id:(0,xn.randomUUID)(),username:e,tty:`pts/${this.nextTty++}`,remoteAddress:r,startedAt:new Date().toISOString()};return this.activeSessions.set(s.id,s),this.emit("session:register",{sessionId:s.id,username:e,remoteAddress:r}),s}unregisterSession(e){if(Pt.mark("unregisterSession"),!e)return;let r=this.activeSessions.get(e);this.activeSessions.delete(e),r&&this.emit("session:unregister",{sessionId:e,username:r.username}),this.activeSessions.delete(e)}updateSession(e,r,s){if(Pt.mark("updateSession"),!e)return;let i=this.activeSessions.get(e);i&&this.activeSessions.set(e,{...i,username:r,remoteAddress:s})}listActiveSessions(){return Pt.mark("listActiveSessions"),Array.from(this.activeSessions.values()).sort((e,r)=>e.startedAt.localeCompare(r.startedAt))}listUsers(){return Array.from(this.users.keys()).sort()}loadFromVfs(){if(this.users.clear(),!this.vfs.exists(this.usersPath))return;let e=this.vfs.readFile(this.usersPath);for(let r of e.split(`
|
|
441
442
|
`)){let s=r.trim();if(s.length===0)continue;let i=s.split(":");if(i.length<3)continue;let[o,a,c]=i;!o||!a||!c||this.users.set(o,{username:o,salt:a,passwordHash:c})}}loadSudoersFromVfs(){if(this.sudoers.clear(),!this.vfs.exists(this.sudoersPath))return;let e=this.vfs.readFile(this.sudoersPath);for(let r of e.split(`
|
|
442
443
|
`)){let s=r.trim();s.length>0&&this.sudoers.add(s)}}loadQuotasFromVfs(){if(this.quotas.clear(),!this.vfs.exists(this.quotasPath))return;let e=this.vfs.readFile(this.quotasPath);for(let r of e.split(`
|
|
443
444
|
`)){let s=r.trim();if(s.length===0)continue;let[i,o]=s.split(":"),a=Number.parseInt(o??"",10);!i||!Number.isFinite(a)||a<0||this.quotas.set(i,a)}}async persist(){this.vfs.exists(this.authDirPath)||this.vfs.mkdir(this.authDirPath,448);let e=Array.from(this.users.values()).sort((o,a)=>o.username.localeCompare(a.username)).map(o=>[o.username,o.salt,o.passwordHash].join(":")).join(`
|
|
@@ -450,7 +451,7 @@ echo 'neofetch: virtual stub'
|
|
|
450
451
|
`).replace(/\r/g,`
|
|
451
452
|
`).replace(/\n/g,`\r
|
|
452
453
|
`)}function Ph(n,t){let e=Number.isFinite(t.cols)&&t.cols>0?Math.floor(t.cols):80,r=Number.isFinite(t.rows)&&t.rows>0?Math.floor(t.rows):24;return`stty cols ${e} rows ${r} 2>/dev/null; ${n}`}function Th(n,t){return!t||t.trim()===""||t==="."?n:t.startsWith("/")?ro.posix.normalize(t):ro.posix.normalize(ro.posix.join(n,t))}async function Lh(n){try{let e=(await(0,Nh.readFile)(`/proc/${n}/task/${n}/children`,"utf8")).trim().split(/\s+/).filter(Boolean).map(s=>Number.parseInt(s,10)).filter(s=>Number.isInteger(s)&&s>0),r=await Promise.all(e.map(s=>Lh(s)));return[...e,...r.flat()]}catch{return[]}}async function $h(n=process.pid){let t=await Lh(n),e=Array.from(new Set(t)).sort((r,s)=>r-s);return e.length===0?null:e.join(",")}function Uh(n,t,e){let r=Ph(n,t),s=(0,Dh.spawn)("script",["-qfec",r,"/dev/null"],{stdio:["pipe","pipe","pipe"],env:{...process.env,TERM:process.env.TERM??"xterm-256color"}});return s.stdout.on("data",i=>{e.write(i.toString("utf8"))}),s.stderr.on("data",i=>{e.write(i.toString("utf8"))}),s}function Oh(n,t,e){return Uh(`nano -- ${Ec(n)}`,t,e)}function Mh(n,t,e){return Uh(`htop -p ${Ec(n)}`,t,e)}function Fh(n,t,e){let r=[`Linux ${n} ${t.kernel} ${t.arch}`,"","The programs included with the Fortune GNU/Linux system are free software;","the exact distribution terms for each program are described in the","individual files in /usr/share/doc/*/copyright.","","Fortune GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent","permitted by applicable law."];if(e){let s=new Date(e.at),i=Number.isNaN(s.getTime())?e.at:Xs(s);r.push(`Last login: ${i} from ${e.from||"unknown"}`)}return r.push(""),`${r.map(s=>`${s}\r
|
|
453
|
-
`).join("")}`}function Hh(n,t,e){let r=n==="root",s=r?"\x1B[31;1m":"\x1B[35;1m",i="\x1B[37;1m",o="\x1B[34;1m",a="\x1B[0m";return`${i}[${s}${n}${i}@${o}${t}${a} ${e}${i}]${a}${r?"#":"$"} `}function Qh(n,t,e,r,s,i="unknown",o={cols:80,rows:24},a){let c="",l=0,f=
|
|
454
|
+
`).join("")}`}function Hh(n,t,e){let r=n==="root",s=r?"\x1B[31;1m":"\x1B[35;1m",i="\x1B[37;1m",o="\x1B[34;1m",a="\x1B[0m";return`${i}[${s}${n}${i}@${o}${t}${a} ${e}${i}]${a}${r?"#":"$"} `}function Qh(n,t,e,r,s,i="unknown",o={cols:80,rows:24},a){let c="",l=0,f=Cy(a.vfs,e),u=null,h="",p=`/home/${e}`,y=zr(e,r),_=null,x=null,S=()=>{let N=`/home/${e}`,L=p===N?"~":bc.posix.basename(p)||"/";return Hh(e,r,L)},R=Array.from(new Set(lc())).sort();console.log(`[${s}] Shell started for user '${e}' at ${i}`),(async()=>{let N=`/home/${e}/.bashrc`;if(a.vfs.exists(N))try{let L=a.vfs.readFile(N);for(let K of L.split(`
|
|
454
455
|
`)){let ee=K.trim();!ee||ee.startsWith("#")||await St(ee,e,r,"shell",p,a,void 0,y)}}catch{}})();function H(){let N=S();t.write(`\r${N}${c}\x1B[K`);let L=c.length-l;L>0&&t.write(`\x1B[${L}D`)}function C(){t.write("\r\x1B[K")}function U(N){x={...N,buffer:""},C(),t.write(N.prompt)}async function Q(N){if(!x)return;let L=x;if(x=null,!N){t.write(`\r
|
|
455
456
|
Sorry, try again.\r
|
|
456
457
|
`),H();return}if(!L.commandLine){e=L.targetUser,L.loginShell&&(p=`/home/${e}`),a.users.updateSession(s,e,i),t.write(`\r
|
|
@@ -478,13 +479,13 @@ Sorry, try again.\r
|
|
|
478
479
|
`),ue.length>0){let ie=await Promise.resolve(St(ue,e,r,"shell",p,a,void 0,y));if(Y(ue),ie.openEditor){await b(ie.openEditor.targetPath,ie.openEditor.initialContent,ie.openEditor.tempPath);return}if(ie.openHtop){await w();return}if(ie.sudoChallenge){U(ie.sudoChallenge);return}if(ie.clearScreen&&t.write("\x1B[2J\x1B[H"),ie.stdout&&t.write(`${Fi(ie.stdout)}\r
|
|
479
480
|
`),ie.stderr&&t.write(`${Fi(ie.stderr)}\r
|
|
480
481
|
`),ie.closeSession){t.write(`logout\r
|
|
481
|
-
`),t.exit(ie.exitCode??0),t.end();return}ie.nextCwd&&(p=ie.nextCwd),ie.switchUser&&(e=ie.switchUser,p=ie.nextCwd??`/home/${e}`,a.users.updateSession(s,e,i),c="",l=0),await a.vfs.flushMirror()}H();continue}if(ee==="\x7F"||ee==="\b"){l>0&&(c=`${c.slice(0,l-1)}${c.slice(l)}`,l-=1,H());continue}v(ee)}}),t.on("close",()=>{_&&(_.process.kill("SIGTERM"),_=null)})}function
|
|
482
|
-
`).map(s=>s.trim()).filter(s=>s.length>0):(n.writeFile(e,""),[])}function
|
|
482
|
+
`),t.exit(ie.exitCode??0),t.end();return}ie.nextCwd&&(p=ie.nextCwd),ie.switchUser&&(e=ie.switchUser,p=ie.nextCwd??`/home/${e}`,a.users.updateSession(s,e,i),c="",l=0),await a.vfs.flushMirror()}H();continue}if(ee==="\x7F"||ee==="\b"){l>0&&(c=`${c.slice(0,l-1)}${c.slice(l)}`,l-=1,H());continue}v(ee)}}),t.on("close",()=>{_&&(_.process.kill("SIGTERM"),_=null)})}function Cy(n,t){let e=`/home/${t}/.bash_history`;return n.exists(e)?n.readFile(e).split(`
|
|
483
|
+
`).map(s=>s.trim()).filter(s=>s.length>0):(n.writeFile(e,""),[])}function ky(n){return typeof n=="object"&&n!==null&&"vfsInstance"in n&&qh(n.vfsInstance)}function qh(n){if(typeof n!="object"||n===null)return!1;let t=n;return typeof t.restoreMirror=="function"&&typeof t.flushMirror=="function"&&typeof t.writeFile=="function"&&typeof t.readFile=="function"&&typeof t.mkdir=="function"&&typeof t.exists=="function"&&typeof t.stat=="function"&&typeof t.list=="function"&&typeof t.remove=="function"&&typeof t.copy=="function"&&typeof t.move=="function"&&typeof t.touch=="function"}var vy={kernel:"1.0.0+itsrealfortune+1-amd64",os:"Fortune GNU/Linux x64",arch:"x86_64"},Hi=nr("VirtualShell");function By(){let n=process.env.SSH_MIMIC_AUTO_SUDO_NEW_USERS;return n?!["0","false","no","off"].includes(n.toLowerCase()):!0}var gr=class extends Wh.EventEmitter{vfs;users;packageManager;hostname;properties;startTime;initialized;constructor(t,e,r){super(),Hi.mark("constructor"),this.hostname=t,this.properties=e||vy,this.startTime=Date.now(),qh(r)?this.vfs=r:ky(r)?this.vfs=r.vfsInstance:this.vfs=new kh(r??{}),this.users=new no(this.vfs,By()),this.packageManager=new to(this.vfs,this.users);let s=this.vfs,i=this.users,o=this.packageManager,a=this.properties,c=this.hostname,l=this.startTime;this.initialized=(async()=>{await s.restoreMirror(),await i.initialize(),mh(s,i,c,a,l),o.load(),this.emit("initialized")})()}async ensureInitialized(){Hi.mark("ensureInitialized"),await this.initialized}addCommand(t,e,r){let s=t.trim().toLowerCase();if(s.length===0||/\s/.test(s))throw new Error("Command name must be non-empty and contain no spaces");ac(cc(s,e,r))}executeCommand(t,e,r){Hi.mark("executeCommand"),St(t,e,this.hostname,"shell",r,this),this.emit("command",{command:t,user:e,cwd:r})}startInteractiveSession(t,e,r,s,i){Hi.mark("startInteractiveSession"),this.emit("session:start",{user:e,sessionId:r,remoteAddress:s}),Qh(this.properties,t,e,this.hostname,r,s,i,this),this.refreshProcSessions()}refreshProcFs(){Zs(this.vfs,this.properties,this.hostname,this.startTime,this.users.listActiveSessions())}mount(t,e,r={}){this.vfs.mount(t,e,r)}unmount(t){this.vfs.unmount(t)}getMounts(){return this.vfs.getMounts()}refreshProcSessions(){Zs(this.vfs,this.properties,this.hostname,this.startTime,this.users.listActiveSessions())}syncPasswd(){pc(this.vfs,this.users)}getVfs(){return this?.vfs??null}getUsers(){return this?.users??null}getHostname(){return this?.hostname}writeFileAsUser(t,e,r){Hi.mark("writeFileAsUser"),this.users.assertWriteWithinQuota(t,e,r),this.vfs.writeFile(e,r)}};function Kh(n){return n.replace(/\r\n/g,`
|
|
483
484
|
`).replace(/\r/g,`
|
|
484
485
|
`).replace(/\n/g,`\r
|
|
485
486
|
`)}function Vh(n,t,e,r,s){Promise.resolve(St(t,e,r,"exec",`/home/${e}`,s,void 0,zr(e,r))).then(i=>{i.stdout&&n.write(`${Kh(i.stdout)}\r
|
|
486
487
|
`),i.stderr&&n.stderr.write(`${Kh(i.stderr)}\r
|
|
487
488
|
`),n.exit(i.exitCode??0),s.vfs.flushMirror(),n.end()}).catch(i=>{console.error("Exec error:",i),n.stderr.write(`Error: ${String(i)}\r
|
|
488
|
-
`),n.exit(1),n.end()})}var Gh=require("node:crypto"),rr=require("node:fs"),io=require("node:path");function xc(n=process.cwd()){let t=(0,io.resolve)(n,".ssh-mimic","host_rsa");if((0,rr.existsSync)(t))return(0,rr.readFileSync)(t,"utf8");let e=(0,Gh.generateKeyPairSync)("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs1",format:"pem"},publicKeyEncoding:{type:"pkcs1",format:"pem"}}).privateKey;return(0,rr.mkdirSync)((0,io.dirname)(t),{recursive:!0}),(0,rr.writeFileSync)(t,e,{mode:384}),e}var
|
|
489
|
+
`),n.exit(1),n.end()})}var Gh=require("node:crypto"),rr=require("node:fs"),io=require("node:path");function xc(n=process.cwd()){let t=(0,io.resolve)(n,".ssh-mimic","host_rsa");if((0,rr.existsSync)(t))return(0,rr.readFileSync)(t,"utf8");let e=(0,Gh.generateKeyPairSync)("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs1",format:"pem"},publicKeyEncoding:{type:"pkcs1",format:"pem"}}).privateKey;return(0,rr.mkdirSync)((0,io.dirname)(t),{recursive:!0}),(0,rr.writeFileSync)(t,e,{mode:384}),e}var Ry=zt(Za(),1);var Sc=!!process.env.DEV_MODE,JS=Sc?console.log.bind(console):()=>{},ZS=Sc?console.warn.bind(console):()=>{},ew=Sc?console.error.bind(console):()=>{};var tw=nr("SftpMimic");var wc=nr("SshMimic"),Ny=!!process.env.DEV_MODE,zh=Ny?console.log.bind(console):()=>{},so=class extends Yh.EventEmitter{port;server;shell;maxAuthAttempts;lockoutDurationMs;authAttempts=new Map;constructor({port:t,hostname:e="typescript-vm",shell:r=new gr(e),maxAuthAttempts:s=5,lockoutDurationMs:i=6e4}){super(),wc.mark("constructor"),this.port=t,this.server=null,this.shell=r,this.maxAuthAttempts=s,this.lockoutDurationMs=i}isLockedOut(t){let e=this.authAttempts.get(t);return e?Date.now()<e.lockedUntil?!0:(e.lockedUntil>0&&this.authAttempts.delete(t),!1):!1}recordFailure(t){let e=this.authAttempts.get(t)??{attempts:0,lockedUntil:0};e.attempts+=1,e.attempts>=this.maxAuthAttempts&&(e.lockedUntil=Date.now()+this.lockoutDurationMs,this.emit("auth:lockout",{ip:t,until:new Date(e.lockedUntil)})),this.authAttempts.set(t,e)}recordSuccess(t){this.authAttempts.delete(t)}ensureHomeDir(t){let e=`/home/${t}`;this.shell.vfs.exists(e)||(this.shell.vfs.mkdir(e,493),this.shell.vfs.writeFile(`${e}/README.txt`,`Welcome to ${this.shell.hostname}
|
|
489
490
|
`),this.shell.vfs.flushMirror())}async start(){wc.mark("start");let t=this.shell,e=xc();return await t.ensureInitialized(),this.server=new jh.Server({hostKeys:[e],ident:`SSH-2.0-${t.hostname}`},r=>{let s="root",i="unknown",o=null;this.emit("client:connect"),r.on("authentication",a=>{let c=a.username||"root";if(i=a.ip??i,this.isLockedOut(i)){this.emit("auth:failure",{username:c,remoteAddress:i,reason:"lockout"}),a.reject();return}if(a.method==="password"){if(!t.users.hasPassword(c)){s=c,o=t.users.registerSession(s,i).id,this.recordSuccess(i),this.emit("auth:success",{username:s,remoteAddress:i}),this.ensureHomeDir(s),a.accept();return}if(!a.password||a.password===""||!t.users.verifyPassword(c,a.password)){this.recordFailure(i),this.emit("auth:failure",{username:c,remoteAddress:i}),a.reject();return}s=c,o=t.users.registerSession(s,i).id,this.recordSuccess(i),this.emit("auth:success",{username:s,remoteAddress:i}),this.ensureHomeDir(s),a.accept();return}if(a.method==="publickey"){let l=t.users.getAuthorizedKeys(c);if(l.length===0){a.reject();return}let f=a.key;if(!l.some(h=>h.algo===f.algo&&h.data.equals(f.data))){this.recordFailure(i),this.emit("auth:failure",{username:c,remoteAddress:i,method:"publickey"}),a.reject();return}a.signature&&(s=c,o=t.users.registerSession(s,i).id,this.recordSuccess(i),this.emit("auth:success",{username:s,remoteAddress:i,method:"publickey"}),this.ensureHomeDir(s)),a.accept();return}a.reject(["password","publickey"])}),r.on("close",()=>{t.users.unregisterSession(o),this.emit("client:disconnect",{user:s}),o=null}),r.on("ready",()=>{r.on("session",a=>{let c=a(),l={cols:80,rows:24};c.on("pty",(f,u,h)=>{l.cols=h?.cols??l.cols,l.rows=h?.rows??l.rows,f()}),c.on("window-change",(f,u,h)=>{l.cols=h?.cols??l.cols,l.rows=h?.rows??l.rows}),c.on("shell",f=>{let u=f();t?.startInteractiveSession(u,s,o,i,l)}),c.on("exec",(f,u,h)=>{let p=f();p&&Vh(p,h.command.trim(),s,t.hostname,t)})})})}),new Promise((r,s)=>{this.server?.once("error",i=>s(i)),this.server?.listen(this.port,"0.0.0.0",()=>{zh(`SSH Mimic listening on port ${this.port}`),this.emit("start",{port:this.port}),r(this.port)})})}stop(){wc.mark("stop"),this.server&&this.server.close(()=>{zh("SSH Mimic stopped"),this.emit("stop")})}clearLockout(t){this.authAttempts.delete(t)}};var Xh=process.env.SSH_MIMIC_HOSTNAME??"typescript-vm",Jh=new gr(Xh,void 0,{mode:"fs",snapshotPath:".vfs"});Jh.addCommand("demo",[],()=>({stdout:"This is a demo command. It does nothing useful.",exitCode:0}));new so({port:2222,hostname:Xh,shell:Jh}).start().catch(n=>{console.error("Failed to start SSH Mimic:",n),process.exit(1)});process.on("uncaughtException",n=>{console.log("Oh my god, something terrible happened: ",n)});process.on("unhandledRejection",(n,t)=>{console.log(" Oh Lord! We forgot to handle a promise rejection here: ",t),console.log(" The error was: ",n)});
|
|
490
491
|
//# sourceMappingURL=standalone-wo-sftp.js.map
|