typescript-virtual-container 1.2.2 → 1.2.4

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/standalone.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";var bh=Object.create;var Rs=Object.defineProperty;var xh=Object.getOwnPropertyDescriptor;var Sh=Object.getOwnPropertyNames;var yh=Object.getPrototypeOf,wh=Object.prototype.hasOwnProperty;var We=(n,t)=>()=>(n&&(t=n(n=0)),t);var nt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),Da=(n,t)=>{for(var e in t)Rs(n,e,{get:t[e],enumerable:!0})},Ih=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Sh(t))!wh.call(n,i)&&i!==e&&Rs(n,i,{get:()=>t[i],enumerable:!(r=xh(t,i))||r.enumerable});return n};var Xt=(n,t,e)=>(e=n!=null?bh(yh(n)):{},Ih(t||!n||!n.__esModule?Rs(e,"default",{value:n,enumerable:!0}):e,n));var Qa,Ma=We(()=>{"use strict";Qa={name:"adduser",params:["<username> <password>"],run:async({authUser:n,shell:t,args:e})=>{if(n!=="root")return{stderr:"adduser: permission denied",exitCode:1};let[r,i]=e;return!r||!i?{stderr:"adduser: usage: adduser <username> <password>",exitCode:1}:(await t.users.addUser(r,i),{stdout:`adduser: user '${r}' created`,exitCode:0})}}});function $a(n){return Array.isArray(n)?n:[n]}function Ii(n,t){if(n===t)return{matched:!0,inlineValue:null};let e=`${t}=`;return n.startsWith(e)?{matched:!0,inlineValue:n.slice(e.length)}:{matched:!1,inlineValue:null}}function Bh(n,t={}){let e=new Set(t.flags??[]),r=new Set(t.flagsWithValue??[]),i=[],s=!1;for(let o=0;o<n.length;o+=1){let a=n[o];if(s){i.push(a);continue}if(a==="--"){s=!0;continue}let f=!1;for(let c of e){let{matched:l}=Ii(a,c);if(l){f=!0;break}}if(!f){for(let c of r){let l=Ii(a,c);if(l.matched){f=!0,l.inlineValue===null&&o+1<n.length&&(o+=1);break}}f||i.push(a)}}return i}function lr(n,t){let e=$a(t);for(let r of n)for(let i of e)if(Ii(r,i).matched)return!0;return!1}function vs(n,t){let e=$a(t);for(let r=0;r<n.length;r+=1){let i=n[r];for(let s of e){let o=Ii(i,s);if(!o.matched)continue;if(o.inlineValue!==null)return o.inlineValue;let a=n[r+1];return a!==void 0&&a!=="--"?a:!0}}}function St(n,t,e={}){return Bh(n,e)[t]}function hr(n,t={}){let e=new Set,r=new Map,i=[],s=new Set(t.flags??[]),o=new Set(t.flagsWithValue??[]),a=!1;for(let f=0;f<n.length;f+=1){let c=n[f];if(a){i.push(c);continue}if(c==="--"){a=!0;continue}if(s.has(c)){e.add(c);continue}if(o.has(c)){let h=n[f+1];h&&!h.startsWith("-")?(r.set(c,h),f+=1):r.set(c,"");continue}let l=Array.from(o).find(h=>c.startsWith(`${h}=`));if(l){r.set(l,c.slice(l.length+1));continue}i.push(c)}return{flags:e,flagsWithValues:r,positionals:i}}var Nt=We(()=>{"use strict"});function kr(n){return n.replace(/\r\n/g,`
2
+ `).replace(/\r/g,`
3
+ `).replace(/\t/g," ").split(`
4
+ `).map(t=>t.replace(/^[ \u00A0]{8,}/," ").replace(/[ \u00A0]{3,}/g," ")).join(`
5
+ `).replace(/\n{3,}/g,`
6
+
7
+ `).trimEnd()}function ot(n,t){return!t||t.trim()===""?n:t.startsWith("/")?dr.posix.normalize(t):dr.posix.normalize(dr.posix.join(n,t))}function Rh(n){let t=n.startsWith("/")?dr.posix.normalize(n):dr.posix.normalize(`/${n}`);return kh.some(e=>t===e||t.startsWith(`${e}/`))}function mt(n,t,e){if(n!=="root"&&Rh(t))throw new Error(`${e}: permission denied: ${t}`)}function qa(n){let e=(n.split("?")[0]?.split("#")[0]??n).split("/").filter(Boolean).pop();return e&&e.length>0?e:"index.html"}function Ci(n,t){return new Promise(e=>{let r;try{r=(0,Wa.spawn)(n,t,{stdio:["ignore","pipe","pipe"]})}catch(f){e({stdout:"",stderr:`${n}: ${f instanceof Error?f.message:String(f)}`,exitCode:1});return}let i="",s="",o=r.stdout,a=r.stderr;if(!o||!a){e({stdout:"",stderr:`${n}: failed to capture process output`,exitCode:1});return}o.setEncoding("utf8"),a.setEncoding("utf8"),o.on("data",f=>{i+=f}),a.on("data",f=>{s+=f}),r.on("error",f=>{let c=f instanceof Error&&"code"in f?String(f.code??""):"";e({stdout:"",stderr:`${n}: ${f.message}`,exitCode:c==="ENOENT"?127:1})}),r.on("close",f=>{e({stdout:i,stderr:s,exitCode:f??1})})})}function vh(n,t){let e=Array.from({length:n.length+1},()=>Array(t.length+1).fill(0));for(let r=0;r<=n.length;r+=1)e[r][0]=r;for(let r=0;r<=t.length;r+=1)e[0][r]=r;for(let r=1;r<=n.length;r+=1)for(let i=1;i<=t.length;i+=1){let s=n[r-1]===t[i-1]?0:1;e[r][i]=Math.min(e[r-1][i]+1,e[r][i-1]+1,e[r-1][i-1]+s)}return e[n.length][t.length]}function Ka(n,t,e){let r=ot(t,e);if(n.exists(r))return r;let i=dr.posix.dirname(r),s=dr.posix.basename(r),o=n.list(i),a=o.filter(c=>c.toLowerCase()===s.toLowerCase());if(a.length===1)return dr.posix.join(i,a[0]);let f=o.filter(c=>vh(c.toLowerCase(),s.toLowerCase())<=1);return f.length===1?dr.posix.join(i,f[0]):r}function Ga(n,t,e){return t.map(r=>{let i=ot(n,r);return e(i).type==="directory"?`${r}/`:r}).join(" ")}var Wa,dr,kh,zt=We(()=>{"use strict";Wa=require("node:child_process"),dr=Xt(require("node:path"),1),kh=["/virtual-env-js/.auth"]});var Ya,Va=We(()=>{"use strict";Nt();zt();Ya={name:"cat",params:["<file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let i=St(r,0);if(!i)return{stderr:"cat: missing file operand",exitCode:1};let s=Ka(t.vfs,e,i);return mt(n,s,"cat"),{stdout:t.vfs.readFile(s),exitCode:0}}}});var ja,Xa=We(()=>{"use strict";zt();ja={name:"cd",params:["[path]"],run:({authUser:n,shell:t,cwd:e,args:r,mode:i})=>{let s=ot(e,r[0]??"/virtual-env-js");return mt(n,s,"cd"),t.vfs.stat(s).type!=="directory"?{stderr:`cd: not a directory: ${s}`,exitCode:1}:i==="exec"?{exitCode:0}:{nextCwd:s,exitCode:0}}}});var za,Ja=We(()=>{"use strict";za={name:"clear",params:[],run:()=>({clearScreen:!0,exitCode:0})}});var Za,ef=We(()=>{"use strict";Nt();zt();Za={name:"curl",params:["[-o file] <url>"],run:async({authUser:n,cwd:t,args:e,shell:r})=>{let{flagsWithValues:i,positionals:s}=hr(e,{flagsWithValue:["-o","--output"]}),o=i.get("-o")||i.get("--output")||null;if(!s[0])return{stderr:"curl: missing URL",exitCode:1};let f=o?[...s,"-o","-"]:s,c=await Ci("curl",f);if(c.exitCode!==0)return{stderr:kr(c.stderr||`curl: exited with code ${c.exitCode}`),exitCode:c.exitCode};if(o){let l=ot(t,o);return mt(n,l,"curl"),r.writeFileAsUser(n,l,c.stdout),{stderr:c.stderr?kr(c.stderr):void 0,exitCode:0}}return{stdout:c.stdout,stderr:c.stderr?kr(c.stderr):void 0,exitCode:0}}}});var tf,rf=We(()=>{"use strict";tf={name:"deluser",params:["<username>"],run:async({authUser:n,args:t,shell:e})=>{if(n!=="root")return{stderr:"deluser: permission denied",exitCode:1};let[r]=t;return r?(await e.users.deleteUser(r),{stdout:`deluser: user '${r}' deleted`,exitCode:0}):{stderr:"deluser: usage: deluser <username>",exitCode:1}}}});function Ns(n){return fn[n]}function cn(n,t){fn[n]=t}function un(n){return fn.USER=n,fn.HOME=`/home/${n}`,{...fn}}var fn,nf,Gr=We(()=>{"use strict";Nt();fn={PATH:"/usr/local/bin:/usr/bin:/bin",HOME:"/home/user",SHELL:"/bin/sh",TERM:"xterm-256color",USER:"user"};nf={name:"set",params:["[VAR=value]"],run:({args:n})=>{if(n.length===0)return{stdout:Object.entries(fn).map(([r,i])=>`${r}=${i}`).sort().join(`
8
+ `),exitCode:0};let t=[];for(let e=0;;e+=1){let r=St(n,e);if(!r)break;if(r.includes("=")){let[i,s]=r.split("=",2);i&&s!==void 0&&(cn(i,s),t.push(r))}else{let i=Ns(r);i!==void 0?t.push(`${r}=${i}`):t.push(`${r}: not set`)}}return{stdout:t.length>0?t.join(`
9
+ `):"",exitCode:0}}}});function Nh(n,t){return n.replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g,(e,r)=>t[r]??"")}var sf,of=We(()=>{"use strict";Nt();Gr();sf={name:"echo",params:["[options] [text...]"],run:({args:n,authUser:t,stdin:e})=>{let{flags:r,positionals:i}=hr(n,{flags:["-n"]}),s=!r.has("-n"),o=i.length>0?i.join(" "):e??"",a=un(t),f=Nh(o,a);return{stdout:s?f:f.trimEnd(),exitCode:0}}}});var af,ff=We(()=>{"use strict";Gr();af={name:"env",params:["[VAR=value...] [command]"],run:({authUser:n})=>{let t=un(n);return{stdout:Object.entries(t).map(([r,i])=>`${r}=${i}`).sort().join(`
10
+ `),exitCode:0}}}});var cf,uf=We(()=>{"use strict";cf={name:"exit",aliases:["bye"],params:[],run:()=>({closeSession:!0,exitCode:0})}});var lf,hf=We(()=>{"use strict";Nt();Gr();lf={name:"export",params:["[VAR=value]"],run:({args:n})=>{if(n.length===0)return{stdout:"# export command - sets variables for child processes",exitCode:0};for(let t=0;;t+=1){let e=St(n,t);if(!e)break;if(e.includes("=")){let[r,i]=e.split("=",2);r&&i!==void 0&&cn(r,i)}else cn(e,Ns(e)||"")}return{exitCode:0}}}});var df,gf=We(()=>{"use strict";Nt();zt();df={name:"grep",params:["[-i] [-v] <pattern> [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:i})=>{let{flags:s,positionals:o}=hr(r,{flags:["-i","-v"]}),a=s.has("-i"),f=s.has("-v"),c=o[0],l=o.slice(1);if(!c)return{stderr:"grep: no pattern specified",exitCode:1};let h;try{let p=a?"gmi":"gm";h=new RegExp(c,p)}catch{return{stderr:`grep: invalid regex: ${c}`,exitCode:1}}let g=[];if(l.length===0){if(!i)return{stdout:"",exitCode:1};let p=i.split(`
11
+ `);for(let _ of p){h.lastIndex=0;let b=h.test(_);(f?!b:b)&&g.push(_)}return{stdout:g.length>0?g.join(`
12
+ `):"",exitCode:g.length>0?0:1}}for(let p of l){let _=ot(e,p);try{mt(n,_,"grep");let R=t.vfs.readFile(_).split(`
13
+ `);for(let P of R){h.lastIndex=0;let L=h.test(P);(f?!L:L)&&g.push(P)}}catch{return{stderr:`grep: ${p}: No such file or directory`,exitCode:1}}}return{stdout:g.length>0?g.join(`
14
+ `):"",exitCode:g.length>0?0:1}}}});function pf(n){return{name:"help",params:[],run:()=>({stdout:`Builtins: ${n().join(" ")}`,exitCode:0})}}var Af=We(()=>{"use strict"});var Ef,mf=We(()=>{"use strict";Ef={name:"hostname",params:[],run:({hostname:n})=>({stdout:n,exitCode:0})}});var _f,bf=We(()=>{"use strict";_f={name:"htop",params:[],run:({mode:n})=>n==="exec"?{stderr:"htop: interactive terminal required",exitCode:1}:{openHtop:!0,exitCode:0}}});function Ph(n,t){let e=t?"d":"-",i=[[256,"r"],[128,"w"],[64,"x"],[32,"r"],[16,"w"],[8,"x"],[4,"r"],[2,"w"],[1,"x"]].map(([s,o])=>n&s?o:"-").join("");return`${e}${i}`}function Th(n){return n.toISOString().replace("T"," ").slice(0,16)}var xf,Sf=We(()=>{"use strict";Nt();zt();xf={name:"ls",params:["[path]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let i=lr(r,["-l","--long"]),s=St(r,0,{flags:["-l","--long"]}),o=ot(e,s??e);mt(n,o,"ls");let a=t.vfs.list(o).filter(c=>!c.startsWith("."));return{stdout:i?a.map(c=>{let l=ot(o,c),h=t.vfs.stat(l),g=h.type==="file"?h.size:h.childrenCount;return`${Ph(h.mode,h.type==="directory")} 1 ${g} ${Th(h.updatedAt)} ${c}${h.type==="directory"?"/":""}`}).join(`
15
+ `):Ga(o,a,c=>t.vfs.stat(c)),exitCode:0}}}});var yf,wf=We(()=>{"use strict";Nt();zt();yf={name:"mkdir",params:["<dir>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"mkdir: missing operand",exitCode:1};for(let i=0;i<r.length;i++){let s=St(r,i);if(!s)return{stderr:"mkdir: missing operand",exitCode:1};let o=ot(e,s);mt(n,o,"mkdir"),t.vfs.mkdir(o)}return{exitCode:0}}}});var If,Cf,Bf=We(()=>{"use strict";If=Xt(require("node:path"),1);zt();Cf={name:"nano",params:["<file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let i=r[0];if(!i)return{stderr:"nano: missing file operand",exitCode:1};let s=ot(e,i);mt(n,s,"nano");let o=t.vfs.exists(s)?t.vfs.readFile(s):"",a=If.posix.basename(s)||"buffer",f=`/tmp/sshmimic-nano-${Date.now()}-${a}.tmp`;return{openEditor:{targetPath:s,tempPath:f,initialContent:o},exitCode:0}}}});function Lh(n){let t=Math.max(1,Math.floor(n/60)),e=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60,s=[];return e>0&&s.push(`${e} day${e>1?"s":""}`),r>0&&s.push(`${r} hour${r>1?"s":""}`),(i>0||s.length===0)&&s.push(`${i} min${i>1?"s":""}`),s.join(", ")}function kf(n){return`\x1B[${n}m \x1B[0m`}function Uh(){let n=[40,41,42,43,44,45,46,47].map(kf).join(""),t=[100,101,102,103,104,105,106,107].map(kf).join("");return[n,t]}function Rf(n,t,e){if(n.trim().length===0)return n;let r={r:255,g:255,b:255},i={r:168,g:85,b:247},s=e<=1?0:t/(e-1),o=Math.round(r.r+(i.r-r.r)*s),a=Math.round(r.g+(i.g-r.g)*s),f=Math.round(r.b+(i.b-r.b)*s);return`\x1B[38;2;${o};${a};${f}m${n}\x1B[0m`}function Oh(n){if(n.trim().length===0)return n;let t=n.indexOf(":");if(t===-1)return n.includes("@")?vf(n):n;let e=n.substring(0,t+1),r=n.substring(t+1);return vf(e)+r}function vf(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},i={r:168,g:85,b:247},s="";for(let o=0;o<e.length;o+=1){let a=e.length<=1?0:o/(e.length-1),f=Math.round(r.r+(i.r-r.r)*a),c=Math.round(r.g+(i.g-r.g)*a),l=Math.round(r.b+(i.b-r.b)*a);s+=`\x1B[38;2;${f};${c};${l}m${e[o]}\x1B[0m`}return s}function Nf(n){return Math.max(0,Math.round(n/(1024*1024)))}function Pf(){try{let n=(0,_r.readFileSync)("/etc/os-release","utf8");for(let t of n.split(`
16
+ `)){if(!t.startsWith("PRETTY_NAME="))continue;return t.slice(12).trim().replace(/^"|"$/g,"")}}catch{return}}function Tf(n){try{let t=(0,_r.readFileSync)(n,"utf8").split(`
17
+ `)[0]?.trim();return!t||t.length===0?void 0:t}catch{return}}function Dh(n){let t=Tf("/sys/devices/virtual/dmi/id/sys_vendor"),e=Tf("/sys/devices/virtual/dmi/id/product_name");return t&&e?`${t} ${e}`:e||n}function Hh(){let n=["/var/lib/dpkg/status","/usr/local/var/lib/dpkg/status"];for(let t of n)if((0,_r.existsSync)(t))try{return(0,_r.readFileSync)(t,"utf8").match(/^Package:\s+/gm)?.length??0}catch{}}function Fh(){let n=["/snap","/var/lib/snapd/snaps"];for(let t of n)if((0,_r.existsSync)(t))try{return(0,_r.readdirSync)(t,{withFileTypes:!0}).filter(i=>i.isDirectory()).length}catch{}}function Qh(){let n=Hh(),t=Fh();return n!==void 0&&t!==void 0?`${n} (dpkg), ${t} (snap)`:n!==void 0?`${n} (dpkg)`:t!==void 0?`${t} (snap)`:"n/a"}function Mh(){let n=kt.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 $h(n){return!n||n.trim().length===0?"unknown":Lf.posix.basename(n.trim())}function Wh(n){let t=kt.totalmem(),e=kt.freemem(),r=Math.max(0,t-e),i=n.shellProps,s=process.uptime();return n.uptimeSeconds===void 0&&(n.uptimeSeconds=Math.round(s)),{user:n.user,host:n.host,osName:i?.os??n.osName??`${Pf()??kt.type()} ${kt.arch()}`,kernel:i?.kernel??n.kernel??kt.release(),uptimeSeconds:n.uptimeSeconds??kt.uptime(),packages:n.packages??Qh(),shell:$h(n.shell),shellProps:n.shellProps??{kernel:n.kernel??kt.release(),os:n.osName??`${Pf()??kt.type()} ${kt.arch()}`,arch:kt.arch()},resolution:n.resolution??"n/a (ssh)",terminal:n.terminal??"unknown",cpu:n.cpu??Mh(),gpu:n.gpu??"n/a",memoryUsedMiB:n.memoryUsedMiB??Nf(r),memoryTotalMiB:n.memoryTotalMiB??Nf(t)}}function Uf(n){let t=Wh(n),e=Lh(t.uptimeSeconds),r=Uh(),i=[" .. .:. "," .::.. .. .. ",". .... ... .. ",": .... .:. .. ",": .:.:........:. .. ",": .. ",". : ",". : ",".. : "," :. .. "," .. .. "," :-. :: "," .:. :. "," ..: ... "," ..: :.. "," :... :...."," .. ...."," . .. "," .:. .: "," :. .. "," ::. .. ","..... ..:... ","...:. .. ",".:...:. ::. .. "," ... ..:::::.. ..:::::::.. "],s=[`${t.user}@${t.host}`,"-------------------------",`OS: ${t.osName}`,`Host: ${Dh(t.host)}`,`Kernel: ${t.kernel}`,`Uptime: ${e}`,`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(i.length,s.length),a=[];for(let f=0;f<o;f+=1){let c=i[f]??"",l=s[f]??"";if(l.length>0){let h=Rf(c.padEnd(31," "),f,i.length),g=Oh(l);a.push(`${h} ${g}`);continue}a.push(Rf(c,f,i.length))}return a.join(`
18
+ `)}var _r,kt,Lf,Of=We(()=>{"use strict";_r=require("node:fs"),kt=Xt(require("node:os"),1),Lf=Xt(require("node:path"),1)});var Df,Hf=We(()=>{"use strict";Of();Nt();Gr();Df={name:"neofetch",params:["[--off]"],run:({args:n,authUser:t,hostname:e,shell:r})=>{let i=un(t);return lr(n,"--help")?{stdout:"Usage: neofetch [--off]",exitCode:0}:lr(n,"--off")?{stdout:`${t}@${e}`,exitCode:0}:{stdout:Uf({user:t,host:e,shell:i.SHELL,shellProps:r.properties,terminal:i.TERM}),exitCode:0}}}});var Ff,Qf=We(()=>{"use strict";Ff={name:"passwd",params:["<username> <password>"],run:async({authUser:n,args:t,shell:e})=>{let[r,i]=t;return!r||!i?{stderr:"passwd: usage: passwd <username> <password>",exitCode:1}:n!=="root"&&n!==r?{stderr:"passwd: permission denied",exitCode:1}:(await e.users.setPassword(r,i),{stdout:`passwd: password updated for '${r}'`,exitCode:0})}}});var Mf,$f=We(()=>{"use strict";Mf={name:"pwd",params:[],run:({cwd:n})=>({stdout:n,exitCode:0})}});var Wf,qf=We(()=>{"use strict";Nt();zt();Wf={name:"rm",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 i=lr(r,["-r","-rf","-fr"]),s=[];for(let o=0;;o+=1){let a=St(r,o,{flags:["-r","-rf","-fr"]});if(!a)break;s.push(a)}if(s.length===0)return{stderr:"rm: missing operand",exitCode:1};for(let o of s){let a=ot(e,o);mt(n,a,"rm"),t.vfs.remove(a,{recursive:i})}return{exitCode:0}}}});var Kf,Gf=We(()=>{"use strict";Nt();Rr();Kf={name:"sh",params:["-c <script>","[<file>]"],aliases:["bash"],run:async n=>{let{args:t,authUser:e,hostname:r,mode:i,cwd:s}=n;if(vs(t,"-c")&&t.length>=2){let o=St(t,1)??"";if(!o)return{stderr:"sh: -c requires a script",exitCode:1};let a=t.slice(2),f=o.split(/[;\n]/).map(h=>h.trim()).filter(h=>h&&!h.startsWith("#")),c="",l=0;for(let h of f){let g=h;for(let _=0;_<a.length;_++){let b=a[_]??"";g=g.replaceAll(`$${_}`,b)}g=g.replaceAll("$@",a.join(" "));let p=await Promise.resolve(Qt(g,e,r,i,s,n.shell));if(p.stdout&&(c+=`${p.stdout}
19
+ `),p.stderr)return{stderr:p.stderr,exitCode:p.exitCode??1}}return{stdout:c.trim(),exitCode:l}}return{stderr:"sh: invalid usage",exitCode:1}}}});var Yf,Vf=We(()=>{"use strict";Nt();Yf={name:"su",params:["- <username>"],run:({authUser:n,shell:t,args:e})=>{let r=t.users,i=St(e,0,{flags:["-"]});return i?!r.isSudoer(n)&&n!=="root"?{stderr:"su: permission denied",exitCode:1}:!r.verifyPassword(i,St(e,1)??"")&&n!=="root"?{stderr:"su: authentication failure",exitCode:1}:{switchUser:i,nextCwd:`/home/${i}`,exitCode:0}:{stderr:"su: missing username",exitCode:1}}}});function qh(n){let{flags:t,flagsWithValues:e,positionals:r}=hr(n,{flags:["-i","-S"],flagsWithValue:["-u","--user"]}),i=t.has("-i"),s=e.get("-u")||e.get("--user")||"root",o=r.length>0?r.join(" "):null;return{targetUser:s,loginShell:i,commandLine:o}}var jf,Xf=We(()=>{"use strict";Nt();Rr();jf={name:"sudo",params:["<command...>"],run:async({authUser:n,hostname:t,mode:e,cwd:r,shell:i,args:s})=>{let{targetUser:o,loginShell:a,commandLine:f}=qh(s);if(n!=="root"&&!i.users.isSudoer(n))return{stderr:"sudo: permission denied",exitCode:1};let c=o||"root",l=`[sudo] password for ${n}: `;return n==="root"?!f&&a?{switchUser:c,nextCwd:`/home/${c}`,exitCode:0}:f?Qt(f,c,t,e,a?`/home/${c}`:r,i):{stderr:"sudo: missing command",exitCode:1}:{sudoChallenge:{username:n,targetUser:c,commandLine:f,loginShell:a,prompt:l},exitCode:0}}}});var zf,Jf=We(()=>{"use strict";zt();zf={name:"touch",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 i of r){let s=ot(e,i);mt(n,s,"touch"),t.vfs.exists(s)||t.writeFileAsUser(n,s,"")}return{exitCode:0}}}});var Zf,ec=We(()=>{"use strict";Nt();zt();Zf={name:"tree",params:["[path]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let i=ot(e,St(r,0)??e);return mt(n,i,"tree"),{stdout:t.vfs.tree(i),exitCode:0}}}});var tc,rc=We(()=>{"use strict";Gr();tc={name:"unset",params:["<VAR...>"],run:({args:n})=>{if(n.length===0)return{stderr:"unset: missing variable name",exitCode:1};for(let t of n)cn(t,"");return{exitCode:0}}}});function Kh(n){return new Promise(t=>{let e;try{e=(0,nc.spawn)("wget",n,{stdio:["ignore","pipe","pipe"]})}catch(a){t({stdout:"",stderr:`wget: ${a instanceof Error?a.message:String(a)}`,exitCode:1});return}let r="",i="",s=e.stdout,o=e.stderr;if(!s||!o){t({stdout:"",stderr:"wget: failed to capture process output",exitCode:1});return}s.setEncoding("utf8"),o.setEncoding("utf8"),s.on("data",a=>{r+=a}),o.on("data",a=>{i+=a}),e.on("error",a=>{let f=a instanceof Error&&"code"in a?String(a.code??""):"";t({stdout:"",stderr:`wget: ${a.message}`,exitCode:f==="ENOENT"?127:1})}),e.on("close",a=>{t({stdout:r,stderr:i,exitCode:a??1})})})}var nc,ln,ic,Ps,sc,oc=We(()=>{"use strict";nc=require("node:child_process"),ln=require("node:fs/promises"),ic=require("node:os"),Ps=require("node:path");Nt();zt();sc={name:"wget",params:["[url]"],run:async({authUser:n,cwd:t,args:e,shell:r})=>{let{flagsWithValues:i,positionals:s}=hr(e,{flagsWithValue:["-o","-O","--output","--output-document"]}),o=i.get("-o")||i.get("-O")||i.get("--output")||i.get("--output-document")||null,a=s[0];if(!a)return{stderr:"wget: missing URL",exitCode:1};if(lr(e,["-h","--help","-V","--version"])){let h=await Kh(e);return{stdout:kr(h.stdout),stderr:h.stderr?kr(h.stderr):void 0,exitCode:h.exitCode}}let c=await(0,ln.mkdtemp)((0,Ps.join)((0,ic.tmpdir)(),"virtual-env-js-wget-")),l=(0,Ps.join)(c,"download");try{let h=[...s,"-O",l],g=await Ci("wget",h);if(g.exitCode!==0)return{stderr:kr(g.stderr||`wget: exited with code ${g.exitCode}`),exitCode:g.exitCode};let p=await(0,ln.readFile)(l,"utf8"),_=ot(t,o||qa(a));return mt(n,_,"wget"),r.writeFileAsUser(n,_,p),{stdout:`saved ${_}`,exitCode:0}}finally{await(0,ln.rm)(c,{recursive:!0,force:!0})}}}});function Bi(n){let t=n.toLocaleString("en-US",{weekday:"short"}),e=n.toLocaleString("en-US",{month:"short"}),r=n.getDate().toString().padStart(2,"0"),i=n.getHours().toString().padStart(2,"0"),s=n.getMinutes().toString().padStart(2,"0"),o=n.getSeconds().toString().padStart(2,"0"),a=n.getFullYear();return`${t} ${e} ${r} ${i}:${s}:${o} ${a}`}var Ts=We(()=>{"use strict"});var ac,fc=We(()=>{"use strict";Ts();ac={name:"who",params:[],run:({shell:n})=>({stdout:n.users.listActiveSessions().map(e=>{let r=new Date(e.startedAt),i=Number.isNaN(r.getTime())?e.startedAt:Bi(r);return`${e.username} ${e.tty} ${i} (${e.remoteAddress||"unknown"})`}).join(`
20
+ `),exitCode:0})}});var cc,uc=We(()=>{"use strict";cc={name:"whoami",params:[],run:({authUser:n})=>({stdout:n,exitCode:0})}});var lc={};Da(lc,{parseShellPipeline:()=>Gh});function Gh(n){let t=n.trim();if(!t)return{commands:[],isValid:!0};let e=[],r=Yh(t);if(r.error)return{commands:[],isValid:!1,error:r.error};let i=r.tokens;for(let s of i){let o=Vh(s);if(!o.isValid)return{commands:[],isValid:!1,error:o.error};o.command&&e.push(o.command)}return{commands:e,isValid:!0}}function Yh(n){let t=[],e="",r=!1,i="",s=0;for(;s<n.length;){let o=n[s];if((o==='"'||o==="'")&&(s===0||n[s-1]!=="\\"))r?o===i&&(r=!1):(r=!0,i=o),e+=o,s++;else if(o==="|"&&!r){if(!e.trim())return{tokens:[],error:"Syntax error near unexpected token '|'"};t.push(e.trim()),e="",s++}else e+=o,s++}return r?{tokens:[],error:"Syntax error: unterminated quote"}:e.trim()?(t.push(e.trim()),{tokens:t}):{tokens:[],error:"Syntax error near unexpected token '|'"}}function Vh(n){let t=jh(n);if(t.length===0)return{isValid:!0};let e=[],r,i,s=!1,o=0;for(;o<t.length;){let c=t[o];if(c==="<"){if(o++,o>=t.length)return{isValid:!1,error:"Syntax error: expected filename after <"};r=t[o],o++}else if(c===">>"){if(o++,o>=t.length)return{isValid:!1,error:"Syntax error: expected filename after >>"};i=t[o],s=!0,o++}else if(c===">"){if(o++,o>=t.length)return{isValid:!1,error:"Syntax error: expected filename after >"};i=t[o],s=!1,o++}else e.push(c),o++}if(e.length===0)return{isValid:!0};let a=e[0].toLowerCase(),f=e.slice(1);return{command:{name:a,args:f,inputFile:r,outputFile:i,appendOutput:s},isValid:!0}}function jh(n){let t=[],e="",r=!1,i="",s=0;for(;s<n.length;){let o=n[s],a=n[s+1];(o==='"'||o==="'")&&(s===0||n[s-1]!=="\\")?(r?o===i?(r=!1,i=""):e+=o:(r=!0,i=o),s++):o===" "&&!r?(e&&(t.push(e),e=""),s++):(o===">"||o==="<")&&!r?(e&&(t.push(e),e=""),o===">"&&a===">"?(t.push(">>"),s+=2):(t.push(o),s++)):(e+=o,s++)}return e&&t.push(e),t}var hc=We(()=>{"use strict"});var dc={};Da(dc,{executePipeline:()=>Xh});async function Xh(n,t,e,r,i,s){return n.commands.length===0?{exitCode:0}:n.commands.length===1?zh(n.commands[0],t,e,r,i,s):Jh(n.commands,t,e,r,i,s)}async function zh(n,t,e,r,i,s){let o;if(n.inputFile){let c=ot(i,n.inputFile);try{o=s.vfs.readFile(c)}catch{return{stderr:`cat: ${n.inputFile}: No such file or directory`,exitCode:1}}}let a=[n.name,...n.args].join(" "),f=await Qt(a,t,e,r,i,s,o);if(n.outputFile){let c=ot(i,n.outputFile),l=f.stdout||"";try{if(n.appendOutput)try{let h=s.vfs.readFile(c);s.writeFileAsUser(t,c,h+l)}catch{s.writeFileAsUser(t,c,l)}else s.writeFileAsUser(t,c,l);return{...f,stdout:""}}catch{return{...f,stderr:`Failed to write to ${n.outputFile}`,exitCode:1}}}return f}async function Jh(n,t,e,r,i,s){let o="",a=0;for(let f=0;f<n.length;f++){let c=n[f];if(f===0&&c.inputFile){let g=ot(i,c.inputFile);try{o=s.vfs.readFile(g)}catch{return{stderr:`cat: ${c.inputFile}: No such file or directory`,exitCode:1}}}let l=[c.name,...c.args].join(" "),h=await Qt(l,t,e,r,i,s,o);if(a=h.exitCode??0,f===n.length-1&&c.outputFile){let g=ot(i,c.outputFile),p=h.stdout||"";try{if(c.appendOutput)try{let _=s.vfs.readFile(g);s.writeFileAsUser(t,g,_+p)}catch{s.writeFileAsUser(t,g,p)}else s.writeFileAsUser(t,g,p);o=""}catch{return{stderr:`Failed to write to ${c.outputFile}`,exitCode:1}}}else o=h.stdout||"";if(h.stderr&&a!==0)return{stderr:h.stderr,exitCode:a}}return{stdout:o,exitCode:a}}var gc=We(()=>{"use strict";Rr();zt()});function Ls(){for(let n of pc()){hn.set(n.name,n);for(let t of n.aliases??[])hn.set(t,n)}ki=Array.from(hn.keys()).sort()}function pc(){return[...Zh,...ed,td]}function Ac(n){let t={...n,name:n.name.trim().toLowerCase(),aliases:n.aliases?.map(r=>r.trim().toLowerCase())},e=[t.name,...t.aliases??[]];if(e.some(r=>r.length===0||/\s/.test(r)))throw new Error("Command names and aliases must be non-empty and contain no spaces");for(let r of e){if(hn.has(r))throw new Error(`Command '${r}' already exists`);hn.set(r,t)}Ls()}function Ec(n,t,e){return{name:n,params:t,run:e}}function mc(){return ki||Ls(),ki}function rd(n){return ki||Ls(),hn.get(n.toLowerCase())}function nd(n){let t=[],e="",r=!1,i="";for(let s=0;s<n.length;s+=1){let o=n[s]||"",a=s>0?n[s-1]:"";if((o==='"'||o==="'")&&a!=="\\"){if(!r){r=!0,i=o;continue}if(o===i){r=!1,i="";continue}}if(/\s/.test(o)&&!r){e.length>0&&(t.push(e),e="");continue}e+=o}return e.length>0&&t.push(e),t}function id(n){let t=nd(n.trim());return{commandName:t[0]?.toLowerCase()??"",args:t.slice(1)}}async function Qt(n,t,e,r,i,s,o){let a=n.trim();if(a.length===0)return{exitCode:0};if(a.includes("|")||a.includes(">")||a.includes("<")){let{parseShellPipeline:h}=await Promise.resolve().then(()=>(hc(),lc)),{executePipeline:g}=await Promise.resolve().then(()=>(gc(),dc)),p=h(a);if(!p.isValid)return{stderr:p.error||"Syntax error",exitCode:1};try{return await g(p,t,e,r,i,s)}catch(_){return{stderr:_ instanceof Error?_.message:"Pipeline execution failed",exitCode:1}}}let{commandName:f,args:c}=id(a),l=rd(f);if(!l)return{stderr:`Command '${a}' not found`,exitCode:127};try{return await l.run({authUser:t,hostname:e,activeSessions:s.users.listActiveSessions(),rawInput:a,mode:r,args:c,stdin:o,cwd:i,shell:s})}catch(h){return{stderr:h instanceof Error?h.message:"Command failed",exitCode:1}}}var Zh,ed,td,hn,ki,Rr=We(()=>{"use strict";Ma();Va();Xa();Ja();ef();rf();of();ff();uf();hf();gf();Af();mf();bf();Sf();wf();Bf();Hf();Qf();$f();qf();Gr();Gf();Vf();Xf();Jf();ec();rc();oc();fc();uc();Zh=[Mf,cc,ac,Ef,xf,ja,Ya,sf,yf,zf,Wf,Zf,Cf,Df,_f,Qa,Ff,tf,jf,Yf,Za,af,sc,df,lf,nf,tc,Kf,za,cf],ed=[],td=pf(()=>pc().map(n=>n.name)),hn=new Map,ki=null});var Ri=nt((am,_c)=>{_c.exports={newInvalidAsn1Error:function(n){var t=new Error;return t.name="InvalidAsn1Error",t.message=n||"",t}}});var vi=nt((fm,bc)=>{bc.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 Us=nt((cm,xc)=>{"use strict";var Ni=require("buffer"),dn=Ni.Buffer,rr={},nr;for(nr in Ni)Ni.hasOwnProperty(nr)&&(nr==="SlowBuffer"||nr==="Buffer"||(rr[nr]=Ni[nr]));var gn=rr.Buffer={};for(nr in dn)dn.hasOwnProperty(nr)&&(nr==="allocUnsafe"||nr==="allocUnsafeSlow"||(gn[nr]=dn[nr]));rr.Buffer.prototype=dn.prototype;(!gn.from||gn.from===Uint8Array.from)&&(gn.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 dn(n,t,e)});gn.alloc||(gn.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=dn(n);return!t||t.length===0?r.fill(0):typeof e=="string"?r.fill(t,e):r.fill(t),r});if(!rr.kStringMaxLength)try{rr.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}rr.constants||(rr.constants={MAX_LENGTH:rr.kMaxLength},rr.kStringMaxLength&&(rr.constants.MAX_STRING_LENGTH=rr.kStringMaxLength));xc.exports=rr});var wc=nt((um,yc)=>{var sd=require("assert"),Sc=Us().Buffer,qn=vi(),od=Ri(),pn=od.newInvalidAsn1Error;function Mt(n){if(!n||!Sc.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(Mt.prototype,"length",{enumerable:!0,get:function(){return this._len}});Object.defineProperty(Mt.prototype,"offset",{enumerable:!0,get:function(){return this._offset}});Object.defineProperty(Mt.prototype,"remain",{get:function(){return this._size-this._offset}});Object.defineProperty(Mt.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}});Mt.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};Mt.prototype.peek=function(){return this.readByte(!0)};Mt.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 pn("Indefinite length not supported");if(t>4)throw pn("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};Mt.prototype.readSequence=function(n){var t=this.peek();if(t===null)return null;if(n!==void 0&&n!==t)throw pn("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)};Mt.prototype.readInt=function(){return this._readTag(qn.Integer)};Mt.prototype.readBoolean=function(){return this._readTag(qn.Boolean)!==0};Mt.prototype.readEnumeration=function(){return this._readTag(qn.Enumeration)};Mt.prototype.readString=function(n,t){n||(n=qn.OctetString);var e=this.peek();if(e===null)return null;if(e!==n)throw pn("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?Sc.alloc(0):"";var i=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?i:i.toString("utf8")};Mt.prototype.readOID=function(n){n||(n=qn.OID);var t=this.readString(n,!0);if(t===null)return null;for(var e=[],r=0,i=0;i<t.length;i++){var s=t[i]&255;r<<=7,r+=s&127,(s&128)===0&&(e.push(r),r=0)}return r=e.shift(),e.unshift(r%40),e.unshift(r/40>>0),e.join(".")};Mt.prototype._readTag=function(n){sd.ok(n!==void 0);var t=this.peek();if(t===null)return null;if(t!==n)throw pn("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 pn("Integer too long: "+this.length);if(this.length>this._size-e)return null;this._offset=e;for(var r=this._buf[this._offset],i=0,s=0;s<this.length;s++)i<<=8,i|=this._buf[this._offset++]&255;return(r&128)===128&&s!==4&&(i-=1<<s*8),i>>0};yc.exports=Mt});var Cc=nt((lm,Ic)=>{var vr=require("assert"),Pi=Us().Buffer,Nr=vi(),ad=Ri(),Ti=ad.newInvalidAsn1Error,fd={size:1024,growthFactor:8};function cd(n,t){vr.ok(n),vr.equal(typeof n,"object"),vr.ok(t),vr.equal(typeof t,"object");var e=Object.getOwnPropertyNames(n);return e.forEach(function(r){if(!t[r]){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,i)}}),t}function Ot(n){n=cd(fd,n||{}),this._buf=Pi.alloc(n.size||1024),this._size=this._buf.length,this._offset=0,this._options=n,this._seq=[]}Object.defineProperty(Ot.prototype,"buffer",{get:function(){if(this._seq.length)throw Ti(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}});Ot.prototype.writeByte=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=n};Ot.prototype.writeInt=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");typeof t!="number"&&(t=Nr.Integer);for(var e=4;((n&4286578688)===0||(n&4286578688)===-8388608)&&e>1;)e--,n<<=8;if(e>4)throw Ti("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};Ot.prototype.writeNull=function(){this.writeByte(Nr.Null),this.writeByte(0)};Ot.prototype.writeEnumeration=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");return typeof t!="number"&&(t=Nr.Enumeration),this.writeInt(n,t)};Ot.prototype.writeBoolean=function(n,t){if(typeof n!="boolean")throw new TypeError("argument must be a Boolean");typeof t!="number"&&(t=Nr.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=n?255:0};Ot.prototype.writeString=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string (was: "+typeof n+")");typeof t!="number"&&(t=Nr.OctetString);var e=Pi.byteLength(n);this.writeByte(t),this.writeLength(e),e&&(this._ensure(e),this._buf.write(n,this._offset),this._offset+=e)};Ot.prototype.writeBuffer=function(n,t){if(typeof t!="number")throw new TypeError("tag must be a number");if(!Pi.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};Ot.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)})};Ot.prototype.writeOID=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string");if(typeof t!="number"&&(t=Nr.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("."),i=[];i.push(parseInt(r[0],10)*40+parseInt(r[1],10)),r.slice(2).forEach(function(o){e(i,parseInt(o,10))});var s=this;this._ensure(2+i.length),this.writeByte(t),this.writeLength(i.length),i.forEach(function(o){s.writeByte(o)})};Ot.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 Ti("Length too long (> 4 bytes)")};Ot.prototype.startSequence=function(n){typeof n!="number"&&(n=Nr.Sequence|Nr.Constructor),this.writeByte(n),this._seq.push(this._offset),this._ensure(3),this._offset+=3};Ot.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 Ti("Sequence too long")};Ot.prototype._shift=function(n,t,e){vr.ok(n!==void 0),vr.ok(t!==void 0),vr.ok(e),this._buf.copy(this._buf,n+e,n,n+t),this._offset+=e};Ot.prototype._ensure=function(n){if(vr.ok(n),this._size-this._offset<n){var t=this._size*this._options.growthFactor;t-this._offset<n&&(t+=n);var e=Pi.alloc(t);this._buf.copy(e,0,0,this._offset),this._buf=e,this._size=t}};Ic.exports=Ot});var Bc=nt((hm,Oi)=>{var Os=Ri(),Ds=vi(),ud=wc(),ld=Cc();Oi.exports={Reader:ud,Writer:ld};for(Li in Ds)Ds.hasOwnProperty(Li)&&(Oi.exports[Li]=Ds[Li]);var Li;for(Ui in Os)Os.hasOwnProperty(Ui)&&(Oi.exports[Ui]=Os[Ui]);var Ui});var Kn=nt((dm,kc)=>{var Hs=Bc();kc.exports={Ber:Hs,BerReader:Hs.Reader,BerWriter:Hs.Writer}});var Rc=nt((gm,Di)=>{(function(n){"use strict";var t=function(d){var E,A=new Float64Array(16);if(d)for(E=0;E<d.length;E++)A[E]=d[E];return A},e=function(){throw new Error("no PRNG")},r=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var s=t(),o=t([1]),a=t([56129,1]),f=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),l=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),g=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(d,E,A,u){d[E]=A>>24&255,d[E+1]=A>>16&255,d[E+2]=A>>8&255,d[E+3]=A&255,d[E+4]=u>>24&255,d[E+5]=u>>16&255,d[E+6]=u>>8&255,d[E+7]=u&255}function _(d,E,A,u,m){var C,T=0;for(C=0;C<m;C++)T|=d[E+C]^A[u+C];return(1&T-1>>>8)-1}function b(d,E,A,u){return _(d,E,A,u,16)}function R(d,E,A,u){return _(d,E,A,u,32)}function P(d,E,A,u){for(var m=u[0]&255|(u[1]&255)<<8|(u[2]&255)<<16|(u[3]&255)<<24,C=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,T=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,K=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,ne=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,de=u[4]&255|(u[5]&255)<<8|(u[6]&255)<<16|(u[7]&255)<<24,ue=E[0]&255|(E[1]&255)<<8|(E[2]&255)<<16|(E[3]&255)<<24,ze=E[4]&255|(E[5]&255)<<8|(E[6]&255)<<16|(E[7]&255)<<24,he=E[8]&255|(E[9]&255)<<8|(E[10]&255)<<16|(E[11]&255)<<24,Re=E[12]&255|(E[13]&255)<<8|(E[14]&255)<<16|(E[15]&255)<<24,ve=u[8]&255|(u[9]&255)<<8|(u[10]&255)<<16|(u[11]&255)<<24,Oe=A[16]&255|(A[17]&255)<<8|(A[18]&255)<<16|(A[19]&255)<<24,Le=A[20]&255|(A[21]&255)<<8|(A[22]&255)<<16|(A[23]&255)<<24,Ne=A[24]&255|(A[25]&255)<<8|(A[26]&255)<<16|(A[27]&255)<<24,Te=A[28]&255|(A[29]&255)<<8|(A[30]&255)<<16|(A[31]&255)<<24,Pe=u[12]&255|(u[13]&255)<<8|(u[14]&255)<<16|(u[15]&255)<<24,ge=m,me=C,le=T,pe=K,Ae=ne,ce=de,D=ue,F=ze,Y=he,q=Re,G=ve,re=Oe,ye=Le,De=Ne,Fe=Te,He=Pe,x,Me=0;Me<20;Me+=2)x=ge+ye|0,Ae^=x<<7|x>>>25,x=Ae+ge|0,Y^=x<<9|x>>>23,x=Y+Ae|0,ye^=x<<13|x>>>19,x=ye+Y|0,ge^=x<<18|x>>>14,x=ce+me|0,q^=x<<7|x>>>25,x=q+ce|0,De^=x<<9|x>>>23,x=De+q|0,me^=x<<13|x>>>19,x=me+De|0,ce^=x<<18|x>>>14,x=G+D|0,Fe^=x<<7|x>>>25,x=Fe+G|0,le^=x<<9|x>>>23,x=le+Fe|0,D^=x<<13|x>>>19,x=D+le|0,G^=x<<18|x>>>14,x=He+re|0,pe^=x<<7|x>>>25,x=pe+He|0,F^=x<<9|x>>>23,x=F+pe|0,re^=x<<13|x>>>19,x=re+F|0,He^=x<<18|x>>>14,x=ge+pe|0,me^=x<<7|x>>>25,x=me+ge|0,le^=x<<9|x>>>23,x=le+me|0,pe^=x<<13|x>>>19,x=pe+le|0,ge^=x<<18|x>>>14,x=ce+Ae|0,D^=x<<7|x>>>25,x=D+ce|0,F^=x<<9|x>>>23,x=F+D|0,Ae^=x<<13|x>>>19,x=Ae+F|0,ce^=x<<18|x>>>14,x=G+q|0,re^=x<<7|x>>>25,x=re+G|0,Y^=x<<9|x>>>23,x=Y+re|0,q^=x<<13|x>>>19,x=q+Y|0,G^=x<<18|x>>>14,x=He+Fe|0,ye^=x<<7|x>>>25,x=ye+He|0,De^=x<<9|x>>>23,x=De+ye|0,Fe^=x<<13|x>>>19,x=Fe+De|0,He^=x<<18|x>>>14;ge=ge+m|0,me=me+C|0,le=le+T|0,pe=pe+K|0,Ae=Ae+ne|0,ce=ce+de|0,D=D+ue|0,F=F+ze|0,Y=Y+he|0,q=q+Re|0,G=G+ve|0,re=re+Oe|0,ye=ye+Le|0,De=De+Ne|0,Fe=Fe+Te|0,He=He+Pe|0,d[0]=ge>>>0&255,d[1]=ge>>>8&255,d[2]=ge>>>16&255,d[3]=ge>>>24&255,d[4]=me>>>0&255,d[5]=me>>>8&255,d[6]=me>>>16&255,d[7]=me>>>24&255,d[8]=le>>>0&255,d[9]=le>>>8&255,d[10]=le>>>16&255,d[11]=le>>>24&255,d[12]=pe>>>0&255,d[13]=pe>>>8&255,d[14]=pe>>>16&255,d[15]=pe>>>24&255,d[16]=Ae>>>0&255,d[17]=Ae>>>8&255,d[18]=Ae>>>16&255,d[19]=Ae>>>24&255,d[20]=ce>>>0&255,d[21]=ce>>>8&255,d[22]=ce>>>16&255,d[23]=ce>>>24&255,d[24]=D>>>0&255,d[25]=D>>>8&255,d[26]=D>>>16&255,d[27]=D>>>24&255,d[28]=F>>>0&255,d[29]=F>>>8&255,d[30]=F>>>16&255,d[31]=F>>>24&255,d[32]=Y>>>0&255,d[33]=Y>>>8&255,d[34]=Y>>>16&255,d[35]=Y>>>24&255,d[36]=q>>>0&255,d[37]=q>>>8&255,d[38]=q>>>16&255,d[39]=q>>>24&255,d[40]=G>>>0&255,d[41]=G>>>8&255,d[42]=G>>>16&255,d[43]=G>>>24&255,d[44]=re>>>0&255,d[45]=re>>>8&255,d[46]=re>>>16&255,d[47]=re>>>24&255,d[48]=ye>>>0&255,d[49]=ye>>>8&255,d[50]=ye>>>16&255,d[51]=ye>>>24&255,d[52]=De>>>0&255,d[53]=De>>>8&255,d[54]=De>>>16&255,d[55]=De>>>24&255,d[56]=Fe>>>0&255,d[57]=Fe>>>8&255,d[58]=Fe>>>16&255,d[59]=Fe>>>24&255,d[60]=He>>>0&255,d[61]=He>>>8&255,d[62]=He>>>16&255,d[63]=He>>>24&255}function L(d,E,A,u){for(var m=u[0]&255|(u[1]&255)<<8|(u[2]&255)<<16|(u[3]&255)<<24,C=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,T=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,K=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,ne=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,de=u[4]&255|(u[5]&255)<<8|(u[6]&255)<<16|(u[7]&255)<<24,ue=E[0]&255|(E[1]&255)<<8|(E[2]&255)<<16|(E[3]&255)<<24,ze=E[4]&255|(E[5]&255)<<8|(E[6]&255)<<16|(E[7]&255)<<24,he=E[8]&255|(E[9]&255)<<8|(E[10]&255)<<16|(E[11]&255)<<24,Re=E[12]&255|(E[13]&255)<<8|(E[14]&255)<<16|(E[15]&255)<<24,ve=u[8]&255|(u[9]&255)<<8|(u[10]&255)<<16|(u[11]&255)<<24,Oe=A[16]&255|(A[17]&255)<<8|(A[18]&255)<<16|(A[19]&255)<<24,Le=A[20]&255|(A[21]&255)<<8|(A[22]&255)<<16|(A[23]&255)<<24,Ne=A[24]&255|(A[25]&255)<<8|(A[26]&255)<<16|(A[27]&255)<<24,Te=A[28]&255|(A[29]&255)<<8|(A[30]&255)<<16|(A[31]&255)<<24,Pe=u[12]&255|(u[13]&255)<<8|(u[14]&255)<<16|(u[15]&255)<<24,ge=m,me=C,le=T,pe=K,Ae=ne,ce=de,D=ue,F=ze,Y=he,q=Re,G=ve,re=Oe,ye=Le,De=Ne,Fe=Te,He=Pe,x,Me=0;Me<20;Me+=2)x=ge+ye|0,Ae^=x<<7|x>>>25,x=Ae+ge|0,Y^=x<<9|x>>>23,x=Y+Ae|0,ye^=x<<13|x>>>19,x=ye+Y|0,ge^=x<<18|x>>>14,x=ce+me|0,q^=x<<7|x>>>25,x=q+ce|0,De^=x<<9|x>>>23,x=De+q|0,me^=x<<13|x>>>19,x=me+De|0,ce^=x<<18|x>>>14,x=G+D|0,Fe^=x<<7|x>>>25,x=Fe+G|0,le^=x<<9|x>>>23,x=le+Fe|0,D^=x<<13|x>>>19,x=D+le|0,G^=x<<18|x>>>14,x=He+re|0,pe^=x<<7|x>>>25,x=pe+He|0,F^=x<<9|x>>>23,x=F+pe|0,re^=x<<13|x>>>19,x=re+F|0,He^=x<<18|x>>>14,x=ge+pe|0,me^=x<<7|x>>>25,x=me+ge|0,le^=x<<9|x>>>23,x=le+me|0,pe^=x<<13|x>>>19,x=pe+le|0,ge^=x<<18|x>>>14,x=ce+Ae|0,D^=x<<7|x>>>25,x=D+ce|0,F^=x<<9|x>>>23,x=F+D|0,Ae^=x<<13|x>>>19,x=Ae+F|0,ce^=x<<18|x>>>14,x=G+q|0,re^=x<<7|x>>>25,x=re+G|0,Y^=x<<9|x>>>23,x=Y+re|0,q^=x<<13|x>>>19,x=q+Y|0,G^=x<<18|x>>>14,x=He+Fe|0,ye^=x<<7|x>>>25,x=ye+He|0,De^=x<<9|x>>>23,x=De+ye|0,Fe^=x<<13|x>>>19,x=Fe+De|0,He^=x<<18|x>>>14;d[0]=ge>>>0&255,d[1]=ge>>>8&255,d[2]=ge>>>16&255,d[3]=ge>>>24&255,d[4]=ce>>>0&255,d[5]=ce>>>8&255,d[6]=ce>>>16&255,d[7]=ce>>>24&255,d[8]=G>>>0&255,d[9]=G>>>8&255,d[10]=G>>>16&255,d[11]=G>>>24&255,d[12]=He>>>0&255,d[13]=He>>>8&255,d[14]=He>>>16&255,d[15]=He>>>24&255,d[16]=D>>>0&255,d[17]=D>>>8&255,d[18]=D>>>16&255,d[19]=D>>>24&255,d[20]=F>>>0&255,d[21]=F>>>8&255,d[22]=F>>>16&255,d[23]=F>>>24&255,d[24]=Y>>>0&255,d[25]=Y>>>8&255,d[26]=Y>>>16&255,d[27]=Y>>>24&255,d[28]=q>>>0&255,d[29]=q>>>8&255,d[30]=q>>>16&255,d[31]=q>>>24&255}function ee(d,E,A,u){P(d,E,A,u)}function H(d,E,A,u){L(d,E,A,u)}var z=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function J(d,E,A,u,m,C,T){var K=new Uint8Array(16),ne=new Uint8Array(64),de,ue;for(ue=0;ue<16;ue++)K[ue]=0;for(ue=0;ue<8;ue++)K[ue]=C[ue];for(;m>=64;){for(ee(ne,K,T,z),ue=0;ue<64;ue++)d[E+ue]=A[u+ue]^ne[ue];for(de=1,ue=8;ue<16;ue++)de=de+(K[ue]&255)|0,K[ue]=de&255,de>>>=8;m-=64,E+=64,u+=64}if(m>0)for(ee(ne,K,T,z),ue=0;ue<m;ue++)d[E+ue]=A[u+ue]^ne[ue];return 0}function V(d,E,A,u,m){var C=new Uint8Array(16),T=new Uint8Array(64),K,ne;for(ne=0;ne<16;ne++)C[ne]=0;for(ne=0;ne<8;ne++)C[ne]=u[ne];for(;A>=64;){for(ee(T,C,m,z),ne=0;ne<64;ne++)d[E+ne]=T[ne];for(K=1,ne=8;ne<16;ne++)K=K+(C[ne]&255)|0,C[ne]=K&255,K>>>=8;A-=64,E+=64}if(A>0)for(ee(T,C,m,z),ne=0;ne<A;ne++)d[E+ne]=T[ne];return 0}function y(d,E,A,u,m){var C=new Uint8Array(32);H(C,u,m,z);for(var T=new Uint8Array(8),K=0;K<8;K++)T[K]=u[K+16];return V(d,E,A,T,C)}function w(d,E,A,u,m,C,T){var K=new Uint8Array(32);H(K,C,T,z);for(var ne=new Uint8Array(8),de=0;de<8;de++)ne[de]=C[de+16];return J(d,E,A,u,m,ne,K)}var U=function(d){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var E,A,u,m,C,T,K,ne;E=d[0]&255|(d[1]&255)<<8,this.r[0]=E&8191,A=d[2]&255|(d[3]&255)<<8,this.r[1]=(E>>>13|A<<3)&8191,u=d[4]&255|(d[5]&255)<<8,this.r[2]=(A>>>10|u<<6)&7939,m=d[6]&255|(d[7]&255)<<8,this.r[3]=(u>>>7|m<<9)&8191,C=d[8]&255|(d[9]&255)<<8,this.r[4]=(m>>>4|C<<12)&255,this.r[5]=C>>>1&8190,T=d[10]&255|(d[11]&255)<<8,this.r[6]=(C>>>14|T<<2)&8191,K=d[12]&255|(d[13]&255)<<8,this.r[7]=(T>>>11|K<<5)&8065,ne=d[14]&255|(d[15]&255)<<8,this.r[8]=(K>>>8|ne<<8)&8191,this.r[9]=ne>>>5&127,this.pad[0]=d[16]&255|(d[17]&255)<<8,this.pad[1]=d[18]&255|(d[19]&255)<<8,this.pad[2]=d[20]&255|(d[21]&255)<<8,this.pad[3]=d[22]&255|(d[23]&255)<<8,this.pad[4]=d[24]&255|(d[25]&255)<<8,this.pad[5]=d[26]&255|(d[27]&255)<<8,this.pad[6]=d[28]&255|(d[29]&255)<<8,this.pad[7]=d[30]&255|(d[31]&255)<<8};U.prototype.blocks=function(d,E,A){for(var u=this.fin?0:2048,m,C,T,K,ne,de,ue,ze,he,Re,ve,Oe,Le,Ne,Te,Pe,ge,me,le,pe=this.h[0],Ae=this.h[1],ce=this.h[2],D=this.h[3],F=this.h[4],Y=this.h[5],q=this.h[6],G=this.h[7],re=this.h[8],ye=this.h[9],De=this.r[0],Fe=this.r[1],He=this.r[2],x=this.r[3],Me=this.r[4],Je=this.r[5],Ze=this.r[6],Qe=this.r[7],Ve=this.r[8],je=this.r[9];A>=16;)m=d[E+0]&255|(d[E+1]&255)<<8,pe+=m&8191,C=d[E+2]&255|(d[E+3]&255)<<8,Ae+=(m>>>13|C<<3)&8191,T=d[E+4]&255|(d[E+5]&255)<<8,ce+=(C>>>10|T<<6)&8191,K=d[E+6]&255|(d[E+7]&255)<<8,D+=(T>>>7|K<<9)&8191,ne=d[E+8]&255|(d[E+9]&255)<<8,F+=(K>>>4|ne<<12)&8191,Y+=ne>>>1&8191,de=d[E+10]&255|(d[E+11]&255)<<8,q+=(ne>>>14|de<<2)&8191,ue=d[E+12]&255|(d[E+13]&255)<<8,G+=(de>>>11|ue<<5)&8191,ze=d[E+14]&255|(d[E+15]&255)<<8,re+=(ue>>>8|ze<<8)&8191,ye+=ze>>>5|u,he=0,Re=he,Re+=pe*De,Re+=Ae*(5*je),Re+=ce*(5*Ve),Re+=D*(5*Qe),Re+=F*(5*Ze),he=Re>>>13,Re&=8191,Re+=Y*(5*Je),Re+=q*(5*Me),Re+=G*(5*x),Re+=re*(5*He),Re+=ye*(5*Fe),he+=Re>>>13,Re&=8191,ve=he,ve+=pe*Fe,ve+=Ae*De,ve+=ce*(5*je),ve+=D*(5*Ve),ve+=F*(5*Qe),he=ve>>>13,ve&=8191,ve+=Y*(5*Ze),ve+=q*(5*Je),ve+=G*(5*Me),ve+=re*(5*x),ve+=ye*(5*He),he+=ve>>>13,ve&=8191,Oe=he,Oe+=pe*He,Oe+=Ae*Fe,Oe+=ce*De,Oe+=D*(5*je),Oe+=F*(5*Ve),he=Oe>>>13,Oe&=8191,Oe+=Y*(5*Qe),Oe+=q*(5*Ze),Oe+=G*(5*Je),Oe+=re*(5*Me),Oe+=ye*(5*x),he+=Oe>>>13,Oe&=8191,Le=he,Le+=pe*x,Le+=Ae*He,Le+=ce*Fe,Le+=D*De,Le+=F*(5*je),he=Le>>>13,Le&=8191,Le+=Y*(5*Ve),Le+=q*(5*Qe),Le+=G*(5*Ze),Le+=re*(5*Je),Le+=ye*(5*Me),he+=Le>>>13,Le&=8191,Ne=he,Ne+=pe*Me,Ne+=Ae*x,Ne+=ce*He,Ne+=D*Fe,Ne+=F*De,he=Ne>>>13,Ne&=8191,Ne+=Y*(5*je),Ne+=q*(5*Ve),Ne+=G*(5*Qe),Ne+=re*(5*Ze),Ne+=ye*(5*Je),he+=Ne>>>13,Ne&=8191,Te=he,Te+=pe*Je,Te+=Ae*Me,Te+=ce*x,Te+=D*He,Te+=F*Fe,he=Te>>>13,Te&=8191,Te+=Y*De,Te+=q*(5*je),Te+=G*(5*Ve),Te+=re*(5*Qe),Te+=ye*(5*Ze),he+=Te>>>13,Te&=8191,Pe=he,Pe+=pe*Ze,Pe+=Ae*Je,Pe+=ce*Me,Pe+=D*x,Pe+=F*He,he=Pe>>>13,Pe&=8191,Pe+=Y*Fe,Pe+=q*De,Pe+=G*(5*je),Pe+=re*(5*Ve),Pe+=ye*(5*Qe),he+=Pe>>>13,Pe&=8191,ge=he,ge+=pe*Qe,ge+=Ae*Ze,ge+=ce*Je,ge+=D*Me,ge+=F*x,he=ge>>>13,ge&=8191,ge+=Y*He,ge+=q*Fe,ge+=G*De,ge+=re*(5*je),ge+=ye*(5*Ve),he+=ge>>>13,ge&=8191,me=he,me+=pe*Ve,me+=Ae*Qe,me+=ce*Ze,me+=D*Je,me+=F*Me,he=me>>>13,me&=8191,me+=Y*x,me+=q*He,me+=G*Fe,me+=re*De,me+=ye*(5*je),he+=me>>>13,me&=8191,le=he,le+=pe*je,le+=Ae*Ve,le+=ce*Qe,le+=D*Ze,le+=F*Je,he=le>>>13,le&=8191,le+=Y*Me,le+=q*x,le+=G*He,le+=re*Fe,le+=ye*De,he+=le>>>13,le&=8191,he=(he<<2)+he|0,he=he+Re|0,Re=he&8191,he=he>>>13,ve+=he,pe=Re,Ae=ve,ce=Oe,D=Le,F=Ne,Y=Te,q=Pe,G=ge,re=me,ye=le,E+=16,A-=16;this.h[0]=pe,this.h[1]=Ae,this.h[2]=ce,this.h[3]=D,this.h[4]=F,this.h[5]=Y,this.h[6]=q,this.h[7]=G,this.h[8]=re,this.h[9]=ye},U.prototype.finish=function(d,E){var A=new Uint16Array(10),u,m,C,T;if(this.leftover){for(T=this.leftover,this.buffer[T++]=1;T<16;T++)this.buffer[T]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(u=this.h[1]>>>13,this.h[1]&=8191,T=2;T<10;T++)this.h[T]+=u,u=this.h[T]>>>13,this.h[T]&=8191;for(this.h[0]+=u*5,u=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=u,u=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=u,A[0]=this.h[0]+5,u=A[0]>>>13,A[0]&=8191,T=1;T<10;T++)A[T]=this.h[T]+u,u=A[T]>>>13,A[T]&=8191;for(A[9]-=8192,m=(u^1)-1,T=0;T<10;T++)A[T]&=m;for(m=~m,T=0;T<10;T++)this.h[T]=this.h[T]&m|A[T];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,C=this.h[0]+this.pad[0],this.h[0]=C&65535,T=1;T<8;T++)C=(this.h[T]+this.pad[T]|0)+(C>>>16)|0,this.h[T]=C&65535;d[E+0]=this.h[0]>>>0&255,d[E+1]=this.h[0]>>>8&255,d[E+2]=this.h[1]>>>0&255,d[E+3]=this.h[1]>>>8&255,d[E+4]=this.h[2]>>>0&255,d[E+5]=this.h[2]>>>8&255,d[E+6]=this.h[3]>>>0&255,d[E+7]=this.h[3]>>>8&255,d[E+8]=this.h[4]>>>0&255,d[E+9]=this.h[4]>>>8&255,d[E+10]=this.h[5]>>>0&255,d[E+11]=this.h[5]>>>8&255,d[E+12]=this.h[6]>>>0&255,d[E+13]=this.h[6]>>>8&255,d[E+14]=this.h[7]>>>0&255,d[E+15]=this.h[7]>>>8&255},U.prototype.update=function(d,E,A){var u,m;if(this.leftover){for(m=16-this.leftover,m>A&&(m=A),u=0;u<m;u++)this.buffer[this.leftover+u]=d[E+u];if(A-=m,E+=m,this.leftover+=m,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(A>=16&&(m=A-A%16,this.blocks(d,E,m),E+=m,A-=m),A){for(u=0;u<A;u++)this.buffer[this.leftover+u]=d[E+u];this.leftover+=A}};function $(d,E,A,u,m,C){var T=new U(C);return T.update(A,u,m),T.finish(d,E),0}function M(d,E,A,u,m,C){var T=new Uint8Array(16);return $(T,0,A,u,m,C),b(d,E,T,0)}function se(d,E,A,u,m){var C;if(A<32)return-1;for(w(d,0,E,0,A,u,m),$(d,16,d,32,A-32,d),C=0;C<16;C++)d[C]=0;return 0}function Z(d,E,A,u,m){var C,T=new Uint8Array(32);if(A<32||(y(T,0,32,u,m),M(E,16,E,32,A-32,T)!==0))return-1;for(w(d,0,E,0,A,u,m),C=0;C<32;C++)d[C]=0;return 0}function j(d,E){var A;for(A=0;A<16;A++)d[A]=E[A]|0}function te(d){var E,A,u=1;for(E=0;E<16;E++)A=d[E]+u+65535,u=Math.floor(A/65536),d[E]=A-u*65536;d[0]+=u-1+37*(u-1)}function oe(d,E,A){for(var u,m=~(A-1),C=0;C<16;C++)u=m&(d[C]^E[C]),d[C]^=u,E[C]^=u}function S(d,E){var A,u,m,C=t(),T=t();for(A=0;A<16;A++)T[A]=E[A];for(te(T),te(T),te(T),u=0;u<2;u++){for(C[0]=T[0]-65517,A=1;A<15;A++)C[A]=T[A]-65535-(C[A-1]>>16&1),C[A-1]&=65535;C[15]=T[15]-32767-(C[14]>>16&1),m=C[15]>>16&1,C[14]&=65535,oe(T,C,1-m)}for(A=0;A<16;A++)d[2*A]=T[A]&255,d[2*A+1]=T[A]>>8}function k(d,E){var A=new Uint8Array(32),u=new Uint8Array(32);return S(A,d),S(u,E),R(A,0,u,0)}function v(d){var E=new Uint8Array(32);return S(E,d),E[0]&1}function O(d,E){var A;for(A=0;A<16;A++)d[A]=E[2*A]+(E[2*A+1]<<8);d[15]&=32767}function ie(d,E,A){for(var u=0;u<16;u++)d[u]=E[u]+A[u]}function X(d,E,A){for(var u=0;u<16;u++)d[u]=E[u]-A[u]}function fe(d,E,A){var u,m,C=0,T=0,K=0,ne=0,de=0,ue=0,ze=0,he=0,Re=0,ve=0,Oe=0,Le=0,Ne=0,Te=0,Pe=0,ge=0,me=0,le=0,pe=0,Ae=0,ce=0,D=0,F=0,Y=0,q=0,G=0,re=0,ye=0,De=0,Fe=0,He=0,x=A[0],Me=A[1],Je=A[2],Ze=A[3],Qe=A[4],Ve=A[5],je=A[6],bt=A[7],it=A[8],pt=A[9],At=A[10],Et=A[11],Ct=A[12],Tt=A[13],Lt=A[14],Ut=A[15];u=E[0],C+=u*x,T+=u*Me,K+=u*Je,ne+=u*Ze,de+=u*Qe,ue+=u*Ve,ze+=u*je,he+=u*bt,Re+=u*it,ve+=u*pt,Oe+=u*At,Le+=u*Et,Ne+=u*Ct,Te+=u*Tt,Pe+=u*Lt,ge+=u*Ut,u=E[1],T+=u*x,K+=u*Me,ne+=u*Je,de+=u*Ze,ue+=u*Qe,ze+=u*Ve,he+=u*je,Re+=u*bt,ve+=u*it,Oe+=u*pt,Le+=u*At,Ne+=u*Et,Te+=u*Ct,Pe+=u*Tt,ge+=u*Lt,me+=u*Ut,u=E[2],K+=u*x,ne+=u*Me,de+=u*Je,ue+=u*Ze,ze+=u*Qe,he+=u*Ve,Re+=u*je,ve+=u*bt,Oe+=u*it,Le+=u*pt,Ne+=u*At,Te+=u*Et,Pe+=u*Ct,ge+=u*Tt,me+=u*Lt,le+=u*Ut,u=E[3],ne+=u*x,de+=u*Me,ue+=u*Je,ze+=u*Ze,he+=u*Qe,Re+=u*Ve,ve+=u*je,Oe+=u*bt,Le+=u*it,Ne+=u*pt,Te+=u*At,Pe+=u*Et,ge+=u*Ct,me+=u*Tt,le+=u*Lt,pe+=u*Ut,u=E[4],de+=u*x,ue+=u*Me,ze+=u*Je,he+=u*Ze,Re+=u*Qe,ve+=u*Ve,Oe+=u*je,Le+=u*bt,Ne+=u*it,Te+=u*pt,Pe+=u*At,ge+=u*Et,me+=u*Ct,le+=u*Tt,pe+=u*Lt,Ae+=u*Ut,u=E[5],ue+=u*x,ze+=u*Me,he+=u*Je,Re+=u*Ze,ve+=u*Qe,Oe+=u*Ve,Le+=u*je,Ne+=u*bt,Te+=u*it,Pe+=u*pt,ge+=u*At,me+=u*Et,le+=u*Ct,pe+=u*Tt,Ae+=u*Lt,ce+=u*Ut,u=E[6],ze+=u*x,he+=u*Me,Re+=u*Je,ve+=u*Ze,Oe+=u*Qe,Le+=u*Ve,Ne+=u*je,Te+=u*bt,Pe+=u*it,ge+=u*pt,me+=u*At,le+=u*Et,pe+=u*Ct,Ae+=u*Tt,ce+=u*Lt,D+=u*Ut,u=E[7],he+=u*x,Re+=u*Me,ve+=u*Je,Oe+=u*Ze,Le+=u*Qe,Ne+=u*Ve,Te+=u*je,Pe+=u*bt,ge+=u*it,me+=u*pt,le+=u*At,pe+=u*Et,Ae+=u*Ct,ce+=u*Tt,D+=u*Lt,F+=u*Ut,u=E[8],Re+=u*x,ve+=u*Me,Oe+=u*Je,Le+=u*Ze,Ne+=u*Qe,Te+=u*Ve,Pe+=u*je,ge+=u*bt,me+=u*it,le+=u*pt,pe+=u*At,Ae+=u*Et,ce+=u*Ct,D+=u*Tt,F+=u*Lt,Y+=u*Ut,u=E[9],ve+=u*x,Oe+=u*Me,Le+=u*Je,Ne+=u*Ze,Te+=u*Qe,Pe+=u*Ve,ge+=u*je,me+=u*bt,le+=u*it,pe+=u*pt,Ae+=u*At,ce+=u*Et,D+=u*Ct,F+=u*Tt,Y+=u*Lt,q+=u*Ut,u=E[10],Oe+=u*x,Le+=u*Me,Ne+=u*Je,Te+=u*Ze,Pe+=u*Qe,ge+=u*Ve,me+=u*je,le+=u*bt,pe+=u*it,Ae+=u*pt,ce+=u*At,D+=u*Et,F+=u*Ct,Y+=u*Tt,q+=u*Lt,G+=u*Ut,u=E[11],Le+=u*x,Ne+=u*Me,Te+=u*Je,Pe+=u*Ze,ge+=u*Qe,me+=u*Ve,le+=u*je,pe+=u*bt,Ae+=u*it,ce+=u*pt,D+=u*At,F+=u*Et,Y+=u*Ct,q+=u*Tt,G+=u*Lt,re+=u*Ut,u=E[12],Ne+=u*x,Te+=u*Me,Pe+=u*Je,ge+=u*Ze,me+=u*Qe,le+=u*Ve,pe+=u*je,Ae+=u*bt,ce+=u*it,D+=u*pt,F+=u*At,Y+=u*Et,q+=u*Ct,G+=u*Tt,re+=u*Lt,ye+=u*Ut,u=E[13],Te+=u*x,Pe+=u*Me,ge+=u*Je,me+=u*Ze,le+=u*Qe,pe+=u*Ve,Ae+=u*je,ce+=u*bt,D+=u*it,F+=u*pt,Y+=u*At,q+=u*Et,G+=u*Ct,re+=u*Tt,ye+=u*Lt,De+=u*Ut,u=E[14],Pe+=u*x,ge+=u*Me,me+=u*Je,le+=u*Ze,pe+=u*Qe,Ae+=u*Ve,ce+=u*je,D+=u*bt,F+=u*it,Y+=u*pt,q+=u*At,G+=u*Et,re+=u*Ct,ye+=u*Tt,De+=u*Lt,Fe+=u*Ut,u=E[15],ge+=u*x,me+=u*Me,le+=u*Je,pe+=u*Ze,Ae+=u*Qe,ce+=u*Ve,D+=u*je,F+=u*bt,Y+=u*it,q+=u*pt,G+=u*At,re+=u*Et,ye+=u*Ct,De+=u*Tt,Fe+=u*Lt,He+=u*Ut,C+=38*me,T+=38*le,K+=38*pe,ne+=38*Ae,de+=38*ce,ue+=38*D,ze+=38*F,he+=38*Y,Re+=38*q,ve+=38*G,Oe+=38*re,Le+=38*ye,Ne+=38*De,Te+=38*Fe,Pe+=38*He,m=1,u=C+m+65535,m=Math.floor(u/65536),C=u-m*65536,u=T+m+65535,m=Math.floor(u/65536),T=u-m*65536,u=K+m+65535,m=Math.floor(u/65536),K=u-m*65536,u=ne+m+65535,m=Math.floor(u/65536),ne=u-m*65536,u=de+m+65535,m=Math.floor(u/65536),de=u-m*65536,u=ue+m+65535,m=Math.floor(u/65536),ue=u-m*65536,u=ze+m+65535,m=Math.floor(u/65536),ze=u-m*65536,u=he+m+65535,m=Math.floor(u/65536),he=u-m*65536,u=Re+m+65535,m=Math.floor(u/65536),Re=u-m*65536,u=ve+m+65535,m=Math.floor(u/65536),ve=u-m*65536,u=Oe+m+65535,m=Math.floor(u/65536),Oe=u-m*65536,u=Le+m+65535,m=Math.floor(u/65536),Le=u-m*65536,u=Ne+m+65535,m=Math.floor(u/65536),Ne=u-m*65536,u=Te+m+65535,m=Math.floor(u/65536),Te=u-m*65536,u=Pe+m+65535,m=Math.floor(u/65536),Pe=u-m*65536,u=ge+m+65535,m=Math.floor(u/65536),ge=u-m*65536,C+=m-1+37*(m-1),m=1,u=C+m+65535,m=Math.floor(u/65536),C=u-m*65536,u=T+m+65535,m=Math.floor(u/65536),T=u-m*65536,u=K+m+65535,m=Math.floor(u/65536),K=u-m*65536,u=ne+m+65535,m=Math.floor(u/65536),ne=u-m*65536,u=de+m+65535,m=Math.floor(u/65536),de=u-m*65536,u=ue+m+65535,m=Math.floor(u/65536),ue=u-m*65536,u=ze+m+65535,m=Math.floor(u/65536),ze=u-m*65536,u=he+m+65535,m=Math.floor(u/65536),he=u-m*65536,u=Re+m+65535,m=Math.floor(u/65536),Re=u-m*65536,u=ve+m+65535,m=Math.floor(u/65536),ve=u-m*65536,u=Oe+m+65535,m=Math.floor(u/65536),Oe=u-m*65536,u=Le+m+65535,m=Math.floor(u/65536),Le=u-m*65536,u=Ne+m+65535,m=Math.floor(u/65536),Ne=u-m*65536,u=Te+m+65535,m=Math.floor(u/65536),Te=u-m*65536,u=Pe+m+65535,m=Math.floor(u/65536),Pe=u-m*65536,u=ge+m+65535,m=Math.floor(u/65536),ge=u-m*65536,C+=m-1+37*(m-1),d[0]=C,d[1]=T,d[2]=K,d[3]=ne,d[4]=de,d[5]=ue,d[6]=ze,d[7]=he,d[8]=Re,d[9]=ve,d[10]=Oe,d[11]=Le,d[12]=Ne,d[13]=Te,d[14]=Pe,d[15]=ge}function tt(d,E){fe(d,E,E)}function _t(d,E){var A=t(),u;for(u=0;u<16;u++)A[u]=E[u];for(u=253;u>=0;u--)tt(A,A),u!==2&&u!==4&&fe(A,A,E);for(u=0;u<16;u++)d[u]=A[u]}function Hn(d,E){var A=t(),u;for(u=0;u<16;u++)A[u]=E[u];for(u=250;u>=0;u--)tt(A,A),u!==1&&fe(A,A,E);for(u=0;u<16;u++)d[u]=A[u]}function Zr(d,E,A){var u=new Uint8Array(32),m=new Float64Array(80),C,T,K=t(),ne=t(),de=t(),ue=t(),ze=t(),he=t();for(T=0;T<31;T++)u[T]=E[T];for(u[31]=E[31]&127|64,u[0]&=248,O(m,A),T=0;T<16;T++)ne[T]=m[T],ue[T]=K[T]=de[T]=0;for(K[0]=ue[0]=1,T=254;T>=0;--T)C=u[T>>>3]>>>(T&7)&1,oe(K,ne,C),oe(de,ue,C),ie(ze,K,de),X(K,K,de),ie(de,ne,ue),X(ne,ne,ue),tt(ue,ze),tt(he,K),fe(K,de,K),fe(de,ne,ze),ie(ze,K,de),X(K,K,de),tt(ne,K),X(de,ue,he),fe(K,de,a),ie(K,K,ue),fe(de,de,K),fe(K,ue,he),fe(ue,ne,m),tt(ne,ze),oe(K,ne,C),oe(de,ue,C);for(T=0;T<16;T++)m[T+16]=K[T],m[T+32]=de[T],m[T+48]=ne[T],m[T+64]=ue[T];var Re=m.subarray(32),ve=m.subarray(16);return _t(Re,Re),fe(ve,ve,Re),S(d,ve),0}function en(d,E){return Zr(d,E,i)}function Er(d,E){return e(E,32),en(d,E)}function tn(d,E,A){var u=new Uint8Array(32);return Zr(u,A,E),H(d,r,u,z)}var Fn=se,yi=Z;function Qn(d,E,A,u,m,C){var T=new Uint8Array(32);return tn(T,m,C),Fn(d,E,A,u,T)}function rn(d,E,A,u,m,C){var T=new Uint8Array(32);return tn(T,m,C),yi(d,E,A,u,T)}var nn=[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 W(d,E,A,u){for(var m=new Int32Array(16),C=new Int32Array(16),T,K,ne,de,ue,ze,he,Re,ve,Oe,Le,Ne,Te,Pe,ge,me,le,pe,Ae,ce,D,F,Y,q,G,re,ye=d[0],De=d[1],Fe=d[2],He=d[3],x=d[4],Me=d[5],Je=d[6],Ze=d[7],Qe=E[0],Ve=E[1],je=E[2],bt=E[3],it=E[4],pt=E[5],At=E[6],Et=E[7],Ct=0;u>=128;){for(Ae=0;Ae<16;Ae++)ce=8*Ae+Ct,m[Ae]=A[ce+0]<<24|A[ce+1]<<16|A[ce+2]<<8|A[ce+3],C[Ae]=A[ce+4]<<24|A[ce+5]<<16|A[ce+6]<<8|A[ce+7];for(Ae=0;Ae<80;Ae++)if(T=ye,K=De,ne=Fe,de=He,ue=x,ze=Me,he=Je,Re=Ze,ve=Qe,Oe=Ve,Le=je,Ne=bt,Te=it,Pe=pt,ge=At,me=Et,D=Ze,F=Et,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=(x>>>14|it<<18)^(x>>>18|it<<14)^(it>>>9|x<<23),F=(it>>>14|x<<18)^(it>>>18|x<<14)^(x>>>9|it<<23),Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,D=x&Me^~x&Je,F=it&pt^~it&At,Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,D=nn[Ae*2],F=nn[Ae*2+1],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,D=m[Ae%16],F=C[Ae%16],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,le=G&65535|re<<16,pe=Y&65535|q<<16,D=le,F=pe,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=(ye>>>28|Qe<<4)^(Qe>>>2|ye<<30)^(Qe>>>7|ye<<25),F=(Qe>>>28|ye<<4)^(ye>>>2|Qe<<30)^(ye>>>7|Qe<<25),Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,D=ye&De^ye&Fe^De&Fe,F=Qe&Ve^Qe&je^Ve&je,Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,Re=G&65535|re<<16,me=Y&65535|q<<16,D=de,F=Ne,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=le,F=pe,Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,de=G&65535|re<<16,Ne=Y&65535|q<<16,De=T,Fe=K,He=ne,x=de,Me=ue,Je=ze,Ze=he,ye=Re,Ve=ve,je=Oe,bt=Le,it=Ne,pt=Te,At=Pe,Et=ge,Qe=me,Ae%16===15)for(ce=0;ce<16;ce++)D=m[ce],F=C[ce],Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=m[(ce+9)%16],F=C[(ce+9)%16],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,le=m[(ce+1)%16],pe=C[(ce+1)%16],D=(le>>>1|pe<<31)^(le>>>8|pe<<24)^le>>>7,F=(pe>>>1|le<<31)^(pe>>>8|le<<24)^(pe>>>7|le<<25),Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,le=m[(ce+14)%16],pe=C[(ce+14)%16],D=(le>>>19|pe<<13)^(pe>>>29|le<<3)^le>>>6,F=(pe>>>19|le<<13)^(le>>>29|pe<<3)^(pe>>>6|le<<26),Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,m[ce]=G&65535|re<<16,C[ce]=Y&65535|q<<16;D=ye,F=Qe,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=d[0],F=E[0],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,d[0]=ye=G&65535|re<<16,E[0]=Qe=Y&65535|q<<16,D=De,F=Ve,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=d[1],F=E[1],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,d[1]=De=G&65535|re<<16,E[1]=Ve=Y&65535|q<<16,D=Fe,F=je,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=d[2],F=E[2],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,d[2]=Fe=G&65535|re<<16,E[2]=je=Y&65535|q<<16,D=He,F=bt,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=d[3],F=E[3],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,d[3]=He=G&65535|re<<16,E[3]=bt=Y&65535|q<<16,D=x,F=it,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=d[4],F=E[4],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,d[4]=x=G&65535|re<<16,E[4]=it=Y&65535|q<<16,D=Me,F=pt,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=d[5],F=E[5],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,d[5]=Me=G&65535|re<<16,E[5]=pt=Y&65535|q<<16,D=Je,F=At,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=d[6],F=E[6],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,d[6]=Je=G&65535|re<<16,E[6]=At=Y&65535|q<<16,D=Ze,F=Et,Y=F&65535,q=F>>>16,G=D&65535,re=D>>>16,D=d[7],F=E[7],Y+=F&65535,q+=F>>>16,G+=D&65535,re+=D>>>16,q+=Y>>>16,G+=q>>>16,re+=G>>>16,d[7]=Ze=G&65535|re<<16,E[7]=Et=Y&65535|q<<16,Ct+=128,u-=128}return u}function ae(d,E,A){var u=new Int32Array(8),m=new Int32Array(8),C=new Uint8Array(256),T,K=A;for(u[0]=1779033703,u[1]=3144134277,u[2]=1013904242,u[3]=2773480762,u[4]=1359893119,u[5]=2600822924,u[6]=528734635,u[7]=1541459225,m[0]=4089235720,m[1]=2227873595,m[2]=4271175723,m[3]=1595750129,m[4]=2917565137,m[5]=725511199,m[6]=4215389547,m[7]=327033209,W(u,m,E,A),A%=128,T=0;T<A;T++)C[T]=E[K-A+T];for(C[A]=128,A=256-128*(A<112?1:0),C[A-9]=0,p(C,A-8,K/536870912|0,K<<3),W(u,m,C,A),T=0;T<8;T++)p(d,8*T,u[T],m[T]);return 0}function _e(d,E){var A=t(),u=t(),m=t(),C=t(),T=t(),K=t(),ne=t(),de=t(),ue=t();X(A,d[1],d[0]),X(ue,E[1],E[0]),fe(A,A,ue),ie(u,d[0],d[1]),ie(ue,E[0],E[1]),fe(u,u,ue),fe(m,d[3],E[3]),fe(m,m,c),fe(C,d[2],E[2]),ie(C,C,C),X(T,u,A),X(K,C,m),ie(ne,C,m),ie(de,u,A),fe(d[0],T,K),fe(d[1],de,ne),fe(d[2],ne,K),fe(d[3],T,de)}function ke(d,E,A){var u;for(u=0;u<4;u++)oe(d[u],E[u],A)}function Ge(d,E){var A=t(),u=t(),m=t();_t(m,E[2]),fe(A,E[0],m),fe(u,E[1],m),S(d,u),d[31]^=v(A)<<7}function xt(d,E,A){var u,m;for(j(d[0],s),j(d[1],o),j(d[2],o),j(d[3],s),m=255;m>=0;--m)u=A[m/8|0]>>(m&7)&1,ke(d,E,u),_e(E,d),_e(d,d),ke(d,E,u)}function ur(d,E){var A=[t(),t(),t(),t()];j(A[0],l),j(A[1],h),j(A[2],o),fe(A[3],l,h),xt(d,A,E)}function Vt(d,E,A){var u=new Uint8Array(64),m=[t(),t(),t(),t()],C;for(A||e(E,32),ae(u,E,32),u[0]&=248,u[31]&=127,u[31]|=64,ur(m,u),Ge(d,m),C=0;C<32;C++)E[C+32]=d[C];return 0}var sn=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 rt(d,E){var A,u,m,C;for(u=63;u>=32;--u){for(A=0,m=u-32,C=u-12;m<C;++m)E[m]+=A-16*E[u]*sn[m-(u-32)],A=E[m]+128>>8,E[m]-=A*256;E[m]+=A,E[u]=0}for(A=0,m=0;m<32;m++)E[m]+=A-(E[31]>>4)*sn[m],A=E[m]>>8,E[m]&=255;for(m=0;m<32;m++)E[m]-=A*sn[m];for(u=0;u<32;u++)E[u+1]+=E[u]>>8,d[u]=E[u]&255}function Bt(d){var E=new Float64Array(64),A;for(A=0;A<64;A++)E[A]=d[A];for(A=0;A<64;A++)d[A]=0;rt(d,E)}function It(d,E,A,u){var m=new Uint8Array(64),C=new Uint8Array(64),T=new Uint8Array(64),K,ne,de=new Float64Array(64),ue=[t(),t(),t(),t()];ae(m,u,32),m[0]&=248,m[31]&=127,m[31]|=64;var ze=A+64;for(K=0;K<A;K++)d[64+K]=E[K];for(K=0;K<32;K++)d[32+K]=m[32+K];for(ae(T,d.subarray(32),A+32),Bt(T),ur(ue,T),Ge(d,ue),K=32;K<64;K++)d[K]=u[K];for(ae(C,d,A+64),Bt(C),K=0;K<64;K++)de[K]=0;for(K=0;K<32;K++)de[K]=T[K];for(K=0;K<32;K++)for(ne=0;ne<32;ne++)de[K+ne]+=C[K]*m[ne];return rt(d.subarray(32),de),ze}function dt(d,E){var A=t(),u=t(),m=t(),C=t(),T=t(),K=t(),ne=t();return j(d[2],o),O(d[1],E),tt(m,d[1]),fe(C,m,f),X(m,m,d[2]),ie(C,d[2],C),tt(T,C),tt(K,T),fe(ne,K,T),fe(A,ne,m),fe(A,A,C),Hn(A,A),fe(A,A,m),fe(A,A,C),fe(A,A,C),fe(d[0],A,C),tt(u,d[0]),fe(u,u,C),k(u,m)&&fe(d[0],d[0],g),tt(u,d[0]),fe(u,u,C),k(u,m)?-1:(v(d[0])===E[31]>>7&&X(d[0],s,d[0]),fe(d[3],d[0],d[1]),0)}function ft(d,E,A,u){var m,C,T=new Uint8Array(32),K=new Uint8Array(64),ne=[t(),t(),t(),t()],de=[t(),t(),t(),t()];if(C=-1,A<64||dt(de,u))return-1;for(m=0;m<A;m++)d[m]=E[m];for(m=0;m<32;m++)d[m+32]=u[m];if(ae(K,d,A),Bt(K),xt(ne,de,K),ur(de,E.subarray(32)),_e(ne,de),Ge(T,ne),A-=64,R(E,0,T,0)){for(m=0;m<A;m++)d[m]=0;return-1}for(m=0;m<A;m++)d[m]=E[m+64];return C=A,C}var tr=32,gt=24,qr=32,on=16,Mn=32,wi=32,$n=32,Wn=32,Cs=32,La=gt,Eh=qr,mh=on,mr=64,Kr=32,an=64,Bs=32,ks=64;n.lowlevel={crypto_core_hsalsa20:H,crypto_stream_xor:w,crypto_stream:y,crypto_stream_salsa20_xor:J,crypto_stream_salsa20:V,crypto_onetimeauth:$,crypto_onetimeauth_verify:M,crypto_verify_16:b,crypto_verify_32:R,crypto_secretbox:se,crypto_secretbox_open:Z,crypto_scalarmult:Zr,crypto_scalarmult_base:en,crypto_box_beforenm:tn,crypto_box_afternm:Fn,crypto_box:Qn,crypto_box_open:rn,crypto_box_keypair:Er,crypto_hash:ae,crypto_sign:It,crypto_sign_keypair:Vt,crypto_sign_open:ft,crypto_secretbox_KEYBYTES:tr,crypto_secretbox_NONCEBYTES:gt,crypto_secretbox_ZEROBYTES:qr,crypto_secretbox_BOXZEROBYTES:on,crypto_scalarmult_BYTES:Mn,crypto_scalarmult_SCALARBYTES:wi,crypto_box_PUBLICKEYBYTES:$n,crypto_box_SECRETKEYBYTES:Wn,crypto_box_BEFORENMBYTES:Cs,crypto_box_NONCEBYTES:La,crypto_box_ZEROBYTES:Eh,crypto_box_BOXZEROBYTES:mh,crypto_sign_BYTES:mr,crypto_sign_PUBLICKEYBYTES:Kr,crypto_sign_SECRETKEYBYTES:an,crypto_sign_SEEDBYTES:Bs,crypto_hash_BYTES:ks};function Ua(d,E){if(d.length!==tr)throw new Error("bad key size");if(E.length!==gt)throw new Error("bad nonce size")}function _h(d,E){if(d.length!==$n)throw new Error("bad public key size");if(E.length!==Wn)throw new Error("bad secret key size")}function jt(){var d,E;for(E=0;E<arguments.length;E++)if((d=Object.prototype.toString.call(arguments[E]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+d+", use Uint8Array")}function Oa(d){for(var E=0;E<d.length;E++)d[E]=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(d){var E=new Uint8Array(d);return e(E,d),E},n.secretbox=function(d,E,A){jt(d,E,A),Ua(A,E);for(var u=new Uint8Array(qr+d.length),m=new Uint8Array(u.length),C=0;C<d.length;C++)u[C+qr]=d[C];return se(m,u,u.length,E,A),m.subarray(on)},n.secretbox.open=function(d,E,A){jt(d,E,A),Ua(A,E);for(var u=new Uint8Array(on+d.length),m=new Uint8Array(u.length),C=0;C<d.length;C++)u[C+on]=d[C];return u.length<32||Z(m,u,u.length,E,A)!==0?!1:m.subarray(qr)},n.secretbox.keyLength=tr,n.secretbox.nonceLength=gt,n.secretbox.overheadLength=on,n.scalarMult=function(d,E){if(jt(d,E),d.length!==wi)throw new Error("bad n size");if(E.length!==Mn)throw new Error("bad p size");var A=new Uint8Array(Mn);return Zr(A,d,E),A},n.scalarMult.base=function(d){if(jt(d),d.length!==wi)throw new Error("bad n size");var E=new Uint8Array(Mn);return en(E,d),E},n.scalarMult.scalarLength=wi,n.scalarMult.groupElementLength=Mn,n.box=function(d,E,A,u){var m=n.box.before(A,u);return n.secretbox(d,E,m)},n.box.before=function(d,E){jt(d,E),_h(d,E);var A=new Uint8Array(Cs);return tn(A,d,E),A},n.box.after=n.secretbox,n.box.open=function(d,E,A,u){var m=n.box.before(A,u);return n.secretbox.open(d,E,m)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var d=new Uint8Array($n),E=new Uint8Array(Wn);return Er(d,E),{publicKey:d,secretKey:E}},n.box.keyPair.fromSecretKey=function(d){if(jt(d),d.length!==Wn)throw new Error("bad secret key size");var E=new Uint8Array($n);return en(E,d),{publicKey:E,secretKey:new Uint8Array(d)}},n.box.publicKeyLength=$n,n.box.secretKeyLength=Wn,n.box.sharedKeyLength=Cs,n.box.nonceLength=La,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(d,E){if(jt(d,E),E.length!==an)throw new Error("bad secret key size");var A=new Uint8Array(mr+d.length);return It(A,d,d.length,E),A},n.sign.open=function(d,E){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(jt(d,E),E.length!==Kr)throw new Error("bad public key size");var A=new Uint8Array(d.length),u=ft(A,d,d.length,E);if(u<0)return null;for(var m=new Uint8Array(u),C=0;C<m.length;C++)m[C]=A[C];return m},n.sign.detached=function(d,E){for(var A=n.sign(d,E),u=new Uint8Array(mr),m=0;m<u.length;m++)u[m]=A[m];return u},n.sign.detached.verify=function(d,E,A){if(jt(d,E,A),E.length!==mr)throw new Error("bad signature size");if(A.length!==Kr)throw new Error("bad public key size");var u=new Uint8Array(mr+d.length),m=new Uint8Array(mr+d.length),C;for(C=0;C<mr;C++)u[C]=E[C];for(C=0;C<d.length;C++)u[C+mr]=d[C];return ft(m,u,u.length,A)>=0},n.sign.keyPair=function(){var d=new Uint8Array(Kr),E=new Uint8Array(an);return Vt(d,E),{publicKey:d,secretKey:E}},n.sign.keyPair.fromSecretKey=function(d){if(jt(d),d.length!==an)throw new Error("bad secret key size");for(var E=new Uint8Array(Kr),A=0;A<E.length;A++)E[A]=d[32+A];return{publicKey:E,secretKey:new Uint8Array(d)}},n.sign.keyPair.fromSeed=function(d){if(jt(d),d.length!==Bs)throw new Error("bad seed size");for(var E=new Uint8Array(Kr),A=new Uint8Array(an),u=0;u<32;u++)A[u]=d[u];return Vt(E,A,!0),{publicKey:E,secretKey:A}},n.sign.publicKeyLength=Kr,n.sign.secretKeyLength=an,n.sign.seedLength=Bs,n.sign.signatureLength=mr,n.hash=function(d){jt(d);var E=new Uint8Array(ks);return ae(E,d,d.length),E},n.hash.hashLength=ks,n.verify=function(d,E){return jt(d,E),d.length===0||E.length===0||d.length!==E.length?!1:_(d,0,E,0,d.length)===0},n.setPRNG=function(d){e=d},(function(){var d=typeof self<"u"?self.crypto||self.msCrypto:null;if(d&&d.getRandomValues){var E=65536;n.setPRNG(function(A,u){var m,C=new Uint8Array(u);for(m=0;m<u;m+=E)d.getRandomValues(C.subarray(m,m+Math.min(u-m,E)));for(m=0;m<u;m++)A[m]=C[m];Oa(C)})}else typeof require<"u"&&(d=require("crypto"),d&&d.randomBytes&&n.setPRNG(function(A,u){var m,C=d.randomBytes(u);for(m=0;m<u;m++)A[m]=C[m];Oa(C)}))})()})(typeof Di<"u"&&Di.exports?Di.exports:self.nacl=self.nacl||{})});var $s=nt((pm,vc)=>{"use strict";var Fs=Rc().lowlevel.crypto_hash,br=0,Vr=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 Fi(n,t,e){return(n[0][t[e+3]]+n[1][t[e+2]]^n[2][t[e+1]])+n[3][t[e]]}Vr.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]^=Fi(this.S,t,0)^this.P[e],n[0]^=Fi(this.S,t,4)^this.P[e+1];var r=n[0];n[0]=n[1]^this.P[17],n[1]=r};Vr.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]^=Fi(this.S,t,0)^this.P[e],n[0]^=Fi(this.S,t,4)^this.P[e-1];var r=n[0];n[0]=n[1]^this.P[0],n[1]=r};function Yr(n,t){var e,r=0;for(e=0;e<4;e++,br++)br>=t&&(br=0),r=r<<8|n[br];return r}Vr.prototype.expand0state=function(n,t){var e=new Uint32Array(2),r,i,s=new Uint8Array(e.buffer);for(r=0,br=0;r<18;r++)this.P[r]^=Yr(n,t);for(br=0,r=0;r<18;r+=2)this.encipher(e,s),this.P[r]=e[0],this.P[r+1]=e[1];for(r=0;r<4;r++)for(i=0;i<256;i+=2)this.encipher(e,s),this.S[r][i]=e[0],this.S[r][i+1]=e[1]};Vr.prototype.expandstate=function(n,t,e,r){var i=new Uint32Array(2),s,o;for(s=0,br=0;s<18;s++)this.P[s]^=Yr(e,r);for(s=0,br=0;s<18;s+=2)i[0]^=Yr(n,t),i[1]^=Yr(n,t),this.encipher(i),this.P[s]=i[0],this.P[s+1]=i[1];for(s=0;s<4;s++)for(o=0;o<256;o+=2)i[0]^=Yr(n,t),i[1]^=Yr(n,t),this.encipher(i),this.S[s][o]=i[0],this.S[s][o+1]=i[1];br=0};Vr.prototype.enc=function(n,t){for(var e=0;e<t;e++)this.encipher(n.subarray(e*2))};Vr.prototype.dec=function(n,t){for(var e=0;e<t;e++)this.decipher(n.subarray(e*2))};var Hi=8,Qs=32;function Ms(n,t,e){var r=new Vr,i=new Uint32Array(Hi),s,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),s=0;s<64;s++)r.expand0state(t,64),r.expand0state(n,64);for(s=0;s<Hi;s++)i[s]=Yr(o,o.byteLength);for(s=0;s<64;s++)r.enc(i,i.byteLength/8);for(s=0;s<Hi;s++)e[4*s+3]=i[s]>>>24,e[4*s+2]=i[s]>>>16,e[4*s+1]=i[s]>>>8,e[4*s+0]=i[s]}function hd(n,t,e,r,i,s,o){var a=new Uint8Array(64),f=new Uint8Array(64),c=new Uint8Array(Qs),l=new Uint8Array(Qs),h=new Uint8Array(r+4),g,p,_,b,R,P,L=s;if(o<1||t===0||r===0||s===0||s>c.byteLength*c.byteLength||r>1<<20)return-1;for(b=Math.floor((s+c.byteLength-1)/c.byteLength),_=Math.floor((s+b-1)/b),g=0;g<r;g++)h[g]=e[g];for(Fs(a,n,t),P=1;s>0;P++){for(h[r+0]=P>>>24,h[r+1]=P>>>16,h[r+2]=P>>>8,h[r+3]=P,Fs(f,h,r+4),Ms(a,f,l),g=c.byteLength;g--;)c[g]=l[g];for(g=1;g<o;g++)for(Fs(f,l,l.byteLength),Ms(a,f,l),p=0;p<c.byteLength;p++)c[p]^=l[p];for(_=Math.min(_,s),g=0;g<_&&(R=g*b+(P-1),!(R>=L));g++)i[R]=c[g];s-=g}return 0}vc.exports={BLOCKS:Hi,HASHSIZE:Qs,hash:Ms,pbkdf:hd}});var Sr=nt((Am,Mi)=>{"use strict";var xr=require("crypto"),En;try{En=require("cpu-features")()}catch{}var{bindingAvailable:Nc,CIPHER_INFO:dd,MAC_INFO:gd}=Tr(),Pc=(()=>{if(typeof xr.sign=="function"&&typeof xr.verify=="function"){let n=`-----BEGIN PRIVATE KEY-----\r
21
+ MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
22
+ -----END PRIVATE KEY-----`,t=Buffer.from("a"),e,r;try{e=xr.sign(null,t,n),r=xr.verify(null,t,n,e)}catch{}return Buffer.isBuffer(e)&&e.length===64&&r===!0}return!1})(),Tc=typeof xr.diffieHellman=="function"&&typeof xr.generateKeyPairSync=="function"&&typeof xr.createPublicKey=="function",Qi=["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"];Tc&&(Qi.unshift("curve25519-sha256"),Qi.unshift("curve25519-sha256@libssh.org"));var pd=Qi.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),Ws=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];Pc&&Ws.unshift("ssh-ed25519");var Ad=Ws.concat(["ssh-dss"]),Lc=(()=>{let n=xr.getCiphers();return t=>n.includes(dd[t].sslName)})(),Pr=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];En&&En.flags&&!En.flags.aes?Nc?Pr.unshift("chacha20-poly1305@openssh.com"):Pr.push("chacha20-poly1305@openssh.com"):Nc&&En&&En.arch==="x86"?Pr.splice(4,0,"chacha20-poly1305@openssh.com"):Pr.push("chacha20-poly1305@openssh.com");Pr=Pr.filter(Lc);var Ed=Pr.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(Lc)),Uc=(()=>{let n=xr.getHashes();return t=>n.includes(gd[t].sslName)})(),Oc=["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(Uc),md=Oc.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(Uc)),Dc=["none","zlib@openssh.com","zlib"],_d=Dc.concat([]),An={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};Mi.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:An,COMPAT_CHECKS:[["Cisco-1.25",An.BAD_DHGEX],[/^Cisco-1[.]/,An.BUG_DHGEX_LARGE],[/^[0-9.]+$/,An.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,An.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,An.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:Qi,SUPPORTED_KEX:pd,DEFAULT_SERVER_HOST_KEY:Ws,SUPPORTED_SERVER_HOST_KEY:Ad,DEFAULT_CIPHER:Pr,SUPPORTED_CIPHER:Ed,DEFAULT_MAC:Oc,SUPPORTED_MAC:md,DEFAULT_COMPRESSION:Dc,SUPPORTED_COMPRESSION:_d,curve25519Supported:Tc,eddsaSupported:Pc};Mi.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(Mi.exports.DISCONNECT_REASON)).reduce((n,[t,e])=>({...n,[e]:t}),{})});var or=nt((Em,Mc)=>{"use strict";var ir=Kn().Ber,$i,Qc=Buffer[Symbol.species],bd=Object.getPrototypeOf(Uint8Array.prototype).fill;function Hc(n,t){return n[t++]*16777216+n[t++]*65536+n[t++]*256+n[t]}function Gn(n,t,e,r,i){i||(i=0),r>n.length&&(r=n.length);let s=r-e,o=t.length-i;return s>o&&(s=o),t.set(new Uint8Array(n.buffer,n.byteOffset+e,s),i),s}function Yn(n,t,e){return e===void 0&&(e=n.length),new Qc(n.buffer,n.byteOffset+t,e-t)}function Ks(){let n=0,t,e={init:(r,i)=>{t=r,n=typeof i=="number"?i: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,i)=>{typeof r=="number"&&(i=r,r=void 0);let s=e.readUInt32BE();if(s!==void 0&&!(t.length-n<s||typeof i=="number"&&s>i))return r?Buffer.isBuffer(r)?Gn(t,r,n,n+=s):t.utf8Slice(n,n+=s):Yn(t,n,n+=s)},readRaw:r=>{if(t){if(typeof r!="number")return Yn(t,n,n+=t.length-n);if(t.length-n>=r)return Yn(t,n,n+=r)}}};return e}function Fc(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 qs(n,t,e){return n[e++]=t>>>24,n[e++]=t>>>16,n[e++]=t>>>8,n[e++]=t,e}var Wi=Ks();Mc.exports={bufferCopy:Gn,bufferSlice:Yn,FastBuffer:Qc,bufferFill:(n,t,e,r)=>bd.call(n,t,e,r),makeError:Fc,doFatalError:(n,t,e,r)=>{let i;return $i===void 0&&({DISCONNECT_REASON:$i}=Sr()),t instanceof Error?(i=t,typeof e!="number"?r=$i.PROTOCOL_ERROR:r=e):i=Fc(t,e,!0),typeof r!="number"&&(r=$i.PROTOCOL_ERROR),n.disconnect(r),n._destruct(),n._onError(i),1/0},readUInt32BE:Hc,writeUInt32BE:qs,writeUInt32LE:(n,t,e)=>(n[e++]=t,n[e++]=t>>>8,n[e++]=t>>>16,n[e++]=t>>>24,e),makeBufferParser:Ks,bufferParser:Ks(),readString:(n,t,e,r)=>{typeof e=="number"&&(r=e,e=void 0),t===void 0&&(t=0);let i=n.length-t;if(t<0||t>=n.length||i<4)return;let s=Hc(n,t);if(i<4+s||typeof r=="number"&&s>r)return;t+=4;let o=t+s;return n._pos=o,e?Buffer.isBuffer(e)?Gn(n,e,t,o):n.utf8Slice(t,o):Yn(n,t,o)},sigSSHToASN1:(n,t)=>{switch(t){case"ssh-dss":{if(n.length>40)return n;let e=new ir.Writer;e.startSequence();let r=n.slice(0,20),i=n.slice(20);if(r[0]&128){let s=Buffer.allocUnsafe(21);s[0]=0,r.copy(s,1),r=s}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(i[0]&128){let s=Buffer.allocUnsafe(21);s[0]=0,i.copy(s,1),i=s}else i[0]===0&&!(i[1]&128)&&(i=i.slice(1));return e.writeBuffer(r,ir.Integer),e.writeBuffer(i,ir.Integer),e.endSequence(),e.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{Wi.init(n,0);let e=Wi.readString(),r=Wi.readString();if(Wi.clear(),e===void 0||r===void 0)return;let i=new ir.Writer;return i.startSequence(),i.writeBuffer(e,ir.Integer),i.writeBuffer(r,ir.Integer),i.endSequence(),i.buffer}default:return n}},convertSignature:(n,t)=>{switch(t){case"ssh-dss":{if(n.length<=40)return n;let e=new ir.Reader(n);e.readSequence();let r=e.readString(ir.Integer,!0),i=e.readString(ir.Integer,!0),s=0,o=0;if(r.length<20){let f=Buffer.allocUnsafe(20);f.set(r,1),r=f,r[0]=0}if(i.length<20){let f=Buffer.allocUnsafe(20);f.set(i,1),i=f,i[0]=0}r.length>20&&r[0]===0&&(s=1),i.length>20&&i[0]===0&&(o=1);let a=Buffer.allocUnsafe(r.length-s+(i.length-o));return Gn(r,a,s,r.length,0),Gn(i,a,o,i.length,r.length-s),a}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(n[0]===0)return n;let e=new ir.Reader(n);e.readSequence();let r=e.readString(ir.Integer,!0),i=e.readString(ir.Integer,!0);if(r===null||i===null)return;let s=Buffer.allocUnsafe(4+r.length+4+i.length);return qs(s,r.length,0),s.set(r,4),qs(s,i.length,4+r.length),s.set(i,8+r.length),s}}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 $c=nt((qi,Ys)=>{var Gs=(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,i;e.ready=new Promise(function(W,ae){r=W,i=ae});var s={},o;for(o in e)e.hasOwnProperty(o)&&(s[o]=e[o]);var a=typeof window=="object",f=typeof importScripts=="function",c=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",l="",h,g,p,_,b;c?(l=f?require("path").dirname(l)+"/":__dirname+"/",h=function(W,ae){var _e=Er(W);return _e?ae?_e:_e.toString():(_||(_=require("fs")),b||(b=require("path")),W=b.normalize(W),_.readFileSync(W,ae?null:"utf8"))},p=function(W){return W=h(W,!0),W.buffer||(W=new Uint8Array(W)),z(W.buffer),W},g=function(W,ae,_e){var ke=Er(W);ke&&ae(ke),_||(_=require("fs")),b||(b=require("path")),W=b.normalize(W),_.readFile(W,function(Ge,xt){Ge?_e(Ge):ae(xt.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),e.inspect=function(){return"[Emscripten Module object]"}):(a||f)&&(f?l=self.location.href:typeof document<"u"&&document.currentScript&&(l=document.currentScript.src),n&&(l=n),l.indexOf("blob:")!==0?l=l.substr(0,l.lastIndexOf("/")+1):l="",h=function(W){try{var ae=new XMLHttpRequest;return ae.open("GET",W,!1),ae.send(null),ae.responseText}catch(Ge){if(W=Er(W)){ae=[];for(var _e=0;_e<W.length;_e++){var ke=W[_e];255<ke&&(Zr&&z(!1,"Character code "+ke+" ("+String.fromCharCode(ke)+") at offset "+_e+" not in 0x00-0xFF."),ke&=255),ae.push(String.fromCharCode(ke))}return ae.join("")}throw Ge}},f&&(p=function(W){try{var ae=new XMLHttpRequest;return ae.open("GET",W,!1),ae.responseType="arraybuffer",ae.send(null),new Uint8Array(ae.response)}catch(_e){if(W=Er(W))return W;throw _e}}),g=function(W,ae,_e){var ke=new XMLHttpRequest;ke.open("GET",W,!0),ke.responseType="arraybuffer",ke.onload=function(){if(ke.status==200||ke.status==0&&ke.response)ae(ke.response);else{var Ge=Er(W);Ge?ae(Ge.buffer):_e()}},ke.onerror=_e,ke.send(null)}),e.print||console.log.bind(console);var R=e.printErr||console.warn.bind(console);for(o in s)s.hasOwnProperty(o)&&(e[o]=s[o]);s=null;var P;e.wasmBinary&&(P=e.wasmBinary);var L=e.noExitRuntime||!0;typeof WebAssembly!="object"&&O("no native wasm support detected");var ee,H=!1;function z(W,ae){W||O("Assertion failed: "+ae)}function J(W){var ae=e["_"+W];return z(ae,"Cannot call unknown function "+W+", make sure it is exported"),ae}function V(W,ae,_e,ke){var Ge={string:function(rt){var Bt=0;if(rt!=null&&rt!==0){var It=(rt.length<<2)+1;Bt=Qn(It);var dt=Bt,ft=$;if(0<It){It=dt+It-1;for(var tr=0;tr<rt.length;++tr){var gt=rt.charCodeAt(tr);if(55296<=gt&&57343>=gt){var qr=rt.charCodeAt(++tr);gt=65536+((gt&1023)<<10)|qr&1023}if(127>=gt){if(dt>=It)break;ft[dt++]=gt}else{if(2047>=gt){if(dt+1>=It)break;ft[dt++]=192|gt>>6}else{if(65535>=gt){if(dt+2>=It)break;ft[dt++]=224|gt>>12}else{if(dt+3>=It)break;ft[dt++]=240|gt>>18,ft[dt++]=128|gt>>12&63}ft[dt++]=128|gt>>6&63}ft[dt++]=128|gt&63}}ft[dt]=0}}return Bt},array:function(rt){var Bt=Qn(rt.length);return U.set(rt,Bt),Bt}},xt=J(W),ur=[];if(W=0,ke)for(var Vt=0;Vt<ke.length;Vt++){var sn=Ge[_e[Vt]];sn?(W===0&&(W=Fn()),ur[Vt]=sn(ke[Vt])):ur[Vt]=ke[Vt]}return _e=xt.apply(null,ur),_e=(function(rt){if(ae==="string")if(rt){for(var Bt=$,It=rt+NaN,dt=rt;Bt[dt]&&!(dt>=It);)++dt;if(16<dt-rt&&Bt.subarray&&y)rt=y.decode(Bt.subarray(rt,dt));else{for(It="";rt<dt;){var ft=Bt[rt++];if(ft&128){var tr=Bt[rt++]&63;if((ft&224)==192)It+=String.fromCharCode((ft&31)<<6|tr);else{var gt=Bt[rt++]&63;ft=(ft&240)==224?(ft&15)<<12|tr<<6|gt:(ft&7)<<18|tr<<12|gt<<6|Bt[rt++]&63,65536>ft?It+=String.fromCharCode(ft):(ft-=65536,It+=String.fromCharCode(55296|ft>>10,56320|ft&1023))}}else It+=String.fromCharCode(ft)}rt=It}}else rt="";else rt=ae==="boolean"?!!rt:rt;return rt})(_e),W!==0&&yi(W),_e}var y=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,w,U,$;function M(){var W=ee.buffer;w=W,e.HEAP8=U=new Int8Array(W),e.HEAP16=new Int16Array(W),e.HEAP32=new Int32Array(W),e.HEAPU8=$=new Uint8Array(W),e.HEAPU16=new Uint16Array(W),e.HEAPU32=new Uint32Array(W),e.HEAPF32=new Float32Array(W),e.HEAPF64=new Float64Array(W)}var se,Z=[],j=[],te=[];function oe(){var W=e.preRun.shift();Z.unshift(W)}var S=0,k=null,v=null;e.preloadedImages={},e.preloadedAudios={};function O(W){throw e.onAbort&&e.onAbort(W),R(W),H=!0,W=new WebAssembly.RuntimeError("abort("+W+"). Build with -s ASSERTIONS=1 for more info."),i(W),W}var ie="data:application/octet-stream;base64,",X;if(X="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==",!X.startsWith(ie)){var fe=X;X=e.locateFile?e.locateFile(fe,l):l+fe}function tt(){var W=X;try{if(W==X&&P)return new Uint8Array(P);var ae=Er(W);if(ae)return ae;if(p)return p(W);throw"both async and sync fetching of the wasm failed"}catch(_e){O(_e)}}function _t(){if(!P&&(a||f)){if(typeof fetch=="function"&&!X.startsWith("file://"))return fetch(X,{credentials:"same-origin"}).then(function(W){if(!W.ok)throw"failed to load wasm binary file at '"+X+"'";return W.arrayBuffer()}).catch(function(){return tt()});if(g)return new Promise(function(W,ae){g(X,function(_e){W(new Uint8Array(_e))},ae)})}return Promise.resolve().then(function(){return tt()})}function Hn(W){for(;0<W.length;){var ae=W.shift();if(typeof ae=="function")ae(e);else{var _e=ae.m;typeof _e=="number"?ae.l===void 0?se.get(_e)():se.get(_e)(ae.l):_e(ae.l===void 0?null:ae.l)}}}var Zr=!1,en=typeof atob=="function"?atob:function(W){var ae="",_e=0;W=W.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(W.charAt(_e++)),Ge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(W.charAt(_e++)),xt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(W.charAt(_e++)),ur="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(W.charAt(_e++));ke=ke<<2|Ge>>4,Ge=(Ge&15)<<4|xt>>2;var Vt=(xt&3)<<6|ur;ae+=String.fromCharCode(ke),xt!==64&&(ae+=String.fromCharCode(Ge)),ur!==64&&(ae+=String.fromCharCode(Vt))}while(_e<W.length);return ae};function Er(W){if(W.startsWith(ie)){if(W=W.slice(ie.length),typeof c=="boolean"&&c){var ae=Buffer.from(W,"base64");ae=new Uint8Array(ae.buffer,ae.byteOffset,ae.byteLength)}else try{var _e=en(W),ke=new Uint8Array(_e.length);for(W=0;W<_e.length;++W)ke[W]=_e.charCodeAt(W);ae=ke}catch{throw Error("Converting base64 string to bytes failed.")}return ae}}var tn={a:function(W){var ae=$.length;if(W>>>=0,2147483648<W)return!1;for(var _e=1;4>=_e;_e*=2){var ke=ae*(1+.2/_e);ke=Math.min(ke,W+100663296),ke=Math.max(W,ke),0<ke%65536&&(ke+=65536-ke%65536);e:{try{ee.grow(Math.min(2147483648,ke)-w.byteLength+65535>>>16),M();var Ge=1;break e}catch{}Ge=void 0}if(Ge)return!0}return!1}};(function(){function W(Ge){e.asm=Ge.exports,ee=e.asm.b,M(),se=e.asm.j,j.unshift(e.asm.c),S--,e.monitorRunDependencies&&e.monitorRunDependencies(S),S==0&&(k!==null&&(clearInterval(k),k=null),v&&(Ge=v,v=null,Ge()))}function ae(Ge){W(Ge.instance)}function _e(Ge){return _t().then(function(xt){return WebAssembly.instantiate(xt,ke)}).then(Ge,function(xt){R("failed to asynchronously prepare wasm: "+xt),O(xt)})}var ke={a:tn};if(S++,e.monitorRunDependencies&&e.monitorRunDependencies(S),e.instantiateWasm)try{return e.instantiateWasm(ke,W)}catch(Ge){return R("Module.instantiateWasm callback failed with error: "+Ge),!1}return(function(){return P||typeof WebAssembly.instantiateStreaming!="function"||X.startsWith(ie)||X.startsWith("file://")||typeof fetch!="function"?_e(ae):fetch(X,{credentials:"same-origin"}).then(function(Ge){return WebAssembly.instantiateStreaming(Ge,ke).then(ae,function(xt){return R("wasm streaming compile failed: "+xt),R("falling back to ArrayBuffer instantiation"),_e(ae)})})})().catch(i),{}})(),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 Fn=e.stackSave=function(){return(Fn=e.stackSave=e.asm.e).apply(null,arguments)},yi=e.stackRestore=function(){return(yi=e.stackRestore=e.asm.f).apply(null,arguments)},Qn=e.stackAlloc=function(){return(Qn=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(W,ae,_e,ke){_e=_e||[];var Ge=_e.every(function(xt){return xt==="number"});return ae!=="string"&&Ge&&!ke?J(W):function(){return V(W,ae,_e,arguments)}};var rn;v=function W(){rn||nn(),rn||(v=W)};function nn(){function W(){if(!rn&&(rn=!0,e.calledRun=!0,!H)){if(Hn(j),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;){var ae=e.postRun.shift();te.unshift(ae)}Hn(te)}}if(!(0<S)){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)oe();Hn(Z),0<S||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),W()},1)):W())}}if(e.run=nn,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return nn(),t.ready})})();typeof qi=="object"&&typeof Ys=="object"?Ys.exports=Gs:typeof define=="function"&&define.amd?define([],function(){return Gs}):typeof qi=="object"&&(qi.createPoly1305=Gs)});var Tr=nt((mm,Yc)=>{"use strict";var{createCipheriv:_n,createDecipheriv:Ki,createHmac:Vs,randomFillSync:jr,timingSafeEqual:js}=require("crypto"),{readUInt32BE:jn,writeUInt32BE:Jt}=or(),Lr=Buffer[Symbol.species],Wc=2**32-1,qc=Buffer.alloc(0),mn=Buffer.alloc(4),Gi=new Map,Xr=35e3,Xs,lo,ho,go,po,Ao,Eo;try{Xs=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:lo,ChaChaPolyCipher:ho,GenericCipher:go,AESGCMDecipher:po,ChaChaPolyDecipher:Ao,GenericDecipher:Eo}=Xs}catch{}var Pt=1,xd=(()=>{function n(t,e,r,i,s,o,a){return{sslName:t,blockLen:e,keyLen:r,ivLen:i!==0||a&Pt?i:e,authLen:s,discardLen:o,stream:!!(a&Pt)}}return{"chacha20-poly1305@openssh.com":n("chacha20",8,64,0,16,0,Pt),"aes128-gcm":n("aes-128-gcm",16,16,12,16,0,Pt),"aes256-gcm":n("aes-256-gcm",16,32,12,16,0,Pt),"aes128-gcm@openssh.com":n("aes-128-gcm",16,16,12,16,0,Pt),"aes256-gcm@openssh.com":n("aes-256-gcm",16,32,12,16,0,Pt),"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,Pt),"aes192-ctr":n("aes-192-ctr",16,24,16,0,0,Pt),"aes256-ctr":n("aes-256-ctr",16,32,16,0,0,Pt),"3des-ctr":n("des-ede3",8,24,8,0,0,Pt),"blowfish-ctr":n("bf-ecb",8,16,8,0,0,Pt),"cast128-ctr":n("cast5-ecb",8,16,8,0,0,Pt),arcfour:n("rc4",8,16,0,0,1536,Pt),arcfour128:n("rc4",8,16,0,0,1536,Pt),arcfour256:n("rc4",8,32,0,0,1536,Pt),arcfour512:n("rc4",8,64,0,0,1536,Pt)}})(),Sd=(()=>{function n(t,e,r,i){return{sslName:t,len:e,actualLen:r,isETM:i}}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)}})(),zs=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 i=Buffer.allocUnsafe(e);return Jt(i,e-4,0),i[4]=r,jr(i,5+t,r),i}encrypt(t){this._dead||(this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},Kc=Buffer.alloc(32),qt=Buffer.alloc(16),Vn,Xn,mo,Js=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 i=Buffer.allocUnsafe(e);return Jt(i,e-4,0),i[4]=r,jr(i,5+t,r),i}encrypt(t){if(this._dead)return;qt[0]=0,Jt(qt,this.outSeqno,12);let e=_n("chacha20",this._encKeyMain,qt).update(Kc),r=_n("chacha20",this._encKeyPktLen,qt).update(t.slice(0,4));this._onWrite(r),qt[0]=1;let i=_n("chacha20",this._encKeyMain,qt).update(t.slice(4));this._onWrite(i),mo(Xn,r,r.length,i,i.length,e);let s=Buffer.allocUnsafe(16);s.set(new Uint8Array(Vn.HEAPU8.buffer,Xn,16),0),this._onWrite(s),this.outSeqno=this.outSeqno+1>>>0}},Zs=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 i=Buffer.allocUnsafe(e+16);return Jt(i,e-4,0),i[4]=r,jr(i,5+t,r),i}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},eo=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 i=Buffer.allocUnsafe(e);return Jt(i,e-4,0),i[4]=r,jr(i,5+t,r),i}encrypt(t){if(this._dead)return;let e=_n(this._encSSLName,this._encKey,this._encIV);e.setAutoPadding(!1);let r=t.slice(0,4);e.setAAD(r),this._onWrite(r);let i=e.update(t.slice(4));this._onWrite(i);let s=e.final();s.length&&this._onWrite(s);let o=e.getAuthTag();this._onWrite(o),Gc(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},to=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new lo(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 i=Buffer.allocUnsafe(e+16);return Jt(i,e-4,0),i[4]=r,jr(i,5+t,r),i}encrypt(t){this._dead||(this._instance.encrypt(t),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},ro=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._cipherInstance=_n(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 i=Gi.get(r);i===void 0&&(i=Buffer.alloc(r),Gi.set(r,i)),this._cipherInstance.update(i)}}free(){this._dead=!0}allocPacket(t){let e=this._encBlockLen,r=5+t,i=e-(r-this._aadLen&e-1);i<4&&(i+=e),r+=i;let s=Buffer.allocUnsafe(r);return Jt(s,r-4,0),s[4]=i,jr(s,5+t,i),s}encrypt(t){if(this._dead)return;let e;if(this._macETM){let i=new Uint8Array(t.buffer,t.byteOffset,4),s=this._cipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+4,t.length-4));this._onWrite(i),this._onWrite(s),e=Vs(this._macSSLName,this._macKey),Jt(mn,this.outSeqno,0),e.update(mn),e.update(i),e.update(s)}else{let i=this._cipherInstance.update(t);this._onWrite(i),e=Vs(this._macSSLName,this._macKey),Jt(mn,this.outSeqno,0),e.update(mn),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}},no=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 go(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,i=e-(r-this._aadLen&e-1);i<4&&(i+=e),r+=i;let s=Buffer.allocUnsafe(r+this._macLen);return Jt(s,r-4,0),s[4]=i,jr(s,5+t,i),s}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._macActualLen<this._macLen&&(t=new Lr(t.buffer,t.byteOffset,t.length-(this._macLen-this._macActualLen))),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},io=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 s=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=s;s--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len>Xr||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._packetPos<this._len){let s=Math.min(this._len-this._packetPos,r-e),o;if(e!==0||s!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,s):o=t,s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),e+=s,this._packetPos+=s,this._packetPos<this._len)return}let i=this._packet?new Lr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):qc;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}},so=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;qt[0]=0,Jt(qt,this.inSeqno,12);let f=Ki("chacha20",this._decKeyPktLen,qt).update(this._lenBuf);if(this._len=jn(f,0),this._len>Xr||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),f;if(e!==0||a!==r?f=new Uint8Array(t.buffer,t.byteOffset+e,a):f=t,a===this._len?this._packet=f:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(f,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}qt[0]=0,Jt(qt,this.inSeqno,12);let i=_n("chacha20",this._decKeyMain,qt).update(Kc);if(mo(Xn,this._lenBuf,4,this._packet,this._packet.length,i),this._calcMac.set(new Uint8Array(Vn.HEAPU8.buffer,Xn,16),0),!js(this._calcMac,this._mac))throw new Error("Invalid MAC");qt[0]=1;let s=Ki("chacha20",this._decKeyMain,qt).update(this._packet),o=new Lr(s.buffer,s.byteOffset+1,s.length-s[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}}}},oo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Ao(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 s=Math.min(4-this._lenPos,r-e);for(;s--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>Xr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._pktLen<this._len){let s=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||s!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,s):o=t,s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=s,this._pktLen+=s,this._pktLen<this._len||e>=r)return}{let s=Math.min(16-this._macPos,r-e);if(e!==0||s!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._macPos):this._mac.set(t,this._macPos),e+=s,this._macPos+=s,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let i=new Lr(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 s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}},ao=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 s=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=s;s--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>Xr||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=Ki(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(yd(this._len))}if(this._pktLen<this._len){if(e>=r)return;let s=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||s!==r?o=this._decipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+e,s)):o=this._decipherInstance.update(t),o.length&&(s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),this._packetPos+=o.length),e+=s,this._pktLen+=s,this._pktLen<this._len||e>=r)return}{let s=Math.min(16-this._tagPos,r-e);if(e!==0||s!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._tagPos):this._tag.set(t,this._tagPos),e+=s,this._tagPos+=s,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let s=this._decipherInstance.final();s.length&&(this._packet?this._packet.set(s,this._packetPos):this._packet=s)}let i=this._packet?new Lr(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):qc;this.inSeqno=this.inSeqno+1>>>0,Gc(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}},fo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new po(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 s=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=s;s--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>Xr||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 s=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||s!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,s):o=t,s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=s,this._pktLen+=s,this._pktLen<this._len||e>=r)return}{let s=Math.min(16-this._tagPos,r-e);if(e!==0||s!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._tagPos):this._tag.set(t,this._tagPos),e+=s,this._tagPos+=s,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let i=new Lr(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 s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}},co=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=Ki(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 i=Gi.get(r);i===void 0&&(i=Buffer.alloc(r),Gi.set(r,i)),this._decipherInstance.update(i)}}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,f;if(this._macETM?this._len=f=jn(this._block,0):(a=this._decipherInstance.update(this._block),this._len=jn(a,0),f=4+this._len-this._blockSize),this._len>Xr||this._len<5||(f&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=Vs(this._macSSLName,this._macKey),Jt(mn,this.inSeqno,0),this._macInstance.update(mn),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 f=this._decipherInstance.update(a);if(f.length&&(o===this._len?this._packet=f:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(f,this._packetPos)),this._packetPos+=f.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 i=this._macInstance.digest();if(this._macActualLen<i.length&&(i=new Uint8Array(i.buffer,i.byteOffset,this._macActualLen)),!wd(i,this._mac))throw new Error("Invalid MAC");let s=new Lr(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(s);if(o!==void 0)return o===!1?e:o}}}},uo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Eo(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 s=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||s!==r||s<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._blockPos):this._block.set(t,this._blockPos),e+=s,this._blockPos+=s,this._blockPos<this._block.length)return;let o;if(this._macETM?this._len=o=jn(this._block,0):(this._instance.decryptBlock(this._block),this._len=jn(this._block,0),o=4+this._len-this._block.length),this._len>Xr||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 s=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||s!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,s):o=t,s===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=s,this._pktLen+=s,this._pktLen<this._len||e>=r)return}{let s=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||s!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,s),this._macPos):this._mac.set(t,this._macPos),e+=s,this._macPos+=s,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let i=new Lr(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 s=this._onPayload(i);if(s!==void 0)return s===!1?e:s}}}};function Gc(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 yd=(()=>{let n=Buffer.alloc(4);return t=>(n[0]=t>>>24,n[1]=t>>>16,n[2]=t>>>8,n[3]=t,n)})();function wd(n,t){return n.length!==t.length?(js(n,n),!1):js(n,t)}function Id(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>Wc)throw new Error("Invalid outbound.seqno");let e=!!t.forceNative;switch(t.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return lo&&!e?new to(n):new eo(n);case"chacha20":return ho&&!e?new Zs(n):new Js(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 go&&!e?new no(n):new ro(n)}}}function Cd(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>Wc)throw new Error("Invalid inbound.seqno");let e=!!t.forceNative;switch(t.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return po&&!e?new fo(n):new ao(n);case"chacha20":return Ao&&!e?new oo(n):new so(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 Eo&&!e?new uo(n):new co(n)}}}Yc.exports={CIPHER_INFO:xd,MAC_INFO:Sd,bindingAvailable:!!Xs,init:new Promise(async(n,t)=>{try{Vn=await $c()(),Xn=Vn._malloc(16),mo=Vn.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(e){return t(e)}n()}),NullCipher:zs,createCipher:Id,NullDecipher:io,createDecipher:Cd}});var Or=nt((_m,nu)=>{"use strict";var{createDecipheriv:bo,createECDH:Bd,createHash:Jn,createHmac:kd,createSign:Rd,createVerify:vd,getCiphers:Nd,sign:Vc,verify:jc}=require("crypto"),Pd=Nd(),{Ber:Ce}=Kn(),Td=$s().pbkdf,{CIPHER_INFO:Zn}=Tr(),{eddsaSupported:xo,SUPPORTED_CIPHER:Ld}=Sr(),{bufferSlice:zr,makeBufferParser:Ud,readString:we,readUInt32BE:zn,writeUInt32BE:Rt}=or(),yr=Symbol("Hash Algorithm"),ar=Symbol("Private key PEM"),gr=Symbol("Public key PEM"),Ur=Symbol("Public key SSH"),bn=Symbol("Decrypted Key"),_o=Object.create(null);{let n=Object.keys(Zn);for(let t=0;t<n.length;++t){let e=Zn[n[t]].sslName;!e||_o[e]||(_o[e]=Zn[n[t]])}}var Yi=Ud();function fr(n,t){t=t.base64Slice(0,t.length);let e=t.replace(/.{64}/g,`$&
23
+ `);return t.length&63&&(e+=`
24
+ `),`-----BEGIN ${n} KEY-----
25
+ ${e}-----END ${n} KEY-----`}function ei(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return e.set(n,0),e.set(t,n.length),e}function So(n,t){let e=n.length,r=n._pos||0;for(let i=0;i<t;++i){let s=e-r;if(r>=e||s<4)return!1;let o=zn(n,r);if(s<4+o)return!1;r+=4+o}return n._pos=r,!0}function ti(n,t){let e=new Ce.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.113549.1.1.1"),e.writeNull(),e.endSequence(),e.startSequence(Ce.BitString),e.writeByte(0),e.startSequence(),e.writeBuffer(n,Ce.Integer),e.writeBuffer(t,Ce.Integer),e.endSequence(),e.endSequence(),e.endSequence(),fr("PUBLIC",e.buffer)}function ri(n,t){let e=Buffer.allocUnsafe(15+t.length+4+n.length);Rt(e,7,0),e.utf8Write("ssh-rsa",4,7);let r=11;return Rt(e,t.length,r),e.set(t,r+=4),Rt(e,n.length,r+=t.length),e.set(n,r+4),e}var Xc=(()=>{function n(r,i,s,o,a,f,c,l){let h=new Ce.Writer;return h.startSequence(),h.writeInt(0,Ce.Integer),h.writeBuffer(r,Ce.Integer),h.writeBuffer(i,Ce.Integer),h.writeBuffer(s,Ce.Integer),h.writeBuffer(o,Ce.Integer),h.writeBuffer(a,Ce.Integer),h.writeBuffer(f,Ce.Integer),h.writeBuffer(c,Ce.Integer),h.writeBuffer(l,Ce.Integer),h.endSequence(),h.buffer}function t(r){return BigInt(`0x${r.hexSlice(0,r.length)}`)}function e(r){let i=r.toString(16);if((i.length&1)!==0)i=`0${i}`;else{let s=i.charCodeAt(0);(s===56||s===57||s>=97&&s<=102)&&(i=`00${i}`)}return Buffer.from(i,"hex")}return function(i,s,o,a,f,c){let l=t(o),h=e(l%(t(f)-1n)),g=e(l%(t(c)-1n));return fr("RSA PRIVATE",n(i,s,o,f,c,h,g,a))}})();function ni(n,t,e,r){let i=new Ce.Writer;return i.startSequence(),i.startSequence(),i.writeOID("1.2.840.10040.4.1"),i.startSequence(),i.writeBuffer(n,Ce.Integer),i.writeBuffer(t,Ce.Integer),i.writeBuffer(e,Ce.Integer),i.endSequence(),i.endSequence(),i.startSequence(Ce.BitString),i.writeByte(0),i.writeBuffer(r,Ce.Integer),i.endSequence(),i.endSequence(),fr("PUBLIC",i.buffer)}function ii(n,t,e,r){let i=Buffer.allocUnsafe(15+n.length+4+t.length+4+e.length+4+r.length);Rt(i,7,0),i.utf8Write("ssh-dss",4,7);let s=11;return Rt(i,n.length,s),i.set(n,s+=4),Rt(i,t.length,s+=n.length),i.set(t,s+=4),Rt(i,e.length,s+=t.length),i.set(e,s+=4),Rt(i,r.length,s+=e.length),i.set(r,s+4),i}function zc(n,t,e,r,i){let s=new Ce.Writer;return s.startSequence(),s.writeInt(0,Ce.Integer),s.writeBuffer(n,Ce.Integer),s.writeBuffer(t,Ce.Integer),s.writeBuffer(e,Ce.Integer),s.writeBuffer(r,Ce.Integer),s.writeBuffer(i,Ce.Integer),s.endSequence(),fr("DSA PRIVATE",s.buffer)}function Jc(n){let t=new Ce.Writer;return t.startSequence(),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Ce.BitString),t.writeByte(0),t._ensure(n.length),t._buf.set(n,t._offset),t._offset+=n.length,t.endSequence(),t.endSequence(),fr("PUBLIC",t.buffer)}function Zc(n){let t=Buffer.allocUnsafe(19+n.length);return Rt(t,11,0),t.utf8Write("ssh-ed25519",4,11),Rt(t,n.length,15),t.set(n,19),t}function Od(n){let t=new Ce.Writer;return t.startSequence(),t.writeInt(0,Ce.Integer),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Ce.OctetString),t.writeBuffer(n,Ce.OctetString),t.endSequence(),t.endSequence(),fr("PRIVATE",t.buffer)}function yo(n,t){let e=new Ce.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.10045.2.1"),e.writeOID(n),e.endSequence(),e.startSequence(Ce.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),fr("PUBLIC",e.buffer)}function wo(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 Rt(r,19,0),r.utf8Write(`ecdsa-sha2-${e}`,4,19),Rt(r,8,23),r.utf8Write(e,27,8),Rt(r,t.length,35),r.set(t,39),r}function Dd(n,t,e){let r=new Ce.Writer;return r.startSequence(),r.writeInt(1,Ce.Integer),r.writeBuffer(e,Ce.OctetString),r.startSequence(160),r.writeOID(n),r.endSequence(),r.startSequence(161),r.startSequence(Ce.BitString),r.writeByte(0),r._ensure(t.length),r._buf.set(t,r._offset),r._offset+=t.length,r.endSequence(),r.endSequence(),r.endSequence(),fr("EC PRIVATE",r.buffer)}function Hd(n,t){let e=Bd(n);return e.setPrivateKey(t),e.getPublicKey()}var si={sign:typeof Vc=="function"?function(t,e){let r=this[ar];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[yr]);try{return Vc(e,t,r)}catch(i){return i}}:function(t,e){let r=this[ar];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[yr]);let i=Rd(e);i.update(t);try{return i.sign(r)}catch(s){return s}},verify:typeof jc=="function"?function(t,e,r){let i=this[gr];if(i===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[yr]);try{return jc(r,t,i,e)}catch(s){return s}}:function(t,e,r){let i=this[gr];if(i===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[yr]);let s=vd(r);s.update(t);try{return s.verify(i,e)}catch(o){return o}},isPrivateKey:function(){return this[ar]!==null},getPrivatePEM:function(){return this[ar]},getPublicPEM:function(){return this[gr]},getPublicSSH:function(){return this[Ur]},equals:function(t){let e=ru(t);return e instanceof Error?!1:this.type===e.type&&this[ar]===e[ar]&&this[gr]===e[gr]&&this[Ur].equals(e[Ur])}};function Vi(n,t,e,r,i,s,o){this.type=n,this.comment=t,this[ar]=e,this[gr]=r,this[Ur]=i,this[yr]=s,this[bn]=o}Vi.prototype=si;{let t=function(e,r,i){let s=[];if(e.length<8)return new Error("Malformed OpenSSH private key");let o=zn(e,0),a=zn(e,4);if(o!==a)return i?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");e._pos=8;let f,c;for(f=0;f<r;++f){let h,g,p,_,b=we(e,e._pos,!0);if(b===void 0)return new Error("Malformed OpenSSH private key");switch(b){case"ssh-rsa":{let P=we(e,e._pos);if(P===void 0)return new Error("Malformed OpenSSH private key");let L=we(e,e._pos);if(L===void 0)return new Error("Malformed OpenSSH private key");let ee=we(e,e._pos);if(ee===void 0)return new Error("Malformed OpenSSH private key");let H=we(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let z=we(e,e._pos);if(z===void 0)return new Error("Malformed OpenSSH private key");let J=we(e,e._pos);if(J===void 0)return new Error("Malformed OpenSSH private key");p=ti(P,L),_=ri(P,L),g=Xc(P,L,ee,H,z,J),h="sha1";break}case"ssh-dss":{let P=we(e,e._pos);if(P===void 0)return new Error("Malformed OpenSSH private key");let L=we(e,e._pos);if(L===void 0)return new Error("Malformed OpenSSH private key");let ee=we(e,e._pos);if(ee===void 0)return new Error("Malformed OpenSSH private key");let H=we(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let z=we(e,e._pos);if(z===void 0)return new Error("Malformed OpenSSH private key");p=ni(P,L,ee,H),_=ii(P,L,ee,H),g=zc(P,L,ee,H,z),h="sha1";break}case"ssh-ed25519":{if(!xo)return new Error(`Unsupported OpenSSH private key type: ${b}`);let P=we(e,e._pos);if(P===void 0||P.length!==32)return new Error("Malformed OpenSSH private key");let L=we(e,e._pos);if(L===void 0||L.length!==64)return new Error("Malformed OpenSSH private key");p=Jc(P),_=Zc(P),g=Od(zr(L,0,32)),h=null;break}case"ecdsa-sha2-nistp256":h="sha256",c="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":h===void 0&&(h="sha384",c="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(h===void 0&&(h="sha512",c="1.3.132.0.35"),!So(e,1))return new Error("Malformed OpenSSH private key");let P=we(e,e._pos);if(P===void 0)return new Error("Malformed OpenSSH private key");let L=we(e,e._pos);if(L===void 0)return new Error("Malformed OpenSSH private key");p=yo(c,P),_=wo(c,P),g=Dd(c,P,L);break}default:return new Error(`Unsupported OpenSSH private key type: ${b}`)}let R=we(e,e._pos,!0);if(R===void 0)return new Error("Malformed OpenSSH private key");s.push(new Vi(b,R,g,p,_,h,i))}let l=0;for(f=e._pos;f<e.length;++f)if(e[f]!==++l%255)return new Error("Malformed OpenSSH private key");return s},n=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;Vi.parse=(e,r)=>{let i=n.exec(e);if(i===null)return null;let s,o=Buffer.from(i[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 f=we(o,15,!0);if(f===void 0)return new Error("Malformed OpenSSH private key");if(f!=="none"&&Ld.indexOf(f)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${f}`);let c=we(o,o._pos,!0);if(c===void 0)return new Error("Malformed OpenSSH private key");if(c!=="none"){if(f==="none")return new Error("Malformed OpenSSH private key");if(c!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${c}`);if(!r)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(f!=="none")return new Error("Malformed OpenSSH private key");let l,h,g;f!=="none"&&(l=Zn[f]);let p=we(o,o._pos);if(p===void 0)return new Error("Malformed OpenSSH private key");if(p.length)switch(c){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{let b=we(p,0);if(b===void 0||p._pos+4>p.length)return new Error("Malformed OpenSSH private key");let R=zn(p,p._pos),P=Buffer.allocUnsafe(l.keyLen+l.ivLen);if(Td(r,r.length,b,b.length,P,P.length,R)!==0)return new Error("Failed to generate information to decrypt key");h=zr(P,0,l.keyLen),g=zr(P,l.keyLen,P.length);break}}else if(c!=="none")return new Error("Malformed OpenSSH private key");if(o._pos+3>=o.length)return new Error("Malformed OpenSSH private key");let _=zn(o,o._pos);if(o._pos+=4,_>0){for(let R=0;R<_;++R){let P=we(o,o._pos);if(P===void 0)return new Error("Malformed OpenSSH private key");if(we(P,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let b=we(o,o._pos);if(b===void 0)return new Error("Malformed OpenSSH private key");if(h!==void 0){if(b.length<l.blockLen||b.length%l.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let R={authTagLength:l.authLen},P=bo(l.sslName,h,g,R);if(P.setAutoPadding(!1),l.authLen>0){if(o.length-o._pos<l.authLen)return new Error("Malformed OpenSSH private key");P.setAuthTag(zr(o,o._pos,o._pos+=l.authLen))}b=ei(P.update(b),P.final())}catch(R){return R}}if(o._pos!==o.length)return new Error("Malformed OpenSSH private key");s=t(b,_,h!==void 0)}else s=[];return s instanceof Error?s:s[0]}}function ji(n,t,e,r,i,s,o){this.type=n,this.comment=t,this[ar]=e,this[gr]=r,this[Ur]=i,this[yr]=s,this[bn]=o}ji.prototype=si;{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-----$/;ji.parse=(t,e)=>{let r=n.exec(t);if(r===null)return null;let i=Buffer.from(r[3],"base64"),s=r[2],o=!1;if(s!==void 0){s=s.split(/\r\n|\n/g);for(let _=0;_<s.length;++_){let b=s[_],R=b.indexOf(":");if(b.slice(0,R)==="DEK-Info"){let P=b.slice(R+2);if(R=P.indexOf(","),R===-1)continue;let L=P.slice(0,R).toLowerCase();if(Pd.indexOf(L)===-1)return new Error(`Cipher (${L}) not supported for encrypted OpenSSH private key`);let ee=_o[L];if(!ee)return new Error(`Cipher (${L}) not supported for encrypted OpenSSH private key`);let H=Buffer.from(P.slice(R+1),"hex");if(H.length!==ee.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!e)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");let z=zr(H,0,8),J=Jn("md5").update(e).update(z).digest();for(;J.length<ee.keyLen;)J=ei(J,Jn("md5").update(J).update(e).update(z).digest());J.length>ee.keyLen&&(J=zr(J,0,ee.keyLen));try{let V=bo(L,J,H);V.setAutoPadding(!1),i=ei(V.update(i),V.final()),o=!0}catch(V){return V}}}}let a,f,c,l,h,g,p="Malformed OpenSSH private key";switch(o&&(p+=". Bad passphrase?"),r[1]){case"RSA":a="ssh-rsa",f=fr("RSA PRIVATE",i);try{g=new Ce.Reader(i),g.readSequence(),g.readInt();let _=g.readString(Ce.Integer,!0);if(_===null)return new Error(p);let b=g.readString(Ce.Integer,!0);if(b===null)return new Error(p);c=ti(_,b),l=ri(_,b)}catch{return new Error(p)}h="sha1";break;case"DSA":a="ssh-dss",f=fr("DSA PRIVATE",i);try{g=new Ce.Reader(i),g.readSequence(),g.readInt();let _=g.readString(Ce.Integer,!0);if(_===null)return new Error(p);let b=g.readString(Ce.Integer,!0);if(b===null)return new Error(p);let R=g.readString(Ce.Integer,!0);if(R===null)return new Error(p);let P=g.readString(Ce.Integer,!0);if(P===null)return new Error(p);c=ni(_,b,R,P),l=ii(_,b,R,P)}catch{return new Error(p)}h="sha1";break;case"EC":{let _,b,R;try{g=new Ce.Reader(i),g.readSequence(),g.readInt(),b=g.readString(Ce.OctetString,!0),g.readByte();let L=g.readLength();if(L!==null){if(g._offset=L,R=g.readOID(),R===null)return new Error(p);switch(R){case"1.2.840.10045.3.1.7":_="prime256v1",a="ecdsa-sha2-nistp256",h="sha256";break;case"1.3.132.0.34":_="secp384r1",a="ecdsa-sha2-nistp384",h="sha384";break;case"1.3.132.0.35":_="secp521r1",a="ecdsa-sha2-nistp521",h="sha512";break;default:return new Error(`Unsupported private key EC OID: ${R}`)}}else return new Error(p)}catch{return new Error(p)}f=fr("EC PRIVATE",i);let P=Hd(_,b);c=yo(R,P),l=wo(R,P);break}}return new ji(a,"",f,c,l,h,o)}}function Xi(n,t,e,r,i,s,o){this.type=n,this.comment=t,this[ar]=e,this[gr]=r,this[Ur]=i,this[yr]=s,this[bn]=o}Xi.prototype=si;{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]),i=/^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]+)/;Xi.parse=(s,o)=>{let a=i.exec(s);if(a===null)return null;let f=a[2],c=f!=="none";if(c&&!o)return new Error("Encrypted PPK private key detected, but no passphrase given");let l=Buffer.from(a[5],"base64");if(c){let U=Zn[f],$=ei(Jn("sha1").update(e).update(o).digest(),Jn("sha1").update(r).update(o).digest());$.length>U.keyLen&&($=zr($,0,U.keyLen));try{let M=bo(U.sslName,$,t);M.setAutoPadding(!1),l=ei(M.update(l),M.final())}catch(M){return M}}let h=a[1],g=a[3],p=Buffer.from(a[4],"base64"),_=a[6],b=h.length,R=f.length,P=Buffer.byteLength(g),L=p.length,ee=l.length,H=Buffer.allocUnsafe(4+b+4+R+4+P+4+L+4+ee),z=0;if(Rt(H,b,z),H.utf8Write(h,z+=4,b),Rt(H,R,z+=b),H.utf8Write(f,z+=4,R),Rt(H,P,z+=R),H.utf8Write(g,z+=4,P),Rt(H,L,z+=P),H.set(p,z+=4),Rt(H,ee,z+=L),H.set(l,z+4),o||(o=n),kd("sha1",Jn("sha1").update("putty-private-key-file-mac-key").update(o).digest()).update(H).digest("hex")!==_)return c?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let V,y,w;switch(p._pos=0,So(p,1),h){case"ssh-rsa":{let U=we(p,p._pos);if(U===void 0)return new Error("Malformed PPK public key");let $=we(p,p._pos);if($===void 0)return new Error("Malformed PPK public key");let M=we(l,0);if(M===void 0)return new Error("Malformed PPK private key");let se=we(l,l._pos);if(se===void 0)return new Error("Malformed PPK private key");let Z=we(l,l._pos);if(Z===void 0)return new Error("Malformed PPK private key");let j=we(l,l._pos);if(j===void 0)return new Error("Malformed PPK private key");V=ti($,U),y=ri($,U),w=Xc($,U,M,j,se,Z);break}case"ssh-dss":{let U=we(p,p._pos);if(U===void 0)return new Error("Malformed PPK public key");let $=we(p,p._pos);if($===void 0)return new Error("Malformed PPK public key");let M=we(p,p._pos);if(M===void 0)return new Error("Malformed PPK public key");let se=we(p,p._pos);if(se===void 0)return new Error("Malformed PPK public key");let Z=we(l,0);if(Z===void 0)return new Error("Malformed PPK private key");V=ni(U,$,M,se),y=ii(U,$,M,se),w=zc(U,$,M,se,Z);break}}return new Xi(h,g,w,V,y,"sha1",c)}}function Ji(n,t,e,r,i){this.type=n,this.comment=t,this[ar]=null,this[gr]=e,this[Ur]=r,this[yr]=i,this[bn]=!1}Ji.prototype=si;{let n;xo?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].*)?)$/,Ji.parse=t=>{let e=n.exec(t);if(e===null)return null;let r=e[1],i=e[2],s=Buffer.from(e[3],"base64"),o=e[4]||"",a=we(s,s._pos,!0);return a===void 0||a.indexOf(i)!==0?new Error("Malformed OpenSSH public key"):Io(s,i,o,r)}}function zi(n,t,e,r,i){this.type=n,this.comment=t,this[ar]=null,this[gr]=e,this[Ur]=r,this[yr]=i,this[bn]=!1}zi.prototype=si;{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;zi.parse=i=>{let s=n.exec(i);if(s===null)return null;let o=s[1],a=0,f="";for(;s=e.exec(o);){let p=s[1],_=s[2].replace(r,"");if(_.length>1024)return e.lastIndex=0,new Error("Malformed RFC4716 public key");a=e.lastIndex,p.toLowerCase()==="comment"&&(f=_,f.length>1&&f.charCodeAt(0)===34&&f.charCodeAt(f.length-1)===34&&(f=f.slice(1,-1)))}let c=o.slice(a);if(!t.test(c))return new Error("Malformed RFC4716 public key");c=Buffer.from(c,"base64");let l=we(c,0,!0);if(l===void 0)return new Error("Malformed RFC4716 public key");let h=null,g=null;switch(l){case"ssh-rsa":{let p=we(c,c._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let _=we(c,c._pos);if(_===void 0)return new Error("Malformed RFC4716 public key");h=ti(_,p),g=ri(_,p);break}case"ssh-dss":{let p=we(c,c._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let _=we(c,c._pos);if(_===void 0)return new Error("Malformed RFC4716 public key");let b=we(c,c._pos);if(b===void 0)return new Error("Malformed RFC4716 public key");let R=we(c,c._pos);if(R===void 0)return new Error("Malformed RFC4716 public key");h=ni(p,_,b,R),g=ii(p,_,b,R);break}default:return new Error("Malformed RFC4716 public key")}return new zi(l,f,h,g,"sha1")}}function Io(n,t,e,r){if(!eu(t))return new Error(`Unsupported OpenSSH public key type: ${t}`);let i,s,o=null,a=null;switch(t){case"ssh-rsa":{let f=we(n,n._pos||0);if(f===void 0)return new Error("Malformed OpenSSH public key");let c=we(n,n._pos);if(c===void 0)return new Error("Malformed OpenSSH public key");o=ti(c,f),a=ri(c,f),i="sha1";break}case"ssh-dss":{let f=we(n,n._pos||0);if(f===void 0)return new Error("Malformed OpenSSH public key");let c=we(n,n._pos);if(c===void 0)return new Error("Malformed OpenSSH public key");let l=we(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");let h=we(n,n._pos);if(h===void 0)return new Error("Malformed OpenSSH public key");o=ni(f,c,l,h),a=ii(f,c,l,h),i="sha1";break}case"ssh-ed25519":{let f=we(n,n._pos||0);if(f===void 0||f.length!==32)return new Error("Malformed OpenSSH public key");o=Jc(f),a=Zc(f),i=null;break}case"ecdsa-sha2-nistp256":i="sha256",s="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":i===void 0&&(i="sha384",s="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(i===void 0&&(i="sha512",s="1.3.132.0.35"),!So(n,1))return new Error("Malformed OpenSSH public key");let f=we(n,n._pos||0);if(f===void 0)return new Error("Malformed OpenSSH public key");o=yo(s,f),a=wo(s,f);break}default:return new Error(`Unsupported OpenSSH public key type: ${t}`)}return new Ji(r,e,o,a,i)}function eu(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(xo)return!0;default:return!1}}function tu(n){return n?typeof n[bn]=="boolean":!1}function ru(n,t){if(tu(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=Vi.parse(n,t))!==null||(r=ji.parse(n,t))!==null||(r=Xi.parse(n,t))!==null||(r=Ji.parse(n))!==null||(r=zi.parse(n))!==null)return r;if(e){Yi.init(e,0);let i=Yi.readString(!0);i!==void 0&&(n=Yi.readRaw(),n!==void 0&&(r=Io(n,i,"",i),r instanceof Error&&(r=null))),Yi.clear()}return r||new Error("Unsupported key format")}nu.exports={isParsedKey:tu,isSupportedKeyType:eu,parseDERKey:(n,t)=>Io(n,t,"",t),parseKey:ru}});var No=nt((ym,du)=>{"use strict";var{Socket:au}=require("net"),{Duplex:fu}=require("stream"),{resolve:Fd}=require("path"),{readFile:iu}=require("fs"),{execFile:Qd,spawn:Md}=require("child_process"),{isParsedKey:su,parseKey:oi}=Or(),{makeBufferParser:$d,readUInt32BE:vo,writeUInt32BE:Kt,writeUInt32LE:ou}=or();function ai(n){let t=!1;return(...e)=>{t||(t=!0,n(...e))}}function Wd(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return n.copy(e,0),t.copy(e,n.length),e}function Bo(){}var qd=Buffer.alloc(0),ht=$d(),fi=class{getIdentities(t){t(new Error("Missing getIdentities() implementation"))}sign(t,e,r,i){typeof r=="function"&&(i=r),i(new Error("Missing sign() implementation"))}},Sn=class extends fi{constructor(t){super(),this.socketPath=t}getStream(t){t=ai(t);let e=new au;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=ai(t),this.getStream((e,r)=>{function i(o){if(r)try{r.destroy()}catch{}o||(o=new Error("Failed to retrieve identities from agent")),t(o)}if(e)return i(e);let s=new ko(!0);s.on("error",i),s.pipe(r).pipe(s),r.on("close",i).on("end",i).on("error",i),s.getIdentities((o,a)=>{if(o)return i(o);try{r.destroy()}catch{}t(null,a)})})}sign(t,e,r,i){typeof r=="function"?(i=r,r=void 0):(typeof r!="object"||r===null)&&(r=void 0),i=ai(i),this.getStream((s,o)=>{function a(c){if(o)try{o.destroy()}catch{}c||(c=new Error("Failed to sign data with agent")),i(c)}if(s)return a(s);let f=new ko(!0);f.on("error",a),f.pipe(o).pipe(f),o.on("close",a).on("end",a).on("error",a),f.sign(t,e,r,(c,l)=>{if(c)return a(c);try{o.destroy()}catch{}i(null,l)})})}},cu=(()=>{let o=Fd(__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 f(l){l.buffer=null,l.proc&&(l.proc.kill(),l.proc=void 0)}class c extends fu{constructor(){super(),this.proc=void 0,this.buffer=null}_read(h){}_write(h,g,p){if(this.buffer===null)this.buffer=h;else{let P=Buffer.allocUnsafe(this.buffer.length+h.length);this.buffer.copy(P,0),h.copy(P,this.buffer.length),this.buffer=P}if(this.buffer.length<4)return p();let _=vo(this.buffer,0);if(this.buffer.length-4<_)return p();if(h=this.buffer.slice(0,4+_),this.buffer.length>4+_)return p(new Error("Unexpected multiple agent requests"));this.buffer=null;let b,R=this.proc=Md(o,[h.length]);R.stdout.on("data",P=>{this.push(P)}),R.on("error",P=>{b=P,p(b)}),R.on("close",P=>{if(this.proc=void 0,!b){if(b=a[P])return p(b);p()}}),R.stdin.end(h)}_final(h){f(this),h()}_destroy(h,g){f(this),g()}}return class extends Sn{getStream(h){h(null,new c)}}})(),uu=(()=>{let n=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Sn{getStream(e){e=ai(e);let r=this.socketPath,i=!1;iu(r,function s(o,a){if(o){if(i)return e(new Error("Invalid cygwin unix socket path"));Qd("cygpath",["-w",r],(J,V,y)=>{if(J||V.length===0)return e(new Error("Invalid cygwin unix socket path"));i=!0,r=V.toString().replace(/[\r\n]/g,""),iu(r,s)});return}let f=n.exec(a.toString("ascii"));if(!f)return e(new Error("Malformed cygwin unix socket file"));let c,l=0,h=!1,g=[],p,_=Buffer.alloc(12),b=parseInt(f[1],10),R=f[2].replace(/-/g,""),P=Buffer.allocUnsafe(16);for(let J=0,V=0;V<32;++J,V+=2)P[J]=parseInt(R.substring(V,V+2),16);for(let J=0;J<16;J+=4)ou(P,vo(P,J),J);z();function L(){l=0,c="secret",p.write(P)}function ee(J){if(l+=J.length,c==="secret"){l===16&&(l=0,c="creds",p.write(_));return}if(c==="creds"&&(h||g.push(J),l===12)){if(p.removeListener("connect",L),p.removeListener("data",ee),p.removeListener("error",H),p.removeListener("end",H),p.removeListener("close",H),h)return e(null,p);h=!0,_=Buffer.concat(g),ou(_,process.pid,0),p.on("error",()=>{}),p.destroy(),z()}}function H(){e(new Error("Problem negotiating cygwin unix socket security"))}function z(){p=new au,p.on("connect",L),p.on("data",ee),p.on("error",H),p.on("end",H),p.on("close",H),p.connect(b)}})}}})(),Kd=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function lu(n){return process.platform==="win32"&&!Kd.test(n)?n==="pageant"?new cu:new uu(n):new Sn(n)}var ko=(()=>{function c(y){let w;for(;y[L].length;){let U=y[L][0][h];if(U===void 0)break;y[L].shift(),w=y.push(U)}return w}let l=Symbol("Inbound Request Type"),h=Symbol("Inbound Request Response"),g=Symbol("Inbound Request Context");class p{constructor(w,U){this[l]=w,this[h]=void 0,this[g]=U}hasResponded(){return this[h]!==void 0}getType(){return this[l]}getContext(){return this[g]}}function _(y,w,U){return w[h]=U,c(y)}function b(y){if(y[H]=null,y[ee]===0){let w=y[L];if(w&&w.length){y[L]=[];for(let U of w)U.cb(new Error("No reply from server"))}}try{y.end()}catch{}setImmediate(()=>{y[V]||y.emit("end"),y[J]||y.emit("close")})}function R(){this[J]=!0}function P(){this[V]=!0}let L=Symbol("Requests"),ee=Symbol("Agent Protocol Role"),H=Symbol("Agent Protocol Buffer"),z=Symbol("Agent Protocol Current Message Length"),J=Symbol("Agent Protocol Closed"),V=Symbol("Agent Protocol Ended");return class extends fu{constructor(w){super({autoDestroy:!0,emitClose:!1}),this[ee]=w?0:1,this[L]=[],this[H]=null,this[z]=-1,this.once("end",P),this.once("close",R)}_read(w){}_write(w,U,$){this[H]===null?this[H]=w:this[H]=Wd(this[H],w);let M=this[H],se=M.length,Z=0;for(;Z<se&&!(se<5||(this[z]===-1&&(this[z]=vo(M,Z)),se<4+this[z]));){let j=M[Z+=4];if(++Z,this[ee]===0){if(this[L].length===0)return $(new Error("Received unexpected message from server"));let te=this[L].shift();switch(j){case 5:te.cb(new Error("Agent responded with failure"));break;case 12:{if(te.type!==11)return $(new Error("Agent responded with wrong message type"));ht.init(M,Z);let oe=ht.readUInt32BE();if(oe===void 0)return ht.clear(),$(new Error("Malformed agent response"));let S=[];for(let k=0;k<oe;++k){let v=ht.readString();if(v===void 0)return ht.clear(),$(new Error("Malformed agent response"));let O=ht.readString(!0);if(O===void 0)return ht.clear(),$(new Error("Malformed agent response"));v=oi(v),!(v instanceof Error)&&(v.comment=v.comment||O,S.push(v))}Z=ht.pos(),ht.clear(),te.cb(null,S);break}case 14:{if(te.type!==13)return $(new Error("Agent responded with wrong message type"));ht.init(M,Z);let oe=ht.readString();if(Z=ht.pos(),ht.clear(),oe===void 0)return $(new Error("Malformed agent response"));if(ht.init(oe,0),ht.readString(!0),oe=ht.readString(),ht.clear(),oe===void 0)return $(new Error("Malformed OpenSSH signature format"));te.cb(null,oe);break}default:return $(new Error("Agent responded with unsupported message type"))}}else switch(j){case 11:{let te=new p(j);this[L].push(te),this.emit("identities",te);break}case 13:{ht.init(M,Z);let te=ht.readString(),oe=ht.readString(),S=ht.readUInt32BE();if(Z=ht.pos(),ht.clear(),S===void 0){let ie=new p(j);return this[L].push(ie),this.failureReply(ie)}if(te=oi(te),te instanceof Error){let ie=new p(j);return this[L].push(ie),this.failureReply(ie)}let k={hash:void 0},v;te.type==="ssh-rsa"&&(S&2?(v="rsa-sha2-256",k.hash="sha256"):S&4&&(v="rsa-sha2-512",k.hash="sha512")),v===void 0&&(v=te.type);let O=new p(j,v);this[L].push(O),this.emit("sign",O,te,oe,k);break}default:{let te=new p(j);this[L].push(te),this.failureReply(te)}}if(this[z]=-1,Z===se){this[H]=null;break}else this[H]=M=M.slice(Z),se=M.length,Z=0}$()}_destroy(w,U){b(this),U()}_final(w){b(this),w()}sign(w,U,$,M){if(this[ee]!==0)throw new Error("Client-only method called with server role");typeof $=="function"?(M=$,$=void 0):(typeof $!="object"||$===null)&&($=void 0);let se=0;if(w=oi(w),w instanceof Error)throw new Error("Invalid public key argument");if(w.type==="ssh-rsa"&&$)switch($.hash){case"sha256":se=2;break;case"sha512":se=4;break}w=w.getPublicSSH();let Z=13,j=w.length,te=U.length,oe=0,S=Buffer.allocUnsafe(9+j+4+te+4);return Kt(S,S.length-4,oe),S[oe+=4]=Z,Kt(S,j,++oe),w.copy(S,oe+=4),Kt(S,te,oe+=j),U.copy(S,oe+=4),Kt(S,se,oe+=te),typeof M!="function"&&(M=Bo),this[L].push({type:Z,cb:M}),this.push(S)}getIdentities(w){if(this[ee]!==0)throw new Error("Client-only method called with server role");let U=11,$=0,M=Buffer.allocUnsafe(5);return Kt(M,M.length-4,$),M[$+=4]=U,typeof w!="function"&&(w=Bo),this[L].push({type:U,cb:w}),this.push(M)}failureReply(w){if(this[ee]!==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 U=0,$=Buffer.allocUnsafe(5);return Kt($,$.length-4,U),$[U+=4]=5,_(this,w,$)}getIdentitiesReply(w,U){if(this[ee]!==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(U))throw new Error("Keys argument must be an array");let $=4,M=[];for(let j=0;j<U.length;++j){let te=U[j];if(typeof te!="object"||te===null)throw new Error(`Invalid key entry: ${te}`);let oe,S;if(su(te))oe=te;else if(su(te.pubKey))oe=te.pubKey;else if(typeof te.pubKey!="object"||te.pubKey===null||({pubKey:oe,comment:S}=te.pubKey,oe=oi(oe),oe instanceof Error))continue;S=oe.comment||S,oe=oe.getPublicSSH(),$+=4+oe.length,S&&typeof S=="string"?S=Buffer.from(S):Buffer.isBuffer(S)||(S=qd),$+=4+S.length,M.push({pubKey:oe,comment:S})}let se=0,Z=Buffer.allocUnsafe(5+$);Kt(Z,Z.length-4,se),Z[se+=4]=12,Kt(Z,M.length,++se),se+=4;for(let j=0;j<M.length;++j){let{pubKey:te,comment:oe}=M[j];Kt(Z,te.length,se),te.copy(Z,se+=4),Kt(Z,oe.length,se+=te.length),se+=4,oe.length&&(oe.copy(Z,se),se+=oe.length)}return _(this,w,Z)}signReply(w,U){if(this[ee]!==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(U))throw new Error("Signature argument must be a Buffer");if(U.length===0)throw new Error("Signature argument must be non-empty");let $=0,M=w.getContext(),se=Buffer.byteLength(M),Z=Buffer.allocUnsafe(13+se+4+U.length);return Kt(Z,Z.length-4,$),Z[$+=4]=14,Kt(Z,4+se+4+U.length,++$),Kt(Z,se,$+=4),Z.utf8Write(M,$+=4,se),Kt(Z,U.length,$+=se),U.copy(Z,$+=4),_(this,w,Z)}}})(),Co=Symbol("Agent"),cr=Symbol("Agent Keys"),wr=Symbol("Agent Keys Index"),xn=Symbol("Agent Init Callbacks"),Ro=class{constructor(t){if(typeof t=="string")t=lu(t);else if(!hu(t))throw new Error("Invalid agent argument");this[Co]=t,this[cr]=null,this[wr]=-1,this[xn]=null}init(t){if(typeof t!="function"&&(t=Bo),this[cr]===null)if(this[xn]===null){this[xn]=[t];let e=(...r)=>{process.nextTick(()=>{let i=this[xn];this[xn]=null;for(let s of i)s(...r)})};this[Co].getIdentities(ai((r,i)=>{if(r)return e(r);if(!Array.isArray(i))return e(new Error("Agent implementation failed to provide keys"));let s=[];for(let o of i)o=oi(o),!(o instanceof Error)&&s.push(o);this[cr]=s,this[wr]=-1,e()}))}else this[xn].push(t);else process.nextTick(t)}nextKey(){return this[cr]===null||++this[wr]>=this[cr].length?!1:this[cr][this[wr]]}currentKey(){return this[cr]===null||this[wr]>=this[cr].length?null:this[cr][this[wr]]}pos(){return this[cr]===null||this[wr]>=this[cr].length?-1:this[wr]}reset(){this[wr]=-1}sign(...t){this[Co].sign(...t)}};function hu(n){return n instanceof fi}du.exports={AgentContext:Ro,AgentProtocol:ko,BaseAgent:fi,createAgent:lu,CygwinAgent:uu,isAgent:hu,OpenSSHAgent:Sn,PageantAgent:cu}});var Do=nt((wm,gu)=>{"use strict";var{kMaxLength:Gd}=require("buffer"),{createInflate:Yd,constants:{DEFLATE:Vd,INFLATE:jd,Z_DEFAULT_CHUNK:Xd,Z_DEFAULT_COMPRESSION:zd,Z_DEFAULT_MEMLEVEL:Jd,Z_DEFAULT_STRATEGY:Zd,Z_DEFAULT_WINDOWBITS:eg,Z_PARTIAL_FLUSH:tg}}=require("zlib"),rg=Yd()._handle.constructor;function ng(){throw new Error("Should not get here")}function ig(n,t,e){let r=this._owner,i=new Error(n);i.errno=t,i.code=e,r._err=i}function Oo(n){n._handle&&(n._handle.close(),n._handle=null)}var Zi=class{constructor(t){let e=eg,r=zd,i=Jd,s=Zd,o=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=Xd,this._maxOutputLength=Gd,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new rg(t),this._handle._owner=this,this._handle.onerror=ig,this._handle.init(e,r,i,s,this._writeState,ng,o)}writeSync(t,e){let r=this._handle;if(!r)throw new Error("Invalid Zlib instance");let i=t.length,s=this._chunkSize-this._outOffset,o=0,a,f,c,l=0,h=this._writeState,g=this._outBuffer,p=this._outOffset,_=this._chunkSize;for(;;){if(r.writeSync(tg,t,o,i,g,p,s),this._err)throw this._err;a=h[0],f=h[1];let R=i-f,P=s-a;if(P>0){let L=p===0&&P===g.length?g:g.slice(p,p+P);if(p+=P,c?c.push===void 0?c=[c,L]:c.push(L):c=L,l+=L.byteLength,l>this._maxOutputLength)throw Oo(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(P!==0)throw new Error("have should not go down");if((a===0||p>=_)&&(s=_,p=0,g=Buffer.allocUnsafe(_)),a===0)o+=R,i=f;else break}if(this._outBuffer=g,this._outOffset=p,l===0&&(c=Buffer.alloc(0)),e)return c.totalLen=l,c;if(c.push===void 0)return c;let b=Buffer.allocUnsafe(l);for(let R=0,P=0;R<c.length;++R){let L=c[R];b.set(L,P),P+=L.length}return b}},Po=class{constructor(t){this.allocStart=0,this.allocStartKEX=0,this._protocol=t,this._zlib=new Zi(Vd)}cleanup(){this._zlib&&Oo(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),i=this._protocol._cipher.allocPacket(r.totalLen);if(r.push===void 0)i.set(r,5);else for(let s=0,o=5;s<r.length;++s){let a=r[s];i.set(a,o),o+=a.length}return i}return t}},To=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}},Lo=class{constructor(){this._zlib=new Zi(jd)}cleanup(){this._zlib&&Oo(this._zlib)}read(t){return this._zlib.writeSync(t,!1)}},Uo=class{cleanup(){}read(t){return t}};gu.exports={PacketReader:Uo,PacketWriter:To,ZlibPacketReader:Lo,ZlibPacketWriter:Po}});var _u=nt((Im,mu)=>{"use strict";var{bufferSlice:Ho,bufferParser:B,doFatalError:ct,sigSSHToASN1:pu,writeUInt32BE:Au}=or(),{CHANNEL_OPEN_FAILURE:sg,COMPAT:og,MESSAGE:ut,TERMINAL_MODE:Eu}=Sr(),{parseKey:ag}=Or(),fg=Array.from(Object.entries(Eu)).reduce((n,[t,e])=>({...n,[t]:e}),{});mu.exports={[ut.DISCONNECT]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readString(!0),i=B.readString();if(B.clear(),i===void 0)return ct(n,"Inbound: Malformed DISCONNECT packet");n._debug&&n._debug(`Inbound: Received DISCONNECT (${e}, "${r}")`);let s=n._handlers.DISCONNECT;s&&s(n,e,r)},[ut.IGNORE]:(n,t)=>{n._debug&&n._debug("Inbound: Received IGNORE")},[ut.UNIMPLEMENTED]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return ct(n,"Inbound: Malformed UNIMPLEMENTED packet");n._debug&&n._debug(`Inbound: Received UNIMPLEMENTED (seqno ${e})`)},[ut.DEBUG]:(n,t)=>{B.init(t,1);let e=B.readBool(),r=B.readString(!0),i=B.readString();if(B.clear(),i===void 0)return ct(n,"Inbound: Malformed DEBUG packet");n._debug&&n._debug("Inbound: Received DEBUG");let s=n._handlers.DEBUG;s&&s(n,e,r)},[ut.SERVICE_REQUEST]:(n,t)=>{B.init(t,1);let e=B.readString(!0);if(B.clear(),e===void 0)return ct(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)},[ut.SERVICE_ACCEPT]:(n,t)=>{B.init(t,1);let e=B.readString(!0);if(B.clear(),e===void 0)return ct(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)},[ut.EXT_INFO]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r;if(e!==void 0){r=[];for(let s=0;s<e;++s){let o=B.readString(!0),a=B.readString();if(a!==void 0)if(o==="server-sig-algs"){let f=a.latin1Slice(0,a.length).split(",");r.push({name:o,algs:f});continue}else continue;r=void 0;break}}if(B.clear(),r===void 0)return ct(n,"Inbound: Malformed EXT_INFO packet");n._debug&&n._debug("Inbound: Received EXT_INFO");let i=n._handlers.EXT_INFO;i&&i(n,r)},[ut.USERAUTH_REQUEST]:(n,t)=>{B.init(t,1);let e=B.readString(!0),r=B.readString(!0),i=B.readString(!0),s,o;switch(i){case"none":s=null;break;case"password":{let f=B.readBool();if(f!==void 0&&(s=B.readString(!0),s!==void 0&&f)){let c=B.readString(!0);c!==void 0?s={oldPassword:s,newPassword:c}:s=void 0}break}case"publickey":{let f=B.readBool();if(f!==void 0){let c=B.readString(!0),l=c,h=B.readString(),g;switch(c){case"rsa-sha2-256":l="ssh-rsa",g="sha256";break;case"rsa-sha2-512":l="ssh-rsa",g="sha512";break}if(f){let p=B.pos(),_=B.readString();if(_!==void 0&&(_.length>4+c.length+4&&_.utf8Slice(4,4+c.length)===c&&(_=Ho(_,4+c.length+4)),_=pu(_,l),_)){let b=n._kex.sessionID,R=Buffer.allocUnsafe(4+b.length+p);Au(R,b.length,0),R.set(b,4),R.set(new Uint8Array(t.buffer,t.byteOffset,p),4+b.length),s={keyAlgo:l,key:h,signature:_,blob:R,hashAlgo:g}}}else s={keyAlgo:l,key:h,hashAlgo:g},o="publickey -- check"}break}case"hostbased":{let f=B.readString(!0),c=f,l=B.readString(),h=B.readString(!0),g=B.readString(!0),p;switch(f){case"rsa-sha2-256":c="ssh-rsa",p="sha256";break;case"rsa-sha2-512":c="ssh-rsa",p="sha512";break}let _=B.pos(),b=B.readString();if(b!==void 0&&(b.length>4+f.length+4&&b.utf8Slice(4,4+f.length)===f&&(b=Ho(b,4+f.length+4)),b=pu(b,c),b!==void 0)){let R=n._kex.sessionID,P=Buffer.allocUnsafe(4+R.length+_);Au(P,R.length,0),P.set(R,4),P.set(new Uint8Array(t.buffer,t.byteOffset,_),4+R.length),s={keyAlgo:c,key:l,signature:b,blob:P,localHostname:h,localUsername:g,hashAlgo:p}}break}case"keyboard-interactive":B.skipString(),s=B.readList();break;default:i!==void 0&&(s=B.readRaw())}if(B.clear(),s===void 0)return ct(n,"Inbound: Malformed USERAUTH_REQUEST packet");o===void 0&&(o=i),n._authsQueue.push(i),n._debug&&n._debug(`Inbound: Received USERAUTH_REQUEST (${o})`);let a=n._handlers.USERAUTH_REQUEST;a&&a(n,e,r,i,s)},[ut.USERAUTH_FAILURE]:(n,t)=>{B.init(t,1);let e=B.readList(),r=B.readBool();if(B.clear(),r===void 0)return ct(n,"Inbound: Malformed USERAUTH_FAILURE packet");n._debug&&n._debug(`Inbound: Received USERAUTH_FAILURE (${e})`),n._authsQueue.shift();let i=n._handlers.USERAUTH_FAILURE;i&&i(n,e,r)},[ut.USERAUTH_SUCCESS]:(n,t)=>{n._debug&&n._debug("Inbound: Received USERAUTH_SUCCESS"),n._authsQueue.shift();let e=n._handlers.USERAUTH_SUCCESS;e&&e(n)},[ut.USERAUTH_BANNER]:(n,t)=>{B.init(t,1);let e=B.readString(!0),r=B.readString();if(B.clear(),r===void 0)return ct(n,"Inbound: Malformed USERAUTH_BANNER packet");n._debug&&n._debug("Inbound: Received USERAUTH_BANNER");let i=n._handlers.USERAUTH_BANNER;i&&i(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":{B.init(t,1);let e=B.readString(!0),r=B.readString();if(B.clear(),r===void 0)return ct(n,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");n._debug&&n._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");let i=n._handlers.USERAUTH_PASSWD_CHANGEREQ;i&&i(n,e);break}case"publickey":{B.init(t,1);let e=B.readString(!0),r=B.readString();if(B.clear(),r===void 0)return ct(n,"Inbound: Malformed USERAUTH_PK_OK packet");n._debug&&n._debug("Inbound: Received USERAUTH_PK_OK"),n._authsQueue.shift();let i=n._handlers.USERAUTH_PK_OK;i&&i(n,e,r);break}case"keyboard-interactive":{B.init(t,1);let e=B.readString(!0),r=B.readString(!0);B.readString();let i=B.readUInt32BE(),s;if(i!==void 0){s=new Array(i);let a;for(a=0;a<i;++a){let f=B.readString(!0),c=B.readBool();if(c===void 0)break;s[a]={prompt:f,echo:c}}a!==i&&(s=void 0)}if(B.clear(),s===void 0)return ct(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,s);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 ct(n,"Inbound: Received unexpected payload type 61");B.init(t,1);let e=B.readUInt32BE(),r;if(e!==void 0){r=new Array(e);let s;for(s=0;s<e;++s){let o=B.readString(!0);if(o===void 0)break;r[s]=o}s!==e&&(r=void 0)}if(B.clear(),r===void 0)return ct(n,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_RESPONSE");let i=n._handlers.USERAUTH_INFO_RESPONSE;i&&i(n,r)},[ut.GLOBAL_REQUEST]:(n,t)=>{B.init(t,1);let e=B.readString(!0),r=B.readBool(),i;if(r!==void 0)switch(e){case"tcpip-forward":case"cancel-tcpip-forward":{let o=B.readString(!0),a=B.readUInt32BE();a!==void 0&&(i={bindAddr:o,bindPort:a});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let o=B.readString(!0);o!==void 0&&(i={socketPath:o});break}case"no-more-sessions@openssh.com":i=null;break;case"hostkeys-00@openssh.com":{for(i=[];B.avail()>0;){let o=B.readString();if(o===void 0){i=void 0;break}let a=ag(o);a instanceof Error||i.push(a)}break}default:i=B.readRaw()}if(B.clear(),i===void 0)return ct(n,"Inbound: Malformed GLOBAL_REQUEST packet");n._debug&&n._debug(`Inbound: GLOBAL_REQUEST (${e})`);let s=n._handlers.GLOBAL_REQUEST;s?s(n,e,r,i):n.requestFailure()},[ut.REQUEST_SUCCESS]:(n,t)=>{let e=t.length>1?Ho(t,1):null;n._debug&&n._debug("Inbound: REQUEST_SUCCESS");let r=n._handlers.REQUEST_SUCCESS;r&&r(n,e)},[ut.REQUEST_FAILURE]:(n,t)=>{n._debug&&n._debug("Inbound: Received REQUEST_FAILURE");let e=n._handlers.REQUEST_FAILURE;e&&e(n)},[ut.CHANNEL_OPEN]:(n,t)=>{B.init(t,1);let e=B.readString(!0),r=B.readUInt32BE(),i=B.readUInt32BE(),s=B.readUInt32BE(),o;switch(e){case"forwarded-tcpip":case"direct-tcpip":{let f=B.readString(!0),c=B.readUInt32BE(),l=B.readString(!0),h=B.readUInt32BE();h!==void 0&&(o={type:e,sender:r,window:i,packetSize:s,data:{destIP:f,destPort:c,srcIP:l,srcPort:h}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{let f=B.readString(!0);f!==void 0&&(o={type:e,sender:r,window:i,packetSize:s,data:{socketPath:f}});break}case"x11":{let f=B.readString(!0),c=B.readUInt32BE();c!==void 0&&(o={type:e,sender:r,window:i,packetSize:s,data:{srcIP:f,srcPort:c}});break}default:o={type:e,sender:r,window:i,packetSize:s,data:{}}}if(B.clear(),o===void 0)return ct(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,sg.ADMINISTRATIVELY_PROHIBITED,"","")},[ut.CHANNEL_OPEN_CONFIRMATION]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readUInt32BE(),i=B.readUInt32BE(),s=B.readUInt32BE(),o=B.avail()?B.readRaw():void 0;if(B.clear(),s===void 0)return ct(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:i,packetSize:s,data:o})},[ut.CHANNEL_OPEN_FAILURE]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readUInt32BE(),i=B.readString(!0),s=B.readString();if(B.clear(),s===void 0)return ct(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,i)},[ut.CHANNEL_WINDOW_ADJUST]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readUInt32BE();if(B.clear(),r===void 0)return ct(n,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");n._debug&&n._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${e}, ${r})`);let i=n._handlers.CHANNEL_WINDOW_ADJUST;i&&i(n,e,r)},[ut.CHANNEL_DATA]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readString();if(B.clear(),r===void 0)return ct(n,"Inbound: Malformed CHANNEL_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_DATA (r:${e}, ${r.length})`);let i=n._handlers.CHANNEL_DATA;i&&i(n,e,r)},[ut.CHANNEL_EXTENDED_DATA]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readUInt32BE(),i=B.readString();if(B.clear(),i===void 0)return ct(n,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${e}, ${i.length})`);let s=n._handlers.CHANNEL_EXTENDED_DATA;s&&s(n,e,i,r)},[ut.CHANNEL_EOF]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return ct(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)},[ut.CHANNEL_CLOSE]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return ct(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)},[ut.CHANNEL_REQUEST]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE(),r=B.readString(!0),i=B.readBool(),s;if(i!==void 0)switch(r){case"exit-status":s=B.readUInt32BE(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"exit-signal":{let a,f;if(n._compatFlags&og.OLD_EXIT){let l=B.readUInt32BE();switch(l){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:l!==void 0&&(a=`UNKNOWN (${l})`)}f=!1}else a=B.readString(!0),f=B.readBool(),f===void 0&&(a=void 0);let c=B.readString(!0);B.skipString()!==void 0&&(s={signal:a,coreDumped:f,errorMessage:c}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a})`);break}case"pty-req":{let a=B.readString(!0),f=B.readUInt32BE(),c=B.readUInt32BE(),l=B.readUInt32BE(),h=B.readUInt32BE(),g=B.readString();if(g!==void 0){B.init(g,1);let p={};for(;B.avail();){let _=B.readByte();if(_===Eu.TTY_OP_END)break;let b=fg[_],R=B.readUInt32BE();if(_===void 0||b===void 0||R===void 0){p=void 0;break}p[b]=R}p!==void 0&&(s={term:a,cols:f,rows:c,width:l,height:h,modes:p})}n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"window-change":{let a=B.readUInt32BE(),f=B.readUInt32BE(),c=B.readUInt32BE(),l=B.readUInt32BE();l!==void 0&&(s={cols:a,rows:f,width:c,height:l}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"x11-req":{let a=B.readBool(),f=B.readString(!0),c=B.readString(),l=B.readUInt32BE();l!==void 0&&(s={single:a,protocol:f,cookie:c,screen:l}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"env":{let a=B.readString(!0),f=B.readString(!0);f!==void 0&&(s={name:a,value:f}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a}=${f})`);break}case"shell":s=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;case"exec":s=B.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"subsystem":s=B.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"signal":s=B.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"xon-xoff":s=B.readBool(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${s})`);break;case"auth-agent-req@openssh.com":s=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;default:s=B.avail()?B.readRaw():null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`)}if(B.clear(),s===void 0)return ct(n,"Inbound: Malformed CHANNEL_REQUEST packet");let o=n._handlers.CHANNEL_REQUEST;o&&o(n,e,r,i,s)},[ut.CHANNEL_SUCCESS]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return ct(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)},[ut.CHANNEL_FAILURE]:(n,t)=>{B.init(t,1);let e=B.readUInt32BE();if(B.clear(),e===void 0)return ct(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 es=nt((Cm,bu)=>{"use strict";var Fo=new Array(256);[ts().HANDLERS,_u()].forEach(n=>{for(let[t,e]of Object.entries(n))t=+t,isFinite(t)&&t>=0&&t<Fo.length&&(Fo[t]=e)});bu.exports=Fo});var ts=nt((km,vu)=>{"use strict";var{createDiffieHellman:cg,createDiffieHellmanGroup:ug,createECDH:lg,createHash:Mo,createPublicKey:hg,diffieHellman:dg,generateKeyPairSync:gg,randomFillSync:pg}=require("crypto"),{Ber:xu}=Kn(),{COMPAT:$o,curve25519Supported:Ag,DEFAULT_KEX:Su,DEFAULT_SERVER_HOST_KEY:yu,DEFAULT_CIPHER:rs,DEFAULT_MAC:ns,DEFAULT_COMPRESSION:is,DISCONNECT_REASON:qe,MESSAGE:at}=Sr(),{CIPHER_INFO:In,createCipher:Eg,createDecipher:mg,MAC_INFO:wu}=Tr(),{parseDERKey:_g}=Or(),{bufferFill:bg,bufferParser:$e,convertSignature:xg,doFatalError:Ke,FastBuffer:Sg,sigSSHToASN1:yg,writeUInt32BE:vt}=or(),{PacketReader:Iu,PacketWriter:Cu,ZlibPacketReader:ss,ZlibPacketWriter:os}=Do(),yn,wg=2048,Ig=8192,Cg=Buffer.alloc(0);function Bu(n){let t;if(n._compatFlags&$o.BAD_DHGEX){let e=n._offer.lists.kex,r=e.array,i=!1;for(let s=0;s<r.length;++s)r[s].includes("group-exchange")&&(i||(i=!0,r=r.slice()),r.splice(s--,1));if(i){let s=17+n._offer.totalSize+1+4,o=Buffer.from(r.join(","));s-=e.buffer.length-o.length;let a=n._offer.lists.all,f=new Uint8Array(a.buffer,a.byteOffset+4+e.buffer.length,a.length-(4+e.buffer.length));t=Buffer.allocUnsafe(s),vt(t,o.length,17),t.set(o,21),t.set(f,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]=at.KEXINIT,pg(t,1,16),bg(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 ku(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($e.init(t,17),(e.kex=$e.readList())===void 0||(e.serverHostKey=$e.readList())===void 0||(e.cs.cipher=$e.readList())===void 0||(e.sc.cipher=$e.readList())===void 0||(e.cs.mac=$e.readList())===void 0||(e.sc.mac=$e.readList())===void 0||(e.cs.compress=$e.readList())===void 0||(e.sc.compress=$e.readList())===void 0||(e.cs.lang=$e.readList())===void 0||(e.sc.lang=$e.readList())===void 0)return $e.clear(),Ke(n,"Received malformed KEXINIT","handshake",qe.KEY_EXCHANGE_FAILED);let r=$e.pos(),i=r<t.length&&t[r]===1;$e.clear();let s=n._offer,o=e,a=s.lists.kex.array;if(n._compatFlags&$o.BAD_DHGEX){let H=!1;for(let z=0;z<a.length;++z)a[z].indexOf("group-exchange")!==-1&&(H||(H=!0,a=a.slice()),a.splice(z--,1))}let f,c,l,h=n._debug;h&&h("Inbound: Handshake in progress"),h&&h(`Handshake: (local) KEX method: ${a}`),h&&h(`Handshake: (remote) KEX method: ${o.kex}`);let g;if(n._server?(c=a,f=o.kex,g=f.indexOf("ext-info-c")!==-1):(c=o.kex,f=a,g=c.indexOf("ext-info-s")!==-1),n._strictMode===void 0&&(n._server?n._strictMode=f.indexOf("kex-strict-c-v00@openssh.com")!==-1:n._strictMode=c.indexOf("kex-strict-s-v00@openssh.com")!==-1,n._strictMode&&(h&&h("Handshake: strict KEX mode enabled"),n._decipher.inSeqno!==1)))return h&&h("Handshake: KEXINIT not first packet in strict KEX mode"),Ke(n,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",qe.KEY_EXCHANGE_FAILED);for(l=0;l<f.length&&c.indexOf(f[l])===-1;++l);if(l===f.length)return h&&h("Handshake: no matching key exchange algorithm"),Ke(n,"Handshake failed: no matching key exchange algorithm","handshake",qe.KEY_EXCHANGE_FAILED);e.kex=f[l],h&&h(`Handshake: KEX algorithm: ${f[l]}`),i&&(!o.kex.length||f[l]!==o.kex[0])&&(n._skipNextInboundPacket=!0);let p=s.lists.serverHostKey.array;for(h&&h(`Handshake: (local) Host key format: ${p}`),h&&h(`Handshake: (remote) Host key format: ${o.serverHostKey}`),n._server?(c=p,f=o.serverHostKey):(c=o.serverHostKey,f=p),l=0;l<f.length&&c.indexOf(f[l])===-1;++l);if(l===f.length)return h&&h("Handshake: No matching host key format"),Ke(n,"Handshake failed: no matching host key format","handshake",qe.KEY_EXCHANGE_FAILED);e.serverHostKey=f[l],h&&h(`Handshake: Host key format: ${f[l]}`);let _=s.lists.cs.cipher.array;for(h&&h(`Handshake: (local) C->S cipher: ${_}`),h&&h(`Handshake: (remote) C->S cipher: ${o.cs.cipher}`),n._server?(c=_,f=o.cs.cipher):(c=o.cs.cipher,f=_),l=0;l<f.length&&c.indexOf(f[l])===-1;++l);if(l===f.length)return h&&h("Handshake: No matching C->S cipher"),Ke(n,"Handshake failed: no matching C->S cipher","handshake",qe.KEY_EXCHANGE_FAILED);e.cs.cipher=f[l],h&&h(`Handshake: C->S Cipher: ${f[l]}`);let b=s.lists.sc.cipher.array;for(h&&h(`Handshake: (local) S->C cipher: ${b}`),h&&h(`Handshake: (remote) S->C cipher: ${o.sc.cipher}`),n._server?(c=b,f=o.sc.cipher):(c=o.sc.cipher,f=b),l=0;l<f.length&&c.indexOf(f[l])===-1;++l);if(l===f.length)return h&&h("Handshake: No matching S->C cipher"),Ke(n,"Handshake failed: no matching S->C cipher","handshake",qe.KEY_EXCHANGE_FAILED);e.sc.cipher=f[l],h&&h(`Handshake: S->C cipher: ${f[l]}`);let R=s.lists.cs.mac.array;if(h&&h(`Handshake: (local) C->S MAC: ${R}`),h&&h(`Handshake: (remote) C->S MAC: ${o.cs.mac}`),In[e.cs.cipher].authLen>0)e.cs.mac="",h&&h("Handshake: C->S MAC: <implicit>");else{for(n._server?(c=R,f=o.cs.mac):(c=o.cs.mac,f=R),l=0;l<f.length&&c.indexOf(f[l])===-1;++l);if(l===f.length)return h&&h("Handshake: No matching C->S MAC"),Ke(n,"Handshake failed: no matching C->S MAC","handshake",qe.KEY_EXCHANGE_FAILED);e.cs.mac=f[l],h&&h(`Handshake: C->S MAC: ${f[l]}`)}let P=s.lists.sc.mac.array;if(h&&h(`Handshake: (local) S->C MAC: ${P}`),h&&h(`Handshake: (remote) S->C MAC: ${o.sc.mac}`),In[e.sc.cipher].authLen>0)e.sc.mac="",h&&h("Handshake: S->C MAC: <implicit>");else{for(n._server?(c=P,f=o.sc.mac):(c=o.sc.mac,f=P),l=0;l<f.length&&c.indexOf(f[l])===-1;++l);if(l===f.length)return h&&h("Handshake: No matching S->C MAC"),Ke(n,"Handshake failed: no matching S->C MAC","handshake",qe.KEY_EXCHANGE_FAILED);e.sc.mac=f[l],h&&h(`Handshake: S->C MAC: ${f[l]}`)}let L=s.lists.cs.compress.array;for(h&&h(`Handshake: (local) C->S compression: ${L}`),h&&h(`Handshake: (remote) C->S compression: ${o.cs.compress}`),n._server?(c=L,f=o.cs.compress):(c=o.cs.compress,f=L),l=0;l<f.length&&c.indexOf(f[l])===-1;++l);if(l===f.length)return h&&h("Handshake: No matching C->S compression"),Ke(n,"Handshake failed: no matching C->S compression","handshake",qe.KEY_EXCHANGE_FAILED);e.cs.compress=f[l],h&&h(`Handshake: C->S compression: ${f[l]}`);let ee=s.lists.sc.compress.array;for(h&&h(`Handshake: (local) S->C compression: ${ee}`),h&&h(`Handshake: (remote) S->C compression: ${o.sc.compress}`),n._server?(c=ee,f=o.sc.compress):(c=o.sc.compress,f=ee),l=0;l<f.length&&c.indexOf(f[l])===-1;++l);if(l===f.length)return h&&h("Handshake: No matching S->C compression"),Ke(n,"Handshake failed: no matching S->C compression","handshake",qe.KEY_EXCHANGE_FAILED);e.sc.compress=f[l],h&&h(`Handshake: S->C compression: ${f[l]}`),e.cs.lang="",e.sc.lang="",n._kex&&(n._kexinit||Bu(n),n._decipher._onPayload=Ru.bind(n,{firstPacket:!1})),n._kex=Bg(e,n,t),n._kex.remoteExtInfoEnabled=g,n._kex.start()}var Bg=(()=>{function n(o){let a=0,f=o.length;for(;o[a]===0;)++a,--f;let c;return o[a]&128?(c=Buffer.allocUnsafe(1+f),c[0]=0,o.copy(c,1,a),o=c):f!==o.length&&(c=Buffer.allocUnsafe(f),o.copy(c,0,a),o=c),o}class t{constructor(a,f,c){this._protocol=f,this.sessionID=f._kex?f._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=f._kexinit,this._remoteKexinit=c,this._identRaw=f._identRaw,this._remoteIdentRaw=f._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(a){if(this._finished)return!1;this._finished=!0;let f=this._protocol._server,c=this.negotiated,l=this.convertPublicKey(this._dhData),h=this.computeSecret(this._dhData);if(h instanceof Error)return h.message=`Error while computing DH secret (${this.type}): ${h.message}`,h.level="handshake",Ke(this._protocol,h,qe.KEY_EXCHANGE_FAILED);let g=Mo(this.hashName);pr(g,f?this._remoteIdentRaw:this._identRaw),pr(g,f?this._identRaw:this._remoteIdentRaw),pr(g,f?this._remoteKexinit:this._kexinit),pr(g,f?this._kexinit:this._remoteKexinit);let p=f?this._hostKey.getPublicSSH():this._hostKey;if(pr(g,p),this.type==="groupex"){let ee=this.getDHParams(),H=Buffer.allocUnsafe(4);vt(H,this._minBits,0),g.update(H),vt(H,this._prefBits,0),g.update(H),vt(H,this._maxBits,0),g.update(H),pr(g,ee.prime),pr(g,ee.generator)}pr(g,f?l:this.getPublicKey());let _=f?this.getPublicKey():l;pr(g,_),pr(g,h);let b=g.digest();if(f){let ee;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":ee="sha256";break;case"rsa-sha2-512":ee="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let H=this._hostKey.sign(b,ee);if(H instanceof Error)return Ke(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${H.message}`,"handshake",qe.KEY_EXCHANGE_FAILED);if(H=xg(H,this._hostKey.type),H===!1)return Ke(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",qe.KEY_EXCHANGE_FAILED);let z=this.negotiated.serverHostKey,J=Buffer.byteLength(z),V=4+J+4+H.length,y=this._protocol._packetRW.write.allocStartKEX,w=this._protocol._packetRW.write.alloc(5+p.length+4+_.length+4+V,!0);if(w[y]=at.KEXDH_REPLY,vt(w,p.length,++y),w.set(p,y+=4),vt(w,_.length,y+=p.length),w.set(_,y+=4),vt(w,V,y+=_.length),vt(w,J,y+=4),w.utf8Write(z,y+=4,J),vt(w,H.length,y+=J),w.set(H,y+=4),this._protocol._debug){let U;switch(this.type){case"group":U="KEXDH_REPLY";break;case"groupex":U="KEXDH_GEX_REPLY";break;default:U="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${U}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(w,!0))}else{$e.init(this._sig,0);let ee=$e.readString(!0);if(!ee)return Ke(this._protocol,"Malformed packet while reading signature","handshake",qe.KEY_EXCHANGE_FAILED);if(ee!==c.serverHostKey)return Ke(this._protocol,`Wrong signature type: ${ee}, expected: ${c.serverHostKey}`,"handshake",qe.KEY_EXCHANGE_FAILED);let H=$e.readString();if($e.clear(),H===void 0)return Ke(this._protocol,"Malformed packet while reading signature","handshake",qe.KEY_EXCHANGE_FAILED);if(!(H=yg(H,ee)))return Ke(this._protocol,"Malformed signature","handshake",qe.KEY_EXCHANGE_FAILED);let z;{$e.init(this._hostKey,0);let y=$e.readString(!0),w=this._hostKey.slice($e.pos());if($e.clear(),z=_g(w,y),z instanceof Error)return z.level="handshake",Ke(this._protocol,z,qe.KEY_EXCHANGE_FAILED)}let J;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":J="sha256";break;case"rsa-sha2-512":J="sha512";break}this._protocol._debug&&this._protocol._debug("Verifying signature ...");let V=z.verify(b,H,J);if(V!==!0)return V instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${V.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),Ke(this._protocol,"Handshake failed: signature verification failed","handshake",qe.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(f||!a)&&as(this);let R,P,L=ee=>{if(R)return as(this),R.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=Eg(R),this._protocol._packetRW.write=P,R=void 0,P=void 0,this._protocol._onHandshakeComplete(c),!1;this.sessionID||(this.sessionID=b);{let te=Buffer.allocUnsafe(4+h.length);vt(te,h.length,0),te.set(h,4),h=te}let H=In[c.cs.cipher],z=In[c.sc.cipher],J=wn(H.ivLen,this.hashName,h,b,this.sessionID,"A"),V=wn(z.ivLen,this.hashName,h,b,this.sessionID,"B"),y=wn(H.keyLen,this.hashName,h,b,this.sessionID,"C"),w=wn(z.keyLen,this.hashName,h,b,this.sessionID,"D"),U,$;H.authLen||(U=wu[c.cs.mac],$=wn(U.len,this.hashName,h,b,this.sessionID,"E"));let M,se;z.authLen||(M=wu[c.sc.mac],se=wn(M.len,this.hashName,h,b,this.sessionID,"F"));let Z={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:f?H:z,decipherIV:f?J:V,decipherKey:f?y:w,macInfo:f?U:M,macKey:f?$:se},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:f?z:H,cipherIV:f?V:J,cipherKey:f?w:y,macInfo:f?M:U,macKey:f?se:$}};this._protocol._decipher.free(),R=Z,this._protocol._decipher=mg(Z);let j={read:void 0,write:void 0};switch(c.cs.compress){case"zlib":f?j.read=new ss:j.write=new os(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){f?j.read=new ss:j.write=new os(this._protocol);break}default:f?j.read=new Iu:j.write=new Cu(this._protocol)}switch(c.sc.compress){case"zlib":f?j.write=new os(this._protocol):j.read=new ss;break;case"zlib@openssh.com":if(this._protocol._authenticated){f?j.write=new os(this._protocol):j.read=new ss;break}default:f?j.write=new Cu(this._protocol):j.read=new Iu}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=j.read,P=j.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,ee?!1:L()};if((f||a)&&(this.finish=L),!f)return L(a)}start(){if(!this._protocol._server){if(this._protocol._debug){let l;this.type==="group"?l="KEXDH_INIT":l="KEXECDH_INIT",this._protocol._debug(`Outbound: Sending ${l}`)}let a=this.getPublicKey(),f=this._protocol._packetRW.write.allocStartKEX,c=this._protocol._packetRW.write.alloc(5+a.length,!0);c[f]=at.KEXDH_INIT,vt(c,a.length,++f),c.set(a,f+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(c,!0))}}getPublicKey(){this.generateKeys();let a=this._public;if(a)return this.convertPublicKey(a)}convertPublicKey(a){let f,c=0,l=a.length;for(;a[c]===0;)++c,--l;return a[c]&128?(f=Buffer.allocUnsafe(1+l),f[0]=0,a.copy(f,1,c),f):(l!==a.length&&(f=Buffer.allocUnsafe(l),a.copy(f,0,c),a=f),a)}computeSecret(a){this.generateKeys();try{return n(this._dh.computeSecret(a))}catch(f){return f}}parse(a){let f=a[0];switch(this._step){case 1:if(this._protocol._server){if(f!==at.KEXDH_INIT)return Ke(this._protocol,`Received packet ${f} instead of ${at.KEXDH_INIT}`,"handshake",qe.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),$e.init(a,1);let c=$e.readString();if($e.clear(),c===void 0)return Ke(this._protocol,"Received malformed KEX*_INIT","handshake",qe.KEY_EXCHANGE_FAILED);this._dhData=c;let l=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(l)&&(l=l[0]),this._hostKey=l,this.finish()}else{if(f!==at.KEXDH_REPLY)return Ke(this._protocol,`Received packet ${f} instead of ${at.KEXDH_REPLY}`,"handshake",qe.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),$e.init(a,1);let c,l,h;if((c=$e.readString())===void 0||(l=$e.readString())===void 0||(h=$e.readString())===void 0)return $e.clear(),Ke(this._protocol,"Received malformed KEX*_REPLY","handshake",qe.KEY_EXCHANGE_FAILED);$e.clear(),$e.init(c,0);let g=$e.readString(!0);if($e.clear(),g===void 0)return Ke(this._protocol,"Received malformed host public key","handshake",qe.KEY_EXCHANGE_FAILED);if(g!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(g==="ssh-rsa")break;default:return Ke(this._protocol,"Host key does not match negotiated type","handshake",qe.KEY_EXCHANGE_FAILED)}this._hostKey=c,this._dhData=l,this._sig=h;let p=!1,_;if(this._protocol._hostVerifier===void 0?(_=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):_=this._protocol._hostVerifier(c,b=>{if(!p){if(p=!0,b===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),Ke(this._protocol,"Host denied (verification failed)","handshake",qe.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():as(this)}}),_===void 0){++this._step;return}if(p=!0,_===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),Ke(this._protocol,"Host denied (verification failed)","handshake",qe.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,as(this)}++this._step;break;case 2:return f!==at.NEWKEYS?Ke(this._protocol,`Received packet ${f} instead of ${at.NEWKEYS}`,"handshake",qe.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 Ke(this._protocol,`Received unexpected packet ${f} after NEWKEYS`,"handshake",qe.KEY_EXCHANGE_FAILED)}}}class e extends t{constructor(a,...f){super(...f),this.type="25519",this.hashName=a,this._keys=null}generateKeys(){this._keys||(this._keys=gg("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(a){let f,c=0,l=a.length;for(;a[c]===0;)++c,--l;return a.length===32||l!==a.length&&(f=Buffer.allocUnsafe(l),a.copy(f,0,c),a=f),a}computeSecret(a){this.generateKeys();try{let f=new xu.Writer;return f.startSequence(),f.startSequence(),f.writeOID("1.3.101.110"),f.endSequence(),f.startSequence(xu.BitString),f.writeByte(0),f._ensure(a.length),a.copy(f._buf,f._offset,0,a.length),f._offset+=a.length,f.endSequence(),f.endSequence(),n(dg({privateKey:this._keys.privateKey,publicKey:hg({key:f.buffer,type:"spki",format:"der"})}))}catch(f){return f}}}class r extends t{constructor(a,f,...c){super(...c),this.type="ecdh",this.curveName=a,this.hashName=f}generateKeys(){this._dh||(this._dh=lg(this.curveName),this._public=this._dh.generateKeys())}}class i extends t{constructor(a,...f){super(...f),this.type="groupex",this.hashName=a,this._prime=null,this._generator=null,this._minBits=wg,this._prefBits=kg(this.negotiated),this._protocol._compatFlags&$o.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=Ig}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let a=this._protocol._packetRW.write.allocStartKEX,f=this._protocol._packetRW.write.alloc(13,!0);f[a]=at.KEXDH_GEX_REQUEST,vt(f,this._minBits,++a),vt(f,this._prefBits,a+=4),vt(f,this._maxBits,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(f,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=cg(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(a,f){if(!Buffer.isBuffer(a))throw new Error("Invalid prime value");if(!Buffer.isBuffer(f))throw new Error("Invalid generator value");this._prime=a,this._generator=f}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}parse(a){let f=a[0];switch(this._step){case 1:{if(this._protocol._server)return f!==at.KEXDH_GEX_REQUEST?Ke(this._protocol,`Received packet ${f} instead of `+at.KEXDH_GEX_REQUEST,"handshake",qe.KEY_EXCHANGE_FAILED):Ke(this._protocol,"Group exchange not implemented for server","handshake",qe.KEY_EXCHANGE_FAILED);if(f!==at.KEXDH_GEX_GROUP)return Ke(this._protocol,`Received packet ${f} instead of ${at.KEXDH_GEX_GROUP}`,"handshake",qe.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),$e.init(a,1);let c,l;if((c=$e.readString())===void 0||(l=$e.readString())===void 0)return $e.clear(),Ke(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",qe.KEY_EXCHANGE_FAILED);$e.clear(),this.setDHParams(c,l),this.generateKeys();let h=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let g=this._protocol._packetRW.write.allocStartKEX,p=this._protocol._packetRW.write.alloc(5+h.length,!0);p[g]=at.KEXDH_GEX_INIT,vt(p,h.length,++g),p.set(h,g+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(p,!0)),++this._step;break}case 2:if(this._protocol._server)return f!==at.KEXDH_GEX_INIT?Ke(this._protocol,`Received packet ${f} instead of ${at.KEXDH_GEX_INIT}`,"handshake",qe.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),Ke(this._protocol,"Group exchange not implemented for server","handshake",qe.KEY_EXCHANGE_FAILED));if(f!==at.KEXDH_GEX_REPLY)return Ke(this._protocol,`Received packet ${f} instead of ${at.KEXDH_GEX_REPLY}`,"handshake",qe.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,a[0]=at.KEXDH_REPLY,this.parse=t.prototype.parse,this.parse(a)}}}class s extends t{constructor(a,f,...c){super(...c),this.type="group",this.groupName=a,this.hashName=f}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");let a=this.getPublicKey(),f=this._protocol._packetRW.write.allocStartKEX,c=this._protocol._packetRW.write.alloc(5+a.length,!0);c[f]=at.KEXDH_INIT,vt(c,a.length,++f),c.set(a,f+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(c,!0))}}generateKeys(){this._dh||(this._dh=ug(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 f=o.kex;if(typeof f=="string"){switch(a=[o,...a],f){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!Ag)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 s("modp2","sha1",...a);case"diffie-hellman-group14-sha1":return new s("modp14","sha1",...a);case"diffie-hellman-group14-sha256":return new s("modp14","sha256",...a);case"diffie-hellman-group15-sha512":return new s("modp15","sha512",...a);case"diffie-hellman-group16-sha512":return new s("modp16","sha512",...a);case"diffie-hellman-group17-sha512":return new s("modp17","sha512",...a);case"diffie-hellman-group18-sha512":return new s("modp18","sha512",...a);case"diffie-hellman-group-exchange-sha1":return new i("sha1",...a);case"diffie-hellman-group-exchange-sha256":return new i("sha256",...a)}throw new Error(`Unsupported key exchange algorithm: ${f}`)}throw new Error(`Invalid key exchange type: ${f}`)}})(),Qo=(()=>{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},i=0;for(let a of n){let f,c,l,h;if(typeof a=="string")f=r,c=e[a],l=h=a;else{let p=a[0];f=r[p],h=a[1],c=e[p][h],l=`${p}.${h}`}let g={array:void 0,buffer:void 0};if(Buffer.isBuffer(c))g.array=(""+c).split(","),g.buffer=c,i+=4+c.length;else{if(typeof c=="string"&&(c=c.split(",")),Array.isArray(c))g.array=c,g.buffer=Buffer.from(c.join(","));else throw new TypeError(`Invalid \`${l}\` type: ${typeof c}`);i+=4+g.buffer.length}f[h]=g}let s=Buffer.allocUnsafe(i);r.all=s;let o=0;for(let a of n){let f;typeof a=="string"?f=r[a].buffer:f=r[a[0]][a[1]].buffer,o=vt(s,f.length,o),s.set(f,o),o+=f.length}this.totalSize=i,this.lists=r}copyAllTo(e,r){let i=this.lists.all;if(typeof r!="number")throw new TypeError(`Invalid offset value: ${typeof r}`);if(e.length-r<i.length)throw new Error("Insufficient space to copy list");return e.set(i,r),i.length}}})(),pr=(()=>{let n=Buffer.allocUnsafe(4);return(t,e)=>{vt(n,e.length,0),t.update(n),t.update(e)}})();function wn(n,t,e,r,i,s){let o;if(n){let a=Mo(t).update(e).update(r).update(s).update(i).digest();for(;a.length<n;){let f=Mo(t).update(e).update(r).update(a).digest(),c=Buffer.allocUnsafe(a.length+f.length);c.set(a,0),c.set(f,a.length),a=c}a.length===n?o=a:o=new Sg(a.buffer,a.byteOffset,n)}else o=Cg;return o}function Ru(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 at.IGNORE:case at.UNIMPLEMENTED:case at.DEBUG:return yn||(yn=es()),yn[e](this,t)}switch(e){case at.DISCONNECT:return yn||(yn=es()),yn[e](this,t);case at.KEXINIT:return n.firstPacket?(n.firstPacket=!1,ku(this,t)):Ke(this,"Received extra KEXINIT during handshake","handshake",qe.KEY_EXCHANGE_FAILED);default:if(e<20||e>49)return Ke(this,`Received unexpected packet type ${e}`,"handshake",qe.KEY_EXCHANGE_FAILED)}return this._kex.parse(t)}function kg(n){let t=In[n.cs.cipher],e=In[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 as(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]=at.NEWKEYS,n._protocol._cipher.encrypt(n._protocol._packetRW.write.finalize(e,!0)),n._sentNEWKEYS=!0,n._protocol._strictMode&&(n._protocol._cipher.outSeqno=0)}}vu.exports={KexInit:Qo,kexinit:Bu,onKEXPayload:Ru,DEFAULT_KEXINIT_CLIENT:new Qo({kex:Su.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:yu,cs:{cipher:rs,mac:ns,compress:is,lang:[]},sc:{cipher:rs,mac:ns,compress:is,lang:[]}}),DEFAULT_KEXINIT_SERVER:new Qo({kex:Su.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:yu,cs:{cipher:rs,mac:ns,compress:is,lang:[]},sc:{cipher:rs,mac:ns,compress:is,lang:[]}}),HANDLERS:{[at.KEXINIT]:ku}}});var Nu=nt((Rm,Rg)=>{Rg.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 Go=nt((vm,qu)=>{"use strict";var{inspect:Du}=require("util"),{bindingAvailable:vg,NullCipher:Ng,NullDecipher:Pg}=Tr(),{COMPAT_CHECKS:Tg,DISCONNECT_REASON:Hu,eddsaSupported:Lg,MESSAGE:be,SIGNALS:Pu,TERMINAL_MODE:qo}=Sr(),{DEFAULT_KEXINIT_CLIENT:Ug,DEFAULT_KEXINIT_SERVER:Og,KexInit:Tu,kexinit:Fu,onKEXPayload:Dg}=ts(),{parseKey:Lu}=Or(),Hg=es(),{bufferCopy:fs,bufferFill:Fg,bufferSlice:Qu,convertSignature:Uu,sendPacket:xe,writeUInt32BE:I}=or(),{PacketReader:Qg,PacketWriter:Mg,ZlibPacketReader:Mu,ZlibPacketWriter:$u}=Do(),$g=Nu().version,Wg=new Map(Object.values(Hu).map(n=>[n,1])),Wu=Buffer.from(`SSH-2.0-ssh2js${$g}`),qg=Buffer.from(`${Wu}\r
26
+ `),Kg=8192,Gg=1024,Ou=Buffer.from([be.GLOBAL_REQUEST,0,0,0,21,107,101,101,112,97,108,105,118,101,64,111,112,101,110,115,115,104,46,99,111,109,1]),Yg=Buffer.from([qo.TTY_OP_END]);function Wo(){}var Ko=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 i=t.debug;this._debug=typeof i=="function"?p=>{i(p)}:void 0;let s=t.onHeader;this._onHeader=typeof s=="function"?(...p)=>{s(...p)}:Wo;let o=t.onPacket;this._onPacket=typeof o=="function"?()=>{o()}:Wo;let a=t.onHandshakeComplete;typeof a!="function"&&(a=Wo);let f;this._onHandshakeComplete=(...p)=>{this._debug&&this._debug("Handshake completed"),f===void 0?f=!0:f=!1;let _=this._queue;if(_){this._queue=void 0,this._debug&&this._debug(`Draining outbound queue (${_.length}) ...`);for(let b=0;b<_.length;++b){let R=_[b],P=this._packetRW.write.finalize(R);if(P===R){let L=this._cipher.allocPacket(R.length);L.set(R,5),P=L}xe(this,P)}this._debug&&this._debug("... finished draining outbound queue")}f&&this._server&&this._kex.remoteExtInfoEnabled&&e0(this),a(...p)},this._queue=void 0;let c=t.messageHandlers;typeof c=="object"&&c!==null?this._handlers=c:this._handlers={},this._onPayload=zg.bind(this),this._server=!!t.server,this._banner=void 0;let l;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&&(l=t.greeting.slice(-2)===`\r
27
+ `?t.greeting:`${t.greeting}\r
28
+ `),typeof t.banner=="string"&&t.banner.length&&(this._banner=t.banner.slice(-2)===`\r
29
+ `?t.banner:`${t.banner}\r
30
+ `)}else this._hostKeys=void 0;let h=t.offer;typeof h!="object"||h===null?h=this._server?Og:Ug:h.constructor!==Tu&&(this._server?h.kex=h.kex.concat(["kex-strict-s-v00@openssh.com"]):h.kex=h.kex.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),h=new Tu(h)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=h,this._cipher=new Ng(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new Qg,write:new Mg(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 g;if(typeof t.ident=="string")this._identRaw=Buffer.from(`SSH-2.0-${t.ident}`),g=Buffer.allocUnsafe(this._identRaw.length+2),g.set(this._identRaw,0),g[g.length-2]=13,g[g.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,g=Buffer.allocUnsafe(p.length+2),g.set(p,0),g[g.length-2]=13,g[g.length-1]=10}else this._identRaw=Wu,g=qg;this._compatFlags=0,this._debug&&(vg?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${Du(this._identRaw.toString())}`),this.start=()=>{this.start=void 0,l&&this._onWrite(l),this._onWrite(g)}}_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,i=this._packetRW.write.alloc(13,!0),s=r+13;Wg.has(t)||(t=Hu.PROTOCOL_ERROR),i[r]=be.DISCONNECT,I(i,t,++r),i.fill(0,r+=4,s),this._debug&&this._debug(`Outbound: Sending DISCONNECT (${t})`),xe(this,this._packetRW.write.finalize(i,!0),!0)}ping(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(Ou.length);e.set(Ou,t),this._debug&&this._debug("Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)"),xe(this,this._packetRW.write.finalize(e))}rekey(){this._kexinit===void 0?(this._debug&&this._debug("Outbound: Initiated explicit rekey"),this._queue=[],Fu(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]=be.REQUEST_SUCCESS,r.set(t,++e)):(r=this._packetRW.write.alloc(1),r[e]=be.REQUEST_SUCCESS),this._debug&&this._debug("Outbound: Sending REQUEST_SUCCESS"),xe(this,this._packetRW.write.finalize(r))}requestFailure(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=be.REQUEST_FAILURE,this._debug&&this._debug("Outbound: Sending REQUEST_FAILURE"),xe(this,this._packetRW.write.finalize(e))}channelSuccess(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=be.CHANNEL_SUCCESS,I(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${t})`),xe(this,this._packetRW.write.finalize(r))}channelFailure(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=be.CHANNEL_FAILURE,I(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${t})`),xe(this,this._packetRW.write.finalize(r))}channelEOF(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=be.CHANNEL_EOF,I(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_EOF (r:${t})`),xe(this,this._packetRW.write.finalize(r))}channelClose(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=be.CHANNEL_CLOSE,I(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${t})`),xe(this,this._packetRW.write.finalize(r))}channelWindowAdjust(t,e){let r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(9);i[r]=be.CHANNEL_WINDOW_ADJUST,I(i,t,++r),I(i,e,r+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${t}, ${e})`),xe(this,this._packetRW.write.finalize(i))}channelData(t,e){let r=Buffer.isBuffer(e),i=r?e.length:Buffer.byteLength(e),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(9+i);o[s]=be.CHANNEL_DATA,I(o,t,++s),I(o,i,s+=4),r?o.set(e,s+=4):o.utf8Write(e,s+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_DATA (r:${t}, ${i})`),xe(this,this._packetRW.write.finalize(o))}channelExtData(t,e,r){let i=Buffer.isBuffer(e),s=i?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(13+s);a[o]=be.CHANNEL_EXTENDED_DATA,I(a,t,++o),I(a,r,o+=4),I(a,s,o+=4),i?a.set(e,o+=4):a.utf8Write(e,o+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${t})`),xe(this,this._packetRW.write.finalize(a))}channelOpenConfirm(t,e,r,i){let s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(17);o[s]=be.CHANNEL_OPEN_CONFIRMATION,I(o,t,++s),I(o,e,s+=4),I(o,r,s+=4),I(o,i,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${t}, l:${e})`),xe(this,this._packetRW.write.finalize(o))}channelOpenFail(t,e,r){typeof r!="string"&&(r="");let i=Buffer.byteLength(r),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(13+i+4);o[s]=be.CHANNEL_OPEN_FAILURE,I(o,t,++s),I(o,e,s+=4),I(o,i,s+=4),s+=4,i&&(o.utf8Write(r,s,i),s+=i),I(o,0,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${t})`),xe(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,i=this._packetRW.write.alloc(5+e);i[r]=be.SERVICE_REQUEST,I(i,e,++r),i.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_REQUEST (${t})`),xe(this,this._packetRW.write.finalize(i))}authPassword(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(t),s=Buffer.byteLength(e),o=r?Buffer.byteLength(r):0,a=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(5+i+4+14+4+8+1+4+s+(r?4+o:0));f[a]=be.USERAUTH_REQUEST,I(f,i,++a),f.utf8Write(t,a+=4,i),I(f,14,a+=i),f.utf8Write("ssh-connection",a+=4,14),I(f,8,a+=14),f.utf8Write("password",a+=4,8),f[a+=8]=r?1:0,I(f,s,++a),Buffer.isBuffer(e)?fs(e,f,0,s,a+=4):f.utf8Write(e,a+=4,s),r?(I(f,o,a+=s),Buffer.isBuffer(r)?fs(r,f,0,o,a+=4):f.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"),xe(this,this._packetRW.write.finalize(f))}authPK(t,e,r,i){if(this._server)throw new Error("Client-only method called in server mode");if(e=Lu(e),e instanceof Error)throw new Error("Invalid key");let s=e.type;e=e.getPublicSSH(),typeof r=="function"&&(i=r,r=void 0),r||(r=s);let o=Buffer.byteLength(t),a=Buffer.byteLength(r),f=e.length,c=this._kex.sessionID,l=c.length,h=(i?4+l:0)+1+4+o+4+14+4+9+1+4+a+4+f,g,p;if(i?(g=Buffer.allocUnsafe(h),p=0,I(g,l,p),g.set(c,p+=4),p+=l):(g=this._packetRW.write.alloc(h),p=this._packetRW.write.allocStart),g[p]=be.USERAUTH_REQUEST,I(g,o,++p),g.utf8Write(t,p+=4,o),I(g,14,p+=o),g.utf8Write("ssh-connection",p+=4,14),I(g,9,p+=14),g.utf8Write("publickey",p+=4,9),g[p+=9]=i?1:0,I(g,a,++p),g.utf8Write(r,p+=4,a),I(g,f,p+=a),g.set(e,p+=4),!i){this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),xe(this,this._packetRW.write.finalize(g));return}i(g,_=>{if(_=Uu(_,s),_===!1)throw new Error("Error while converting handshake signature");let b=_.length;p=this._packetRW.write.allocStart,g=this._packetRW.write.alloc(5+o+4+14+4+9+1+4+a+4+f+4+4+a+4+b),g[p]=be.USERAUTH_REQUEST,I(g,o,++p),g.utf8Write(t,p+=4,o),I(g,14,p+=o),g.utf8Write("ssh-connection",p+=4,14),I(g,9,p+=14),g.utf8Write("publickey",p+=4,9),g[p+=9]=1,I(g,a,++p),g.utf8Write(r,p+=4,a),I(g,f,p+=a),g.set(e,p+=4),I(g,4+a+4+b,p+=f),I(g,a,p+=4),g.utf8Write(r,p+=4,a),I(g,b,p+=a),g.set(_,p+=4),this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey)"),xe(this,this._packetRW.write.finalize(g))})}authHostbased(t,e,r,i,s,o){if(this._server)throw new Error("Client-only method called in server mode");if(e=Lu(e),e instanceof Error)throw new Error("Invalid key");let a=e.type;e=e.getPublicSSH(),typeof s=="function"&&(o=s,s=void 0),s||(s=a);let f=Buffer.byteLength(t),c=Buffer.byteLength(s),l=e.length,h=this._kex.sessionID,g=h.length,p=Buffer.byteLength(r),_=Buffer.byteLength(i),b=Buffer.allocUnsafe(4+g+1+4+f+4+14+4+9+4+c+4+l+4+p+4+_),R=0;I(b,g,R),b.set(h,R+=4),b[R+=g]=be.USERAUTH_REQUEST,I(b,f,++R),b.utf8Write(t,R+=4,f),I(b,14,R+=f),b.utf8Write("ssh-connection",R+=4,14),I(b,9,R+=14),b.utf8Write("hostbased",R+=4,9),I(b,c,R+=9),b.utf8Write(s,R+=4,c),I(b,l,R+=c),b.set(e,R+=4),I(b,p,R+=l),b.utf8Write(r,R+=4,p),I(b,_,R+=p),b.utf8Write(i,R+=4,_),o(b,P=>{if(P=Uu(P,a),!P)throw new Error("Error while converting handshake signature");let L=P.length,ee=b.length-g-4;R=this._packetRW.write.allocStart;let H=this._packetRW.write.alloc(ee+4+4+c+4+L);fs(b,H,4+g,b.length,R),I(H,4+c+4+L,R+=ee),I(H,c,R+=4),H.utf8Write(s,R+=4,c),I(H,L,R+=c),H.set(P,R+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),xe(this,this._packetRW.write.finalize(H))})}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,i=this._packetRW.write.alloc(5+e+4+14+4+20+4+4);i[r]=be.USERAUTH_REQUEST,I(i,e,++r),i.utf8Write(t,r+=4,e),I(i,14,r+=e),i.utf8Write("ssh-connection",r+=4,14),I(i,20,r+=14),i.utf8Write("keyboard-interactive",r+=4,20),I(i,0,r+=20),I(i,0,r+=4),this._authsQueue.push("keyboard-interactive"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)"),xe(this,this._packetRW.write.finalize(i))}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,i=this._packetRW.write.alloc(5+e+4+14+4+4);i[r]=be.USERAUTH_REQUEST,I(i,e,++r),i.utf8Write(t,r+=4,e),I(i,14,r+=e),i.utf8Write("ssh-connection",r+=4,14),I(i,4,r+=14),i.utf8Write("none",r+=4,4),this._authsQueue.push("none"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (none)"),xe(this,this._packetRW.write.finalize(i))}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 i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);if(s[i]=be.USERAUTH_INFO_RESPONSE,t){I(s,t.length,++i),i+=4;for(let o=0;o<t.length;++o){let a=r[o];I(s,a,i),i+=4,a&&(s.utf8Write(t[o],i,a),i+=a)}}else I(s,0,++i);this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_RESPONSE"),xe(this,this._packetRW.write.finalize(s))}tcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(t),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+i+4);o[s]=be.GLOBAL_REQUEST,I(o,13,++s),o.utf8Write("tcpip-forward",s+=4,13),o[s+=13]=r===void 0||r===!0?1:0,I(o,i,++s),o.utf8Write(t,s+=4,i),I(o,e,s+=i),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (tcpip-forward)"),xe(this,this._packetRW.write.finalize(o))}cancelTcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(t),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(30+i+4);o[s]=be.GLOBAL_REQUEST,I(o,20,++s),o.utf8Write("cancel-tcpip-forward",s+=4,20),o[s+=20]=r===void 0||r===!0?1:0,I(o,i,++s),o.utf8Write(t,s+=4,i),I(o,e,s+=i),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)"),xe(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),i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(41+r);s[i]=be.GLOBAL_REQUEST,I(s,31,++i),s.utf8Write("streamlocal-forward@openssh.com",i+=4,31),s[i+=31]=e===void 0||e===!0?1:0,I(s,r,++i),s.utf8Write(t,i+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)"),xe(this,this._packetRW.write.finalize(s))}openssh_cancelStreamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(48+r);s[i]=be.GLOBAL_REQUEST,I(s,38,++i),s.utf8Write("cancel-streamlocal-forward@openssh.com",i+=4,38),s[i+=38]=e===void 0||e===!0?1:0,I(s,r,++i),s.utf8Write(t,i+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-streamlocal-forward@openssh.com)"),xe(this,this._packetRW.write.finalize(s))}directTcpip(t,e,r,i){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(i.srcIP),o=Buffer.byteLength(i.dstIP),a=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(33+s+4+4+o+4);f[a]=be.CHANNEL_OPEN,I(f,12,++a),f.utf8Write("direct-tcpip",a+=4,12),I(f,t,a+=12),I(f,e,a+=4),I(f,r,a+=4),I(f,o,a+=4),f.utf8Write(i.dstIP,a+=4,o),I(f,i.dstPort,a+=o),I(f,s,a+=4),f.utf8Write(i.srcIP,a+=4,s),I(f,i.srcPort,a+=s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-tcpip)`),xe(this,this._packetRW.write.finalize(f))}openssh_directStreamLocal(t,e,r,i){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(i.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(51+s+4+4);a[o]=be.CHANNEL_OPEN,I(a,30,++o),a.utf8Write("direct-streamlocal@openssh.com",o+=4,30),I(a,t,o+=30),I(a,e,o+=4),I(a,r,o+=4),I(a,s,o+=4),a.utf8Write(i.socketPath,o+=4,s),Fg(a,0,o+=s,o+8),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-streamlocal@openssh.com)`),xe(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]=be.GLOBAL_REQUEST,I(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)"),xe(this,this._packetRW.write.finalize(r))}session(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(24);s[i]=be.CHANNEL_OPEN,I(s,7,++i),s.utf8Write("session",i+=4,7),I(s,t,i+=7),I(s,e,i+=4),I(s,r,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, session)`),xe(this,this._packetRW.write.finalize(s))}windowChange(t,e,r,i,s){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]=be.CHANNEL_REQUEST,I(a,t,++o),I(a,13,o+=4),a.utf8Write("window-change",o+=4,13),a[o+=13]=0,I(a,r,++o),I(a,e,o+=4),I(a,s,o+=4),I(a,i,o+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, window-change)`),xe(this,this._packetRW.write.finalize(a))}pty(t,e,r,i,s,o,a,f){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=Zg(a)),(!a||!a.length)&&(a=Yg);let c=o.length,l=a.length,h=this._packetRW.write.allocStart,g=this._packetRW.write.alloc(21+c+4+4+4+4+4+l);if(g[h]=be.CHANNEL_REQUEST,I(g,t,++h),I(g,7,h+=4),g.utf8Write("pty-req",h+=4,7),g[h+=7]=f===void 0||f===!0?1:0,I(g,c,++h),g.utf8Write(o,h+=4,c),I(g,r,h+=c),I(g,e,h+=4),I(g,s,h+=4),I(g,i,h+=4),I(g,l,h+=4),h+=4,Array.isArray(a))for(let p=0;p<l;++p)g[h++]=a[p];else Buffer.isBuffer(a)&&g.set(a,h);this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, pty-req)`),xe(this,this._packetRW.write.finalize(g))}shell(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(15);i[r]=be.CHANNEL_REQUEST,I(i,t,++r),I(i,5,r+=4),i.utf8Write("shell",r+=4,5),i[r+=5]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, shell)`),xe(this,this._packetRW.write.finalize(i))}exec(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.isBuffer(e),s=i?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(18+s);a[o]=be.CHANNEL_REQUEST,I(a,t,++o),I(a,4,o+=4),a.utf8Write("exec",o+=4,4),a[o+=4]=r===void 0||r===!0?1:0,I(a,s,++o),i?a.set(e,o+=4):a.utf8Write(e,o+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exec: ${e})`),xe(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)),Pu[e]!==1)throw new Error(`Invalid signal: ${r}`);let i=e.length,s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(20+i);o[s]=be.CHANNEL_REQUEST,I(o,t,++s),I(o,6,s+=4),o.utf8Write("signal",s+=4,6),o[s+=6]=0,I(o,i,++s),o.utf8Write(e,s+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, signal: ${e})`),xe(this,this._packetRW.write.finalize(o))}env(t,e,r,i){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),o=Buffer.isBuffer(r),a=o?r.length:Buffer.byteLength(r),f=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(17+s+4+a);c[f]=be.CHANNEL_REQUEST,I(c,t,++f),I(c,3,f+=4),c.utf8Write("env",f+=4,3),c[f+=3]=i===void 0||i===!0?1:0,I(c,s,++f),c.utf8Write(e,f+=4,s),I(c,a,f+=s),o?c.set(r,f+=4):c.utf8Write(r,f+=4,a),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, env: ${e}=${r})`),xe(this,this._packetRW.write.finalize(c))}x11Forward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=e.protocol,s=e.cookie,o=Buffer.isBuffer(i),a=o?i.length:Buffer.byteLength(i),f=Buffer.isBuffer(s),c=f?s.length:Buffer.byteLength(s),l=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(22+a+4+c+4);h[l]=be.CHANNEL_REQUEST,I(h,t,++l),I(h,7,l+=4),h.utf8Write("x11-req",l+=4,7),h[l+=7]=r===void 0||r===!0?1:0,h[++l]=e.single?1:0,I(h,a,++l),o?h.set(i,l+=4):h.utf8Write(i,l+=4,a),I(h,c,l+=a),f?h.set(s,l+=4):h.latin1Write(s,l+=4,c),I(h,e.screen||0,l+=c),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, x11-req)`),xe(this,this._packetRW.write.finalize(h))}subsystem(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+i);o[s]=be.CHANNEL_REQUEST,I(o,t,++s),I(o,9,s+=4),o.utf8Write("subsystem",s+=4,9),o[s+=9]=r===void 0||r===!0?1:0,I(o,i,++s),o.utf8Write(e,s+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, subsystem: ${e})`),xe(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,i=this._packetRW.write.alloc(36);i[r]=be.CHANNEL_REQUEST,I(i,t,++r),I(i,26,r+=4),i.utf8Write("auth-agent-req@openssh.com",r+=4,26),i[r+=26]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, auth-agent-req@openssh.com)`),xe(this,this._packetRW.write.finalize(i))}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 i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(35+e);s[i]=be.GLOBAL_REQUEST,I(s,29,++i),s.utf8Write("hostkeys-prove-00@openssh.com",i+=4,29),s[i+=29]=1,++i;for(let o of r)I(s,o.length,i),fs(o,s,0,o.length,i+=4),i+=o.length;this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)"),xe(this,this._packetRW.write.finalize(s))}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,i=this._packetRW.write.alloc(5+e);if(i[r]=be.SERVICE_ACCEPT,I(i,e,++r),i.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_ACCEPT (${t})`),xe(this,this._packetRW.write.finalize(i)),this._server&&this._banner&&t==="ssh-userauth"){let s=this._banner;this._banner=void 0;let o=Buffer.byteLength(s);r=this._packetRW.write.allocStart;let a=this._packetRW.write.alloc(5+o+4);a[r]=be.USERAUTH_BANNER,I(a,o,++r),a.utf8Write(s,r+=4,o),I(a,0,r+=o),this._debug&&this._debug("Outbound: Sending USERAUTH_BANNER"),xe(this,this._packetRW.write.finalize(a))}}forwardedTcpip(t,e,r,i){if(!this._server)throw new Error("Server-only method called in client mode");let s=Buffer.byteLength(i.boundAddr),o=Buffer.byteLength(i.remoteAddr),a=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(36+s+4+4+o+4);f[a]=be.CHANNEL_OPEN,I(f,15,++a),f.utf8Write("forwarded-tcpip",a+=4,15),I(f,t,a+=15),I(f,e,a+=4),I(f,r,a+=4),I(f,s,a+=4),f.utf8Write(i.boundAddr,a+=4,s),I(f,i.boundPort,a+=s),I(f,o,a+=4),f.utf8Write(i.remoteAddr,a+=4,o),I(f,i.remotePort,a+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-tcpip)`),xe(this,this._packetRW.write.finalize(f))}x11(t,e,r,i){if(!this._server)throw new Error("Server-only method called in client mode");let s=Buffer.byteLength(i.originAddr),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(24+s+4);a[o]=be.CHANNEL_OPEN,I(a,3,++o),a.utf8Write("x11",o+=4,3),I(a,t,o+=3),I(a,e,o+=4),I(a,r,o+=4),I(a,s,o+=4),a.utf8Write(i.originAddr,o+=4,s),I(a,i.originPort,o+=s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, x11)`),xe(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 i=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(39);s[i]=be.CHANNEL_OPEN,I(s,22,++i),s.utf8Write("auth-agent@openssh.com",i+=4,22),I(s,t,i+=22),I(s,e,i+=4),I(s,r,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, auth-agent@openssh.com)`),xe(this,this._packetRW.write.finalize(s))}openssh_forwardedStreamLocal(t,e,r,i){if(!this._server)throw new Error("Server-only method called in client mode");let s=Buffer.byteLength(i.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(54+s+4);a[o]=be.CHANNEL_OPEN,I(a,33,++o),a.utf8Write("forwarded-streamlocal@openssh.com",o+=4,33),I(a,t,o+=33),I(a,e,o+=4),I(a,r,o+=4),I(a,s,o+=4),a.utf8Write(i.socketPath,o+=4,s),I(a,0,o+=s),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-streamlocal@openssh.com)`),xe(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,i=this._packetRW.write.alloc(25);i[r]=be.CHANNEL_REQUEST,I(i,t,++r),I(i,11,r+=4),i.utf8Write("exit-status",r+=4,11),i[r+=11]=0,I(i,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-status: ${e})`),xe(this,this._packetRW.write.finalize(i))}exitSignal(t,e,r,i){if(!this._server)throw new Error("Server-only method called in client mode");let s=e;if(typeof s!="string"||!s)throw new Error(`Invalid signal: ${s}`);let o=e.toUpperCase();if(o.slice(0,3)==="SIG"&&(o=o.slice(3)),Pu[o]!==1)throw new Error(`Invalid signal: ${s}`);let a=Buffer.byteLength(o),f=i?Buffer.byteLength(i):0,c=this._packetRW.write.allocStart,l=this._packetRW.write.alloc(25+a+1+4+f+4);l[c]=be.CHANNEL_REQUEST,I(l,t,++c),I(l,11,c+=4),l.utf8Write("exit-signal",c+=4,11),l[c+=11]=0,I(l,a,++c),l.utf8Write(o,c+=4,a),l[c+=a]=r?1:0,I(l,f,++c),c+=4,f&&(l.utf8Write(i,c,f),c+=f),I(l,0,c),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-signal: ${e})`),xe(this,this._packetRW.write.finalize(l))}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 i=r.length,s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+i+1);o[s]=be.USERAUTH_FAILURE,I(o,i,++s),o.utf8Write(r,s+=4,i),o[s+=i]=e===!0?1:0,this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_FAILURE"),xe(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]=be.USERAUTH_SUCCESS,this._authsQueue.shift(),this._authenticated=!0,this._debug&&this._debug("Outbound: Sending USERAUTH_SUCCESS"),xe(this,this._packetRW.write.finalize(e)),this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.read=new Mu),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new $u(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),i=e.length,s=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+r+4+i);o[s]=be.USERAUTH_PK_OK,I(o,r,++s),o.utf8Write(t,s+=4,r),I(o,i,s+=r),o.set(e,s+=4),this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_PK_OK"),xe(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,i=this._packetRW.write.alloc(5+e+4);i[r]=be.USERAUTH_PASSWD_CHANGEREQ,I(i,e,++r),i.utf8Write(t,r+=4,e),I(i,0,r+=e),this._debug&&this._debug("Outbound: Sending USERAUTH_PASSWD_CHANGEREQ"),xe(this,this._packetRW.write.finalize(i))}authInfoReq(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let i=0,s=t?Buffer.byteLength(t):0,o=e?Buffer.byteLength(e):0;for(let c=0;c<r.length;++c)i+=4+Buffer.byteLength(r[c].prompt)+1;let a=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(5+s+4+o+4+4+i);f[a]=be.USERAUTH_INFO_REQUEST,I(f,s,++a),a+=4,t&&(f.utf8Write(t,a,s),a+=s),I(f,o,a),a+=4,e&&(f.utf8Write(e,a,o),a+=o),I(f,0,a),I(f,r.length,a+=4),a+=4;for(let c=0;c<r.length;++c){let l=r[c],h=Buffer.byteLength(l.prompt);I(f,h,a),a+=4,h&&(f.utf8Write(l.prompt,a,h),a+=h),f[a++]=l.echo?1:0}this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_REQUEST"),xe(this,this._packetRW.write.finalize(f))}},Vg=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function jg(n,t,e){let r,i;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),i=this._buffer.length,t=0):(r=n,i=0);let s=t,o=t,a=t,f=!1,c=0,l=0;for(;t<r.length;++t){let h=r[t];if(h===13){f=!0;continue}if(h===10){if(a>o&&a-o>4&&r[o]===83&&r[o+1]===83&&r[o+2]===72&&r[o+3]===45){let g=r.latin1Slice(s,a+1),p=o===s?g:g.slice(o-s),_=Vg.exec(p);if(!_)throw new Error("Invalid identification string");let b={greeting:o===s?"":g.slice(0,o-s),identRaw:p,versions:{protocol:_[1],software:_[2]},comments:_[3]};return this._remoteIdentRaw=Buffer.from(p),this._debug&&this._debug(`Remote ident: ${Du(p)}`),this._compatFlags=Jg(b),this._buffer=void 0,this._decipher=new Pg(0,Dg.bind(this,{firstPacket:!0})),this._parse=Xg,this._onHeader(b),this._destruct?(Fu(this),t+1-i):e}if(this._server)throw new Error("Greetings from clients not permitted");if(++l>Gg)throw new Error("Max greeting lines exceeded");f=!1,o=t+1,c=0}else{if(f)throw new Error("Invalid header: expected newline");if(++c>=Kg)throw new Error("Header line too long")}a=t}return this._buffer||(this._buffer=Qu(r,s)),t-i}function Xg(n,t,e){return this._decipher.decrypt(n,t,e)}function zg(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===be.USERAUTH_SUCCESS&&!this._server&&!this._authenticated&&(this._authenticated=!0,this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.write=new $u(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new Mu));let e=Hg[t];if(e===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${t}`);return}return e(this,n)}function Jg(n){let t=n.versions.software,e=0;for(let r of Tg)typeof r[0]=="string"?t===r[0]&&(e|=r[1]):r[0].test(t)&&(e|=r[1]);return e}function Zg(n){let t=Object.keys(n),e=Buffer.allocUnsafe(5*t.length+1),r=0;for(let i=0;i<t.length;++i){let s=t[i];if(s==="TTY_OP_END")continue;let o=qo[s];if(o===void 0)continue;let a=n[s];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++]=qo.TTY_OP_END,r<e.length?Qu(e,0,r):e}function e0(n){let t="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";Lg&&(t=`ssh-ed25519,${t}`);let e=Buffer.byteLength(t),r=n._packetRW.write.allocStart,i=n._packetRW.write.alloc(28+e);i[r]=be.EXT_INFO,I(i,1,++r),I(i,15,r+=4),i.utf8Write("server-sig-algs",r+=4,15),I(i,e,r+=15),i.utf8Write(t,r+=4,e),n._debug&&n._debug("Outbound: Sending EXT_INFO"),xe(n,n._packetRW.write.finalize(i))}qu.exports=Ko});var Xu=nt(ci=>{"use strict";var cs=require("assert"),{inspect:t0}=require("util");function Ku(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 Gu(n,t){if(cs(typeof t=="string","`thing` has to be of type string"),Array.isArray(n)){let e=n.length;return cs(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)}`}ci.ERR_INTERNAL_ASSERTION=class Vu extends Error{constructor(t){super(),Error.captureStackTrace(this,Vu);let e=`This is caused by either a bug in ssh2 or incorrect usage of ssh2 internals.
31
+ Please open an issue with this stack trace at https://github.com/mscdex/ssh2/issues
32
+ `;this.message=t===void 0?e:`${t}
33
+ ${e}`}};var r0=2**32,Yu=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();ci.ERR_OUT_OF_RANGE=class ju extends RangeError{constructor(t,e,r,i){super(),Error.captureStackTrace(this,ju),cs(e,'Missing "range" argument');let s=i?t:`The value of "${t}" is out of range.`,o;Number.isInteger(r)&&Math.abs(r)>r0?o=Ku(String(r)):typeof r=="bigint"?(o=String(r),(r>Yu||r<-Yu)&&(o=Ku(o)),o+="n"):o=t0(r),s+=` It must be ${e}. Received ${o}`,this.message=s}};var us=class n extends TypeError{constructor(t,e,r){super(),Error.captureStackTrace(this,n),cs(typeof t=="string","'name' must be a string");let i;typeof e=="string"&&e.startsWith("not ")?(i="must not be",e=e.replace(/^not /,"")):i="must be";let s;if(t.endsWith(" argument"))s=`The ${t} ${i} ${Gu(e,"type")}`;else{let o=t.includes(".")?"property":"argument";s=`The "${t}" ${o} ${i} ${Gu(e,"type")}`}s+=`. Received type ${typeof r}`,this.message=s}};ci.ERR_INVALID_ARG_TYPE=us;ci.validateNumber=function(t,e){if(typeof t!="number")throw new us(e,"number",t)}});var ui=nt((Pm,cl)=>{"use strict";var n0=require("events"),Hr=require("fs"),{constants:Gt}=Hr,{Readable:rl,Writable:ta}=require("stream"),{inherits:nl,types:{isDate:jo}}=require("util"),i0=Buffer[Symbol.species],{bufferCopy:Dr,bufferSlice:kn,makeBufferParser:s0,writeUInt32BE:Q}=or(),Ir={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},Be=Buffer.alloc(28),Xe={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},o0=new Map(Object.values(Xe).map(n=>[n,1])),a0={[Xe.OK]:"No error",[Xe.EOF]:"End of file",[Xe.NO_SUCH_FILE]:"No such file or directory",[Xe.PERMISSION_DENIED]:"Permission denied",[Xe.FAILURE]:"Failure",[Xe.BAD_MESSAGE]:"Bad message",[Xe.NO_CONNECTION]:"No connection",[Xe.CONNECTION_LOST]:"Connection lost",[Xe.OP_UNSUPPORTED]:"Operation unsupported"},Ie={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},Yt={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},Se={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},zu=2*1024,st=2**32-1,f0=Buffer.from([0,0,0,5,Ie.INIT,0,0,0,3]),c0=Buffer.from([0,0,0,5,Yt.VERSION,0,0,0,3]),u0=/^SSH-2.0-(?:OpenSSH|dropbear)/,Yo=256*1024,N=s0(),l0={readable:!1,writable:!1,push:n=>{},once:()=>{},on:()=>{},emit:()=>{},end:()=>{}};function il(){}var Xo=class extends n0{constructor(t,e,r){super(),(typeof r!="object"||!r)&&(r={});let i=t._protocol._remoteIdentRaw;this.server=!!r.server,this._debug=typeof r.debug=="function"?r.debug:void 0,this._isOpenSSH=i&&u0.test(i),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=Yo,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?Yo:34e3)-zu,this._maxWriteLen=(this._isOpenSSH?Yo:34e3)-zu,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=l0,this.readable=!0}push(t){if(t===null){if(fl(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 et(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return et(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 i0(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],i=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let s=this.server?A0[r]:p0[r];if(!s)return et(this,`Unknown packet type ${r}`);if(this._version===-1){if(this.server){if(r!==Ie.INIT)return et(this,`Expected INIT packet, got ${r}`)}else if(r!==Yt.VERSION)return et(this,`Expected VERSION packet, got ${r}`)}if(s(this,i)===!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=il,this.server||Ye(this,f0)}createReadStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new Cr(this,t,e)}createWriteStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new sr(this,t,e)}open(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(i=r,r=void 0);let s=typeof e=="number"?e:ol(e);if(s===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=Jr(r),o=r.flags,a=r.nb);let f=Buffer.byteLength(t),c=9,l=Buffer.allocUnsafe(13+f+4+4+a);Q(l,l.length-4,0),l[4]=Ie.OPEN;let h=this._writeReqid=this._writeReqid+1&st;Q(l,h,5),Q(l,f,c),l.utf8Write(t,c+=4,f),Q(l,s,c+=f),Q(l,o,c+=4),a&&(c+=4,a===Be.length?l.set(Be,c):Dr(Be,l,0,a,c),c+=a),this._requests[h]={cb:i};let g=Ye(this,l);this._debug&&this._debug(`SFTP: Outbound: ${g?"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,i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Ie.CLOSE;let o=this._writeReqid=this._writeReqid+1&st;Q(s,o,5),Q(s,r,i),s.set(t,i+=4),this._requests[o]={cb:e};let a=Ye(this,s);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} CLOSE`)}read(t,e,r,i,s,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+i>e.length)throw new Error("length extends beyond buffer");if(s===null)throw new Error("null position currently unsupported");sl(this,t,e,r,i,s,o)}readData(t,e,r,i,s,o){this.read(t,e,r,i,s,o)}write(t,e,r,i,s,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+i>e.length)throw new Error("length extends beyond buffer");if(s===null)throw new Error("null position currently unsupported");if(!i){o&&process.nextTick(o,void 0,0);return}let a=this._maxWriteLen,f=Math.max(i-a,0),c=s;f&&(i=a);let l=t.length,h=9,g=Buffer.allocUnsafe(13+l+8+4+i);Q(g,g.length-4,0),g[4]=Ie.WRITE;let p=this._writeReqid=this._writeReqid+1&st;Q(g,p,5),Q(g,l,h),g.set(t,h+=4),h+=l;for(let b=7;b>=0;--b)g[h+b]=s&255,s/=256;Q(g,i,h+=8),Dr(e,g,r,r+i,h+=4),this._requests[p]={cb:b=>{b?typeof o=="function"&&o(b):f?this.write(t,e,r+i,f,c+i,o):typeof o=="function"&&o(void 0,r+i)}};let _=Ye(this,g);if(this._debug){let b=_?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${b} WRITE (id:${p})`)}}writeData(t,e,r,i,s,o){this.write(t,e,r,i,s,o)}fastGet(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");Ju(this,Hr,t,e,r,i)}fastPut(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");Ju(Hr,this,t,e,r,i)}readFile(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof r=="function"?i=r:typeof e=="function"&&(i=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 s=e.encoding;if(s&&!Buffer.isEncoding(s))throw new Error(`Unknown encoding: ${s}`);let o,a,f,c=0,l,h=0,g=e.flag||"r",p=()=>{o===0?(a=Buffer.allocUnsafe(8192),this.read(l,a,0,8192,h,_)):this.read(l,a,c,o-c,h,_)},_=(R,P)=>{let L;if(R){if(L=R.code===Xe.EOF,!L)return this.close(l,()=>i&&i(R))}else L=!1;if(L||o===0&&P===0)return b();h+=P,c+=P,o!==0?c===o?b():p():(f.push(kn(a,0,P)),p())};_._wantEOFError=!0;let b=()=>{this.close(l,R=>(o===0?a=Buffer.concat(f,c):c<o&&(a=kn(a,0,c)),s&&(a=a.toString(s)),i&&i(R,a)))};this.open(t,g,438,(R,P)=>{if(R)return i&&i(R);l=P;let L=(ee,H)=>{if(ee){this.stat(t,(z,J)=>{if(z)return this.close(l,()=>{i&&i(ee)});L(null,J)});return}if(o=H.size||0,o===0)return f=[],p();a=Buffer.allocUnsafe(o),p()};this.fstat(l,L)})}writeFile(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof i=="function"?s=i:typeof r=="function"&&(s=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,f)=>{if(a)s&&s(a);else{let c=Buffer.isBuffer(e)?e:Buffer.from(""+e,r.encoding||"utf8"),l=/a/.test(o)?null:0;if(l===null){let h=(g,p)=>{if(g){this.stat(t,(_,b)=>{if(_)return this.close(f,()=>{s&&s(g)});h(null,b)});return}zo(this,f,c,0,c.length,p.size,s)};this.fstat(f,h);return}zo(this,f,c,0,c.length,l,s)}})}appendFile(t,e,r,i){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof i=="function"?s=i:typeof r=="function"&&(s=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,s)}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),i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Ie.REMOVE;let o=this._writeReqid=this._writeReqid+1&st;Q(s,o,5),Q(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let a=Ye(this,s);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 i=Buffer.byteLength(t),s=Buffer.byteLength(e),o=9,a=Buffer.allocUnsafe(13+i+4+s);Q(a,a.length-4,0),a[4]=Ie.RENAME;let f=this._writeReqid=this._writeReqid+1&st;Q(a,f,5),Q(a,i,o),a.utf8Write(t,o+=4,i),Q(a,s,o+=i),a.utf8Write(e,o+=4,s),this._requests[f]={cb:r};let c=Ye(this,a);this._debug&&this._debug(`SFTP: Outbound: ${c?"Buffered":"Sending"} RENAME`)}mkdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let i=0,s=0;typeof e=="function"&&(r=e,e=void 0),typeof e=="object"&&e!==null&&(e=Jr(e),i=e.flags,s=e.nb);let o=Buffer.byteLength(t),a=9,f=Buffer.allocUnsafe(13+o+4+s);Q(f,f.length-4,0),f[4]=Ie.MKDIR;let c=this._writeReqid=this._writeReqid+1&st;Q(f,c,5),Q(f,o,a),f.utf8Write(t,a+=4,o),Q(f,i,a+=o),s&&(a+=4,s===Be.length?f.set(Be,a):Dr(Be,f,0,s,a),a+=s),this._requests[c]={cb:r};let l=Ye(this,f);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} MKDIR`)}rmdir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Ie.RMDIR;let o=this._writeReqid=this._writeReqid+1&st;Q(s,o,5),Q(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let a=Ye(this,s);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 i=!(e&&e.full);if(!Buffer.isBuffer(t)&&typeof t!="string")throw new Error("missing directory handle or path");if(typeof t=="string"){let l=[],h=0,g=(p,_)=>{if(p)return r(p);this.readdir(_,e,(b,R)=>{let P=b&&b.code===Xe.EOF;if(b&&!P)return this.close(_,()=>r(b));if(P)return this.close(_,L=>{if(L)return r(L);r(void 0,l)});for(let L=0;L<R.length;++L,++h)l[h]=R[L];g(void 0,_)})};return this.opendir(t,g)}let s=t.length,o=9,a=Buffer.allocUnsafe(13+s);Q(a,a.length-4,0),a[4]=Ie.READDIR;let f=this._writeReqid=this._writeReqid+1&st;Q(a,f,5),Q(a,s,o),a.set(t,o+=4),this._requests[f]={cb:i?(l,h)=>{if(typeof r=="function"){if(l)return r(l);for(let g=h.length-1;g>=0;--g)(h[g].filename==="."||h[g].filename==="..")&&h.splice(g,1);r(void 0,h)}}:r};let c=Ye(this,a);this._debug&&this._debug(`SFTP: Outbound: ${c?"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,i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Ie.FSTAT;let o=this._writeReqid=this._writeReqid+1&st;Q(s,o,5),Q(s,r,i),s.set(t,i+=4),this._requests[o]={cb:e};let a=Ye(this,s);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),i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Ie.STAT;let o=this._writeReqid=this._writeReqid+1&st;Q(s,o,5),Q(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let a=Ye(this,s);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),i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Ie.LSTAT;let o=this._writeReqid=this._writeReqid+1&st;Q(s,o,5),Q(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let a=Ye(this,s);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),i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Ie.OPENDIR;let o=this._writeReqid=this._writeReqid+1&st;Q(s,o,5),Q(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:e};let a=Ye(this,s);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 i=0,s=0;typeof e=="object"&&e!==null?(e=Jr(e),i=e.flags,s=e.nb):typeof e=="function"&&(r=e);let o=Buffer.byteLength(t),a=9,f=Buffer.allocUnsafe(13+o+4+s);Q(f,f.length-4,0),f[4]=Ie.SETSTAT;let c=this._writeReqid=this._writeReqid+1&st;Q(f,c,5),Q(f,o,a),f.utf8Write(t,a+=4,o),Q(f,i,a+=o),s&&(a+=4,s===Be.length?f.set(Be,a):Dr(Be,f,0,s,a),a+=s),this._requests[c]={cb:r};let l=Ye(this,f);this._debug&&this._debug(`SFTP: Outbound: ${l?"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 i=0,s=0;typeof e=="object"&&e!==null?(e=Jr(e),i=e.flags,s=e.nb):typeof e=="function"&&(r=e);let o=t.length,a=9,f=Buffer.allocUnsafe(13+o+4+s);Q(f,f.length-4,0),f[4]=Ie.FSETSTAT;let c=this._writeReqid=this._writeReqid+1&st;Q(f,c,5),Q(f,o,a),f.set(t,a+=4),Q(f,i,a+=o),s&&(a+=4,s===Be.length?f.set(Be,a):Dr(Be,f,0,s,a),a+=s),this._requests[c]={cb:r};let l=Ye(this,f);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} FSETSTAT`)}futimes(t,e,r,i){return this.fsetstat(t,{atime:Cn(e),mtime:Cn(r)},i)}utimes(t,e,r,i){return this.setstat(t,{atime:Cn(e),mtime:Cn(r)},i)}fchown(t,e,r,i){return this.fsetstat(t,{uid:e,gid:r},i)}chown(t,e,r,i){return this.setstat(t,{uid:e,gid:r},i)}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),i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Ie.READLINK;let o=this._writeReqid=this._writeReqid+1&st;Q(s,o,5),Q(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:(f,c)=>{if(typeof e=="function"){if(f)return e(f);if(!c||!c.length)return e(new Error("Response missing link info"));e(void 0,c[0].filename)}}};let a=Ye(this,s);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 i=Buffer.byteLength(e),s=Buffer.byteLength(t),o=9,a=Buffer.allocUnsafe(13+i+4+s);Q(a,a.length-4,0),a[4]=Ie.SYMLINK;let f=this._writeReqid=this._writeReqid+1&st;Q(a,f,5),this._isOpenSSH?(Q(a,s,o),a.utf8Write(t,o+=4,s),Q(a,i,o+=s),a.utf8Write(e,o+=4,i)):(Q(a,i,o),a.utf8Write(e,o+=4,i),Q(a,s,o+=i),a.utf8Write(t,o+=4,s)),this._requests[f]={cb:r};let c=Ye(this,a);this._debug&&this._debug(`SFTP: Outbound: ${c?"Buffered":"Sending"} SYMLINK`)}realpath(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Ie.REALPATH;let o=this._writeReqid=this._writeReqid+1&st;Q(s,o,5),Q(s,r,i),s.utf8Write(t,i+=4,r),this._requests[o]={cb:(f,c)=>{if(typeof e=="function"){if(f)return e(f);if(!c||!c.length)return e(new Error("Response missing path info"));e(void 0,c[0].filename)}}};let a=Ye(this,s);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 i=this._extensions["posix-rename@openssh.com"];if(!i||i!=="1")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,f=Buffer.allocUnsafe(41+s+4+o);Q(f,f.length-4,0),f[4]=Ie.EXTENDED;let c=this._writeReqid=this._writeReqid+1&st;Q(f,c,5),Q(f,24,a),f.utf8Write("posix-rename@openssh.com",a+=4,24),Q(f,s,a+=24),f.utf8Write(t,a+=4,s),Q(f,o,a+=s),f.utf8Write(e,a+=4,o),this._requests[c]={cb:r};let l=Ye(this,f);if(this._debug){let h=l?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} 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 i=Buffer.byteLength(t),s=9,o=Buffer.allocUnsafe(36+i);Q(o,o.length-4,0),o[4]=Ie.EXTENDED;let a=this._writeReqid=this._writeReqid+1&st;Q(o,a,5),Q(o,19,s),o.utf8Write("statvfs@openssh.com",s+=4,19),Q(o,i,s+=19),o.utf8Write(t,s+=4,i),this._requests[a]={extended:"statvfs@openssh.com",cb:e};let f=Ye(this,o);if(this._debug){let c=f?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${c} 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 i=t.length,s=9,o=Buffer.allocUnsafe(37+i);Q(o,o.length-4,0),o[4]=Ie.EXTENDED;let a=this._writeReqid=this._writeReqid+1&st;Q(o,a,5),Q(o,20,s),o.utf8Write("fstatvfs@openssh.com",s+=4,20),Q(o,i,s+=20),o.set(t,s+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:e};let f=Ye(this,o);if(this._debug){let c=f?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${c} 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 s=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,f=Buffer.allocUnsafe(37+s+4+o);Q(f,f.length-4,0),f[4]=Ie.EXTENDED;let c=this._writeReqid=this._writeReqid+1&st;Q(f,c,5),Q(f,20,a),f.utf8Write("hardlink@openssh.com",a+=4,20),Q(f,s,a+=20),f.utf8Write(t,a+=4,s),Q(f,o,a+=s),f.utf8Write(e,a+=4,o),this._requests[c]={cb:r};let l=Ye(this,f);if(this._debug){let h=l?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} 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 i=t.length,s=9,o=Buffer.allocUnsafe(34+i);Q(o,o.length-4,0),o[4]=Ie.EXTENDED;let a=this._writeReqid=this._writeReqid+1&st;Q(o,a,5),Q(o,17,s),o.utf8Write("fsync@openssh.com",s+=4,17),Q(o,i,s+=17),o.set(t,s+=4),this._requests[a]={cb:e};let f=Ye(this,o);this._debug&&this._debug(`SFTP: Outbound: ${f?"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 s=0,o=0;typeof e=="object"&&e!==null?(e=Jr(e),s=e.flags,o=e.nb):typeof e=="function"&&(r=e);let a=Buffer.byteLength(t),f=9,c=Buffer.allocUnsafe(37+a+4+o);Q(c,c.length-4,0),c[4]=Ie.EXTENDED;let l=this._writeReqid=this._writeReqid+1&st;Q(c,l,5),Q(c,20,f),c.utf8Write("lsetstat@openssh.com",f+=4,20),Q(c,a,f+=20),c.utf8Write(t,f+=4,a),Q(c,s,f+=a),o&&(f+=4,o===Be.length?c.set(Be,f):Dr(Be,c,0,o,f),f+=o),this._requests[l]={cb:r};let h=Ye(this,c);if(this._debug){let g=h?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${g} 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 i=Buffer.byteLength(t),s=9,o=Buffer.allocUnsafe(40+i);Q(o,o.length-4,0),o[4]=Ie.EXTENDED;let a=this._writeReqid=this._writeReqid+1&st;Q(o,a,5),Q(o,23,s),o.utf8Write("expand-path@openssh.com",s+=4,23),Q(o,i,s+=20),o.utf8Write(t,s+=4,i),this._requests[a]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing expanded path"));e(void 0,l[0].filename)}}};let f=Ye(this,o);if(this._debug){let c=f?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${c} expand-path@openssh.com`)}}ext_copy_data(t,e,r,i,s,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(i))throw new Error("Destination handle is not a Buffer");let f=0,c=Buffer.allocUnsafe(26+t.length+8+8+4+i.length+8);Q(c,c.length-4,f),f+=4,c[f]=Ie.EXTENDED,++f;let l=this._writeReqid=this._writeReqid+1&st;Q(c,l,f),f+=4,Q(c,9,f),f+=4,c.utf8Write("copy-data",f,9),f+=9,Q(c,t.length,f),f+=4,c.set(t,f),f+=t.length;for(let g=7;g>=0;--g)c[f+g]=e&255,e/=256;f+=8;for(let g=7;g>=0;--g)c[f+g]=r&255,r/=256;f+=8,Q(c,i.length,f),f+=4,c.set(i,f),f+=i.length;for(let g=7;g>=0;--g)c[f+g]=s&255,s/=256;this._requests[l]={cb:o};let h=Ye(this,c);if(this._debug){let g=h?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${g} 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 i=0,s=Buffer.byteLength(t),o=Buffer.allocUnsafe(31+s);Q(o,o.length-4,i),i+=4,o[i]=Ie.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&st;Q(o,a,i),i+=4,Q(o,14,i),i+=4,o.utf8Write("home-directory",i,14),i+=14,Q(o,s,i),i+=4,o.utf8Write(t,i,s),i+=s,this._requests[a]={cb:(c,l)=>{if(typeof e=="function"){if(c)return e(c);if(!l||!l.length)return e(new Error("Response missing home directory"));e(void 0,l[0].filename)}}};let f=Ye(this,o);if(this._debug){let c=f?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${c} 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 c of t)if(!Number.isInteger(c)||c<0||c>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 c of e)if(!Number.isInteger(c)||c<0||c>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let s=0,o=Buffer.allocUnsafe(47+4*t.length+4+4*e.length);Q(o,o.length-4,s),s+=4,o[s]=Ie.EXTENDED,++s;let a=this._writeReqid=this._writeReqid+1&st;Q(o,a,s),s+=4,Q(o,30,s),s+=4,o.utf8Write("users-groups-by-id@openssh.com",s,30),s+=30,Q(o,4*t.length,s),s+=4;for(let c of t)Q(o,c,s),s+=4;Q(o,4*e.length,s),s+=4;for(let c of e)Q(o,c,s),s+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:r};let f=Ye(this,o);if(this._debug){let c=f?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${c} 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 i=9,s=Buffer.allocUnsafe(13+r);Q(s,s.length-4,0),s[4]=Yt.HANDLE,Q(s,t,5),Q(s,r,i),r&&s.set(e,i+=4);let o=Ye(this,s);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(!o0.has(e))throw new Error(`Bad status code: ${e}`);r||(r="");let i=Buffer.byteLength(r),s=9,o=Buffer.allocUnsafe(17+i+4);Q(o,o.length-4,0),o[4]=Yt.STATUS,Q(o,t,5),Q(o,e,s),Q(o,i,s+=4),s+=4,i&&(o.utf8Write(r,s,i),s+=i),Q(o,0,s);let a=Ye(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 i=Buffer.isBuffer(e);if(!i&&typeof e!="string")throw new Error("data is not a Buffer or string");let s;!i&&!r&&(r=void 0,s=!0);let o=i?e.length:Buffer.byteLength(e,r),a=9,f=Buffer.allocUnsafe(13+o);Q(f,f.length-4,0),f[4]=Yt.DATA,Q(f,t,5),Q(f,o,a),o&&(i?f.set(e,a+=4):s?f.utf8Write(e,a+=4,o):f.write(e,a+=4,o,r));let c=Ye(this,f);this._debug&&this._debug(`SFTP: Outbound: ${c?"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,i=0,s,o=[];for(let l=0;l<r;++l){let h=e[l],g=!h||!h.filename||typeof h.filename!="string"?"":h.filename;i+=4+Buffer.byteLength(g);let p=!h||!h.longname||typeof h.longname!="string"?"":h.longname;if(i+=4+Buffer.byteLength(p),typeof h.attrs=="object"&&h.attrs!==null){if(s=Jr(h.attrs),i+=4+s.nb,s.nb){let _;s.nb===Be.length?_=new Uint8Array(Be):(_=new Uint8Array(s.nb),Dr(Be,_,0,s.nb,0)),s.bytes=_}o.push(s)}else i+=4,o.push(null)}let a=9,f=Buffer.allocUnsafe(13+i);Q(f,f.length-4,0),f[4]=Yt.NAME,Q(f,t,5),Q(f,r,a),a+=4;for(let l=0;l<r;++l){let h=e[l];{let p=!h||!h.filename||typeof h.filename!="string"?"":h.filename,_=Buffer.byteLength(p);Q(f,_,a),a+=4,_&&(f.utf8Write(p,a,_),a+=_)}{let p=!h||!h.longname||typeof h.longname!="string"?"":h.longname,_=Buffer.byteLength(p);Q(f,_,a),a+=4,_&&(f.utf8Write(p,a,_),a+=_)}let g=o[l];g?(Q(f,g.flags,a),a+=4,g.flags&&g.bytes&&(f.set(g.bytes,a),a+=g.nb)):(Q(f,0,a),a+=4)}let c=Ye(this,f);this._debug&&this._debug(`SFTP: Outbound: ${c?"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=Jr(e);let r=e.flags,i=e.nb,s=9,o=Buffer.allocUnsafe(13+i);Q(o,o.length-4,0),o[4]=Yt.ATTRS,Q(o,t,5),Q(o,r,s),i&&(s+=4,i===Be.length?o.set(Be,s):Dr(Be,o,0,i,s),s+=i);let a=Ye(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function h0(n){try{return Buffer.allocUnsafe(n)}catch(t){return t}}function sl(n,t,e,r,i,s,o,a){let f=n._maxReadLen,c=Math.max(i-f,0);c&&(i=f);let l=t.length,h=9,g=s,p=Buffer.allocUnsafe(13+l+8+4);Q(p,p.length-4,0),p[4]=Ie.READ;let _=n._writeReqid=n._writeReqid+1&st;Q(p,_,5),Q(p,l,h),p.set(t,h+=4),h+=l;for(let P=7;P>=0;--P)p[h+P]=g&255,g/=256;Q(p,i,h+=8),typeof o!="function"&&(o=il);let b=a||{nb:0,position:s,off:r,origOff:r,len:void 0,overflow:void 0,cb:(P,L,ee)=>{let H=b.len,z=b.overflow;if(P){if(o._wantEOFError||P.code!==Xe.EOF)return o(P)}else{if(ee>H)return o(new Error("Received more data than requested"));if(ee===H&&z){b.nb+=ee,b.position+=ee,b.off+=ee,sl(n,t,e,b.off,z,b.position,o,b);return}}ee=ee||0,b.origOff===0&&e.length===b.nb?L=e:L=kn(e,b.origOff,b.origOff+b.nb+ee),o(void 0,b.nb+ee,L,b.position)},buffer:void 0};b.len=i,b.overflow=c,b.buffer=kn(e,r,r+i),n._requests[_]=b;let R=Ye(n,p);n._debug&&n._debug(`SFTP: Outbound: ${R?"Buffered":"Sending"} READ`)}function Ju(n,t,e,r,i,s){let o=64,a=32768,f,c,l;typeof i=="function"?s=i:typeof i=="object"&&i!==null&&(typeof i.concurrency=="number"&&i.concurrency>0&&!isNaN(i.concurrency)&&(o=i.concurrency),typeof i.chunkSize=="number"&&i.chunkSize>0&&!isNaN(i.chunkSize)&&(a=i.chunkSize),typeof i.fileSize=="number"&&i.fileSize>0&&!isNaN(i.fileSize)&&(l=i.fileSize),typeof i.step=="function"&&(f=i.step),(typeof i.mode=="string"||typeof i.mode=="number")&&(c=ra(i.mode)));let h,g=0,p=0,_=!1,b,R,P,L=a*o;function ee(H){if(_)return;_=!0;let z=0,J;b||R?(J=()=>{--z===0&&s(H)},b&&(n===Hr||n.outgoing.state==="open")&&++z,R&&(t===Hr||t.outgoing.state==="open")&&++z,b&&(n===Hr||n.outgoing.state==="open")&&n.close(b,J),R&&(t===Hr||t.outgoing.state==="open")&&t.close(R,J)):s(H)}n.open(e,"r",(H,z)=>{if(H)return ee(H);b=z,l===void 0?n.fstat(b,J):J(null,{size:l});function J(V,y){if(V){if(n!==Hr){n.stat(e,(w,U)=>{if(w)return ee(V);J(null,U)});return}return ee(V)}h=y.size,t.open(r,"w",(w,U)=>{if(w)return ee(w);if(R=U,h<=0)return ee();for(;L>h;){if(o===1){L=h;break}L-=a,--o}if(P=h0(L),P instanceof Error)return ee(P);c!==void 0?t.fchmod(R,c,function j(te){if(te){t.chmod(r,c,oe=>j());return}Z()}):Z();function $(j,te,oe,S,k,v){if(j)return ee(j);k=k||0,t.write(R,P,k,te,S,O);function O(ie){if(ie)return ee(ie);if(p+=te,f&&f(p,te,h),te<v)return se(k,S+te,v-te);if(p===h){t.close(R,fe=>{if(R=void 0,fe)return ee(fe);n.close(b,tt=>{if(b=void 0,tt)return ee(tt);s()})});return}if(g>=h)return;let X=g+a>h?h-g:a;se(k,g,X),g+=X}}function M(j,te,oe){return(S,k,v)=>{$(S,k,v,te,j,oe)}}function se(j,te,oe){n.read(b,P,j,oe,te,M(j,te,oe))}function Z(){let j=0,te=0;for(;g<h&&j<o;){let oe=g+a>h?h-g:a;se(te,g,oe),te+=oe,g+=oe,++j}}})}})}function zo(n,t,e,r,i,s,o){let a=typeof o=="function"?o:void 0;n.write(t,e,r,i,s,(f,c)=>{if(f)return n.close(t,()=>{a&&a(f)});c===i?n.close(t,a):(r+=c,i-=c,s+=c,zo(n,t,e,r,i,s,a))})}var hs=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&Gt.S_IFMT)===Gt.S_IFDIR}isFile(){return(this.mode&Gt.S_IFMT)===Gt.S_IFREG}isBlockDevice(){return(this.mode&Gt.S_IFMT)===Gt.S_IFBLK}isCharacterDevice(){return(this.mode&Gt.S_IFMT)===Gt.S_IFCHR}isSymbolicLink(){return(this.mode&Gt.S_IFMT)===Gt.S_IFLNK}isFIFO(){return(this.mode&Gt.S_IFMT)===Gt.S_IFIFO}isSocket(){return(this.mode&Gt.S_IFMT)===Gt.S_IFSOCK}};function Jr(n){let t=0,e=0;if(typeof n=="object"&&n!==null){if(typeof n.size=="number"){t|=Ir.SIZE;let r=n.size;Be[e++]=r/72057594037927940,Be[e++]=r/281474976710656,Be[e++]=r/1099511627776,Be[e++]=r/4294967296,Be[e++]=r/16777216,Be[e++]=r/65536,Be[e++]=r/256,Be[e++]=r}if(typeof n.uid=="number"&&typeof n.gid=="number"){t|=Ir.UIDGID;let r=n.uid,i=n.gid;Be[e++]=r>>>24,Be[e++]=r>>>16,Be[e++]=r>>>8,Be[e++]=r,Be[e++]=i>>>24,Be[e++]=i>>>16,Be[e++]=i>>>8,Be[e++]=i}if(typeof n.mode=="number"||typeof n.mode=="string"){let r=ra(n.mode);t|=Ir.PERMISSIONS,Be[e++]=r>>>24,Be[e++]=r>>>16,Be[e++]=r>>>8,Be[e++]=r}if((typeof n.atime=="number"||jo(n.atime))&&(typeof n.mtime=="number"||jo(n.mtime))){let r=Cn(n.atime),i=Cn(n.mtime);t|=Ir.ACMODTIME,Be[e++]=r>>>24,Be[e++]=r>>>16,Be[e++]=r>>>8,Be[e++]=r,Be[e++]=i>>>24,Be[e++]=i>>>16,Be[e++]=i>>>8,Be[e++]=i}}return{flags:t,nb:e}}function Cn(n){if(typeof n=="number"&&n===n)return n;if(jo(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 Jo={r:Se.READ,"r+":Se.READ|Se.WRITE,w:Se.TRUNC|Se.CREAT|Se.WRITE,wx:Se.TRUNC|Se.CREAT|Se.WRITE|Se.EXCL,xw:Se.TRUNC|Se.CREAT|Se.WRITE|Se.EXCL,"w+":Se.TRUNC|Se.CREAT|Se.READ|Se.WRITE,"wx+":Se.TRUNC|Se.CREAT|Se.READ|Se.WRITE|Se.EXCL,"xw+":Se.TRUNC|Se.CREAT|Se.READ|Se.WRITE|Se.EXCL,a:Se.APPEND|Se.CREAT|Se.WRITE,ax:Se.APPEND|Se.CREAT|Se.WRITE|Se.EXCL,xa:Se.APPEND|Se.CREAT|Se.WRITE|Se.EXCL,"a+":Se.APPEND|Se.CREAT|Se.READ|Se.WRITE,"ax+":Se.APPEND|Se.CREAT|Se.READ|Se.WRITE|Se.EXCL,"xa+":Se.APPEND|Se.CREAT|Se.READ|Se.WRITE|Se.EXCL};function ol(n){let t=Jo[n];return t!==void 0?t:null}var d0=(()=>{let n=Object.keys(Jo);return t=>{for(let e=0;e<n.length;++e){let r=n[e];if(Jo[r]===t)return r}return null}})();function Bn(n){let t=N.readUInt32BE();if(t===void 0)return;let e=new hs;if(t&Ir.SIZE){let r=N.readUInt64BE(n);if(r===void 0)return;e.size=r}if(t&Ir.UIDGID){let r=N.readUInt32BE(),i=N.readUInt32BE();if(i===void 0)return;e.uid=r,e.gid=i}if(t&Ir.PERMISSIONS){let r=N.readUInt32BE();if(r===void 0)return;e.mode=r}if(t&Ir.ACMODTIME){let r=N.readUInt32BE(),i=N.readUInt32BE();if(i===void 0)return;e.atime=r,e.mtime=i}if(t&Ir.EXTENDED){let r=N.readUInt32BE();if(r===void 0)return;let i={};for(let s=0;s<r;++s){let o=N.readString(!0),a=N.readString();if(a===void 0)return;i[o]=a}e.extended=i}return e}function Ye(n,t){let e=al(n,t);return e!==void 0?(n._buffer.push(e),!1):!0}function al(n,t){let e=n.outgoing;if(e.state!=="open")return;if(e.window===0)return n._waitWindow=!0,n._chunkcb=Zu,t;let r,i=t.length,s=0;for(;i-s>0&&e.window>0;){let o=Math.min(i-s,e.window,e.packetSize);e.window-=o,e.window===0&&(n._waitWindow=!0,n._chunkcb=Zu),s===0&&o===i?n._protocol.channelData(n.outgoing.id,t):n._protocol.channelData(n.outgoing.id,kn(t,s,s+o)),s+=o}return i-s>0&&(s>0?r=kn(t,s,i):r=t),r}function Zu(){this._chunkcb=void 0;let n=this._buffer,t=0;for(;t<n.length;){let e=n[t],r=al(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 et(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(),fl(n),!1}function fl(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 i=0;i<t.length;++i){let s=e[t[i]];typeof s.cb=="function"&&s.cb(r)}}function g0(n,t){let e=9,r=Buffer.allocUnsafe(31);Q(r,r.length-4,0),r[4]=Ie.EXTENDED;let i=n._writeReqid=n._writeReqid+1&st;Q(r,i,5),Q(r,18,e),r.utf8Write("limits@openssh.com",e+=4,18),n._requests[i]={extended:"limits@openssh.com",cb:t};let s=Ye(n,r);if(n._debug){let o=s?"Buffered":"Sending";n._debug(`SFTP: Outbound: ${o} limits@openssh.com`)}}var p0={[Yt.VERSION]:(n,t)=>{if(n._version!==-1)return et(n,"Duplicate VERSION packet");let e={};N.init(t,1);let r=N.readUInt32BE();for(;N.avail();){let i=N.readString(!0),s=N.readString(!0);if(s===void 0){r=void 0;break}e[i]=s}if(N.clear(),r===void 0)return et(n,"Malformed VERSION packet");if(n._debug){let i=Object.keys(e);i.length?n._debug(`SFTP: Inbound: Received VERSION (v${r}, exts:${i})`):n._debug(`SFTP: Inbound: Received VERSION (v${r})`)}if(n._version=r,n._extensions=e,e["limits@openssh.com"]==="1")return g0(n,(i,s)=>{i||(s.maxPktLen>0&&(n._maxOutPktLen=s.maxPktLen),s.maxReadLen>0&&(n._maxReadLen=s.maxReadLen),s.maxWriteLen>0&&(n._maxWriteLen=s.maxWriteLen),n.maxOpenHandles=s.maxOpenHandles>0?s.maxOpenHandles:1/0),n.emit("ready")});n.emit("ready")},[Yt.STATUS]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readUInt32BE(),i=N.readString(!0);if(N.clear(),n._debug){let o=JSON.stringify(i);n._debug(`SFTP: Inbound: Received STATUS (id:${e}, ${r}, ${o})`)}let s=n._requests[e];if(delete n._requests[e],s&&typeof s.cb=="function"){if(r===Xe.OK){s.cb();return}let o=new Error(i||a0[r]||"Unknown status");o.code=r,s.cb(o)}},[Yt.HANDLE]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString();if(N.clear(),r===void 0)return e!==void 0&&delete n._requests[e],et(n,"Malformed HANDLE packet");n._debug&&n._debug(`SFTP: Inbound: Received HANDLE (id:${e})`);let i=n._requests[e];delete n._requests[e],i&&typeof i.cb=="function"&&i.cb(void 0,r)},[Yt.DATA]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r;if(e!==void 0&&(r=n._requests[e],delete n._requests[e]),r&&typeof r.cb=="function")if(r.buffer){let i=N.readString(r.buffer);if(N.clear(),i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${i})`),r.cb(void 0,r.buffer,i);return}}else{let i=N.readString();if(N.clear(),i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${i.length})`),r.cb(void 0,i);return}}else{let i=N.skipString();if(N.clear(),i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${i})`);return}}return et(n,"Malformed DATA packet")},[Yt.NAME]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let i=N.readUInt32BE();if(i!==void 0){let s=[];for(let o=0;o<i;++o){let a=N.readString(!0),f=N.readString(!0),c=Bn(n._biOpt);if(c===void 0){s=void 0;break}s.push({filename:a,longname:f,attrs:c})}if(s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received NAME (id:${e}, ${s.length})`),N.clear(),r&&typeof r.cb=="function"&&r.cb(void 0,s);return}}return N.clear(),et(n,"Malformed NAME packet")},[Yt.ATTRS]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let i=Bn(n._biOpt);if(N.clear(),i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received ATTRS (id:${e})`),r&&typeof r.cb=="function"&&r.cb(void 0,i);return}return et(n,"Malformed ATTRS packet")},[Yt.EXTENDED]:(n,t)=>{N.init(t,1);let e=N.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 i=n._biOpt,s={f_bsize:N.readUInt64BE(i),f_frsize:N.readUInt64BE(i),f_blocks:N.readUInt64BE(i),f_bfree:N.readUInt64BE(i),f_bavail:N.readUInt64BE(i),f_files:N.readUInt64BE(i),f_ffree:N.readUInt64BE(i),f_favail:N.readUInt64BE(i),f_sid:N.readUInt64BE(i),f_flag:N.readUInt64BE(i),f_namemax:N.readUInt64BE(i)};if(s.f_namemax===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),N.clear(),typeof r.cb=="function"&&r.cb(void 0,s);return}case"limits@openssh.com":{let i={maxPktLen:N.readUInt64BE(),maxReadLen:N.readUInt64BE(),maxWriteLen:N.readUInt64BE(),maxOpenHandles:N.readUInt64BE()};if(i.maxOpenHandles===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),N.clear(),typeof r.cb=="function"&&r.cb(void 0,i);return}case"users-groups-by-id@openssh.com":{let i=N.readUInt32BE();if(i===void 0)break;let s=new Array(i);for(let f=0;f<s.length;++f)s[f]=N.readString(!0);let o=N.readUInt32BE();if(o===void 0)break;let a=new Array(o);for(let f=0;f<a.length;++f)a[f]=N.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})`),N.clear(),typeof r.cb=="function"&&r.cb(void 0,s,a);return}default:n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),N.clear(),typeof r.cb=="function"&&r.cb();return}else{n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),N.clear();return}}return N.clear(),et(n,"Malformed EXTENDED_REPLY packet")}},A0={[Ie.INIT]:(n,t)=>{if(n._version!==-1)return et(n,"Duplicate INIT packet");let e={};N.init(t,1);let r=N.readUInt32BE();for(;N.avail();){let i=N.readString(!0),s=N.readString(!0);if(s===void 0){r=void 0;break}e[i]=s}if(N.clear(),r===void 0)return et(n,"Malformed INIT packet");if(n._debug){let i=Object.keys(e);i.length?n._debug(`SFTP: Inbound: Received INIT (v${r}, exts:${i})`):n._debug(`SFTP: Inbound: Received INIT (v${r})`)}Ye(n,c0),n._version=r,n._extensions=e,n.emit("ready")},[Ie.OPEN]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0),i=N.readUInt32BE(),s=Bn(n._biOpt);if(N.clear(),s===void 0)return et(n,"Malformed OPEN packet");n._debug&&n._debug(`SFTP: Inbound: Received OPEN (id:${e})`),n.emit("OPEN",e,r,i,s)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.CLOSE]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString();if(N.clear(),r===void 0||r.length>256)return et(n,"Malformed CLOSE packet");n._debug&&n._debug(`SFTP: Inbound: Received CLOSE (id:${e})`),n.emit("CLOSE",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.READ]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(),i=N.readUInt64BE(n._biOpt),s=N.readUInt32BE();if(N.clear(),s===void 0||r.length>256)return et(n,"Malformed READ packet");n._debug&&n._debug(`SFTP: Inbound: Received READ (id:${e})`),n.emit("READ",e,r,i,s)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.WRITE]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(),i=N.readUInt64BE(n._biOpt),s=N.readString();if(N.clear(),s===void 0||r.length>256)return et(n,"Malformed WRITE packet");n._debug&&n._debug(`SFTP: Inbound: Received WRITE (id:${e})`),n.emit("WRITE",e,r,i,s)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.LSTAT]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0);if(N.clear(),r===void 0)return et(n,"Malformed LSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received LSTAT (id:${e})`),n.emit("LSTAT",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.FSTAT]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString();if(N.clear(),r===void 0||r.length>256)return et(n,"Malformed FSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSTAT (id:${e})`),n.emit("FSTAT",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.SETSTAT]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0),i=Bn(n._biOpt);if(N.clear(),i===void 0)return et(n,"Malformed SETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received SETSTAT (id:${e})`),n.emit("SETSTAT",e,r,i)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.FSETSTAT]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(),i=Bn(n._biOpt);if(N.clear(),i===void 0||r.length>256)return et(n,"Malformed FSETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSETSTAT (id:${e})`),n.emit("FSETSTAT",e,r,i)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.OPENDIR]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0);if(N.clear(),r===void 0)return et(n,"Malformed OPENDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received OPENDIR (id:${e})`),n.emit("OPENDIR",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.READDIR]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString();if(N.clear(),r===void 0||r.length>256)return et(n,"Malformed READDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received READDIR (id:${e})`),n.emit("READDIR",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.REMOVE]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0);if(N.clear(),r===void 0)return et(n,"Malformed REMOVE packet");n._debug&&n._debug(`SFTP: Inbound: Received REMOVE (id:${e})`),n.emit("REMOVE",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.MKDIR]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0),i=Bn(n._biOpt);if(N.clear(),i===void 0)return et(n,"Malformed MKDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received MKDIR (id:${e})`),n.emit("MKDIR",e,r,i)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.RMDIR]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0);if(N.clear(),r===void 0)return et(n,"Malformed RMDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received RMDIR (id:${e})`),n.emit("RMDIR",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.REALPATH]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0);if(N.clear(),r===void 0)return et(n,"Malformed REALPATH packet");n._debug&&n._debug(`SFTP: Inbound: Received REALPATH (id:${e})`),n.emit("REALPATH",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.STAT]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0);if(N.clear(),r===void 0)return et(n,"Malformed STAT packet");n._debug&&n._debug(`SFTP: Inbound: Received STAT (id:${e})`),n.emit("STAT",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.RENAME]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0),i=N.readString(!0);if(N.clear(),i===void 0)return et(n,"Malformed RENAME packet");n._debug&&n._debug(`SFTP: Inbound: Received RENAME (id:${e})`),n.emit("RENAME",e,r,i)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.READLINK]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0);if(N.clear(),r===void 0)return et(n,"Malformed READLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received READLINK (id:${e})`),n.emit("READLINK",e,r)||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.SYMLINK]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0),i=N.readString(!0);if(N.clear(),i===void 0)return et(n,"Malformed SYMLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received SYMLINK (id:${e})`);let s;n._isOpenSSH?s=n.emit("SYMLINK",e,i,r):s=n.emit("SYMLINK",e,r,i),s||n.status(e,Xe.OP_UNSUPPORTED)},[Ie.EXTENDED]:(n,t)=>{N.init(t,1);let e=N.readUInt32BE(),r=N.readString(!0);if(r===void 0)return N.clear(),et(n,"Malformed EXTENDED packet");let i;N.avail()&&(i=N.readRaw()),N.clear(),n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED (id:${e})`),n.emit("EXTENDED",e,r,i)||n.status(e,Xe.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:E0,ERR_OUT_OF_RANGE:ls,validateNumber:m0}=Xu(),el=128,$t,Zo=[];function _0(n){Zo.length>0?$t=Zo.pop():$t=Buffer.allocUnsafe(n),$t.used=0}function ea(n,t){if(!Number.isSafeInteger(n))throw m0(n,t),Number.isInteger(n)?new ls(t,">= 0 and <= 2 ** 53 - 1",n):new ls(t,"an integer",n);if(n<0)throw new ls(t,">= 0 and <= 2 ** 53 - 1",n)}function Vo(n){return n+7&-8}function Cr(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,rl.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&&(ea(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(ea(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new ls("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}nl(Cr,rl);Cr.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()}))};Cr.prototype._read=function(n){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(n));if(this.destroyed)return;(!$t||$t.length-$t.used<el)&&_0(this.readableHighWaterMark||this._readableState.highWaterMark);let t=$t,e=Math.min($t.length-$t.used,n),r=$t.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,$t,$t.used,e,this.pos,(i,s)=>{if(i){this.emit("error",i),this.autoClose&&this.destroy();return}let o=null;if(r+e===t.used&&t===$t)t.used=Vo(t.used+s-e);else{let a=r+e&-8,f=Vo(r+s);a-f>=el&&Zo.push(t.slice(f,a))}s>0&&(this.bytesRead+=s,o=t.slice(r,r+s)),this.pos+=s,this.push(o)}),$t.used=Vo($t.used+e)};Cr.prototype._destroy=function(n,t){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",tl.bind(null,this,t,n));return}tl(this,t,n),this.handle=null,this._opening=!1};function tl(n,t,e){if(!n.handle)return r();n.sftp.close(n.handle,r);function r(i){i=i||e,t(i),n.isClosed=!0,i||n.emit("close")}}Cr.prototype.close=function(n){this.destroy(null,n)};Object.defineProperty(Cr.prototype,"pending",{get(){return this.handle===null},configurable:!0});function sr(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,ta.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&&(ea(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()}nl(sr,ta);sr.prototype._final=function(n){this.autoClose&&this.destroy(),n()};sr.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,i=>e());return}if(this.flags[0]==="a"){let i=(s,o)=>{if(s){this.sftp.stat(this.path,(a,f)=>{if(a){this.destroy(),this.emit("error",s);return}i(null,f)});return}this.pos=o.size,this.emit("open",t),this.emit("ready")};this.sftp.fstat(t,i);return}this.emit("open",t),this.emit("ready")};this.sftp.fchmod(t,this.mode,e)}))};sr.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,i)=>{if(r)return this.autoClose&&this.destroy(),e(r);this.bytesWritten+=i,e()}),this.pos+=n.length};sr.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,i=n.length,s=(o,a)=>{if(o)return this.destroy(),t(o);this.bytesWritten+=a,--i===0&&t()};for(let o=0;o<n.length;++o){let a=n[o].chunk;e.write(r,a,0,a.length,this.pos,s),this.pos+=a.length}};typeof ta.prototype.destroy!="function"&&(sr.prototype.destroy=Cr.prototype.destroy);sr.prototype._destroy=Cr.prototype._destroy;sr.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()};sr.prototype.destroySoon=sr.prototype.end;Object.defineProperty(sr.prototype,"pending",{get(){return this.handle===null},configurable:!0});cl.exports={flagsToString:d0,OPEN_MODE:Se,SFTP:Xo,Stats:hs,STATUS_CODE:Xe,stringToFlags:ol}});var fa=nt((Tm,dl)=>{"use strict";var{Duplex:b0,Readable:x0,Writable:S0}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:ul}}=Sr(),{bufferSlice:ds}=or(),y0=32*1024,li=2*1024*1024,oa=li/2,na=class extends x0{constructor(t,e){super(e),this._channel=t}_read(t){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=oa&&aa(this._channel))}},ia=class extends S0{constructor(t){super({highWaterMark:li}),this._channel=t}_write(t,e,r){let i=this._channel,s=i._client._protocol,o=i.outgoing,a=o.packetSize,f=o.id,c=o.window,l=t.length,h=0;if(o.state==="open"){for(;l-h>0&&c>0;){let g=l-h;g>c&&(g=c),g>a&&(g=a),h===0&&g===l?s.channelExtData(f,t,ul):s.channelExtData(f,ds(t,h,h+g),ul),h+=g,c-=g}if(o.window=c,l-h>0){c===0&&(i._waitWindow=!0),h>0?i._chunkErr=ds(t,h,l):i._chunkErr=t,i._chunkcbErr=r;return}r()}}},sa=class extends b0{constructor(t,e,r){let i={highWaterMark:li,allowHalfOpen:!r||r&&r.allowHalfOpen!==!1,emitClose:!1};super(i),this.allowHalfOpen=i.allowHalfOpen;let s=!!(r&&r.server);this.server=s,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,s?this.stderr=new ia(this):this.stderr=new na(this,i),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",ll).on("prefinish",ll),this.on("end",hl).on("close",hl)}_read(t){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=oa&&aa(this))}_write(t,e,r){let i=this._client._protocol,s=this.outgoing,o=s.packetSize,a=s.id,f=s.window,c=t.length,l=0;if(s.state==="open"){for(;c-l>0&&f>0;){let h=c-l;h>f&&(h=f),h>o&&(h=o),l===0&&h===c?i.channelData(a,t):i.channelData(a,ds(t,l,l+h)),l+=h,f-=h}if(s.window=f,c-l>0){f===0&&(this._waitWindow=!0),l>0?this._chunk=ds(t,l,c):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,i){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,i)}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 ll(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}function hl(){this.readable=!1}function aa(n){if(n.outgoing.state==="closed")return;let t=li-n.incoming.window;t<=0||(n.incoming.window+=t,n._client._protocol.channelWindowAdjust(n.outgoing.id,t))}dl.exports={Channel:sa,MAX_WINDOW:li,PACKET_SIZE:y0,windowAdjust:aa,WINDOW_THRESHOLD:oa}});var la=nt((Lm,Al)=>{"use strict";var{SFTP:w0}=ui(),hi=2**32-1;function gl(n,t,e,r){if(n._chanMgr.remove(t),typeof r!="function")return;let i;e instanceof Error?i=e:typeof e=="object"&&e!==null?(i=new Error(`(SSH) Channel open failure: ${e.description}`),i.reason=e.reason):(i=new Error("(SSH) Channel open failure: server closed channel unexpectedly"),i.reason=""),r(i)}function pl(n,t,e,r,i){if(typeof e=="function"){gl(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!==w0&&(e.outgoing.state==="open"||e.outgoing.state==="eof")&&!i&&e.close(),e.outgoing.state==="closing"&&(e.outgoing.state="closed");let s=e._readableState,o=e._writableState;o&&!o.ending&&!o.finished&&!i&&e.end();let a=e._callbacks;e._callbacks=[];for(let f=0;f<a.length;++f)a[f](!0);if(e.server)!e.readable||e.destroyed||s&&s.endEmitted?e.emit("close"):e.once("end",()=>e.emit("close"));else{let f;switch(e.type){case"direct-streamlocal@openssh.com":case"direct-tcpip":f=()=>e.emit("close");break;default:{let l=e._exit;f=()=>{l.code===null?e.emit("close",l.code,l.signal,l.dump,l.desc):e.emit("close",l.code)}}}!e.readable||e.destroyed||s&&s.endEmitted?f():e.once("end",f);let c=e.stderr._readableState;!e.stderr.readable||e.stderr.destroyed||c&&c.endEmitted?e.stderr.emit("close"):e.stderr.once("end",()=>e.stderr.emit("close"))}}var ua=class{constructor(t){this._client=t,this._channels={},this._cur=-1,this._count=0}add(t){let e;if(this._cur<hi)e=++this._cur;else if(this._count===0)this._cur=0,e=0;else{let r=this._channels;for(let i=0;i<hi;++i)if(r[i]===void 0){e=i;break}}return e===void 0?-1:(this._channels[e]=t||!0,++this._count,e)}update(t,e){if(typeof t!="number"||t<0||t>=hi||!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>=hi||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);return this._channels[t]}remove(t){if(typeof t!="number"||t<0||t>=hi||!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),i=this._client;for(let s=0;s<r.length;++s){let o=+r[s],a=e[o];pl(i,o,a._channel||a,t,!0)}}},ca=(()=>{let n=Object.prototype.toString;return t=>n.call(t)==="[object RegExp]"})();function I0(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),i=t;for(let s=0;s<r.length;++s){let o=r[s],a=n[o];switch(o){case"append":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let f=0;f<a.length;++f){let c=a[f];if(typeof c=="string"){if(!c||i.indexOf(c)!==-1)continue;if(e.indexOf(c)===-1)throw new Error(`Unsupported algorithm: ${c}`);i===t&&(i=i.slice()),i.push(c)}else if(ca(c))for(let l=0;l<e.length;++l){let h=e[l];if(c.test(h)){if(i.indexOf(h)!==-1)continue;i===t&&(i=i.slice()),i.push(h)}}}break;case"prepend":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let f=a.length;f>=0;--f){let c=a[f];if(typeof c=="string"){if(!c||i.indexOf(c)!==-1)continue;if(e.indexOf(c)===-1)throw new Error(`Unsupported algorithm: ${c}`);i===t&&(i=i.slice()),i.unshift(c)}else if(ca(c))for(let l=e.length;l>=0;--l){let h=e[l];if(c.test(h)){if(i.indexOf(h)!==-1)continue;i===t&&(i=i.slice()),i.unshift(h)}}}break;case"remove":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let f=0;f<a.length;++f){let c=a[f];if(typeof c=="string"){if(!c)continue;let l=i.indexOf(c);if(l===-1)continue;i===t&&(i=i.slice()),i.splice(l,1)}else if(ca(c))for(let l=0;l<i.length;++l)c.test(i[l])&&(i===t&&(i=i.slice()),i.splice(l,1),--l)}break}}return i}return t}Al.exports={ChannelManager:ua,generateAlgorithmList:I0,onChannelOpenFailure:gl,onCHANNEL_CLOSE:pl,isWritable:n=>n&&n.writable&&n._readableState&&n._readableState.ended===!1}});var ma=nt((Um,Ol)=>{"use strict";var{createHash:C0,getHashes:B0,randomFillSync:k0}=require("crypto"),{Socket:R0}=require("net"),{lookup:v0}=require("dns"),N0=require("events"),P0=B0(),{COMPAT:Tl,CHANNEL_EXTENDED_DATATYPE:{STDERR:T0},CHANNEL_OPEN_FAILURE:di,DEFAULT_CIPHER:El,DEFAULT_COMPRESSION:ml,DEFAULT_KEX:_l,DEFAULT_MAC:bl,DEFAULT_SERVER_HOST_KEY:xl,DISCONNECT_REASON:Sl,DISCONNECT_REASON_BY_VALUE:L0,SUPPORTED_CIPHER:U0,SUPPORTED_COMPRESSION:O0,SUPPORTED_KEX:D0,SUPPORTED_MAC:H0,SUPPORTED_SERVER_HOST_KEY:F0}=Sr(),{init:Q0}=Tr(),M0=Go(),{parseKey:As}=Or(),{SFTP:$0}=ui(),{bufferCopy:yl,makeBufferParser:Ll,makeError:W0,readUInt32BE:q0,sigSSHToASN1:K0,writeUInt32BE:ha}=or(),{AgentContext:wl,createAgent:Il,isAgent:Cl}=No(),{Channel:Ul,MAX_WINDOW:Es,PACKET_SIZE:ms,windowAdjust:Bl,WINDOW_THRESHOLD:kl}=fa(),{ChannelManager:G0,generateAlgorithmList:gi,isWritable:yt,onChannelOpenFailure:Y0,onCHANNEL_CLOSE:V0}=la(),gs=Ll(),ps=Ll(),pi=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,Aa=n=>{},Ea=class extends N0{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&&yt(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=gi(t.algorithms.kex,_l,D0),e.kex!==_l&&(r=!1),e.serverHostKey=gi(t.algorithms.serverHostKey,xl,F0),e.serverHostKey!==xl&&(r=!1),e.cs.cipher=gi(t.algorithms.cipher,El,U0),e.cs.cipher!==El&&(r=!1),e.cs.mac=gi(t.algorithms.hmac,bl,H0),e.cs.mac!==bl&&(r=!1),e.cs.compress=gi(t.algorithms.compress,ml,O0),e.cs.compress!==ml&&(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=Il(t.agent):Cl(t.agent)?this.config.agent=t.agent:this.config.agent=void 0,this.config.allowAgentFwd=t.agentForward===!0&&this.config.agent!==void 0;let i=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 s=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 G0(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=As(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 f;if(typeof t.hostVerifier=="function"){let S=t.hostVerifier,k;P0.indexOf(t.hostHash)!==-1&&(k=t.hostHash),f=(v,O)=>{k&&(v=C0(k).update(v).digest("hex"));let ie=S(v,O);ie!==void 0&&O(ie)}}let c=this._sock=t.sock||new R0,l=!1,h=!1;this._protocol&&this._protocol.cleanup();let g=s?(S,k,v)=>{s(`Debug output from server: ${JSON.stringify(v)}`)}:void 0,p,_=this._protocol=new M0({ident:this.config.ident,offer:r?void 0:e,onWrite:S=>{yt(c)&&c.write(S)},onError:S=>{S.level==="handshake"&&clearTimeout(this._readyTimeout),_._destruct||c.removeAllListeners("data"),this.emit("error",S);try{c.end()}catch{}},onHeader:S=>{h=!0,this._remoteVer=S.versions.software,S.greeting&&this.emit("greeting",S.greeting)},onHandshakeComplete:S=>{this.emit("handshake",S),l||(l=!0,_.service("ssh-userauth"))},debug:s,hostVerifier:f,messageHandlers:{DEBUG:g,DISCONNECT:(S,k,v)=>{if(k!==Sl.BY_APPLICATION){v||(v=L0[k],v===void 0&&(v=`Unexpected disconnection reason: ${k}`));let O=new Error(v);O.code=k,this.emit("error",O)}c.end()},SERVICE_ACCEPT:(S,k)=>{k==="ssh-userauth"&&j()},EXT_INFO:(S,k)=>{if(p===void 0){for(let v of k)if(v.name==="server-sig-algs"){p=v.algs;return}p=null}},USERAUTH_BANNER:(S,k)=>{this.emit("banner",k)},USERAUTH_SUCCESS:S=>{H(),clearTimeout(this._readyTimeout),this.emit("ready")},USERAUTH_FAILURE:(S,k,v)=>{if(y.keyAlgos){let O=y.keyAlgos[0][0];if(s&&s(`Client: ${y.type} (${O}) auth failed`),y.keyAlgos.shift(),y.keyAlgos.length){let[ie,X]=y.keyAlgos[0];switch(y.type){case"agent":_.authPK(y.username,y.agentCtx.currentKey(),ie);return;case"publickey":_.authPK(y.username,y.key,ie);return;case"hostbased":_.authHostbased(y.username,y.key,y.localHostname,y.localUsername,ie,(fe,tt)=>{let _t=y.key.sign(fe,X);if(_t instanceof Error)return _t.message=`Error while signing with key: ${_t.message}`,_t.level="client-authentication",this.emit("error",_t),j();tt(_t)});return}}else y.keyAlgos=void 0}if(y.type==="agent"){let O=y.agentCtx.pos();return s&&s(`Client: Agent key #${O+1} failed`),te()}s&&s(`Client: ${y.type} auth failed`),w=v,U=k,j()},USERAUTH_PASSWD_CHANGEREQ:(S,k)=>{y.type==="password"&&this.emit("change password",k,v=>{_.authPassword(this.config.username,this.config.password,v)})},USERAUTH_PK_OK:S=>{let k,v;if(y.keyAlgos&&([k,v]=y.keyAlgos[0]),y.type==="agent"){let O=y.agentCtx.currentKey();_.authPK(y.username,O,k,(ie,X)=>{let fe={hash:v};y.agentCtx.sign(O,ie,fe,(tt,_t)=>{if(tt)tt.level="agent",this.emit("error",tt);else return X(_t);te()})})}else y.type==="publickey"&&_.authPK(y.username,y.key,k,(O,ie)=>{let X=y.key.sign(O,v);if(X instanceof Error)return X.message=`Error signing data with key: ${X.message}`,X.level="client-authentication",this.emit("error",X),j();ie(X)})},USERAUTH_INFO_REQUEST:(S,k,v,O)=>{if(y.type==="keyboard-interactive"){if((Array.isArray(O)?O.length:0)===0){s&&s("Client: Sending automatic USERAUTH_INFO_RESPONSE"),_.authInfoRes();return}y.prompt(k,v,"",O,X=>{_.authInfoRes(X)})}},REQUEST_SUCCESS:(S,k)=>{o.length&&o.shift()(!1,k)},REQUEST_FAILURE:S=>{o.length&&o.shift()(!0)},GLOBAL_REQUEST:(S,k,v,O)=>{k==="hostkeys-00@openssh.com"?(Z0(this,O,(ie,X)=>{ie||this.emit("hostkeys",X)}),v&&_.requestSuccess()):v&&_.requestFailure()},CHANNEL_OPEN:(S,k)=>{z0(this,k)},CHANNEL_OPEN_CONFIRMATION:(S,k)=>{let v=this._chanMgr.get(k.recipient);if(typeof v!="function")return;let O=v.type==="sftp",X={type:O?"session":v.type,incoming:{id:k.recipient,window:Es,packetSize:ms,state:"open"},outgoing:{id:k.sender,window:k.window,packetSize:k.packetSize,state:"open"}},fe=O?new $0(this,X,{debug:s}):new Ul(this,X);this._chanMgr.update(k.recipient,fe),v(void 0,fe)},CHANNEL_OPEN_FAILURE:(S,k,v,O)=>{let ie=this._chanMgr.get(k);if(typeof ie!="function")return;Y0(this,k,{reason:v,description:O},ie)},CHANNEL_DATA:(S,k,v)=>{let O=this._chanMgr.get(k);if(!(typeof O!="object"||O===null)&&O.incoming.window!==0){if(O.incoming.window-=v.length,O.push(v)===!1){O._waitChanDrain=!0;return}O.incoming.window<=kl&&Bl(O)}},CHANNEL_EXTENDED_DATA:(S,k,v,O)=>{if(O!==T0)return;let ie=this._chanMgr.get(k);if(!(typeof ie!="object"||ie===null)&&ie.incoming.window!==0){if(ie.incoming.window-=v.length,!ie.stderr.push(v)){ie._waitChanDrain=!0;return}ie.incoming.window<=kl&&Bl(ie)}},CHANNEL_WINDOW_ADJUST:(S,k,v)=>{let O=this._chanMgr.get(k);typeof O!="object"||O===null||(O.outgoing.window+=v,O._waitWindow&&(O._waitWindow=!1,O._chunk?O._write(O._chunk,null,O._chunkcb):O._chunkcb?O._chunkcb():O._chunkErr?O.stderr._write(O._chunkErr,null,O._chunkcbErr):O._chunkcbErr&&O._chunkcbErr()))},CHANNEL_SUCCESS:(S,k)=>{let v=this._chanMgr.get(k);typeof v!="object"||v===null||(this._resetKA(),v._callbacks.length&&v._callbacks.shift()(!1))},CHANNEL_FAILURE:(S,k)=>{let v=this._chanMgr.get(k);typeof v!="object"||v===null||(this._resetKA(),v._callbacks.length&&v._callbacks.shift()(!0))},CHANNEL_REQUEST:(S,k,v,O,ie)=>{let X=this._chanMgr.get(k);if(typeof X!="object"||X===null)return;let fe=X._exit;if(fe.code===void 0){switch(v){case"exit-status":X.emit("exit",fe.code=ie);return;case"exit-signal":X.emit("exit",fe.code=null,fe.signal=`SIG${ie.signal}`,fe.dump=ie.coreDumped,fe.desc=ie.errorMessage);return}O&&S.channelFailure(X.outgoing.id)}},CHANNEL_EOF:(S,k)=>{let v=this._chanMgr.get(k);typeof v!="object"||v===null||v.incoming.state==="open"&&(v.incoming.state="eof",v.readable&&v.push(null),v.stderr.readable&&v.stderr.push(null))},CHANNEL_CLOSE:(S,k)=>{V0(this,k,this._chanMgr.get(k))}}});c.pause();let b=this.config.keepaliveInterval,R=this.config.keepaliveCountMax,P=0,L,ee=()=>{if(++P>R){if(clearInterval(L),c.readable){let S=new Error("Keepalive timeout");S.level="client-timeout",this.emit("error",S),c.destroy()}return}yt(c)?(o.push(H),_.ping()):clearInterval(L)};function H(){b>0&&(P=0,clearInterval(L),yt(c)&&(L=setInterval(ee,b)))}this._resetKA=H;let z=(()=>{let S=!1;return()=>{if(!S&&(S=!0,V&&!h)){let k=W0("Connection lost before handshake","protocol",!0);this.emit("error",k)}}})(),J=(()=>{let S=!1;return()=>{S||(S=!0,V=!0,s&&s("Socket connected"),this.emit("connect"),Q0.then(()=>{_.start(),c.on("data",k=>{try{_.parse(k,0,k.length)}catch(v){this.emit("error",v);try{yt(c)&&c.end()}catch{}}}),c.stderr&&typeof c.stderr.resume=="function"&&c.stderr.resume(),c.resume()}).catch(k=>{this.emit("error",k);try{yt(c)&&c.end()}catch{}}))}})(),V=!1;c.on("connect",J).on("timeout",()=>{this.emit("timeout")}).on("error",S=>{s&&s(`Socket error: ${S.message}`),clearTimeout(this._readyTimeout),S.level="client-socket",this.emit("error",S)}).on("end",()=>{s&&s("Socket ended"),z(),_.cleanup(),clearTimeout(this._readyTimeout),clearInterval(L),this.emit("end")}).on("close",()=>{s&&s("Socket closed"),z(),_.cleanup(),clearTimeout(this._readyTimeout),clearInterval(L),this.emit("close");let S=o;o=this._callbacks=[];let k=new Error("No response from server");for(let v=0;v<S.length;++v)S[v](k);this._chanMgr.cleanup(k)});let y,w=null,U=null,$=["none"];this.config.password!==void 0&&$.push("password"),a!==void 0&&$.push("publickey"),this._agent!==void 0&&$.push("agent"),this.config.tryKeyboard&&$.push("keyboard-interactive"),a!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&$.push("hostbased"),Array.isArray(i)?i=Pl(i):typeof i!="function"&&(i=Pl($));let M=!1,se=S=>{if(!M){if(M=!0,S===!1){let k=new Error("All configured authentication methods failed");k.level="client-authentication",this.emit("error",k),this.end();return}if(typeof S=="string"){let k=S;if($.indexOf(k)===-1)return Z(`Authentication method not allowed: ${k}`);let v=this.config.username;switch(k){case"password":S={type:k,username:v,password:this.config.password};break;case"publickey":S={type:k,username:v,key:a};break;case"hostbased":S={type:k,username:v,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":S={type:k,username:v,agentCtx:new wl(this._agent)};break;case"keyboard-interactive":S={type:k,username:v,prompt:(...O)=>this.emit("keyboard-interactive",...O)};break;case"none":S={type:k,username:v};break;default:return Z(`Skipping unsupported authentication method: ${S}`)}}else{if(typeof S!="object"||S===null)return Z(`Skipping invalid authentication attempt: ${S}`);{let k=S.username;if(typeof k!="string")return Z(`Skipping invalid authentication attempt: ${S}`);let v=S.type;switch(v){case"password":{let{password:O}=S;if(typeof O!="string"&&!Buffer.isBuffer(O))return Z("Skipping invalid password auth attempt");S={type:v,username:k,password:O};break}case"publickey":{let O=As(S.key,S.passphrase);if(O instanceof Error)return Z("Skipping invalid key auth attempt");if(!O.isPrivateKey())return Z("Skipping non-private key");S={type:v,username:k,key:O};break}case"hostbased":{let{localHostname:O,localUsername:ie}=S,X=As(S.key,S.passphrase);if(X instanceof Error||typeof O!="string"||typeof ie!="string")return Z("Skipping invalid hostbased auth attempt");if(!X.isPrivateKey())return Z("Skipping non-private key");S={type:v,username:k,key:X,localHostname:O,localUsername:ie};break}case"agent":{let O=S.agent;if(typeof O=="string"&&O.length)O=Il(O);else if(!Cl(O))return Z(`Skipping invalid agent: ${S.agent}`);S={type:v,username:k,agentCtx:new wl(O)};break}case"keyboard-interactive":{let{prompt:O}=S;if(typeof O!="function")return Z("Skipping invalid keyboard-interactive auth attempt");S={type:v,username:k,prompt:O};break}case"none":S={type:v,username:k};break;default:return Z(`Skipping unsupported authentication method: ${S}`)}}}y=S;try{let k=y.username;switch(y.type){case"password":_.authPassword(k,y.password);break;case"publickey":{let v;if(y.keyAlgos=pa(this,y.key,p),y.keyAlgos)if(y.keyAlgos.length)v=y.keyAlgos[0][0];else return Z("Skipping key authentication (no mutual hash algorithm)");_.authPK(k,y.key,v);break}case"hostbased":{let v,O;if(y.keyAlgos=pa(this,y.key,p),y.keyAlgos)if(y.keyAlgos.length)[v,O]=y.keyAlgos[0];else return Z("Skipping hostbased authentication (no mutual hash algorithm)");_.authHostbased(k,y.key,y.localHostname,y.localUsername,v,(ie,X)=>{let fe=y.key.sign(ie,O);if(fe instanceof Error)return fe.message=`Error while signing with key: ${fe.message}`,fe.level="client-authentication",this.emit("error",fe),j();X(fe)});break}case"agent":y.agentCtx.init(v=>{if(v)return v.level="agent",this.emit("error",v),j();te()});break;case"keyboard-interactive":_.authKeyboard(k);break;case"none":_.authNone(k);break}}finally{M=!1}}};function Z(S){s&&s(S),process.nextTick(j)}function j(){M=!1;let S=i(U,w,se);M||S===void 0||se(S)}let te=()=>{if(y.type==="agent"){let S=y.agentCtx.nextKey();if(S===!1)s&&s("Agent: No more keys left to try"),s&&s("Client: agent auth failed"),j();else{let k=y.agentCtx.pos(),v;if(y.keyAlgos=pa(this,S,p),y.keyAlgos)if(y.keyAlgos.length)v=y.keyAlgos[0][0];else{s&&s(`Agent: Skipping key #${k+1} (no mutual hash algorithm)`),te();return}s&&s(`Agent: Trying key #${k+1}`),_.authPK(y.username,S,v)}}},oe=()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let S=new Error("Timed out while waiting for handshake");S.level="client-timeout",this.emit("error",S),c.destroy()},this.config.readyTimeout))};if(t.sock)oe(),typeof c.connecting=="boolean"&&c.connecting||J();else{let S=this.config.host,k=this.config.forceIPv4,v=this.config.forceIPv6;s&&s(`Client: Trying ${S} on port ${this.config.port} ...`);let O=()=>{oe(),c.connect({host:S,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),c.setMaxListeners(0),c.setTimeout(typeof t.timeout=="number"?t.timeout:0)};!k&&!v||k&&v?O():v0(S,k?4:6,(ie,X,fe)=>{if(ie){let tt=k?"IPv4":"IPv6",_t=new Error(`Error while looking up ${tt} address for '${S}': ${ie}`);clearTimeout(this._readyTimeout),_t.level="client-dns",this.emit("error",_t),this.emit("close");return}S=X,O()})}return this}end(){return this._sock&&yt(this._sock)&&(this._protocol.disconnect(Sl.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&yt(this._sock)&&this._sock.destroy(),this}exec(t,e,r){if(!this._sock||!yt(this._sock))throw new Error("Not connected");typeof e=="function"&&(r=e,e={});let i={allowHalfOpen:e.allowHalfOpen!==!1};return Rn(this,"session",i,(s,o)=>{if(s){r(s);return}let a=[];function f(c){if(c){o.close(),r(c);return}a.length&&a.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&a.push(()=>Nl(o,f)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&da(o,e.env),(typeof e.pty=="object"&&e.pty!==null||e.pty===!0)&&a.push(()=>vl(o,e.pty,f)),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&a.push(()=>Rl(o,e.x11,f))),a.push(()=>X0(o,t,e,r)),a.shift()()}),this}shell(t,e,r){if(!this._sock||!yt(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),Rn(this,"session",(i,s)=>{if(i){r(i);return}let o=[];function a(f){if(f){s.close(),r(f);return}o.length&&o.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&o.push(()=>Nl(s,a)),t!==!1&&o.push(()=>vl(s,t,a)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&da(s,e.env),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&o.push(()=>Rl(s,e.x11,a))),o.push(()=>j0(s,r)),o.shift()()}),this}subsys(t,e){if(!this._sock||!yt(this._sock))throw new Error("Not connected");return Rn(this,"session",(r,i)=>{if(r){e(r);return}ga(i,t,(s,o)=>{if(s){e(s);return}e(void 0,o)})}),this}forwardIn(t,e,r){if(!this._sock||!yt(this._sock))throw new Error("Not connected");let i=typeof r=="function";return i&&this._callbacks.push((s,o)=>{if(s){r(s!==!0?s:new Error(`Unable to bind to ${t}:${e}`));return}let a=e;e===0&&o&&o.length>=4&&(a=q0(o,0),this._protocol._compatFlags&Tl.DYN_RPORT_BUG||(e=a)),this._forwarding[`${t}:${e}`]=a,r(void 0,a)}),this._protocol.tcpipForward(t,e,i),this}unforwardIn(t,e,r){if(!this._sock||!yt(this._sock))throw new Error("Not connected");let i=typeof r=="function";return i&&this._callbacks.push(s=>{if(s){r(s!==!0?s:new Error(`Unable to unbind from ${t}:${e}`));return}delete this._forwarding[`${t}:${e}`],r()}),this._protocol.cancelTcpipForward(t,e,i),this}forwardOut(t,e,r,i,s){if(!this._sock||!yt(this._sock))throw new Error("Not connected");let o={srcIP:t,srcPort:e,dstIP:r,dstPort:i};return typeof s!="function"&&(s=Aa),Rn(this,"direct-tcpip",o,s),this}openssh_noMoreSessions(t){if(!this._sock||!yt(this._sock))throw new Error("Not connected");let e=typeof t=="function";return!this.config.strictVendor||this.config.strictVendor&&pi.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||!yt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&pi.test(this._remoteVer)?(r&&this._callbacks.push(i=>{if(i){e(i!==!0?i: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||!yt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&pi.test(this._remoteVer)?(r&&this._callbacks.push(i=>{if(i){e(i!==!0?i: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||!yt(this._sock))throw new Error("Not connected");return typeof e!="function"&&(e=Aa),!this.config.strictVendor||this.config.strictVendor&&pi.test(this._remoteVer)?(Rn(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||!yt(this._sock))throw new Error("Not connected");return typeof t=="function"&&(e=t,t=void 0),Rn(this,"sftp",(r,i)=>{if(r){e(r);return}let s=(o,a)=>{if(o){e(o);return}function f(){i.removeListener("ready",c),i.removeListener("error",l),i.removeListener("exit",h),i.removeListener("close",h)}function c(){f(),e(void 0,i)}function l(g){f(),e(g)}function h(g,p){f();let _;typeof g=="number"?_=`Received exit code ${g} while establishing SFTP session`:p!==void 0?_=`Received signal ${p} while establishing SFTP session`:_="Received unexpected SFTP session termination";let b=new Error(_);b.code=g,b.signal=p,e(b)}i.on("ready",c).on("error",l).on("exit",h).on("close",h),i._init()};typeof t=="object"&&t!==null?da(i,t,o=>{if(o){e(o);return}ga(i,"sftp",s)}):ga(i,"sftp",s)}),this}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function Rn(n,t,e,r){let i=Es,s=ms;typeof e=="function"&&(r=e,e={});let o=(f,c)=>{r(f,c)};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,i,s);break;case"direct-tcpip":n._protocol.directTcpip(a,i,s,e);break;case"direct-streamlocal@openssh.com":n._protocol.openssh_directStreamLocal(a,i,s,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Rl(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=J0());let i=typeof e=="function";if(n.outgoing.state!=="open"){i&&e(new Error("Channel is not open"));return}i&&n._callbacks.push(s=>{if(s){e(s!==!0?s: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,i)}function vl(n,t,e){let r=24,i=80,s=640,o=480,a="vt100",f=null;typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.rows=="number"&&(r=t.rows),typeof t.cols=="number"&&(i=t.cols),typeof t.width=="number"&&(s=t.width),typeof t.height=="number"&&(o=t.height),typeof t.term=="string"&&(a=t.term),typeof t.modes=="object"&&(f=t.modes));let c=typeof e=="function";if(n.outgoing.state!=="open"){c&&e(new Error("Channel is not open"));return}c&&n._callbacks.push(l=>{if(l){e(l!==!0?l:new Error("Unable to request a pseudo-terminal"));return}e()}),n._client._protocol.pty(n.outgoing.id,r,i,o,s,a,f,c)}function Nl(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 X0(n,t,e,r){if(n.outgoing.state!=="open"){r(new Error("Channel is not open"));return}n._callbacks.push(i=>{if(i){r(i!==!0?i: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 da(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(s=>{if(s){e(s!==!0?s:new Error("Unable to set environment"));return}e()});let i=Object.keys(t||{});for(let s=0;s<i.length;++s){let o=i[s],a=t[o];n._client._protocol.env(n.outgoing.id,o,a,r)}}function ga(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 z0(n,t){let e=-1,r,i=()=>{let f={type:t.type,incoming:{id:e,window:Es,packetSize:ms,state:"open"},outgoing:{id:t.sender,window:t.window,packetSize:t.packetSize,state:"open"}},c=new Ul(n,f);return n._chanMgr.update(e,c),n._protocol.channelOpenConfirm(t.sender,e,Es,ms),c},s=()=>{r===void 0&&(e===-1?r=di.RESOURCE_SHORTAGE:r=di.CONNECT_FAILED),e!==-1&&n._chanMgr.remove(e),n._protocol.channelOpenFail(t.sender,r,"")},o=()=>(e=n._chanMgr.add(),e===-1&&(r=di.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 f=n._forwarding[`${a.destIP}:${a.destPort}`];if(f!==void 0&&o()){a.destPort===0&&(a.destPort=f),n.emit("tcp connection",a,i,s);return}break}case"forwarded-streamlocal@openssh.com":if(n._forwardingUnix[a.socketPath]!==void 0&&o()){n.emit("unix connection",a,i,s);return}break;case"auth-agent@openssh.com":if(n._agentFwdEnabled&&typeof n._agent.getStream=="function"&&o()){n._agent.getStream((f,c)=>{if(f)return s();let l=i();l.pipe(c).pipe(l)});return}break;case"x11":if(n._acceptX11!==0&&o()){n.emit("x11",a,i,s);return}break;default:r=di.UNKNOWN_CHANNEL_TYPE,n.config.debug&&n.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${t.type}`)}r===void 0&&(r=di.ADMINISTRATIVELY_PROHIBITED,n.config.debug&&n.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+t.type)),s()}var J0=(()=>{let n=Buffer.allocUnsafe(16);return()=>(k0(n,0,16),n.hexSlice(0,16))})();function Pl(n){if(!Array.isArray(n))throw new Error("authList must be an array");let t=0;return(e,r,i)=>t===n.length?!1:n[t++]}function Z0(n,t,e){if(!n._sock||!yt(n._sock))return;if(typeof e!="function"&&(e=Aa),!Array.isArray(t))throw new TypeError("Invalid keys argument type");let r=[];for(let i of t){let s=As(i);if(s instanceof Error)throw s;r.push(s)}if(!n.config.strictVendor||n.config.strictVendor&&pi.test(n._remoteVer)){n._callbacks.push((i,s)=>{if(i){e(i!==!0?i:new Error("Server failed to prove supplied keys"));return}let o=[],a=0;for(gs.init(s,0);gs.avail()&&a!==r.length;){let f=r[a++],c=f.getPublicSSH(),l=gs.readString();ps.init(l,0);let h=ps.readString(!0),g=ps.readString(),p;if(h!==f.type)if(f.type==="ssh-rsa")switch(h){case"rsa-sha2-256":p="sha256";break;case"rsa-sha2-512":p="sha512";break;default:continue}else continue;let _=n._protocol._kex.sessionID,b=Buffer.allocUnsafe(37+_.length+4+c.length),R=0;ha(b,29,R),b.utf8Write("hostkeys-prove-00@openssh.com",R+=4,29),ha(b,_.length,R+=29),yl(_,b,0,_.length,R+=4),ha(b,c.length,R+=_.length),yl(c,b,0,c.length,R+=4),(g=K0(g,h))&&f.verify(b,g,p)===!0&&o.push(f)}ps.clear(),gs.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 pa(n,t,e){switch(t.type){case"ssh-rsa":if(n._protocol._compatFlags&Tl.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"]]}}Ol.exports=Ea});var Hl=nt(Dl=>{"use strict";var{Agent:ba}=require("http"),{Agent:ep}=require("https"),{connect:tp}=require("tls"),_a;for(let n of[ba,ep]){class t extends n{constructor(r,i){super(i),this._connectCfg=r,this._defaultSrcIP=i&&i.srcIP||"localhost"}createConnection(r,i){let s=r&&r.localAddress||this._defaultSrcIP,o=r&&r.localPort||0,a=r.host,f=r.port;_a===void 0&&(_a=ma());let c=new _a,l=!1;c.on("ready",()=>{c.forwardOut(s,o,a,f,(h,g)=>{if(l=!0,h)return c.end(),i(h);g.once("close",()=>c.end()),i(null,rp(g,n,r))})}).on("error",i).on("close",()=>{l||i(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}Dl[n===ba?"SSHTTPAgent":"SSHTTPSAgent"]=t}function Ai(){}function rp(n,t,e){if(t===ba)return n.setKeepAlive=Ai,n.setNoDelay=Ai,n.setTimeout=Ai,n.ref=Ai,n.unref=Ai,n.destroySoon=n.destroy,n;e.socket=n;let r=tp(e),i=(()=>{let s=!1;return()=>{s||(s=!0,n.isPaused()&&n.resume())}})();return r.on("end",i).on("close",i),r}});var Ql=nt((Dm,wa)=>{"use strict";var{Server:np}=require("net"),mi=require("events"),{listenerCount:Dt}=mi,{CHANNEL_OPEN_FAILURE:vn,DEFAULT_CIPHER:ip,DEFAULT_COMPRESSION:sp,DEFAULT_KEX:op,DEFAULT_MAC:ap,DEFAULT_SERVER_HOST_KEY:fp,DISCONNECT_REASON:Nn,DISCONNECT_REASON_BY_VALUE:cp,SUPPORTED_CIPHER:up,SUPPORTED_COMPRESSION:lp,SUPPORTED_KEX:hp,SUPPORTED_MAC:dp,SUPPORTED_SERVER_HOST_KEY:gp}=Sr(),{init:pp}=Tr(),{KexInit:Ap}=ts(),{parseKey:Fl}=Or(),Ep=Go(),{SFTP:mp}=ui(),{writeUInt32BE:_p}=or(),{Channel:Pn,MAX_WINDOW:Fr,PACKET_SIZE:Qr,windowAdjust:bp,WINDOW_THRESHOLD:xp}=fa(),{ChannelManager:Sp,generateAlgorithmList:Ei,isWritable:_s,onChannelOpenFailure:yp,onCHANNEL_CLOSE:wp}=la(),Ip=10,Mr=class extends mi{constructor(t,e,r,i,s){super(),this.username=this.user=e,this.service=r,this.method=i,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(o,a,f)=>{this._finalResponse||(this._finalResponse=!0,s(this,o,a,f))},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)}},bs=class extends Mr{constructor(t,e,r,i,s,o){super(t,e,r,i,o),this._multistep=!0,this._cb=void 0,this._onInfoResponse=a=>{let f=this._cb;f&&(this._cb=void 0,f(a))},this.submethods=s,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(t,e,r,i){Array.isArray(t)||(t=[t]),typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"?(i=r,r=void 0):typeof i!="function"&&(i=void 0);for(let s=0;s<t.length;++s)typeof t[s]=="string"&&(t[s]={prompt:t[s],echo:!0});this._cb=i,this._initialResponse=!0,this._protocol.authInfoReq(e,r,t)}},Sa=class extends Mr{constructor(t,e,r,i,s,o){super(t,e,r,i,o),this.key={algo:s.keyAlgo,data:s.key},this.hashAlgo=s.hashAlgo,this.signature=s.signature,this.blob=s.blob}accept(){this.signature?Mr.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},ya=class extends Mr{constructor(t,e,r,i,s,o){super(t,e,r,i,o),this.key={algo:s.keyAlgo,data:s.key},this.hashAlgo=s.hashAlgo,this.signature=s.signature,this.blob=s.blob,this.localHostname=s.localHostname,this.localUsername=s.localUsername}},xs=class extends Mr{constructor(t,e,r,i,s,o){super(t,e,r,i,o),this.password=s,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)}},Ar=class extends mi{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:Fr,packetSize:Qr,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}}}},Zt=class extends mi{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new Error("Missing configuration object");let r=Object.create(null),i=[],s=t.hostKeys;if(!Array.isArray(s))throw new Error("hostKeys must be an array");let o=typeof t.algorithms=="object"&&t.algorithms!==null?t.algorithms:{},a=Ei(o.serverHostKey,fp,gp);for(let g=0;g<s.length;++g){let p;if(Buffer.isBuffer(s[g])||typeof s[g]=="string"?p=Fl(s[g]):p=Fl(s[g].key,s[g].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(!i.includes(p.type))if(p.type==="ssh-rsa"){let _=a.indexOf("ssh-rsa"),b=a.indexOf("rsa-sha2-256"),R=a.indexOf("rsa-sha2-512");_===-1&&(_=1/0),[_,b,R].sort(Cp).forEach(P=>{if(P===-1)return;let L;switch(P){case _:L="ssh-rsa";break;case b:L="rsa-sha2-256";break;case R:L="rsa-sha2-512";break;default:return}r[L]=p,i.push(L)})}else r[p.type]=p,i.push(p.type)}let f={kex:Ei(o.kex,op,hp).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:i,cs:{cipher:Ei(o.cipher,ip,up),mac:Ei(o.hmac,ap,dp),compress:Ei(o.compress,sp,lp),lang:[]},sc:void 0};f.sc=f.cs,typeof e=="function"&&this.on("connection",e);let c=typeof t.debug=="function"?t.debug:void 0,l=t.ident?Buffer.from(t.ident):void 0,h=new Ap(f);this._srv=new np(g=>{if(this._connections>=this.maxConnections){g.destroy();return}++this._connections,g.once("close",()=>{--this._connections});let p;if(c){let _=`[${process.hrtime().join(".")}] `;p=b=>{c(`${_}${b}`)}}new Ss(g,r,l,h,p,this,t)}).on("error",g=>{this.emit("error",g)}).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}};Zt.KEEPALIVE_CLIENT_INTERVAL=15e3;Zt.KEEPALIVE_CLIENT_COUNT_MAX=3;var Ss=class extends mi{constructor(t,e,r,i,s,o,a){super();let f=0,c=!1,l=[],h,g,p,_=[];this._sock=t,this._chanMgr=new Sp(this),this._debug=s,this.noMoreSessions=!1,this.authenticated=!1;function b(V){}this.on("error",b);let R=s?(V,y,w)=>{s(`Debug output from client: ${JSON.stringify(w)}`)}:void 0,P=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof Zt.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(Zt.KEEPALIVE_CLIENT_INTERVAL)&&Zt.KEEPALIVE_CLIENT_INTERVAL>0?Zt.KEEPALIVE_CLIENT_INTERVAL:-1,L=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof Zt.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(Zt.KEEPALIVE_CLIENT_COUNT_MAX)&&Zt.KEEPALIVE_CLIENT_COUNT_MAX>=0?Zt.KEEPALIVE_CLIENT_COUNT_MAX:-1,ee=0;P!==-1&&L!==-1&&(this.once("ready",()=>{let V=()=>{clearInterval(g)};this.on("close",V).on("end",V),g=setInterval(()=>{if(++ee>L){clearInterval(g);let y=new Error("Keepalive timeout");y.level="client-timeout",this.emit("error",y),this.end()}else H.ping()},P)}),p=()=>{g&&g.refresh(),ee=0});let H=this._protocol=new Ep({server:!0,hostKeys:e,ident:r,offer:i,onPacket:p,greeting:a.greeting,banner:a.banner,onWrite:V=>{_s(t)&&t.write(V)},onError:V=>{H._destruct||t.removeAllListeners("data"),this.emit("error",V);try{t.end()}catch{}},onHeader:V=>{this.removeListener("error",b);let y={ip:t.remoteAddress,family:t.remoteFamily,port:t.remotePort,header:V};if(!o.emit("connection",this,y)){H.disconnect(Nn.BY_APPLICATION),t.end();return}V.greeting&&this.emit("greeting",V.greeting)},onHandshakeComplete:V=>{++f>1&&this.emit("rekey"),this.emit("handshake",V)},debug:s,messageHandlers:{DEBUG:R,DISCONNECT:(V,y,w)=>{if(y!==Nn.BY_APPLICATION){w||(w=cp[y],w===void 0&&(w=`Unexpected disconnection reason: ${y}`));let U=new Error(w);U.code=y,this.emit("error",U)}t.end()},CHANNEL_OPEN:(V,y)=>{if(y.type==="session"&&this.noMoreSessions||!this.authenticated){let te=vn.ADMINISTRATIVELY_PROHIBITED;return H.channelOpenFail(y.sender,te)}let w=-1,U,$=!1,M,se=()=>{$||($=!0,U===void 0&&(w===-1?U=vn.RESOURCE_SHORTAGE:U=vn.CONNECT_FAILED),w!==-1&&this._chanMgr.remove(w),H.channelOpenFail(y.sender,U,""))},Z=()=>(w=this._chanMgr.add(),w===-1&&(U=vn.RESOURCE_SHORTAGE,s&&s("Automatic rejection of incoming channel open: no channels available")),w!==-1),j=y.data;switch(y.type){case"session":if(Dt(this,"session")&&Z()){M=()=>{if($)return;$=!0;let te=new Ar(this,y,w);return this._chanMgr.update(w,te),H.channelOpenConfirm(y.sender,w,Fr,Qr),te},this.emit("session",M,se);return}break;case"direct-tcpip":if(Dt(this,"tcpip")&&Z()){M=()=>{if($)return;$=!0;let te={type:void 0,incoming:{id:w,window:Fr,packetSize:Qr,state:"open"},outgoing:{id:y.sender,window:y.window,packetSize:y.packetSize,state:"open"}},oe=new Pn(this,te,{server:!0});return this._chanMgr.update(w,oe),H.channelOpenConfirm(y.sender,w,Fr,Qr),oe},this.emit("tcpip",M,se,j);return}break;case"direct-streamlocal@openssh.com":if(Dt(this,"openssh.streamlocal")&&Z()){M=()=>{if($)return;$=!0;let te={type:void 0,incoming:{id:w,window:Fr,packetSize:Qr,state:"open"},outgoing:{id:y.sender,window:y.window,packetSize:y.packetSize,state:"open"}},oe=new Pn(this,te,{server:!0});return this._chanMgr.update(w,oe),H.channelOpenConfirm(y.sender,w,Fr,Qr),oe},this.emit("openssh.streamlocal",M,se,j);return}break;default:U=vn.UNKNOWN_CHANNEL_TYPE,s&&s(`Automatic rejection of unsupported incoming channel open type: ${y.type}`)}U===void 0&&(U=vn.ADMINISTRATIVELY_PROHIBITED,s&&s(`Automatic rejection of unexpected incoming channel open for: ${y.type}`)),se()},CHANNEL_OPEN_CONFIRMATION:(V,y)=>{let w=this._chanMgr.get(y.recipient);if(typeof w!="function")return;let U={type:w.type,incoming:{id:y.recipient,window:Fr,packetSize:Qr,state:"open"},outgoing:{id:y.sender,window:y.window,packetSize:y.packetSize,state:"open"}},$=new Pn(this,U,{server:!0});this._chanMgr.update(y.recipient,$),w(void 0,$)},CHANNEL_OPEN_FAILURE:(V,y,w,U)=>{let $=this._chanMgr.get(y);if(typeof $!="function")return;yp(this,y,{reason:w,description:U},$)},CHANNEL_DATA:(V,y,w)=>{let U=this._chanMgr.get(y);if(!(typeof U!="object"||U===null)&&!(U.constructor===Ar&&(U=U._channel,!U))&&U.incoming.window!==0){if(U.incoming.window-=w.length,U.push(w)===!1){U._waitChanDrain=!0;return}U.incoming.window<=xp&&bp(U)}},CHANNEL_EXTENDED_DATA:(V,y,w,U)=>{},CHANNEL_WINDOW_ADJUST:(V,y,w)=>{let U=this._chanMgr.get(y);typeof U!="object"||U===null||U.constructor===Ar&&(U=U._channel,!U)||(U.outgoing.window+=w,U._waitWindow&&(U._waitWindow=!1,U._chunk?U._write(U._chunk,null,U._chunkcb):U._chunkcb?U._chunkcb():U._chunkErr?U.stderr._write(U._chunkErr,null,U._chunkcbErr):U._chunkcbErr&&U._chunkcbErr()))},CHANNEL_SUCCESS:(V,y)=>{let w=this._chanMgr.get(y);typeof w!="object"||w===null||w.constructor===Ar&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!1)},CHANNEL_FAILURE:(V,y)=>{let w=this._chanMgr.get(y);typeof w!="object"||w===null||w.constructor===Ar&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!0)},CHANNEL_REQUEST:(V,y,w,U,$)=>{let M=this._chanMgr.get(y);if(typeof M!="object"||M===null)return;let se=!1,Z,j;if(M.constructor!==Ar){U&&H.channelFailure(M.outgoing.id);return}if(U&&(w!=="shell"&&w!=="exec"&&w!=="subsystem"&&(Z=()=>{se||M._ending||M._channel||(se=!0,H.channelSuccess(M._chanInfo.outgoing.id))}),j=()=>{se||M._ending||M._channel||(se=!0,H.channelFailure(M._chanInfo.outgoing.id))}),M._ending){j&&j();return}switch(w){case"env":if(Dt(M,"env")){M.emit("env",Z,j,{key:$.name,val:$.value});return}break;case"pty-req":if(Dt(M,"pty")){M.emit("pty",Z,j,$);return}break;case"window-change":Dt(M,"window-change")?M.emit("window-change",Z,j,$):j&&j();break;case"x11-req":if(Dt(M,"x11")){M.emit("x11",Z,j,$);return}break;case"signal":if(Dt(M,"signal")){M.emit("signal",Z,j,{name:$});return}break;case"auth-agent-req@openssh.com":if(Dt(M,"auth-agent")){M.emit("auth-agent",Z,j);return}break;case"shell":if(Dt(M,"shell")){Z=()=>{if(se||M._ending||M._channel)return;se=!0,U&&H.channelSuccess(M._chanInfo.outgoing.id);let te=new Pn(this,M._chanInfo,{server:!0});return te.subtype=M.subtype=w,M._channel=te,te},M.emit("shell",Z,j);return}break;case"exec":if(Dt(M,"exec")){Z=()=>{if(se||M._ending||M._channel)return;se=!0,U&&H.channelSuccess(M._chanInfo.outgoing.id);let te=new Pn(this,M._chanInfo,{server:!0});return te.subtype=M.subtype=w,M._channel=te,te},M.emit("exec",Z,j,{command:$});return}break;case"subsystem":{let te=$==="sftp";if(Z=()=>{if(se||M._ending||M._channel)return;se=!0,U&&H.channelSuccess(M._chanInfo.outgoing.id);let oe;return te?oe=new mp(this,M._chanInfo,{server:!0,debug:s}):(oe=new Pn(this,M._chanInfo,{server:!0}),oe.subtype=M.subtype=`${w}:${$}`),M._channel=oe,oe},$==="sftp"){if(Dt(M,"sftp")){M.emit("sftp",Z,j);return}te=!1}if(Dt(M,"subsystem")){M.emit("subsystem",Z,j,{name:$});return}break}}s&&s(`Automatic rejection of incoming channel request: ${w}`),j&&j()},CHANNEL_EOF:(V,y)=>{let w=this._chanMgr.get(y);typeof w!="object"||w===null||w.constructor===Ar&&(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:(V,y)=>{let w=this._chanMgr.get(y);typeof w!="object"||w===null||w.constructor===Ar&&(w._ending=!0,w.emit("close"),w=w._channel,!w)||wp(this,y,w)},SERVICE_REQUEST:(V,y)=>{if(f===0||c||this.authenticated||y!=="ssh-userauth"){H.disconnect(Nn.SERVICE_NOT_AVAILABLE),t.end();return}c=!0,H.serviceAccept(y)},USERAUTH_REQUEST:(V,y,w,U,$)=>{if(f===0||this.authenticated||h&&(h.username!==y||h.service!==w)||U!=="password"&&U!=="publickey"&&U!=="hostbased"&&U!=="keyboard-interactive"&&U!=="none"||l.length===Ip){H.disconnect(Nn.PROTOCOL_ERROR),t.end();return}else if(w!=="ssh-connection"){H.disconnect(Nn.SERVICE_NOT_AVAILABLE),t.end();return}let M;switch(U){case"keyboard-interactive":M=new bs(H,y,w,U,$,z);break;case"publickey":M=new Sa(H,y,w,U,$,z);break;case"hostbased":M=new ya(H,y,w,U,$,z);break;case"password":if(h&&h instanceof xs&&h._changeCb){let se=h._changeCb;h._changeCb=void 0,se($.newPassword);return}M=new xs(H,y,w,U,$,z);break;case"none":M=new Mr(H,y,w,U,z);break}if(h)if(h._initialResponse)h._multistep&&!h._finalResponse&&(h._cleanup&&h._cleanup(),h.emit("abort"));else return l.push(M);h=M,Dt(this,"authentication")?this.emit("authentication",h):h.reject()},USERAUTH_INFO_RESPONSE:(V,y)=>{h&&h instanceof bs&&h._onInfoResponse(y)},GLOBAL_REQUEST:(V,y,w,U)=>{let $={type:null,buf:null};function M(se,Z){$.type=se,$.buf=Z,J()}if(w&&_.push($),(y==="tcpip-forward"||y==="cancel-tcpip-forward"||y==="no-more-sessions@openssh.com"||y==="streamlocal-forward@openssh.com"||y==="cancel-streamlocal-forward@openssh.com")&&Dt(this,"request")&&this.authenticated){let se,Z;if(w){let j=!1;se=te=>{if(j)return;j=!0;let oe;y==="tcpip-forward"&&U.bindPort===0&&typeof te=="number"&&(oe=Buffer.allocUnsafe(4),_p(oe,te,0)),M("SUCCESS",oe)},Z=()=>{j||(j=!0,M("FAILURE"))}}if(y==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,se&&se();return}this.emit("request",se,Z,y,U)}else w&&M("FAILURE")}}});t.pause(),pp.then(()=>{H.start(),t.on("data",V=>{try{H.parse(V,0,V.length)}catch(y){this.emit("error",y);try{_s(t)&&t.end()}catch{}}}),t.resume()}).catch(V=>{this.emit("error",V);try{_s(t)&&t.end()}catch{}}),t.on("error",V=>{V.level="socket",this.emit("error",V)}).once("end",()=>{s&&s("Socket ended"),H.cleanup(),this.emit("end")}).once("close",()=>{s&&s("Socket closed"),H.cleanup(),this.emit("close");let V=new Error("No response from server");this._chanMgr.cleanup(V)});let z=(V,y,w,U)=>{h===V&&!this.authenticated&&(y?(h=void 0,this.authenticated=!0,H.authSuccess(),l=[],this.emit("ready")):(H.authFailure(w,U),l.length&&(h=l.pop(),Dt(this,"authentication")?this.emit("authentication",h):h.reject())))};function J(){for(;_.length>0&&_[0].type;){let V=_.shift();V.type==="SUCCESS"&&H.requestSuccess(V.buf),V.type==="FAILURE"&&H.requestFailure()}}}end(){return this._sock&&_s(this._sock)&&(this._protocol.disconnect(Nn.BY_APPLICATION),this._sock.end()),this}x11(t,e,r){return xa(this,"x11",{originAddr:t,originPort:e},r),this}forwardOut(t,e,r,i,s){return xa(this,"forwarded-tcpip",{boundAddr:t,boundPort:e,remoteAddr:r,remotePort:i},s),this}openssh_forwardOutStreamLocal(t,e){return xa(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 xa(n,t,e,r){let i=Fr,s=Qr;typeof e=="function"&&(r=e,e={});let o=(f,c)=>{r(f,c)};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,i,s,e);break;case"x11":n._protocol.x11(a,i,s,e);break;case"forwarded-streamlocal@openssh.com":n._protocol.openssh_forwardedStreamLocal(a,i,s,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Cp(n,t){return n-t}wa.exports=Zt;wa.exports.IncomingClient=Ss});var Kl=nt((Hm,ql)=>{"use strict";var{createCipheriv:Bp,generateKeyPair:kp,generateKeyPairSync:Rp,getCurves:vp,randomBytes:Ml}=require("crypto"),{Ber:lt}=Kn(),Np=$s().pbkdf,{CIPHER_INFO:Pp}=Tr(),Tp=16,Lp=16,Up=vp(),Op=new Map(Object.entries(Pp));function $l(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 i=t.bits;if(!Number.isInteger(i))throw new TypeError("RSA bits must be an integer");if(i<=0||i>16384)throw new RangeError("RSA bits must be non-zero and <= 16384");return["rsa",{modulusLength:i,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 i;switch(t.bits){case 256:i="prime256v1";break;case 384:i="secp384r1";break;case 521:i="secp521r1";break;default:throw new Error("ECDSA bits must be 256, 384, or 521")}if(!Up.includes(i))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:i,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ed25519":return["ed25519",{publicKeyEncoding:e,privateKeyEncoding:r}];default:throw new Error(`Unsupported key type: ${n}`)}}function Dp(n,t,e){switch(n){case"rsa":{let r=new lt.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()!==lt.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 lt.Reader(r.readString(lt.OctetString,!0)),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");let i=r.readString(lt.Integer,!0),s=r.readString(lt.Integer,!0),o=r.readString(lt.Integer,!0),a=r.readString(lt.Integer,!0),f=r.readString(lt.Integer,!0);r.readString(lt.Integer,!0),r.readString(lt.Integer,!0);let c=r.readString(lt.Integer,!0),l=Buffer.from("ssh-rsa"),h=Buffer.allocUnsafe(4+l.length+4+i.length+4+s.length+4+o.length+4+c.length+4+a.length+4+f.length),g=0;h.writeUInt32BE(l.length,g+=0),h.set(l,g+=4),h.writeUInt32BE(i.length,g+=l.length),h.set(i,g+=4),h.writeUInt32BE(s.length,g+=i.length),h.set(s,g+=4),h.writeUInt32BE(o.length,g+=s.length),h.set(o,g+=4),h.writeUInt32BE(c.length,g+=o.length),h.set(c,g+=4),h.writeUInt32BE(a.length,g+=c.length),h.set(a,g+=4),h.writeUInt32BE(f.length,g+=a.length),h.set(f,g+=4);let p=Buffer.allocUnsafe(4+l.length+4+s.length+4+i.length);return g=0,p.writeUInt32BE(l.length,g+=0),p.set(l,g+=4),p.writeUInt32BE(s.length,g+=l.length),p.set(s,g+=4),p.writeUInt32BE(i.length,g+=s.length),p.set(i,g+=4),{sshName:l.toString(),priv:h,pub:p}}case"ec":{let r=new lt.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 i=r.readString(lt.BitString,!0);{let g=0;for(;g<i.length&&i[g]===0;++g);g>0&&(i=i.slice(g))}if(r=new lt.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 s=r.readOID(),o;switch(s){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 lt.Reader(r.readString(lt.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(lt.OctetString,!0)]),f=Buffer.from(`ecdsa-sha2-${o}`);o=Buffer.from(o);let c=Buffer.allocUnsafe(4+f.length+4+o.length+4+i.length+4+a.length),l=0;c.writeUInt32BE(f.length,l+=0),c.set(f,l+=4),c.writeUInt32BE(o.length,l+=f.length),c.set(o,l+=4),c.writeUInt32BE(i.length,l+=o.length),c.set(i,l+=4),c.writeUInt32BE(a.length,l+=i.length),c.set(a,l+=4);let h=Buffer.allocUnsafe(4+f.length+4+o.length+4+i.length);return l=0,h.writeUInt32BE(f.length,l+=0),h.set(f,l+=4),h.writeUInt32BE(o.length,l+=f.length),h.set(o,l+=4),h.writeUInt32BE(i.length,l+=o.length),h.set(i,l+=4),{sshName:f.toString(),priv:c,pub:h}}case"ed25519":{let r=new lt.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let i=r.readString(lt.BitString,!0);{let l=0;for(;l<i.length&&i[l]===0;++l);l>0&&(i=i.slice(l))}if(r=new lt.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 lt.Reader(r.readString(lt.OctetString,!0));let s=r.readString(lt.OctetString,!0),o=Buffer.from("ssh-ed25519"),a=Buffer.allocUnsafe(4+o.length+4+i.length+4+(s.length+i.length)),f=0;a.writeUInt32BE(o.length,f+=0),a.set(o,f+=4),a.writeUInt32BE(i.length,f+=o.length),a.set(i,f+=4),a.writeUInt32BE(s.length+i.length,f+=i.length),a.set(s,f+=4),a.set(i,f+=s.length);let c=Buffer.allocUnsafe(4+o.length+4+i.length);return f=0,c.writeUInt32BE(o.length,f+=0),c.set(o,f+=4),c.writeUInt32BE(i.length,f+=o.length),c.set(i,f+=4),{sshName:o.toString(),priv:a,pub:c}}}}function Wl(n,t,e,r){let i="new",s,o="";if(typeof r=="object"&&r!==null&&(typeof r.comment=="string"&&r.comment&&(o=r.comment),typeof r.format=="string"&&r.format&&(i=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 f=Op.get(r.cipher);if(f===void 0)throw new Error("Invalid cipher name");if(i==="new"){let c=Lp;if(r.rounds!==void 0){if(!Number.isInteger(r.rounds))throw new TypeError("rounds must be an integer");r.rounds>0&&(c=r.rounds)}let l=Buffer.allocUnsafe(f.keyLen+f.ivLen),h=Ml(Tp);if(Np(a,a.length,h,h.length,l,l.length,c)!==0)return new Error("Failed to generate information to encrypt key");let p=Buffer.allocUnsafe(4+h.length+4);{let _=0;p.writeUInt32BE(h.length,_+=0),p.set(h,_+=4),p.writeUInt32BE(c,_+=h.length)}s={cipher:f,cipherName:r.cipher,kdfName:"bcrypt",kdfOptions:p,key:l.slice(0,f.keyLen),iv:l.slice(f.keyLen)}}}switch(i){case"new":{let a=`-----BEGIN OPENSSH PRIVATE KEY-----
34
+ `,f,c=Buffer.from(s?s.cipherName:"none"),l=Buffer.from(s?s.kdfName:"none"),h=s?s.kdfOptions:Buffer.alloc(0),g=s?s.cipher.blockLen:8,p=Dp(n,t,e),_=Ml(4),b=Buffer.from(o),R=8+p.priv.length+4+b.length,P=[];for(let J=1;(R+P.length)%g;++J)P.push(J&255);P=Buffer.from(P);let L=Buffer.allocUnsafe(R+P.length),ee;{let J=0;L.set(_,J+=0),L.set(_,J+=4),L.set(p.priv,J+=4),L.writeUInt32BE(b.length,J+=p.priv.length),L.set(b,J+=4),L.set(P,J+=b.length)}if(s){let J={authTagLength:s.cipher.authLen},V=Bp(s.cipher.sslName,s.key,s.iv,J);V.setAutoPadding(!1),L=Buffer.concat([V.update(L),V.final()]),s.cipher.authLen>0?ee=V.getAuthTag():ee=Buffer.alloc(0),s.key.fill(0),s.iv.fill(0)}else ee=Buffer.alloc(0);let H=Buffer.from("openssh-key-v1\0"),z=Buffer.allocUnsafe(H.length+4+c.length+4+l.length+4+h.length+4+4+p.pub.length+4+L.length+ee.length);{let J=0;z.set(H,J+=0),z.writeUInt32BE(c.length,J+=H.length),z.set(c,J+=4),z.writeUInt32BE(l.length,J+=c.length),z.set(l,J+=4),z.writeUInt32BE(h.length,J+=l.length),z.set(h,J+=4),z.writeUInt32BE(1,J+=h.length),z.writeUInt32BE(p.pub.length,J+=4),z.set(p.pub,J+=4),z.writeUInt32BE(L.length,J+=p.pub.length),z.set(L,J+=4),z.set(ee,J+=L.length)}{let J=z.base64Slice(0,z.length),V=J.replace(/.{64}/g,`$&
35
+ `);J.length&63&&(V+=`
36
+ `),a+=V}{let J=p.pub.base64Slice(0,p.pub.length);f=`${p.sshName} ${J}${o?` ${o}`:""}`}return a+=`-----END OPENSSH PRIVATE KEY-----
37
+ `,{private:a,public:f}}default:throw new Error("Invalid output key format")}}function Hp(){}ql.exports={generateKeyPair:(n,t,e)=>{typeof t=="function"&&(e=t,t=void 0),typeof e!="function"&&(e=Hp);let r=$l(n,t);kp(...r,(i,s,o)=>{if(i)return e(i);let a;try{a=Wl(r[0],s,o,t)}catch(f){return e(f)}e(null,a)})},generateKeyPairSync:(n,t)=>{let e=$l(n,t),{publicKey:r,privateKey:i}=Rp(...e);return Wl(e[0],r,i,t)}}});var Ia=nt((Fm,Gl)=>{"use strict";var{AgentProtocol:Fp,BaseAgent:Qp,createAgent:Mp,CygwinAgent:$p,OpenSSHAgent:Wp,PageantAgent:qp}=No(),{SSHTTPAgent:Kp,SSHTTPSAgent:Gp}=Hl(),{parseKey:Yp}=Or(),{flagsToString:Vp,OPEN_MODE:jp,STATUS_CODE:Xp,stringToFlags:zp}=ui();Gl.exports={AgentProtocol:Fp,BaseAgent:Qp,createAgent:Mp,Client:ma(),CygwinAgent:$p,HTTPAgent:Kp,HTTPSAgent:Gp,OpenSSHAgent:Wp,PageantAgent:qp,Server:Ql(),utils:{parseKey:Yp,...Kl(),sftp:{flagsToString:Vp,OPEN_MODE:jp,STATUS_CODE:Xp,stringToFlags:zp}}}});function Ha(n){return n==="1"||n==="true"}function Fa(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Ch(){return Ha(process.env.DEV_MODE)||Ha(process.env.RENDER_PERF)}function Wt(n){let t=Ch();if(!t)return{enabled:t,mark:()=>{},done:()=>{}};let e=Fa(),r=s=>{let o=Fa()-e;console.log(`[perf][${n}] ${s}: ${o.toFixed(1)}ms`)};return{enabled:t,mark:r,done:(s="done")=>{r(s)}}}var sA=Wt("HoneyPot");Rr();var sm=Wt("SshClient");var ph=require("node:events"),Ah=Xt(Ia(),1);var ch=require("node:events");Rr();var Vl=require("node:events"),Ee=Xt(require("node:fs"),1),Ft=Xt(require("node:path"),1),Tn=require("node:zlib");var Yl=Xt(require("node:path"),1);function er(n){if(!n||n.trim()==="")return"/";let t=Yl.posix.normalize(n.startsWith("/")?n:`/${n}`);return t===""?"/":t}var Ht=Wt("VirtualFileSystem"),Ca=class extends Vl.EventEmitter{mirrorRoot;ensureMirrorRoot(){Ee.mkdirSync(this.mirrorRoot,{recursive:!0,mode:493})}resolveFsPath(t){let r=er(t).slice(1),i=Ft.resolve(this.mirrorRoot,r||"."),s=Ft.relative(this.mirrorRoot,i);if(s.startsWith("..")||Ft.isAbsolute(s))throw new Error(`Invalid path '${t}'.`);return i}detectGzipFile(t){let e=Ee.openSync(t,"r");try{let r=Buffer.alloc(2);return Ee.readSync(e,r,0,2,0)===2&&r[0]===31&&r[1]===139}finally{Ee.closeSync(e)}}computeDiskUsageBytes(t){let e=Ee.statSync(t);if(e.isFile())return e.size;let r=0;for(let i of Ee.readdirSync(t))r+=this.computeDiskUsageBytes(Ft.join(t,i));return r}renderTreeLines(t,e){let r=[e],i=(s,o)=>{let a=Ee.readdirSync(s,{withFileTypes:!0}).map(f=>f.name).sort((f,c)=>f.localeCompare(c));for(let f=0;f<a.length;f+=1){let c=a[f],l=f===a.length-1,h=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",g=`${o}${l?" ":"\u2502 "}`,p=Ft.join(s,c),_=Ee.statSync(p).isDirectory();r.push(`${o}${h}${c}`),_&&i(p,g)}};return i(t,""),r.join(`
38
+ `)}constructor(t=process.cwd()){super(),Ht.mark("constructor"),this.mirrorRoot=Ft.resolve(t,".vfs","mirror")}async restoreMirror(){Ht.mark("restoreMirror"),this.ensureMirrorRoot()}async flushMirror(){Ht.mark("flushMirror"),this.ensureMirrorRoot(),this.emit("mirror:flush")}mkdir(t,e=493){Ht.mark("mkdir"),this.ensureMirrorRoot();let r=this.resolveFsPath(t);if(Ee.existsSync(r)&&!Ee.statSync(r).isDirectory())throw new Error(`Cannot create directory '${er(t)}': path is a file.`);Ee.mkdirSync(r,{recursive:!0,mode:e}),this.emit("dir:create",{path:er(t),mode:e})}writeFile(t,e,r={}){Ht.mark("writeFile"),this.ensureMirrorRoot();let i=er(t),s=this.resolveFsPath(i),o=Ft.dirname(s);Ee.mkdirSync(o,{recursive:!0,mode:493});let a=Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"),c=r.compress??!1?(0,Tn.gzipSync)(a):a;if(Ee.existsSync(s)&&Ee.statSync(s).isDirectory())throw new Error(`Cannot write file '${i}': path is a directory.`);Ee.writeFileSync(s,c),Ee.chmodSync(s,r.mode??420),this.emit("file:write",{path:i,size:c.length})}readFile(t){Ht.mark("readFile"),this.ensureMirrorRoot();let e=this.resolveFsPath(t);if(!Ee.existsSync(e)||!Ee.statSync(e).isFile())throw new Error(`Cannot read '${t}': not a file.`);let r=Ee.readFileSync(e),i=this.detectGzipFile(e)?(0,Tn.gunzipSync)(r):r,s=er(t);return this.emit("file:read",{path:s,size:i.length}),i.toString("utf8")}exists(t){Ht.mark("exists");try{let e=this.resolveFsPath(t);return Ee.existsSync(e)}catch{return!1}}chmod(t,e){Ht.mark("chmod");let r=this.resolveFsPath(t);if(!Ee.existsSync(r))throw new Error(`Path '${er(t)}' does not exist.`);Ee.chmodSync(r,e)}stat(t){Ht.mark("stat"),this.ensureMirrorRoot();let e=er(t),r=this.resolveFsPath(e);if(!Ee.existsSync(r))throw new Error(`Path '${e}' does not exist.`);let i=Ee.statSync(r),s=i.mode&511,o=e==="/"?"":Ft.posix.basename(e);return i.isFile()?{type:"file",name:o,path:e,mode:s,createdAt:i.birthtime,updatedAt:i.mtime,compressed:this.detectGzipFile(r),size:i.size}:{type:"directory",name:o,path:e,mode:s,createdAt:i.birthtime,updatedAt:i.mtime,childrenCount:Ee.readdirSync(r).length}}list(t="/"){Ht.mark("list");let e=this.resolveFsPath(t);if(!Ee.existsSync(e)||!Ee.statSync(e).isDirectory())throw new Error(`Cannot list '${t}': not a directory.`);return Ee.readdirSync(e).sort()}tree(t="/"){Ht.mark("tree");let e=this.resolveFsPath(t);if(!Ee.existsSync(e)||!Ee.statSync(e).isDirectory())throw new Error(`Cannot render tree for '${t}': not a directory.`);let r=t==="/"?"/":Ft.posix.basename(er(t));return this.renderTreeLines(e,r)}getUsageBytes(t="/"){Ht.mark("getUsageBytes");let e=this.resolveFsPath(t);if(!Ee.existsSync(e))throw new Error(`Path '${er(t)}' does not exist.`);return this.computeDiskUsageBytes(e)}compressFile(t){Ht.mark("compressFile");let e=this.resolveFsPath(t);if(!Ee.existsSync(e)||!Ee.statSync(e).isFile())throw new Error(`Cannot compress '${t}': not a file.`);if(!this.detectGzipFile(e)){let r=Ee.readFileSync(e);Ee.writeFileSync(e,(0,Tn.gzipSync)(r))}}decompressFile(t){Ht.mark("decompressFile");let e=this.resolveFsPath(t);if(!Ee.existsSync(e)||!Ee.statSync(e).isFile())throw new Error(`Cannot decompress '${t}': not a file.`);if(this.detectGzipFile(e)){let r=Ee.readFileSync(e);Ee.writeFileSync(e,(0,Tn.gunzipSync)(r))}}remove(t,e={}){Ht.mark("remove");let r=er(t);if(r==="/")throw new Error("Cannot remove root directory.");let i=this.resolveFsPath(r);if(!Ee.existsSync(i))throw new Error(`Path '${r}' does not exist.`);let s=Ee.statSync(i);if(s.isDirectory()&&!e.recursive&&Ee.readdirSync(i).length>0)throw new Error(`Directory '${r}' is not empty. Use recursive option.`);s.isDirectory()?Ee.rmSync(i,{recursive:e.recursive??!1}):Ee.rmSync(i)}move(t,e){Ht.mark("move");let r=er(t),i=er(e);if(r==="/"||i==="/")throw new Error("Cannot move root directory.");let s=this.resolveFsPath(r),o=this.resolveFsPath(i);if(!Ee.existsSync(s))throw new Error(`Path '${r}' does not exist.`);if(Ee.existsSync(o))throw new Error(`Destination '${i}' already exists.`);Ee.mkdirSync(Ft.dirname(o),{recursive:!0,mode:493}),Ee.renameSync(s,o)}},Ba=Ca;var $r=require("node:crypto"),Xl=require("node:events"),zl=Xt(require("node:path"),1);function Jp(){let n=process.env.SSH_MIMIC_FAST_PASSWORD_HASH;return!!n&&!["0","false","no","off"].includes(n.toLowerCase())}var wt=Wt("VirtualUserManager"),_i=class n extends Xl.EventEmitter{constructor(e,r=!0){super();this.vfs=e;this.autoSudoForNewUsers=r;wt.mark("constructor")}vfs;autoSudoForNewUsers;static recordCache=new Map;static fastPasswordHash=Jp();usersPath="/virtual-env-js/.auth/htpasswd";sudoersPath="/virtual-env-js/.auth/sudoers";quotasPath="/virtual-env-js/.auth/quotas";authDirPath="/virtual-env-js/.auth";users=new Map;sudoers=new Set;quotas=new Map;activeSessions=new Map;nextTty=0;async initialize(){wt.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(wt.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){wt.mark("clearQuota"),this.validateUsername(e),this.quotas.delete(e),await this.persist()}getQuotaBytes(e){return wt.mark("getQuotaBytes"),this.quotas.get(e)??null}getUsageBytes(e){wt.mark("getUsageBytes");let r=`/home/${e}`;return this.vfs.exists(r)?this.vfs.getUsageBytes(r):0}assertWriteWithinQuota(e,r,i){wt.mark("assertWriteWithinQuota");let s=this.quotas.get(e);if(s===void 0)return;let o=jl(r),a=jl(`/home/${e}`);if(!(o===a||o.startsWith(`${a}/`)))return;let c=this.getUsageBytes(e),l=0;if(this.vfs.exists(o)){let p=this.vfs.stat(o);p.type==="file"&&(l=p.size)}let h=Buffer.isBuffer(i)?i.length:Buffer.byteLength(i,"utf8"),g=c-l+h;if(g>s)throw new Error(`quota exceeded for '${e}': ${g}/${s} bytes`)}verifyPassword(e,r){wt.mark("verifyPassword");let i=this.users.get(e);return i?this.hashPassword(r)===i.passwordHash:!1}async addUser(e,r){if(wt.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 i=`/home/${e}`;this.vfs.exists(i)||(this.vfs.mkdir(i,493),this.vfs.writeFile(`${i}/README.txt`,`Welcome to the virtual environment, ${e}`)),await this.persist(),this.emit("user:add",{username:e})}getPasswordHash(e){wt.mark("getPasswordHash");let r=this.users.get(e);return r?r.passwordHash:null}async setPassword(e,r){if(wt.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(wt.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 wt.mark("isSudoer"),this.sudoers.has(e)}async addSudoer(e){if(wt.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(wt.mark("removeSudoer"),this.validateUsername(e),e==="root")throw new Error("sudoers: cannot remove root");this.sudoers.delete(e),await this.persist()}registerSession(e,r){wt.mark("registerSession");let i={id:(0,$r.randomUUID)(),username:e,tty:`pts/${this.nextTty++}`,remoteAddress:r,startedAt:new Date().toISOString()};return this.activeSessions.set(i.id,i),this.emit("session:register",{sessionId:i.id,username:e,remoteAddress:r}),i}unregisterSession(e){if(wt.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,i){if(wt.mark("updateSession"),!e)return;let s=this.activeSessions.get(e);s&&this.activeSessions.set(e,{...s,username:r,remoteAddress:i})}listActiveSessions(){return wt.mark("listActiveSessions"),Array.from(this.activeSessions.values()).sort((e,r)=>e.startedAt.localeCompare(r.startedAt))}loadFromVfs(){if(this.users.clear(),!this.vfs.exists(this.usersPath))return;let e=this.vfs.readFile(this.usersPath);for(let r of e.split(`
39
+ `)){let i=r.trim();if(i.length===0)continue;let s=i.split(":");if(s.length<3)continue;let[o,a,f]=s;!o||!a||!f||this.users.set(o,{username:o,salt:a,passwordHash:f})}}loadSudoersFromVfs(){if(this.sudoers.clear(),!this.vfs.exists(this.sudoersPath))return;let e=this.vfs.readFile(this.sudoersPath);for(let r of e.split(`
40
+ `)){let i=r.trim();i.length>0&&this.sudoers.add(i)}}loadQuotasFromVfs(){if(this.quotas.clear(),!this.vfs.exists(this.quotasPath))return;let e=this.vfs.readFile(this.quotasPath);for(let r of e.split(`
41
+ `)){let i=r.trim();if(i.length===0)continue;let[s,o]=i.split(":"),a=Number.parseInt(o??"",10);!s||!Number.isFinite(a)||a<0||this.quotas.set(s,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(`
42
+ `),r=Array.from(this.sudoers.values()).sort().join(`
43
+ `),i=Array.from(this.quotas.entries()).sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>`${o}:${a}`).join(`
44
+ `),s=!1;s=this.writeIfChanged(this.usersPath,e.length>0?`${e}
45
+ `:"",384)||s,s=this.writeIfChanged(this.sudoersPath,r.length>0?`${r}
46
+ `:"",384)||s,s=this.writeIfChanged(this.quotasPath,i.length>0?`${i}
47
+ `:"",384)||s,s&&await this.vfs.flushMirror()}writeIfChanged(e,r,i){return this.vfs.exists(e)&&this.vfs.readFile(e)===r?(this.vfs.chmod(e,i),!1):(this.vfs.writeFile(e,r,{mode:i}),!0)}createRecord(e,r){let i=`${e}:${r}`,s=n.recordCache.get(i);if(s)return s;let o=(0,$r.randomBytes)(16).toString("hex"),a={username:e,salt:o,passwordHash:this.hashPassword(r)};return n.recordCache.set(i,a),a}hasPassword(e){if(wt.mark("hasPassword"),this.getPasswordHash(e)===this.hashPassword(""))return!1;let r=this.users.get(e);return!!r&&!!r.passwordHash}hashPassword(e){return n.fastPasswordHash?(0,$r.createHash)("sha256").update(`${e}`).digest("hex"):(0,$r.scryptSync)(e,"",32).toString("hex")}validateUsername(e){if(!e||e.trim()==="")throw new Error("invalid username");if(!/^[a-z_][a-z0-9_-]{0,31}$/i.test(e))throw new Error("invalid username")}validatePassword(e){if(!e||e.trim()==="")throw new Error("invalid password")}};function jl(n){let t=zl.posix.normalize(n);return t.startsWith("/")?t:`/${t}`}var Ln=require("node:fs/promises"),Ra=Xt(require("node:path"),1);Rr();var nh=require("node:child_process");var Jl=require("node:fs/promises"),ys=Xt(require("node:path"),1);function ka(n){return`'${n.replace(/'/g,"'\\''")}'`}function bi(n){return n.replace(/\r\n/g,`
48
+ `).replace(/\r/g,`
49
+ `).replace(/\n/g,`\r
50
+ `)}function Zl(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 eh(n,t){return!t||t.trim()===""||t==="."?n:t.startsWith("/")?ys.posix.normalize(t):ys.posix.normalize(ys.posix.join(n,t))}async function th(n){try{let e=(await(0,Jl.readFile)(`/proc/${n}/task/${n}/children`,"utf8")).trim().split(/\s+/).filter(Boolean).map(i=>Number.parseInt(i,10)).filter(i=>Number.isInteger(i)&&i>0),r=await Promise.all(e.map(i=>th(i)));return[...e,...r.flat()]}catch{return[]}}async function rh(n=process.pid){let t=await th(n),e=Array.from(new Set(t)).sort((r,i)=>r-i);return e.length===0?null:e.join(",")}function ih(n,t,e){let r=Zl(n,t),i=(0,nh.spawn)("script",["-qfec",r,"/dev/null"],{stdio:["pipe","pipe","pipe"],env:{...process.env,TERM:process.env.TERM??"xterm-256color"}});return i.stdout.on("data",s=>{e.write(s.toString("utf8"))}),i.stderr.on("data",s=>{e.write(s.toString("utf8"))}),i}function sh(n,t,e){return ih(`nano -- ${ka(n)}`,t,e)}function oh(n,t,e){return ih(`htop -p ${ka(n)}`,t,e)}Ts();function ah(n,t,e){let r=n==="root",i=r?"\x1B[31;1m":"\x1B[35;1m",s="\x1B[37;1m",o="\x1B[34;1m",a="\x1B[0m";return`${s}[${i}${n}${s}@${o}${t}${a} ${e}${s}]${a}${r?"#":"$"} `}function fh(n,t,e,r,i,s="unknown",o={cols:80,rows:24},a){let f="",c=0,l=Zp(a.vfs),h=null,g="",p=`/home/${e}`,_=null,b=null,R=()=>{let S=`/home/${e}`,k=p===S?"~":Ra.posix.basename(p)||"/";return ah(e,r,k)},P=Array.from(new Set(mc())).sort();console.log(`[${i}] Shell started for user '${e}' at ${s}`);function L(){let S=R();t.write(`\r${S}${f}\x1B[K`);let k=f.length-c;k>0&&t.write(`\x1B[${k}D`)}function ee(){t.write("\r\x1B[K")}function H(S){b={...S,buffer:""},ee(),t.write(S.prompt)}async function z(S){if(!b)return;let k=b;if(b=null,!S){t.write(`\r
51
+ Sorry, try again.\r
52
+ `),L();return}if(!k.commandLine){e=k.targetUser,p=`/home/${e}`,a.users.updateSession(i,e,s),t.write(`\r
53
+ `),L();return}let v=k.loginShell?`/home/${k.targetUser}`:p,O=await Promise.resolve(Qt(k.commandLine,k.targetUser,r,"shell",v,a));if(t.write(`\r
54
+ `),O.openEditor){await V(O.openEditor.targetPath,O.openEditor.initialContent,O.openEditor.tempPath);return}if(O.openHtop){await y();return}O.clearScreen&&t.write("\x1B[2J\x1B[H"),O.stdout&&t.write(`${bi(O.stdout)}\r
55
+ `),O.stderr&&t.write(`${bi(O.stderr)}\r
56
+ `),O.switchUser?(e=O.switchUser,p=O.nextCwd??`/home/${e}`,a.users.updateSession(i,e,s)):O.nextCwd&&(p=O.nextCwd),await a.vfs.flushMirror(),L()}async function J(){if(!_)return;let S=_;if(S.kind==="nano"){try{let k=await(0,Ln.readFile)(S.tempPath,"utf8");a.writeFileAsUser(e,S.targetPath,k),await a.vfs.flushMirror()}catch{}await(0,Ln.unlink)(S.tempPath).catch(()=>{})}_=null,f="",c=0,t.write(`\r
57
+ `),L()}async function V(S,k,v){a.vfs.exists(S)&&await(0,Ln.writeFile)(v,k,"utf8");let O=sh(v,o,t);O.on("error",ie=>{t.write(`nano: ${ie.message}\r
58
+ `),J()}),O.on("close",()=>{J()}),_={kind:"nano",targetPath:S,tempPath:v,process:O}}async function y(){let S=await rh();if(!S){t.write(`htop: no child_process processes to display\r
59
+ `);return}let k=oh(S,o,t);k.on("error",v=>{t.write(`htop: ${v.message}\r
60
+ `),J()}),k.on("close",()=>{J()}),_={kind:"htop",targetPath:"",tempPath:"",process:k}}function w(S){f=S,c=f.length,L()}function U(S){f=`${f.slice(0,c)}${S}${f.slice(c)}`,c+=S.length,L()}function $(S,k){let v=k;for(;v>0&&!/\s/.test(S[v-1]);)v-=1;let O=k;for(;O<S.length&&!/\s/.test(S[O]);)O+=1;return{start:v,end:O}}function M(S){let k=S.lastIndexOf("/"),v=k>=0?S.slice(0,k+1):"",O=k>=0?S.slice(k+1):S,ie=eh(p,v||".");try{return a.vfs.list(ie).filter(X=>!X.startsWith(".")).filter(X=>X.startsWith(O)).map(X=>{let fe=Ra.posix.join(ie,X),_t=a.vfs.stat(fe).type==="directory"?"/":"";return`${v}${X}${_t}`}).sort()}catch{return[]}}function se(){let{start:S,end:k}=$(f,c),v=f.slice(S,c);if(v.length===0)return;let ie=f.slice(0,S).trim().length===0?P.filter(tt=>tt.startsWith(v)):[],X=M(v),fe=Array.from(new Set([...ie,...X])).sort();if(fe.length!==0){if(fe.length===1){let tt=fe[0],_t=tt.endsWith("/")?"":" ";f=`${f.slice(0,S)}${tt}${_t}${f.slice(k)}`,c=S+tt.length+_t.length,L();return}t.write(`\r
61
+ `),t.write(`${fe.join(" ")}\r
62
+ `),L()}}function Z(S){if(S.length===0)return;l.push(S),l.length>500&&(l=l.slice(l.length-500));let k=l.length>0?`${l.join(`
63
+ `)}
64
+ `:"";a.vfs.writeFile("/virtual-env-js/.bash_history",k)}function j(){let S=`/virtual-env-js/.lastlog/${e}.json`;if(!a.vfs.exists(S))return null;try{return JSON.parse(a.vfs.readFile(S))}catch{return null}}function te(S){let k="/virtual-env-js/.lastlog";a.vfs.exists(k)||a.vfs.mkdir(k,448);let v=`${k}/${e}.json`;a.vfs.writeFile(v,JSON.stringify({at:S,from:s}))}function oe(){let S=j(),k=new Date().toISOString();if(t.write(`Linux ${r} ${n.kernel} ${n.arch}\r
65
+ `),t.write(`\r
66
+ `),t.write(`The programs included with the Fortune GNU/Linux system are free software;\r
67
+ `),t.write(`the exact distribution terms for each program are described in the\r
68
+ `),t.write(`individual files in /usr/share/doc/*/copyright.\r
69
+ `),t.write(`\r
70
+ `),t.write(`Fortune GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent\r
71
+ `),t.write(`permitted by applicable law.\r
72
+ `),S){let v=new Date(S.at),O=Number.isNaN(v.getTime())?S.at:Bi(v);t.write(`Last login: ${O} from ${S.from||"unknown"}\r
73
+ `)}t.write(`\r
74
+ `),te(k)}oe(),L(),t.on("data",async S=>{if(_){_.process.stdin.write(S);return}if(b){let v=S.toString("utf8");for(let O=0;O<v.length;O+=1){let ie=v[O];if(ie===""){b=null,t.write(`^C\r
75
+ `),L();return}if(ie==="\x7F"||ie==="\b"){b.buffer=b.buffer.slice(0,-1);continue}if(ie==="\r"||ie===`
76
+ `){let X=b.buffer;b.buffer="";let fe=a.users.verifyPassword(b.username,X);await z(fe);return}ie>=" "&&(b.buffer+=ie)}return}let k=S.toString("utf8");for(let v=0;v<k.length;v+=1){let O=k[v];if(O===""){f="",c=0,h=null,g="",t.write(`bye\r
77
+ `),Z("bye"),await a.vfs.flushMirror(),t.write(`logout\r
78
+ `),t.exit(0),t.end();return}if(O===" "){se();continue}if(O==="\x1B"){let ie=k[v+1],X=k[v+2],fe=k[v+3];if(ie==="["&&X){if(X==="A"){v+=2,l.length>0&&(h===null?(g=f,h=l.length-1):h>0&&(h-=1),w(l[h]??""));continue}if(X==="B"){v+=2,h!==null&&(h<l.length-1?(h+=1,w(l[h]??"")):(h=null,w(g)));continue}if(X==="C"){v+=2,c<f.length&&(c+=1,t.write("\x1B[C"));continue}if(X==="D"){v+=2,c>0&&(c-=1,t.write("\x1B[D"));continue}if(X==="3"&&fe==="~"){v+=3,c<f.length&&(f=`${f.slice(0,c)}${f.slice(c+1)}`,L());continue}}}if(O===""){f="",c=0,h=null,g="",t.write(`^C\r
79
+ `),L();continue}if(O==="\r"||O===`
80
+ `){let ie=f.trim();if(f="",c=0,h=null,g="",t.write(`\r
81
+ `),ie.length>0){let X=await Promise.resolve(Qt(ie,e,r,"shell",p,a));if(Z(ie),X.openEditor){await V(X.openEditor.targetPath,X.openEditor.initialContent,X.openEditor.tempPath);return}if(X.openHtop){await y();return}if(X.sudoChallenge){H(X.sudoChallenge);return}if(X.clearScreen&&t.write("\x1B[2J\x1B[H"),X.stdout&&t.write(`${bi(X.stdout)}\r
82
+ `),X.stderr&&t.write(`${bi(X.stderr)}\r
83
+ `),X.closeSession){t.write(`logout\r
84
+ `),t.exit(X.exitCode??0),t.end();return}X.nextCwd&&(p=X.nextCwd),X.switchUser&&(e=X.switchUser,p=X.nextCwd??`/home/${e}`,a.users.updateSession(i,e,s),f="",c=0),await a.vfs.flushMirror()}L();continue}if(O==="\x7F"||O==="\b"){c>0&&(f=`${f.slice(0,c-1)}${f.slice(c)}`,c-=1,L());continue}U(O)}}),t.on("close",()=>{_&&(_.process.kill("SIGTERM"),_=null)})}function Zp(n){let t="/virtual-env-js/.bash_history";return n.exists(t)?n.readFile(t).split(`
85
+ `).map(r=>r.trim()).filter(r=>r.length>0):(n.writeFile(t,""),[])}var eA={kernel:"1.0.0+itsrealfortune+1-amd64",os:"Fortune GNU/Linux x64",arch:"x86_64"},xi=Wt("VirtualShell");function tA(){let n=process.env.SSH_MIMIC_AUTO_SUDO_NEW_USERS;return n?!["0","false","no","off"].includes(n.toLowerCase()):!0}var Br=class extends ch.EventEmitter{basePath=".";vfs;users;hostname;properties;initialized;constructor(t,e,r){super(),xi.mark("constructor"),this.hostname=t,this.properties=e||eA,this.basePath=r||".",this.vfs=new Ba(this.basePath),this.users=new _i(this.vfs,tA());let i=this.vfs,s=this.users;this.initialized=(async()=>{await i.restoreMirror(),await s.initialize(),this.emit("initialized")})()}async ensureInitialized(){xi.mark("ensureInitialized"),await this.initialized}addCommand(t,e,r){let i=t.trim().toLowerCase();if(i.length===0||/\s/.test(i))throw new Error("Command name must be non-empty and contain no spaces");Ac(Ec(i,e,r))}executeCommand(t,e,r){xi.mark("executeCommand"),Qt(t,e,this.hostname,"shell",r,this),this.emit("command",{command:t,user:e,cwd:r})}startInteractiveSession(t,e,r,i,s){xi.mark("startInteractiveSession"),this.emit("session:start",{user:e,sessionId:r,remoteAddress:i}),fh(this.properties,t,e,this.hostname,r,i,s,this)}getVfs(){return this?.vfs??null}getUsers(){return this?.users??null}getHostname(){return this?.hostname}writeFileAsUser(t,e,r){xi.mark("writeFileAsUser"),this.users.assertWriteWithinQuota(t,e,r),this.vfs.writeFile(e,r)}};Rr();function uh(n){return n.replace(/\r\n/g,`
86
+ `).replace(/\r/g,`
87
+ `).replace(/\n/g,`\r
88
+ `)}function lh(n,t,e,r,i){Promise.resolve(Qt(t,e,r,"exec",`/home/${e}`,i)).then(s=>{s.stdout&&n.write(`${uh(s.stdout)}\r
89
+ `),s.stderr&&n.stderr.write(`${uh(s.stderr)}\r
90
+ `),n.exit(s.exitCode??0),i.vfs.flushMirror(),n.end()}).catch(s=>{console.error("Exec error:",s),n.stderr.write(`Error: ${String(s)}\r
91
+ `),n.exit(1),n.end()})}var hh=require("node:crypto"),Wr=require("node:fs"),ws=require("node:path");function Is(n=process.cwd()){let t=(0,ws.resolve)(n,".ssh-mimic","host_rsa");if((0,Wr.existsSync)(t))return(0,Wr.readFileSync)(t,"utf8");let e=(0,hh.generateKeyPairSync)("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs1",format:"pem"},publicKeyEncoding:{type:"pkcs1",format:"pem"}}).privateKey;return(0,Wr.mkdirSync)((0,ws.dirname)(t),{recursive:!0}),(0,Wr.writeFileSync)(t,e,{mode:384}),e}var dh=require("node:events"),On=Xt(require("node:path"),1),gh=Xt(Ia(),1);var Ue={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},Un={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},va=Wt("SftpMimic"),Dn=class extends dh.EventEmitter{port;server;hostname;shell;vfs;users;nextHandleId=0;handles=new Map;constructor({port:t,hostname:e="typescript-vm",shell:r,vfs:i,users:s}){if(super(),va.mark("constructor"),this.port=t,this.server=null,this.hostname=e,this.shell=null,r)this.vfs=r.vfs,this.users=r.users,this.hostname=r.hostname,this.shell=r;else if(i&&s)this.vfs=i,this.users=s;else{let o=new Br(e);this.vfs=o.vfs,this.users=o.users,this.shell=o}}getVfs(){return this.shell?.vfs??this.vfs}getUsers(){return this.shell?.users??this.users}async start(){va.mark("start");let t=Is();return this.shell?await this.shell.ensureInitialized():await this.users.initialize(),this.server=new gh.Server({hostKeys:[t],ident:`SSH-2.0-${this.hostname}`},e=>{let r=["password","keyboard-interactive"],i="root",s=null,o="unknown";this.emit("client:connect"),e.on("error",f=>{console.error("[SFTP] Client error:",f)});let a=f=>{i=f,s=this.getUsers().registerSession(i,o).id;let c="/home";this.getVfs().exists(c)||this.getVfs().mkdir(c,493);let l=`/home/${i}`;this.getVfs().exists(l)||(this.getVfs().mkdir(l,493),this.getVfs().writeFile(`${l}/README.txt`,`Welcome to ${this.hostname}`),this.getVfs().flushMirror())};e.on("authentication",f=>{let c=f.username||"root";if(o=f.ip??o,console.log(`[SFTP] Auth attempt: user=${c}, method=${f.method}, ip=${o}`),f.method==="password"){if(!this.getUsers().verifyPassword(c,f.password??"")){this.emit("auth:failure",{username:c,remoteAddress:o}),f.reject(r);return}a(c),this.emit("auth:success",{username:i,remoteAddress:o}),f.accept();return}if(f.method==="keyboard-interactive"){let l=f;l.prompt([{prompt:"Password: ",echo:!1}],h=>{let g=h[0]??"";if(!this.getUsers().verifyPassword(c,g)){this.emit("auth:failure",{username:c,remoteAddress:o}),l.reject(r);return}a(c),this.emit("auth:success",{username:i,remoteAddress:o}),l.accept()});return}f.reject(r)}),e.on("close",()=>{this.getUsers().unregisterSession(s),this.emit("client:disconnect",{user:i}),s=null}),e.on("ready",()=>{e.on("session",(f,c)=>{let l=f();l.on("error",h=>{console.error(`[SFTP] Session error for user=${i}:`,h)}),l.on("sftp",h=>{let g=h();this.attachSftpHandlers(g,i)})})})}),new Promise((e,r)=>{this.server?.once("error",i=>r(i)),this.server?.listen(this.port,"0.0.0.0",()=>{let i=this.server?.address(),s=i&&typeof i=="object"&&"port"in i?i.port:this.port;console.log(`SFTP Mimic listening on port ${s}`),this.emit("start",{port:s}),e(s)})})}stop(){va.mark("stop"),this.server&&this.server.close(()=>{console.log("SFTP Mimic stopped"),this.emit("stop")})}resolveRequestPath(t,e){let r=`/home/${e}`;if(!t||t===".")return r;if(!t.startsWith("/")){let i=On.posix.join(r,t);return On.posix.normalize(i)}return On.posix.normalize(t)}isPathWithinHome(t,e){let r=`/home/${e}`,i=On.posix.normalize(t);return!!(i===r||i.startsWith(`${r}/`))}createAttrs(t){let e=t.mode&511;return{mode:(t.type==="directory"?16384:32768)|e,size:t.type==="file"?t.size:0,uid:0,gid:0,atime:Math.floor(t.createdAt.getTime()/1e3),mtime:Math.floor(t.updatedAt.getTime()/1e3)}}openHandle(t){let e=++this.nextHandleId,r=Buffer.alloc(4);return r.writeUInt32BE(e,0),this.handles.set(r.toString("hex"),t),r}getHandle(t){return this.handles.get(t.toString("hex"))}closeHandle(t){this.handles.delete(t.toString("hex"))}attachSftpHandlers(t,e){let r=()=>this.getVfs(),i=()=>this.getUsers();t.on("OPEN",(s,o,a)=>{let f=this.resolveRequestPath(o,e);if(!this.isPathWithinHome(f,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, path=${f}`),t.status(s,Ue.PERMISSION_DENIED);return}let c=a,l=!!(c&Un.READ),h=!!(c&Un.WRITE||c&Un.APPEND),g=!!(c&Un.CREAT),p=!!(c&Un.TRUNC);try{if(!r().exists(f)){if(!g){t.status(s,Ue.NO_SUCH_FILE);return}r().writeFile(f,Buffer.alloc(0))}if(r().stat(f).type==="directory"){t.status(s,Ue.FAILURE);return}let b=Buffer.from(r().readFile(f),"utf8");if(p&&(b=Buffer.alloc(0)),c&Un.APPEND){let P=this.openHandle({type:"file",path:f,flags:c,buffer:b});t.handle(s,P);return}let R=this.openHandle({type:"file",path:f,flags:c,buffer:b});t.handle(s,R)}catch(_){console.error("SFTP OPEN error:",_),t.status(s,Ue.FAILURE)}}),t.on("READ",(s,o,a,f)=>{let c=this.getHandle(o);if(!c||c.type!=="file"){t.status(s,Ue.FAILURE);return}if(a>=c.buffer.length){t.status(s,Ue.EOF);return}let l=c.buffer.slice(a,a+f);t.data(s,l)}),t.on("WRITE",async(s,o,a,f)=>{let c=this.getHandle(o);if(!c||c.type!=="file"){t.status(s,Ue.FAILURE);return}let l=a+f.length;if(l>c.buffer.length){let h=Buffer.alloc(l);c.buffer.copy(h,0,0,c.buffer.length),c.buffer=h}f.copy(c.buffer,a),t.status(s,Ue.OK)}),t.on("FSTAT",(s,o)=>{let a=this.getHandle(o);if(!a){t.status(s,Ue.FAILURE);return}try{let f=r().stat(a.path);t.attrs(s,this.createAttrs(f))}catch{t.status(s,Ue.FAILURE)}}),t.on("CLOSE",async(s,o)=>{let a=this.getHandle(o);if(!a){t.status(s,Ue.FAILURE);return}if(a.type==="file")try{i().assertWriteWithinQuota(e,a.path,a.buffer),r().writeFile(a.path,a.buffer),r().flushMirror()}catch(f){console.error("SFTP CLOSE write error:",f),t.status(s,Ue.FAILURE),this.closeHandle(o);return}this.closeHandle(o),t.status(s,Ue.OK)}),t.on("OPENDIR",(s,o)=>{let a=this.resolveRequestPath(o,e);if(!this.isPathWithinHome(a,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, path=${a}`),t.status(s,Ue.PERMISSION_DENIED);return}try{if(r().stat(a).type!=="directory"){t.status(s,Ue.FAILURE);return}let c=r().list(a),l=this.openHandle({type:"dir",path:a,entries:c,index:0});t.handle(s,l)}catch{t.status(s,Ue.NO_SUCH_FILE)}}),t.on("READDIR",(s,o)=>{let a=this.getHandle(o);if(!a||a.type!=="dir"){t.status(s,Ue.FAILURE);return}if(a.index>=a.entries.length){t.status(s,Ue.EOF);return}let f=a.entries[a.index++],c=On.posix.join(a.path,f),l=r().stat(c),h=this.createAttrs(l),g=`${l.type==="directory"?"d":"-"}${(l.mode&511).toString(8)} ${f}`;return t.name(s,[{filename:f,longname:g,attrs:h}])}),t.on("STAT",(s,o)=>{let a=this.resolveRequestPath(o,e);if(!this.isPathWithinHome(a,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, path=${a}`),t.status(s,Ue.PERMISSION_DENIED);return}try{let f=r().stat(a);t.attrs(s,this.createAttrs(f))}catch{t.status(s,Ue.NO_SUCH_FILE)}}),t.on("LSTAT",(s,o)=>{let a=this.resolveRequestPath(o,e);if(!this.isPathWithinHome(a,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, path=${a}`),t.status(s,Ue.PERMISSION_DENIED);return}try{let f=r().stat(a);t.attrs(s,this.createAttrs(f))}catch{t.status(s,Ue.NO_SUCH_FILE)}}),t.on("FSETSTAT",(s,o,a)=>{let f=this.getHandle(o);if(!f){t.status(s,Ue.FAILURE);return}try{a.mode!==void 0&&r().chmod(f.path,a.mode),t.status(s,Ue.OK)}catch{t.status(s,Ue.FAILURE)}}),t.on("SETSTAT",(s,o,a)=>{let f=this.resolveRequestPath(o,e);if(!this.isPathWithinHome(f,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, path=${f}`),t.status(s,Ue.PERMISSION_DENIED);return}try{a.mode!==void 0&&r().chmod(f,a.mode),t.status(s,Ue.OK)}catch{t.status(s,Ue.FAILURE)}}),t.on("REALPATH",(s,o)=>{let a=this.resolveRequestPath(o,e);if(!this.isPathWithinHome(a,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, path=${a}`),t.status(s,Ue.PERMISSION_DENIED);return}t.name(s,[{filename:a,longname:a,attrs:{mode:16877,uid:0,gid:0,size:0,atime:0,mtime:0}}])}),t.on("MKDIR",(s,o)=>{let a=this.resolveRequestPath(o,e);if(!this.isPathWithinHome(a,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, path=${a}`),t.status(s,Ue.PERMISSION_DENIED);return}try{r().mkdir(a,493),r().flushMirror(),t.status(s,Ue.OK)}catch{t.status(s,Ue.FAILURE)}}),t.on("RMDIR",(s,o)=>{let a=this.resolveRequestPath(o,e);if(!this.isPathWithinHome(a,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, path=${a}`),t.status(s,Ue.PERMISSION_DENIED);return}try{r().remove(a,{recursive:!1}),r().flushMirror(),t.status(s,Ue.OK)}catch{t.status(s,Ue.FAILURE)}}),t.on("REMOVE",(s,o)=>{let a=this.resolveRequestPath(o,e);if(!this.isPathWithinHome(a,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, path=${a}`),t.status(s,Ue.PERMISSION_DENIED);return}try{r().remove(a,{recursive:!1}),r().flushMirror(),t.status(s,Ue.OK)}catch{t.status(s,Ue.FAILURE)}}),t.on("RENAME",(s,o,a)=>{let f=this.resolveRequestPath(o,e),c=this.resolveRequestPath(a,e);if(!this.isPathWithinHome(f,e)||!this.isPathWithinHome(c,e)){console.warn(`[SFTP] Path traversal attempt blocked: user=${e}, from=${f}, to=${c}`),t.status(s,Ue.PERMISSION_DENIED);return}try{r().move(f,c),r().flushMirror(),t.status(s,Ue.OK)}catch{t.status(s,Ue.FAILURE)}}),t.on("READLINK",s=>{t.status(s,Ue.OP_UNSUPPORTED)}),t.on("SYMLINK",s=>{t.status(s,Ue.OP_UNSUPPORTED)}),t.on("error",s=>{console.error(`[SFTP] Stream error for user=${e}:`,s)}),t.on("close",()=>{console.log(`[SFTP] Stream closed for user=${e}`),this.handles.clear()}),t.on("end",()=>{console.log(`[SFTP] end event for user=${e}`),this.handles.clear()}),t.on("END",()=>{console.log(`[SFTP] END event for user=${e}`),this.handles.clear()})}};var Na=Wt("SshMimic"),Si=class extends ph.EventEmitter{port;server;shell;shellHostname;constructor({port:t,hostname:e="typescript-vm",shell:r=new Br(e)}){super(),Na.mark("constructor"),this.port=t,this.shellHostname=e,this.server=null,this.shell=r}async start(){Na.mark("start");let t=this.shell,e=Is();return await t.ensureInitialized(),this.server=new Ah.Server({hostKeys:[e],ident:`SSH-2.0-${t.hostname}`},r=>{let i="root",s="unknown",o=null;this.emit("client:connect"),r.on("authentication",a=>{if(a.method==="password"){let f=a.username||"root";if(s=a.ip??s,!t.users.hasPassword(f)){console.log(`User ${f} has no password set, allowing login without verification`),i=f,o=t.users.registerSession(i,s).id,this.emit("auth:success",{username:i,remoteAddress:s});let l=`/home/${i}`;t.vfs.exists(l)||(t.vfs.mkdir(l,493),t.vfs.writeFile(`${l}/README.txt`,`Welcome to ${t?.hostname??this.shellHostname}`),t.vfs.flushMirror()),a.accept();return}if(!a.password||a.password===""||!t.users.verifyPassword(f,a.password)){this.emit("auth:failure",{username:f,remoteAddress:s}),a.reject();return}i=f,o=t.users.registerSession(i,s).id,this.emit("auth:success",{username:i,remoteAddress:s});let c=`/home/${i}`;t.vfs.exists(c)||(t.vfs.mkdir(c,493),t.vfs.writeFile(`${c}/README.txt`,`Welcome to ${t?.hostname??this.shellHostname}`),t.vfs.flushMirror()),a.accept();return}a.reject()}),r.on("close",()=>{t.users.unregisterSession(o),this.emit("client:disconnect",{user:i}),o=null}),r.on("ready",()=>{r.on("session",a=>{let f=a(),c={cols:80,rows:24};f.on("pty",(l,h,g)=>{c.cols=g?.cols??c.cols,c.rows=g?.rows??c.rows,l()}),f.on("window-change",(l,h,g)=>{c.cols=g?.cols??c.cols,c.rows=g?.rows??c.rows}),f.on("shell",l=>{let h=l();t?.startInteractiveSession(h,i,o,s,c)}),f.on("exec",(l,h,g)=>{let p=l();p&&lh(p,g.command.trim(),i,t.hostname,t)})})})}),new Promise((r,i)=>{this.server?.once("error",s=>i(s)),this.server?.listen(this.port,"0.0.0.0",()=>{console.log(`SSH Mimic listening on port ${this.port}`),this.emit("start",{port:this.port}),r(this.port)})})}stop(){Na.mark("stop"),this.server&&this.server.close(()=>{console.log("SSH Mimic stopped"),this.emit("stop")})}};Nt();var Pa=process.env.SSH_MIMIC_HOSTNAME??"typescript-vm",Ta=new Br(Pa);Ta.addCommand("demo",[],()=>({stdout:"This is a demo command. It does nothing useful.",exitCode:0}));new Si({port:2222,hostname:Pa,shell:Ta}).start().catch(n=>{console.error("Failed to start SSH Mimic:",n),process.exit(1)});new Dn({port:2223,hostname:Pa,shell:Ta}).start().catch(n=>{console.error("Failed to start SFTP 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)});
92
+ //# sourceMappingURL=standalone.js.map