typescript-virtual-container 1.4.2 → 1.4.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.
Files changed (603) hide show
  1. package/.vscode/settings.json +2 -1
  2. package/README.md +209 -54
  3. package/benchmark-results.txt +21 -21
  4. package/builds/self-standalone.js +196 -189
  5. package/builds/self-standalone.js.map +4 -4
  6. package/builds/standalone-wo-sftp.js +167 -160
  7. package/builds/standalone-wo-sftp.js.map +4 -4
  8. package/builds/standalone.js +169 -162
  9. package/builds/standalone.js.map +4 -4
  10. package/builds/web-full-api.min.js +5 -5
  11. package/builds/web-full-api.min.js.map +3 -3
  12. package/builds/web.min.js +5 -5
  13. package/builds/web.min.js.map +3 -3
  14. package/bun.lock +4 -6
  15. package/examples/web.min.js +5 -5
  16. package/package.json +4 -3
  17. package/src/Honeypot/index.d.ts.map +1 -0
  18. package/src/SSHClient/index.d.ts.map +1 -0
  19. package/src/SSHMimic/exec.d.ts.map +1 -0
  20. package/src/SSHMimic/executor.d.ts.map +1 -0
  21. package/src/SSHMimic/hostKey.d.ts.map +1 -0
  22. package/src/SSHMimic/index.d.ts.map +1 -0
  23. package/src/SSHMimic/loginBanner.d.ts.map +1 -0
  24. package/src/SSHMimic/loginFormat.d.ts.map +1 -0
  25. package/src/SSHMimic/prompt.d.ts.map +1 -0
  26. package/src/SSHMimic/sftp.d.ts.map +1 -0
  27. package/src/VirtualFileSystem/binaryPack.d.ts.map +1 -0
  28. package/{dist → src}/VirtualFileSystem/index.d.ts +47 -0
  29. package/src/VirtualFileSystem/index.d.ts.map +1 -0
  30. package/{dist → src}/VirtualFileSystem/index.js +159 -0
  31. package/src/VirtualFileSystem/index.ts +173 -8
  32. package/src/VirtualFileSystem/internalTypes.d.ts.map +1 -0
  33. package/src/VirtualFileSystem/path.d.ts.map +1 -0
  34. package/src/VirtualPackageManager/index.d.ts.map +1 -0
  35. package/{dist → src}/VirtualShell/index.d.ts +29 -0
  36. package/src/VirtualShell/index.d.ts.map +1 -0
  37. package/{dist → src}/VirtualShell/index.js +29 -0
  38. package/src/VirtualShell/index.ts +36 -0
  39. package/src/VirtualShell/shell.d.ts.map +1 -0
  40. package/src/VirtualShell/shellParser.d.ts.map +1 -0
  41. package/{dist → src}/VirtualShell/shellParser.js +30 -2
  42. package/src/VirtualShell/shellParser.ts +29 -3
  43. package/src/VirtualUserManager/index.d.ts.map +1 -0
  44. package/src/bun.d.ts +1 -0
  45. package/src/commands/adduser.d.ts.map +1 -0
  46. package/src/commands/alias.d.ts.map +1 -0
  47. package/src/commands/apt.d.ts.map +1 -0
  48. package/src/commands/awk.d.ts.map +1 -0
  49. package/{dist → src}/commands/awk.js +1 -2
  50. package/src/commands/awk.ts +1 -2
  51. package/src/commands/base64.d.ts.map +1 -0
  52. package/src/commands/cat.d.ts.map +1 -0
  53. package/src/commands/cd.d.ts.map +1 -0
  54. package/{dist → src}/commands/cd.js +2 -2
  55. package/src/commands/cd.ts +2 -2
  56. package/src/commands/chmod.d.ts.map +1 -0
  57. package/src/commands/clear.d.ts.map +1 -0
  58. package/src/commands/command-helpers.d.ts.map +1 -0
  59. package/src/commands/cp.d.ts.map +1 -0
  60. package/src/commands/curl.d.ts.map +1 -0
  61. package/src/commands/cut.d.ts.map +1 -0
  62. package/src/commands/date.d.ts.map +1 -0
  63. package/src/commands/declare.d.ts.map +1 -0
  64. package/src/commands/deluser.d.ts.map +1 -0
  65. package/src/commands/df.d.ts.map +1 -0
  66. package/src/commands/diff.d.ts.map +1 -0
  67. package/src/commands/dpkg.d.ts.map +1 -0
  68. package/src/commands/du.d.ts.map +1 -0
  69. package/src/commands/echo.d.ts.map +1 -0
  70. package/src/commands/env.d.ts.map +1 -0
  71. package/src/commands/exit.d.ts.map +1 -0
  72. package/src/commands/export.d.ts.map +1 -0
  73. package/{dist → src}/commands/export.js +5 -3
  74. package/src/commands/export.ts +5 -3
  75. package/src/commands/find.d.ts.map +1 -0
  76. package/src/commands/free.d.ts.map +1 -0
  77. package/src/commands/grep.d.ts.map +1 -0
  78. package/src/commands/groups.d.ts.map +1 -0
  79. package/src/commands/gzip.d.ts.map +1 -0
  80. package/src/commands/head.d.ts.map +1 -0
  81. package/src/commands/help.d.ts.map +1 -0
  82. package/src/commands/helpers.d.ts.map +1 -0
  83. package/{dist → src}/commands/helpers.js +3 -0
  84. package/src/commands/helpers.ts +3 -0
  85. package/src/commands/history.d.ts.map +1 -0
  86. package/src/commands/hostname.d.ts.map +1 -0
  87. package/src/commands/htop.d.ts.map +1 -0
  88. package/src/commands/id.d.ts.map +1 -0
  89. package/src/commands/index.d.ts.map +1 -0
  90. package/src/commands/kill.d.ts.map +1 -0
  91. package/src/commands/ln.d.ts.map +1 -0
  92. package/src/commands/ls.d.ts.map +1 -0
  93. package/src/commands/ls.js +200 -0
  94. package/src/commands/ls.ts +210 -41
  95. package/src/commands/lsb-release.d.ts.map +1 -0
  96. package/src/commands/man.d.ts.map +1 -0
  97. package/src/commands/mkdir.d.ts.map +1 -0
  98. package/src/commands/mv.d.ts.map +1 -0
  99. package/src/commands/nano.d.ts.map +1 -0
  100. package/src/commands/neofetch.d.ts.map +1 -0
  101. package/src/commands/node.d.ts.map +1 -0
  102. package/src/commands/npm.d.ts.map +1 -0
  103. package/src/commands/passwd.d.ts.map +1 -0
  104. package/src/commands/ping.d.ts.map +1 -0
  105. package/src/commands/printf.d.ts.map +1 -0
  106. package/src/commands/ps.d.ts.map +1 -0
  107. package/src/commands/pwd.d.ts.map +1 -0
  108. package/src/commands/python.d.ts.map +1 -0
  109. package/src/commands/read.d.ts.map +1 -0
  110. package/src/commands/registry.d.ts.map +1 -0
  111. package/{dist → src}/commands/registry.js +2 -0
  112. package/src/commands/registry.ts +2 -0
  113. package/src/commands/rm.d.ts.map +1 -0
  114. package/src/commands/runtime.d.ts.map +1 -0
  115. package/{dist → src}/commands/runtime.js +64 -3
  116. package/src/commands/runtime.ts +86 -6
  117. package/src/commands/sed.d.ts.map +1 -0
  118. package/src/commands/seq.d.ts +4 -0
  119. package/src/commands/seq.d.ts.map +1 -0
  120. package/src/commands/seq.js +50 -0
  121. package/src/commands/seq.ts +43 -0
  122. package/src/commands/set.d.ts.map +1 -0
  123. package/src/commands/sh.d.ts +3 -0
  124. package/src/commands/sh.d.ts.map +1 -0
  125. package/{dist → src}/commands/sh.js +158 -11
  126. package/src/commands/sh.ts +148 -20
  127. package/src/commands/shift.d.ts.map +1 -0
  128. package/src/commands/sleep.d.ts.map +1 -0
  129. package/src/commands/sort.d.ts.map +1 -0
  130. package/src/commands/source.d.ts.map +1 -0
  131. package/src/commands/stat.d.ts.map +1 -0
  132. package/src/commands/su.d.ts.map +1 -0
  133. package/src/commands/sudo.d.ts.map +1 -0
  134. package/src/commands/tail.d.ts.map +1 -0
  135. package/src/commands/tar.d.ts.map +1 -0
  136. package/src/commands/tee.d.ts.map +1 -0
  137. package/src/commands/test.d.ts.map +1 -0
  138. package/src/commands/test.ts +4 -2
  139. package/src/commands/touch.d.ts.map +1 -0
  140. package/src/commands/tr.d.ts.map +1 -0
  141. package/src/commands/tree.d.ts.map +1 -0
  142. package/src/commands/true.d.ts.map +1 -0
  143. package/src/commands/type.d.ts.map +1 -0
  144. package/src/commands/uname.d.ts.map +1 -0
  145. package/src/commands/uniq.d.ts.map +1 -0
  146. package/src/commands/unset.d.ts.map +1 -0
  147. package/src/commands/uptime.d.ts.map +1 -0
  148. package/src/commands/wc.d.ts.map +1 -0
  149. package/{dist → src}/commands/wc.js +1 -1
  150. package/src/commands/wc.ts +1 -1
  151. package/src/commands/wget.d.ts.map +1 -0
  152. package/src/commands/which.d.ts.map +1 -0
  153. package/src/commands/who.d.ts.map +1 -0
  154. package/src/commands/whoami.d.ts.map +1 -0
  155. package/src/commands/xargs.d.ts.map +1 -0
  156. package/src/index.d.ts.map +1 -0
  157. package/src/modules/linuxRootfs.d.ts +59 -0
  158. package/src/modules/linuxRootfs.d.ts.map +1 -0
  159. package/src/modules/linuxRootfs.js +619 -0
  160. package/src/modules/linuxRootfs.ts +420 -231
  161. package/src/modules/neofetch.d.ts.map +1 -0
  162. package/src/modules/shellInteractive.d.ts.map +1 -0
  163. package/src/modules/shellRuntime.d.ts.map +1 -0
  164. package/{dist → src}/self-standalone.d.ts.map +1 -1
  165. package/src/standalone-wo-sftp.d.ts.map +1 -0
  166. package/{dist → src}/standalone.d.ts.map +1 -1
  167. package/{dist → src}/types/commands.d.ts +1 -1
  168. package/src/types/commands.d.ts.map +1 -0
  169. package/src/types/commands.ts +1 -1
  170. package/{dist → src}/types/pipeline.d.ts +6 -0
  171. package/src/types/pipeline.d.ts.map +1 -0
  172. package/src/types/pipeline.ts +6 -0
  173. package/src/types/streams.d.ts.map +1 -0
  174. package/{dist → src}/types/vfs.d.ts +15 -0
  175. package/src/types/vfs.d.ts.map +1 -0
  176. package/src/types/vfs.ts +17 -0
  177. package/{dist → src}/utils/expand.d.ts +11 -2
  178. package/src/utils/expand.d.ts.map +1 -0
  179. package/src/utils/expand.js +476 -0
  180. package/src/utils/expand.ts +281 -28
  181. package/src/utils/perfLogger.d.ts.map +1 -0
  182. package/src/utils/tokenize.d.ts.map +1 -0
  183. package/{dist → src}/utils/tokenize.js +40 -0
  184. package/src/utils/tokenize.ts +20 -0
  185. package/src/utils/vfsDiff.d.ts.map +1 -0
  186. package/src/web-api.d.ts.map +1 -0
  187. package/src/web-full.d.ts.map +1 -0
  188. package/src/web.d.ts.map +1 -0
  189. package/tests/command-helpers.test.d.ts +2 -0
  190. package/tests/command-helpers.test.d.ts.map +1 -0
  191. package/tests/command-helpers.test.js +92 -0
  192. package/tests/command-helpers.test.ts +80 -0
  193. package/tests/commands-admin-net.test.d.ts +2 -0
  194. package/tests/commands-admin-net.test.d.ts.map +1 -0
  195. package/tests/commands-admin-net.test.js +353 -0
  196. package/tests/commands-admin-net.test.ts +441 -0
  197. package/tests/commands-advanced.test.d.ts +2 -0
  198. package/tests/commands-advanced.test.d.ts.map +1 -0
  199. package/tests/commands-advanced.test.js +378 -0
  200. package/tests/commands-advanced.test.ts +456 -0
  201. package/tests/commands-core.test.d.ts +2 -0
  202. package/tests/commands-core.test.d.ts.map +1 -0
  203. package/tests/commands-core.test.js +477 -0
  204. package/tests/commands-core.test.ts +562 -0
  205. package/tests/commands-missing.test.d.ts +2 -0
  206. package/tests/commands-missing.test.d.ts.map +1 -0
  207. package/tests/commands-missing.test.js +470 -0
  208. package/tests/commands-missing.test.ts +570 -0
  209. package/tests/commands-specific-units.test.d.ts +2 -0
  210. package/tests/commands-specific-units.test.d.ts.map +1 -0
  211. package/tests/commands-specific-units.test.js +264 -0
  212. package/tests/commands-specific-units.test.ts +327 -0
  213. package/tests/commands-text-sys.test.d.ts +2 -0
  214. package/tests/commands-text-sys.test.d.ts.map +1 -0
  215. package/tests/commands-text-sys.test.js +366 -0
  216. package/tests/commands-text-sys.test.ts +445 -0
  217. package/tests/expand.test.d.ts +2 -0
  218. package/tests/expand.test.d.ts.map +1 -0
  219. package/tests/expand.test.js +138 -0
  220. package/tests/expand.test.ts +170 -0
  221. package/tests/helpers.test.d.ts +2 -0
  222. package/tests/helpers.test.d.ts.map +1 -0
  223. package/tests/helpers.test.js +52 -0
  224. package/tests/helpers.test.ts +75 -0
  225. package/tests/new-features.test.d.ts +2 -0
  226. package/tests/new-features.test.d.ts.map +1 -0
  227. package/tests/new-features.test.js +850 -0
  228. package/tests/parser-executor.test.d.ts +2 -0
  229. package/tests/parser-executor.test.d.ts.map +1 -0
  230. package/tests/parser-executor.test.js +25 -0
  231. package/tests/sftp.test.d.ts +2 -0
  232. package/tests/sftp.test.d.ts.map +1 -0
  233. package/tests/sftp.test.js +246 -0
  234. package/tests/ssh-exec.test.d.ts +2 -0
  235. package/tests/ssh-exec.test.d.ts.map +1 -0
  236. package/tests/ssh-exec.test.js +39 -0
  237. package/tests/test-helper.d.ts +56 -0
  238. package/tests/test-helper.d.ts.map +1 -0
  239. package/tests/test-helper.js +71 -0
  240. package/tests/test-helper.ts +79 -0
  241. package/tests/users.test.d.ts +2 -0
  242. package/tests/users.test.d.ts.map +1 -0
  243. package/tests/users.test.js +71 -0
  244. package/tests/web.test.d.ts +2 -0
  245. package/tests/web.test.d.ts.map +1 -0
  246. package/tests/web.test.js +149 -0
  247. package/tsconfig.json +2 -4
  248. package/dist/Honeypot/index.d.ts.map +0 -1
  249. package/dist/SSHClient/index.d.ts.map +0 -1
  250. package/dist/SSHMimic/exec.d.ts.map +0 -1
  251. package/dist/SSHMimic/executor.d.ts.map +0 -1
  252. package/dist/SSHMimic/hostKey.d.ts.map +0 -1
  253. package/dist/SSHMimic/index.d.ts.map +0 -1
  254. package/dist/SSHMimic/loginBanner.d.ts.map +0 -1
  255. package/dist/SSHMimic/loginFormat.d.ts.map +0 -1
  256. package/dist/SSHMimic/prompt.d.ts.map +0 -1
  257. package/dist/SSHMimic/sftp.d.ts.map +0 -1
  258. package/dist/VirtualFileSystem/binaryPack.d.ts.map +0 -1
  259. package/dist/VirtualFileSystem/index.d.ts.map +0 -1
  260. package/dist/VirtualFileSystem/internalTypes.d.ts.map +0 -1
  261. package/dist/VirtualFileSystem/path.d.ts.map +0 -1
  262. package/dist/VirtualPackageManager/index.d.ts.map +0 -1
  263. package/dist/VirtualShell/index.d.ts.map +0 -1
  264. package/dist/VirtualShell/shell.d.ts.map +0 -1
  265. package/dist/VirtualShell/shellParser.d.ts.map +0 -1
  266. package/dist/VirtualUserManager/index.d.ts.map +0 -1
  267. package/dist/commands/adduser.d.ts.map +0 -1
  268. package/dist/commands/alias.d.ts.map +0 -1
  269. package/dist/commands/apt.d.ts.map +0 -1
  270. package/dist/commands/awk.d.ts.map +0 -1
  271. package/dist/commands/base64.d.ts.map +0 -1
  272. package/dist/commands/cat.d.ts.map +0 -1
  273. package/dist/commands/cd.d.ts.map +0 -1
  274. package/dist/commands/chmod.d.ts.map +0 -1
  275. package/dist/commands/clear.d.ts.map +0 -1
  276. package/dist/commands/command-helpers.d.ts.map +0 -1
  277. package/dist/commands/cp.d.ts.map +0 -1
  278. package/dist/commands/curl.d.ts.map +0 -1
  279. package/dist/commands/cut.d.ts.map +0 -1
  280. package/dist/commands/date.d.ts.map +0 -1
  281. package/dist/commands/declare.d.ts.map +0 -1
  282. package/dist/commands/deluser.d.ts.map +0 -1
  283. package/dist/commands/df.d.ts.map +0 -1
  284. package/dist/commands/diff.d.ts.map +0 -1
  285. package/dist/commands/dpkg.d.ts.map +0 -1
  286. package/dist/commands/du.d.ts.map +0 -1
  287. package/dist/commands/echo.d.ts.map +0 -1
  288. package/dist/commands/env.d.ts.map +0 -1
  289. package/dist/commands/exit.d.ts.map +0 -1
  290. package/dist/commands/export.d.ts.map +0 -1
  291. package/dist/commands/find.d.ts.map +0 -1
  292. package/dist/commands/free.d.ts.map +0 -1
  293. package/dist/commands/grep.d.ts.map +0 -1
  294. package/dist/commands/groups.d.ts.map +0 -1
  295. package/dist/commands/gzip.d.ts.map +0 -1
  296. package/dist/commands/head.d.ts.map +0 -1
  297. package/dist/commands/help.d.ts.map +0 -1
  298. package/dist/commands/helpers.d.ts.map +0 -1
  299. package/dist/commands/history.d.ts.map +0 -1
  300. package/dist/commands/hostname.d.ts.map +0 -1
  301. package/dist/commands/htop.d.ts.map +0 -1
  302. package/dist/commands/id.d.ts.map +0 -1
  303. package/dist/commands/index.d.ts.map +0 -1
  304. package/dist/commands/kill.d.ts.map +0 -1
  305. package/dist/commands/ln.d.ts.map +0 -1
  306. package/dist/commands/ls.d.ts.map +0 -1
  307. package/dist/commands/ls.js +0 -67
  308. package/dist/commands/lsb-release.d.ts.map +0 -1
  309. package/dist/commands/man.d.ts.map +0 -1
  310. package/dist/commands/mkdir.d.ts.map +0 -1
  311. package/dist/commands/mv.d.ts.map +0 -1
  312. package/dist/commands/nano.d.ts.map +0 -1
  313. package/dist/commands/neofetch.d.ts.map +0 -1
  314. package/dist/commands/node.d.ts.map +0 -1
  315. package/dist/commands/npm.d.ts.map +0 -1
  316. package/dist/commands/passwd.d.ts.map +0 -1
  317. package/dist/commands/ping.d.ts.map +0 -1
  318. package/dist/commands/printf.d.ts.map +0 -1
  319. package/dist/commands/ps.d.ts.map +0 -1
  320. package/dist/commands/pwd.d.ts.map +0 -1
  321. package/dist/commands/python.d.ts.map +0 -1
  322. package/dist/commands/read.d.ts.map +0 -1
  323. package/dist/commands/registry.d.ts.map +0 -1
  324. package/dist/commands/rm.d.ts.map +0 -1
  325. package/dist/commands/runtime.d.ts.map +0 -1
  326. package/dist/commands/sed.d.ts.map +0 -1
  327. package/dist/commands/set.d.ts.map +0 -1
  328. package/dist/commands/sh.d.ts +0 -9
  329. package/dist/commands/sh.d.ts.map +0 -1
  330. package/dist/commands/shift.d.ts.map +0 -1
  331. package/dist/commands/sleep.d.ts.map +0 -1
  332. package/dist/commands/sort.d.ts.map +0 -1
  333. package/dist/commands/source.d.ts.map +0 -1
  334. package/dist/commands/stat.d.ts.map +0 -1
  335. package/dist/commands/su.d.ts.map +0 -1
  336. package/dist/commands/sudo.d.ts.map +0 -1
  337. package/dist/commands/tail.d.ts.map +0 -1
  338. package/dist/commands/tar.d.ts.map +0 -1
  339. package/dist/commands/tee.d.ts.map +0 -1
  340. package/dist/commands/test.d.ts.map +0 -1
  341. package/dist/commands/touch.d.ts.map +0 -1
  342. package/dist/commands/tr.d.ts.map +0 -1
  343. package/dist/commands/tree.d.ts.map +0 -1
  344. package/dist/commands/true.d.ts.map +0 -1
  345. package/dist/commands/type.d.ts.map +0 -1
  346. package/dist/commands/uname.d.ts.map +0 -1
  347. package/dist/commands/uniq.d.ts.map +0 -1
  348. package/dist/commands/unset.d.ts.map +0 -1
  349. package/dist/commands/uptime.d.ts.map +0 -1
  350. package/dist/commands/wc.d.ts.map +0 -1
  351. package/dist/commands/wget.d.ts.map +0 -1
  352. package/dist/commands/which.d.ts.map +0 -1
  353. package/dist/commands/who.d.ts.map +0 -1
  354. package/dist/commands/whoami.d.ts.map +0 -1
  355. package/dist/commands/xargs.d.ts.map +0 -1
  356. package/dist/index.d.ts.map +0 -1
  357. package/dist/modules/linuxRootfs.d.ts +0 -41
  358. package/dist/modules/linuxRootfs.d.ts.map +0 -1
  359. package/dist/modules/linuxRootfs.js +0 -440
  360. package/dist/modules/neofetch.d.ts.map +0 -1
  361. package/dist/modules/shellInteractive.d.ts.map +0 -1
  362. package/dist/modules/shellRuntime.d.ts.map +0 -1
  363. package/dist/standalone-wo-sftp.d.ts.map +0 -1
  364. package/dist/types/commands.d.ts.map +0 -1
  365. package/dist/types/pipeline.d.ts.map +0 -1
  366. package/dist/types/streams.d.ts.map +0 -1
  367. package/dist/types/vfs.d.ts.map +0 -1
  368. package/dist/utils/expand.d.ts.map +0 -1
  369. package/dist/utils/expand.js +0 -183
  370. package/dist/utils/perfLogger.d.ts.map +0 -1
  371. package/dist/utils/tokenize.d.ts.map +0 -1
  372. package/dist/utils/vfsDiff.d.ts.map +0 -1
  373. package/dist/web-api.d.ts.map +0 -1
  374. package/dist/web-full.d.ts.map +0 -1
  375. package/dist/web.d.ts.map +0 -1
  376. package/tests/bun-test-shim.ts +0 -9
  377. /package/{dist → src}/Honeypot/index.d.ts +0 -0
  378. /package/{dist → src}/Honeypot/index.js +0 -0
  379. /package/{dist → src}/SSHClient/index.d.ts +0 -0
  380. /package/{dist → src}/SSHClient/index.js +0 -0
  381. /package/{dist → src}/SSHMimic/exec.d.ts +0 -0
  382. /package/{dist → src}/SSHMimic/exec.js +0 -0
  383. /package/{dist → src}/SSHMimic/executor.d.ts +0 -0
  384. /package/{dist → src}/SSHMimic/executor.js +0 -0
  385. /package/{dist → src}/SSHMimic/hostKey.d.ts +0 -0
  386. /package/{dist → src}/SSHMimic/hostKey.js +0 -0
  387. /package/{dist → src}/SSHMimic/index.d.ts +0 -0
  388. /package/{dist → src}/SSHMimic/index.js +0 -0
  389. /package/{dist → src}/SSHMimic/loginBanner.d.ts +0 -0
  390. /package/{dist → src}/SSHMimic/loginBanner.js +0 -0
  391. /package/{dist → src}/SSHMimic/loginFormat.d.ts +0 -0
  392. /package/{dist → src}/SSHMimic/loginFormat.js +0 -0
  393. /package/{dist → src}/SSHMimic/prompt.d.ts +0 -0
  394. /package/{dist → src}/SSHMimic/prompt.js +0 -0
  395. /package/{dist → src}/SSHMimic/sftp.d.ts +0 -0
  396. /package/{dist → src}/SSHMimic/sftp.js +0 -0
  397. /package/{dist → src}/VirtualFileSystem/binaryPack.d.ts +0 -0
  398. /package/{dist → src}/VirtualFileSystem/binaryPack.js +0 -0
  399. /package/{dist → src}/VirtualFileSystem/internalTypes.d.ts +0 -0
  400. /package/{dist → src}/VirtualFileSystem/internalTypes.js +0 -0
  401. /package/{dist → src}/VirtualFileSystem/path.d.ts +0 -0
  402. /package/{dist → src}/VirtualFileSystem/path.js +0 -0
  403. /package/{dist → src}/VirtualPackageManager/index.d.ts +0 -0
  404. /package/{dist → src}/VirtualPackageManager/index.js +0 -0
  405. /package/{dist → src}/VirtualShell/shell.d.ts +0 -0
  406. /package/{dist → src}/VirtualShell/shell.js +0 -0
  407. /package/{dist → src}/VirtualShell/shellParser.d.ts +0 -0
  408. /package/{dist → src}/VirtualUserManager/index.d.ts +0 -0
  409. /package/{dist → src}/VirtualUserManager/index.js +0 -0
  410. /package/{dist → src}/commands/adduser.d.ts +0 -0
  411. /package/{dist → src}/commands/adduser.js +0 -0
  412. /package/{dist → src}/commands/alias.d.ts +0 -0
  413. /package/{dist → src}/commands/alias.js +0 -0
  414. /package/{dist → src}/commands/apt.d.ts +0 -0
  415. /package/{dist → src}/commands/apt.js +0 -0
  416. /package/{dist → src}/commands/awk.d.ts +0 -0
  417. /package/{dist → src}/commands/base64.d.ts +0 -0
  418. /package/{dist → src}/commands/base64.js +0 -0
  419. /package/{dist → src}/commands/cat.d.ts +0 -0
  420. /package/{dist → src}/commands/cat.js +0 -0
  421. /package/{dist → src}/commands/cd.d.ts +0 -0
  422. /package/{dist → src}/commands/chmod.d.ts +0 -0
  423. /package/{dist → src}/commands/chmod.js +0 -0
  424. /package/{dist → src}/commands/clear.d.ts +0 -0
  425. /package/{dist → src}/commands/clear.js +0 -0
  426. /package/{dist → src}/commands/command-helpers.d.ts +0 -0
  427. /package/{dist → src}/commands/command-helpers.js +0 -0
  428. /package/{dist → src}/commands/cp.d.ts +0 -0
  429. /package/{dist → src}/commands/cp.js +0 -0
  430. /package/{dist → src}/commands/curl.d.ts +0 -0
  431. /package/{dist → src}/commands/curl.js +0 -0
  432. /package/{dist → src}/commands/cut.d.ts +0 -0
  433. /package/{dist → src}/commands/cut.js +0 -0
  434. /package/{dist → src}/commands/date.d.ts +0 -0
  435. /package/{dist → src}/commands/date.js +0 -0
  436. /package/{dist → src}/commands/declare.d.ts +0 -0
  437. /package/{dist → src}/commands/declare.js +0 -0
  438. /package/{dist → src}/commands/deluser.d.ts +0 -0
  439. /package/{dist → src}/commands/deluser.js +0 -0
  440. /package/{dist → src}/commands/df.d.ts +0 -0
  441. /package/{dist → src}/commands/df.js +0 -0
  442. /package/{dist → src}/commands/diff.d.ts +0 -0
  443. /package/{dist → src}/commands/diff.js +0 -0
  444. /package/{dist → src}/commands/dpkg.d.ts +0 -0
  445. /package/{dist → src}/commands/dpkg.js +0 -0
  446. /package/{dist → src}/commands/du.d.ts +0 -0
  447. /package/{dist → src}/commands/du.js +0 -0
  448. /package/{dist → src}/commands/echo.d.ts +0 -0
  449. /package/{dist → src}/commands/echo.js +0 -0
  450. /package/{dist → src}/commands/env.d.ts +0 -0
  451. /package/{dist → src}/commands/env.js +0 -0
  452. /package/{dist → src}/commands/exit.d.ts +0 -0
  453. /package/{dist → src}/commands/exit.js +0 -0
  454. /package/{dist → src}/commands/export.d.ts +0 -0
  455. /package/{dist → src}/commands/find.d.ts +0 -0
  456. /package/{dist → src}/commands/find.js +0 -0
  457. /package/{dist → src}/commands/free.d.ts +0 -0
  458. /package/{dist → src}/commands/free.js +0 -0
  459. /package/{dist → src}/commands/grep.d.ts +0 -0
  460. /package/{dist → src}/commands/grep.js +0 -0
  461. /package/{dist → src}/commands/groups.d.ts +0 -0
  462. /package/{dist → src}/commands/groups.js +0 -0
  463. /package/{dist → src}/commands/gzip.d.ts +0 -0
  464. /package/{dist → src}/commands/gzip.js +0 -0
  465. /package/{dist → src}/commands/head.d.ts +0 -0
  466. /package/{dist → src}/commands/head.js +0 -0
  467. /package/{dist → src}/commands/help.d.ts +0 -0
  468. /package/{dist → src}/commands/help.js +0 -0
  469. /package/{dist → src}/commands/helpers.d.ts +0 -0
  470. /package/{dist → src}/commands/history.d.ts +0 -0
  471. /package/{dist → src}/commands/history.js +0 -0
  472. /package/{dist → src}/commands/hostname.d.ts +0 -0
  473. /package/{dist → src}/commands/hostname.js +0 -0
  474. /package/{dist → src}/commands/htop.d.ts +0 -0
  475. /package/{dist → src}/commands/htop.js +0 -0
  476. /package/{dist → src}/commands/id.d.ts +0 -0
  477. /package/{dist → src}/commands/id.js +0 -0
  478. /package/{dist → src}/commands/index.d.ts +0 -0
  479. /package/{dist → src}/commands/index.js +0 -0
  480. /package/{dist → src}/commands/kill.d.ts +0 -0
  481. /package/{dist → src}/commands/kill.js +0 -0
  482. /package/{dist → src}/commands/ln.d.ts +0 -0
  483. /package/{dist → src}/commands/ln.js +0 -0
  484. /package/{dist → src}/commands/ls.d.ts +0 -0
  485. /package/{dist → src}/commands/lsb-release.d.ts +0 -0
  486. /package/{dist → src}/commands/lsb-release.js +0 -0
  487. /package/{dist → src}/commands/man.d.ts +0 -0
  488. /package/{dist → src}/commands/man.js +0 -0
  489. /package/{dist → src}/commands/mkdir.d.ts +0 -0
  490. /package/{dist → src}/commands/mkdir.js +0 -0
  491. /package/{dist → src}/commands/mv.d.ts +0 -0
  492. /package/{dist → src}/commands/mv.js +0 -0
  493. /package/{dist → src}/commands/nano.d.ts +0 -0
  494. /package/{dist → src}/commands/nano.js +0 -0
  495. /package/{dist → src}/commands/neofetch.d.ts +0 -0
  496. /package/{dist → src}/commands/neofetch.js +0 -0
  497. /package/{dist → src}/commands/node.d.ts +0 -0
  498. /package/{dist → src}/commands/node.js +0 -0
  499. /package/{dist → src}/commands/npm.d.ts +0 -0
  500. /package/{dist → src}/commands/npm.js +0 -0
  501. /package/{dist → src}/commands/passwd.d.ts +0 -0
  502. /package/{dist → src}/commands/passwd.js +0 -0
  503. /package/{dist → src}/commands/ping.d.ts +0 -0
  504. /package/{dist → src}/commands/ping.js +0 -0
  505. /package/{dist → src}/commands/printf.d.ts +0 -0
  506. /package/{dist → src}/commands/printf.js +0 -0
  507. /package/{dist → src}/commands/ps.d.ts +0 -0
  508. /package/{dist → src}/commands/ps.js +0 -0
  509. /package/{dist → src}/commands/pwd.d.ts +0 -0
  510. /package/{dist → src}/commands/pwd.js +0 -0
  511. /package/{dist → src}/commands/python.d.ts +0 -0
  512. /package/{dist → src}/commands/python.js +0 -0
  513. /package/{dist → src}/commands/read.d.ts +0 -0
  514. /package/{dist → src}/commands/read.js +0 -0
  515. /package/{dist → src}/commands/registry.d.ts +0 -0
  516. /package/{dist → src}/commands/rm.d.ts +0 -0
  517. /package/{dist → src}/commands/rm.js +0 -0
  518. /package/{dist → src}/commands/runtime.d.ts +0 -0
  519. /package/{dist → src}/commands/sed.d.ts +0 -0
  520. /package/{dist → src}/commands/sed.js +0 -0
  521. /package/{dist → src}/commands/set.d.ts +0 -0
  522. /package/{dist → src}/commands/set.js +0 -0
  523. /package/{dist → src}/commands/shift.d.ts +0 -0
  524. /package/{dist → src}/commands/shift.js +0 -0
  525. /package/{dist → src}/commands/sleep.d.ts +0 -0
  526. /package/{dist → src}/commands/sleep.js +0 -0
  527. /package/{dist → src}/commands/sort.d.ts +0 -0
  528. /package/{dist → src}/commands/sort.js +0 -0
  529. /package/{dist → src}/commands/source.d.ts +0 -0
  530. /package/{dist → src}/commands/source.js +0 -0
  531. /package/{dist → src}/commands/stat.d.ts +0 -0
  532. /package/{dist → src}/commands/stat.js +0 -0
  533. /package/{dist → src}/commands/su.d.ts +0 -0
  534. /package/{dist → src}/commands/su.js +0 -0
  535. /package/{dist → src}/commands/sudo.d.ts +0 -0
  536. /package/{dist → src}/commands/sudo.js +0 -0
  537. /package/{dist → src}/commands/tail.d.ts +0 -0
  538. /package/{dist → src}/commands/tail.js +0 -0
  539. /package/{dist → src}/commands/tar.d.ts +0 -0
  540. /package/{dist → src}/commands/tar.js +0 -0
  541. /package/{dist → src}/commands/tee.d.ts +0 -0
  542. /package/{dist → src}/commands/tee.js +0 -0
  543. /package/{dist → src}/commands/test.d.ts +0 -0
  544. /package/{dist → src}/commands/test.js +0 -0
  545. /package/{dist → src}/commands/touch.d.ts +0 -0
  546. /package/{dist → src}/commands/touch.js +0 -0
  547. /package/{dist → src}/commands/tr.d.ts +0 -0
  548. /package/{dist → src}/commands/tr.js +0 -0
  549. /package/{dist → src}/commands/tree.d.ts +0 -0
  550. /package/{dist → src}/commands/tree.js +0 -0
  551. /package/{dist → src}/commands/true.d.ts +0 -0
  552. /package/{dist → src}/commands/true.js +0 -0
  553. /package/{dist → src}/commands/type.d.ts +0 -0
  554. /package/{dist → src}/commands/type.js +0 -0
  555. /package/{dist → src}/commands/uname.d.ts +0 -0
  556. /package/{dist → src}/commands/uname.js +0 -0
  557. /package/{dist → src}/commands/uniq.d.ts +0 -0
  558. /package/{dist → src}/commands/uniq.js +0 -0
  559. /package/{dist → src}/commands/unset.d.ts +0 -0
  560. /package/{dist → src}/commands/unset.js +0 -0
  561. /package/{dist → src}/commands/uptime.d.ts +0 -0
  562. /package/{dist → src}/commands/uptime.js +0 -0
  563. /package/{dist → src}/commands/wc.d.ts +0 -0
  564. /package/{dist → src}/commands/wget.d.ts +0 -0
  565. /package/{dist → src}/commands/wget.js +0 -0
  566. /package/{dist → src}/commands/which.d.ts +0 -0
  567. /package/{dist → src}/commands/which.js +0 -0
  568. /package/{dist → src}/commands/who.d.ts +0 -0
  569. /package/{dist → src}/commands/who.js +0 -0
  570. /package/{dist → src}/commands/whoami.d.ts +0 -0
  571. /package/{dist → src}/commands/whoami.js +0 -0
  572. /package/{dist → src}/commands/xargs.d.ts +0 -0
  573. /package/{dist → src}/commands/xargs.js +0 -0
  574. /package/{dist → src}/index.d.ts +0 -0
  575. /package/{dist → src}/index.js +0 -0
  576. /package/{dist → src}/modules/neofetch.d.ts +0 -0
  577. /package/{dist → src}/modules/neofetch.js +0 -0
  578. /package/{dist → src}/modules/shellInteractive.d.ts +0 -0
  579. /package/{dist → src}/modules/shellInteractive.js +0 -0
  580. /package/{dist → src}/modules/shellRuntime.d.ts +0 -0
  581. /package/{dist → src}/modules/shellRuntime.js +0 -0
  582. /package/{dist → src}/self-standalone.d.ts +0 -0
  583. /package/{dist → src}/self-standalone.js +0 -0
  584. /package/{dist → src}/standalone-wo-sftp.d.ts +0 -0
  585. /package/{dist → src}/standalone-wo-sftp.js +0 -0
  586. /package/{dist → src}/standalone.d.ts +0 -0
  587. /package/{dist → src}/standalone.js +0 -0
  588. /package/{dist → src}/types/commands.js +0 -0
  589. /package/{dist → src}/types/pipeline.js +0 -0
  590. /package/{dist → src}/types/streams.d.ts +0 -0
  591. /package/{dist → src}/types/streams.js +0 -0
  592. /package/{dist → src}/types/vfs.js +0 -0
  593. /package/{dist → src}/utils/perfLogger.d.ts +0 -0
  594. /package/{dist → src}/utils/perfLogger.js +0 -0
  595. /package/{dist → src}/utils/tokenize.d.ts +0 -0
  596. /package/{dist → src}/utils/vfsDiff.d.ts +0 -0
  597. /package/{dist → src}/utils/vfsDiff.js +0 -0
  598. /package/{dist → src}/web-api.d.ts +0 -0
  599. /package/{dist → src}/web-api.js +0 -0
  600. /package/{dist → src}/web-full.d.ts +0 -0
  601. /package/{dist → src}/web-full.js +0 -0
  602. /package/{dist → src}/web.d.ts +0 -0
  603. /package/{dist → src}/web.js +0 -0
@@ -1,30 +1,30 @@
1
- "use strict";var Yh=Object.create;var bc=Object.defineProperty;var jh=Object.getOwnPropertyDescriptor;var Xh=Object.getOwnPropertyNames;var Jh=Object.getPrototypeOf,Zh=Object.prototype.hasOwnProperty;var at=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var ep=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Xh(t))!Zh.call(n,s)&&s!==e&&bc(n,s,{get:()=>t[s],enumerable:!(r=jh(t,s))||r.enumerable});return n};var Vt=(n,t,e)=>(e=n!=null?Yh(Jh(n)):{},ep(t||!n||!n.__esModule?bc(e,"default",{value:n,enumerable:!0}):e,n));var Hi=at((hE,xc)=>{xc.exports={newInvalidAsn1Error:function(n){var t=new Error;return t.name="InvalidAsn1Error",t.message=n||"",t}}});var Qi=at((pE,Sc)=>{Sc.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 io=at((gE,wc)=>{"use strict";var Wi=require("buffer"),xr=Wi.Buffer,fn={},ln;for(ln in Wi)Wi.hasOwnProperty(ln)&&(ln==="SlowBuffer"||ln==="Buffer"||(fn[ln]=Wi[ln]));var Sr=fn.Buffer={};for(ln in xr)xr.hasOwnProperty(ln)&&(ln==="allocUnsafe"||ln==="allocUnsafeSlow"||(Sr[ln]=xr[ln]));fn.Buffer.prototype=xr.prototype;(!Sr.from||Sr.from===Uint8Array.from)&&(Sr.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 xr(n,t,e)});Sr.alloc||(Sr.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=xr(n);return!t||t.length===0?r.fill(0):typeof e=="string"?r.fill(t,e):r.fill(t),r});if(!fn.kStringMaxLength)try{fn.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}fn.constants||(fn.constants={MAX_LENGTH:fn.kMaxLength},fn.kStringMaxLength&&(fn.constants.MAX_STRING_LENGTH=fn.kStringMaxLength));wc.exports=fn});var kc=at((mE,Cc)=>{var tp=require("assert"),Ic=io().Buffer,ti=Qi(),np=Hi(),wr=np.newInvalidAsn1Error;function Gt(n){if(!n||!Ic.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(Gt.prototype,"length",{enumerable:!0,get:function(){return this._len}});Object.defineProperty(Gt.prototype,"offset",{enumerable:!0,get:function(){return this._offset}});Object.defineProperty(Gt.prototype,"remain",{get:function(){return this._size-this._offset}});Object.defineProperty(Gt.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}});Gt.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};Gt.prototype.peek=function(){return this.readByte(!0)};Gt.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 wr("Indefinite length not supported");if(t>4)throw wr("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};Gt.prototype.readSequence=function(n){var t=this.peek();if(t===null)return null;if(n!==void 0&&n!==t)throw wr("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)};Gt.prototype.readInt=function(){return this._readTag(ti.Integer)};Gt.prototype.readBoolean=function(){return this._readTag(ti.Boolean)!==0};Gt.prototype.readEnumeration=function(){return this._readTag(ti.Enumeration)};Gt.prototype.readString=function(n,t){n||(n=ti.OctetString);var e=this.peek();if(e===null)return null;if(e!==n)throw wr("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?Ic.alloc(0):"";var s=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?s:s.toString("utf8")};Gt.prototype.readOID=function(n){n||(n=ti.OID);var t=this.readString(n,!0);if(t===null)return null;for(var e=[],r=0,s=0;s<t.length;s++){var i=t[s]&255;r<<=7,r+=i&127,(i&128)===0&&(e.push(r),r=0)}return r=e.shift(),e.unshift(r%40),e.unshift(r/40>>0),e.join(".")};Gt.prototype._readTag=function(n){tp.ok(n!==void 0);var t=this.peek();if(t===null)return null;if(t!==n)throw wr("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 wr("Integer too long: "+this.length);if(this.length>this._size-e)return null;this._offset=e;for(var r=this._buf[this._offset],s=0,i=0;i<this.length;i++)s<<=8,s|=this._buf[this._offset++]&255;return(r&128)===128&&i!==4&&(s-=1<<i*8),s>>0};Cc.exports=Gt});var Bc=at((AE,vc)=>{var Mn=require("assert"),qi=io().Buffer,Fn=Qi(),rp=Hi(),Ki=rp.newInvalidAsn1Error,ip={size:1024,growthFactor:8};function sp(n,t){Mn.ok(n),Mn.equal(typeof n,"object"),Mn.ok(t),Mn.equal(typeof t,"object");var e=Object.getOwnPropertyNames(n);return e.forEach(function(r){if(!t[r]){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s)}}),t}function qt(n){n=sp(ip,n||{}),this._buf=qi.alloc(n.size||1024),this._size=this._buf.length,this._offset=0,this._options=n,this._seq=[]}Object.defineProperty(qt.prototype,"buffer",{get:function(){if(this._seq.length)throw Ki(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}});qt.prototype.writeByte=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=n};qt.prototype.writeInt=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");typeof t!="number"&&(t=Fn.Integer);for(var e=4;((n&4286578688)===0||(n&4286578688)===-8388608)&&e>1;)e--,n<<=8;if(e>4)throw Ki("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};qt.prototype.writeNull=function(){this.writeByte(Fn.Null),this.writeByte(0)};qt.prototype.writeEnumeration=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");return typeof t!="number"&&(t=Fn.Enumeration),this.writeInt(n,t)};qt.prototype.writeBoolean=function(n,t){if(typeof n!="boolean")throw new TypeError("argument must be a Boolean");typeof t!="number"&&(t=Fn.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=n?255:0};qt.prototype.writeString=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string (was: "+typeof n+")");typeof t!="number"&&(t=Fn.OctetString);var e=qi.byteLength(n);this.writeByte(t),this.writeLength(e),e&&(this._ensure(e),this._buf.write(n,this._offset),this._offset+=e)};qt.prototype.writeBuffer=function(n,t){if(typeof t!="number")throw new TypeError("tag must be a number");if(!qi.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};qt.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)})};qt.prototype.writeOID=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string");if(typeof t!="number"&&(t=Fn.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(n))throw new Error("argument is not a valid OID string");function e(o,a){a<128?o.push(a):a<16384?(o.push(a>>>7|128),o.push(a&127)):a<2097152?(o.push(a>>>14|128),o.push((a>>>7|128)&255),o.push(a&127)):a<268435456?(o.push(a>>>21|128),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127)):(o.push((a>>>28|128)&255),o.push((a>>>21|128)&255),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127))}var r=n.split("."),s=[];s.push(parseInt(r[0],10)*40+parseInt(r[1],10)),r.slice(2).forEach(function(o){e(s,parseInt(o,10))});var i=this;this._ensure(2+s.length),this.writeByte(t),this.writeLength(s.length),s.forEach(function(o){i.writeByte(o)})};qt.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 Ki("Length too long (> 4 bytes)")};qt.prototype.startSequence=function(n){typeof n!="number"&&(n=Fn.Sequence|Fn.Constructor),this.writeByte(n),this._seq.push(this._offset),this._ensure(3),this._offset+=3};qt.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 Ki("Sequence too long")};qt.prototype._shift=function(n,t,e){Mn.ok(n!==void 0),Mn.ok(t!==void 0),Mn.ok(e),this._buf.copy(this._buf,n+e,n,n+t),this._offset+=e};qt.prototype._ensure=function(n){if(Mn.ok(n),this._size-this._offset<n){var t=this._size*this._options.growthFactor;t-this._offset<n&&(t+=n);var e=qi.alloc(t);this._buf.copy(e,0,0,this._offset),this._buf=e,this._size=t}};vc.exports=qt});var Rc=at((EE,zi)=>{var so=Hi(),oo=Qi(),op=kc(),ap=Bc();zi.exports={Reader:op,Writer:ap};for(Vi in oo)oo.hasOwnProperty(Vi)&&(zi.exports[Vi]=oo[Vi]);var Vi;for(Gi in so)so.hasOwnProperty(Gi)&&(zi.exports[Gi]=so[Gi]);var Gi});var ni=at((_E,Nc)=>{var ao=Rc();Nc.exports={Ber:ao,BerReader:ao.Reader,BerWriter:ao.Writer}});var Pc=at((yE,Yi)=>{(function(n){"use strict";var t=function(g){var A,m=new Float64Array(16);if(g)for(A=0;A<g.length;A++)m[A]=g[A];return m},e=function(){throw new Error("no PRNG")},r=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var i=t(),o=t([1]),a=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),f=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]),u=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),h=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(g,A,m,d){g[A]=m>>24&255,g[A+1]=m>>16&255,g[A+2]=m>>8&255,g[A+3]=m&255,g[A+4]=d>>24&255,g[A+5]=d>>16&255,g[A+6]=d>>8&255,g[A+7]=d&255}function y(g,A,m,d,_){var L,M=0;for(L=0;L<_;L++)M|=g[A+L]^m[d+L];return(1&M-1>>>8)-1}function E(g,A,m,d){return y(g,A,m,d,16)}function x(g,A,m,d){return y(g,A,m,d,32)}function k(g,A,m,d){for(var _=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,L=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,M=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,J=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ae=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,me=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,he=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,tt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,ge=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Te=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Le=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,Fe=m[16]&255|(m[17]&255)<<8|(m[18]&255)<<16|(m[19]&255)<<24,Me=m[20]&255|(m[21]&255)<<8|(m[22]&255)<<16|(m[23]&255)<<24,Ue=m[24]&255|(m[25]&255)<<8|(m[26]&255)<<16|(m[27]&255)<<24,$e=m[28]&255|(m[29]&255)<<8|(m[30]&255)<<16|(m[31]&255)<<24,De=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,Ae=_,be=L,pe=M,Ee=J,_e=ae,de=me,W=he,q=tt,re=ge,X=Te,Z=Le,oe=Fe,Ce=Me,He=Ue,We=$e,Qe=De,w,Ke=0;Ke<20;Ke+=2)w=Ae+Ce|0,_e^=w<<7|w>>>25,w=_e+Ae|0,re^=w<<9|w>>>23,w=re+_e|0,Ce^=w<<13|w>>>19,w=Ce+re|0,Ae^=w<<18|w>>>14,w=de+be|0,X^=w<<7|w>>>25,w=X+de|0,He^=w<<9|w>>>23,w=He+X|0,be^=w<<13|w>>>19,w=be+He|0,de^=w<<18|w>>>14,w=Z+W|0,We^=w<<7|w>>>25,w=We+Z|0,pe^=w<<9|w>>>23,w=pe+We|0,W^=w<<13|w>>>19,w=W+pe|0,Z^=w<<18|w>>>14,w=Qe+oe|0,Ee^=w<<7|w>>>25,w=Ee+Qe|0,q^=w<<9|w>>>23,w=q+Ee|0,oe^=w<<13|w>>>19,w=oe+q|0,Qe^=w<<18|w>>>14,w=Ae+Ee|0,be^=w<<7|w>>>25,w=be+Ae|0,pe^=w<<9|w>>>23,w=pe+be|0,Ee^=w<<13|w>>>19,w=Ee+pe|0,Ae^=w<<18|w>>>14,w=de+_e|0,W^=w<<7|w>>>25,w=W+de|0,q^=w<<9|w>>>23,w=q+W|0,_e^=w<<13|w>>>19,w=_e+q|0,de^=w<<18|w>>>14,w=Z+X|0,oe^=w<<7|w>>>25,w=oe+Z|0,re^=w<<9|w>>>23,w=re+oe|0,X^=w<<13|w>>>19,w=X+re|0,Z^=w<<18|w>>>14,w=Qe+We|0,Ce^=w<<7|w>>>25,w=Ce+Qe|0,He^=w<<9|w>>>23,w=He+Ce|0,We^=w<<13|w>>>19,w=We+He|0,Qe^=w<<18|w>>>14;Ae=Ae+_|0,be=be+L|0,pe=pe+M|0,Ee=Ee+J|0,_e=_e+ae|0,de=de+me|0,W=W+he|0,q=q+tt|0,re=re+ge|0,X=X+Te|0,Z=Z+Le|0,oe=oe+Fe|0,Ce=Ce+Me|0,He=He+Ue|0,We=We+$e|0,Qe=Qe+De|0,g[0]=Ae>>>0&255,g[1]=Ae>>>8&255,g[2]=Ae>>>16&255,g[3]=Ae>>>24&255,g[4]=be>>>0&255,g[5]=be>>>8&255,g[6]=be>>>16&255,g[7]=be>>>24&255,g[8]=pe>>>0&255,g[9]=pe>>>8&255,g[10]=pe>>>16&255,g[11]=pe>>>24&255,g[12]=Ee>>>0&255,g[13]=Ee>>>8&255,g[14]=Ee>>>16&255,g[15]=Ee>>>24&255,g[16]=_e>>>0&255,g[17]=_e>>>8&255,g[18]=_e>>>16&255,g[19]=_e>>>24&255,g[20]=de>>>0&255,g[21]=de>>>8&255,g[22]=de>>>16&255,g[23]=de>>>24&255,g[24]=W>>>0&255,g[25]=W>>>8&255,g[26]=W>>>16&255,g[27]=W>>>24&255,g[28]=q>>>0&255,g[29]=q>>>8&255,g[30]=q>>>16&255,g[31]=q>>>24&255,g[32]=re>>>0&255,g[33]=re>>>8&255,g[34]=re>>>16&255,g[35]=re>>>24&255,g[36]=X>>>0&255,g[37]=X>>>8&255,g[38]=X>>>16&255,g[39]=X>>>24&255,g[40]=Z>>>0&255,g[41]=Z>>>8&255,g[42]=Z>>>16&255,g[43]=Z>>>24&255,g[44]=oe>>>0&255,g[45]=oe>>>8&255,g[46]=oe>>>16&255,g[47]=oe>>>24&255,g[48]=Ce>>>0&255,g[49]=Ce>>>8&255,g[50]=Ce>>>16&255,g[51]=Ce>>>24&255,g[52]=He>>>0&255,g[53]=He>>>8&255,g[54]=He>>>16&255,g[55]=He>>>24&255,g[56]=We>>>0&255,g[57]=We>>>8&255,g[58]=We>>>16&255,g[59]=We>>>24&255,g[60]=Qe>>>0&255,g[61]=Qe>>>8&255,g[62]=Qe>>>16&255,g[63]=Qe>>>24&255}function D(g,A,m,d){for(var _=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,L=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,M=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,J=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ae=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,me=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,he=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,tt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,ge=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Te=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Le=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,Fe=m[16]&255|(m[17]&255)<<8|(m[18]&255)<<16|(m[19]&255)<<24,Me=m[20]&255|(m[21]&255)<<8|(m[22]&255)<<16|(m[23]&255)<<24,Ue=m[24]&255|(m[25]&255)<<8|(m[26]&255)<<16|(m[27]&255)<<24,$e=m[28]&255|(m[29]&255)<<8|(m[30]&255)<<16|(m[31]&255)<<24,De=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,Ae=_,be=L,pe=M,Ee=J,_e=ae,de=me,W=he,q=tt,re=ge,X=Te,Z=Le,oe=Fe,Ce=Me,He=Ue,We=$e,Qe=De,w,Ke=0;Ke<20;Ke+=2)w=Ae+Ce|0,_e^=w<<7|w>>>25,w=_e+Ae|0,re^=w<<9|w>>>23,w=re+_e|0,Ce^=w<<13|w>>>19,w=Ce+re|0,Ae^=w<<18|w>>>14,w=de+be|0,X^=w<<7|w>>>25,w=X+de|0,He^=w<<9|w>>>23,w=He+X|0,be^=w<<13|w>>>19,w=be+He|0,de^=w<<18|w>>>14,w=Z+W|0,We^=w<<7|w>>>25,w=We+Z|0,pe^=w<<9|w>>>23,w=pe+We|0,W^=w<<13|w>>>19,w=W+pe|0,Z^=w<<18|w>>>14,w=Qe+oe|0,Ee^=w<<7|w>>>25,w=Ee+Qe|0,q^=w<<9|w>>>23,w=q+Ee|0,oe^=w<<13|w>>>19,w=oe+q|0,Qe^=w<<18|w>>>14,w=Ae+Ee|0,be^=w<<7|w>>>25,w=be+Ae|0,pe^=w<<9|w>>>23,w=pe+be|0,Ee^=w<<13|w>>>19,w=Ee+pe|0,Ae^=w<<18|w>>>14,w=de+_e|0,W^=w<<7|w>>>25,w=W+de|0,q^=w<<9|w>>>23,w=q+W|0,_e^=w<<13|w>>>19,w=_e+q|0,de^=w<<18|w>>>14,w=Z+X|0,oe^=w<<7|w>>>25,w=oe+Z|0,re^=w<<9|w>>>23,w=re+oe|0,X^=w<<13|w>>>19,w=X+re|0,Z^=w<<18|w>>>14,w=Qe+We|0,Ce^=w<<7|w>>>25,w=Ce+Qe|0,He^=w<<9|w>>>23,w=He+Ce|0,We^=w<<13|w>>>19,w=We+He|0,Qe^=w<<18|w>>>14;g[0]=Ae>>>0&255,g[1]=Ae>>>8&255,g[2]=Ae>>>16&255,g[3]=Ae>>>24&255,g[4]=de>>>0&255,g[5]=de>>>8&255,g[6]=de>>>16&255,g[7]=de>>>24&255,g[8]=Z>>>0&255,g[9]=Z>>>8&255,g[10]=Z>>>16&255,g[11]=Z>>>24&255,g[12]=Qe>>>0&255,g[13]=Qe>>>8&255,g[14]=Qe>>>16&255,g[15]=Qe>>>24&255,g[16]=W>>>0&255,g[17]=W>>>8&255,g[18]=W>>>16&255,g[19]=W>>>24&255,g[20]=q>>>0&255,g[21]=q>>>8&255,g[22]=q>>>16&255,g[23]=q>>>24&255,g[24]=re>>>0&255,g[25]=re>>>8&255,g[26]=re>>>16&255,g[27]=re>>>24&255,g[28]=X>>>0&255,g[29]=X>>>8&255,g[30]=X>>>16&255,g[31]=X>>>24&255}function H(g,A,m,d){k(g,A,m,d)}function C(g,A,m,d){D(g,A,m,d)}var F=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function V(g,A,m,d,_,L,M){var J=new Uint8Array(16),ae=new Uint8Array(64),me,he;for(he=0;he<16;he++)J[he]=0;for(he=0;he<8;he++)J[he]=L[he];for(;_>=64;){for(H(ae,J,M,F),he=0;he<64;he++)g[A+he]=m[d+he]^ae[he];for(me=1,he=8;he<16;he++)me=me+(J[he]&255)|0,J[he]=me&255,me>>>=8;_-=64,A+=64,d+=64}if(_>0)for(H(ae,J,M,F),he=0;he<_;he++)g[A+he]=m[d+he]^ae[he];return 0}function N(g,A,m,d,_){var L=new Uint8Array(16),M=new Uint8Array(64),J,ae;for(ae=0;ae<16;ae++)L[ae]=0;for(ae=0;ae<8;ae++)L[ae]=d[ae];for(;m>=64;){for(H(M,L,_,F),ae=0;ae<64;ae++)g[A+ae]=M[ae];for(J=1,ae=8;ae<16;ae++)J=J+(L[ae]&255)|0,L[ae]=J&255,J>>>=8;m-=64,A+=64}if(m>0)for(H(M,L,_,F),ae=0;ae<m;ae++)g[A+ae]=M[ae];return 0}function b(g,A,m,d,_){var L=new Uint8Array(32);C(L,d,_,F);for(var M=new Uint8Array(8),J=0;J<8;J++)M[J]=d[J+16];return N(g,A,m,M,L)}function S(g,A,m,d,_,L,M){var J=new Uint8Array(32);C(J,L,M,F);for(var ae=new Uint8Array(8),me=0;me<8;me++)ae[me]=L[me+16];return V(g,A,m,d,_,ae,J)}var I=function(g){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var A,m,d,_,L,M,J,ae;A=g[0]&255|(g[1]&255)<<8,this.r[0]=A&8191,m=g[2]&255|(g[3]&255)<<8,this.r[1]=(A>>>13|m<<3)&8191,d=g[4]&255|(g[5]&255)<<8,this.r[2]=(m>>>10|d<<6)&7939,_=g[6]&255|(g[7]&255)<<8,this.r[3]=(d>>>7|_<<9)&8191,L=g[8]&255|(g[9]&255)<<8,this.r[4]=(_>>>4|L<<12)&255,this.r[5]=L>>>1&8190,M=g[10]&255|(g[11]&255)<<8,this.r[6]=(L>>>14|M<<2)&8191,J=g[12]&255|(g[13]&255)<<8,this.r[7]=(M>>>11|J<<5)&8065,ae=g[14]&255|(g[15]&255)<<8,this.r[8]=(J>>>8|ae<<8)&8191,this.r[9]=ae>>>5&127,this.pad[0]=g[16]&255|(g[17]&255)<<8,this.pad[1]=g[18]&255|(g[19]&255)<<8,this.pad[2]=g[20]&255|(g[21]&255)<<8,this.pad[3]=g[22]&255|(g[23]&255)<<8,this.pad[4]=g[24]&255|(g[25]&255)<<8,this.pad[5]=g[26]&255|(g[27]&255)<<8,this.pad[6]=g[28]&255|(g[29]&255)<<8,this.pad[7]=g[30]&255|(g[31]&255)<<8};I.prototype.blocks=function(g,A,m){for(var d=this.fin?0:2048,_,L,M,J,ae,me,he,tt,ge,Te,Le,Fe,Me,Ue,$e,De,Ae,be,pe,Ee=this.h[0],_e=this.h[1],de=this.h[2],W=this.h[3],q=this.h[4],re=this.h[5],X=this.h[6],Z=this.h[7],oe=this.h[8],Ce=this.h[9],He=this.r[0],We=this.r[1],Qe=this.r[2],w=this.r[3],Ke=this.r[4],nt=this.r[5],rt=this.r[6],qe=this.r[7],Je=this.r[8],Ze=this.r[9];m>=16;)_=g[A+0]&255|(g[A+1]&255)<<8,Ee+=_&8191,L=g[A+2]&255|(g[A+3]&255)<<8,_e+=(_>>>13|L<<3)&8191,M=g[A+4]&255|(g[A+5]&255)<<8,de+=(L>>>10|M<<6)&8191,J=g[A+6]&255|(g[A+7]&255)<<8,W+=(M>>>7|J<<9)&8191,ae=g[A+8]&255|(g[A+9]&255)<<8,q+=(J>>>4|ae<<12)&8191,re+=ae>>>1&8191,me=g[A+10]&255|(g[A+11]&255)<<8,X+=(ae>>>14|me<<2)&8191,he=g[A+12]&255|(g[A+13]&255)<<8,Z+=(me>>>11|he<<5)&8191,tt=g[A+14]&255|(g[A+15]&255)<<8,oe+=(he>>>8|tt<<8)&8191,Ce+=tt>>>5|d,ge=0,Te=ge,Te+=Ee*He,Te+=_e*(5*Ze),Te+=de*(5*Je),Te+=W*(5*qe),Te+=q*(5*rt),ge=Te>>>13,Te&=8191,Te+=re*(5*nt),Te+=X*(5*Ke),Te+=Z*(5*w),Te+=oe*(5*Qe),Te+=Ce*(5*We),ge+=Te>>>13,Te&=8191,Le=ge,Le+=Ee*We,Le+=_e*He,Le+=de*(5*Ze),Le+=W*(5*Je),Le+=q*(5*qe),ge=Le>>>13,Le&=8191,Le+=re*(5*rt),Le+=X*(5*nt),Le+=Z*(5*Ke),Le+=oe*(5*w),Le+=Ce*(5*Qe),ge+=Le>>>13,Le&=8191,Fe=ge,Fe+=Ee*Qe,Fe+=_e*We,Fe+=de*He,Fe+=W*(5*Ze),Fe+=q*(5*Je),ge=Fe>>>13,Fe&=8191,Fe+=re*(5*qe),Fe+=X*(5*rt),Fe+=Z*(5*nt),Fe+=oe*(5*Ke),Fe+=Ce*(5*w),ge+=Fe>>>13,Fe&=8191,Me=ge,Me+=Ee*w,Me+=_e*Qe,Me+=de*We,Me+=W*He,Me+=q*(5*Ze),ge=Me>>>13,Me&=8191,Me+=re*(5*Je),Me+=X*(5*qe),Me+=Z*(5*rt),Me+=oe*(5*nt),Me+=Ce*(5*Ke),ge+=Me>>>13,Me&=8191,Ue=ge,Ue+=Ee*Ke,Ue+=_e*w,Ue+=de*Qe,Ue+=W*We,Ue+=q*He,ge=Ue>>>13,Ue&=8191,Ue+=re*(5*Ze),Ue+=X*(5*Je),Ue+=Z*(5*qe),Ue+=oe*(5*rt),Ue+=Ce*(5*nt),ge+=Ue>>>13,Ue&=8191,$e=ge,$e+=Ee*nt,$e+=_e*Ke,$e+=de*w,$e+=W*Qe,$e+=q*We,ge=$e>>>13,$e&=8191,$e+=re*He,$e+=X*(5*Ze),$e+=Z*(5*Je),$e+=oe*(5*qe),$e+=Ce*(5*rt),ge+=$e>>>13,$e&=8191,De=ge,De+=Ee*rt,De+=_e*nt,De+=de*Ke,De+=W*w,De+=q*Qe,ge=De>>>13,De&=8191,De+=re*We,De+=X*He,De+=Z*(5*Ze),De+=oe*(5*Je),De+=Ce*(5*qe),ge+=De>>>13,De&=8191,Ae=ge,Ae+=Ee*qe,Ae+=_e*rt,Ae+=de*nt,Ae+=W*Ke,Ae+=q*w,ge=Ae>>>13,Ae&=8191,Ae+=re*Qe,Ae+=X*We,Ae+=Z*He,Ae+=oe*(5*Ze),Ae+=Ce*(5*Je),ge+=Ae>>>13,Ae&=8191,be=ge,be+=Ee*Je,be+=_e*qe,be+=de*rt,be+=W*nt,be+=q*Ke,ge=be>>>13,be&=8191,be+=re*w,be+=X*Qe,be+=Z*We,be+=oe*He,be+=Ce*(5*Ze),ge+=be>>>13,be&=8191,pe=ge,pe+=Ee*Ze,pe+=_e*Je,pe+=de*qe,pe+=W*rt,pe+=q*nt,ge=pe>>>13,pe&=8191,pe+=re*Ke,pe+=X*w,pe+=Z*Qe,pe+=oe*We,pe+=Ce*He,ge+=pe>>>13,pe&=8191,ge=(ge<<2)+ge|0,ge=ge+Te|0,Te=ge&8191,ge=ge>>>13,Le+=ge,Ee=Te,_e=Le,de=Fe,W=Me,q=Ue,re=$e,X=De,Z=Ae,oe=be,Ce=pe,A+=16,m-=16;this.h[0]=Ee,this.h[1]=_e,this.h[2]=de,this.h[3]=W,this.h[4]=q,this.h[5]=re,this.h[6]=X,this.h[7]=Z,this.h[8]=oe,this.h[9]=Ce},I.prototype.finish=function(g,A){var m=new Uint16Array(10),d,_,L,M;if(this.leftover){for(M=this.leftover,this.buffer[M++]=1;M<16;M++)this.buffer[M]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(d=this.h[1]>>>13,this.h[1]&=8191,M=2;M<10;M++)this.h[M]+=d,d=this.h[M]>>>13,this.h[M]&=8191;for(this.h[0]+=d*5,d=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=d,d=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=d,m[0]=this.h[0]+5,d=m[0]>>>13,m[0]&=8191,M=1;M<10;M++)m[M]=this.h[M]+d,d=m[M]>>>13,m[M]&=8191;for(m[9]-=8192,_=(d^1)-1,M=0;M<10;M++)m[M]&=_;for(_=~_,M=0;M<10;M++)this.h[M]=this.h[M]&_|m[M];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,L=this.h[0]+this.pad[0],this.h[0]=L&65535,M=1;M<8;M++)L=(this.h[M]+this.pad[M]|0)+(L>>>16)|0,this.h[M]=L&65535;g[A+0]=this.h[0]>>>0&255,g[A+1]=this.h[0]>>>8&255,g[A+2]=this.h[1]>>>0&255,g[A+3]=this.h[1]>>>8&255,g[A+4]=this.h[2]>>>0&255,g[A+5]=this.h[2]>>>8&255,g[A+6]=this.h[3]>>>0&255,g[A+7]=this.h[3]>>>8&255,g[A+8]=this.h[4]>>>0&255,g[A+9]=this.h[4]>>>8&255,g[A+10]=this.h[5]>>>0&255,g[A+11]=this.h[5]>>>8&255,g[A+12]=this.h[6]>>>0&255,g[A+13]=this.h[6]>>>8&255,g[A+14]=this.h[7]>>>0&255,g[A+15]=this.h[7]>>>8&255},I.prototype.update=function(g,A,m){var d,_;if(this.leftover){for(_=16-this.leftover,_>m&&(_=m),d=0;d<_;d++)this.buffer[this.leftover+d]=g[A+d];if(m-=_,A+=_,this.leftover+=_,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(m>=16&&(_=m-m%16,this.blocks(g,A,_),A+=_,m-=_),m){for(d=0;d<m;d++)this.buffer[this.leftover+d]=g[A+d];this.leftover+=m}};function v(g,A,m,d,_,L){var M=new I(L);return M.update(m,d,_),M.finish(g,A),0}function R(g,A,m,d,_,L){var M=new Uint8Array(16);return v(M,0,m,d,_,L),E(g,A,M,0)}function ne(g,A,m,d,_){var L;if(m<32)return-1;for(S(g,0,A,0,m,d,_),v(g,16,g,32,m-32,g),L=0;L<16;L++)g[L]=0;return 0}function z(g,A,m,d,_){var L,M=new Uint8Array(32);if(m<32||(b(M,0,32,d,_),R(A,16,A,32,m-32,M)!==0))return-1;for(S(g,0,A,0,m,d,_),L=0;L<32;L++)g[L]=0;return 0}function Y(g,A){var m;for(m=0;m<16;m++)g[m]=A[m]|0}function te(g){var A,m,d=1;for(A=0;A<16;A++)m=g[A]+d+65535,d=Math.floor(m/65536),g[A]=m-d*65536;g[0]+=d-1+37*(d-1)}function ce(g,A,m){for(var d,_=~(m-1),L=0;L<16;L++)d=_&(g[L]^A[L]),g[L]^=d,A[L]^=d}function $(g,A){var m,d,_,L=t(),M=t();for(m=0;m<16;m++)M[m]=A[m];for(te(M),te(M),te(M),d=0;d<2;d++){for(L[0]=M[0]-65517,m=1;m<15;m++)L[m]=M[m]-65535-(L[m-1]>>16&1),L[m-1]&=65535;L[15]=M[15]-32767-(L[14]>>16&1),_=L[15]>>16&1,L[14]&=65535,ce(M,L,1-_)}for(m=0;m<16;m++)g[2*m]=M[m]&255,g[2*m+1]=M[m]>>8}function B(g,A){var m=new Uint8Array(32),d=new Uint8Array(32);return $(m,g),$(d,A),x(m,0,d,0)}function T(g){var A=new Uint8Array(32);return $(A,g),A[0]&1}function Q(g,A){var m;for(m=0;m<16;m++)g[m]=A[2*m]+(A[2*m+1]<<8);g[15]&=32767}function ee(g,A,m){for(var d=0;d<16;d++)g[d]=A[d]+m[d]}function fe(g,A,m){for(var d=0;d<16;d++)g[d]=A[d]-m[d]}function ie(g,A,m){var d,_,L=0,M=0,J=0,ae=0,me=0,he=0,tt=0,ge=0,Te=0,Le=0,Fe=0,Me=0,Ue=0,$e=0,De=0,Ae=0,be=0,pe=0,Ee=0,_e=0,de=0,W=0,q=0,re=0,X=0,Z=0,oe=0,Ce=0,He=0,We=0,Qe=0,w=m[0],Ke=m[1],nt=m[2],rt=m[3],qe=m[4],Je=m[5],Ze=m[6],kt=m[7],ft=m[8],wt=m[9],It=m[10],Ct=m[11],Lt=m[12],Ht=m[13],Qt=m[14],Wt=m[15];d=A[0],L+=d*w,M+=d*Ke,J+=d*nt,ae+=d*rt,me+=d*qe,he+=d*Je,tt+=d*Ze,ge+=d*kt,Te+=d*ft,Le+=d*wt,Fe+=d*It,Me+=d*Ct,Ue+=d*Lt,$e+=d*Ht,De+=d*Qt,Ae+=d*Wt,d=A[1],M+=d*w,J+=d*Ke,ae+=d*nt,me+=d*rt,he+=d*qe,tt+=d*Je,ge+=d*Ze,Te+=d*kt,Le+=d*ft,Fe+=d*wt,Me+=d*It,Ue+=d*Ct,$e+=d*Lt,De+=d*Ht,Ae+=d*Qt,be+=d*Wt,d=A[2],J+=d*w,ae+=d*Ke,me+=d*nt,he+=d*rt,tt+=d*qe,ge+=d*Je,Te+=d*Ze,Le+=d*kt,Fe+=d*ft,Me+=d*wt,Ue+=d*It,$e+=d*Ct,De+=d*Lt,Ae+=d*Ht,be+=d*Qt,pe+=d*Wt,d=A[3],ae+=d*w,me+=d*Ke,he+=d*nt,tt+=d*rt,ge+=d*qe,Te+=d*Je,Le+=d*Ze,Fe+=d*kt,Me+=d*ft,Ue+=d*wt,$e+=d*It,De+=d*Ct,Ae+=d*Lt,be+=d*Ht,pe+=d*Qt,Ee+=d*Wt,d=A[4],me+=d*w,he+=d*Ke,tt+=d*nt,ge+=d*rt,Te+=d*qe,Le+=d*Je,Fe+=d*Ze,Me+=d*kt,Ue+=d*ft,$e+=d*wt,De+=d*It,Ae+=d*Ct,be+=d*Lt,pe+=d*Ht,Ee+=d*Qt,_e+=d*Wt,d=A[5],he+=d*w,tt+=d*Ke,ge+=d*nt,Te+=d*rt,Le+=d*qe,Fe+=d*Je,Me+=d*Ze,Ue+=d*kt,$e+=d*ft,De+=d*wt,Ae+=d*It,be+=d*Ct,pe+=d*Lt,Ee+=d*Ht,_e+=d*Qt,de+=d*Wt,d=A[6],tt+=d*w,ge+=d*Ke,Te+=d*nt,Le+=d*rt,Fe+=d*qe,Me+=d*Je,Ue+=d*Ze,$e+=d*kt,De+=d*ft,Ae+=d*wt,be+=d*It,pe+=d*Ct,Ee+=d*Lt,_e+=d*Ht,de+=d*Qt,W+=d*Wt,d=A[7],ge+=d*w,Te+=d*Ke,Le+=d*nt,Fe+=d*rt,Me+=d*qe,Ue+=d*Je,$e+=d*Ze,De+=d*kt,Ae+=d*ft,be+=d*wt,pe+=d*It,Ee+=d*Ct,_e+=d*Lt,de+=d*Ht,W+=d*Qt,q+=d*Wt,d=A[8],Te+=d*w,Le+=d*Ke,Fe+=d*nt,Me+=d*rt,Ue+=d*qe,$e+=d*Je,De+=d*Ze,Ae+=d*kt,be+=d*ft,pe+=d*wt,Ee+=d*It,_e+=d*Ct,de+=d*Lt,W+=d*Ht,q+=d*Qt,re+=d*Wt,d=A[9],Le+=d*w,Fe+=d*Ke,Me+=d*nt,Ue+=d*rt,$e+=d*qe,De+=d*Je,Ae+=d*Ze,be+=d*kt,pe+=d*ft,Ee+=d*wt,_e+=d*It,de+=d*Ct,W+=d*Lt,q+=d*Ht,re+=d*Qt,X+=d*Wt,d=A[10],Fe+=d*w,Me+=d*Ke,Ue+=d*nt,$e+=d*rt,De+=d*qe,Ae+=d*Je,be+=d*Ze,pe+=d*kt,Ee+=d*ft,_e+=d*wt,de+=d*It,W+=d*Ct,q+=d*Lt,re+=d*Ht,X+=d*Qt,Z+=d*Wt,d=A[11],Me+=d*w,Ue+=d*Ke,$e+=d*nt,De+=d*rt,Ae+=d*qe,be+=d*Je,pe+=d*Ze,Ee+=d*kt,_e+=d*ft,de+=d*wt,W+=d*It,q+=d*Ct,re+=d*Lt,X+=d*Ht,Z+=d*Qt,oe+=d*Wt,d=A[12],Ue+=d*w,$e+=d*Ke,De+=d*nt,Ae+=d*rt,be+=d*qe,pe+=d*Je,Ee+=d*Ze,_e+=d*kt,de+=d*ft,W+=d*wt,q+=d*It,re+=d*Ct,X+=d*Lt,Z+=d*Ht,oe+=d*Qt,Ce+=d*Wt,d=A[13],$e+=d*w,De+=d*Ke,Ae+=d*nt,be+=d*rt,pe+=d*qe,Ee+=d*Je,_e+=d*Ze,de+=d*kt,W+=d*ft,q+=d*wt,re+=d*It,X+=d*Ct,Z+=d*Lt,oe+=d*Ht,Ce+=d*Qt,He+=d*Wt,d=A[14],De+=d*w,Ae+=d*Ke,be+=d*nt,pe+=d*rt,Ee+=d*qe,_e+=d*Je,de+=d*Ze,W+=d*kt,q+=d*ft,re+=d*wt,X+=d*It,Z+=d*Ct,oe+=d*Lt,Ce+=d*Ht,He+=d*Qt,We+=d*Wt,d=A[15],Ae+=d*w,be+=d*Ke,pe+=d*nt,Ee+=d*rt,_e+=d*qe,de+=d*Je,W+=d*Ze,q+=d*kt,re+=d*ft,X+=d*wt,Z+=d*It,oe+=d*Ct,Ce+=d*Lt,He+=d*Ht,We+=d*Qt,Qe+=d*Wt,L+=38*be,M+=38*pe,J+=38*Ee,ae+=38*_e,me+=38*de,he+=38*W,tt+=38*q,ge+=38*re,Te+=38*X,Le+=38*Z,Fe+=38*oe,Me+=38*Ce,Ue+=38*He,$e+=38*We,De+=38*Qe,_=1,d=L+_+65535,_=Math.floor(d/65536),L=d-_*65536,d=M+_+65535,_=Math.floor(d/65536),M=d-_*65536,d=J+_+65535,_=Math.floor(d/65536),J=d-_*65536,d=ae+_+65535,_=Math.floor(d/65536),ae=d-_*65536,d=me+_+65535,_=Math.floor(d/65536),me=d-_*65536,d=he+_+65535,_=Math.floor(d/65536),he=d-_*65536,d=tt+_+65535,_=Math.floor(d/65536),tt=d-_*65536,d=ge+_+65535,_=Math.floor(d/65536),ge=d-_*65536,d=Te+_+65535,_=Math.floor(d/65536),Te=d-_*65536,d=Le+_+65535,_=Math.floor(d/65536),Le=d-_*65536,d=Fe+_+65535,_=Math.floor(d/65536),Fe=d-_*65536,d=Me+_+65535,_=Math.floor(d/65536),Me=d-_*65536,d=Ue+_+65535,_=Math.floor(d/65536),Ue=d-_*65536,d=$e+_+65535,_=Math.floor(d/65536),$e=d-_*65536,d=De+_+65535,_=Math.floor(d/65536),De=d-_*65536,d=Ae+_+65535,_=Math.floor(d/65536),Ae=d-_*65536,L+=_-1+37*(_-1),_=1,d=L+_+65535,_=Math.floor(d/65536),L=d-_*65536,d=M+_+65535,_=Math.floor(d/65536),M=d-_*65536,d=J+_+65535,_=Math.floor(d/65536),J=d-_*65536,d=ae+_+65535,_=Math.floor(d/65536),ae=d-_*65536,d=me+_+65535,_=Math.floor(d/65536),me=d-_*65536,d=he+_+65535,_=Math.floor(d/65536),he=d-_*65536,d=tt+_+65535,_=Math.floor(d/65536),tt=d-_*65536,d=ge+_+65535,_=Math.floor(d/65536),ge=d-_*65536,d=Te+_+65535,_=Math.floor(d/65536),Te=d-_*65536,d=Le+_+65535,_=Math.floor(d/65536),Le=d-_*65536,d=Fe+_+65535,_=Math.floor(d/65536),Fe=d-_*65536,d=Me+_+65535,_=Math.floor(d/65536),Me=d-_*65536,d=Ue+_+65535,_=Math.floor(d/65536),Ue=d-_*65536,d=$e+_+65535,_=Math.floor(d/65536),$e=d-_*65536,d=De+_+65535,_=Math.floor(d/65536),De=d-_*65536,d=Ae+_+65535,_=Math.floor(d/65536),Ae=d-_*65536,L+=_-1+37*(_-1),g[0]=L,g[1]=M,g[2]=J,g[3]=ae,g[4]=me,g[5]=he,g[6]=tt,g[7]=ge,g[8]=Te,g[9]=Le,g[10]=Fe,g[11]=Me,g[12]=Ue,g[13]=$e,g[14]=De,g[15]=Ae}function Ye(g,A){ie(g,A,A)}function ct(g,A){var m=t(),d;for(d=0;d<16;d++)m[d]=A[d];for(d=253;d>=0;d--)Ye(m,m),d!==2&&d!==4&&ie(m,m,A);for(d=0;d<16;d++)g[d]=m[d]}function tn(g,A){var m=t(),d;for(d=0;d<16;d++)m[d]=A[d];for(d=250;d>=0;d--)Ye(m,m),d!==1&&ie(m,m,A);for(d=0;d<16;d++)g[d]=m[d]}function pr(g,A,m){var d=new Uint8Array(32),_=new Float64Array(80),L,M,J=t(),ae=t(),me=t(),he=t(),tt=t(),ge=t();for(M=0;M<31;M++)d[M]=A[M];for(d[31]=A[31]&127|64,d[0]&=248,Q(_,m),M=0;M<16;M++)ae[M]=_[M],he[M]=J[M]=me[M]=0;for(J[0]=he[0]=1,M=254;M>=0;--M)L=d[M>>>3]>>>(M&7)&1,ce(J,ae,L),ce(me,he,L),ee(tt,J,me),fe(J,J,me),ee(me,ae,he),fe(ae,ae,he),Ye(he,tt),Ye(ge,J),ie(J,me,J),ie(me,ae,tt),ee(tt,J,me),fe(J,J,me),Ye(ae,J),fe(me,he,ge),ie(J,me,a),ee(J,J,he),ie(me,me,J),ie(J,he,ge),ie(he,ae,_),Ye(ae,tt),ce(J,ae,L),ce(me,he,L);for(M=0;M<16;M++)_[M+16]=J[M],_[M+32]=me[M],_[M+48]=ae[M],_[M+64]=he[M];var Te=_.subarray(32),Le=_.subarray(16);return ct(Te,Te),ie(Le,Le,Te),$(g,Le),0}function gr(g,A){return pr(g,A,s)}function vn(g,A){return e(A,32),gr(g,A)}function mr(g,A,m){var d=new Uint8Array(32);return pr(d,m,A),C(g,r,d,F)}var jr=ne,Mi=z;function Xr(g,A,m,d,_,L){var M=new Uint8Array(32);return mr(M,_,L),jr(g,A,m,d,M)}function Ar(g,A,m,d,_,L){var M=new Uint8Array(32);return mr(M,_,L),Mi(g,A,m,d,M)}var Er=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function j(g,A,m,d){for(var _=new Int32Array(16),L=new Int32Array(16),M,J,ae,me,he,tt,ge,Te,Le,Fe,Me,Ue,$e,De,Ae,be,pe,Ee,_e,de,W,q,re,X,Z,oe,Ce=g[0],He=g[1],We=g[2],Qe=g[3],w=g[4],Ke=g[5],nt=g[6],rt=g[7],qe=A[0],Je=A[1],Ze=A[2],kt=A[3],ft=A[4],wt=A[5],It=A[6],Ct=A[7],Lt=0;d>=128;){for(_e=0;_e<16;_e++)de=8*_e+Lt,_[_e]=m[de+0]<<24|m[de+1]<<16|m[de+2]<<8|m[de+3],L[_e]=m[de+4]<<24|m[de+5]<<16|m[de+6]<<8|m[de+7];for(_e=0;_e<80;_e++)if(M=Ce,J=He,ae=We,me=Qe,he=w,tt=Ke,ge=nt,Te=rt,Le=qe,Fe=Je,Me=Ze,Ue=kt,$e=ft,De=wt,Ae=It,be=Ct,W=rt,q=Ct,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=(w>>>14|ft<<18)^(w>>>18|ft<<14)^(ft>>>9|w<<23),q=(ft>>>14|w<<18)^(ft>>>18|w<<14)^(w>>>9|ft<<23),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=w&Ke^~w&nt,q=ft&wt^~ft&It,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=Er[_e*2],q=Er[_e*2+1],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=_[_e%16],q=L[_e%16],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,pe=Z&65535|oe<<16,Ee=re&65535|X<<16,W=pe,q=Ee,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=(Ce>>>28|qe<<4)^(qe>>>2|Ce<<30)^(qe>>>7|Ce<<25),q=(qe>>>28|Ce<<4)^(Ce>>>2|qe<<30)^(Ce>>>7|qe<<25),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=Ce&He^Ce&We^He&We,q=qe&Je^qe&Ze^Je&Ze,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,Te=Z&65535|oe<<16,be=re&65535|X<<16,W=me,q=Ue,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=pe,q=Ee,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,me=Z&65535|oe<<16,Ue=re&65535|X<<16,He=M,We=J,Qe=ae,w=me,Ke=he,nt=tt,rt=ge,Ce=Te,Je=Le,Ze=Fe,kt=Me,ft=Ue,wt=$e,It=De,Ct=Ae,qe=be,_e%16===15)for(de=0;de<16;de++)W=_[de],q=L[de],re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=_[(de+9)%16],q=L[(de+9)%16],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,pe=_[(de+1)%16],Ee=L[(de+1)%16],W=(pe>>>1|Ee<<31)^(pe>>>8|Ee<<24)^pe>>>7,q=(Ee>>>1|pe<<31)^(Ee>>>8|pe<<24)^(Ee>>>7|pe<<25),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,pe=_[(de+14)%16],Ee=L[(de+14)%16],W=(pe>>>19|Ee<<13)^(Ee>>>29|pe<<3)^pe>>>6,q=(Ee>>>19|pe<<13)^(pe>>>29|Ee<<3)^(Ee>>>6|pe<<26),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,_[de]=Z&65535|oe<<16,L[de]=re&65535|X<<16;W=Ce,q=qe,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[0],q=A[0],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[0]=Ce=Z&65535|oe<<16,A[0]=qe=re&65535|X<<16,W=He,q=Je,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[1],q=A[1],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[1]=He=Z&65535|oe<<16,A[1]=Je=re&65535|X<<16,W=We,q=Ze,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[2],q=A[2],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[2]=We=Z&65535|oe<<16,A[2]=Ze=re&65535|X<<16,W=Qe,q=kt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[3],q=A[3],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[3]=Qe=Z&65535|oe<<16,A[3]=kt=re&65535|X<<16,W=w,q=ft,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[4],q=A[4],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[4]=w=Z&65535|oe<<16,A[4]=ft=re&65535|X<<16,W=Ke,q=wt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[5],q=A[5],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[5]=Ke=Z&65535|oe<<16,A[5]=wt=re&65535|X<<16,W=nt,q=It,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[6],q=A[6],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[6]=nt=Z&65535|oe<<16,A[6]=It=re&65535|X<<16,W=rt,q=Ct,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[7],q=A[7],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[7]=rt=Z&65535|oe<<16,A[7]=Ct=re&65535|X<<16,Lt+=128,d-=128}return d}function ue(g,A,m){var d=new Int32Array(8),_=new Int32Array(8),L=new Uint8Array(256),M,J=m;for(d[0]=1779033703,d[1]=3144134277,d[2]=1013904242,d[3]=2773480762,d[4]=1359893119,d[5]=2600822924,d[6]=528734635,d[7]=1541459225,_[0]=4089235720,_[1]=2227873595,_[2]=4271175723,_[3]=1595750129,_[4]=2917565137,_[5]=725511199,_[6]=4215389547,_[7]=327033209,j(d,_,A,m),m%=128,M=0;M<m;M++)L[M]=A[J-m+M];for(L[m]=128,m=256-128*(m<112?1:0),L[m-9]=0,p(L,m-8,J/536870912|0,J<<3),j(d,_,L,m),M=0;M<8;M++)p(g,8*M,d[M],_[M]);return 0}function xe(g,A){var m=t(),d=t(),_=t(),L=t(),M=t(),J=t(),ae=t(),me=t(),he=t();fe(m,g[1],g[0]),fe(he,A[1],A[0]),ie(m,m,he),ee(d,g[0],g[1]),ee(he,A[0],A[1]),ie(d,d,he),ie(_,g[3],A[3]),ie(_,_,f),ie(L,g[2],A[2]),ee(L,L,L),fe(M,d,m),fe(J,L,_),ee(ae,L,_),ee(me,d,m),ie(g[0],M,J),ie(g[1],me,ae),ie(g[2],ae,J),ie(g[3],M,me)}function Pe(g,A,m){var d;for(d=0;d<4;d++)ce(g[d],A[d],m)}function je(g,A){var m=t(),d=t(),_=t();ct(_,A[2]),ie(m,A[0],_),ie(d,A[1],_),$(g,d),g[31]^=T(m)<<7}function Nt(g,A,m){var d,_;for(Y(g[0],i),Y(g[1],o),Y(g[2],o),Y(g[3],i),_=255;_>=0;--_)d=m[_/8|0]>>(_&7)&1,Pe(g,A,d),xe(A,g),xe(g,g),Pe(g,A,d)}function En(g,A){var m=[t(),t(),t(),t()];Y(m[0],l),Y(m[1],u),Y(m[2],o),ie(m[3],l,u),Nt(g,m,A)}function nn(g,A,m){var d=new Uint8Array(64),_=[t(),t(),t(),t()],L;for(m||e(A,32),ue(d,A,32),d[0]&=248,d[31]&=127,d[31]|=64,En(_,d),je(g,_),L=0;L<32;L++)A[L+32]=g[L];return 0}var _r=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ot(g,A){var m,d,_,L;for(d=63;d>=32;--d){for(m=0,_=d-32,L=d-12;_<L;++_)A[_]+=m-16*A[d]*_r[_-(d-32)],m=A[_]+128>>8,A[_]-=m*256;A[_]+=m,A[d]=0}for(m=0,_=0;_<32;_++)A[_]+=m-(A[31]>>4)*_r[_],m=A[_]>>8,A[_]&=255;for(_=0;_<32;_++)A[_]-=m*_r[_];for(d=0;d<32;d++)A[d+1]+=A[d]>>8,g[d]=A[d]&255}function Ut(g){var A=new Float64Array(64),m;for(m=0;m<64;m++)A[m]=g[m];for(m=0;m<64;m++)g[m]=0;ot(g,A)}function Tt(g,A,m,d){var _=new Uint8Array(64),L=new Uint8Array(64),M=new Uint8Array(64),J,ae,me=new Float64Array(64),he=[t(),t(),t(),t()];ue(_,d,32),_[0]&=248,_[31]&=127,_[31]|=64;var tt=m+64;for(J=0;J<m;J++)g[64+J]=A[J];for(J=0;J<32;J++)g[32+J]=_[32+J];for(ue(M,g.subarray(32),m+32),Ut(M),En(he,M),je(g,he),J=32;J<64;J++)g[J]=d[J];for(ue(L,g,m+64),Ut(L),J=0;J<64;J++)me[J]=0;for(J=0;J<32;J++)me[J]=M[J];for(J=0;J<32;J++)for(ae=0;ae<32;ae++)me[J+ae]+=L[J]*_[ae];return ot(g.subarray(32),me),tt}function xt(g,A){var m=t(),d=t(),_=t(),L=t(),M=t(),J=t(),ae=t();return Y(g[2],o),Q(g[1],A),Ye(_,g[1]),ie(L,_,c),fe(_,_,g[2]),ee(L,g[2],L),Ye(M,L),Ye(J,M),ie(ae,J,M),ie(m,ae,_),ie(m,m,L),tn(m,m),ie(m,m,_),ie(m,m,L),ie(m,m,L),ie(g[0],m,L),Ye(d,g[0]),ie(d,d,L),B(d,_)&&ie(g[0],g[0],h),Ye(d,g[0]),ie(d,d,L),B(d,_)?-1:(T(g[0])===A[31]>>7&&fe(g[0],i,g[0]),ie(g[3],g[0],g[1]),0)}function dt(g,A,m,d){var _,L,M=new Uint8Array(32),J=new Uint8Array(64),ae=[t(),t(),t(),t()],me=[t(),t(),t(),t()];if(L=-1,m<64||xt(me,d))return-1;for(_=0;_<m;_++)g[_]=A[_];for(_=0;_<32;_++)g[_+32]=d[_];if(ue(J,g,m),Ut(J),Nt(ae,me,J),En(me,A.subarray(32)),xe(ae,me),je(M,ae),m-=64,x(A,0,M,0)){for(_=0;_<m;_++)g[_]=0;return-1}for(_=0;_<m;_++)g[_]=A[_+64];return L=m,L}var cn=32,St=24,tr=32,yr=16,Jr=32,Fi=32,Zr=32,ei=32,to=32,Ec=St,Vh=tr,Gh=yr,Bn=64,nr=32,br=64,no=32,ro=64;n.lowlevel={crypto_core_hsalsa20:C,crypto_stream_xor:S,crypto_stream:b,crypto_stream_salsa20_xor:V,crypto_stream_salsa20:N,crypto_onetimeauth:v,crypto_onetimeauth_verify:R,crypto_verify_16:E,crypto_verify_32:x,crypto_secretbox:ne,crypto_secretbox_open:z,crypto_scalarmult:pr,crypto_scalarmult_base:gr,crypto_box_beforenm:mr,crypto_box_afternm:jr,crypto_box:Xr,crypto_box_open:Ar,crypto_box_keypair:vn,crypto_hash:ue,crypto_sign:Tt,crypto_sign_keypair:nn,crypto_sign_open:dt,crypto_secretbox_KEYBYTES:cn,crypto_secretbox_NONCEBYTES:St,crypto_secretbox_ZEROBYTES:tr,crypto_secretbox_BOXZEROBYTES:yr,crypto_scalarmult_BYTES:Jr,crypto_scalarmult_SCALARBYTES:Fi,crypto_box_PUBLICKEYBYTES:Zr,crypto_box_SECRETKEYBYTES:ei,crypto_box_BEFORENMBYTES:to,crypto_box_NONCEBYTES:Ec,crypto_box_ZEROBYTES:Vh,crypto_box_BOXZEROBYTES:Gh,crypto_sign_BYTES:Bn,crypto_sign_PUBLICKEYBYTES:nr,crypto_sign_SECRETKEYBYTES:br,crypto_sign_SEEDBYTES:no,crypto_hash_BYTES:ro};function _c(g,A){if(g.length!==cn)throw new Error("bad key size");if(A.length!==St)throw new Error("bad nonce size")}function zh(g,A){if(g.length!==Zr)throw new Error("bad public key size");if(A.length!==ei)throw new Error("bad secret key size")}function rn(){var g,A;for(A=0;A<arguments.length;A++)if((g=Object.prototype.toString.call(arguments[A]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+g+", use Uint8Array")}function yc(g){for(var A=0;A<g.length;A++)g[A]=0}n.util||(n.util={},n.util.decodeUTF8=n.util.encodeUTF8=n.util.encodeBase64=n.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),n.randomBytes=function(g){var A=new Uint8Array(g);return e(A,g),A},n.secretbox=function(g,A,m){rn(g,A,m),_c(m,A);for(var d=new Uint8Array(tr+g.length),_=new Uint8Array(d.length),L=0;L<g.length;L++)d[L+tr]=g[L];return ne(_,d,d.length,A,m),_.subarray(yr)},n.secretbox.open=function(g,A,m){rn(g,A,m),_c(m,A);for(var d=new Uint8Array(yr+g.length),_=new Uint8Array(d.length),L=0;L<g.length;L++)d[L+yr]=g[L];return d.length<32||z(_,d,d.length,A,m)!==0?!1:_.subarray(tr)},n.secretbox.keyLength=cn,n.secretbox.nonceLength=St,n.secretbox.overheadLength=yr,n.scalarMult=function(g,A){if(rn(g,A),g.length!==Fi)throw new Error("bad n size");if(A.length!==Jr)throw new Error("bad p size");var m=new Uint8Array(Jr);return pr(m,g,A),m},n.scalarMult.base=function(g){if(rn(g),g.length!==Fi)throw new Error("bad n size");var A=new Uint8Array(Jr);return gr(A,g),A},n.scalarMult.scalarLength=Fi,n.scalarMult.groupElementLength=Jr,n.box=function(g,A,m,d){var _=n.box.before(m,d);return n.secretbox(g,A,_)},n.box.before=function(g,A){rn(g,A),zh(g,A);var m=new Uint8Array(to);return mr(m,g,A),m},n.box.after=n.secretbox,n.box.open=function(g,A,m,d){var _=n.box.before(m,d);return n.secretbox.open(g,A,_)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var g=new Uint8Array(Zr),A=new Uint8Array(ei);return vn(g,A),{publicKey:g,secretKey:A}},n.box.keyPair.fromSecretKey=function(g){if(rn(g),g.length!==ei)throw new Error("bad secret key size");var A=new Uint8Array(Zr);return gr(A,g),{publicKey:A,secretKey:new Uint8Array(g)}},n.box.publicKeyLength=Zr,n.box.secretKeyLength=ei,n.box.sharedKeyLength=to,n.box.nonceLength=Ec,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(g,A){if(rn(g,A),A.length!==br)throw new Error("bad secret key size");var m=new Uint8Array(Bn+g.length);return Tt(m,g,g.length,A),m},n.sign.open=function(g,A){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(rn(g,A),A.length!==nr)throw new Error("bad public key size");var m=new Uint8Array(g.length),d=dt(m,g,g.length,A);if(d<0)return null;for(var _=new Uint8Array(d),L=0;L<_.length;L++)_[L]=m[L];return _},n.sign.detached=function(g,A){for(var m=n.sign(g,A),d=new Uint8Array(Bn),_=0;_<d.length;_++)d[_]=m[_];return d},n.sign.detached.verify=function(g,A,m){if(rn(g,A,m),A.length!==Bn)throw new Error("bad signature size");if(m.length!==nr)throw new Error("bad public key size");var d=new Uint8Array(Bn+g.length),_=new Uint8Array(Bn+g.length),L;for(L=0;L<Bn;L++)d[L]=A[L];for(L=0;L<g.length;L++)d[L+Bn]=g[L];return dt(_,d,d.length,m)>=0},n.sign.keyPair=function(){var g=new Uint8Array(nr),A=new Uint8Array(br);return nn(g,A),{publicKey:g,secretKey:A}},n.sign.keyPair.fromSecretKey=function(g){if(rn(g),g.length!==br)throw new Error("bad secret key size");for(var A=new Uint8Array(nr),m=0;m<A.length;m++)A[m]=g[32+m];return{publicKey:A,secretKey:new Uint8Array(g)}},n.sign.keyPair.fromSeed=function(g){if(rn(g),g.length!==no)throw new Error("bad seed size");for(var A=new Uint8Array(nr),m=new Uint8Array(br),d=0;d<32;d++)m[d]=g[d];return nn(A,m,!0),{publicKey:A,secretKey:m}},n.sign.publicKeyLength=nr,n.sign.secretKeyLength=br,n.sign.seedLength=no,n.sign.signatureLength=Bn,n.hash=function(g){rn(g);var A=new Uint8Array(ro);return ue(A,g,g.length),A},n.hash.hashLength=ro,n.verify=function(g,A){return rn(g,A),g.length===0||A.length===0||g.length!==A.length?!1:y(g,0,A,0,g.length)===0},n.setPRNG=function(g){e=g},(function(){var g=typeof self<"u"?self.crypto||self.msCrypto:null;if(g&&g.getRandomValues){var A=65536;n.setPRNG(function(m,d){var _,L=new Uint8Array(d);for(_=0;_<d;_+=A)g.getRandomValues(L.subarray(_,_+Math.min(d-_,A)));for(_=0;_<d;_++)m[_]=L[_];yc(L)})}else typeof require<"u"&&(g=require("crypto"),g&&g.randomBytes&&n.setPRNG(function(m,d){var _,L=g.randomBytes(d);for(_=0;_<d;_++)m[_]=L[_];yc(L)}))})()})(typeof Yi<"u"&&Yi.exports?Yi.exports:self.nacl=self.nacl||{})});var uo=at((bE,Tc)=>{"use strict";var co=Pc().lowlevel.crypto_hash,Rn=0,ir=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 Xi(n,t,e){return(n[0][t[e+3]]+n[1][t[e+2]]^n[2][t[e+1]])+n[3][t[e]]}ir.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]^=Xi(this.S,t,0)^this.P[e],n[0]^=Xi(this.S,t,4)^this.P[e+1];var r=n[0];n[0]=n[1]^this.P[17],n[1]=r};ir.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]^=Xi(this.S,t,0)^this.P[e],n[0]^=Xi(this.S,t,4)^this.P[e-1];var r=n[0];n[0]=n[1]^this.P[0],n[1]=r};function rr(n,t){var e,r=0;for(e=0;e<4;e++,Rn++)Rn>=t&&(Rn=0),r=r<<8|n[Rn];return r}ir.prototype.expand0state=function(n,t){var e=new Uint32Array(2),r,s,i=new Uint8Array(e.buffer);for(r=0,Rn=0;r<18;r++)this.P[r]^=rr(n,t);for(Rn=0,r=0;r<18;r+=2)this.encipher(e,i),this.P[r]=e[0],this.P[r+1]=e[1];for(r=0;r<4;r++)for(s=0;s<256;s+=2)this.encipher(e,i),this.S[r][s]=e[0],this.S[r][s+1]=e[1]};ir.prototype.expandstate=function(n,t,e,r){var s=new Uint32Array(2),i,o;for(i=0,Rn=0;i<18;i++)this.P[i]^=rr(e,r);for(i=0,Rn=0;i<18;i+=2)s[0]^=rr(n,t),s[1]^=rr(n,t),this.encipher(s),this.P[i]=s[0],this.P[i+1]=s[1];for(i=0;i<4;i++)for(o=0;o<256;o+=2)s[0]^=rr(n,t),s[1]^=rr(n,t),this.encipher(s),this.S[i][o]=s[0],this.S[i][o+1]=s[1];Rn=0};ir.prototype.enc=function(n,t){for(var e=0;e<t;e++)this.encipher(n.subarray(e*2))};ir.prototype.dec=function(n,t){for(var e=0;e<t;e++)this.decipher(n.subarray(e*2))};var ji=8,fo=32;function lo(n,t,e){var r=new ir,s=new Uint32Array(ji),i,o=new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,105,116,101]);for(r.expandstate(t,64,n,64),i=0;i<64;i++)r.expand0state(t,64),r.expand0state(n,64);for(i=0;i<ji;i++)s[i]=rr(o,o.byteLength);for(i=0;i<64;i++)r.enc(s,s.byteLength/8);for(i=0;i<ji;i++)e[4*i+3]=s[i]>>>24,e[4*i+2]=s[i]>>>16,e[4*i+1]=s[i]>>>8,e[4*i+0]=s[i]}function cp(n,t,e,r,s,i,o){var a=new Uint8Array(64),c=new Uint8Array(64),f=new Uint8Array(fo),l=new Uint8Array(fo),u=new Uint8Array(r+4),h,p,y,E,x,k,D=i;if(o<1||t===0||r===0||i===0||i>f.byteLength*f.byteLength||r>1<<20)return-1;for(E=Math.floor((i+f.byteLength-1)/f.byteLength),y=Math.floor((i+E-1)/E),h=0;h<r;h++)u[h]=e[h];for(co(a,n,t),k=1;i>0;k++){for(u[r+0]=k>>>24,u[r+1]=k>>>16,u[r+2]=k>>>8,u[r+3]=k,co(c,u,r+4),lo(a,c,l),h=f.byteLength;h--;)f[h]=l[h];for(h=1;h<o;h++)for(co(c,l,l.byteLength),lo(a,c,l),p=0;p<f.byteLength;p++)f[p]^=l[p];for(y=Math.min(y,i),h=0;h<y&&(x=h*E+(k-1),!(x>=D));h++)s[x]=f[h];i-=h}return 0}Tc.exports={BLOCKS:ji,HASHSIZE:fo,hash:lo,pbkdf:cp}});var Pn=at((xE,Zi)=>{"use strict";var Nn=require("crypto"),Cr;try{Cr=require("cpu-features")()}catch{}var{bindingAvailable:Lc,CIPHER_INFO:fp,MAC_INFO:lp}=Qn(),Uc=(()=>{if(typeof Nn.sign=="function"&&typeof Nn.verify=="function"){let n=`-----BEGIN PRIVATE KEY-----\r
1
+ "use strict";var tp=Object.create;var ao=Object.defineProperty;var np=Object.getOwnPropertyDescriptor;var rp=Object.getOwnPropertyNames;var ip=Object.getPrototypeOf,sp=Object.prototype.hasOwnProperty;var op=(n,t)=>()=>(n&&(t=n(n=0)),t);var ct=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),ap=(n,t)=>{for(var e in t)ao(n,e,{get:t[e],enumerable:!0})},cp=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of rp(t))!sp.call(n,s)&&s!==e&&ao(n,s,{get:()=>t[s],enumerable:!(r=np(t,s))||r.enumerable});return n};var Gt=(n,t,e)=>(e=n!=null?tp(ip(n)):{},cp(t||!n||!n.__esModule?ao(e,"default",{value:n,enumerable:!0}):e,n));var qi=ct((_E,Ic)=>{Ic.exports={newInvalidAsn1Error:function(n){var t=new Error;return t.name="InvalidAsn1Error",t.message=n||"",t}}});var Ki=ct((bE,Cc)=>{Cc.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 co=ct((xE,vc)=>{"use strict";var Vi=require("buffer"),xr=Vi.Buffer,un={},dn;for(dn in Vi)Vi.hasOwnProperty(dn)&&(dn==="SlowBuffer"||dn==="Buffer"||(un[dn]=Vi[dn]));var Sr=un.Buffer={};for(dn in xr)xr.hasOwnProperty(dn)&&(dn==="allocUnsafe"||dn==="allocUnsafeSlow"||(Sr[dn]=xr[dn]));un.Buffer.prototype=xr.prototype;(!Sr.from||Sr.from===Uint8Array.from)&&(Sr.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 xr(n,t,e)});Sr.alloc||(Sr.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=xr(n);return!t||t.length===0?r.fill(0):typeof e=="string"?r.fill(t,e):r.fill(t),r});if(!un.kStringMaxLength)try{un.kStringMaxLength=process.binding("buffer").kStringMaxLength}catch{}un.constants||(un.constants={MAX_LENGTH:un.kMaxLength},un.kStringMaxLength&&(un.constants.MAX_STRING_LENGTH=un.kStringMaxLength));vc.exports=un});var Rc=ct((SE,Bc)=>{var fp=require("assert"),kc=co().Buffer,ni=Ki(),lp=qi(),wr=lp.newInvalidAsn1Error;function zt(n){if(!n||!kc.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(zt.prototype,"length",{enumerable:!0,get:function(){return this._len}});Object.defineProperty(zt.prototype,"offset",{enumerable:!0,get:function(){return this._offset}});Object.defineProperty(zt.prototype,"remain",{get:function(){return this._size-this._offset}});Object.defineProperty(zt.prototype,"buffer",{get:function(){return this._buf.slice(this._offset)}});zt.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};zt.prototype.peek=function(){return this.readByte(!0)};zt.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 wr("Indefinite length not supported");if(t>4)throw wr("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};zt.prototype.readSequence=function(n){var t=this.peek();if(t===null)return null;if(n!==void 0&&n!==t)throw wr("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)};zt.prototype.readInt=function(){return this._readTag(ni.Integer)};zt.prototype.readBoolean=function(){return this._readTag(ni.Boolean)!==0};zt.prototype.readEnumeration=function(){return this._readTag(ni.Enumeration)};zt.prototype.readString=function(n,t){n||(n=ni.OctetString);var e=this.peek();if(e===null)return null;if(e!==n)throw wr("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?kc.alloc(0):"";var s=this._buf.slice(this._offset,this._offset+this.length);return this._offset+=this.length,t?s:s.toString("utf8")};zt.prototype.readOID=function(n){n||(n=ni.OID);var t=this.readString(n,!0);if(t===null)return null;for(var e=[],r=0,s=0;s<t.length;s++){var i=t[s]&255;r<<=7,r+=i&127,(i&128)===0&&(e.push(r),r=0)}return r=e.shift(),e.unshift(r%40),e.unshift(r/40>>0),e.join(".")};zt.prototype._readTag=function(n){fp.ok(n!==void 0);var t=this.peek();if(t===null)return null;if(t!==n)throw wr("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 wr("Integer too long: "+this.length);if(this.length>this._size-e)return null;this._offset=e;for(var r=this._buf[this._offset],s=0,i=0;i<this.length;i++)s<<=8,s|=this._buf[this._offset++]&255;return(r&128)===128&&i!==4&&(s-=1<<i*8),s>>0};Bc.exports=zt});var Pc=ct((wE,Nc)=>{var Fn=require("assert"),Gi=co().Buffer,Hn=Ki(),up=qi(),zi=up.newInvalidAsn1Error,dp={size:1024,growthFactor:8};function hp(n,t){Fn.ok(n),Fn.equal(typeof n,"object"),Fn.ok(t),Fn.equal(typeof t,"object");var e=Object.getOwnPropertyNames(n);return e.forEach(function(r){if(!t[r]){var s=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,s)}}),t}function Kt(n){n=hp(dp,n||{}),this._buf=Gi.alloc(n.size||1024),this._size=this._buf.length,this._offset=0,this._options=n,this._seq=[]}Object.defineProperty(Kt.prototype,"buffer",{get:function(){if(this._seq.length)throw zi(this._seq.length+" unended sequence(s)");return this._buf.slice(0,this._offset)}});Kt.prototype.writeByte=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");this._ensure(1),this._buf[this._offset++]=n};Kt.prototype.writeInt=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");typeof t!="number"&&(t=Hn.Integer);for(var e=4;((n&4286578688)===0||(n&4286578688)===-8388608)&&e>1;)e--,n<<=8;if(e>4)throw zi("BER ints cannot be > 0xffffffff");for(this._ensure(2+e),this._buf[this._offset++]=t,this._buf[this._offset++]=e;e-- >0;)this._buf[this._offset++]=(n&4278190080)>>>24,n<<=8};Kt.prototype.writeNull=function(){this.writeByte(Hn.Null),this.writeByte(0)};Kt.prototype.writeEnumeration=function(n,t){if(typeof n!="number")throw new TypeError("argument must be a Number");return typeof t!="number"&&(t=Hn.Enumeration),this.writeInt(n,t)};Kt.prototype.writeBoolean=function(n,t){if(typeof n!="boolean")throw new TypeError("argument must be a Boolean");typeof t!="number"&&(t=Hn.Boolean),this._ensure(3),this._buf[this._offset++]=t,this._buf[this._offset++]=1,this._buf[this._offset++]=n?255:0};Kt.prototype.writeString=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string (was: "+typeof n+")");typeof t!="number"&&(t=Hn.OctetString);var e=Gi.byteLength(n);this.writeByte(t),this.writeLength(e),e&&(this._ensure(e),this._buf.write(n,this._offset),this._offset+=e)};Kt.prototype.writeBuffer=function(n,t){if(typeof t!="number")throw new TypeError("tag must be a number");if(!Gi.isBuffer(n))throw new TypeError("argument must be a buffer");this.writeByte(t),this.writeLength(n.length),this._ensure(n.length),n.copy(this._buf,this._offset,0,n.length),this._offset+=n.length};Kt.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)})};Kt.prototype.writeOID=function(n,t){if(typeof n!="string")throw new TypeError("argument must be a string");if(typeof t!="number"&&(t=Hn.OID),!/^([0-9]+\.){3,}[0-9]+$/.test(n))throw new Error("argument is not a valid OID string");function e(o,a){a<128?o.push(a):a<16384?(o.push(a>>>7|128),o.push(a&127)):a<2097152?(o.push(a>>>14|128),o.push((a>>>7|128)&255),o.push(a&127)):a<268435456?(o.push(a>>>21|128),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127)):(o.push((a>>>28|128)&255),o.push((a>>>21|128)&255),o.push((a>>>14|128)&255),o.push((a>>>7|128)&255),o.push(a&127))}var r=n.split("."),s=[];s.push(parseInt(r[0],10)*40+parseInt(r[1],10)),r.slice(2).forEach(function(o){e(s,parseInt(o,10))});var i=this;this._ensure(2+s.length),this.writeByte(t),this.writeLength(s.length),s.forEach(function(o){i.writeByte(o)})};Kt.prototype.writeLength=function(n){if(typeof n!="number")throw new TypeError("argument must be a Number");if(this._ensure(4),n<=127)this._buf[this._offset++]=n;else if(n<=255)this._buf[this._offset++]=129,this._buf[this._offset++]=n;else if(n<=65535)this._buf[this._offset++]=130,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else if(n<=16777215)this._buf[this._offset++]=131,this._buf[this._offset++]=n>>16,this._buf[this._offset++]=n>>8,this._buf[this._offset++]=n;else throw zi("Length too long (> 4 bytes)")};Kt.prototype.startSequence=function(n){typeof n!="number"&&(n=Hn.Sequence|Hn.Constructor),this.writeByte(n),this._seq.push(this._offset),this._ensure(3),this._offset+=3};Kt.prototype.endSequence=function(){var n=this._seq.pop(),t=n+3,e=this._offset-t;if(e<=127)this._shift(t,e,-2),this._buf[n]=e;else if(e<=255)this._shift(t,e,-1),this._buf[n]=129,this._buf[n+1]=e;else if(e<=65535)this._buf[n]=130,this._buf[n+1]=e>>8,this._buf[n+2]=e;else if(e<=16777215)this._shift(t,e,1),this._buf[n]=131,this._buf[n+1]=e>>16,this._buf[n+2]=e>>8,this._buf[n+3]=e;else throw zi("Sequence too long")};Kt.prototype._shift=function(n,t,e){Fn.ok(n!==void 0),Fn.ok(t!==void 0),Fn.ok(e),this._buf.copy(this._buf,n+e,n,n+t),this._offset+=e};Kt.prototype._ensure=function(n){if(Fn.ok(n),this._size-this._offset<n){var t=this._size*this._options.growthFactor;t-this._offset<n&&(t+=n);var e=Gi.alloc(t);this._buf.copy(e,0,0,this._offset),this._buf=e,this._size=t}};Nc.exports=Kt});var Tc=ct((IE,Xi)=>{var fo=qi(),lo=Ki(),pp=Rc(),gp=Pc();Xi.exports={Reader:pp,Writer:gp};for(Yi in lo)lo.hasOwnProperty(Yi)&&(Xi.exports[Yi]=lo[Yi]);var Yi;for(ji in fo)fo.hasOwnProperty(ji)&&(Xi.exports[ji]=fo[ji]);var ji});var ri=ct((CE,Lc)=>{var uo=Tc();Lc.exports={Ber:uo,BerReader:uo.Reader,BerWriter:uo.Writer}});var Uc=ct((vE,Ji)=>{(function(n){"use strict";var t=function(g){var A,m=new Float64Array(16);if(g)for(A=0;A<g.length;A++)m[A]=g[A];return m},e=function(){throw new Error("no PRNG")},r=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var i=t(),o=t([1]),a=t([56129,1]),c=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),f=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]),u=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),h=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function p(g,A,m,d){g[A]=m>>24&255,g[A+1]=m>>16&255,g[A+2]=m>>8&255,g[A+3]=m&255,g[A+4]=d>>24&255,g[A+5]=d>>16&255,g[A+6]=d>>8&255,g[A+7]=d&255}function y(g,A,m,d,_){var U,F=0;for(U=0;U<_;U++)F|=g[A+U]^m[d+U];return(1&F-1>>>8)-1}function E(g,A,m,d){return y(g,A,m,d,16)}function b(g,A,m,d){return y(g,A,m,d,32)}function C(g,A,m,d){for(var _=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,U=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,F=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,J=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ae=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,me=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,he=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,tt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,ge=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Te=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Le=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,Fe=m[16]&255|(m[17]&255)<<8|(m[18]&255)<<16|(m[19]&255)<<24,Me=m[20]&255|(m[21]&255)<<8|(m[22]&255)<<16|(m[23]&255)<<24,Ue=m[24]&255|(m[25]&255)<<8|(m[26]&255)<<16|(m[27]&255)<<24,$e=m[28]&255|(m[29]&255)<<8|(m[30]&255)<<16|(m[31]&255)<<24,De=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,Ae=_,be=U,pe=F,Ee=J,ye=ae,de=me,W=he,q=tt,re=ge,X=Te,Z=Le,oe=Fe,Ce=Me,He=Ue,We=$e,Qe=De,S,Ke=0;Ke<20;Ke+=2)S=Ae+Ce|0,ye^=S<<7|S>>>25,S=ye+Ae|0,re^=S<<9|S>>>23,S=re+ye|0,Ce^=S<<13|S>>>19,S=Ce+re|0,Ae^=S<<18|S>>>14,S=de+be|0,X^=S<<7|S>>>25,S=X+de|0,He^=S<<9|S>>>23,S=He+X|0,be^=S<<13|S>>>19,S=be+He|0,de^=S<<18|S>>>14,S=Z+W|0,We^=S<<7|S>>>25,S=We+Z|0,pe^=S<<9|S>>>23,S=pe+We|0,W^=S<<13|S>>>19,S=W+pe|0,Z^=S<<18|S>>>14,S=Qe+oe|0,Ee^=S<<7|S>>>25,S=Ee+Qe|0,q^=S<<9|S>>>23,S=q+Ee|0,oe^=S<<13|S>>>19,S=oe+q|0,Qe^=S<<18|S>>>14,S=Ae+Ee|0,be^=S<<7|S>>>25,S=be+Ae|0,pe^=S<<9|S>>>23,S=pe+be|0,Ee^=S<<13|S>>>19,S=Ee+pe|0,Ae^=S<<18|S>>>14,S=de+ye|0,W^=S<<7|S>>>25,S=W+de|0,q^=S<<9|S>>>23,S=q+W|0,ye^=S<<13|S>>>19,S=ye+q|0,de^=S<<18|S>>>14,S=Z+X|0,oe^=S<<7|S>>>25,S=oe+Z|0,re^=S<<9|S>>>23,S=re+oe|0,X^=S<<13|S>>>19,S=X+re|0,Z^=S<<18|S>>>14,S=Qe+We|0,Ce^=S<<7|S>>>25,S=Ce+Qe|0,He^=S<<9|S>>>23,S=He+Ce|0,We^=S<<13|S>>>19,S=We+He|0,Qe^=S<<18|S>>>14;Ae=Ae+_|0,be=be+U|0,pe=pe+F|0,Ee=Ee+J|0,ye=ye+ae|0,de=de+me|0,W=W+he|0,q=q+tt|0,re=re+ge|0,X=X+Te|0,Z=Z+Le|0,oe=oe+Fe|0,Ce=Ce+Me|0,He=He+Ue|0,We=We+$e|0,Qe=Qe+De|0,g[0]=Ae>>>0&255,g[1]=Ae>>>8&255,g[2]=Ae>>>16&255,g[3]=Ae>>>24&255,g[4]=be>>>0&255,g[5]=be>>>8&255,g[6]=be>>>16&255,g[7]=be>>>24&255,g[8]=pe>>>0&255,g[9]=pe>>>8&255,g[10]=pe>>>16&255,g[11]=pe>>>24&255,g[12]=Ee>>>0&255,g[13]=Ee>>>8&255,g[14]=Ee>>>16&255,g[15]=Ee>>>24&255,g[16]=ye>>>0&255,g[17]=ye>>>8&255,g[18]=ye>>>16&255,g[19]=ye>>>24&255,g[20]=de>>>0&255,g[21]=de>>>8&255,g[22]=de>>>16&255,g[23]=de>>>24&255,g[24]=W>>>0&255,g[25]=W>>>8&255,g[26]=W>>>16&255,g[27]=W>>>24&255,g[28]=q>>>0&255,g[29]=q>>>8&255,g[30]=q>>>16&255,g[31]=q>>>24&255,g[32]=re>>>0&255,g[33]=re>>>8&255,g[34]=re>>>16&255,g[35]=re>>>24&255,g[36]=X>>>0&255,g[37]=X>>>8&255,g[38]=X>>>16&255,g[39]=X>>>24&255,g[40]=Z>>>0&255,g[41]=Z>>>8&255,g[42]=Z>>>16&255,g[43]=Z>>>24&255,g[44]=oe>>>0&255,g[45]=oe>>>8&255,g[46]=oe>>>16&255,g[47]=oe>>>24&255,g[48]=Ce>>>0&255,g[49]=Ce>>>8&255,g[50]=Ce>>>16&255,g[51]=Ce>>>24&255,g[52]=He>>>0&255,g[53]=He>>>8&255,g[54]=He>>>16&255,g[55]=He>>>24&255,g[56]=We>>>0&255,g[57]=We>>>8&255,g[58]=We>>>16&255,g[59]=We>>>24&255,g[60]=Qe>>>0&255,g[61]=Qe>>>8&255,g[62]=Qe>>>16&255,g[63]=Qe>>>24&255}function N(g,A,m,d){for(var _=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,U=m[0]&255|(m[1]&255)<<8|(m[2]&255)<<16|(m[3]&255)<<24,F=m[4]&255|(m[5]&255)<<8|(m[6]&255)<<16|(m[7]&255)<<24,J=m[8]&255|(m[9]&255)<<8|(m[10]&255)<<16|(m[11]&255)<<24,ae=m[12]&255|(m[13]&255)<<8|(m[14]&255)<<16|(m[15]&255)<<24,me=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,he=A[0]&255|(A[1]&255)<<8|(A[2]&255)<<16|(A[3]&255)<<24,tt=A[4]&255|(A[5]&255)<<8|(A[6]&255)<<16|(A[7]&255)<<24,ge=A[8]&255|(A[9]&255)<<8|(A[10]&255)<<16|(A[11]&255)<<24,Te=A[12]&255|(A[13]&255)<<8|(A[14]&255)<<16|(A[15]&255)<<24,Le=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,Fe=m[16]&255|(m[17]&255)<<8|(m[18]&255)<<16|(m[19]&255)<<24,Me=m[20]&255|(m[21]&255)<<8|(m[22]&255)<<16|(m[23]&255)<<24,Ue=m[24]&255|(m[25]&255)<<8|(m[26]&255)<<16|(m[27]&255)<<24,$e=m[28]&255|(m[29]&255)<<8|(m[30]&255)<<16|(m[31]&255)<<24,De=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,Ae=_,be=U,pe=F,Ee=J,ye=ae,de=me,W=he,q=tt,re=ge,X=Te,Z=Le,oe=Fe,Ce=Me,He=Ue,We=$e,Qe=De,S,Ke=0;Ke<20;Ke+=2)S=Ae+Ce|0,ye^=S<<7|S>>>25,S=ye+Ae|0,re^=S<<9|S>>>23,S=re+ye|0,Ce^=S<<13|S>>>19,S=Ce+re|0,Ae^=S<<18|S>>>14,S=de+be|0,X^=S<<7|S>>>25,S=X+de|0,He^=S<<9|S>>>23,S=He+X|0,be^=S<<13|S>>>19,S=be+He|0,de^=S<<18|S>>>14,S=Z+W|0,We^=S<<7|S>>>25,S=We+Z|0,pe^=S<<9|S>>>23,S=pe+We|0,W^=S<<13|S>>>19,S=W+pe|0,Z^=S<<18|S>>>14,S=Qe+oe|0,Ee^=S<<7|S>>>25,S=Ee+Qe|0,q^=S<<9|S>>>23,S=q+Ee|0,oe^=S<<13|S>>>19,S=oe+q|0,Qe^=S<<18|S>>>14,S=Ae+Ee|0,be^=S<<7|S>>>25,S=be+Ae|0,pe^=S<<9|S>>>23,S=pe+be|0,Ee^=S<<13|S>>>19,S=Ee+pe|0,Ae^=S<<18|S>>>14,S=de+ye|0,W^=S<<7|S>>>25,S=W+de|0,q^=S<<9|S>>>23,S=q+W|0,ye^=S<<13|S>>>19,S=ye+q|0,de^=S<<18|S>>>14,S=Z+X|0,oe^=S<<7|S>>>25,S=oe+Z|0,re^=S<<9|S>>>23,S=re+oe|0,X^=S<<13|S>>>19,S=X+re|0,Z^=S<<18|S>>>14,S=Qe+We|0,Ce^=S<<7|S>>>25,S=Ce+Qe|0,He^=S<<9|S>>>23,S=He+Ce|0,We^=S<<13|S>>>19,S=We+He|0,Qe^=S<<18|S>>>14;g[0]=Ae>>>0&255,g[1]=Ae>>>8&255,g[2]=Ae>>>16&255,g[3]=Ae>>>24&255,g[4]=de>>>0&255,g[5]=de>>>8&255,g[6]=de>>>16&255,g[7]=de>>>24&255,g[8]=Z>>>0&255,g[9]=Z>>>8&255,g[10]=Z>>>16&255,g[11]=Z>>>24&255,g[12]=Qe>>>0&255,g[13]=Qe>>>8&255,g[14]=Qe>>>16&255,g[15]=Qe>>>24&255,g[16]=W>>>0&255,g[17]=W>>>8&255,g[18]=W>>>16&255,g[19]=W>>>24&255,g[20]=q>>>0&255,g[21]=q>>>8&255,g[22]=q>>>16&255,g[23]=q>>>24&255,g[24]=re>>>0&255,g[25]=re>>>8&255,g[26]=re>>>16&255,g[27]=re>>>24&255,g[28]=X>>>0&255,g[29]=X>>>8&255,g[30]=X>>>16&255,g[31]=X>>>24&255}function H(g,A,m,d){C(g,A,m,d)}function v(g,A,m,d){N(g,A,m,d)}var M=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Q(g,A,m,d,_,U,F){var J=new Uint8Array(16),ae=new Uint8Array(64),me,he;for(he=0;he<16;he++)J[he]=0;for(he=0;he<8;he++)J[he]=U[he];for(;_>=64;){for(H(ae,J,F,M),he=0;he<64;he++)g[A+he]=m[d+he]^ae[he];for(me=1,he=8;he<16;he++)me=me+(J[he]&255)|0,J[he]=me&255,me>>>=8;_-=64,A+=64,d+=64}if(_>0)for(H(ae,J,F,M),he=0;he<_;he++)g[A+he]=m[d+he]^ae[he];return 0}function P(g,A,m,d,_){var U=new Uint8Array(16),F=new Uint8Array(64),J,ae;for(ae=0;ae<16;ae++)U[ae]=0;for(ae=0;ae<8;ae++)U[ae]=d[ae];for(;m>=64;){for(H(F,U,_,M),ae=0;ae<64;ae++)g[A+ae]=F[ae];for(J=1,ae=8;ae<16;ae++)J=J+(U[ae]&255)|0,U[ae]=J&255,J>>>=8;m-=64,A+=64}if(m>0)for(H(F,U,_,M),ae=0;ae<m;ae++)g[A+ae]=F[ae];return 0}function x(g,A,m,d,_){var U=new Uint8Array(32);v(U,d,_,M);for(var F=new Uint8Array(8),J=0;J<8;J++)F[J]=d[J+16];return P(g,A,m,F,U)}function w(g,A,m,d,_,U,F){var J=new Uint8Array(32);v(J,U,F,M);for(var ae=new Uint8Array(8),me=0;me<8;me++)ae[me]=U[me+16];return Q(g,A,m,d,_,ae,J)}var I=function(g){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var A,m,d,_,U,F,J,ae;A=g[0]&255|(g[1]&255)<<8,this.r[0]=A&8191,m=g[2]&255|(g[3]&255)<<8,this.r[1]=(A>>>13|m<<3)&8191,d=g[4]&255|(g[5]&255)<<8,this.r[2]=(m>>>10|d<<6)&7939,_=g[6]&255|(g[7]&255)<<8,this.r[3]=(d>>>7|_<<9)&8191,U=g[8]&255|(g[9]&255)<<8,this.r[4]=(_>>>4|U<<12)&255,this.r[5]=U>>>1&8190,F=g[10]&255|(g[11]&255)<<8,this.r[6]=(U>>>14|F<<2)&8191,J=g[12]&255|(g[13]&255)<<8,this.r[7]=(F>>>11|J<<5)&8065,ae=g[14]&255|(g[15]&255)<<8,this.r[8]=(J>>>8|ae<<8)&8191,this.r[9]=ae>>>5&127,this.pad[0]=g[16]&255|(g[17]&255)<<8,this.pad[1]=g[18]&255|(g[19]&255)<<8,this.pad[2]=g[20]&255|(g[21]&255)<<8,this.pad[3]=g[22]&255|(g[23]&255)<<8,this.pad[4]=g[24]&255|(g[25]&255)<<8,this.pad[5]=g[26]&255|(g[27]&255)<<8,this.pad[6]=g[28]&255|(g[29]&255)<<8,this.pad[7]=g[30]&255|(g[31]&255)<<8};I.prototype.blocks=function(g,A,m){for(var d=this.fin?0:2048,_,U,F,J,ae,me,he,tt,ge,Te,Le,Fe,Me,Ue,$e,De,Ae,be,pe,Ee=this.h[0],ye=this.h[1],de=this.h[2],W=this.h[3],q=this.h[4],re=this.h[5],X=this.h[6],Z=this.h[7],oe=this.h[8],Ce=this.h[9],He=this.r[0],We=this.r[1],Qe=this.r[2],S=this.r[3],Ke=this.r[4],nt=this.r[5],rt=this.r[6],qe=this.r[7],Je=this.r[8],Ze=this.r[9];m>=16;)_=g[A+0]&255|(g[A+1]&255)<<8,Ee+=_&8191,U=g[A+2]&255|(g[A+3]&255)<<8,ye+=(_>>>13|U<<3)&8191,F=g[A+4]&255|(g[A+5]&255)<<8,de+=(U>>>10|F<<6)&8191,J=g[A+6]&255|(g[A+7]&255)<<8,W+=(F>>>7|J<<9)&8191,ae=g[A+8]&255|(g[A+9]&255)<<8,q+=(J>>>4|ae<<12)&8191,re+=ae>>>1&8191,me=g[A+10]&255|(g[A+11]&255)<<8,X+=(ae>>>14|me<<2)&8191,he=g[A+12]&255|(g[A+13]&255)<<8,Z+=(me>>>11|he<<5)&8191,tt=g[A+14]&255|(g[A+15]&255)<<8,oe+=(he>>>8|tt<<8)&8191,Ce+=tt>>>5|d,ge=0,Te=ge,Te+=Ee*He,Te+=ye*(5*Ze),Te+=de*(5*Je),Te+=W*(5*qe),Te+=q*(5*rt),ge=Te>>>13,Te&=8191,Te+=re*(5*nt),Te+=X*(5*Ke),Te+=Z*(5*S),Te+=oe*(5*Qe),Te+=Ce*(5*We),ge+=Te>>>13,Te&=8191,Le=ge,Le+=Ee*We,Le+=ye*He,Le+=de*(5*Ze),Le+=W*(5*Je),Le+=q*(5*qe),ge=Le>>>13,Le&=8191,Le+=re*(5*rt),Le+=X*(5*nt),Le+=Z*(5*Ke),Le+=oe*(5*S),Le+=Ce*(5*Qe),ge+=Le>>>13,Le&=8191,Fe=ge,Fe+=Ee*Qe,Fe+=ye*We,Fe+=de*He,Fe+=W*(5*Ze),Fe+=q*(5*Je),ge=Fe>>>13,Fe&=8191,Fe+=re*(5*qe),Fe+=X*(5*rt),Fe+=Z*(5*nt),Fe+=oe*(5*Ke),Fe+=Ce*(5*S),ge+=Fe>>>13,Fe&=8191,Me=ge,Me+=Ee*S,Me+=ye*Qe,Me+=de*We,Me+=W*He,Me+=q*(5*Ze),ge=Me>>>13,Me&=8191,Me+=re*(5*Je),Me+=X*(5*qe),Me+=Z*(5*rt),Me+=oe*(5*nt),Me+=Ce*(5*Ke),ge+=Me>>>13,Me&=8191,Ue=ge,Ue+=Ee*Ke,Ue+=ye*S,Ue+=de*Qe,Ue+=W*We,Ue+=q*He,ge=Ue>>>13,Ue&=8191,Ue+=re*(5*Ze),Ue+=X*(5*Je),Ue+=Z*(5*qe),Ue+=oe*(5*rt),Ue+=Ce*(5*nt),ge+=Ue>>>13,Ue&=8191,$e=ge,$e+=Ee*nt,$e+=ye*Ke,$e+=de*S,$e+=W*Qe,$e+=q*We,ge=$e>>>13,$e&=8191,$e+=re*He,$e+=X*(5*Ze),$e+=Z*(5*Je),$e+=oe*(5*qe),$e+=Ce*(5*rt),ge+=$e>>>13,$e&=8191,De=ge,De+=Ee*rt,De+=ye*nt,De+=de*Ke,De+=W*S,De+=q*Qe,ge=De>>>13,De&=8191,De+=re*We,De+=X*He,De+=Z*(5*Ze),De+=oe*(5*Je),De+=Ce*(5*qe),ge+=De>>>13,De&=8191,Ae=ge,Ae+=Ee*qe,Ae+=ye*rt,Ae+=de*nt,Ae+=W*Ke,Ae+=q*S,ge=Ae>>>13,Ae&=8191,Ae+=re*Qe,Ae+=X*We,Ae+=Z*He,Ae+=oe*(5*Ze),Ae+=Ce*(5*Je),ge+=Ae>>>13,Ae&=8191,be=ge,be+=Ee*Je,be+=ye*qe,be+=de*rt,be+=W*nt,be+=q*Ke,ge=be>>>13,be&=8191,be+=re*S,be+=X*Qe,be+=Z*We,be+=oe*He,be+=Ce*(5*Ze),ge+=be>>>13,be&=8191,pe=ge,pe+=Ee*Ze,pe+=ye*Je,pe+=de*qe,pe+=W*rt,pe+=q*nt,ge=pe>>>13,pe&=8191,pe+=re*Ke,pe+=X*S,pe+=Z*Qe,pe+=oe*We,pe+=Ce*He,ge+=pe>>>13,pe&=8191,ge=(ge<<2)+ge|0,ge=ge+Te|0,Te=ge&8191,ge=ge>>>13,Le+=ge,Ee=Te,ye=Le,de=Fe,W=Me,q=Ue,re=$e,X=De,Z=Ae,oe=be,Ce=pe,A+=16,m-=16;this.h[0]=Ee,this.h[1]=ye,this.h[2]=de,this.h[3]=W,this.h[4]=q,this.h[5]=re,this.h[6]=X,this.h[7]=Z,this.h[8]=oe,this.h[9]=Ce},I.prototype.finish=function(g,A){var m=new Uint16Array(10),d,_,U,F;if(this.leftover){for(F=this.leftover,this.buffer[F++]=1;F<16;F++)this.buffer[F]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(d=this.h[1]>>>13,this.h[1]&=8191,F=2;F<10;F++)this.h[F]+=d,d=this.h[F]>>>13,this.h[F]&=8191;for(this.h[0]+=d*5,d=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=d,d=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=d,m[0]=this.h[0]+5,d=m[0]>>>13,m[0]&=8191,F=1;F<10;F++)m[F]=this.h[F]+d,d=m[F]>>>13,m[F]&=8191;for(m[9]-=8192,_=(d^1)-1,F=0;F<10;F++)m[F]&=_;for(_=~_,F=0;F<10;F++)this.h[F]=this.h[F]&_|m[F];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,U=this.h[0]+this.pad[0],this.h[0]=U&65535,F=1;F<8;F++)U=(this.h[F]+this.pad[F]|0)+(U>>>16)|0,this.h[F]=U&65535;g[A+0]=this.h[0]>>>0&255,g[A+1]=this.h[0]>>>8&255,g[A+2]=this.h[1]>>>0&255,g[A+3]=this.h[1]>>>8&255,g[A+4]=this.h[2]>>>0&255,g[A+5]=this.h[2]>>>8&255,g[A+6]=this.h[3]>>>0&255,g[A+7]=this.h[3]>>>8&255,g[A+8]=this.h[4]>>>0&255,g[A+9]=this.h[4]>>>8&255,g[A+10]=this.h[5]>>>0&255,g[A+11]=this.h[5]>>>8&255,g[A+12]=this.h[6]>>>0&255,g[A+13]=this.h[6]>>>8&255,g[A+14]=this.h[7]>>>0&255,g[A+15]=this.h[7]>>>8&255},I.prototype.update=function(g,A,m){var d,_;if(this.leftover){for(_=16-this.leftover,_>m&&(_=m),d=0;d<_;d++)this.buffer[this.leftover+d]=g[A+d];if(m-=_,A+=_,this.leftover+=_,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(m>=16&&(_=m-m%16,this.blocks(g,A,_),A+=_,m-=_),m){for(d=0;d<m;d++)this.buffer[this.leftover+d]=g[A+d];this.leftover+=m}};function k(g,A,m,d,_,U){var F=new I(U);return F.update(m,d,_),F.finish(g,A),0}function R(g,A,m,d,_,U){var F=new Uint8Array(16);return k(F,0,m,d,_,U),E(g,A,F,0)}function ne(g,A,m,d,_){var U;if(m<32)return-1;for(w(g,0,A,0,m,d,_),k(g,16,g,32,m-32,g),U=0;U<16;U++)g[U]=0;return 0}function z(g,A,m,d,_){var U,F=new Uint8Array(32);if(m<32||(x(F,0,32,d,_),R(A,16,A,32,m-32,F)!==0))return-1;for(w(g,0,A,0,m,d,_),U=0;U<32;U++)g[U]=0;return 0}function Y(g,A){var m;for(m=0;m<16;m++)g[m]=A[m]|0}function te(g){var A,m,d=1;for(A=0;A<16;A++)m=g[A]+d+65535,d=Math.floor(m/65536),g[A]=m-d*65536;g[0]+=d-1+37*(d-1)}function ce(g,A,m){for(var d,_=~(m-1),U=0;U<16;U++)d=_&(g[U]^A[U]),g[U]^=d,A[U]^=d}function $(g,A){var m,d,_,U=t(),F=t();for(m=0;m<16;m++)F[m]=A[m];for(te(F),te(F),te(F),d=0;d<2;d++){for(U[0]=F[0]-65517,m=1;m<15;m++)U[m]=F[m]-65535-(U[m-1]>>16&1),U[m-1]&=65535;U[15]=F[15]-32767-(U[14]>>16&1),_=U[15]>>16&1,U[14]&=65535,ce(F,U,1-_)}for(m=0;m<16;m++)g[2*m]=F[m]&255,g[2*m+1]=F[m]>>8}function B(g,A){var m=new Uint8Array(32),d=new Uint8Array(32);return $(m,g),$(d,A),b(m,0,d,0)}function L(g){var A=new Uint8Array(32);return $(A,g),A[0]&1}function K(g,A){var m;for(m=0;m<16;m++)g[m]=A[2*m]+(A[2*m+1]<<8);g[15]&=32767}function ee(g,A,m){for(var d=0;d<16;d++)g[d]=A[d]+m[d]}function fe(g,A,m){for(var d=0;d<16;d++)g[d]=A[d]-m[d]}function ie(g,A,m){var d,_,U=0,F=0,J=0,ae=0,me=0,he=0,tt=0,ge=0,Te=0,Le=0,Fe=0,Me=0,Ue=0,$e=0,De=0,Ae=0,be=0,pe=0,Ee=0,ye=0,de=0,W=0,q=0,re=0,X=0,Z=0,oe=0,Ce=0,He=0,We=0,Qe=0,S=m[0],Ke=m[1],nt=m[2],rt=m[3],qe=m[4],Je=m[5],Ze=m[6],kt=m[7],lt=m[8],It=m[9],Ct=m[10],vt=m[11],Ut=m[12],Qt=m[13],Wt=m[14],qt=m[15];d=A[0],U+=d*S,F+=d*Ke,J+=d*nt,ae+=d*rt,me+=d*qe,he+=d*Je,tt+=d*Ze,ge+=d*kt,Te+=d*lt,Le+=d*It,Fe+=d*Ct,Me+=d*vt,Ue+=d*Ut,$e+=d*Qt,De+=d*Wt,Ae+=d*qt,d=A[1],F+=d*S,J+=d*Ke,ae+=d*nt,me+=d*rt,he+=d*qe,tt+=d*Je,ge+=d*Ze,Te+=d*kt,Le+=d*lt,Fe+=d*It,Me+=d*Ct,Ue+=d*vt,$e+=d*Ut,De+=d*Qt,Ae+=d*Wt,be+=d*qt,d=A[2],J+=d*S,ae+=d*Ke,me+=d*nt,he+=d*rt,tt+=d*qe,ge+=d*Je,Te+=d*Ze,Le+=d*kt,Fe+=d*lt,Me+=d*It,Ue+=d*Ct,$e+=d*vt,De+=d*Ut,Ae+=d*Qt,be+=d*Wt,pe+=d*qt,d=A[3],ae+=d*S,me+=d*Ke,he+=d*nt,tt+=d*rt,ge+=d*qe,Te+=d*Je,Le+=d*Ze,Fe+=d*kt,Me+=d*lt,Ue+=d*It,$e+=d*Ct,De+=d*vt,Ae+=d*Ut,be+=d*Qt,pe+=d*Wt,Ee+=d*qt,d=A[4],me+=d*S,he+=d*Ke,tt+=d*nt,ge+=d*rt,Te+=d*qe,Le+=d*Je,Fe+=d*Ze,Me+=d*kt,Ue+=d*lt,$e+=d*It,De+=d*Ct,Ae+=d*vt,be+=d*Ut,pe+=d*Qt,Ee+=d*Wt,ye+=d*qt,d=A[5],he+=d*S,tt+=d*Ke,ge+=d*nt,Te+=d*rt,Le+=d*qe,Fe+=d*Je,Me+=d*Ze,Ue+=d*kt,$e+=d*lt,De+=d*It,Ae+=d*Ct,be+=d*vt,pe+=d*Ut,Ee+=d*Qt,ye+=d*Wt,de+=d*qt,d=A[6],tt+=d*S,ge+=d*Ke,Te+=d*nt,Le+=d*rt,Fe+=d*qe,Me+=d*Je,Ue+=d*Ze,$e+=d*kt,De+=d*lt,Ae+=d*It,be+=d*Ct,pe+=d*vt,Ee+=d*Ut,ye+=d*Qt,de+=d*Wt,W+=d*qt,d=A[7],ge+=d*S,Te+=d*Ke,Le+=d*nt,Fe+=d*rt,Me+=d*qe,Ue+=d*Je,$e+=d*Ze,De+=d*kt,Ae+=d*lt,be+=d*It,pe+=d*Ct,Ee+=d*vt,ye+=d*Ut,de+=d*Qt,W+=d*Wt,q+=d*qt,d=A[8],Te+=d*S,Le+=d*Ke,Fe+=d*nt,Me+=d*rt,Ue+=d*qe,$e+=d*Je,De+=d*Ze,Ae+=d*kt,be+=d*lt,pe+=d*It,Ee+=d*Ct,ye+=d*vt,de+=d*Ut,W+=d*Qt,q+=d*Wt,re+=d*qt,d=A[9],Le+=d*S,Fe+=d*Ke,Me+=d*nt,Ue+=d*rt,$e+=d*qe,De+=d*Je,Ae+=d*Ze,be+=d*kt,pe+=d*lt,Ee+=d*It,ye+=d*Ct,de+=d*vt,W+=d*Ut,q+=d*Qt,re+=d*Wt,X+=d*qt,d=A[10],Fe+=d*S,Me+=d*Ke,Ue+=d*nt,$e+=d*rt,De+=d*qe,Ae+=d*Je,be+=d*Ze,pe+=d*kt,Ee+=d*lt,ye+=d*It,de+=d*Ct,W+=d*vt,q+=d*Ut,re+=d*Qt,X+=d*Wt,Z+=d*qt,d=A[11],Me+=d*S,Ue+=d*Ke,$e+=d*nt,De+=d*rt,Ae+=d*qe,be+=d*Je,pe+=d*Ze,Ee+=d*kt,ye+=d*lt,de+=d*It,W+=d*Ct,q+=d*vt,re+=d*Ut,X+=d*Qt,Z+=d*Wt,oe+=d*qt,d=A[12],Ue+=d*S,$e+=d*Ke,De+=d*nt,Ae+=d*rt,be+=d*qe,pe+=d*Je,Ee+=d*Ze,ye+=d*kt,de+=d*lt,W+=d*It,q+=d*Ct,re+=d*vt,X+=d*Ut,Z+=d*Qt,oe+=d*Wt,Ce+=d*qt,d=A[13],$e+=d*S,De+=d*Ke,Ae+=d*nt,be+=d*rt,pe+=d*qe,Ee+=d*Je,ye+=d*Ze,de+=d*kt,W+=d*lt,q+=d*It,re+=d*Ct,X+=d*vt,Z+=d*Ut,oe+=d*Qt,Ce+=d*Wt,He+=d*qt,d=A[14],De+=d*S,Ae+=d*Ke,be+=d*nt,pe+=d*rt,Ee+=d*qe,ye+=d*Je,de+=d*Ze,W+=d*kt,q+=d*lt,re+=d*It,X+=d*Ct,Z+=d*vt,oe+=d*Ut,Ce+=d*Qt,He+=d*Wt,We+=d*qt,d=A[15],Ae+=d*S,be+=d*Ke,pe+=d*nt,Ee+=d*rt,ye+=d*qe,de+=d*Je,W+=d*Ze,q+=d*kt,re+=d*lt,X+=d*It,Z+=d*Ct,oe+=d*vt,Ce+=d*Ut,He+=d*Qt,We+=d*Wt,Qe+=d*qt,U+=38*be,F+=38*pe,J+=38*Ee,ae+=38*ye,me+=38*de,he+=38*W,tt+=38*q,ge+=38*re,Te+=38*X,Le+=38*Z,Fe+=38*oe,Me+=38*Ce,Ue+=38*He,$e+=38*We,De+=38*Qe,_=1,d=U+_+65535,_=Math.floor(d/65536),U=d-_*65536,d=F+_+65535,_=Math.floor(d/65536),F=d-_*65536,d=J+_+65535,_=Math.floor(d/65536),J=d-_*65536,d=ae+_+65535,_=Math.floor(d/65536),ae=d-_*65536,d=me+_+65535,_=Math.floor(d/65536),me=d-_*65536,d=he+_+65535,_=Math.floor(d/65536),he=d-_*65536,d=tt+_+65535,_=Math.floor(d/65536),tt=d-_*65536,d=ge+_+65535,_=Math.floor(d/65536),ge=d-_*65536,d=Te+_+65535,_=Math.floor(d/65536),Te=d-_*65536,d=Le+_+65535,_=Math.floor(d/65536),Le=d-_*65536,d=Fe+_+65535,_=Math.floor(d/65536),Fe=d-_*65536,d=Me+_+65535,_=Math.floor(d/65536),Me=d-_*65536,d=Ue+_+65535,_=Math.floor(d/65536),Ue=d-_*65536,d=$e+_+65535,_=Math.floor(d/65536),$e=d-_*65536,d=De+_+65535,_=Math.floor(d/65536),De=d-_*65536,d=Ae+_+65535,_=Math.floor(d/65536),Ae=d-_*65536,U+=_-1+37*(_-1),_=1,d=U+_+65535,_=Math.floor(d/65536),U=d-_*65536,d=F+_+65535,_=Math.floor(d/65536),F=d-_*65536,d=J+_+65535,_=Math.floor(d/65536),J=d-_*65536,d=ae+_+65535,_=Math.floor(d/65536),ae=d-_*65536,d=me+_+65535,_=Math.floor(d/65536),me=d-_*65536,d=he+_+65535,_=Math.floor(d/65536),he=d-_*65536,d=tt+_+65535,_=Math.floor(d/65536),tt=d-_*65536,d=ge+_+65535,_=Math.floor(d/65536),ge=d-_*65536,d=Te+_+65535,_=Math.floor(d/65536),Te=d-_*65536,d=Le+_+65535,_=Math.floor(d/65536),Le=d-_*65536,d=Fe+_+65535,_=Math.floor(d/65536),Fe=d-_*65536,d=Me+_+65535,_=Math.floor(d/65536),Me=d-_*65536,d=Ue+_+65535,_=Math.floor(d/65536),Ue=d-_*65536,d=$e+_+65535,_=Math.floor(d/65536),$e=d-_*65536,d=De+_+65535,_=Math.floor(d/65536),De=d-_*65536,d=Ae+_+65535,_=Math.floor(d/65536),Ae=d-_*65536,U+=_-1+37*(_-1),g[0]=U,g[1]=F,g[2]=J,g[3]=ae,g[4]=me,g[5]=he,g[6]=tt,g[7]=ge,g[8]=Te,g[9]=Le,g[10]=Fe,g[11]=Me,g[12]=Ue,g[13]=$e,g[14]=De,g[15]=Ae}function Ye(g,A){ie(g,A,A)}function ft(g,A){var m=t(),d;for(d=0;d<16;d++)m[d]=A[d];for(d=253;d>=0;d--)Ye(m,m),d!==2&&d!==4&&ie(m,m,A);for(d=0;d<16;d++)g[d]=m[d]}function rn(g,A){var m=t(),d;for(d=0;d<16;d++)m[d]=A[d];for(d=250;d>=0;d--)Ye(m,m),d!==1&&ie(m,m,A);for(d=0;d<16;d++)g[d]=m[d]}function pr(g,A,m){var d=new Uint8Array(32),_=new Float64Array(80),U,F,J=t(),ae=t(),me=t(),he=t(),tt=t(),ge=t();for(F=0;F<31;F++)d[F]=A[F];for(d[31]=A[31]&127|64,d[0]&=248,K(_,m),F=0;F<16;F++)ae[F]=_[F],he[F]=J[F]=me[F]=0;for(J[0]=he[0]=1,F=254;F>=0;--F)U=d[F>>>3]>>>(F&7)&1,ce(J,ae,U),ce(me,he,U),ee(tt,J,me),fe(J,J,me),ee(me,ae,he),fe(ae,ae,he),Ye(he,tt),Ye(ge,J),ie(J,me,J),ie(me,ae,tt),ee(tt,J,me),fe(J,J,me),Ye(ae,J),fe(me,he,ge),ie(J,me,a),ee(J,J,he),ie(me,me,J),ie(J,he,ge),ie(he,ae,_),Ye(ae,tt),ce(J,ae,U),ce(me,he,U);for(F=0;F<16;F++)_[F+16]=J[F],_[F+32]=me[F],_[F+48]=ae[F],_[F+64]=he[F];var Te=_.subarray(32),Le=_.subarray(16);return ft(Te,Te),ie(Le,Le,Te),$(g,Le),0}function gr(g,A){return pr(g,A,s)}function Bn(g,A){return e(A,32),gr(g,A)}function mr(g,A,m){var d=new Uint8Array(32);return pr(d,m,A),v(g,r,d,M)}var Xr=ne,Qi=z;function Jr(g,A,m,d,_,U){var F=new Uint8Array(32);return mr(F,_,U),Xr(g,A,m,d,F)}function Ar(g,A,m,d,_,U){var F=new Uint8Array(32);return mr(F,_,U),Qi(g,A,m,d,F)}var Er=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function j(g,A,m,d){for(var _=new Int32Array(16),U=new Int32Array(16),F,J,ae,me,he,tt,ge,Te,Le,Fe,Me,Ue,$e,De,Ae,be,pe,Ee,ye,de,W,q,re,X,Z,oe,Ce=g[0],He=g[1],We=g[2],Qe=g[3],S=g[4],Ke=g[5],nt=g[6],rt=g[7],qe=A[0],Je=A[1],Ze=A[2],kt=A[3],lt=A[4],It=A[5],Ct=A[6],vt=A[7],Ut=0;d>=128;){for(ye=0;ye<16;ye++)de=8*ye+Ut,_[ye]=m[de+0]<<24|m[de+1]<<16|m[de+2]<<8|m[de+3],U[ye]=m[de+4]<<24|m[de+5]<<16|m[de+6]<<8|m[de+7];for(ye=0;ye<80;ye++)if(F=Ce,J=He,ae=We,me=Qe,he=S,tt=Ke,ge=nt,Te=rt,Le=qe,Fe=Je,Me=Ze,Ue=kt,$e=lt,De=It,Ae=Ct,be=vt,W=rt,q=vt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=(S>>>14|lt<<18)^(S>>>18|lt<<14)^(lt>>>9|S<<23),q=(lt>>>14|S<<18)^(lt>>>18|S<<14)^(S>>>9|lt<<23),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=S&Ke^~S&nt,q=lt&It^~lt&Ct,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=Er[ye*2],q=Er[ye*2+1],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=_[ye%16],q=U[ye%16],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,pe=Z&65535|oe<<16,Ee=re&65535|X<<16,W=pe,q=Ee,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=(Ce>>>28|qe<<4)^(qe>>>2|Ce<<30)^(qe>>>7|Ce<<25),q=(qe>>>28|Ce<<4)^(Ce>>>2|qe<<30)^(Ce>>>7|qe<<25),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,W=Ce&He^Ce&We^He&We,q=qe&Je^qe&Ze^Je&Ze,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,Te=Z&65535|oe<<16,be=re&65535|X<<16,W=me,q=Ue,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=pe,q=Ee,re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,me=Z&65535|oe<<16,Ue=re&65535|X<<16,He=F,We=J,Qe=ae,S=me,Ke=he,nt=tt,rt=ge,Ce=Te,Je=Le,Ze=Fe,kt=Me,lt=Ue,It=$e,Ct=De,vt=Ae,qe=be,ye%16===15)for(de=0;de<16;de++)W=_[de],q=U[de],re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=_[(de+9)%16],q=U[(de+9)%16],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,pe=_[(de+1)%16],Ee=U[(de+1)%16],W=(pe>>>1|Ee<<31)^(pe>>>8|Ee<<24)^pe>>>7,q=(Ee>>>1|pe<<31)^(Ee>>>8|pe<<24)^(Ee>>>7|pe<<25),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,pe=_[(de+14)%16],Ee=U[(de+14)%16],W=(pe>>>19|Ee<<13)^(Ee>>>29|pe<<3)^pe>>>6,q=(Ee>>>19|pe<<13)^(pe>>>29|Ee<<3)^(Ee>>>6|pe<<26),re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,_[de]=Z&65535|oe<<16,U[de]=re&65535|X<<16;W=Ce,q=qe,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[0],q=A[0],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[0]=Ce=Z&65535|oe<<16,A[0]=qe=re&65535|X<<16,W=He,q=Je,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[1],q=A[1],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[1]=He=Z&65535|oe<<16,A[1]=Je=re&65535|X<<16,W=We,q=Ze,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[2],q=A[2],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[2]=We=Z&65535|oe<<16,A[2]=Ze=re&65535|X<<16,W=Qe,q=kt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[3],q=A[3],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[3]=Qe=Z&65535|oe<<16,A[3]=kt=re&65535|X<<16,W=S,q=lt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[4],q=A[4],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[4]=S=Z&65535|oe<<16,A[4]=lt=re&65535|X<<16,W=Ke,q=It,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[5],q=A[5],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[5]=Ke=Z&65535|oe<<16,A[5]=It=re&65535|X<<16,W=nt,q=Ct,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[6],q=A[6],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[6]=nt=Z&65535|oe<<16,A[6]=Ct=re&65535|X<<16,W=rt,q=vt,re=q&65535,X=q>>>16,Z=W&65535,oe=W>>>16,W=g[7],q=A[7],re+=q&65535,X+=q>>>16,Z+=W&65535,oe+=W>>>16,X+=re>>>16,Z+=X>>>16,oe+=Z>>>16,g[7]=rt=Z&65535|oe<<16,A[7]=vt=re&65535|X<<16,Ut+=128,d-=128}return d}function ue(g,A,m){var d=new Int32Array(8),_=new Int32Array(8),U=new Uint8Array(256),F,J=m;for(d[0]=1779033703,d[1]=3144134277,d[2]=1013904242,d[3]=2773480762,d[4]=1359893119,d[5]=2600822924,d[6]=528734635,d[7]=1541459225,_[0]=4089235720,_[1]=2227873595,_[2]=4271175723,_[3]=1595750129,_[4]=2917565137,_[5]=725511199,_[6]=4215389547,_[7]=327033209,j(d,_,A,m),m%=128,F=0;F<m;F++)U[F]=A[J-m+F];for(U[m]=128,m=256-128*(m<112?1:0),U[m-9]=0,p(U,m-8,J/536870912|0,J<<3),j(d,_,U,m),F=0;F<8;F++)p(g,8*F,d[F],_[F]);return 0}function xe(g,A){var m=t(),d=t(),_=t(),U=t(),F=t(),J=t(),ae=t(),me=t(),he=t();fe(m,g[1],g[0]),fe(he,A[1],A[0]),ie(m,m,he),ee(d,g[0],g[1]),ee(he,A[0],A[1]),ie(d,d,he),ie(_,g[3],A[3]),ie(_,_,f),ie(U,g[2],A[2]),ee(U,U,U),fe(F,d,m),fe(J,U,_),ee(ae,U,_),ee(me,d,m),ie(g[0],F,J),ie(g[1],me,ae),ie(g[2],ae,J),ie(g[3],F,me)}function Pe(g,A,m){var d;for(d=0;d<4;d++)ce(g[d],A[d],m)}function je(g,A){var m=t(),d=t(),_=t();ft(_,A[2]),ie(m,A[0],_),ie(d,A[1],_),$(g,d),g[31]^=L(m)<<7}function Pt(g,A,m){var d,_;for(Y(g[0],i),Y(g[1],o),Y(g[2],o),Y(g[3],i),_=255;_>=0;--_)d=m[_/8|0]>>(_&7)&1,Pe(g,A,d),xe(A,g),xe(g,g),Pe(g,A,d)}function bn(g,A){var m=[t(),t(),t(),t()];Y(m[0],l),Y(m[1],u),Y(m[2],o),ie(m[3],l,u),Pt(g,m,A)}function sn(g,A,m){var d=new Uint8Array(64),_=[t(),t(),t(),t()],U;for(m||e(A,32),ue(d,A,32),d[0]&=248,d[31]&=127,d[31]|=64,bn(_,d),je(g,_),U=0;U<32;U++)A[U+32]=g[U];return 0}var yr=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ot(g,A){var m,d,_,U;for(d=63;d>=32;--d){for(m=0,_=d-32,U=d-12;_<U;++_)A[_]+=m-16*A[d]*yr[_-(d-32)],m=A[_]+128>>8,A[_]-=m*256;A[_]+=m,A[d]=0}for(m=0,_=0;_<32;_++)A[_]+=m-(A[31]>>4)*yr[_],m=A[_]>>8,A[_]&=255;for(_=0;_<32;_++)A[_]-=m*yr[_];for(d=0;d<32;d++)A[d+1]+=A[d]>>8,g[d]=A[d]&255}function Dt(g){var A=new Float64Array(64),m;for(m=0;m<64;m++)A[m]=g[m];for(m=0;m<64;m++)g[m]=0;ot(g,A)}function Lt(g,A,m,d){var _=new Uint8Array(64),U=new Uint8Array(64),F=new Uint8Array(64),J,ae,me=new Float64Array(64),he=[t(),t(),t(),t()];ue(_,d,32),_[0]&=248,_[31]&=127,_[31]|=64;var tt=m+64;for(J=0;J<m;J++)g[64+J]=A[J];for(J=0;J<32;J++)g[32+J]=_[32+J];for(ue(F,g.subarray(32),m+32),Dt(F),bn(he,F),je(g,he),J=32;J<64;J++)g[J]=d[J];for(ue(U,g,m+64),Dt(U),J=0;J<64;J++)me[J]=0;for(J=0;J<32;J++)me[J]=F[J];for(J=0;J<32;J++)for(ae=0;ae<32;ae++)me[J+ae]+=U[J]*_[ae];return ot(g.subarray(32),me),tt}function St(g,A){var m=t(),d=t(),_=t(),U=t(),F=t(),J=t(),ae=t();return Y(g[2],o),K(g[1],A),Ye(_,g[1]),ie(U,_,c),fe(_,_,g[2]),ee(U,g[2],U),Ye(F,U),Ye(J,F),ie(ae,J,F),ie(m,ae,_),ie(m,m,U),rn(m,m),ie(m,m,_),ie(m,m,U),ie(m,m,U),ie(g[0],m,U),Ye(d,g[0]),ie(d,d,U),B(d,_)&&ie(g[0],g[0],h),Ye(d,g[0]),ie(d,d,U),B(d,_)?-1:(L(g[0])===A[31]>>7&&fe(g[0],i,g[0]),ie(g[3],g[0],g[1]),0)}function pt(g,A,m,d){var _,U,F=new Uint8Array(32),J=new Uint8Array(64),ae=[t(),t(),t(),t()],me=[t(),t(),t(),t()];if(U=-1,m<64||St(me,d))return-1;for(_=0;_<m;_++)g[_]=A[_];for(_=0;_<32;_++)g[_+32]=d[_];if(ue(J,g,m),Dt(J),Pt(ae,me,J),bn(me,A.subarray(32)),xe(ae,me),je(F,ae),m-=64,b(A,0,F,0)){for(_=0;_<m;_++)g[_]=0;return-1}for(_=0;_<m;_++)g[_]=A[_+64];return U=m,U}var ln=32,wt=24,rr=32,_r=16,Zr=32,Wi=32,ei=32,ti=32,io=32,xc=wt,Jh=rr,Zh=_r,Rn=64,ir=32,br=64,so=32,oo=64;n.lowlevel={crypto_core_hsalsa20:v,crypto_stream_xor:w,crypto_stream:x,crypto_stream_salsa20_xor:Q,crypto_stream_salsa20:P,crypto_onetimeauth:k,crypto_onetimeauth_verify:R,crypto_verify_16:E,crypto_verify_32:b,crypto_secretbox:ne,crypto_secretbox_open:z,crypto_scalarmult:pr,crypto_scalarmult_base:gr,crypto_box_beforenm:mr,crypto_box_afternm:Xr,crypto_box:Jr,crypto_box_open:Ar,crypto_box_keypair:Bn,crypto_hash:ue,crypto_sign:Lt,crypto_sign_keypair:sn,crypto_sign_open:pt,crypto_secretbox_KEYBYTES:ln,crypto_secretbox_NONCEBYTES:wt,crypto_secretbox_ZEROBYTES:rr,crypto_secretbox_BOXZEROBYTES:_r,crypto_scalarmult_BYTES:Zr,crypto_scalarmult_SCALARBYTES:Wi,crypto_box_PUBLICKEYBYTES:ei,crypto_box_SECRETKEYBYTES:ti,crypto_box_BEFORENMBYTES:io,crypto_box_NONCEBYTES:xc,crypto_box_ZEROBYTES:Jh,crypto_box_BOXZEROBYTES:Zh,crypto_sign_BYTES:Rn,crypto_sign_PUBLICKEYBYTES:ir,crypto_sign_SECRETKEYBYTES:br,crypto_sign_SEEDBYTES:so,crypto_hash_BYTES:oo};function Sc(g,A){if(g.length!==ln)throw new Error("bad key size");if(A.length!==wt)throw new Error("bad nonce size")}function ep(g,A){if(g.length!==ei)throw new Error("bad public key size");if(A.length!==ti)throw new Error("bad secret key size")}function on(){var g,A;for(A=0;A<arguments.length;A++)if((g=Object.prototype.toString.call(arguments[A]))!=="[object Uint8Array]")throw new TypeError("unexpected type "+g+", use Uint8Array")}function wc(g){for(var A=0;A<g.length;A++)g[A]=0}n.util||(n.util={},n.util.decodeUTF8=n.util.encodeUTF8=n.util.encodeBase64=n.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),n.randomBytes=function(g){var A=new Uint8Array(g);return e(A,g),A},n.secretbox=function(g,A,m){on(g,A,m),Sc(m,A);for(var d=new Uint8Array(rr+g.length),_=new Uint8Array(d.length),U=0;U<g.length;U++)d[U+rr]=g[U];return ne(_,d,d.length,A,m),_.subarray(_r)},n.secretbox.open=function(g,A,m){on(g,A,m),Sc(m,A);for(var d=new Uint8Array(_r+g.length),_=new Uint8Array(d.length),U=0;U<g.length;U++)d[U+_r]=g[U];return d.length<32||z(_,d,d.length,A,m)!==0?!1:_.subarray(rr)},n.secretbox.keyLength=ln,n.secretbox.nonceLength=wt,n.secretbox.overheadLength=_r,n.scalarMult=function(g,A){if(on(g,A),g.length!==Wi)throw new Error("bad n size");if(A.length!==Zr)throw new Error("bad p size");var m=new Uint8Array(Zr);return pr(m,g,A),m},n.scalarMult.base=function(g){if(on(g),g.length!==Wi)throw new Error("bad n size");var A=new Uint8Array(Zr);return gr(A,g),A},n.scalarMult.scalarLength=Wi,n.scalarMult.groupElementLength=Zr,n.box=function(g,A,m,d){var _=n.box.before(m,d);return n.secretbox(g,A,_)},n.box.before=function(g,A){on(g,A),ep(g,A);var m=new Uint8Array(io);return mr(m,g,A),m},n.box.after=n.secretbox,n.box.open=function(g,A,m,d){var _=n.box.before(m,d);return n.secretbox.open(g,A,_)},n.box.open.after=n.secretbox.open,n.box.keyPair=function(){var g=new Uint8Array(ei),A=new Uint8Array(ti);return Bn(g,A),{publicKey:g,secretKey:A}},n.box.keyPair.fromSecretKey=function(g){if(on(g),g.length!==ti)throw new Error("bad secret key size");var A=new Uint8Array(ei);return gr(A,g),{publicKey:A,secretKey:new Uint8Array(g)}},n.box.publicKeyLength=ei,n.box.secretKeyLength=ti,n.box.sharedKeyLength=io,n.box.nonceLength=xc,n.box.overheadLength=n.secretbox.overheadLength,n.sign=function(g,A){if(on(g,A),A.length!==br)throw new Error("bad secret key size");var m=new Uint8Array(Rn+g.length);return Lt(m,g,g.length,A),m},n.sign.open=function(g,A){if(arguments.length!==2)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(on(g,A),A.length!==ir)throw new Error("bad public key size");var m=new Uint8Array(g.length),d=pt(m,g,g.length,A);if(d<0)return null;for(var _=new Uint8Array(d),U=0;U<_.length;U++)_[U]=m[U];return _},n.sign.detached=function(g,A){for(var m=n.sign(g,A),d=new Uint8Array(Rn),_=0;_<d.length;_++)d[_]=m[_];return d},n.sign.detached.verify=function(g,A,m){if(on(g,A,m),A.length!==Rn)throw new Error("bad signature size");if(m.length!==ir)throw new Error("bad public key size");var d=new Uint8Array(Rn+g.length),_=new Uint8Array(Rn+g.length),U;for(U=0;U<Rn;U++)d[U]=A[U];for(U=0;U<g.length;U++)d[U+Rn]=g[U];return pt(_,d,d.length,m)>=0},n.sign.keyPair=function(){var g=new Uint8Array(ir),A=new Uint8Array(br);return sn(g,A),{publicKey:g,secretKey:A}},n.sign.keyPair.fromSecretKey=function(g){if(on(g),g.length!==br)throw new Error("bad secret key size");for(var A=new Uint8Array(ir),m=0;m<A.length;m++)A[m]=g[32+m];return{publicKey:A,secretKey:new Uint8Array(g)}},n.sign.keyPair.fromSeed=function(g){if(on(g),g.length!==so)throw new Error("bad seed size");for(var A=new Uint8Array(ir),m=new Uint8Array(br),d=0;d<32;d++)m[d]=g[d];return sn(A,m,!0),{publicKey:A,secretKey:m}},n.sign.publicKeyLength=ir,n.sign.secretKeyLength=br,n.sign.seedLength=so,n.sign.signatureLength=Rn,n.hash=function(g){on(g);var A=new Uint8Array(oo);return ue(A,g,g.length),A},n.hash.hashLength=oo,n.verify=function(g,A){return on(g,A),g.length===0||A.length===0||g.length!==A.length?!1:y(g,0,A,0,g.length)===0},n.setPRNG=function(g){e=g},(function(){var g=typeof self<"u"?self.crypto||self.msCrypto:null;if(g&&g.getRandomValues){var A=65536;n.setPRNG(function(m,d){var _,U=new Uint8Array(d);for(_=0;_<d;_+=A)g.getRandomValues(U.subarray(_,_+Math.min(d-_,A)));for(_=0;_<d;_++)m[_]=U[_];wc(U)})}else typeof require<"u"&&(g=require("crypto"),g&&g.randomBytes&&n.setPRNG(function(m,d){var _,U=g.randomBytes(d);for(_=0;_<d;_++)m[_]=U[_];wc(U)}))})()})(typeof Ji<"u"&&Ji.exports?Ji.exports:self.nacl=self.nacl||{})});var mo=ct((kE,Dc)=>{"use strict";var ho=Uc().lowlevel.crypto_hash,Nn=0,or=function(){this.S=[new Uint32Array([3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946]),new Uint32Array([1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055]),new Uint32Array([3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504]),new Uint32Array([976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462])],this.P=new Uint32Array([608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731])};function es(n,t,e){return(n[0][t[e+3]]+n[1][t[e+2]]^n[2][t[e+1]])+n[3][t[e]]}or.prototype.encipher=function(n,t){t===void 0&&(t=new Uint8Array(n.buffer),n.byteOffset!==0&&(t=t.subarray(n.byteOffset))),n[0]^=this.P[0];for(var e=1;e<16;e+=2)n[1]^=es(this.S,t,0)^this.P[e],n[0]^=es(this.S,t,4)^this.P[e+1];var r=n[0];n[0]=n[1]^this.P[17],n[1]=r};or.prototype.decipher=function(n){var t=new Uint8Array(n.buffer);n.byteOffset!==0&&(t=t.subarray(n.byteOffset)),n[0]^=this.P[17];for(var e=16;e>0;e-=2)n[1]^=es(this.S,t,0)^this.P[e],n[0]^=es(this.S,t,4)^this.P[e-1];var r=n[0];n[0]=n[1]^this.P[0],n[1]=r};function sr(n,t){var e,r=0;for(e=0;e<4;e++,Nn++)Nn>=t&&(Nn=0),r=r<<8|n[Nn];return r}or.prototype.expand0state=function(n,t){var e=new Uint32Array(2),r,s,i=new Uint8Array(e.buffer);for(r=0,Nn=0;r<18;r++)this.P[r]^=sr(n,t);for(Nn=0,r=0;r<18;r+=2)this.encipher(e,i),this.P[r]=e[0],this.P[r+1]=e[1];for(r=0;r<4;r++)for(s=0;s<256;s+=2)this.encipher(e,i),this.S[r][s]=e[0],this.S[r][s+1]=e[1]};or.prototype.expandstate=function(n,t,e,r){var s=new Uint32Array(2),i,o;for(i=0,Nn=0;i<18;i++)this.P[i]^=sr(e,r);for(i=0,Nn=0;i<18;i+=2)s[0]^=sr(n,t),s[1]^=sr(n,t),this.encipher(s),this.P[i]=s[0],this.P[i+1]=s[1];for(i=0;i<4;i++)for(o=0;o<256;o+=2)s[0]^=sr(n,t),s[1]^=sr(n,t),this.encipher(s),this.S[i][o]=s[0],this.S[i][o+1]=s[1];Nn=0};or.prototype.enc=function(n,t){for(var e=0;e<t;e++)this.encipher(n.subarray(e*2))};or.prototype.dec=function(n,t){for(var e=0;e<t;e++)this.decipher(n.subarray(e*2))};var Zi=8,po=32;function go(n,t,e){var r=new or,s=new Uint32Array(Zi),i,o=new Uint8Array([79,120,121,99,104,114,111,109,97,116,105,99,66,108,111,119,102,105,115,104,83,119,97,116,68,121,110,97,109,105,116,101]);for(r.expandstate(t,64,n,64),i=0;i<64;i++)r.expand0state(t,64),r.expand0state(n,64);for(i=0;i<Zi;i++)s[i]=sr(o,o.byteLength);for(i=0;i<64;i++)r.enc(s,s.byteLength/8);for(i=0;i<Zi;i++)e[4*i+3]=s[i]>>>24,e[4*i+2]=s[i]>>>16,e[4*i+1]=s[i]>>>8,e[4*i+0]=s[i]}function mp(n,t,e,r,s,i,o){var a=new Uint8Array(64),c=new Uint8Array(64),f=new Uint8Array(po),l=new Uint8Array(po),u=new Uint8Array(r+4),h,p,y,E,b,C,N=i;if(o<1||t===0||r===0||i===0||i>f.byteLength*f.byteLength||r>1<<20)return-1;for(E=Math.floor((i+f.byteLength-1)/f.byteLength),y=Math.floor((i+E-1)/E),h=0;h<r;h++)u[h]=e[h];for(ho(a,n,t),C=1;i>0;C++){for(u[r+0]=C>>>24,u[r+1]=C>>>16,u[r+2]=C>>>8,u[r+3]=C,ho(c,u,r+4),go(a,c,l),h=f.byteLength;h--;)f[h]=l[h];for(h=1;h<o;h++)for(ho(c,l,l.byteLength),go(a,c,l),p=0;p<f.byteLength;p++)f[p]^=l[p];for(y=Math.min(y,i),h=0;h<y&&(b=h*E+(C-1),!(b>=N));h++)s[b]=f[h];i-=h}return 0}Dc.exports={BLOCKS:Zi,HASHSIZE:po,hash:go,pbkdf:mp}});var Tn=ct((BE,ns)=>{"use strict";var Pn=require("crypto"),Cr;try{Cr=require("cpu-features")()}catch{}var{bindingAvailable:$c,CIPHER_INFO:Ap,MAC_INFO:Ep}=Wn(),Oc=(()=>{if(typeof Pn.sign=="function"&&typeof Pn.verify=="function"){let n=`-----BEGIN PRIVATE KEY-----\r
2
2
  MC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r
3
- -----END PRIVATE KEY-----`,t=Buffer.from("a"),e,r;try{e=Nn.sign(null,t,n),r=Nn.verify(null,t,n,e)}catch{}return Buffer.isBuffer(e)&&e.length===64&&r===!0}return!1})(),Dc=typeof Nn.diffieHellman=="function"&&typeof Nn.generateKeyPairSync=="function"&&typeof Nn.createPublicKey=="function",Ji=["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"];Dc&&(Ji.unshift("curve25519-sha256"),Ji.unshift("curve25519-sha256@libssh.org"));var up=Ji.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),ho=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];Uc&&ho.unshift("ssh-ed25519");var dp=ho.concat(["ssh-dss"]),$c=(()=>{let n=Nn.getCiphers();return t=>n.includes(fp[t].sslName)})(),Hn=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];Cr&&Cr.flags&&!Cr.flags.aes?Lc?Hn.unshift("chacha20-poly1305@openssh.com"):Hn.push("chacha20-poly1305@openssh.com"):Lc&&Cr&&Cr.arch==="x86"?Hn.splice(4,0,"chacha20-poly1305@openssh.com"):Hn.push("chacha20-poly1305@openssh.com");Hn=Hn.filter($c);var hp=Hn.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter($c)),Oc=(()=>{let n=Nn.getHashes();return t=>n.includes(lp[t].sslName)})(),Mc=["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(Oc),pp=Mc.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(Oc)),Fc=["none","zlib@openssh.com","zlib"],gp=Fc.concat([]),Ir={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};Zi.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:Ir,COMPAT_CHECKS:[["Cisco-1.25",Ir.BAD_DHGEX],[/^Cisco-1[.]/,Ir.BUG_DHGEX_LARGE],[/^[0-9.]+$/,Ir.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,Ir.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,Ir.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:Ji,SUPPORTED_KEX:up,DEFAULT_SERVER_HOST_KEY:ho,SUPPORTED_SERVER_HOST_KEY:dp,DEFAULT_CIPHER:Hn,SUPPORTED_CIPHER:hp,DEFAULT_MAC:Mc,SUPPORTED_MAC:pp,DEFAULT_COMPRESSION:Fc,SUPPORTED_COMPRESSION:gp,curve25519Supported:Dc,eddsaSupported:Uc};Zi.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(Zi.exports.DISCONNECT_REASON)).reduce((n,[t,e])=>({...n,[e]:t}),{})});var hn=at((SE,qc)=>{"use strict";var un=ni().Ber,es,Wc=Buffer[Symbol.species],mp=Object.getPrototypeOf(Uint8Array.prototype).fill;function Hc(n,t){return n[t++]*16777216+n[t++]*65536+n[t++]*256+n[t]}function ri(n,t,e,r,s){s||(s=0),r>n.length&&(r=n.length);let i=r-e,o=t.length-s;return i>o&&(i=o),t.set(new Uint8Array(n.buffer,n.byteOffset+e,i),s),i}function ii(n,t,e){return e===void 0&&(e=n.length),new Wc(n.buffer,n.byteOffset+t,e-t)}function go(){let n=0,t,e={init:(r,s)=>{t=r,n=typeof s=="number"?s:0},pos:()=>n,length:()=>t?t.length:0,avail:()=>t&&n<t.length?t.length-n:0,clear:()=>{t=void 0},readUInt32BE:()=>{if(!(!t||n+3>=t.length))return t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]},readUInt64BE:r=>{if(!(!t||n+7>=t.length))switch(r){case"always":return BigInt(`0x${t.hexSlice(n,n+=8)}`);case"maybe":if(t[n]>31)return BigInt(`0x${t.hexSlice(n,n+=8)}`);default:return t[n++]*72057594037927940+t[n++]*281474976710656+t[n++]*1099511627776+t[n++]*4294967296+t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]}},skip:r=>{t&&r>0&&(n+=r)},skipString:()=>{let r=e.readUInt32BE();if(r!==void 0)return n+=r,n<=t.length?r:void 0},readByte:()=>{if(t&&n<t.length)return t[n++]},readBool:()=>{if(t&&n<t.length)return!!t[n++]},readList:()=>{let r=e.readString(!0);if(r!==void 0)return r?r.split(","):[]},readString:(r,s)=>{typeof r=="number"&&(s=r,r=void 0);let i=e.readUInt32BE();if(i!==void 0&&!(t.length-n<i||typeof s=="number"&&i>s))return r?Buffer.isBuffer(r)?ri(t,r,n,n+=i):t.utf8Slice(n,n+=i):ii(t,n,n+=i)},readRaw:r=>{if(t){if(typeof r!="number")return ii(t,n,n+=t.length-n);if(t.length-n>=r)return ii(t,n,n+=r)}}};return e}function Qc(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 po(n,t,e){return n[e++]=t>>>24,n[e++]=t>>>16,n[e++]=t>>>8,n[e++]=t,e}var ts=go();qc.exports={bufferCopy:ri,bufferSlice:ii,FastBuffer:Wc,bufferFill:(n,t,e,r)=>mp.call(n,t,e,r),makeError:Qc,doFatalError:(n,t,e,r)=>{let s;return es===void 0&&({DISCONNECT_REASON:es}=Pn()),t instanceof Error?(s=t,typeof e!="number"?r=es.PROTOCOL_ERROR:r=e):s=Qc(t,e,!0),typeof r!="number"&&(r=es.PROTOCOL_ERROR),n.disconnect(r),n._destruct(),n._onError(s),1/0},readUInt32BE:Hc,writeUInt32BE:po,writeUInt32LE:(n,t,e)=>(n[e++]=t,n[e++]=t>>>8,n[e++]=t>>>16,n[e++]=t>>>24,e),makeBufferParser:go,bufferParser:go(),readString:(n,t,e,r)=>{typeof e=="number"&&(r=e,e=void 0),t===void 0&&(t=0);let s=n.length-t;if(t<0||t>=n.length||s<4)return;let i=Hc(n,t);if(s<4+i||typeof r=="number"&&i>r)return;t+=4;let o=t+i;return n._pos=o,e?Buffer.isBuffer(e)?ri(n,e,t,o):n.utf8Slice(t,o):ii(n,t,o)},sigSSHToASN1:(n,t)=>{switch(t){case"ssh-dss":{if(n.length>40)return n;let e=new un.Writer;e.startSequence();let r=n.slice(0,20),s=n.slice(20);if(r[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,r.copy(i,1),r=i}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(s[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,s.copy(i,1),s=i}else s[0]===0&&!(s[1]&128)&&(s=s.slice(1));return e.writeBuffer(r,un.Integer),e.writeBuffer(s,un.Integer),e.endSequence(),e.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{ts.init(n,0);let e=ts.readString(),r=ts.readString();if(ts.clear(),e===void 0||r===void 0)return;let s=new un.Writer;return s.startSequence(),s.writeBuffer(e,un.Integer),s.writeBuffer(r,un.Integer),s.endSequence(),s.buffer}default:return n}},convertSignature:(n,t)=>{switch(t){case"ssh-dss":{if(n.length<=40)return n;let e=new un.Reader(n);e.readSequence();let r=e.readString(un.Integer,!0),s=e.readString(un.Integer,!0),i=0,o=0;if(r.length<20){let c=Buffer.allocUnsafe(20);c.set(r,1),r=c,r[0]=0}if(s.length<20){let c=Buffer.allocUnsafe(20);c.set(s,1),s=c,s[0]=0}r.length>20&&r[0]===0&&(i=1),s.length>20&&s[0]===0&&(o=1);let a=Buffer.allocUnsafe(r.length-i+(s.length-o));return ri(r,a,i,r.length,0),ri(s,a,o,s.length,r.length-i),a}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(n[0]===0)return n;let e=new un.Reader(n);e.readSequence();let r=e.readString(un.Integer,!0),s=e.readString(un.Integer,!0);if(r===null||s===null)return;let i=Buffer.allocUnsafe(4+r.length+4+s.length);return po(i,r.length,0),i.set(r,4),po(i,s.length,4+r.length),i.set(s,8+r.length),i}}return n},sendPacket:(n,t,e)=>!e&&n._kexinit!==void 0?(n._queue===void 0&&(n._queue=[]),n._queue.push(t),n._debug&&n._debug("Outbound: ... packet queued"),!1):(n._cipher.encrypt(t),!0)}});var Kc=at((ns,Ao)=>{var mo=(function(){var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),(function(t){t=t||{};var e;e||(e=typeof t<"u"?t:{});var r,s;e.ready=new Promise(function(j,ue){r=j,s=ue});var i={},o;for(o in e)e.hasOwnProperty(o)&&(i[o]=e[o]);var a=typeof window=="object",c=typeof importScripts=="function",f=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",l="",u,h,p,y,E;f?(l=c?require("path").dirname(l)+"/":__dirname+"/",u=function(j,ue){var xe=vn(j);return xe?ue?xe:xe.toString():(y||(y=require("fs")),E||(E=require("path")),j=E.normalize(j),y.readFileSync(j,ue?null:"utf8"))},p=function(j){return j=u(j,!0),j.buffer||(j=new Uint8Array(j)),F(j.buffer),j},h=function(j,ue,xe){var Pe=vn(j);Pe&&ue(Pe),y||(y=require("fs")),E||(E=require("path")),j=E.normalize(j),y.readFile(j,function(je,Nt){je?xe(je):ue(Nt.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),e.inspect=function(){return"[Emscripten Module object]"}):(a||c)&&(c?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="",u=function(j){try{var ue=new XMLHttpRequest;return ue.open("GET",j,!1),ue.send(null),ue.responseText}catch(je){if(j=vn(j)){ue=[];for(var xe=0;xe<j.length;xe++){var Pe=j[xe];255<Pe&&(pr&&F(!1,"Character code "+Pe+" ("+String.fromCharCode(Pe)+") at offset "+xe+" not in 0x00-0xFF."),Pe&=255),ue.push(String.fromCharCode(Pe))}return ue.join("")}throw je}},c&&(p=function(j){try{var ue=new XMLHttpRequest;return ue.open("GET",j,!1),ue.responseType="arraybuffer",ue.send(null),new Uint8Array(ue.response)}catch(xe){if(j=vn(j))return j;throw xe}}),h=function(j,ue,xe){var Pe=new XMLHttpRequest;Pe.open("GET",j,!0),Pe.responseType="arraybuffer",Pe.onload=function(){if(Pe.status==200||Pe.status==0&&Pe.response)ue(Pe.response);else{var je=vn(j);je?ue(je.buffer):xe()}},Pe.onerror=xe,Pe.send(null)}),e.print||console.log.bind(console);var x=e.printErr||console.warn.bind(console);for(o in i)i.hasOwnProperty(o)&&(e[o]=i[o]);i=null;var k;e.wasmBinary&&(k=e.wasmBinary);var D=e.noExitRuntime||!0;typeof WebAssembly!="object"&&Q("no native wasm support detected");var H,C=!1;function F(j,ue){j||Q("Assertion failed: "+ue)}function V(j){var ue=e["_"+j];return F(ue,"Cannot call unknown function "+j+", make sure it is exported"),ue}function N(j,ue,xe,Pe){var je={string:function(ot){var Ut=0;if(ot!=null&&ot!==0){var Tt=(ot.length<<2)+1;Ut=Xr(Tt);var xt=Ut,dt=v;if(0<Tt){Tt=xt+Tt-1;for(var cn=0;cn<ot.length;++cn){var St=ot.charCodeAt(cn);if(55296<=St&&57343>=St){var tr=ot.charCodeAt(++cn);St=65536+((St&1023)<<10)|tr&1023}if(127>=St){if(xt>=Tt)break;dt[xt++]=St}else{if(2047>=St){if(xt+1>=Tt)break;dt[xt++]=192|St>>6}else{if(65535>=St){if(xt+2>=Tt)break;dt[xt++]=224|St>>12}else{if(xt+3>=Tt)break;dt[xt++]=240|St>>18,dt[xt++]=128|St>>12&63}dt[xt++]=128|St>>6&63}dt[xt++]=128|St&63}}dt[xt]=0}}return Ut},array:function(ot){var Ut=Xr(ot.length);return I.set(ot,Ut),Ut}},Nt=V(j),En=[];if(j=0,Pe)for(var nn=0;nn<Pe.length;nn++){var _r=je[xe[nn]];_r?(j===0&&(j=jr()),En[nn]=_r(Pe[nn])):En[nn]=Pe[nn]}return xe=Nt.apply(null,En),xe=(function(ot){if(ue==="string")if(ot){for(var Ut=v,Tt=ot+NaN,xt=ot;Ut[xt]&&!(xt>=Tt);)++xt;if(16<xt-ot&&Ut.subarray&&b)ot=b.decode(Ut.subarray(ot,xt));else{for(Tt="";ot<xt;){var dt=Ut[ot++];if(dt&128){var cn=Ut[ot++]&63;if((dt&224)==192)Tt+=String.fromCharCode((dt&31)<<6|cn);else{var St=Ut[ot++]&63;dt=(dt&240)==224?(dt&15)<<12|cn<<6|St:(dt&7)<<18|cn<<12|St<<6|Ut[ot++]&63,65536>dt?Tt+=String.fromCharCode(dt):(dt-=65536,Tt+=String.fromCharCode(55296|dt>>10,56320|dt&1023))}}else Tt+=String.fromCharCode(dt)}ot=Tt}}else ot="";else ot=ue==="boolean"?!!ot:ot;return ot})(xe),j!==0&&Mi(j),xe}var b=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,S,I,v;function R(){var j=H.buffer;S=j,e.HEAP8=I=new Int8Array(j),e.HEAP16=new Int16Array(j),e.HEAP32=new Int32Array(j),e.HEAPU8=v=new Uint8Array(j),e.HEAPU16=new Uint16Array(j),e.HEAPU32=new Uint32Array(j),e.HEAPF32=new Float32Array(j),e.HEAPF64=new Float64Array(j)}var ne,z=[],Y=[],te=[];function ce(){var j=e.preRun.shift();z.unshift(j)}var $=0,B=null,T=null;e.preloadedImages={},e.preloadedAudios={};function Q(j){throw e.onAbort&&e.onAbort(j),x(j),C=!0,j=new WebAssembly.RuntimeError("abort("+j+"). Build with -s ASSERTIONS=1 for more info."),s(j),j}var ee="data:application/octet-stream;base64,",fe;if(fe="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==",!fe.startsWith(ee)){var ie=fe;fe=e.locateFile?e.locateFile(ie,l):l+ie}function Ye(){var j=fe;try{if(j==fe&&k)return new Uint8Array(k);var ue=vn(j);if(ue)return ue;if(p)return p(j);throw"both async and sync fetching of the wasm failed"}catch(xe){Q(xe)}}function ct(){if(!k&&(a||c)){if(typeof fetch=="function"&&!fe.startsWith("file://"))return fetch(fe,{credentials:"same-origin"}).then(function(j){if(!j.ok)throw"failed to load wasm binary file at '"+fe+"'";return j.arrayBuffer()}).catch(function(){return Ye()});if(h)return new Promise(function(j,ue){h(fe,function(xe){j(new Uint8Array(xe))},ue)})}return Promise.resolve().then(function(){return Ye()})}function tn(j){for(;0<j.length;){var ue=j.shift();if(typeof ue=="function")ue(e);else{var xe=ue.m;typeof xe=="number"?ue.l===void 0?ne.get(xe)():ne.get(xe)(ue.l):xe(ue.l===void 0?null:ue.l)}}}var pr=!1,gr=typeof atob=="function"?atob:function(j){var ue="",xe=0;j=j.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var Pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(xe++)),je="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(xe++)),Nt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(xe++)),En="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(xe++));Pe=Pe<<2|je>>4,je=(je&15)<<4|Nt>>2;var nn=(Nt&3)<<6|En;ue+=String.fromCharCode(Pe),Nt!==64&&(ue+=String.fromCharCode(je)),En!==64&&(ue+=String.fromCharCode(nn))}while(xe<j.length);return ue};function vn(j){if(j.startsWith(ee)){if(j=j.slice(ee.length),typeof f=="boolean"&&f){var ue=Buffer.from(j,"base64");ue=new Uint8Array(ue.buffer,ue.byteOffset,ue.byteLength)}else try{var xe=gr(j),Pe=new Uint8Array(xe.length);for(j=0;j<xe.length;++j)Pe[j]=xe.charCodeAt(j);ue=Pe}catch{throw Error("Converting base64 string to bytes failed.")}return ue}}var mr={a:function(j){var ue=v.length;if(j>>>=0,2147483648<j)return!1;for(var xe=1;4>=xe;xe*=2){var Pe=ue*(1+.2/xe);Pe=Math.min(Pe,j+100663296),Pe=Math.max(j,Pe),0<Pe%65536&&(Pe+=65536-Pe%65536);e:{try{H.grow(Math.min(2147483648,Pe)-S.byteLength+65535>>>16),R();var je=1;break e}catch{}je=void 0}if(je)return!0}return!1}};(function(){function j(je){e.asm=je.exports,H=e.asm.b,R(),ne=e.asm.j,Y.unshift(e.asm.c),$--,e.monitorRunDependencies&&e.monitorRunDependencies($),$==0&&(B!==null&&(clearInterval(B),B=null),T&&(je=T,T=null,je()))}function ue(je){j(je.instance)}function xe(je){return ct().then(function(Nt){return WebAssembly.instantiate(Nt,Pe)}).then(je,function(Nt){x("failed to asynchronously prepare wasm: "+Nt),Q(Nt)})}var Pe={a:mr};if($++,e.monitorRunDependencies&&e.monitorRunDependencies($),e.instantiateWasm)try{return e.instantiateWasm(Pe,j)}catch(je){return x("Module.instantiateWasm callback failed with error: "+je),!1}return(function(){return k||typeof WebAssembly.instantiateStreaming!="function"||fe.startsWith(ee)||fe.startsWith("file://")||typeof fetch!="function"?xe(ue):fetch(fe,{credentials:"same-origin"}).then(function(je){return WebAssembly.instantiateStreaming(je,Pe).then(ue,function(Nt){return x("wasm streaming compile failed: "+Nt),x("falling back to ArrayBuffer instantiation"),xe(ue)})})})().catch(s),{}})(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.c).apply(null,arguments)},e._poly1305_auth=function(){return(e._poly1305_auth=e.asm.d).apply(null,arguments)};var jr=e.stackSave=function(){return(jr=e.stackSave=e.asm.e).apply(null,arguments)},Mi=e.stackRestore=function(){return(Mi=e.stackRestore=e.asm.f).apply(null,arguments)},Xr=e.stackAlloc=function(){return(Xr=e.stackAlloc=e.asm.g).apply(null,arguments)};e._malloc=function(){return(e._malloc=e.asm.h).apply(null,arguments)},e._free=function(){return(e._free=e.asm.i).apply(null,arguments)},e.cwrap=function(j,ue,xe,Pe){xe=xe||[];var je=xe.every(function(Nt){return Nt==="number"});return ue!=="string"&&je&&!Pe?V(j):function(){return N(j,ue,xe,arguments)}};var Ar;T=function j(){Ar||Er(),Ar||(T=j)};function Er(){function j(){if(!Ar&&(Ar=!0,e.calledRun=!0,!C)){if(tn(Y),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;){var ue=e.postRun.shift();te.unshift(ue)}tn(te)}}if(!(0<$)){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)ce();tn(z),0<$||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),j()},1)):j())}}if(e.run=Er,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return Er(),t.ready})})();typeof ns=="object"&&typeof Ao=="object"?Ao.exports=mo:typeof define=="function"&&define.amd?define([],function(){return mo}):typeof ns=="object"&&(ns.createPoly1305=mo)});var Qn=at((wE,jc)=>{"use strict";var{createCipheriv:vr,createDecipheriv:rs,createHmac:Eo,randomFillSync:sr,timingSafeEqual:_o}=require("crypto"),{readUInt32BE:oi,writeUInt32BE:sn}=hn(),Wn=Buffer[Symbol.species],Vc=2**32-1,Gc=Buffer.alloc(0),kr=Buffer.alloc(4),is=new Map,or=35e3,yo,Uo,Do,$o,Oo,Mo,Fo;try{yo=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:Uo,ChaChaPolyCipher:Do,GenericCipher:$o,AESGCMDecipher:Oo,ChaChaPolyDecipher:Mo,GenericDecipher:Fo}=yo}catch{}var Mt=1,Ap=(()=>{function n(t,e,r,s,i,o,a){return{sslName:t,blockLen:e,keyLen:r,ivLen:s!==0||a&Mt?s:e,authLen:i,discardLen:o,stream:!!(a&Mt)}}return{"chacha20-poly1305@openssh.com":n("chacha20",8,64,0,16,0,Mt),"aes128-gcm":n("aes-128-gcm",16,16,12,16,0,Mt),"aes256-gcm":n("aes-256-gcm",16,32,12,16,0,Mt),"aes128-gcm@openssh.com":n("aes-128-gcm",16,16,12,16,0,Mt),"aes256-gcm@openssh.com":n("aes-256-gcm",16,32,12,16,0,Mt),"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,Mt),"aes192-ctr":n("aes-192-ctr",16,24,16,0,0,Mt),"aes256-ctr":n("aes-256-ctr",16,32,16,0,0,Mt),"3des-ctr":n("des-ede3",8,24,8,0,0,Mt),"blowfish-ctr":n("bf-ecb",8,16,8,0,0,Mt),"cast128-ctr":n("cast5-ecb",8,16,8,0,0,Mt),arcfour:n("rc4",8,16,0,0,1536,Mt),arcfour128:n("rc4",8,16,0,0,1536,Mt),arcfour256:n("rc4",8,32,0,0,1536,Mt),arcfour512:n("rc4",8,64,0,0,1536,Mt)}})(),Ep=(()=>{function n(t,e,r,s){return{sslName:t,len:e,actualLen:r,isETM:s}}return{"hmac-md5":n("md5",16,16,!1),"hmac-md5-96":n("md5",16,12,!1),"hmac-ripemd160":n("ripemd160",20,20,!1),"hmac-sha1":n("sha1",20,20,!1),"hmac-sha1-etm@openssh.com":n("sha1",20,20,!0),"hmac-sha1-96":n("sha1",20,12,!1),"hmac-sha2-256":n("sha256",32,32,!1),"hmac-sha2-256-etm@openssh.com":n("sha256",32,32,!0),"hmac-sha2-256-96":n("sha256",32,12,!1),"hmac-sha2-512":n("sha512",64,64,!1),"hmac-sha2-512-etm@openssh.com":n("sha512",64,64,!0),"hmac-sha2-512-96":n("sha512",64,12,!1)}})(),bo=class{constructor(t,e){this.outSeqno=t,this._onWrite=e,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return sn(s,e-4,0),s[4]=r,sr(s,5+t,r),s}encrypt(t){this._dead||(this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},zc=Buffer.alloc(32),jt=Buffer.alloc(16),si,ai,Ho,xo=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encKeyMain=e.cipherKey.slice(0,32),this._encKeyPktLen=e.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return sn(s,e-4,0),s[4]=r,sr(s,5+t,r),s}encrypt(t){if(this._dead)return;jt[0]=0,sn(jt,this.outSeqno,12);let e=vr("chacha20",this._encKeyMain,jt).update(zc),r=vr("chacha20",this._encKeyPktLen,jt).update(t.slice(0,4));this._onWrite(r),jt[0]=1;let s=vr("chacha20",this._encKeyMain,jt).update(t.slice(4));this._onWrite(s),Ho(ai,r,r.length,s,s.length,e);let i=Buffer.allocUnsafe(16);i.set(new Uint8Array(si.HEAPU8.buffer,ai,16),0),this._onWrite(i),this.outSeqno=this.outSeqno+1>>>0}},So=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new Do(e.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e+16);return sn(s,e-4,0),s[4]=r,sr(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},wo=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encSSLName=e.cipherInfo.sslName,this._encKey=e.cipherKey,this._encIV=e.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e);return sn(s,e-4,0),s[4]=r,sr(s,5+t,r),s}encrypt(t){if(this._dead)return;let e=vr(this._encSSLName,this._encKey,this._encIV);e.setAutoPadding(!1);let r=t.slice(0,4);e.setAAD(r),this._onWrite(r);let s=e.update(t.slice(4));this._onWrite(s);let i=e.final();i.length&&this._onWrite(i);let o=e.getAuthTag();this._onWrite(o),Yc(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},Io=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new Uo(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e+16);return sn(s,e-4,0),s[4]=r,sr(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},Co=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encBlockLen=e.cipherInfo.blockLen,this._cipherInstance=vr(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let r=e.cipherInfo.discardLen;if(r){let s=is.get(r);s===void 0&&(s=Buffer.alloc(r),is.set(r,s)),this._cipherInstance.update(s)}}free(){this._dead=!0}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r);return sn(i,r-4,0),i[4]=s,sr(i,5+t,s),i}encrypt(t){if(this._dead)return;let e;if(this._macETM){let s=new Uint8Array(t.buffer,t.byteOffset,4),i=this._cipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+4,t.length-4));this._onWrite(s),this._onWrite(i),e=Eo(this._macSSLName,this._macKey),sn(kr,this.outSeqno,0),e.update(kr),e.update(s),e.update(i)}else{let s=this._cipherInstance.update(t);this._onWrite(s),e=Eo(this._macSSLName,this._macKey),sn(kr,this.outSeqno,0),e.update(kr),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}},ko=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 $o(e.cipherInfo.sslName,e.cipherKey,e.cipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r+this._macLen);return sn(i,r-4,0),i[4]=s,sr(i,5+t,s),i}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._macActualLen<this._macLen&&(t=new Wn(t.buffer,t.byteOffset,t.length-(this._macLen-this._macActualLen))),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},vo=class{constructor(t,e){this.inSeqno=t,this._onPayload=e,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len>or||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._packetPos<this._len){let i=Math.min(this._len-this._packetPos,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),e+=i,this._packetPos+=i,this._packetPos<this._len)return}let s=this._packet?new Wn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Gc;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Bo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decKeyMain=e.decipherKey.slice(0,32),this._decKeyPktLen=e.decipherKey.slice(32),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._calcMac=Buffer.allocUnsafe(16),this._macPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenPos<4){let a=Math.min(4-this._lenPos,r-e);for(;a--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;jt[0]=0,sn(jt,this.inSeqno,12);let c=rs("chacha20",this._decKeyPktLen,jt).update(this._lenBuf);if(this._len=oi(c,0),this._len>or||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(e>=r)return;let a=Math.min(this._len-this._pktLen,r-e),c;if(e!==0||a!==r?c=new Uint8Array(t.buffer,t.byteOffset+e,a):c=t,a===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._pktLen)),e+=a,this._pktLen+=a,this._pktLen<this._len||e>=r)return}{let a=Math.min(16-this._macPos,r-e);if(e!==0||a!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,a),this._macPos):this._mac.set(t,this._macPos),e+=a,this._macPos+=a,this._macPos<16)return}jt[0]=0,sn(jt,this.inSeqno,12);let s=vr("chacha20",this._decKeyMain,jt).update(zc);if(Ho(ai,this._lenBuf,4,this._packet,this._packet.length,s),this._calcMac.set(new Uint8Array(si.HEAPU8.buffer,ai,16),0),!_o(this._calcMac,this._mac))throw new Error("Invalid MAC");jt[0]=1;let i=rs("chacha20",this._decKeyMain,jt).update(this._packet),o=new Wn(i.buffer,i.byteOffset+1,i.length-i[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let a=this._onPayload(o);if(a!==void 0)return a===!1?e:a}}}},Ro=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Mo(e.decipherKey),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._macPos=0}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._lenPos<4){let i=Math.min(4-this._lenPos,r-e);for(;i--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>or||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let s=new Wn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},No=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=null,this._decipherSSLName=e.decipherInfo.sslName,this._decipherKey=e.decipherKey,this._decipherIV=e.decipherIV,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>or||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=rs(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(_p(this._len))}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=this._decipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+e,i)):o=this._decipherInstance.update(t),o.length&&(i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),this._packetPos+=o.length),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let i=this._decipherInstance.final();i.length&&(this._packet?this._packet.set(i,this._packetPos):this._packet=i)}let s=this._packet?new Wn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):Gc;this.inSeqno=this.inSeqno+1>>>0,Yc(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Po=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Oo(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>or||this._len<16||(this._len&15)!==0)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let s=new Wn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},To=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=rs(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(e.macInfo.isETM?4:e.decipherInfo.blockLen),this._blockSize=e.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._macInstance=null;let r=e.decipherInfo.discardLen;if(r){let s=is.get(r);s===void 0&&(s=Buffer.alloc(r),is.set(r,s)),this._decipherInstance.update(s)}}free(){}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let o=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||o!==r||o<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._blockPos):this._block.set(t,this._blockPos),e+=o,this._blockPos+=o,this._blockPos<this._block.length)return;let a,c;if(this._macETM?this._len=c=oi(this._block,0):(a=this._decipherInstance.update(this._block),this._len=oi(a,0),c=4+this._len-this._blockSize),this._len>or||this._len<5||(c&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=Eo(this._macSSLName,this._macKey),sn(kr,this.inSeqno,0),this._macInstance.update(kr),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),e>=r)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,r-e),a;e!==0||o!==r?a=new Uint8Array(t.buffer,t.byteOffset+e,o):a=t,this._macETM&&this._macInstance.update(a);let c=this._decipherInstance.update(a);if(c.length&&(o===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._packetPos)),this._packetPos+=c.length),e+=o,this._pktLen+=o,this._pktLen<this._len||e>=r)return}{let o=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||o!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._macPos):this._mac.set(t,this._macPos),e+=o,this._macPos+=o,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let s=this._macInstance.digest();if(this._macActualLen<s.length&&(s=new Uint8Array(s.buffer,s.byteOffset,this._macActualLen)),!yp(s,this._mac))throw new Error("Invalid MAC");let i=new Wn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._macPos=0,this._macInstance=null;{let o=this._onPayload(i);if(o!==void 0)return o===!1?e:o}}}},Lo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Fo(e.decipherInfo.sslName,e.decipherKey,e.decipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM,e.macInfo.actualLen),this._block=Buffer.allocUnsafe(e.macInfo.isETM||e.decipherInfo.stream?4:e.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let i=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||i!==r||i<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._blockPos):this._block.set(t,this._blockPos),e+=i,this._blockPos+=i,this._blockPos<this._block.length)return;let o;if(this._macETM?this._len=o=oi(this._block,0):(this._instance.decryptBlock(this._block),this._len=oi(this._block,0),o=4+this._len-this._block.length),this._len>or||this._len<5||(o&this._block.length-1)!==0)throw new Error("Bad packet length");if(this._macETM||(this._pktLen=this._block.length-4,this._pktLen&&(this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(this._block.buffer,this._block.byteOffset+4,this._pktLen),0))),e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let s=new Wn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._macPos=0,this._macInstance=null;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}};function Yc(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 _p=(()=>{let n=Buffer.alloc(4);return t=>(n[0]=t>>>24,n[1]=t>>>16,n[2]=t>>>8,n[3]=t,n)})();function yp(n,t){return n.length!==t.length?(_o(n,n),!1):_o(n,t)}function bp(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>Vc)throw new Error("Invalid outbound.seqno");let e=!!t.forceNative;switch(t.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return Uo&&!e?new Io(n):new wo(n);case"chacha20":return Do&&!e?new So(n):new xo(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 $o&&!e?new ko(n):new Co(n)}}}function xp(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>Vc)throw new Error("Invalid inbound.seqno");let e=!!t.forceNative;switch(t.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return Oo&&!e?new Po(n):new No(n);case"chacha20":return Mo&&!e?new Ro(n):new Bo(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 Fo&&!e?new Lo(n):new To(n)}}}jc.exports={CIPHER_INFO:Ap,MAC_INFO:Ep,bindingAvailable:!!yo,init:new Promise(async(n,t)=>{try{si=await Kc()(),ai=si._malloc(16),Ho=si.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(e){return t(e)}n()}),NullCipher:bo,createCipher:bp,NullDecipher:vo,createDecipher:xp}});var Kn=at((IE,af)=>{"use strict";var{createDecipheriv:Wo,createECDH:Sp,createHash:fi,createHmac:wp,createSign:Ip,createVerify:Cp,getCiphers:kp,sign:Xc,verify:Jc}=require("crypto"),vp=kp(),{Ber:Be}=ni(),Bp=uo().pbkdf,{CIPHER_INFO:li}=Qn(),{eddsaSupported:qo,SUPPORTED_CIPHER:Rp}=Pn(),{bufferSlice:ar,makeBufferParser:Np,readString:ke,readUInt32BE:ci,writeUInt32BE:Dt}=hn(),Tn=Symbol("Hash Algorithm"),pn=Symbol("Private key PEM"),_n=Symbol("Public key PEM"),qn=Symbol("Public key SSH"),Br=Symbol("Decrypted Key"),Qo=Object.create(null);{let n=Object.keys(li);for(let t=0;t<n.length;++t){let e=li[n[t]].sslName;!e||Qo[e]||(Qo[e]=li[n[t]])}}var ss=Np();function gn(n,t){t=t.base64Slice(0,t.length);let e=t.replace(/.{64}/g,`$&
3
+ -----END PRIVATE KEY-----`,t=Buffer.from("a"),e,r;try{e=Pn.sign(null,t,n),r=Pn.verify(null,t,n,e)}catch{}return Buffer.isBuffer(e)&&e.length===64&&r===!0}return!1})(),Mc=typeof Pn.diffieHellman=="function"&&typeof Pn.generateKeyPairSync=="function"&&typeof Pn.createPublicKey=="function",ts=["ecdh-sha2-nistp256","ecdh-sha2-nistp384","ecdh-sha2-nistp521","diffie-hellman-group-exchange-sha256","diffie-hellman-group14-sha256","diffie-hellman-group15-sha512","diffie-hellman-group16-sha512","diffie-hellman-group17-sha512","diffie-hellman-group18-sha512"];Mc&&(ts.unshift("curve25519-sha256"),ts.unshift("curve25519-sha256@libssh.org"));var yp=ts.concat(["diffie-hellman-group-exchange-sha1","diffie-hellman-group14-sha1","diffie-hellman-group1-sha1"]),Ao=["ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","rsa-sha2-256","ssh-rsa"];Oc&&Ao.unshift("ssh-ed25519");var _p=Ao.concat(["ssh-dss"]),Fc=(()=>{let n=Pn.getCiphers();return t=>n.includes(Ap[t].sslName)})(),Qn=["aes128-gcm@openssh.com","aes256-gcm@openssh.com","aes128-ctr","aes192-ctr","aes256-ctr"];Cr&&Cr.flags&&!Cr.flags.aes?$c?Qn.unshift("chacha20-poly1305@openssh.com"):Qn.push("chacha20-poly1305@openssh.com"):$c&&Cr&&Cr.arch==="x86"?Qn.splice(4,0,"chacha20-poly1305@openssh.com"):Qn.push("chacha20-poly1305@openssh.com");Qn=Qn.filter(Fc);var bp=Qn.concat(["aes256-cbc","aes192-cbc","aes128-cbc","blowfish-cbc","3des-cbc","aes128-gcm","aes256-gcm","arcfour256","arcfour128","cast128-cbc","arcfour"].filter(Fc)),Hc=(()=>{let n=Pn.getHashes();return t=>n.includes(Ep[t].sslName)})(),Qc=["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(Hc),xp=Qc.concat(["hmac-md5","hmac-sha2-256-96","hmac-sha2-512-96","hmac-ripemd160","hmac-sha1-96","hmac-md5-96"].filter(Hc)),Wc=["none","zlib@openssh.com","zlib"],Sp=Wc.concat([]),Ir={BAD_DHGEX:1,OLD_EXIT:2,DYN_RPORT_BUG:4,BUG_DHGEX_LARGE:8,IMPLY_RSA_SHA2_SIGALGS:16};ns.exports={MESSAGE:{DISCONNECT:1,IGNORE:2,UNIMPLEMENTED:3,DEBUG:4,SERVICE_REQUEST:5,SERVICE_ACCEPT:6,EXT_INFO:7,KEXINIT:20,NEWKEYS:21,KEXDH_INIT:30,KEXDH_REPLY:31,KEXDH_GEX_GROUP:31,KEXDH_GEX_INIT:32,KEXDH_GEX_REPLY:33,KEXDH_GEX_REQUEST:34,KEXECDH_INIT:30,KEXECDH_REPLY:31,USERAUTH_REQUEST:50,USERAUTH_FAILURE:51,USERAUTH_SUCCESS:52,USERAUTH_BANNER:53,USERAUTH_PASSWD_CHANGEREQ:60,USERAUTH_PK_OK:60,USERAUTH_INFO_REQUEST:60,USERAUTH_INFO_RESPONSE:61,GLOBAL_REQUEST:80,REQUEST_SUCCESS:81,REQUEST_FAILURE:82,CHANNEL_OPEN:90,CHANNEL_OPEN_CONFIRMATION:91,CHANNEL_OPEN_FAILURE:92,CHANNEL_WINDOW_ADJUST:93,CHANNEL_DATA:94,CHANNEL_EXTENDED_DATA:95,CHANNEL_EOF:96,CHANNEL_CLOSE:97,CHANNEL_REQUEST:98,CHANNEL_SUCCESS:99,CHANNEL_FAILURE:100},DISCONNECT_REASON:{HOST_NOT_ALLOWED_TO_CONNECT:1,PROTOCOL_ERROR:2,KEY_EXCHANGE_FAILED:3,RESERVED:4,MAC_ERROR:5,COMPRESSION_ERROR:6,SERVICE_NOT_AVAILABLE:7,PROTOCOL_VERSION_NOT_SUPPORTED:8,HOST_KEY_NOT_VERIFIABLE:9,CONNECTION_LOST:10,BY_APPLICATION:11,TOO_MANY_CONNECTIONS:12,AUTH_CANCELED_BY_USER:13,NO_MORE_AUTH_METHODS_AVAILABLE:14,ILLEGAL_USER_NAME:15},DISCONNECT_REASON_STR:void 0,CHANNEL_OPEN_FAILURE:{ADMINISTRATIVELY_PROHIBITED:1,CONNECT_FAILED:2,UNKNOWN_CHANNEL_TYPE:3,RESOURCE_SHORTAGE:4},TERMINAL_MODE:{TTY_OP_END:0,VINTR:1,VQUIT:2,VERASE:3,VKILL:4,VEOF:5,VEOL:6,VEOL2:7,VSTART:8,VSTOP:9,VSUSP:10,VDSUSP:11,VREPRINT:12,VWERASE:13,VLNEXT:14,VFLUSH:15,VSWTCH:16,VSTATUS:17,VDISCARD:18,IGNPAR:30,PARMRK:31,INPCK:32,ISTRIP:33,INLCR:34,IGNCR:35,ICRNL:36,IUCLC:37,IXON:38,IXANY:39,IXOFF:40,IMAXBEL:41,ISIG:50,ICANON:51,XCASE:52,ECHO:53,ECHOE:54,ECHOK:55,ECHONL:56,NOFLSH:57,TOSTOP:58,IEXTEN:59,ECHOCTL:60,ECHOKE:61,PENDIN:62,OPOST:70,OLCUC:71,ONLCR:72,OCRNL:73,ONOCR:74,ONLRET:75,CS7:90,CS8:91,PARENB:92,PARODD:93,TTY_OP_ISPEED:128,TTY_OP_OSPEED:129},CHANNEL_EXTENDED_DATATYPE:{STDERR:1},SIGNALS:["ABRT","ALRM","FPE","HUP","ILL","INT","QUIT","SEGV","TERM","USR1","USR2","KILL","PIPE"].reduce((n,t)=>({...n,[t]:1}),{}),COMPAT:Ir,COMPAT_CHECKS:[["Cisco-1.25",Ir.BAD_DHGEX],[/^Cisco-1[.]/,Ir.BUG_DHGEX_LARGE],[/^[0-9.]+$/,Ir.OLD_EXIT],[/^OpenSSH_5[.][0-9]+/,Ir.DYN_RPORT_BUG],[/^OpenSSH_7[.]4/,Ir.IMPLY_RSA_SHA2_SIGALGS]],DEFAULT_KEX:ts,SUPPORTED_KEX:yp,DEFAULT_SERVER_HOST_KEY:Ao,SUPPORTED_SERVER_HOST_KEY:_p,DEFAULT_CIPHER:Qn,SUPPORTED_CIPHER:bp,DEFAULT_MAC:Qc,SUPPORTED_MAC:xp,DEFAULT_COMPRESSION:Wc,SUPPORTED_COMPRESSION:Sp,curve25519Supported:Mc,eddsaSupported:Oc};ns.exports.DISCONNECT_REASON_BY_VALUE=Array.from(Object.entries(ns.exports.DISCONNECT_REASON)).reduce((n,[t,e])=>({...n,[e]:t}),{})});var gn=ct((RE,Gc)=>{"use strict";var hn=ri().Ber,rs,Vc=Buffer[Symbol.species],wp=Object.getPrototypeOf(Uint8Array.prototype).fill;function qc(n,t){return n[t++]*16777216+n[t++]*65536+n[t++]*256+n[t]}function ii(n,t,e,r,s){s||(s=0),r>n.length&&(r=n.length);let i=r-e,o=t.length-s;return i>o&&(i=o),t.set(new Uint8Array(n.buffer,n.byteOffset+e,i),s),i}function si(n,t,e){return e===void 0&&(e=n.length),new Vc(n.buffer,n.byteOffset+t,e-t)}function yo(){let n=0,t,e={init:(r,s)=>{t=r,n=typeof s=="number"?s:0},pos:()=>n,length:()=>t?t.length:0,avail:()=>t&&n<t.length?t.length-n:0,clear:()=>{t=void 0},readUInt32BE:()=>{if(!(!t||n+3>=t.length))return t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]},readUInt64BE:r=>{if(!(!t||n+7>=t.length))switch(r){case"always":return BigInt(`0x${t.hexSlice(n,n+=8)}`);case"maybe":if(t[n]>31)return BigInt(`0x${t.hexSlice(n,n+=8)}`);default:return t[n++]*72057594037927940+t[n++]*281474976710656+t[n++]*1099511627776+t[n++]*4294967296+t[n++]*16777216+t[n++]*65536+t[n++]*256+t[n++]}},skip:r=>{t&&r>0&&(n+=r)},skipString:()=>{let r=e.readUInt32BE();if(r!==void 0)return n+=r,n<=t.length?r:void 0},readByte:()=>{if(t&&n<t.length)return t[n++]},readBool:()=>{if(t&&n<t.length)return!!t[n++]},readList:()=>{let r=e.readString(!0);if(r!==void 0)return r?r.split(","):[]},readString:(r,s)=>{typeof r=="number"&&(s=r,r=void 0);let i=e.readUInt32BE();if(i!==void 0&&!(t.length-n<i||typeof s=="number"&&i>s))return r?Buffer.isBuffer(r)?ii(t,r,n,n+=i):t.utf8Slice(n,n+=i):si(t,n,n+=i)},readRaw:r=>{if(t){if(typeof r!="number")return si(t,n,n+=t.length-n);if(t.length-n>=r)return si(t,n,n+=r)}}};return e}function Kc(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 Eo(n,t,e){return n[e++]=t>>>24,n[e++]=t>>>16,n[e++]=t>>>8,n[e++]=t,e}var is=yo();Gc.exports={bufferCopy:ii,bufferSlice:si,FastBuffer:Vc,bufferFill:(n,t,e,r)=>wp.call(n,t,e,r),makeError:Kc,doFatalError:(n,t,e,r)=>{let s;return rs===void 0&&({DISCONNECT_REASON:rs}=Tn()),t instanceof Error?(s=t,typeof e!="number"?r=rs.PROTOCOL_ERROR:r=e):s=Kc(t,e,!0),typeof r!="number"&&(r=rs.PROTOCOL_ERROR),n.disconnect(r),n._destruct(),n._onError(s),1/0},readUInt32BE:qc,writeUInt32BE:Eo,writeUInt32LE:(n,t,e)=>(n[e++]=t,n[e++]=t>>>8,n[e++]=t>>>16,n[e++]=t>>>24,e),makeBufferParser:yo,bufferParser:yo(),readString:(n,t,e,r)=>{typeof e=="number"&&(r=e,e=void 0),t===void 0&&(t=0);let s=n.length-t;if(t<0||t>=n.length||s<4)return;let i=qc(n,t);if(s<4+i||typeof r=="number"&&i>r)return;t+=4;let o=t+i;return n._pos=o,e?Buffer.isBuffer(e)?ii(n,e,t,o):n.utf8Slice(t,o):si(n,t,o)},sigSSHToASN1:(n,t)=>{switch(t){case"ssh-dss":{if(n.length>40)return n;let e=new hn.Writer;e.startSequence();let r=n.slice(0,20),s=n.slice(20);if(r[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,r.copy(i,1),r=i}else r[0]===0&&!(r[1]&128)&&(r=r.slice(1));if(s[0]&128){let i=Buffer.allocUnsafe(21);i[0]=0,s.copy(i,1),s=i}else s[0]===0&&!(s[1]&128)&&(s=s.slice(1));return e.writeBuffer(r,hn.Integer),e.writeBuffer(s,hn.Integer),e.endSequence(),e.buffer}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{is.init(n,0);let e=is.readString(),r=is.readString();if(is.clear(),e===void 0||r===void 0)return;let s=new hn.Writer;return s.startSequence(),s.writeBuffer(e,hn.Integer),s.writeBuffer(r,hn.Integer),s.endSequence(),s.buffer}default:return n}},convertSignature:(n,t)=>{switch(t){case"ssh-dss":{if(n.length<=40)return n;let e=new hn.Reader(n);e.readSequence();let r=e.readString(hn.Integer,!0),s=e.readString(hn.Integer,!0),i=0,o=0;if(r.length<20){let c=Buffer.allocUnsafe(20);c.set(r,1),r=c,r[0]=0}if(s.length<20){let c=Buffer.allocUnsafe(20);c.set(s,1),s=c,s[0]=0}r.length>20&&r[0]===0&&(i=1),s.length>20&&s[0]===0&&(o=1);let a=Buffer.allocUnsafe(r.length-i+(s.length-o));return ii(r,a,i,r.length,0),ii(s,a,o,s.length,r.length-i),a}case"ecdsa-sha2-nistp256":case"ecdsa-sha2-nistp384":case"ecdsa-sha2-nistp521":{if(n[0]===0)return n;let e=new hn.Reader(n);e.readSequence();let r=e.readString(hn.Integer,!0),s=e.readString(hn.Integer,!0);if(r===null||s===null)return;let i=Buffer.allocUnsafe(4+r.length+4+s.length);return Eo(i,r.length,0),i.set(r,4),Eo(i,s.length,4+r.length),i.set(s,8+r.length),i}}return n},sendPacket:(n,t,e)=>!e&&n._kexinit!==void 0?(n._queue===void 0&&(n._queue=[]),n._queue.push(t),n._debug&&n._debug("Outbound: ... packet queued"),!1):(n._cipher.encrypt(t),!0)}});var zc=ct((ss,bo)=>{var _o=(function(){var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),(function(t){t=t||{};var e;e||(e=typeof t<"u"?t:{});var r,s;e.ready=new Promise(function(j,ue){r=j,s=ue});var i={},o;for(o in e)e.hasOwnProperty(o)&&(i[o]=e[o]);var a=typeof window=="object",c=typeof importScripts=="function",f=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",l="",u,h,p,y,E;f?(l=c?require("path").dirname(l)+"/":__dirname+"/",u=function(j,ue){var xe=Bn(j);return xe?ue?xe:xe.toString():(y||(y=require("fs")),E||(E=require("path")),j=E.normalize(j),y.readFileSync(j,ue?null:"utf8"))},p=function(j){return j=u(j,!0),j.buffer||(j=new Uint8Array(j)),M(j.buffer),j},h=function(j,ue,xe){var Pe=Bn(j);Pe&&ue(Pe),y||(y=require("fs")),E||(E=require("path")),j=E.normalize(j),y.readFile(j,function(je,Pt){je?xe(je):ue(Pt.buffer)})},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),e.inspect=function(){return"[Emscripten Module object]"}):(a||c)&&(c?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="",u=function(j){try{var ue=new XMLHttpRequest;return ue.open("GET",j,!1),ue.send(null),ue.responseText}catch(je){if(j=Bn(j)){ue=[];for(var xe=0;xe<j.length;xe++){var Pe=j[xe];255<Pe&&(pr&&M(!1,"Character code "+Pe+" ("+String.fromCharCode(Pe)+") at offset "+xe+" not in 0x00-0xFF."),Pe&=255),ue.push(String.fromCharCode(Pe))}return ue.join("")}throw je}},c&&(p=function(j){try{var ue=new XMLHttpRequest;return ue.open("GET",j,!1),ue.responseType="arraybuffer",ue.send(null),new Uint8Array(ue.response)}catch(xe){if(j=Bn(j))return j;throw xe}}),h=function(j,ue,xe){var Pe=new XMLHttpRequest;Pe.open("GET",j,!0),Pe.responseType="arraybuffer",Pe.onload=function(){if(Pe.status==200||Pe.status==0&&Pe.response)ue(Pe.response);else{var je=Bn(j);je?ue(je.buffer):xe()}},Pe.onerror=xe,Pe.send(null)}),e.print||console.log.bind(console);var b=e.printErr||console.warn.bind(console);for(o in i)i.hasOwnProperty(o)&&(e[o]=i[o]);i=null;var C;e.wasmBinary&&(C=e.wasmBinary);var N=e.noExitRuntime||!0;typeof WebAssembly!="object"&&K("no native wasm support detected");var H,v=!1;function M(j,ue){j||K("Assertion failed: "+ue)}function Q(j){var ue=e["_"+j];return M(ue,"Cannot call unknown function "+j+", make sure it is exported"),ue}function P(j,ue,xe,Pe){var je={string:function(ot){var Dt=0;if(ot!=null&&ot!==0){var Lt=(ot.length<<2)+1;Dt=Jr(Lt);var St=Dt,pt=k;if(0<Lt){Lt=St+Lt-1;for(var ln=0;ln<ot.length;++ln){var wt=ot.charCodeAt(ln);if(55296<=wt&&57343>=wt){var rr=ot.charCodeAt(++ln);wt=65536+((wt&1023)<<10)|rr&1023}if(127>=wt){if(St>=Lt)break;pt[St++]=wt}else{if(2047>=wt){if(St+1>=Lt)break;pt[St++]=192|wt>>6}else{if(65535>=wt){if(St+2>=Lt)break;pt[St++]=224|wt>>12}else{if(St+3>=Lt)break;pt[St++]=240|wt>>18,pt[St++]=128|wt>>12&63}pt[St++]=128|wt>>6&63}pt[St++]=128|wt&63}}pt[St]=0}}return Dt},array:function(ot){var Dt=Jr(ot.length);return I.set(ot,Dt),Dt}},Pt=Q(j),bn=[];if(j=0,Pe)for(var sn=0;sn<Pe.length;sn++){var yr=je[xe[sn]];yr?(j===0&&(j=Xr()),bn[sn]=yr(Pe[sn])):bn[sn]=Pe[sn]}return xe=Pt.apply(null,bn),xe=(function(ot){if(ue==="string")if(ot){for(var Dt=k,Lt=ot+NaN,St=ot;Dt[St]&&!(St>=Lt);)++St;if(16<St-ot&&Dt.subarray&&x)ot=x.decode(Dt.subarray(ot,St));else{for(Lt="";ot<St;){var pt=Dt[ot++];if(pt&128){var ln=Dt[ot++]&63;if((pt&224)==192)Lt+=String.fromCharCode((pt&31)<<6|ln);else{var wt=Dt[ot++]&63;pt=(pt&240)==224?(pt&15)<<12|ln<<6|wt:(pt&7)<<18|ln<<12|wt<<6|Dt[ot++]&63,65536>pt?Lt+=String.fromCharCode(pt):(pt-=65536,Lt+=String.fromCharCode(55296|pt>>10,56320|pt&1023))}}else Lt+=String.fromCharCode(pt)}ot=Lt}}else ot="";else ot=ue==="boolean"?!!ot:ot;return ot})(xe),j!==0&&Qi(j),xe}var x=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,w,I,k;function R(){var j=H.buffer;w=j,e.HEAP8=I=new Int8Array(j),e.HEAP16=new Int16Array(j),e.HEAP32=new Int32Array(j),e.HEAPU8=k=new Uint8Array(j),e.HEAPU16=new Uint16Array(j),e.HEAPU32=new Uint32Array(j),e.HEAPF32=new Float32Array(j),e.HEAPF64=new Float64Array(j)}var ne,z=[],Y=[],te=[];function ce(){var j=e.preRun.shift();z.unshift(j)}var $=0,B=null,L=null;e.preloadedImages={},e.preloadedAudios={};function K(j){throw e.onAbort&&e.onAbort(j),b(j),v=!0,j=new WebAssembly.RuntimeError("abort("+j+"). Build with -s ASSERTIONS=1 for more info."),s(j),j}var ee="data:application/octet-stream;base64,",fe;if(fe="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==",!fe.startsWith(ee)){var ie=fe;fe=e.locateFile?e.locateFile(ie,l):l+ie}function Ye(){var j=fe;try{if(j==fe&&C)return new Uint8Array(C);var ue=Bn(j);if(ue)return ue;if(p)return p(j);throw"both async and sync fetching of the wasm failed"}catch(xe){K(xe)}}function ft(){if(!C&&(a||c)){if(typeof fetch=="function"&&!fe.startsWith("file://"))return fetch(fe,{credentials:"same-origin"}).then(function(j){if(!j.ok)throw"failed to load wasm binary file at '"+fe+"'";return j.arrayBuffer()}).catch(function(){return Ye()});if(h)return new Promise(function(j,ue){h(fe,function(xe){j(new Uint8Array(xe))},ue)})}return Promise.resolve().then(function(){return Ye()})}function rn(j){for(;0<j.length;){var ue=j.shift();if(typeof ue=="function")ue(e);else{var xe=ue.m;typeof xe=="number"?ue.l===void 0?ne.get(xe)():ne.get(xe)(ue.l):xe(ue.l===void 0?null:ue.l)}}}var pr=!1,gr=typeof atob=="function"?atob:function(j){var ue="",xe=0;j=j.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var Pe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(xe++)),je="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(xe++)),Pt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(xe++)),bn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(j.charAt(xe++));Pe=Pe<<2|je>>4,je=(je&15)<<4|Pt>>2;var sn=(Pt&3)<<6|bn;ue+=String.fromCharCode(Pe),Pt!==64&&(ue+=String.fromCharCode(je)),bn!==64&&(ue+=String.fromCharCode(sn))}while(xe<j.length);return ue};function Bn(j){if(j.startsWith(ee)){if(j=j.slice(ee.length),typeof f=="boolean"&&f){var ue=Buffer.from(j,"base64");ue=new Uint8Array(ue.buffer,ue.byteOffset,ue.byteLength)}else try{var xe=gr(j),Pe=new Uint8Array(xe.length);for(j=0;j<xe.length;++j)Pe[j]=xe.charCodeAt(j);ue=Pe}catch{throw Error("Converting base64 string to bytes failed.")}return ue}}var mr={a:function(j){var ue=k.length;if(j>>>=0,2147483648<j)return!1;for(var xe=1;4>=xe;xe*=2){var Pe=ue*(1+.2/xe);Pe=Math.min(Pe,j+100663296),Pe=Math.max(j,Pe),0<Pe%65536&&(Pe+=65536-Pe%65536);e:{try{H.grow(Math.min(2147483648,Pe)-w.byteLength+65535>>>16),R();var je=1;break e}catch{}je=void 0}if(je)return!0}return!1}};(function(){function j(je){e.asm=je.exports,H=e.asm.b,R(),ne=e.asm.j,Y.unshift(e.asm.c),$--,e.monitorRunDependencies&&e.monitorRunDependencies($),$==0&&(B!==null&&(clearInterval(B),B=null),L&&(je=L,L=null,je()))}function ue(je){j(je.instance)}function xe(je){return ft().then(function(Pt){return WebAssembly.instantiate(Pt,Pe)}).then(je,function(Pt){b("failed to asynchronously prepare wasm: "+Pt),K(Pt)})}var Pe={a:mr};if($++,e.monitorRunDependencies&&e.monitorRunDependencies($),e.instantiateWasm)try{return e.instantiateWasm(Pe,j)}catch(je){return b("Module.instantiateWasm callback failed with error: "+je),!1}return(function(){return C||typeof WebAssembly.instantiateStreaming!="function"||fe.startsWith(ee)||fe.startsWith("file://")||typeof fetch!="function"?xe(ue):fetch(fe,{credentials:"same-origin"}).then(function(je){return WebAssembly.instantiateStreaming(je,Pe).then(ue,function(Pt){return b("wasm streaming compile failed: "+Pt),b("falling back to ArrayBuffer instantiation"),xe(ue)})})})().catch(s),{}})(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.c).apply(null,arguments)},e._poly1305_auth=function(){return(e._poly1305_auth=e.asm.d).apply(null,arguments)};var Xr=e.stackSave=function(){return(Xr=e.stackSave=e.asm.e).apply(null,arguments)},Qi=e.stackRestore=function(){return(Qi=e.stackRestore=e.asm.f).apply(null,arguments)},Jr=e.stackAlloc=function(){return(Jr=e.stackAlloc=e.asm.g).apply(null,arguments)};e._malloc=function(){return(e._malloc=e.asm.h).apply(null,arguments)},e._free=function(){return(e._free=e.asm.i).apply(null,arguments)},e.cwrap=function(j,ue,xe,Pe){xe=xe||[];var je=xe.every(function(Pt){return Pt==="number"});return ue!=="string"&&je&&!Pe?Q(j):function(){return P(j,ue,xe,arguments)}};var Ar;L=function j(){Ar||Er(),Ar||(L=j)};function Er(){function j(){if(!Ar&&(Ar=!0,e.calledRun=!0,!v)){if(rn(Y),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;){var ue=e.postRun.shift();te.unshift(ue)}rn(te)}}if(!(0<$)){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)ce();rn(z),0<$||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),j()},1)):j())}}if(e.run=Er,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();return Er(),t.ready})})();typeof ss=="object"&&typeof bo=="object"?bo.exports=_o:typeof define=="function"&&define.amd?define([],function(){return _o}):typeof ss=="object"&&(ss.createPoly1305=_o)});var Wn=ct((NE,Zc)=>{"use strict";var{createCipheriv:kr,createDecipheriv:os,createHmac:xo,randomFillSync:ar,timingSafeEqual:So}=require("crypto"),{readUInt32BE:ai,writeUInt32BE:an}=gn(),qn=Buffer[Symbol.species],Yc=2**32-1,jc=Buffer.alloc(0),vr=Buffer.alloc(4),as=new Map,cr=35e3,wo,Mo,Fo,Ho,Qo,Wo,qo;try{wo=require("./crypto/build/Release/sshcrypto.node"),{AESGCMCipher:Mo,ChaChaPolyCipher:Fo,GenericCipher:Ho,AESGCMDecipher:Qo,ChaChaPolyDecipher:Wo,GenericDecipher:qo}=wo}catch{}var Ft=1,Ip=(()=>{function n(t,e,r,s,i,o,a){return{sslName:t,blockLen:e,keyLen:r,ivLen:s!==0||a&Ft?s:e,authLen:i,discardLen:o,stream:!!(a&Ft)}}return{"chacha20-poly1305@openssh.com":n("chacha20",8,64,0,16,0,Ft),"aes128-gcm":n("aes-128-gcm",16,16,12,16,0,Ft),"aes256-gcm":n("aes-256-gcm",16,32,12,16,0,Ft),"aes128-gcm@openssh.com":n("aes-128-gcm",16,16,12,16,0,Ft),"aes256-gcm@openssh.com":n("aes-256-gcm",16,32,12,16,0,Ft),"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,Ft),"aes192-ctr":n("aes-192-ctr",16,24,16,0,0,Ft),"aes256-ctr":n("aes-256-ctr",16,32,16,0,0,Ft),"3des-ctr":n("des-ede3",8,24,8,0,0,Ft),"blowfish-ctr":n("bf-ecb",8,16,8,0,0,Ft),"cast128-ctr":n("cast5-ecb",8,16,8,0,0,Ft),arcfour:n("rc4",8,16,0,0,1536,Ft),arcfour128:n("rc4",8,16,0,0,1536,Ft),arcfour256:n("rc4",8,32,0,0,1536,Ft),arcfour512:n("rc4",8,64,0,0,1536,Ft)}})(),Cp=(()=>{function n(t,e,r,s){return{sslName:t,len:e,actualLen:r,isETM:s}}return{"hmac-md5":n("md5",16,16,!1),"hmac-md5-96":n("md5",16,12,!1),"hmac-ripemd160":n("ripemd160",20,20,!1),"hmac-sha1":n("sha1",20,20,!1),"hmac-sha1-etm@openssh.com":n("sha1",20,20,!0),"hmac-sha1-96":n("sha1",20,12,!1),"hmac-sha2-256":n("sha256",32,32,!1),"hmac-sha2-256-etm@openssh.com":n("sha256",32,32,!0),"hmac-sha2-256-96":n("sha256",32,12,!1),"hmac-sha2-512":n("sha512",64,64,!1),"hmac-sha2-512-etm@openssh.com":n("sha512",64,64,!0),"hmac-sha2-512-96":n("sha512",64,12,!1)}})(),Io=class{constructor(t,e){this.outSeqno=t,this._onWrite=e,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return an(s,e-4,0),s[4]=r,ar(s,5+t,r),s}encrypt(t){this._dead||(this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},Xc=Buffer.alloc(32),Xt=Buffer.alloc(16),oi,ci,Ko,Co=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encKeyMain=e.cipherKey.slice(0,32),this._encKeyPktLen=e.cipherKey.slice(32),this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e);return an(s,e-4,0),s[4]=r,ar(s,5+t,r),s}encrypt(t){if(this._dead)return;Xt[0]=0,an(Xt,this.outSeqno,12);let e=kr("chacha20",this._encKeyMain,Xt).update(Xc),r=kr("chacha20",this._encKeyPktLen,Xt).update(t.slice(0,4));this._onWrite(r),Xt[0]=1;let s=kr("chacha20",this._encKeyMain,Xt).update(t.slice(4));this._onWrite(s),Ko(ci,r,r.length,s,s.length,e);let i=Buffer.allocUnsafe(16);i.set(new Uint8Array(oi.HEAPU8.buffer,ci,16),0),this._onWrite(i),this.outSeqno=this.outSeqno+1>>>0}},vo=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new Fo(e.cipherKey),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=8-(e-4&7);r<4&&(r+=8),e+=r;let s=Buffer.allocUnsafe(e+16);return an(s,e-4,0),s[4]=r,ar(s,5+t,r),s}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},ko=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._encSSLName=e.cipherInfo.sslName,this._encKey=e.cipherKey,this._encIV=e.cipherIV,this._dead=!1}free(){this._dead=!0}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e);return an(s,e-4,0),s[4]=r,ar(s,5+t,r),s}encrypt(t){if(this._dead)return;let e=kr(this._encSSLName,this._encKey,this._encIV);e.setAutoPadding(!1);let r=t.slice(0,4);e.setAAD(r),this._onWrite(r);let s=e.update(t.slice(4));this._onWrite(s);let i=e.final();i.length&&this._onWrite(i);let o=e.getAuthTag();this._onWrite(o),Jc(this._encIV),this.outSeqno=this.outSeqno+1>>>0}},Bo=class{constructor(t){let e=t.outbound;this.outSeqno=e.seqno,this._onWrite=e.onWrite,this._instance=new Mo(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=5+t,r=16-(e-4&15);r<4&&(r+=16),e+=r;let s=Buffer.allocUnsafe(e+16);return an(s,e-4,0),s[4]=r,ar(s,5+t,r),s}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=kr(e.cipherInfo.sslName,e.cipherKey,e.cipherIV),this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._aadLen=this._macETM?4:0,this._dead=!1;let r=e.cipherInfo.discardLen;if(r){let s=as.get(r);s===void 0&&(s=Buffer.alloc(r),as.set(r,s)),this._cipherInstance.update(s)}}free(){this._dead=!0}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r);return an(i,r-4,0),i[4]=s,ar(i,5+t,s),i}encrypt(t){if(this._dead)return;let e;if(this._macETM){let s=new Uint8Array(t.buffer,t.byteOffset,4),i=this._cipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+4,t.length-4));this._onWrite(s),this._onWrite(i),e=xo(this._macSSLName,this._macKey),an(vr,this.outSeqno,0),e.update(vr),e.update(s),e.update(i)}else{let s=this._cipherInstance.update(t);this._onWrite(s),e=xo(this._macSSLName,this._macKey),an(vr,this.outSeqno,0),e.update(vr),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 Ho(e.cipherInfo.sslName,e.cipherKey,e.cipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM),this._dead=!1}free(){this._dead=!0,this._instance.free()}allocPacket(t){let e=this._encBlockLen,r=5+t,s=e-(r-this._aadLen&e-1);s<4&&(s+=e),r+=s;let i=Buffer.allocUnsafe(r+this._macLen);return an(i,r-4,0),i[4]=s,ar(i,5+t,s),i}encrypt(t){this._dead||(this._instance.encrypt(t,this.outSeqno),this._macActualLen<this._macLen&&(t=new qn(t.buffer,t.byteOffset,t.length-(this._macLen-this._macActualLen))),this._onWrite(t),this.outSeqno=this.outSeqno+1>>>0)}},Po=class{constructor(t,e){this.inSeqno=t,this._onPayload=e,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len>cr||this._len<8||(4+this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._packetPos<this._len){let i=Math.min(this._len-this._packetPos,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),e+=i,this._packetPos+=i,this._packetPos<this._len)return}let s=this._packet?new qn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):jc;this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},To=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;Xt[0]=0,an(Xt,this.inSeqno,12);let c=os("chacha20",this._decKeyPktLen,Xt).update(this._lenBuf);if(this._len=ai(c,0),this._len>cr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length")}if(this._pktLen<this._len){if(e>=r)return;let a=Math.min(this._len-this._pktLen,r-e),c;if(e!==0||a!==r?c=new Uint8Array(t.buffer,t.byteOffset+e,a):c=t,a===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._pktLen)),e+=a,this._pktLen+=a,this._pktLen<this._len||e>=r)return}{let a=Math.min(16-this._macPos,r-e);if(e!==0||a!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,a),this._macPos):this._mac.set(t,this._macPos),e+=a,this._macPos+=a,this._macPos<16)return}Xt[0]=0,an(Xt,this.inSeqno,12);let s=kr("chacha20",this._decKeyMain,Xt).update(Xc);if(Ko(ci,this._lenBuf,4,this._packet,this._packet.length,s),this._calcMac.set(new Uint8Array(oi.HEAPU8.buffer,ci,16),0),!So(this._calcMac,this._mac))throw new Error("Invalid MAC");Xt[0]=1;let i=os("chacha20",this._decKeyMain,Xt).update(this._packet),o=new qn(i.buffer,i.byteOffset+1,i.length-i[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let a=this._onPayload(o);if(a!==void 0)return a===!1?e:a}}}},Lo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Wo(e.decipherKey),this._len=0,this._lenBuf=Buffer.alloc(4),this._lenPos=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(16),this._macPos=0}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._lenPos<4){let i=Math.min(4-this._lenPos,r-e);for(;i--;)this._lenBuf[this._lenPos++]=t[e++];if(this._lenPos<4)return;if(this._len=this._instance.decryptLen(this._lenBuf,this.inSeqno),this._len>cr||this._len<8||(this._len&7)!==0)throw new Error("Bad packet length");if(e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<16)return}this._instance.decrypt(this._packet,this._mac,this.inSeqno);let s=new qn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenPos=0,this._packet=null,this._pktLen=0,this._macPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Uo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=null,this._decipherSSLName=e.decipherInfo.sslName,this._decipherKey=e.decipherKey,this._decipherIV=e.decipherIV,this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>cr||this._len<16||(this._len&15)!==0)throw new Error("Bad packet length");this._decipherInstance=os(this._decipherSSLName,this._decipherKey,this._decipherIV),this._decipherInstance.setAutoPadding(!1),this._decipherInstance.setAAD(vp(this._len))}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=this._decipherInstance.update(new Uint8Array(t.buffer,t.byteOffset+e,i)):o=this._decipherInstance.update(t),o.length&&(i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._packetPos)),this._packetPos+=o.length),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}{this._decipherInstance.setAuthTag(this._tag);let i=this._decipherInstance.final();i.length&&(this._packet?this._packet.set(i,this._packetPos):this._packet=i)}let s=this._packet?new qn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1):jc;this.inSeqno=this.inSeqno+1>>>0,Jc(this._decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},Do=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new Qo(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tag=Buffer.allocUnsafe(16),this._tagPos=0}free(){}decrypt(t,e,r){for(;e<r;){if(this._lenBytes<4){let i=Math.min(4-this._lenBytes,r-e);for(this._lenBytes+=i;i--;)this._len=(this._len<<8)+t[e++];if(this._lenBytes<4)return;if(this._len+20>cr||this._len<16||(this._len&15)!==0)throw new Error(`Bad packet length: ${this._len}`)}if(this._pktLen<this._len){if(e>=r)return;let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(16-this._tagPos,r-e);if(e!==0||i!==r?this._tag.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._tagPos):this._tag.set(t,this._tagPos),e+=i,this._tagPos+=i,this._tagPos<16)return}this._instance.decrypt(this._packet,this._len,this._tag);let s=new qn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._len=0,this._lenBytes=0,this._packet=null,this._pktLen=0,this._tagPos=0;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}},$o=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._decipherInstance=os(e.decipherInfo.sslName,e.decipherKey,e.decipherIV),this._decipherInstance.setAutoPadding(!1),this._block=Buffer.allocUnsafe(e.macInfo.isETM?4:e.decipherInfo.blockLen),this._blockSize=e.decipherInfo.blockLen,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macSSLName=e.macInfo.sslName,this._macKey=e.macKey,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM,this._macInstance=null;let r=e.decipherInfo.discardLen;if(r){let s=as.get(r);s===void 0&&(s=Buffer.alloc(r),as.set(r,s)),this._decipherInstance.update(s)}}free(){}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let o=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||o!==r||o<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._blockPos):this._block.set(t,this._blockPos),e+=o,this._blockPos+=o,this._blockPos<this._block.length)return;let a,c;if(this._macETM?this._len=c=ai(this._block,0):(a=this._decipherInstance.update(this._block),this._len=ai(a,0),c=4+this._len-this._blockSize),this._len>cr||this._len<5||(c&this._blockSize-1)!==0)throw new Error("Bad packet length");if(this._macInstance=xo(this._macSSLName,this._macKey),an(vr,this.inSeqno,0),this._macInstance.update(vr),this._macETM?this._macInstance.update(this._block):(this._macInstance.update(new Uint8Array(a.buffer,a.byteOffset,4)),this._pktLen=a.length-4,this._packetPos=this._pktLen,this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(a.buffer,a.byteOffset+4,this._packetPos),0)),e>=r)return}if(this._pktLen<this._len){let o=Math.min(this._len-this._pktLen,r-e),a;e!==0||o!==r?a=new Uint8Array(t.buffer,t.byteOffset+e,o):a=t,this._macETM&&this._macInstance.update(a);let c=this._decipherInstance.update(a);if(c.length&&(o===this._len?this._packet=c:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(c,this._packetPos)),this._packetPos+=c.length),e+=o,this._pktLen+=o,this._pktLen<this._len||e>=r)return}{let o=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||o!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._macPos):this._mac.set(t,this._macPos),e+=o,this._macPos+=o,this._macPos<this._macActualLen)return}this._macETM||this._macInstance.update(this._packet);let s=this._macInstance.digest();if(this._macActualLen<s.length&&(s=new Uint8Array(s.buffer,s.byteOffset,this._macActualLen)),!kp(s,this._mac))throw new Error("Invalid MAC");let i=new qn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._packetPos=0,this._pktLen=0,this._macPos=0,this._macInstance=null;{let o=this._onPayload(i);if(o!==void 0)return o===!1?e:o}}}},Oo=class{constructor(t){let e=t.inbound;this.inSeqno=e.seqno,this._onPayload=e.onPayload,this._instance=new qo(e.decipherInfo.sslName,e.decipherKey,e.decipherIV,e.macInfo.sslName,e.macKey,e.macInfo.isETM,e.macInfo.actualLen),this._block=Buffer.allocUnsafe(e.macInfo.isETM||e.decipherInfo.stream?4:e.decipherInfo.blockLen),this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._mac=Buffer.allocUnsafe(e.macInfo.actualLen),this._macPos=0,this._macActualLen=e.macInfo.actualLen,this._macETM=e.macInfo.isETM}free(){this._instance.free()}decrypt(t,e,r){for(;e<r;){if(this._blockPos<this._block.length){let i=Math.min(this._block.length-this._blockPos,r-e);if(e!==0||i!==r||i<t.length?this._block.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._blockPos):this._block.set(t,this._blockPos),e+=i,this._blockPos+=i,this._blockPos<this._block.length)return;let o;if(this._macETM?this._len=o=ai(this._block,0):(this._instance.decryptBlock(this._block),this._len=ai(this._block,0),o=4+this._len-this._block.length),this._len>cr||this._len<5||(o&this._block.length-1)!==0)throw new Error("Bad packet length");if(this._macETM||(this._pktLen=this._block.length-4,this._pktLen&&(this._packet=Buffer.allocUnsafe(this._len),this._packet.set(new Uint8Array(this._block.buffer,this._block.byteOffset+4,this._pktLen),0))),e>=r)return}if(this._pktLen<this._len){let i=Math.min(this._len-this._pktLen,r-e),o;if(e!==0||i!==r?o=new Uint8Array(t.buffer,t.byteOffset+e,i):o=t,i===this._len?this._packet=o:(this._packet||(this._packet=Buffer.allocUnsafe(this._len)),this._packet.set(o,this._pktLen)),e+=i,this._pktLen+=i,this._pktLen<this._len||e>=r)return}{let i=Math.min(this._macActualLen-this._macPos,r-e);if(e!==0||i!==r?this._mac.set(new Uint8Array(t.buffer,t.byteOffset+e,i),this._macPos):this._mac.set(t,this._macPos),e+=i,this._macPos+=i,this._macPos<this._macActualLen)return}this._instance.decrypt(this._packet,this.inSeqno,this._block,this._mac);let s=new qn(this._packet.buffer,this._packet.byteOffset+1,this._packet.length-this._packet[0]-1);this.inSeqno=this.inSeqno+1>>>0,this._blockPos=0,this._len=0,this._packet=null,this._pktLen=0,this._macPos=0,this._macInstance=null;{let i=this._onPayload(s);if(i!==void 0)return i===!1?e:i}}}};function Jc(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 vp=(()=>{let n=Buffer.alloc(4);return t=>(n[0]=t>>>24,n[1]=t>>>16,n[2]=t>>>8,n[3]=t,n)})();function kp(n,t){return n.length!==t.length?(So(n,n),!1):So(n,t)}function Bp(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>Yc)throw new Error("Invalid outbound.seqno");let e=!!t.forceNative;switch(t.cipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return Mo&&!e?new Bo(n):new ko(n);case"chacha20":return Fo&&!e?new vo(n):new Co(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 Ho&&!e?new No(n):new Ro(n)}}}function Rp(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>Yc)throw new Error("Invalid inbound.seqno");let e=!!t.forceNative;switch(t.decipherInfo.sslName){case"aes-128-gcm":case"aes-256-gcm":return Qo&&!e?new Do(n):new Uo(n);case"chacha20":return Wo&&!e?new Lo(n):new To(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 qo&&!e?new Oo(n):new $o(n)}}}Zc.exports={CIPHER_INFO:Ip,MAC_INFO:Cp,bindingAvailable:!!wo,init:new Promise(async(n,t)=>{try{oi=await zc()(),ci=oi._malloc(16),Ko=oi.cwrap("poly1305_auth",null,["number","array","number","array","number","array"])}catch(e){return t(e)}n()}),NullCipher:Io,createCipher:Bp,NullDecipher:Po,createDecipher:Rp}});var Vn=ct((PE,lf)=>{"use strict";var{createDecipheriv:Go,createECDH:Np,createHash:li,createHmac:Pp,createSign:Tp,createVerify:Lp,getCiphers:Up,sign:ef,verify:tf}=require("crypto"),Dp=Up(),{Ber:Be}=ri(),$p=mo().pbkdf,{CIPHER_INFO:ui}=Wn(),{eddsaSupported:zo,SUPPORTED_CIPHER:Op}=Tn(),{bufferSlice:fr,makeBufferParser:Mp,readString:ve,readUInt32BE:fi,writeUInt32BE:$t}=gn(),Ln=Symbol("Hash Algorithm"),mn=Symbol("Private key PEM"),xn=Symbol("Public key PEM"),Kn=Symbol("Public key SSH"),Br=Symbol("Decrypted Key"),Vo=Object.create(null);{let n=Object.keys(ui);for(let t=0;t<n.length;++t){let e=ui[n[t]].sslName;!e||Vo[e]||(Vo[e]=ui[n[t]])}}var cs=Mp();function An(n,t){t=t.base64Slice(0,t.length);let e=t.replace(/.{64}/g,`$&
4
4
  `);return t.length&63&&(e+=`
5
5
  `),`-----BEGIN ${n} KEY-----
6
- ${e}-----END ${n} KEY-----`}function ui(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return e.set(n,0),e.set(t,n.length),e}function Ko(n,t){let e=n.length,r=n._pos||0;for(let s=0;s<t;++s){let i=e-r;if(r>=e||i<4)return!1;let o=ci(n,r);if(i<4+o)return!1;r+=4+o}return n._pos=r,!0}function di(n,t){let e=new Be.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.113549.1.1.1"),e.writeNull(),e.endSequence(),e.startSequence(Be.BitString),e.writeByte(0),e.startSequence(),e.writeBuffer(n,Be.Integer),e.writeBuffer(t,Be.Integer),e.endSequence(),e.endSequence(),e.endSequence(),gn("PUBLIC",e.buffer)}function hi(n,t){let e=Buffer.allocUnsafe(15+t.length+4+n.length);Dt(e,7,0),e.utf8Write("ssh-rsa",4,7);let r=11;return Dt(e,t.length,r),e.set(t,r+=4),Dt(e,n.length,r+=t.length),e.set(n,r+4),e}var Zc=(()=>{function n(r,s,i,o,a,c,f,l){let u=new Be.Writer;return u.startSequence(),u.writeInt(0,Be.Integer),u.writeBuffer(r,Be.Integer),u.writeBuffer(s,Be.Integer),u.writeBuffer(i,Be.Integer),u.writeBuffer(o,Be.Integer),u.writeBuffer(a,Be.Integer),u.writeBuffer(c,Be.Integer),u.writeBuffer(f,Be.Integer),u.writeBuffer(l,Be.Integer),u.endSequence(),u.buffer}function t(r){return BigInt(`0x${r.hexSlice(0,r.length)}`)}function e(r){let s=r.toString(16);if((s.length&1)!==0)s=`0${s}`;else{let i=s.charCodeAt(0);(i===56||i===57||i>=97&&i<=102)&&(s=`00${s}`)}return Buffer.from(s,"hex")}return function(s,i,o,a,c,f){let l=t(o),u=e(l%(t(c)-1n)),h=e(l%(t(f)-1n));return gn("RSA PRIVATE",n(s,i,o,c,f,u,h,a))}})();function pi(n,t,e,r){let s=new Be.Writer;return s.startSequence(),s.startSequence(),s.writeOID("1.2.840.10040.4.1"),s.startSequence(),s.writeBuffer(n,Be.Integer),s.writeBuffer(t,Be.Integer),s.writeBuffer(e,Be.Integer),s.endSequence(),s.endSequence(),s.startSequence(Be.BitString),s.writeByte(0),s.writeBuffer(r,Be.Integer),s.endSequence(),s.endSequence(),gn("PUBLIC",s.buffer)}function gi(n,t,e,r){let s=Buffer.allocUnsafe(15+n.length+4+t.length+4+e.length+4+r.length);Dt(s,7,0),s.utf8Write("ssh-dss",4,7);let i=11;return Dt(s,n.length,i),s.set(n,i+=4),Dt(s,t.length,i+=n.length),s.set(t,i+=4),Dt(s,e.length,i+=t.length),s.set(e,i+=4),Dt(s,r.length,i+=e.length),s.set(r,i+4),s}function ef(n,t,e,r,s){let i=new Be.Writer;return i.startSequence(),i.writeInt(0,Be.Integer),i.writeBuffer(n,Be.Integer),i.writeBuffer(t,Be.Integer),i.writeBuffer(e,Be.Integer),i.writeBuffer(r,Be.Integer),i.writeBuffer(s,Be.Integer),i.endSequence(),gn("DSA PRIVATE",i.buffer)}function tf(n){let t=new Be.Writer;return t.startSequence(),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Be.BitString),t.writeByte(0),t._ensure(n.length),t._buf.set(n,t._offset),t._offset+=n.length,t.endSequence(),t.endSequence(),gn("PUBLIC",t.buffer)}function nf(n){let t=Buffer.allocUnsafe(19+n.length);return Dt(t,11,0),t.utf8Write("ssh-ed25519",4,11),Dt(t,n.length,15),t.set(n,19),t}function Pp(n){let t=new Be.Writer;return t.startSequence(),t.writeInt(0,Be.Integer),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Be.OctetString),t.writeBuffer(n,Be.OctetString),t.endSequence(),t.endSequence(),gn("PRIVATE",t.buffer)}function Vo(n,t){let e=new Be.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.10045.2.1"),e.writeOID(n),e.endSequence(),e.startSequence(Be.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),gn("PUBLIC",e.buffer)}function Go(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 Dt(r,19,0),r.utf8Write(`ecdsa-sha2-${e}`,4,19),Dt(r,8,23),r.utf8Write(e,27,8),Dt(r,t.length,35),r.set(t,39),r}function Tp(n,t,e){let r=new Be.Writer;return r.startSequence(),r.writeInt(1,Be.Integer),r.writeBuffer(e,Be.OctetString),r.startSequence(160),r.writeOID(n),r.endSequence(),r.startSequence(161),r.startSequence(Be.BitString),r.writeByte(0),r._ensure(t.length),r._buf.set(t,r._offset),r._offset+=t.length,r.endSequence(),r.endSequence(),r.endSequence(),gn("EC PRIVATE",r.buffer)}function Lp(n,t){let e=Sp(n);return e.setPrivateKey(t),e.getPublicKey()}var mi={sign:typeof Xc=="function"?function(t,e){let r=this[pn];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[Tn]);try{return Xc(e,t,r)}catch(s){return s}}:function(t,e){let r=this[pn];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[Tn]);let s=Ip(e);s.update(t);try{return s.sign(r)}catch(i){return i}},verify:typeof Jc=="function"?function(t,e,r){let s=this[_n];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[Tn]);try{return Jc(r,t,s,e)}catch(i){return i}}:function(t,e,r){let s=this[_n];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[Tn]);let i=Cp(r);i.update(t);try{return i.verify(s,e)}catch(o){return o}},isPrivateKey:function(){return this[pn]!==null},getPrivatePEM:function(){return this[pn]},getPublicPEM:function(){return this[_n]},getPublicSSH:function(){return this[qn]},equals:function(t){let e=of(t);return e instanceof Error?!1:this.type===e.type&&this[pn]===e[pn]&&this[_n]===e[_n]&&this[qn].equals(e[qn])}};function os(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[pn]=e,this[_n]=r,this[qn]=s,this[Tn]=i,this[Br]=o}os.prototype=mi;{let t=function(e,r,s){let i=[];if(e.length<8)return new Error("Malformed OpenSSH private key");let o=ci(e,0),a=ci(e,4);if(o!==a)return s?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");e._pos=8;let c,f;for(c=0;c<r;++c){let u,h,p,y,E=ke(e,e._pos,!0);if(E===void 0)return new Error("Malformed OpenSSH private key");switch(E){case"ssh-rsa":{let k=ke(e,e._pos);if(k===void 0)return new Error("Malformed OpenSSH private key");let D=ke(e,e._pos);if(D===void 0)return new Error("Malformed OpenSSH private key");let H=ke(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let C=ke(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let F=ke(e,e._pos);if(F===void 0)return new Error("Malformed OpenSSH private key");let V=ke(e,e._pos);if(V===void 0)return new Error("Malformed OpenSSH private key");p=di(k,D),y=hi(k,D),h=Zc(k,D,H,C,F,V),u="sha1";break}case"ssh-dss":{let k=ke(e,e._pos);if(k===void 0)return new Error("Malformed OpenSSH private key");let D=ke(e,e._pos);if(D===void 0)return new Error("Malformed OpenSSH private key");let H=ke(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let C=ke(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let F=ke(e,e._pos);if(F===void 0)return new Error("Malformed OpenSSH private key");p=pi(k,D,H,C),y=gi(k,D,H,C),h=ef(k,D,H,C,F),u="sha1";break}case"ssh-ed25519":{if(!qo)return new Error(`Unsupported OpenSSH private key type: ${E}`);let k=ke(e,e._pos);if(k===void 0||k.length!==32)return new Error("Malformed OpenSSH private key");let D=ke(e,e._pos);if(D===void 0||D.length!==64)return new Error("Malformed OpenSSH private key");p=tf(k),y=nf(k),h=Pp(ar(D,0,32)),u=null;break}case"ecdsa-sha2-nistp256":u="sha256",f="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":u===void 0&&(u="sha384",f="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(u===void 0&&(u="sha512",f="1.3.132.0.35"),!Ko(e,1))return new Error("Malformed OpenSSH private key");let k=ke(e,e._pos);if(k===void 0)return new Error("Malformed OpenSSH private key");let D=ke(e,e._pos);if(D===void 0)return new Error("Malformed OpenSSH private key");p=Vo(f,k),y=Go(f,k),h=Tp(f,k,D);break}default:return new Error(`Unsupported OpenSSH private key type: ${E}`)}let x=ke(e,e._pos,!0);if(x===void 0)return new Error("Malformed OpenSSH private key");i.push(new os(E,x,h,p,y,u,s))}let l=0;for(c=e._pos;c<e.length;++c)if(e[c]!==++l%255)return new Error("Malformed OpenSSH private key");return i},n=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;os.parse=(e,r)=>{let s=n.exec(e);if(s===null)return null;let i,o=Buffer.from(s[1],"base64");if(o.length<31)return new Error("Malformed OpenSSH private key");let a=o.utf8Slice(0,15);if(a!=="openssh-key-v1\0")return new Error(`Unsupported OpenSSH key magic: ${a}`);let c=ke(o,15,!0);if(c===void 0)return new Error("Malformed OpenSSH private key");if(c!=="none"&&Rp.indexOf(c)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${c}`);let f=ke(o,o._pos,!0);if(f===void 0)return new Error("Malformed OpenSSH private key");if(f!=="none"){if(c==="none")return new Error("Malformed OpenSSH private key");if(f!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${f}`);if(!r)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(c!=="none")return new Error("Malformed OpenSSH private key");let l,u,h;c!=="none"&&(l=li[c]);let p=ke(o,o._pos);if(p===void 0)return new Error("Malformed OpenSSH private key");if(p.length)switch(f){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{let E=ke(p,0);if(E===void 0||p._pos+4>p.length)return new Error("Malformed OpenSSH private key");let x=ci(p,p._pos),k=Buffer.allocUnsafe(l.keyLen+l.ivLen);if(Bp(r,r.length,E,E.length,k,k.length,x)!==0)return new Error("Failed to generate information to decrypt key");u=ar(k,0,l.keyLen),h=ar(k,l.keyLen,k.length);break}}else if(f!=="none")return new Error("Malformed OpenSSH private key");if(o._pos+3>=o.length)return new Error("Malformed OpenSSH private key");let y=ci(o,o._pos);if(o._pos+=4,y>0){for(let x=0;x<y;++x){let k=ke(o,o._pos);if(k===void 0)return new Error("Malformed OpenSSH private key");if(ke(k,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let E=ke(o,o._pos);if(E===void 0)return new Error("Malformed OpenSSH private key");if(u!==void 0){if(E.length<l.blockLen||E.length%l.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let x={authTagLength:l.authLen},k=Wo(l.sslName,u,h,x);if(k.setAutoPadding(!1),l.authLen>0){if(o.length-o._pos<l.authLen)return new Error("Malformed OpenSSH private key");k.setAuthTag(ar(o,o._pos,o._pos+=l.authLen))}E=ui(k.update(E),k.final())}catch(x){return x}}if(o._pos!==o.length)return new Error("Malformed OpenSSH private key");i=t(E,y,u!==void 0)}else i=[];return i instanceof Error?i:i[0]}}function as(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[pn]=e,this[_n]=r,this[qn]=s,this[Tn]=i,this[Br]=o}as.prototype=mi;{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-----$/;as.parse=(t,e)=>{let r=n.exec(t);if(r===null)return null;let s=Buffer.from(r[3],"base64"),i=r[2],o=!1;if(i!==void 0){i=i.split(/\r\n|\n/g);for(let y=0;y<i.length;++y){let E=i[y],x=E.indexOf(":");if(E.slice(0,x)==="DEK-Info"){let k=E.slice(x+2);if(x=k.indexOf(","),x===-1)continue;let D=k.slice(0,x).toLowerCase();if(vp.indexOf(D)===-1)return new Error(`Cipher (${D}) not supported for encrypted OpenSSH private key`);let H=Qo[D];if(!H)return new Error(`Cipher (${D}) not supported for encrypted OpenSSH private key`);let C=Buffer.from(k.slice(x+1),"hex");if(C.length!==H.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!e)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");let F=ar(C,0,8),V=fi("md5").update(e).update(F).digest();for(;V.length<H.keyLen;)V=ui(V,fi("md5").update(V).update(e).update(F).digest());V.length>H.keyLen&&(V=ar(V,0,H.keyLen));try{let N=Wo(D,V,C);N.setAutoPadding(!1),s=ui(N.update(s),N.final()),o=!0}catch(N){return N}}}}let a,c,f,l,u,h,p="Malformed OpenSSH private key";switch(o&&(p+=". Bad passphrase?"),r[1]){case"RSA":a="ssh-rsa",c=gn("RSA PRIVATE",s);try{h=new Be.Reader(s),h.readSequence(),h.readInt();let y=h.readString(Be.Integer,!0);if(y===null)return new Error(p);let E=h.readString(Be.Integer,!0);if(E===null)return new Error(p);f=di(y,E),l=hi(y,E)}catch{return new Error(p)}u="sha1";break;case"DSA":a="ssh-dss",c=gn("DSA PRIVATE",s);try{h=new Be.Reader(s),h.readSequence(),h.readInt();let y=h.readString(Be.Integer,!0);if(y===null)return new Error(p);let E=h.readString(Be.Integer,!0);if(E===null)return new Error(p);let x=h.readString(Be.Integer,!0);if(x===null)return new Error(p);let k=h.readString(Be.Integer,!0);if(k===null)return new Error(p);f=pi(y,E,x,k),l=gi(y,E,x,k)}catch{return new Error(p)}u="sha1";break;case"EC":{let y,E,x;try{h=new Be.Reader(s),h.readSequence(),h.readInt(),E=h.readString(Be.OctetString,!0),h.readByte();let D=h.readLength();if(D!==null){if(h._offset=D,x=h.readOID(),x===null)return new Error(p);switch(x){case"1.2.840.10045.3.1.7":y="prime256v1",a="ecdsa-sha2-nistp256",u="sha256";break;case"1.3.132.0.34":y="secp384r1",a="ecdsa-sha2-nistp384",u="sha384";break;case"1.3.132.0.35":y="secp521r1",a="ecdsa-sha2-nistp521",u="sha512";break;default:return new Error(`Unsupported private key EC OID: ${x}`)}}else return new Error(p)}catch{return new Error(p)}c=gn("EC PRIVATE",s);let k=Lp(y,E);f=Vo(x,k),l=Go(x,k);break}}return new as(a,"",c,f,l,u,o)}}function cs(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[pn]=e,this[_n]=r,this[qn]=s,this[Tn]=i,this[Br]=o}cs.prototype=mi;{let n=Buffer.alloc(0),t=Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e=Buffer.from([0,0,0,0]),r=Buffer.from([0,0,0,1]),s=/^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\r?\nEncryption: (aes256-cbc|none)\r?\nComment: ([^\r\n]*)\r?\nPublic-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-MAC: ([^\r\n]+)/;cs.parse=(i,o)=>{let a=s.exec(i);if(a===null)return null;let c=a[2],f=c!=="none";if(f&&!o)return new Error("Encrypted PPK private key detected, but no passphrase given");let l=Buffer.from(a[5],"base64");if(f){let I=li[c],v=ui(fi("sha1").update(e).update(o).digest(),fi("sha1").update(r).update(o).digest());v.length>I.keyLen&&(v=ar(v,0,I.keyLen));try{let R=Wo(I.sslName,v,t);R.setAutoPadding(!1),l=ui(R.update(l),R.final())}catch(R){return R}}let u=a[1],h=a[3],p=Buffer.from(a[4],"base64"),y=a[6],E=u.length,x=c.length,k=Buffer.byteLength(h),D=p.length,H=l.length,C=Buffer.allocUnsafe(4+E+4+x+4+k+4+D+4+H),F=0;if(Dt(C,E,F),C.utf8Write(u,F+=4,E),Dt(C,x,F+=E),C.utf8Write(c,F+=4,x),Dt(C,k,F+=x),C.utf8Write(h,F+=4,k),Dt(C,D,F+=k),C.set(p,F+=4),Dt(C,H,F+=D),C.set(l,F+4),o||(o=n),wp("sha1",fi("sha1").update("putty-private-key-file-mac-key").update(o).digest()).update(C).digest("hex")!==y)return f?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let N,b,S;switch(p._pos=0,Ko(p,1),u){case"ssh-rsa":{let I=ke(p,p._pos);if(I===void 0)return new Error("Malformed PPK public key");let v=ke(p,p._pos);if(v===void 0)return new Error("Malformed PPK public key");let R=ke(l,0);if(R===void 0)return new Error("Malformed PPK private key");let ne=ke(l,l._pos);if(ne===void 0)return new Error("Malformed PPK private key");let z=ke(l,l._pos);if(z===void 0)return new Error("Malformed PPK private key");let Y=ke(l,l._pos);if(Y===void 0)return new Error("Malformed PPK private key");N=di(v,I),b=hi(v,I),S=Zc(v,I,R,Y,ne,z);break}case"ssh-dss":{let I=ke(p,p._pos);if(I===void 0)return new Error("Malformed PPK public key");let v=ke(p,p._pos);if(v===void 0)return new Error("Malformed PPK public key");let R=ke(p,p._pos);if(R===void 0)return new Error("Malformed PPK public key");let ne=ke(p,p._pos);if(ne===void 0)return new Error("Malformed PPK public key");let z=ke(l,0);if(z===void 0)return new Error("Malformed PPK private key");N=pi(I,v,R,ne),b=gi(I,v,R,ne),S=ef(I,v,R,ne,z);break}}return new cs(u,h,S,N,b,"sha1",f)}}function ls(n,t,e,r,s){this.type=n,this.comment=t,this[pn]=null,this[_n]=e,this[qn]=r,this[Tn]=s,this[Br]=!1}ls.prototype=mi;{let n;qo?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].*)?)$/,ls.parse=t=>{let e=n.exec(t);if(e===null)return null;let r=e[1],s=e[2],i=Buffer.from(e[3],"base64"),o=e[4]||"",a=ke(i,i._pos,!0);return a===void 0||a.indexOf(s)!==0?new Error("Malformed OpenSSH public key"):zo(i,s,o,r)}}function fs(n,t,e,r,s){this.type=n,this.comment=t,this[pn]=null,this[_n]=e,this[qn]=r,this[Tn]=s,this[Br]=!1}fs.prototype=mi;{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;fs.parse=s=>{let i=n.exec(s);if(i===null)return null;let o=i[1],a=0,c="";for(;i=e.exec(o);){let p=i[1],y=i[2].replace(r,"");if(y.length>1024)return e.lastIndex=0,new Error("Malformed RFC4716 public key");a=e.lastIndex,p.toLowerCase()==="comment"&&(c=y,c.length>1&&c.charCodeAt(0)===34&&c.charCodeAt(c.length-1)===34&&(c=c.slice(1,-1)))}let f=o.slice(a);if(!t.test(f))return new Error("Malformed RFC4716 public key");f=Buffer.from(f,"base64");let l=ke(f,0,!0);if(l===void 0)return new Error("Malformed RFC4716 public key");let u=null,h=null;switch(l){case"ssh-rsa":{let p=ke(f,f._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let y=ke(f,f._pos);if(y===void 0)return new Error("Malformed RFC4716 public key");u=di(y,p),h=hi(y,p);break}case"ssh-dss":{let p=ke(f,f._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let y=ke(f,f._pos);if(y===void 0)return new Error("Malformed RFC4716 public key");let E=ke(f,f._pos);if(E===void 0)return new Error("Malformed RFC4716 public key");let x=ke(f,f._pos);if(x===void 0)return new Error("Malformed RFC4716 public key");u=pi(p,y,E,x),h=gi(p,y,E,x);break}default:return new Error("Malformed RFC4716 public key")}return new fs(l,c,u,h,"sha1")}}function zo(n,t,e,r){if(!rf(t))return new Error(`Unsupported OpenSSH public key type: ${t}`);let s,i,o=null,a=null;switch(t){case"ssh-rsa":{let c=ke(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let f=ke(n,n._pos);if(f===void 0)return new Error("Malformed OpenSSH public key");o=di(f,c),a=hi(f,c),s="sha1";break}case"ssh-dss":{let c=ke(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let f=ke(n,n._pos);if(f===void 0)return new Error("Malformed OpenSSH public key");let l=ke(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");let u=ke(n,n._pos);if(u===void 0)return new Error("Malformed OpenSSH public key");o=pi(c,f,l,u),a=gi(c,f,l,u),s="sha1";break}case"ssh-ed25519":{let c=ke(n,n._pos||0);if(c===void 0||c.length!==32)return new Error("Malformed OpenSSH public key");o=tf(c),a=nf(c),s=null;break}case"ecdsa-sha2-nistp256":s="sha256",i="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":s===void 0&&(s="sha384",i="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(s===void 0&&(s="sha512",i="1.3.132.0.35"),!Ko(n,1))return new Error("Malformed OpenSSH public key");let c=ke(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");o=Vo(i,c),a=Go(i,c);break}default:return new Error(`Unsupported OpenSSH public key type: ${t}`)}return new ls(r,e,o,a,s)}function rf(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(qo)return!0;default:return!1}}function sf(n){return n?typeof n[Br]=="boolean":!1}function of(n,t){if(sf(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=os.parse(n,t))!==null||(r=as.parse(n,t))!==null||(r=cs.parse(n,t))!==null||(r=ls.parse(n))!==null||(r=fs.parse(n))!==null)return r;if(e){ss.init(e,0);let s=ss.readString(!0);s!==void 0&&(n=ss.readRaw(),n!==void 0&&(r=zo(n,s,"",s),r instanceof Error&&(r=null))),ss.clear()}return r||new Error("Unsupported key format")}af.exports={isParsedKey:sf,isSupportedKeyType:rf,parseDERKey:(n,t)=>zo(n,t,"",t),parseKey:of}});var ea=at((BE,Af)=>{"use strict";var{Socket:uf}=require("net"),{Duplex:df}=require("stream"),{resolve:Up}=require("path"),{readFile:cf}=require("fs"),{execFile:Dp,spawn:$p}=require("child_process"),{isParsedKey:ff,parseKey:Ai}=Kn(),{makeBufferParser:Op,readUInt32BE:Zo,writeUInt32BE:Xt,writeUInt32LE:lf}=hn();function Ei(n){let t=!1;return(...e)=>{t||(t=!0,n(...e))}}function Mp(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return n.copy(e,0),t.copy(e,n.length),e}function jo(){}var Fp=Buffer.alloc(0),yt=Op(),_i=class{getIdentities(t){t(new Error("Missing getIdentities() implementation"))}sign(t,e,r,s){typeof r=="function"&&(s=r),s(new Error("Missing sign() implementation"))}},Nr=class extends _i{constructor(t){super(),this.socketPath=t}getStream(t){t=Ei(t);let e=new uf;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=Ei(t),this.getStream((e,r)=>{function s(o){if(r)try{r.destroy()}catch{}o||(o=new Error("Failed to retrieve identities from agent")),t(o)}if(e)return s(e);let i=new Xo(!0);i.on("error",s),i.pipe(r).pipe(i),r.on("close",s).on("end",s).on("error",s),i.getIdentities((o,a)=>{if(o)return s(o);try{r.destroy()}catch{}t(null,a)})})}sign(t,e,r,s){typeof r=="function"?(s=r,r=void 0):(typeof r!="object"||r===null)&&(r=void 0),s=Ei(s),this.getStream((i,o)=>{function a(f){if(o)try{o.destroy()}catch{}f||(f=new Error("Failed to sign data with agent")),s(f)}if(i)return a(i);let c=new Xo(!0);c.on("error",a),c.pipe(o).pipe(c),o.on("close",a).on("end",a).on("error",a),c.sign(t,e,r,(f,l)=>{if(f)return a(f);try{o.destroy()}catch{}s(null,l)})})}},hf=(()=>{let o=Up(__dirname,"..","util/pagent.exe"),a={10:new Error("Invalid pagent.exe arguments"),11:new Error("Pageant is not running"),12:new Error("pagent.exe could not create an mmap"),13:new Error("pagent.exe could not set mode for stdin"),14:new Error("pagent.exe could not set mode for stdout"),15:new Error("pagent.exe did not get expected input payload")};function c(l){l.buffer=null,l.proc&&(l.proc.kill(),l.proc=void 0)}class f extends df{constructor(){super(),this.proc=void 0,this.buffer=null}_read(u){}_write(u,h,p){if(this.buffer===null)this.buffer=u;else{let k=Buffer.allocUnsafe(this.buffer.length+u.length);this.buffer.copy(k,0),u.copy(k,this.buffer.length),this.buffer=k}if(this.buffer.length<4)return p();let y=Zo(this.buffer,0);if(this.buffer.length-4<y)return p();if(u=this.buffer.slice(0,4+y),this.buffer.length>4+y)return p(new Error("Unexpected multiple agent requests"));this.buffer=null;let E,x=this.proc=$p(o,[u.length]);x.stdout.on("data",k=>{this.push(k)}),x.on("error",k=>{E=k,p(E)}),x.on("close",k=>{if(this.proc=void 0,!E){if(E=a[k])return p(E);p()}}),x.stdin.end(u)}_final(u){c(this),u()}_destroy(u,h){c(this),h()}}return class extends Nr{getStream(u){u(null,new f)}}})(),pf=(()=>{let n=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Nr{getStream(e){e=Ei(e);let r=this.socketPath,s=!1;cf(r,function i(o,a){if(o){if(s)return e(new Error("Invalid cygwin unix socket path"));Dp("cygpath",["-w",r],(V,N,b)=>{if(V||N.length===0)return e(new Error("Invalid cygwin unix socket path"));s=!0,r=N.toString().replace(/[\r\n]/g,""),cf(r,i)});return}let c=n.exec(a.toString("ascii"));if(!c)return e(new Error("Malformed cygwin unix socket file"));let f,l=0,u=!1,h=[],p,y=Buffer.alloc(12),E=parseInt(c[1],10),x=c[2].replace(/-/g,""),k=Buffer.allocUnsafe(16);for(let V=0,N=0;N<32;++V,N+=2)k[V]=parseInt(x.substring(N,N+2),16);for(let V=0;V<16;V+=4)lf(k,Zo(k,V),V);F();function D(){l=0,f="secret",p.write(k)}function H(V){if(l+=V.length,f==="secret"){l===16&&(l=0,f="creds",p.write(y));return}if(f==="creds"&&(u||h.push(V),l===12)){if(p.removeListener("connect",D),p.removeListener("data",H),p.removeListener("error",C),p.removeListener("end",C),p.removeListener("close",C),u)return e(null,p);u=!0,y=Buffer.concat(h),lf(y,process.pid,0),p.on("error",()=>{}),p.destroy(),F()}}function C(){e(new Error("Problem negotiating cygwin unix socket security"))}function F(){p=new uf,p.on("connect",D),p.on("data",H),p.on("error",C),p.on("end",C),p.on("close",C),p.connect(E)}})}}})(),Hp=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function gf(n){return process.platform==="win32"&&!Hp.test(n)?n==="pageant"?new hf:new pf(n):new Nr(n)}var Xo=(()=>{function f(b){let S;for(;b[D].length;){let I=b[D][0][u];if(I===void 0)break;b[D].shift(),S=b.push(I)}return S}let l=Symbol("Inbound Request Type"),u=Symbol("Inbound Request Response"),h=Symbol("Inbound Request Context");class p{constructor(S,I){this[l]=S,this[u]=void 0,this[h]=I}hasResponded(){return this[u]!==void 0}getType(){return this[l]}getContext(){return this[h]}}function y(b,S,I){return S[u]=I,f(b)}function E(b){if(b[C]=null,b[H]===0){let S=b[D];if(S&&S.length){b[D]=[];for(let I of S)I.cb(new Error("No reply from server"))}}try{b.end()}catch{}setImmediate(()=>{b[N]||b.emit("end"),b[V]||b.emit("close")})}function x(){this[V]=!0}function k(){this[N]=!0}let D=Symbol("Requests"),H=Symbol("Agent Protocol Role"),C=Symbol("Agent Protocol Buffer"),F=Symbol("Agent Protocol Current Message Length"),V=Symbol("Agent Protocol Closed"),N=Symbol("Agent Protocol Ended");return class extends df{constructor(S){super({autoDestroy:!0,emitClose:!1}),this[H]=S?0:1,this[D]=[],this[C]=null,this[F]=-1,this.once("end",k),this.once("close",x)}_read(S){}_write(S,I,v){this[C]===null?this[C]=S:this[C]=Mp(this[C],S);let R=this[C],ne=R.length,z=0;for(;z<ne&&!(ne<5||(this[F]===-1&&(this[F]=Zo(R,z)),ne<4+this[F]));){let Y=R[z+=4];if(++z,this[H]===0){if(this[D].length===0)return v(new Error("Received unexpected message from server"));let te=this[D].shift();switch(Y){case 5:te.cb(new Error("Agent responded with failure"));break;case 12:{if(te.type!==11)return v(new Error("Agent responded with wrong message type"));yt.init(R,z);let ce=yt.readUInt32BE();if(ce===void 0)return yt.clear(),v(new Error("Malformed agent response"));let $=[];for(let B=0;B<ce;++B){let T=yt.readString();if(T===void 0)return yt.clear(),v(new Error("Malformed agent response"));let Q=yt.readString(!0);if(Q===void 0)return yt.clear(),v(new Error("Malformed agent response"));T=Ai(T),!(T instanceof Error)&&(T.comment=T.comment||Q,$.push(T))}z=yt.pos(),yt.clear(),te.cb(null,$);break}case 14:{if(te.type!==13)return v(new Error("Agent responded with wrong message type"));yt.init(R,z);let ce=yt.readString();if(z=yt.pos(),yt.clear(),ce===void 0)return v(new Error("Malformed agent response"));if(yt.init(ce,0),yt.readString(!0),ce=yt.readString(),yt.clear(),ce===void 0)return v(new Error("Malformed OpenSSH signature format"));te.cb(null,ce);break}default:return v(new Error("Agent responded with unsupported message type"))}}else switch(Y){case 11:{let te=new p(Y);this[D].push(te),this.emit("identities",te);break}case 13:{yt.init(R,z);let te=yt.readString(),ce=yt.readString(),$=yt.readUInt32BE();if(z=yt.pos(),yt.clear(),$===void 0){let ee=new p(Y);return this[D].push(ee),this.failureReply(ee)}if(te=Ai(te),te instanceof Error){let ee=new p(Y);return this[D].push(ee),this.failureReply(ee)}let B={hash:void 0},T;te.type==="ssh-rsa"&&($&2?(T="rsa-sha2-256",B.hash="sha256"):$&4&&(T="rsa-sha2-512",B.hash="sha512")),T===void 0&&(T=te.type);let Q=new p(Y,T);this[D].push(Q),this.emit("sign",Q,te,ce,B);break}default:{let te=new p(Y);this[D].push(te),this.failureReply(te)}}if(this[F]=-1,z===ne){this[C]=null;break}else this[C]=R=R.slice(z),ne=R.length,z=0}v()}_destroy(S,I){E(this),I()}_final(S){E(this),S()}sign(S,I,v,R){if(this[H]!==0)throw new Error("Client-only method called with server role");typeof v=="function"?(R=v,v=void 0):(typeof v!="object"||v===null)&&(v=void 0);let ne=0;if(S=Ai(S),S instanceof Error)throw new Error("Invalid public key argument");if(S.type==="ssh-rsa"&&v)switch(v.hash){case"sha256":ne=2;break;case"sha512":ne=4;break}S=S.getPublicSSH();let z=13,Y=S.length,te=I.length,ce=0,$=Buffer.allocUnsafe(9+Y+4+te+4);return Xt($,$.length-4,ce),$[ce+=4]=z,Xt($,Y,++ce),S.copy($,ce+=4),Xt($,te,ce+=Y),I.copy($,ce+=4),Xt($,ne,ce+=te),typeof R!="function"&&(R=jo),this[D].push({type:z,cb:R}),this.push($)}getIdentities(S){if(this[H]!==0)throw new Error("Client-only method called with server role");let I=11,v=0,R=Buffer.allocUnsafe(5);return Xt(R,R.length-4,v),R[v+=4]=I,typeof S!="function"&&(S=jo),this[D].push({type:I,cb:S}),this.push(R)}failureReply(S){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(S instanceof p))throw new Error("Wrong request argument");if(S.hasResponded())return!0;let I=0,v=Buffer.allocUnsafe(5);return Xt(v,v.length-4,I),v[I+=4]=5,y(this,S,v)}getIdentitiesReply(S,I){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(S instanceof p))throw new Error("Wrong request argument");if(S.hasResponded())return!0;if(S.getType()!==11)throw new Error("Invalid response to request");if(!Array.isArray(I))throw new Error("Keys argument must be an array");let v=4,R=[];for(let Y=0;Y<I.length;++Y){let te=I[Y];if(typeof te!="object"||te===null)throw new Error(`Invalid key entry: ${te}`);let ce,$;if(ff(te))ce=te;else if(ff(te.pubKey))ce=te.pubKey;else if(typeof te.pubKey!="object"||te.pubKey===null||({pubKey:ce,comment:$}=te.pubKey,ce=Ai(ce),ce instanceof Error))continue;$=ce.comment||$,ce=ce.getPublicSSH(),v+=4+ce.length,$&&typeof $=="string"?$=Buffer.from($):Buffer.isBuffer($)||($=Fp),v+=4+$.length,R.push({pubKey:ce,comment:$})}let ne=0,z=Buffer.allocUnsafe(5+v);Xt(z,z.length-4,ne),z[ne+=4]=12,Xt(z,R.length,++ne),ne+=4;for(let Y=0;Y<R.length;++Y){let{pubKey:te,comment:ce}=R[Y];Xt(z,te.length,ne),te.copy(z,ne+=4),Xt(z,ce.length,ne+=te.length),ne+=4,ce.length&&(ce.copy(z,ne),ne+=ce.length)}return y(this,S,z)}signReply(S,I){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(S instanceof p))throw new Error("Wrong request argument");if(S.hasResponded())return!0;if(S.getType()!==13)throw new Error("Invalid response to request");if(!Buffer.isBuffer(I))throw new Error("Signature argument must be a Buffer");if(I.length===0)throw new Error("Signature argument must be non-empty");let v=0,R=S.getContext(),ne=Buffer.byteLength(R),z=Buffer.allocUnsafe(13+ne+4+I.length);return Xt(z,z.length-4,v),z[v+=4]=14,Xt(z,4+ne+4+I.length,++v),Xt(z,ne,v+=4),z.utf8Write(R,v+=4,ne),Xt(z,I.length,v+=ne),I.copy(z,v+=4),y(this,S,z)}}})(),Yo=Symbol("Agent"),mn=Symbol("Agent Keys"),Ln=Symbol("Agent Keys Index"),Rr=Symbol("Agent Init Callbacks"),Jo=class{constructor(t){if(typeof t=="string")t=gf(t);else if(!mf(t))throw new Error("Invalid agent argument");this[Yo]=t,this[mn]=null,this[Ln]=-1,this[Rr]=null}init(t){if(typeof t!="function"&&(t=jo),this[mn]===null)if(this[Rr]===null){this[Rr]=[t];let e=(...r)=>{process.nextTick(()=>{let s=this[Rr];this[Rr]=null;for(let i of s)i(...r)})};this[Yo].getIdentities(Ei((r,s)=>{if(r)return e(r);if(!Array.isArray(s))return e(new Error("Agent implementation failed to provide keys"));let i=[];for(let o of s)o=Ai(o),!(o instanceof Error)&&i.push(o);this[mn]=i,this[Ln]=-1,e()}))}else this[Rr].push(t);else process.nextTick(t)}nextKey(){return this[mn]===null||++this[Ln]>=this[mn].length?!1:this[mn][this[Ln]]}currentKey(){return this[mn]===null||this[Ln]>=this[mn].length?null:this[mn][this[Ln]]}pos(){return this[mn]===null||this[Ln]>=this[mn].length?-1:this[Ln]}reset(){this[Ln]=-1}sign(...t){this[Yo].sign(...t)}};function mf(n){return n instanceof _i}Af.exports={AgentContext:Jo,AgentProtocol:Xo,BaseAgent:_i,createAgent:gf,CygwinAgent:pf,isAgent:mf,OpenSSHAgent:Nr,PageantAgent:hf}});var oa=at((RE,Ef)=>{"use strict";var{kMaxLength:Qp}=require("buffer"),{createInflate:Wp,constants:{DEFLATE:qp,INFLATE:Kp,Z_DEFAULT_CHUNK:Vp,Z_DEFAULT_COMPRESSION:Gp,Z_DEFAULT_MEMLEVEL:zp,Z_DEFAULT_STRATEGY:Yp,Z_DEFAULT_WINDOWBITS:jp,Z_PARTIAL_FLUSH:Xp}}=require("zlib"),Jp=Wp()._handle.constructor;function Zp(){throw new Error("Should not get here")}function eg(n,t,e){let r=this._owner,s=new Error(n);s.errno=t,s.code=e,r._err=s}function sa(n){n._handle&&(n._handle.close(),n._handle=null)}var us=class{constructor(t){let e=jp,r=Gp,s=zp,i=Yp,o=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=Vp,this._maxOutputLength=Qp,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new Jp(t),this._handle._owner=this,this._handle.onerror=eg,this._handle.init(e,r,s,i,this._writeState,Zp,o)}writeSync(t,e){let r=this._handle;if(!r)throw new Error("Invalid Zlib instance");let s=t.length,i=this._chunkSize-this._outOffset,o=0,a,c,f,l=0,u=this._writeState,h=this._outBuffer,p=this._outOffset,y=this._chunkSize;for(;;){if(r.writeSync(Xp,t,o,s,h,p,i),this._err)throw this._err;a=u[0],c=u[1];let x=s-c,k=i-a;if(k>0){let D=p===0&&k===h.length?h:h.slice(p,p+k);if(p+=k,f?f.push===void 0?f=[f,D]:f.push(D):f=D,l+=D.byteLength,l>this._maxOutputLength)throw sa(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(k!==0)throw new Error("have should not go down");if((a===0||p>=y)&&(i=y,p=0,h=Buffer.allocUnsafe(y)),a===0)o+=x,s=c;else break}if(this._outBuffer=h,this._outOffset=p,l===0&&(f=Buffer.alloc(0)),e)return f.totalLen=l,f;if(f.push===void 0)return f;let E=Buffer.allocUnsafe(l);for(let x=0,k=0;x<f.length;++x){let D=f[x];E.set(D,k),k+=D.length}return E}},ta=class{constructor(t){this.allocStart=0,this.allocStartKEX=0,this._protocol=t,this._zlib=new us(qp)}cleanup(){this._zlib&&sa(this._zlib)}alloc(t,e){return Buffer.allocUnsafe(t)}finalize(t,e){if(this._protocol._kexinit===void 0||e){let r=this._zlib.writeSync(t,!0),s=this._protocol._cipher.allocPacket(r.totalLen);if(r.push===void 0)s.set(r,5);else for(let i=0,o=5;i<r.length;++i){let a=r[i];s.set(a,o),o+=a.length}return s}return t}},na=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}},ra=class{constructor(){this._zlib=new us(Kp)}cleanup(){this._zlib&&sa(this._zlib)}read(t){return this._zlib.writeSync(t,!1)}},ia=class{cleanup(){}read(t){return t}};Ef.exports={PacketReader:ia,PacketWriter:na,ZlibPacketReader:ra,ZlibPacketWriter:ta}});var Sf=at((NE,xf)=>{"use strict";var{bufferSlice:aa,bufferParser:U,doFatalError:ht,sigSSHToASN1:_f,writeUInt32BE:yf}=hn(),{CHANNEL_OPEN_FAILURE:tg,COMPAT:ng,MESSAGE:gt,TERMINAL_MODE:bf}=Pn(),{parseKey:rg}=Kn(),ig=Array.from(Object.entries(bf)).reduce((n,[t,e])=>({...n,[t]:e}),{});xf.exports={[gt.DISCONNECT]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readString(!0),s=U.readString();if(U.clear(),s===void 0)return ht(n,"Inbound: Malformed DISCONNECT packet");n._debug&&n._debug(`Inbound: Received DISCONNECT (${e}, "${r}")`);let i=n._handlers.DISCONNECT;i&&i(n,e,r)},[gt.IGNORE]:(n,t)=>{n._debug&&n._debug("Inbound: Received IGNORE")},[gt.UNIMPLEMENTED]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return ht(n,"Inbound: Malformed UNIMPLEMENTED packet");n._debug&&n._debug(`Inbound: Received UNIMPLEMENTED (seqno ${e})`)},[gt.DEBUG]:(n,t)=>{U.init(t,1);let e=U.readBool(),r=U.readString(!0),s=U.readString();if(U.clear(),s===void 0)return ht(n,"Inbound: Malformed DEBUG packet");n._debug&&n._debug("Inbound: Received DEBUG");let i=n._handlers.DEBUG;i&&i(n,e,r)},[gt.SERVICE_REQUEST]:(n,t)=>{U.init(t,1);let e=U.readString(!0);if(U.clear(),e===void 0)return ht(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)},[gt.SERVICE_ACCEPT]:(n,t)=>{U.init(t,1);let e=U.readString(!0);if(U.clear(),e===void 0)return ht(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)},[gt.EXT_INFO]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r;if(e!==void 0){r=[];for(let i=0;i<e;++i){let o=U.readString(!0),a=U.readString();if(a!==void 0)if(o==="server-sig-algs"){let c=a.latin1Slice(0,a.length).split(",");r.push({name:o,algs:c});continue}else continue;r=void 0;break}}if(U.clear(),r===void 0)return ht(n,"Inbound: Malformed EXT_INFO packet");n._debug&&n._debug("Inbound: Received EXT_INFO");let s=n._handlers.EXT_INFO;s&&s(n,r)},[gt.USERAUTH_REQUEST]:(n,t)=>{U.init(t,1);let e=U.readString(!0),r=U.readString(!0),s=U.readString(!0),i,o;switch(s){case"none":i=null;break;case"password":{let c=U.readBool();if(c!==void 0&&(i=U.readString(!0),i!==void 0&&c)){let f=U.readString(!0);f!==void 0?i={oldPassword:i,newPassword:f}:i=void 0}break}case"publickey":{let c=U.readBool();if(c!==void 0){let f=U.readString(!0),l=f,u=U.readString(),h;switch(f){case"rsa-sha2-256":l="ssh-rsa",h="sha256";break;case"rsa-sha2-512":l="ssh-rsa",h="sha512";break}if(c){let p=U.pos(),y=U.readString();if(y!==void 0&&(y.length>4+f.length+4&&y.utf8Slice(4,4+f.length)===f&&(y=aa(y,4+f.length+4)),y=_f(y,l),y)){let E=n._kex.sessionID,x=Buffer.allocUnsafe(4+E.length+p);yf(x,E.length,0),x.set(E,4),x.set(new Uint8Array(t.buffer,t.byteOffset,p),4+E.length),i={keyAlgo:l,key:u,signature:y,blob:x,hashAlgo:h}}}else i={keyAlgo:l,key:u,hashAlgo:h},o="publickey -- check"}break}case"hostbased":{let c=U.readString(!0),f=c,l=U.readString(),u=U.readString(!0),h=U.readString(!0),p;switch(c){case"rsa-sha2-256":f="ssh-rsa",p="sha256";break;case"rsa-sha2-512":f="ssh-rsa",p="sha512";break}let y=U.pos(),E=U.readString();if(E!==void 0&&(E.length>4+c.length+4&&E.utf8Slice(4,4+c.length)===c&&(E=aa(E,4+c.length+4)),E=_f(E,f),E!==void 0)){let x=n._kex.sessionID,k=Buffer.allocUnsafe(4+x.length+y);yf(k,x.length,0),k.set(x,4),k.set(new Uint8Array(t.buffer,t.byteOffset,y),4+x.length),i={keyAlgo:f,key:l,signature:E,blob:k,localHostname:u,localUsername:h,hashAlgo:p}}break}case"keyboard-interactive":U.skipString(),i=U.readList();break;default:s!==void 0&&(i=U.readRaw())}if(U.clear(),i===void 0)return ht(n,"Inbound: Malformed USERAUTH_REQUEST packet");o===void 0&&(o=s),n._authsQueue.push(s),n._debug&&n._debug(`Inbound: Received USERAUTH_REQUEST (${o})`);let a=n._handlers.USERAUTH_REQUEST;a&&a(n,e,r,s,i)},[gt.USERAUTH_FAILURE]:(n,t)=>{U.init(t,1);let e=U.readList(),r=U.readBool();if(U.clear(),r===void 0)return ht(n,"Inbound: Malformed USERAUTH_FAILURE packet");n._debug&&n._debug(`Inbound: Received USERAUTH_FAILURE (${e})`),n._authsQueue.shift();let s=n._handlers.USERAUTH_FAILURE;s&&s(n,e,r)},[gt.USERAUTH_SUCCESS]:(n,t)=>{n._debug&&n._debug("Inbound: Received USERAUTH_SUCCESS"),n._authsQueue.shift();let e=n._handlers.USERAUTH_SUCCESS;e&&e(n)},[gt.USERAUTH_BANNER]:(n,t)=>{U.init(t,1);let e=U.readString(!0),r=U.readString();if(U.clear(),r===void 0)return ht(n,"Inbound: Malformed USERAUTH_BANNER packet");n._debug&&n._debug("Inbound: Received USERAUTH_BANNER");let s=n._handlers.USERAUTH_BANNER;s&&s(n,e)},60:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 60 without auth");return}switch(n._authsQueue[0]){case"password":{U.init(t,1);let e=U.readString(!0),r=U.readString();if(U.clear(),r===void 0)return ht(n,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");n._debug&&n._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");let s=n._handlers.USERAUTH_PASSWD_CHANGEREQ;s&&s(n,e);break}case"publickey":{U.init(t,1);let e=U.readString(!0),r=U.readString();if(U.clear(),r===void 0)return ht(n,"Inbound: Malformed USERAUTH_PK_OK packet");n._debug&&n._debug("Inbound: Received USERAUTH_PK_OK"),n._authsQueue.shift();let s=n._handlers.USERAUTH_PK_OK;s&&s(n,e,r);break}case"keyboard-interactive":{U.init(t,1);let e=U.readString(!0),r=U.readString(!0);U.readString();let s=U.readUInt32BE(),i;if(s!==void 0){i=new Array(s);let a;for(a=0;a<s;++a){let c=U.readString(!0),f=U.readBool();if(f===void 0)break;i[a]={prompt:c,echo:f}}a!==s&&(i=void 0)}if(U.clear(),i===void 0)return ht(n,"Inbound: Malformed USERAUTH_INFO_REQUEST packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_REQUEST");let o=n._handlers.USERAUTH_INFO_REQUEST;o&&o(n,e,r,i);break}default:n._debug&&n._debug("Inbound: Received unexpected payload type 60")}},61:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 61 without auth");return}if(n._authsQueue[0]!=="keyboard-interactive")return ht(n,"Inbound: Received unexpected payload type 61");U.init(t,1);let e=U.readUInt32BE(),r;if(e!==void 0){r=new Array(e);let i;for(i=0;i<e;++i){let o=U.readString(!0);if(o===void 0)break;r[i]=o}i!==e&&(r=void 0)}if(U.clear(),r===void 0)return ht(n,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_RESPONSE");let s=n._handlers.USERAUTH_INFO_RESPONSE;s&&s(n,r)},[gt.GLOBAL_REQUEST]:(n,t)=>{U.init(t,1);let e=U.readString(!0),r=U.readBool(),s;if(r!==void 0)switch(e){case"tcpip-forward":case"cancel-tcpip-forward":{let o=U.readString(!0),a=U.readUInt32BE();a!==void 0&&(s={bindAddr:o,bindPort:a});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let o=U.readString(!0);o!==void 0&&(s={socketPath:o});break}case"no-more-sessions@openssh.com":s=null;break;case"hostkeys-00@openssh.com":{for(s=[];U.avail()>0;){let o=U.readString();if(o===void 0){s=void 0;break}let a=rg(o);a instanceof Error||s.push(a)}break}default:s=U.readRaw()}if(U.clear(),s===void 0)return ht(n,"Inbound: Malformed GLOBAL_REQUEST packet");n._debug&&n._debug(`Inbound: GLOBAL_REQUEST (${e})`);let i=n._handlers.GLOBAL_REQUEST;i?i(n,e,r,s):n.requestFailure()},[gt.REQUEST_SUCCESS]:(n,t)=>{let e=t.length>1?aa(t,1):null;n._debug&&n._debug("Inbound: REQUEST_SUCCESS");let r=n._handlers.REQUEST_SUCCESS;r&&r(n,e)},[gt.REQUEST_FAILURE]:(n,t)=>{n._debug&&n._debug("Inbound: Received REQUEST_FAILURE");let e=n._handlers.REQUEST_FAILURE;e&&e(n)},[gt.CHANNEL_OPEN]:(n,t)=>{U.init(t,1);let e=U.readString(!0),r=U.readUInt32BE(),s=U.readUInt32BE(),i=U.readUInt32BE(),o;switch(e){case"forwarded-tcpip":case"direct-tcpip":{let c=U.readString(!0),f=U.readUInt32BE(),l=U.readString(!0),u=U.readUInt32BE();u!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{destIP:c,destPort:f,srcIP:l,srcPort:u}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{let c=U.readString(!0);c!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{socketPath:c}});break}case"x11":{let c=U.readString(!0),f=U.readUInt32BE();f!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{srcIP:c,srcPort:f}});break}default:o={type:e,sender:r,window:s,packetSize:i,data:{}}}if(U.clear(),o===void 0)return ht(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,tg.ADMINISTRATIVELY_PROHIBITED,"","")},[gt.CHANNEL_OPEN_CONFIRMATION]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readUInt32BE(),s=U.readUInt32BE(),i=U.readUInt32BE(),o=U.avail()?U.readRaw():void 0;if(U.clear(),i===void 0)return ht(n,"Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${e}, s:${r})`);let a=n._handlers.CHANNEL_OPEN_CONFIRMATION;a&&a(n,{recipient:e,sender:r,window:s,packetSize:i,data:o})},[gt.CHANNEL_OPEN_FAILURE]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readUInt32BE(),s=U.readString(!0),i=U.readString();if(U.clear(),i===void 0)return ht(n,"Inbound: Malformed CHANNEL_OPEN_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${e})`);let o=n._handlers.CHANNEL_OPEN_FAILURE;o&&o(n,e,r,s)},[gt.CHANNEL_WINDOW_ADJUST]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readUInt32BE();if(U.clear(),r===void 0)return ht(n,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");n._debug&&n._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${e}, ${r})`);let s=n._handlers.CHANNEL_WINDOW_ADJUST;s&&s(n,e,r)},[gt.CHANNEL_DATA]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readString();if(U.clear(),r===void 0)return ht(n,"Inbound: Malformed CHANNEL_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_DATA (r:${e}, ${r.length})`);let s=n._handlers.CHANNEL_DATA;s&&s(n,e,r)},[gt.CHANNEL_EXTENDED_DATA]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readUInt32BE(),s=U.readString();if(U.clear(),s===void 0)return ht(n,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${e}, ${s.length})`);let i=n._handlers.CHANNEL_EXTENDED_DATA;i&&i(n,e,s,r)},[gt.CHANNEL_EOF]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return ht(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)},[gt.CHANNEL_CLOSE]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return ht(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)},[gt.CHANNEL_REQUEST]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE(),r=U.readString(!0),s=U.readBool(),i;if(s!==void 0)switch(r){case"exit-status":i=U.readUInt32BE(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"exit-signal":{let a,c;if(n._compatFlags&ng.OLD_EXIT){let l=U.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})`)}c=!1}else a=U.readString(!0),c=U.readBool(),c===void 0&&(a=void 0);let f=U.readString(!0);U.skipString()!==void 0&&(i={signal:a,coreDumped:c,errorMessage:f}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a})`);break}case"pty-req":{let a=U.readString(!0),c=U.readUInt32BE(),f=U.readUInt32BE(),l=U.readUInt32BE(),u=U.readUInt32BE(),h=U.readString();if(h!==void 0){U.init(h,1);let p={};for(;U.avail();){let y=U.readByte();if(y===bf.TTY_OP_END)break;let E=ig[y],x=U.readUInt32BE();if(y===void 0||E===void 0||x===void 0){p=void 0;break}p[E]=x}p!==void 0&&(i={term:a,cols:c,rows:f,width:l,height:u,modes:p})}n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"window-change":{let a=U.readUInt32BE(),c=U.readUInt32BE(),f=U.readUInt32BE(),l=U.readUInt32BE();l!==void 0&&(i={cols:a,rows:c,width:f,height:l}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"x11-req":{let a=U.readBool(),c=U.readString(!0),f=U.readString(),l=U.readUInt32BE();l!==void 0&&(i={single:a,protocol:c,cookie:f,screen:l}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"env":{let a=U.readString(!0),c=U.readString(!0);c!==void 0&&(i={name:a,value:c}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a}=${c})`);break}case"shell":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;case"exec":i=U.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"subsystem":i=U.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"signal":i=U.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"xon-xoff":i=U.readBool(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"auth-agent-req@openssh.com":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;default:i=U.avail()?U.readRaw():null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`)}if(U.clear(),i===void 0)return ht(n,"Inbound: Malformed CHANNEL_REQUEST packet");let o=n._handlers.CHANNEL_REQUEST;o&&o(n,e,r,s,i)},[gt.CHANNEL_SUCCESS]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return ht(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)},[gt.CHANNEL_FAILURE]:(n,t)=>{U.init(t,1);let e=U.readUInt32BE();if(U.clear(),e===void 0)return ht(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 ds=at((PE,wf)=>{"use strict";var ca=new Array(256);[hs().HANDLERS,Sf()].forEach(n=>{for(let[t,e]of Object.entries(n))t=+t,isFinite(t)&&t>=0&&t<ca.length&&(ca[t]=e)});wf.exports=ca});var hs=at((LE,Lf)=>{"use strict";var{createDiffieHellman:sg,createDiffieHellmanGroup:og,createECDH:ag,createHash:la,createPublicKey:cg,diffieHellman:fg,generateKeyPairSync:lg,randomFillSync:ug}=require("crypto"),{Ber:If}=ni(),{COMPAT:ua,curve25519Supported:dg,DEFAULT_KEX:Cf,DEFAULT_SERVER_HOST_KEY:kf,DEFAULT_CIPHER:ps,DEFAULT_MAC:gs,DEFAULT_COMPRESSION:ms,DISCONNECT_REASON:Ge,MESSAGE:ut}=Pn(),{CIPHER_INFO:Lr,createCipher:hg,createDecipher:pg,MAC_INFO:vf}=Qn(),{parseDERKey:gg}=Kn(),{bufferFill:mg,bufferParser:Ve,convertSignature:Ag,doFatalError:ze,FastBuffer:Eg,sigSSHToASN1:_g,writeUInt32BE:$t}=hn(),{PacketReader:Bf,PacketWriter:Rf,ZlibPacketReader:As,ZlibPacketWriter:Es}=oa(),Pr,yg=2048,bg=8192,xg=Buffer.alloc(0);function Nf(n){let t;if(n._compatFlags&ua.BAD_DHGEX){let e=n._offer.lists.kex,r=e.array,s=!1;for(let i=0;i<r.length;++i)r[i].includes("group-exchange")&&(s||(s=!0,r=r.slice()),r.splice(i--,1));if(s){let i=17+n._offer.totalSize+1+4,o=Buffer.from(r.join(","));i-=e.buffer.length-o.length;let a=n._offer.lists.all,c=new Uint8Array(a.buffer,a.byteOffset+4+e.buffer.length,a.length-(4+e.buffer.length));t=Buffer.allocUnsafe(i),$t(t,o.length,17),t.set(o,21),t.set(c,21+o.length)}}t===void 0&&(t=Buffer.allocUnsafe(17+n._offer.totalSize+1+4),n._offer.copyAllTo(t,17)),n._debug&&n._debug("Outbound: Sending KEXINIT"),t[0]=ut.KEXINIT,ug(t,1,16),mg(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 Pf(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(Ve.init(t,17),(e.kex=Ve.readList())===void 0||(e.serverHostKey=Ve.readList())===void 0||(e.cs.cipher=Ve.readList())===void 0||(e.sc.cipher=Ve.readList())===void 0||(e.cs.mac=Ve.readList())===void 0||(e.sc.mac=Ve.readList())===void 0||(e.cs.compress=Ve.readList())===void 0||(e.sc.compress=Ve.readList())===void 0||(e.cs.lang=Ve.readList())===void 0||(e.sc.lang=Ve.readList())===void 0)return Ve.clear(),ze(n,"Received malformed KEXINIT","handshake",Ge.KEY_EXCHANGE_FAILED);let r=Ve.pos(),s=r<t.length&&t[r]===1;Ve.clear();let i=n._offer,o=e,a=i.lists.kex.array;if(n._compatFlags&ua.BAD_DHGEX){let C=!1;for(let F=0;F<a.length;++F)a[F].indexOf("group-exchange")!==-1&&(C||(C=!0,a=a.slice()),a.splice(F--,1))}let c,f,l,u=n._debug;u&&u("Inbound: Handshake in progress"),u&&u(`Handshake: (local) KEX method: ${a}`),u&&u(`Handshake: (remote) KEX method: ${o.kex}`);let h;if(n._server?(f=a,c=o.kex,h=c.indexOf("ext-info-c")!==-1):(f=o.kex,c=a,h=f.indexOf("ext-info-s")!==-1),n._strictMode===void 0&&(n._server?n._strictMode=c.indexOf("kex-strict-c-v00@openssh.com")!==-1:n._strictMode=f.indexOf("kex-strict-s-v00@openssh.com")!==-1,n._strictMode&&(u&&u("Handshake: strict KEX mode enabled"),n._decipher.inSeqno!==1)))return u&&u("Handshake: KEXINIT not first packet in strict KEX mode"),ze(n,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",Ge.KEY_EXCHANGE_FAILED);for(l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: no matching key exchange algorithm"),ze(n,"Handshake failed: no matching key exchange algorithm","handshake",Ge.KEY_EXCHANGE_FAILED);e.kex=c[l],u&&u(`Handshake: KEX algorithm: ${c[l]}`),s&&(!o.kex.length||c[l]!==o.kex[0])&&(n._skipNextInboundPacket=!0);let p=i.lists.serverHostKey.array;for(u&&u(`Handshake: (local) Host key format: ${p}`),u&&u(`Handshake: (remote) Host key format: ${o.serverHostKey}`),n._server?(f=p,c=o.serverHostKey):(f=o.serverHostKey,c=p),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching host key format"),ze(n,"Handshake failed: no matching host key format","handshake",Ge.KEY_EXCHANGE_FAILED);e.serverHostKey=c[l],u&&u(`Handshake: Host key format: ${c[l]}`);let y=i.lists.cs.cipher.array;for(u&&u(`Handshake: (local) C->S cipher: ${y}`),u&&u(`Handshake: (remote) C->S cipher: ${o.cs.cipher}`),n._server?(f=y,c=o.cs.cipher):(f=o.cs.cipher,c=y),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching C->S cipher"),ze(n,"Handshake failed: no matching C->S cipher","handshake",Ge.KEY_EXCHANGE_FAILED);e.cs.cipher=c[l],u&&u(`Handshake: C->S Cipher: ${c[l]}`);let E=i.lists.sc.cipher.array;for(u&&u(`Handshake: (local) S->C cipher: ${E}`),u&&u(`Handshake: (remote) S->C cipher: ${o.sc.cipher}`),n._server?(f=E,c=o.sc.cipher):(f=o.sc.cipher,c=E),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching S->C cipher"),ze(n,"Handshake failed: no matching S->C cipher","handshake",Ge.KEY_EXCHANGE_FAILED);e.sc.cipher=c[l],u&&u(`Handshake: S->C cipher: ${c[l]}`);let x=i.lists.cs.mac.array;if(u&&u(`Handshake: (local) C->S MAC: ${x}`),u&&u(`Handshake: (remote) C->S MAC: ${o.cs.mac}`),Lr[e.cs.cipher].authLen>0)e.cs.mac="",u&&u("Handshake: C->S MAC: <implicit>");else{for(n._server?(f=x,c=o.cs.mac):(f=o.cs.mac,c=x),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching C->S MAC"),ze(n,"Handshake failed: no matching C->S MAC","handshake",Ge.KEY_EXCHANGE_FAILED);e.cs.mac=c[l],u&&u(`Handshake: C->S MAC: ${c[l]}`)}let k=i.lists.sc.mac.array;if(u&&u(`Handshake: (local) S->C MAC: ${k}`),u&&u(`Handshake: (remote) S->C MAC: ${o.sc.mac}`),Lr[e.sc.cipher].authLen>0)e.sc.mac="",u&&u("Handshake: S->C MAC: <implicit>");else{for(n._server?(f=k,c=o.sc.mac):(f=o.sc.mac,c=k),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching S->C MAC"),ze(n,"Handshake failed: no matching S->C MAC","handshake",Ge.KEY_EXCHANGE_FAILED);e.sc.mac=c[l],u&&u(`Handshake: S->C MAC: ${c[l]}`)}let D=i.lists.cs.compress.array;for(u&&u(`Handshake: (local) C->S compression: ${D}`),u&&u(`Handshake: (remote) C->S compression: ${o.cs.compress}`),n._server?(f=D,c=o.cs.compress):(f=o.cs.compress,c=D),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching C->S compression"),ze(n,"Handshake failed: no matching C->S compression","handshake",Ge.KEY_EXCHANGE_FAILED);e.cs.compress=c[l],u&&u(`Handshake: C->S compression: ${c[l]}`);let H=i.lists.sc.compress.array;for(u&&u(`Handshake: (local) S->C compression: ${H}`),u&&u(`Handshake: (remote) S->C compression: ${o.sc.compress}`),n._server?(f=H,c=o.sc.compress):(f=o.sc.compress,c=H),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching S->C compression"),ze(n,"Handshake failed: no matching S->C compression","handshake",Ge.KEY_EXCHANGE_FAILED);e.sc.compress=c[l],u&&u(`Handshake: S->C compression: ${c[l]}`),e.cs.lang="",e.sc.lang="",n._kex&&(n._kexinit||Nf(n),n._decipher._onPayload=Tf.bind(n,{firstPacket:!1})),n._kex=Sg(e,n,t),n._kex.remoteExtInfoEnabled=h,n._kex.start()}var Sg=(()=>{function n(o){let a=0,c=o.length;for(;o[a]===0;)++a,--c;let f;return o[a]&128?(f=Buffer.allocUnsafe(1+c),f[0]=0,o.copy(f,1,a),o=f):c!==o.length&&(f=Buffer.allocUnsafe(c),o.copy(f,0,a),o=f),o}class t{constructor(a,c,f){this._protocol=c,this.sessionID=c._kex?c._kex.sessionID:void 0,this.negotiated=a,this.remoteExtInfoEnabled=!1,this._step=1,this._public=null,this._dh=null,this._sentNEWKEYS=!1,this._receivedNEWKEYS=!1,this._finished=!1,this._hostVerified=!1,this._kexinit=c._kexinit,this._remoteKexinit=f,this._identRaw=c._identRaw,this._remoteIdentRaw=c._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(a){if(this._finished)return!1;this._finished=!0;let c=this._protocol._server,f=this.negotiated,l=this.convertPublicKey(this._dhData),u=this.computeSecret(this._dhData);if(u instanceof Error)return u.message=`Error while computing DH secret (${this.type}): ${u.message}`,u.level="handshake",ze(this._protocol,u,Ge.KEY_EXCHANGE_FAILED);let h=la(this.hashName);yn(h,c?this._remoteIdentRaw:this._identRaw),yn(h,c?this._identRaw:this._remoteIdentRaw),yn(h,c?this._remoteKexinit:this._kexinit),yn(h,c?this._kexinit:this._remoteKexinit);let p=c?this._hostKey.getPublicSSH():this._hostKey;if(yn(h,p),this.type==="groupex"){let H=this.getDHParams(),C=Buffer.allocUnsafe(4);$t(C,this._minBits,0),h.update(C),$t(C,this._prefBits,0),h.update(C),$t(C,this._maxBits,0),h.update(C),yn(h,H.prime),yn(h,H.generator)}yn(h,c?l:this.getPublicKey());let y=c?this.getPublicKey():l;yn(h,y),yn(h,u);let E=h.digest();if(c){let H;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":H="sha256";break;case"rsa-sha2-512":H="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let C=this._hostKey.sign(E,H);if(C instanceof Error)return ze(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${C.message}`,"handshake",Ge.KEY_EXCHANGE_FAILED);if(C=Ag(C,this._hostKey.type),C===!1)return ze(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",Ge.KEY_EXCHANGE_FAILED);let F=this.negotiated.serverHostKey,V=Buffer.byteLength(F),N=4+V+4+C.length,b=this._protocol._packetRW.write.allocStartKEX,S=this._protocol._packetRW.write.alloc(5+p.length+4+y.length+4+N,!0);if(S[b]=ut.KEXDH_REPLY,$t(S,p.length,++b),S.set(p,b+=4),$t(S,y.length,b+=p.length),S.set(y,b+=4),$t(S,N,b+=y.length),$t(S,V,b+=4),S.utf8Write(F,b+=4,V),$t(S,C.length,b+=V),S.set(C,b+=4),this._protocol._debug){let I;switch(this.type){case"group":I="KEXDH_REPLY";break;case"groupex":I="KEXDH_GEX_REPLY";break;default:I="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${I}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(S,!0))}else{Ve.init(this._sig,0);let H=Ve.readString(!0);if(!H)return ze(this._protocol,"Malformed packet while reading signature","handshake",Ge.KEY_EXCHANGE_FAILED);if(H!==f.serverHostKey)return ze(this._protocol,`Wrong signature type: ${H}, expected: ${f.serverHostKey}`,"handshake",Ge.KEY_EXCHANGE_FAILED);let C=Ve.readString();if(Ve.clear(),C===void 0)return ze(this._protocol,"Malformed packet while reading signature","handshake",Ge.KEY_EXCHANGE_FAILED);if(!(C=_g(C,H)))return ze(this._protocol,"Malformed signature","handshake",Ge.KEY_EXCHANGE_FAILED);let F;{Ve.init(this._hostKey,0);let b=Ve.readString(!0),S=this._hostKey.slice(Ve.pos());if(Ve.clear(),F=gg(S,b),F instanceof Error)return F.level="handshake",ze(this._protocol,F,Ge.KEY_EXCHANGE_FAILED)}let V;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":V="sha256";break;case"rsa-sha2-512":V="sha512";break}this._protocol._debug&&this._protocol._debug("Verifying signature ...");let N=F.verify(E,C,V);if(N!==!0)return N instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${N.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),ze(this._protocol,"Handshake failed: signature verification failed","handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(c||!a)&&_s(this);let x,k,D=H=>{if(x)return _s(this),x.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=hg(x),this._protocol._packetRW.write=k,x=void 0,k=void 0,this._protocol._onHandshakeComplete(f),!1;this.sessionID||(this.sessionID=E);{let te=Buffer.allocUnsafe(4+u.length);$t(te,u.length,0),te.set(u,4),u=te}let C=Lr[f.cs.cipher],F=Lr[f.sc.cipher],V=Tr(C.ivLen,this.hashName,u,E,this.sessionID,"A"),N=Tr(F.ivLen,this.hashName,u,E,this.sessionID,"B"),b=Tr(C.keyLen,this.hashName,u,E,this.sessionID,"C"),S=Tr(F.keyLen,this.hashName,u,E,this.sessionID,"D"),I,v;C.authLen||(I=vf[f.cs.mac],v=Tr(I.len,this.hashName,u,E,this.sessionID,"E"));let R,ne;F.authLen||(R=vf[f.sc.mac],ne=Tr(R.len,this.hashName,u,E,this.sessionID,"F"));let z={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:c?C:F,decipherIV:c?V:N,decipherKey:c?b:S,macInfo:c?I:R,macKey:c?v:ne},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:c?F:C,cipherIV:c?N:V,cipherKey:c?S:b,macInfo:c?R:I,macKey:c?ne:v}};this._protocol._decipher.free(),x=z,this._protocol._decipher=pg(z);let Y={read:void 0,write:void 0};switch(f.cs.compress){case"zlib":c?Y.read=new As:Y.write=new Es(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){c?Y.read=new As:Y.write=new Es(this._protocol);break}default:c?Y.read=new Bf:Y.write=new Rf(this._protocol)}switch(f.sc.compress){case"zlib":c?Y.write=new Es(this._protocol):Y.read=new As;break;case"zlib@openssh.com":if(this._protocol._authenticated){c?Y.write=new Es(this._protocol):Y.read=new As;break}default:c?Y.write=new Rf(this._protocol):Y.read=new Bf}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=Y.read,k=Y.write,this._public=null,this._dh=null,this._kexinit=this._protocol._kexinit=void 0,this._remoteKexinit=void 0,this._identRaw=void 0,this._remoteIdentRaw=void 0,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0,H?!1:D()};if((c||a)&&(this.finish=D),!c)return D(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(),c=this._protocol._packetRW.write.allocStartKEX,f=this._protocol._packetRW.write.alloc(5+a.length,!0);f[c]=ut.KEXDH_INIT,$t(f,a.length,++c),f.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(f,!0))}}getPublicKey(){this.generateKeys();let a=this._public;if(a)return this.convertPublicKey(a)}convertPublicKey(a){let c,f=0,l=a.length;for(;a[f]===0;)++f,--l;return a[f]&128?(c=Buffer.allocUnsafe(1+l),c[0]=0,a.copy(c,1,f),c):(l!==a.length&&(c=Buffer.allocUnsafe(l),a.copy(c,0,f),a=c),a)}computeSecret(a){this.generateKeys();try{return n(this._dh.computeSecret(a))}catch(c){return c}}parse(a){let c=a[0];switch(this._step){case 1:if(this._protocol._server){if(c!==ut.KEXDH_INIT)return ze(this._protocol,`Received packet ${c} instead of ${ut.KEXDH_INIT}`,"handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),Ve.init(a,1);let f=Ve.readString();if(Ve.clear(),f===void 0)return ze(this._protocol,"Received malformed KEX*_INIT","handshake",Ge.KEY_EXCHANGE_FAILED);this._dhData=f;let l=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(l)&&(l=l[0]),this._hostKey=l,this.finish()}else{if(c!==ut.KEXDH_REPLY)return ze(this._protocol,`Received packet ${c} instead of ${ut.KEXDH_REPLY}`,"handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),Ve.init(a,1);let f,l,u;if((f=Ve.readString())===void 0||(l=Ve.readString())===void 0||(u=Ve.readString())===void 0)return Ve.clear(),ze(this._protocol,"Received malformed KEX*_REPLY","handshake",Ge.KEY_EXCHANGE_FAILED);Ve.clear(),Ve.init(f,0);let h=Ve.readString(!0);if(Ve.clear(),h===void 0)return ze(this._protocol,"Received malformed host public key","handshake",Ge.KEY_EXCHANGE_FAILED);if(h!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(h==="ssh-rsa")break;default:return ze(this._protocol,"Host key does not match negotiated type","handshake",Ge.KEY_EXCHANGE_FAILED)}this._hostKey=f,this._dhData=l,this._sig=u;let p=!1,y;if(this._protocol._hostVerifier===void 0?(y=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):y=this._protocol._hostVerifier(f,E=>{if(!p){if(p=!0,E===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),ze(this._protocol,"Host denied (verification failed)","handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():_s(this)}}),y===void 0){++this._step;return}if(p=!0,y===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),ze(this._protocol,"Host denied (verification failed)","handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,_s(this)}++this._step;break;case 2:return c!==ut.NEWKEYS?ze(this._protocol,`Received packet ${c} instead of ${ut.NEWKEYS}`,"handshake",Ge.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 ze(this._protocol,`Received unexpected packet ${c} after NEWKEYS`,"handshake",Ge.KEY_EXCHANGE_FAILED)}}}class e extends t{constructor(a,...c){super(...c),this.type="25519",this.hashName=a,this._keys=null}generateKeys(){this._keys||(this._keys=lg("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(a){let c,f=0,l=a.length;for(;a[f]===0;)++f,--l;return a.length===32||l!==a.length&&(c=Buffer.allocUnsafe(l),a.copy(c,0,f),a=c),a}computeSecret(a){this.generateKeys();try{let c=new If.Writer;return c.startSequence(),c.startSequence(),c.writeOID("1.3.101.110"),c.endSequence(),c.startSequence(If.BitString),c.writeByte(0),c._ensure(a.length),a.copy(c._buf,c._offset,0,a.length),c._offset+=a.length,c.endSequence(),c.endSequence(),n(fg({privateKey:this._keys.privateKey,publicKey:cg({key:c.buffer,type:"spki",format:"der"})}))}catch(c){return c}}}class r extends t{constructor(a,c,...f){super(...f),this.type="ecdh",this.curveName=a,this.hashName=c}generateKeys(){this._dh||(this._dh=ag(this.curveName),this._public=this._dh.generateKeys())}}class s extends t{constructor(a,...c){super(...c),this.type="groupex",this.hashName=a,this._prime=null,this._generator=null,this._minBits=yg,this._prefBits=wg(this.negotiated),this._protocol._compatFlags&ua.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=bg}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let a=this._protocol._packetRW.write.allocStartKEX,c=this._protocol._packetRW.write.alloc(13,!0);c[a]=ut.KEXDH_GEX_REQUEST,$t(c,this._minBits,++a),$t(c,this._prefBits,a+=4),$t(c,this._maxBits,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(c,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=sg(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(a,c){if(!Buffer.isBuffer(a))throw new Error("Invalid prime value");if(!Buffer.isBuffer(c))throw new Error("Invalid generator value");this._prime=a,this._generator=c}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}parse(a){let c=a[0];switch(this._step){case 1:{if(this._protocol._server)return c!==ut.KEXDH_GEX_REQUEST?ze(this._protocol,`Received packet ${c} instead of `+ut.KEXDH_GEX_REQUEST,"handshake",Ge.KEY_EXCHANGE_FAILED):ze(this._protocol,"Group exchange not implemented for server","handshake",Ge.KEY_EXCHANGE_FAILED);if(c!==ut.KEXDH_GEX_GROUP)return ze(this._protocol,`Received packet ${c} instead of ${ut.KEXDH_GEX_GROUP}`,"handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),Ve.init(a,1);let f,l;if((f=Ve.readString())===void 0||(l=Ve.readString())===void 0)return Ve.clear(),ze(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",Ge.KEY_EXCHANGE_FAILED);Ve.clear(),this.setDHParams(f,l),this.generateKeys();let u=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let h=this._protocol._packetRW.write.allocStartKEX,p=this._protocol._packetRW.write.alloc(5+u.length,!0);p[h]=ut.KEXDH_GEX_INIT,$t(p,u.length,++h),p.set(u,h+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(p,!0)),++this._step;break}case 2:if(this._protocol._server)return c!==ut.KEXDH_GEX_INIT?ze(this._protocol,`Received packet ${c} instead of ${ut.KEXDH_GEX_INIT}`,"handshake",Ge.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),ze(this._protocol,"Group exchange not implemented for server","handshake",Ge.KEY_EXCHANGE_FAILED));if(c!==ut.KEXDH_GEX_REPLY)return ze(this._protocol,`Received packet ${c} instead of ${ut.KEXDH_GEX_REPLY}`,"handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,a[0]=ut.KEXDH_REPLY,this.parse=t.prototype.parse,this.parse(a)}}}class i extends t{constructor(a,c,...f){super(...f),this.type="group",this.groupName=a,this.hashName=c}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");let a=this.getPublicKey(),c=this._protocol._packetRW.write.allocStartKEX,f=this._protocol._packetRW.write.alloc(5+a.length,!0);f[c]=ut.KEXDH_INIT,$t(f,a.length,++c),f.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(f,!0))}}generateKeys(){this._dh||(this._dh=og(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}}return(o,...a)=>{if(typeof o!="object"||o===null)throw new Error("Invalid negotiated argument");let c=o.kex;if(typeof c=="string"){switch(a=[o,...a],c){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!dg)break;return new e("sha256",...a);case"ecdh-sha2-nistp256":return new r("prime256v1","sha256",...a);case"ecdh-sha2-nistp384":return new r("secp384r1","sha384",...a);case"ecdh-sha2-nistp521":return new r("secp521r1","sha512",...a);case"diffie-hellman-group1-sha1":return new i("modp2","sha1",...a);case"diffie-hellman-group14-sha1":return new i("modp14","sha1",...a);case"diffie-hellman-group14-sha256":return new i("modp14","sha256",...a);case"diffie-hellman-group15-sha512":return new i("modp15","sha512",...a);case"diffie-hellman-group16-sha512":return new i("modp16","sha512",...a);case"diffie-hellman-group17-sha512":return new i("modp17","sha512",...a);case"diffie-hellman-group18-sha512":return new i("modp18","sha512",...a);case"diffie-hellman-group-exchange-sha1":return new s("sha1",...a);case"diffie-hellman-group-exchange-sha256":return new s("sha256",...a)}throw new Error(`Unsupported key exchange algorithm: ${c}`)}throw new Error(`Invalid key exchange type: ${c}`)}})(),fa=(()=>{let n=["kex","serverHostKey",["cs","cipher"],["sc","cipher"],["cs","mac"],["sc","mac"],["cs","compress"],["sc","compress"],["cs","lang"],["sc","lang"]];return class{constructor(e){if(typeof e!="object"||e===null)throw new TypeError("Argument must be an object");let r={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},all:void 0},s=0;for(let a of n){let c,f,l,u;if(typeof a=="string")c=r,f=e[a],l=u=a;else{let p=a[0];c=r[p],u=a[1],f=e[p][u],l=`${p}.${u}`}let h={array:void 0,buffer:void 0};if(Buffer.isBuffer(f))h.array=(""+f).split(","),h.buffer=f,s+=4+f.length;else{if(typeof f=="string"&&(f=f.split(",")),Array.isArray(f))h.array=f,h.buffer=Buffer.from(f.join(","));else throw new TypeError(`Invalid \`${l}\` type: ${typeof f}`);s+=4+h.buffer.length}c[u]=h}let i=Buffer.allocUnsafe(s);r.all=i;let o=0;for(let a of n){let c;typeof a=="string"?c=r[a].buffer:c=r[a[0]][a[1]].buffer,o=$t(i,c.length,o),i.set(c,o),o+=c.length}this.totalSize=s,this.lists=r}copyAllTo(e,r){let s=this.lists.all;if(typeof r!="number")throw new TypeError(`Invalid offset value: ${typeof r}`);if(e.length-r<s.length)throw new Error("Insufficient space to copy list");return e.set(s,r),s.length}}})(),yn=(()=>{let n=Buffer.allocUnsafe(4);return(t,e)=>{$t(n,e.length,0),t.update(n),t.update(e)}})();function Tr(n,t,e,r,s,i){let o;if(n){let a=la(t).update(e).update(r).update(i).update(s).digest();for(;a.length<n;){let c=la(t).update(e).update(r).update(a).digest(),f=Buffer.allocUnsafe(a.length+c.length);f.set(a,0),f.set(c,a.length),a=f}a.length===n?o=a:o=new Eg(a.buffer,a.byteOffset,n)}else o=xg;return o}function Tf(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 ut.IGNORE:case ut.UNIMPLEMENTED:case ut.DEBUG:return Pr||(Pr=ds()),Pr[e](this,t)}switch(e){case ut.DISCONNECT:return Pr||(Pr=ds()),Pr[e](this,t);case ut.KEXINIT:return n.firstPacket?(n.firstPacket=!1,Pf(this,t)):ze(this,"Received extra KEXINIT during handshake","handshake",Ge.KEY_EXCHANGE_FAILED);default:if(e<20||e>49)return ze(this,`Received unexpected packet type ${e}`,"handshake",Ge.KEY_EXCHANGE_FAILED)}return this._kex.parse(t)}function wg(n){let t=Lr[n.cs.cipher],e=Lr[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 _s(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]=ut.NEWKEYS,n._protocol._cipher.encrypt(n._protocol._packetRW.write.finalize(e,!0)),n._sentNEWKEYS=!0,n._protocol._strictMode&&(n._protocol._cipher.outSeqno=0)}}Lf.exports={KexInit:fa,kexinit:Nf,onKEXPayload:Tf,DEFAULT_KEXINIT_CLIENT:new fa({kex:Cf.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:kf,cs:{cipher:ps,mac:gs,compress:ms,lang:[]},sc:{cipher:ps,mac:gs,compress:ms,lang:[]}}),DEFAULT_KEXINIT_SERVER:new fa({kex:Cf.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:kf,cs:{cipher:ps,mac:gs,compress:ms,lang:[]},sc:{cipher:ps,mac:gs,compress:ms,lang:[]}}),HANDLERS:{[ut.KEXINIT]:Pf}}});var Uf=at((UE,Ig)=>{Ig.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 ga=at((DE,zf)=>{"use strict";var{inspect:Hf}=require("util"),{bindingAvailable:Cg,NullCipher:kg,NullDecipher:vg}=Qn(),{COMPAT_CHECKS:Bg,DISCONNECT_REASON:Qf,eddsaSupported:Rg,MESSAGE:Se,SIGNALS:Df,TERMINAL_MODE:ha}=Pn(),{DEFAULT_KEXINIT_CLIENT:Ng,DEFAULT_KEXINIT_SERVER:Pg,KexInit:$f,kexinit:Wf,onKEXPayload:Tg}=hs(),{parseKey:Of}=Kn(),Lg=ds(),{bufferCopy:ys,bufferFill:Ug,bufferSlice:qf,convertSignature:Mf,sendPacket:we,writeUInt32BE:P}=hn(),{PacketReader:Dg,PacketWriter:$g,ZlibPacketReader:Kf,ZlibPacketWriter:Vf}=oa(),Og=Uf().version,Mg=new Map(Object.values(Qf).map(n=>[n,1])),Gf=Buffer.from(`SSH-2.0-ssh2js${Og}`),Fg=Buffer.from(`${Gf}\r
7
- `),Hg=8192,Qg=1024,Ff=Buffer.from([Se.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]),Wg=Buffer.from([ha.TTY_OP_END]);function da(){}var pa=class{constructor(t){let e=t.onWrite;if(typeof e!="function")throw new Error("Missing onWrite function");this._onWrite=p=>{e(p)};let r=t.onError;if(typeof r!="function")throw new Error("Missing onError function");this._onError=p=>{r(p)};let s=t.debug;this._debug=typeof s=="function"?p=>{s(p)}:void 0;let i=t.onHeader;this._onHeader=typeof i=="function"?(...p)=>{i(...p)}:da;let o=t.onPacket;this._onPacket=typeof o=="function"?()=>{o()}:da;let a=t.onHandshakeComplete;typeof a!="function"&&(a=da);let c;this._onHandshakeComplete=(...p)=>{this._debug&&this._debug("Handshake completed"),c===void 0?c=!0:c=!1;let y=this._queue;if(y){this._queue=void 0,this._debug&&this._debug(`Draining outbound queue (${y.length}) ...`);for(let E=0;E<y.length;++E){let x=y[E],k=this._packetRW.write.finalize(x);if(k===x){let D=this._cipher.allocPacket(x.length);D.set(x,5),k=D}we(this,k)}this._debug&&this._debug("... finished draining outbound queue")}c&&this._server&&this._kex.remoteExtInfoEnabled&&jg(this),a(...p)},this._queue=void 0;let f=t.messageHandlers;typeof f=="object"&&f!==null?this._handlers=f:this._handlers={},this._onPayload=Gg.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
6
+ ${e}-----END ${n} KEY-----`}function di(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return e.set(n,0),e.set(t,n.length),e}function Yo(n,t){let e=n.length,r=n._pos||0;for(let s=0;s<t;++s){let i=e-r;if(r>=e||i<4)return!1;let o=fi(n,r);if(i<4+o)return!1;r+=4+o}return n._pos=r,!0}function hi(n,t){let e=new Be.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.113549.1.1.1"),e.writeNull(),e.endSequence(),e.startSequence(Be.BitString),e.writeByte(0),e.startSequence(),e.writeBuffer(n,Be.Integer),e.writeBuffer(t,Be.Integer),e.endSequence(),e.endSequence(),e.endSequence(),An("PUBLIC",e.buffer)}function pi(n,t){let e=Buffer.allocUnsafe(15+t.length+4+n.length);$t(e,7,0),e.utf8Write("ssh-rsa",4,7);let r=11;return $t(e,t.length,r),e.set(t,r+=4),$t(e,n.length,r+=t.length),e.set(n,r+4),e}var nf=(()=>{function n(r,s,i,o,a,c,f,l){let u=new Be.Writer;return u.startSequence(),u.writeInt(0,Be.Integer),u.writeBuffer(r,Be.Integer),u.writeBuffer(s,Be.Integer),u.writeBuffer(i,Be.Integer),u.writeBuffer(o,Be.Integer),u.writeBuffer(a,Be.Integer),u.writeBuffer(c,Be.Integer),u.writeBuffer(f,Be.Integer),u.writeBuffer(l,Be.Integer),u.endSequence(),u.buffer}function t(r){return BigInt(`0x${r.hexSlice(0,r.length)}`)}function e(r){let s=r.toString(16);if((s.length&1)!==0)s=`0${s}`;else{let i=s.charCodeAt(0);(i===56||i===57||i>=97&&i<=102)&&(s=`00${s}`)}return Buffer.from(s,"hex")}return function(s,i,o,a,c,f){let l=t(o),u=e(l%(t(c)-1n)),h=e(l%(t(f)-1n));return An("RSA PRIVATE",n(s,i,o,c,f,u,h,a))}})();function gi(n,t,e,r){let s=new Be.Writer;return s.startSequence(),s.startSequence(),s.writeOID("1.2.840.10040.4.1"),s.startSequence(),s.writeBuffer(n,Be.Integer),s.writeBuffer(t,Be.Integer),s.writeBuffer(e,Be.Integer),s.endSequence(),s.endSequence(),s.startSequence(Be.BitString),s.writeByte(0),s.writeBuffer(r,Be.Integer),s.endSequence(),s.endSequence(),An("PUBLIC",s.buffer)}function mi(n,t,e,r){let s=Buffer.allocUnsafe(15+n.length+4+t.length+4+e.length+4+r.length);$t(s,7,0),s.utf8Write("ssh-dss",4,7);let i=11;return $t(s,n.length,i),s.set(n,i+=4),$t(s,t.length,i+=n.length),s.set(t,i+=4),$t(s,e.length,i+=t.length),s.set(e,i+=4),$t(s,r.length,i+=e.length),s.set(r,i+4),s}function rf(n,t,e,r,s){let i=new Be.Writer;return i.startSequence(),i.writeInt(0,Be.Integer),i.writeBuffer(n,Be.Integer),i.writeBuffer(t,Be.Integer),i.writeBuffer(e,Be.Integer),i.writeBuffer(r,Be.Integer),i.writeBuffer(s,Be.Integer),i.endSequence(),An("DSA PRIVATE",i.buffer)}function sf(n){let t=new Be.Writer;return t.startSequence(),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Be.BitString),t.writeByte(0),t._ensure(n.length),t._buf.set(n,t._offset),t._offset+=n.length,t.endSequence(),t.endSequence(),An("PUBLIC",t.buffer)}function of(n){let t=Buffer.allocUnsafe(19+n.length);return $t(t,11,0),t.utf8Write("ssh-ed25519",4,11),$t(t,n.length,15),t.set(n,19),t}function Fp(n){let t=new Be.Writer;return t.startSequence(),t.writeInt(0,Be.Integer),t.startSequence(),t.writeOID("1.3.101.112"),t.endSequence(),t.startSequence(Be.OctetString),t.writeBuffer(n,Be.OctetString),t.endSequence(),t.endSequence(),An("PRIVATE",t.buffer)}function jo(n,t){let e=new Be.Writer;return e.startSequence(),e.startSequence(),e.writeOID("1.2.840.10045.2.1"),e.writeOID(n),e.endSequence(),e.startSequence(Be.BitString),e.writeByte(0),e._ensure(t.length),e._buf.set(t,e._offset),e._offset+=t.length,e.endSequence(),e.endSequence(),An("PUBLIC",e.buffer)}function Xo(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 $t(r,19,0),r.utf8Write(`ecdsa-sha2-${e}`,4,19),$t(r,8,23),r.utf8Write(e,27,8),$t(r,t.length,35),r.set(t,39),r}function Hp(n,t,e){let r=new Be.Writer;return r.startSequence(),r.writeInt(1,Be.Integer),r.writeBuffer(e,Be.OctetString),r.startSequence(160),r.writeOID(n),r.endSequence(),r.startSequence(161),r.startSequence(Be.BitString),r.writeByte(0),r._ensure(t.length),r._buf.set(t,r._offset),r._offset+=t.length,r.endSequence(),r.endSequence(),r.endSequence(),An("EC PRIVATE",r.buffer)}function Qp(n,t){let e=Np(n);return e.setPrivateKey(t),e.getPublicKey()}var Ai={sign:typeof ef=="function"?function(t,e){let r=this[mn];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[Ln]);try{return ef(e,t,r)}catch(s){return s}}:function(t,e){let r=this[mn];if(r===null)return new Error("No private key available");(!e||typeof e!="string")&&(e=this[Ln]);let s=Tp(e);s.update(t);try{return s.sign(r)}catch(i){return i}},verify:typeof tf=="function"?function(t,e,r){let s=this[xn];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[Ln]);try{return tf(r,t,s,e)}catch(i){return i}}:function(t,e,r){let s=this[xn];if(s===null)return new Error("No public key available");(!r||typeof r!="string")&&(r=this[Ln]);let i=Lp(r);i.update(t);try{return i.verify(s,e)}catch(o){return o}},isPrivateKey:function(){return this[mn]!==null},getPrivatePEM:function(){return this[mn]},getPublicPEM:function(){return this[xn]},getPublicSSH:function(){return this[Kn]},equals:function(t){let e=ff(t);return e instanceof Error?!1:this.type===e.type&&this[mn]===e[mn]&&this[xn]===e[xn]&&this[Kn].equals(e[Kn])}};function fs(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[mn]=e,this[xn]=r,this[Kn]=s,this[Ln]=i,this[Br]=o}fs.prototype=Ai;{let t=function(e,r,s){let i=[];if(e.length<8)return new Error("Malformed OpenSSH private key");let o=fi(e,0),a=fi(e,4);if(o!==a)return s?new Error("OpenSSH key integrity check failed -- bad passphrase?"):new Error("OpenSSH key integrity check failed");e._pos=8;let c,f;for(c=0;c<r;++c){let u,h,p,y,E=ve(e,e._pos,!0);if(E===void 0)return new Error("Malformed OpenSSH private key");switch(E){case"ssh-rsa":{let C=ve(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let N=ve(e,e._pos);if(N===void 0)return new Error("Malformed OpenSSH private key");let H=ve(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let v=ve(e,e._pos);if(v===void 0)return new Error("Malformed OpenSSH private key");let M=ve(e,e._pos);if(M===void 0)return new Error("Malformed OpenSSH private key");let Q=ve(e,e._pos);if(Q===void 0)return new Error("Malformed OpenSSH private key");p=hi(C,N),y=pi(C,N),h=nf(C,N,H,v,M,Q),u="sha1";break}case"ssh-dss":{let C=ve(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let N=ve(e,e._pos);if(N===void 0)return new Error("Malformed OpenSSH private key");let H=ve(e,e._pos);if(H===void 0)return new Error("Malformed OpenSSH private key");let v=ve(e,e._pos);if(v===void 0)return new Error("Malformed OpenSSH private key");let M=ve(e,e._pos);if(M===void 0)return new Error("Malformed OpenSSH private key");p=gi(C,N,H,v),y=mi(C,N,H,v),h=rf(C,N,H,v,M),u="sha1";break}case"ssh-ed25519":{if(!zo)return new Error(`Unsupported OpenSSH private key type: ${E}`);let C=ve(e,e._pos);if(C===void 0||C.length!==32)return new Error("Malformed OpenSSH private key");let N=ve(e,e._pos);if(N===void 0||N.length!==64)return new Error("Malformed OpenSSH private key");p=sf(C),y=of(C),h=Fp(fr(N,0,32)),u=null;break}case"ecdsa-sha2-nistp256":u="sha256",f="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":u===void 0&&(u="sha384",f="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(u===void 0&&(u="sha512",f="1.3.132.0.35"),!Yo(e,1))return new Error("Malformed OpenSSH private key");let C=ve(e,e._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");let N=ve(e,e._pos);if(N===void 0)return new Error("Malformed OpenSSH private key");p=jo(f,C),y=Xo(f,C),h=Hp(f,C,N);break}default:return new Error(`Unsupported OpenSSH private key type: ${E}`)}let b=ve(e,e._pos,!0);if(b===void 0)return new Error("Malformed OpenSSH private key");i.push(new fs(E,b,h,p,y,u,s))}let l=0;for(c=e._pos;c<e.length;++c)if(e[c]!==++l%255)return new Error("Malformed OpenSSH private key");return i},n=/^-----BEGIN OPENSSH PRIVATE KEY-----(?:\r\n|\n)([\s\S]+)(?:\r\n|\n)-----END OPENSSH PRIVATE KEY-----$/;fs.parse=(e,r)=>{let s=n.exec(e);if(s===null)return null;let i,o=Buffer.from(s[1],"base64");if(o.length<31)return new Error("Malformed OpenSSH private key");let a=o.utf8Slice(0,15);if(a!=="openssh-key-v1\0")return new Error(`Unsupported OpenSSH key magic: ${a}`);let c=ve(o,15,!0);if(c===void 0)return new Error("Malformed OpenSSH private key");if(c!=="none"&&Op.indexOf(c)===-1)return new Error(`Unsupported cipher for OpenSSH key: ${c}`);let f=ve(o,o._pos,!0);if(f===void 0)return new Error("Malformed OpenSSH private key");if(f!=="none"){if(c==="none")return new Error("Malformed OpenSSH private key");if(f!=="bcrypt")return new Error(`Unsupported kdf name for OpenSSH key: ${f}`);if(!r)return new Error("Encrypted private OpenSSH key detected, but no passphrase given")}else if(c!=="none")return new Error("Malformed OpenSSH private key");let l,u,h;c!=="none"&&(l=ui[c]);let p=ve(o,o._pos);if(p===void 0)return new Error("Malformed OpenSSH private key");if(p.length)switch(f){case"none":return new Error("Malformed OpenSSH private key");case"bcrypt":{let E=ve(p,0);if(E===void 0||p._pos+4>p.length)return new Error("Malformed OpenSSH private key");let b=fi(p,p._pos),C=Buffer.allocUnsafe(l.keyLen+l.ivLen);if($p(r,r.length,E,E.length,C,C.length,b)!==0)return new Error("Failed to generate information to decrypt key");u=fr(C,0,l.keyLen),h=fr(C,l.keyLen,C.length);break}}else if(f!=="none")return new Error("Malformed OpenSSH private key");if(o._pos+3>=o.length)return new Error("Malformed OpenSSH private key");let y=fi(o,o._pos);if(o._pos+=4,y>0){for(let b=0;b<y;++b){let C=ve(o,o._pos);if(C===void 0)return new Error("Malformed OpenSSH private key");if(ve(C,0,!0)===void 0)return new Error("Malformed OpenSSH private key")}let E=ve(o,o._pos);if(E===void 0)return new Error("Malformed OpenSSH private key");if(u!==void 0){if(E.length<l.blockLen||E.length%l.blockLen!==0)return new Error("Malformed OpenSSH private key");try{let b={authTagLength:l.authLen},C=Go(l.sslName,u,h,b);if(C.setAutoPadding(!1),l.authLen>0){if(o.length-o._pos<l.authLen)return new Error("Malformed OpenSSH private key");C.setAuthTag(fr(o,o._pos,o._pos+=l.authLen))}E=di(C.update(E),C.final())}catch(b){return b}}if(o._pos!==o.length)return new Error("Malformed OpenSSH private key");i=t(E,y,u!==void 0)}else i=[];return i instanceof Error?i:i[0]}}function ls(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[mn]=e,this[xn]=r,this[Kn]=s,this[Ln]=i,this[Br]=o}ls.prototype=Ai;{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-----$/;ls.parse=(t,e)=>{let r=n.exec(t);if(r===null)return null;let s=Buffer.from(r[3],"base64"),i=r[2],o=!1;if(i!==void 0){i=i.split(/\r\n|\n/g);for(let y=0;y<i.length;++y){let E=i[y],b=E.indexOf(":");if(E.slice(0,b)==="DEK-Info"){let C=E.slice(b+2);if(b=C.indexOf(","),b===-1)continue;let N=C.slice(0,b).toLowerCase();if(Dp.indexOf(N)===-1)return new Error(`Cipher (${N}) not supported for encrypted OpenSSH private key`);let H=Vo[N];if(!H)return new Error(`Cipher (${N}) not supported for encrypted OpenSSH private key`);let v=Buffer.from(C.slice(b+1),"hex");if(v.length!==H.ivLen)return new Error("Malformed encrypted OpenSSH private key");if(!e)return new Error("Encrypted OpenSSH private key detected, but no passphrase given");let M=fr(v,0,8),Q=li("md5").update(e).update(M).digest();for(;Q.length<H.keyLen;)Q=di(Q,li("md5").update(Q).update(e).update(M).digest());Q.length>H.keyLen&&(Q=fr(Q,0,H.keyLen));try{let P=Go(N,Q,v);P.setAutoPadding(!1),s=di(P.update(s),P.final()),o=!0}catch(P){return P}}}}let a,c,f,l,u,h,p="Malformed OpenSSH private key";switch(o&&(p+=". Bad passphrase?"),r[1]){case"RSA":a="ssh-rsa",c=An("RSA PRIVATE",s);try{h=new Be.Reader(s),h.readSequence(),h.readInt();let y=h.readString(Be.Integer,!0);if(y===null)return new Error(p);let E=h.readString(Be.Integer,!0);if(E===null)return new Error(p);f=hi(y,E),l=pi(y,E)}catch{return new Error(p)}u="sha1";break;case"DSA":a="ssh-dss",c=An("DSA PRIVATE",s);try{h=new Be.Reader(s),h.readSequence(),h.readInt();let y=h.readString(Be.Integer,!0);if(y===null)return new Error(p);let E=h.readString(Be.Integer,!0);if(E===null)return new Error(p);let b=h.readString(Be.Integer,!0);if(b===null)return new Error(p);let C=h.readString(Be.Integer,!0);if(C===null)return new Error(p);f=gi(y,E,b,C),l=mi(y,E,b,C)}catch{return new Error(p)}u="sha1";break;case"EC":{let y,E,b;try{h=new Be.Reader(s),h.readSequence(),h.readInt(),E=h.readString(Be.OctetString,!0),h.readByte();let N=h.readLength();if(N!==null){if(h._offset=N,b=h.readOID(),b===null)return new Error(p);switch(b){case"1.2.840.10045.3.1.7":y="prime256v1",a="ecdsa-sha2-nistp256",u="sha256";break;case"1.3.132.0.34":y="secp384r1",a="ecdsa-sha2-nistp384",u="sha384";break;case"1.3.132.0.35":y="secp521r1",a="ecdsa-sha2-nistp521",u="sha512";break;default:return new Error(`Unsupported private key EC OID: ${b}`)}}else return new Error(p)}catch{return new Error(p)}c=An("EC PRIVATE",s);let C=Qp(y,E);f=jo(b,C),l=Xo(b,C);break}}return new ls(a,"",c,f,l,u,o)}}function us(n,t,e,r,s,i,o){this.type=n,this.comment=t,this[mn]=e,this[xn]=r,this[Kn]=s,this[Ln]=i,this[Br]=o}us.prototype=Ai;{let n=Buffer.alloc(0),t=Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e=Buffer.from([0,0,0,0]),r=Buffer.from([0,0,0,1]),s=/^PuTTY-User-Key-File-2: (ssh-(?:rsa|dss))\r?\nEncryption: (aes256-cbc|none)\r?\nComment: ([^\r\n]*)\r?\nPublic-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-Lines: \d+\r?\n([\s\S]+?)\r?\nPrivate-MAC: ([^\r\n]+)/;us.parse=(i,o)=>{let a=s.exec(i);if(a===null)return null;let c=a[2],f=c!=="none";if(f&&!o)return new Error("Encrypted PPK private key detected, but no passphrase given");let l=Buffer.from(a[5],"base64");if(f){let I=ui[c],k=di(li("sha1").update(e).update(o).digest(),li("sha1").update(r).update(o).digest());k.length>I.keyLen&&(k=fr(k,0,I.keyLen));try{let R=Go(I.sslName,k,t);R.setAutoPadding(!1),l=di(R.update(l),R.final())}catch(R){return R}}let u=a[1],h=a[3],p=Buffer.from(a[4],"base64"),y=a[6],E=u.length,b=c.length,C=Buffer.byteLength(h),N=p.length,H=l.length,v=Buffer.allocUnsafe(4+E+4+b+4+C+4+N+4+H),M=0;if($t(v,E,M),v.utf8Write(u,M+=4,E),$t(v,b,M+=E),v.utf8Write(c,M+=4,b),$t(v,C,M+=b),v.utf8Write(h,M+=4,C),$t(v,N,M+=C),v.set(p,M+=4),$t(v,H,M+=N),v.set(l,M+4),o||(o=n),Pp("sha1",li("sha1").update("putty-private-key-file-mac-key").update(o).digest()).update(v).digest("hex")!==y)return f?new Error("PPK private key integrity check failed -- bad passphrase?"):new Error("PPK private key integrity check failed");let P,x,w;switch(p._pos=0,Yo(p,1),u){case"ssh-rsa":{let I=ve(p,p._pos);if(I===void 0)return new Error("Malformed PPK public key");let k=ve(p,p._pos);if(k===void 0)return new Error("Malformed PPK public key");let R=ve(l,0);if(R===void 0)return new Error("Malformed PPK private key");let ne=ve(l,l._pos);if(ne===void 0)return new Error("Malformed PPK private key");let z=ve(l,l._pos);if(z===void 0)return new Error("Malformed PPK private key");let Y=ve(l,l._pos);if(Y===void 0)return new Error("Malformed PPK private key");P=hi(k,I),x=pi(k,I),w=nf(k,I,R,Y,ne,z);break}case"ssh-dss":{let I=ve(p,p._pos);if(I===void 0)return new Error("Malformed PPK public key");let k=ve(p,p._pos);if(k===void 0)return new Error("Malformed PPK public key");let R=ve(p,p._pos);if(R===void 0)return new Error("Malformed PPK public key");let ne=ve(p,p._pos);if(ne===void 0)return new Error("Malformed PPK public key");let z=ve(l,0);if(z===void 0)return new Error("Malformed PPK private key");P=gi(I,k,R,ne),x=mi(I,k,R,ne),w=rf(I,k,R,ne,z);break}}return new us(u,h,w,P,x,"sha1",f)}}function hs(n,t,e,r,s){this.type=n,this.comment=t,this[mn]=null,this[xn]=e,this[Kn]=r,this[Ln]=s,this[Br]=!1}hs.prototype=Ai;{let n;zo?n=/^(((?:ssh-(?:rsa|dss|ed25519))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/:n=/^(((?:ssh-(?:rsa|dss))|ecdsa-sha2-nistp(?:256|384|521))(?:-cert-v0[01]@openssh.com)?) ([A-Z0-9a-z/+=]+)(?:$|\s+([\S].*)?)$/,hs.parse=t=>{let e=n.exec(t);if(e===null)return null;let r=e[1],s=e[2],i=Buffer.from(e[3],"base64"),o=e[4]||"",a=ve(i,i._pos,!0);return a===void 0||a.indexOf(s)!==0?new Error("Malformed OpenSSH public key"):Jo(i,s,o,r)}}function ds(n,t,e,r,s){this.type=n,this.comment=t,this[mn]=null,this[xn]=e,this[Kn]=r,this[Ln]=s,this[Br]=!1}ds.prototype=Ai;{let n=/^---- BEGIN SSH2 PUBLIC KEY ----(?:\r?\n)((?:.{0,72}\r?\n)+)---- END SSH2 PUBLIC KEY ----$/,t=/^[A-Z0-9a-z/+=\r\n]+$/,e=/^([\x21-\x39\x3B-\x7E]{1,64}): ((?:[^\\]*\\\r?\n)*[^\r\n]+)\r?\n/gm,r=/\\\r?\n/g;ds.parse=s=>{let i=n.exec(s);if(i===null)return null;let o=i[1],a=0,c="";for(;i=e.exec(o);){let p=i[1],y=i[2].replace(r,"");if(y.length>1024)return e.lastIndex=0,new Error("Malformed RFC4716 public key");a=e.lastIndex,p.toLowerCase()==="comment"&&(c=y,c.length>1&&c.charCodeAt(0)===34&&c.charCodeAt(c.length-1)===34&&(c=c.slice(1,-1)))}let f=o.slice(a);if(!t.test(f))return new Error("Malformed RFC4716 public key");f=Buffer.from(f,"base64");let l=ve(f,0,!0);if(l===void 0)return new Error("Malformed RFC4716 public key");let u=null,h=null;switch(l){case"ssh-rsa":{let p=ve(f,f._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let y=ve(f,f._pos);if(y===void 0)return new Error("Malformed RFC4716 public key");u=hi(y,p),h=pi(y,p);break}case"ssh-dss":{let p=ve(f,f._pos);if(p===void 0)return new Error("Malformed RFC4716 public key");let y=ve(f,f._pos);if(y===void 0)return new Error("Malformed RFC4716 public key");let E=ve(f,f._pos);if(E===void 0)return new Error("Malformed RFC4716 public key");let b=ve(f,f._pos);if(b===void 0)return new Error("Malformed RFC4716 public key");u=gi(p,y,E,b),h=mi(p,y,E,b);break}default:return new Error("Malformed RFC4716 public key")}return new ds(l,c,u,h,"sha1")}}function Jo(n,t,e,r){if(!af(t))return new Error(`Unsupported OpenSSH public key type: ${t}`);let s,i,o=null,a=null;switch(t){case"ssh-rsa":{let c=ve(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let f=ve(n,n._pos);if(f===void 0)return new Error("Malformed OpenSSH public key");o=hi(f,c),a=pi(f,c),s="sha1";break}case"ssh-dss":{let c=ve(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");let f=ve(n,n._pos);if(f===void 0)return new Error("Malformed OpenSSH public key");let l=ve(n,n._pos);if(l===void 0)return new Error("Malformed OpenSSH public key");let u=ve(n,n._pos);if(u===void 0)return new Error("Malformed OpenSSH public key");o=gi(c,f,l,u),a=mi(c,f,l,u),s="sha1";break}case"ssh-ed25519":{let c=ve(n,n._pos||0);if(c===void 0||c.length!==32)return new Error("Malformed OpenSSH public key");o=sf(c),a=of(c),s=null;break}case"ecdsa-sha2-nistp256":s="sha256",i="1.2.840.10045.3.1.7";case"ecdsa-sha2-nistp384":s===void 0&&(s="sha384",i="1.3.132.0.34");case"ecdsa-sha2-nistp521":{if(s===void 0&&(s="sha512",i="1.3.132.0.35"),!Yo(n,1))return new Error("Malformed OpenSSH public key");let c=ve(n,n._pos||0);if(c===void 0)return new Error("Malformed OpenSSH public key");o=jo(i,c),a=Xo(i,c);break}default:return new Error(`Unsupported OpenSSH public key type: ${t}`)}return new hs(r,e,o,a,s)}function af(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(zo)return!0;default:return!1}}function cf(n){return n?typeof n[Br]=="boolean":!1}function ff(n,t){if(cf(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=fs.parse(n,t))!==null||(r=ls.parse(n,t))!==null||(r=us.parse(n,t))!==null||(r=hs.parse(n))!==null||(r=ds.parse(n))!==null)return r;if(e){cs.init(e,0);let s=cs.readString(!0);s!==void 0&&(n=cs.readRaw(),n!==void 0&&(r=Jo(n,s,"",s),r instanceof Error&&(r=null))),cs.clear()}return r||new Error("Unsupported key format")}lf.exports={isParsedKey:cf,isSupportedKeyType:af,parseDERKey:(n,t)=>Jo(n,t,"",t),parseKey:ff}});var ia=ct((DE,_f)=>{"use strict";var{Socket:pf}=require("net"),{Duplex:gf}=require("stream"),{resolve:Wp}=require("path"),{readFile:uf}=require("fs"),{execFile:qp,spawn:Kp}=require("child_process"),{isParsedKey:df,parseKey:Ei}=Vn(),{makeBufferParser:Vp,readUInt32BE:ra,writeUInt32BE:Jt,writeUInt32LE:hf}=gn();function yi(n){let t=!1;return(...e)=>{t||(t=!0,n(...e))}}function Gp(n,t){let e=Buffer.allocUnsafe(n.length+t.length);return n.copy(e,0),t.copy(e,n.length),e}function ea(){}var zp=Buffer.alloc(0),bt=Vp(),_i=class{getIdentities(t){t(new Error("Missing getIdentities() implementation"))}sign(t,e,r,s){typeof r=="function"&&(s=r),s(new Error("Missing sign() implementation"))}},Nr=class extends _i{constructor(t){super(),this.socketPath=t}getStream(t){t=yi(t);let e=new pf;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=yi(t),this.getStream((e,r)=>{function s(o){if(r)try{r.destroy()}catch{}o||(o=new Error("Failed to retrieve identities from agent")),t(o)}if(e)return s(e);let i=new ta(!0);i.on("error",s),i.pipe(r).pipe(i),r.on("close",s).on("end",s).on("error",s),i.getIdentities((o,a)=>{if(o)return s(o);try{r.destroy()}catch{}t(null,a)})})}sign(t,e,r,s){typeof r=="function"?(s=r,r=void 0):(typeof r!="object"||r===null)&&(r=void 0),s=yi(s),this.getStream((i,o)=>{function a(f){if(o)try{o.destroy()}catch{}f||(f=new Error("Failed to sign data with agent")),s(f)}if(i)return a(i);let c=new ta(!0);c.on("error",a),c.pipe(o).pipe(c),o.on("close",a).on("end",a).on("error",a),c.sign(t,e,r,(f,l)=>{if(f)return a(f);try{o.destroy()}catch{}s(null,l)})})}},mf=(()=>{let o=Wp(__dirname,"..","util/pagent.exe"),a={10:new Error("Invalid pagent.exe arguments"),11:new Error("Pageant is not running"),12:new Error("pagent.exe could not create an mmap"),13:new Error("pagent.exe could not set mode for stdin"),14:new Error("pagent.exe could not set mode for stdout"),15:new Error("pagent.exe did not get expected input payload")};function c(l){l.buffer=null,l.proc&&(l.proc.kill(),l.proc=void 0)}class f extends gf{constructor(){super(),this.proc=void 0,this.buffer=null}_read(u){}_write(u,h,p){if(this.buffer===null)this.buffer=u;else{let C=Buffer.allocUnsafe(this.buffer.length+u.length);this.buffer.copy(C,0),u.copy(C,this.buffer.length),this.buffer=C}if(this.buffer.length<4)return p();let y=ra(this.buffer,0);if(this.buffer.length-4<y)return p();if(u=this.buffer.slice(0,4+y),this.buffer.length>4+y)return p(new Error("Unexpected multiple agent requests"));this.buffer=null;let E,b=this.proc=Kp(o,[u.length]);b.stdout.on("data",C=>{this.push(C)}),b.on("error",C=>{E=C,p(E)}),b.on("close",C=>{if(this.proc=void 0,!E){if(E=a[C])return p(E);p()}}),b.stdin.end(u)}_final(u){c(this),u()}_destroy(u,h){c(this),h()}}return class extends Nr{getStream(u){u(null,new f)}}})(),Af=(()=>{let n=/^!<socket >(\d+) s ([A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8}-[A-Z0-9]{8})/;return class extends Nr{getStream(e){e=yi(e);let r=this.socketPath,s=!1;uf(r,function i(o,a){if(o){if(s)return e(new Error("Invalid cygwin unix socket path"));qp("cygpath",["-w",r],(Q,P,x)=>{if(Q||P.length===0)return e(new Error("Invalid cygwin unix socket path"));s=!0,r=P.toString().replace(/[\r\n]/g,""),uf(r,i)});return}let c=n.exec(a.toString("ascii"));if(!c)return e(new Error("Malformed cygwin unix socket file"));let f,l=0,u=!1,h=[],p,y=Buffer.alloc(12),E=parseInt(c[1],10),b=c[2].replace(/-/g,""),C=Buffer.allocUnsafe(16);for(let Q=0,P=0;P<32;++Q,P+=2)C[Q]=parseInt(b.substring(P,P+2),16);for(let Q=0;Q<16;Q+=4)hf(C,ra(C,Q),Q);M();function N(){l=0,f="secret",p.write(C)}function H(Q){if(l+=Q.length,f==="secret"){l===16&&(l=0,f="creds",p.write(y));return}if(f==="creds"&&(u||h.push(Q),l===12)){if(p.removeListener("connect",N),p.removeListener("data",H),p.removeListener("error",v),p.removeListener("end",v),p.removeListener("close",v),u)return e(null,p);u=!0,y=Buffer.concat(h),hf(y,process.pid,0),p.on("error",()=>{}),p.destroy(),M()}}function v(){e(new Error("Problem negotiating cygwin unix socket security"))}function M(){p=new pf,p.on("connect",N),p.on("data",H),p.on("error",v),p.on("end",v),p.on("close",v),p.connect(E)}})}}})(),Yp=/^[/\\][/\\]\.[/\\]pipe[/\\].+/;function Ef(n){return process.platform==="win32"&&!Yp.test(n)?n==="pageant"?new mf:new Af(n):new Nr(n)}var ta=(()=>{function f(x){let w;for(;x[N].length;){let I=x[N][0][u];if(I===void 0)break;x[N].shift(),w=x.push(I)}return w}let l=Symbol("Inbound Request Type"),u=Symbol("Inbound Request Response"),h=Symbol("Inbound Request Context");class p{constructor(w,I){this[l]=w,this[u]=void 0,this[h]=I}hasResponded(){return this[u]!==void 0}getType(){return this[l]}getContext(){return this[h]}}function y(x,w,I){return w[u]=I,f(x)}function E(x){if(x[v]=null,x[H]===0){let w=x[N];if(w&&w.length){x[N]=[];for(let I of w)I.cb(new Error("No reply from server"))}}try{x.end()}catch{}setImmediate(()=>{x[P]||x.emit("end"),x[Q]||x.emit("close")})}function b(){this[Q]=!0}function C(){this[P]=!0}let N=Symbol("Requests"),H=Symbol("Agent Protocol Role"),v=Symbol("Agent Protocol Buffer"),M=Symbol("Agent Protocol Current Message Length"),Q=Symbol("Agent Protocol Closed"),P=Symbol("Agent Protocol Ended");return class extends gf{constructor(w){super({autoDestroy:!0,emitClose:!1}),this[H]=w?0:1,this[N]=[],this[v]=null,this[M]=-1,this.once("end",C),this.once("close",b)}_read(w){}_write(w,I,k){this[v]===null?this[v]=w:this[v]=Gp(this[v],w);let R=this[v],ne=R.length,z=0;for(;z<ne&&!(ne<5||(this[M]===-1&&(this[M]=ra(R,z)),ne<4+this[M]));){let Y=R[z+=4];if(++z,this[H]===0){if(this[N].length===0)return k(new Error("Received unexpected message from server"));let te=this[N].shift();switch(Y){case 5:te.cb(new Error("Agent responded with failure"));break;case 12:{if(te.type!==11)return k(new Error("Agent responded with wrong message type"));bt.init(R,z);let ce=bt.readUInt32BE();if(ce===void 0)return bt.clear(),k(new Error("Malformed agent response"));let $=[];for(let B=0;B<ce;++B){let L=bt.readString();if(L===void 0)return bt.clear(),k(new Error("Malformed agent response"));let K=bt.readString(!0);if(K===void 0)return bt.clear(),k(new Error("Malformed agent response"));L=Ei(L),!(L instanceof Error)&&(L.comment=L.comment||K,$.push(L))}z=bt.pos(),bt.clear(),te.cb(null,$);break}case 14:{if(te.type!==13)return k(new Error("Agent responded with wrong message type"));bt.init(R,z);let ce=bt.readString();if(z=bt.pos(),bt.clear(),ce===void 0)return k(new Error("Malformed agent response"));if(bt.init(ce,0),bt.readString(!0),ce=bt.readString(),bt.clear(),ce===void 0)return k(new Error("Malformed OpenSSH signature format"));te.cb(null,ce);break}default:return k(new Error("Agent responded with unsupported message type"))}}else switch(Y){case 11:{let te=new p(Y);this[N].push(te),this.emit("identities",te);break}case 13:{bt.init(R,z);let te=bt.readString(),ce=bt.readString(),$=bt.readUInt32BE();if(z=bt.pos(),bt.clear(),$===void 0){let ee=new p(Y);return this[N].push(ee),this.failureReply(ee)}if(te=Ei(te),te instanceof Error){let ee=new p(Y);return this[N].push(ee),this.failureReply(ee)}let B={hash:void 0},L;te.type==="ssh-rsa"&&($&2?(L="rsa-sha2-256",B.hash="sha256"):$&4&&(L="rsa-sha2-512",B.hash="sha512")),L===void 0&&(L=te.type);let K=new p(Y,L);this[N].push(K),this.emit("sign",K,te,ce,B);break}default:{let te=new p(Y);this[N].push(te),this.failureReply(te)}}if(this[M]=-1,z===ne){this[v]=null;break}else this[v]=R=R.slice(z),ne=R.length,z=0}k()}_destroy(w,I){E(this),I()}_final(w){E(this),w()}sign(w,I,k,R){if(this[H]!==0)throw new Error("Client-only method called with server role");typeof k=="function"?(R=k,k=void 0):(typeof k!="object"||k===null)&&(k=void 0);let ne=0;if(w=Ei(w),w instanceof Error)throw new Error("Invalid public key argument");if(w.type==="ssh-rsa"&&k)switch(k.hash){case"sha256":ne=2;break;case"sha512":ne=4;break}w=w.getPublicSSH();let z=13,Y=w.length,te=I.length,ce=0,$=Buffer.allocUnsafe(9+Y+4+te+4);return Jt($,$.length-4,ce),$[ce+=4]=z,Jt($,Y,++ce),w.copy($,ce+=4),Jt($,te,ce+=Y),I.copy($,ce+=4),Jt($,ne,ce+=te),typeof R!="function"&&(R=ea),this[N].push({type:z,cb:R}),this.push($)}getIdentities(w){if(this[H]!==0)throw new Error("Client-only method called with server role");let I=11,k=0,R=Buffer.allocUnsafe(5);return Jt(R,R.length-4,k),R[k+=4]=I,typeof w!="function"&&(w=ea),this[N].push({type:I,cb:w}),this.push(R)}failureReply(w){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;let I=0,k=Buffer.allocUnsafe(5);return Jt(k,k.length-4,I),k[I+=4]=5,y(this,w,k)}getIdentitiesReply(w,I){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;if(w.getType()!==11)throw new Error("Invalid response to request");if(!Array.isArray(I))throw new Error("Keys argument must be an array");let k=4,R=[];for(let Y=0;Y<I.length;++Y){let te=I[Y];if(typeof te!="object"||te===null)throw new Error(`Invalid key entry: ${te}`);let ce,$;if(df(te))ce=te;else if(df(te.pubKey))ce=te.pubKey;else if(typeof te.pubKey!="object"||te.pubKey===null||({pubKey:ce,comment:$}=te.pubKey,ce=Ei(ce),ce instanceof Error))continue;$=ce.comment||$,ce=ce.getPublicSSH(),k+=4+ce.length,$&&typeof $=="string"?$=Buffer.from($):Buffer.isBuffer($)||($=zp),k+=4+$.length,R.push({pubKey:ce,comment:$})}let ne=0,z=Buffer.allocUnsafe(5+k);Jt(z,z.length-4,ne),z[ne+=4]=12,Jt(z,R.length,++ne),ne+=4;for(let Y=0;Y<R.length;++Y){let{pubKey:te,comment:ce}=R[Y];Jt(z,te.length,ne),te.copy(z,ne+=4),Jt(z,ce.length,ne+=te.length),ne+=4,ce.length&&(ce.copy(z,ne),ne+=ce.length)}return y(this,w,z)}signReply(w,I){if(this[H]!==1)throw new Error("Server-only method called with client role");if(!(w instanceof p))throw new Error("Wrong request argument");if(w.hasResponded())return!0;if(w.getType()!==13)throw new Error("Invalid response to request");if(!Buffer.isBuffer(I))throw new Error("Signature argument must be a Buffer");if(I.length===0)throw new Error("Signature argument must be non-empty");let k=0,R=w.getContext(),ne=Buffer.byteLength(R),z=Buffer.allocUnsafe(13+ne+4+I.length);return Jt(z,z.length-4,k),z[k+=4]=14,Jt(z,4+ne+4+I.length,++k),Jt(z,ne,k+=4),z.utf8Write(R,k+=4,ne),Jt(z,I.length,k+=ne),I.copy(z,k+=4),y(this,w,z)}}})(),Zo=Symbol("Agent"),En=Symbol("Agent Keys"),Un=Symbol("Agent Keys Index"),Rr=Symbol("Agent Init Callbacks"),na=class{constructor(t){if(typeof t=="string")t=Ef(t);else if(!yf(t))throw new Error("Invalid agent argument");this[Zo]=t,this[En]=null,this[Un]=-1,this[Rr]=null}init(t){if(typeof t!="function"&&(t=ea),this[En]===null)if(this[Rr]===null){this[Rr]=[t];let e=(...r)=>{process.nextTick(()=>{let s=this[Rr];this[Rr]=null;for(let i of s)i(...r)})};this[Zo].getIdentities(yi((r,s)=>{if(r)return e(r);if(!Array.isArray(s))return e(new Error("Agent implementation failed to provide keys"));let i=[];for(let o of s)o=Ei(o),!(o instanceof Error)&&i.push(o);this[En]=i,this[Un]=-1,e()}))}else this[Rr].push(t);else process.nextTick(t)}nextKey(){return this[En]===null||++this[Un]>=this[En].length?!1:this[En][this[Un]]}currentKey(){return this[En]===null||this[Un]>=this[En].length?null:this[En][this[Un]]}pos(){return this[En]===null||this[Un]>=this[En].length?-1:this[Un]}reset(){this[Un]=-1}sign(...t){this[Zo].sign(...t)}};function yf(n){return n instanceof _i}_f.exports={AgentContext:na,AgentProtocol:ta,BaseAgent:_i,createAgent:Ef,CygwinAgent:Af,isAgent:yf,OpenSSHAgent:Nr,PageantAgent:mf}});var la=ct(($E,bf)=>{"use strict";var{kMaxLength:jp}=require("buffer"),{createInflate:Xp,constants:{DEFLATE:Jp,INFLATE:Zp,Z_DEFAULT_CHUNK:eg,Z_DEFAULT_COMPRESSION:tg,Z_DEFAULT_MEMLEVEL:ng,Z_DEFAULT_STRATEGY:rg,Z_DEFAULT_WINDOWBITS:ig,Z_PARTIAL_FLUSH:sg}}=require("zlib"),og=Xp()._handle.constructor;function ag(){throw new Error("Should not get here")}function cg(n,t,e){let r=this._owner,s=new Error(n);s.errno=t,s.code=e,r._err=s}function fa(n){n._handle&&(n._handle.close(),n._handle=null)}var ps=class{constructor(t){let e=ig,r=tg,s=ng,i=rg,o=void 0;this._err=void 0,this._writeState=new Uint32Array(2),this._chunkSize=eg,this._maxOutputLength=jp,this._outBuffer=Buffer.allocUnsafe(this._chunkSize),this._outOffset=0,this._handle=new og(t),this._handle._owner=this,this._handle.onerror=cg,this._handle.init(e,r,s,i,this._writeState,ag,o)}writeSync(t,e){let r=this._handle;if(!r)throw new Error("Invalid Zlib instance");let s=t.length,i=this._chunkSize-this._outOffset,o=0,a,c,f,l=0,u=this._writeState,h=this._outBuffer,p=this._outOffset,y=this._chunkSize;for(;;){if(r.writeSync(sg,t,o,s,h,p,i),this._err)throw this._err;a=u[0],c=u[1];let b=s-c,C=i-a;if(C>0){let N=p===0&&C===h.length?h:h.slice(p,p+C);if(p+=C,f?f.push===void 0?f=[f,N]:f.push(N):f=N,l+=N.byteLength,l>this._maxOutputLength)throw fa(this),new Error(`Output length exceeded maximum of ${this._maxOutputLength}`)}else if(C!==0)throw new Error("have should not go down");if((a===0||p>=y)&&(i=y,p=0,h=Buffer.allocUnsafe(y)),a===0)o+=b,s=c;else break}if(this._outBuffer=h,this._outOffset=p,l===0&&(f=Buffer.alloc(0)),e)return f.totalLen=l,f;if(f.push===void 0)return f;let E=Buffer.allocUnsafe(l);for(let b=0,C=0;b<f.length;++b){let N=f[b];E.set(N,C),C+=N.length}return E}},sa=class{constructor(t){this.allocStart=0,this.allocStartKEX=0,this._protocol=t,this._zlib=new ps(Jp)}cleanup(){this._zlib&&fa(this._zlib)}alloc(t,e){return Buffer.allocUnsafe(t)}finalize(t,e){if(this._protocol._kexinit===void 0||e){let r=this._zlib.writeSync(t,!0),s=this._protocol._cipher.allocPacket(r.totalLen);if(r.push===void 0)s.set(r,5);else for(let i=0,o=5;i<r.length;++i){let a=r[i];s.set(a,o),o+=a.length}return s}return t}},oa=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}},aa=class{constructor(){this._zlib=new ps(Zp)}cleanup(){this._zlib&&fa(this._zlib)}read(t){return this._zlib.writeSync(t,!1)}},ca=class{cleanup(){}read(t){return t}};bf.exports={PacketReader:ca,PacketWriter:oa,ZlibPacketReader:aa,ZlibPacketWriter:sa}});var Cf=ct((OE,If)=>{"use strict";var{bufferSlice:ua,bufferParser:D,doFatalError:gt,sigSSHToASN1:xf,writeUInt32BE:Sf}=gn(),{CHANNEL_OPEN_FAILURE:fg,COMPAT:lg,MESSAGE:At,TERMINAL_MODE:wf}=Tn(),{parseKey:ug}=Vn(),dg=Array.from(Object.entries(wf)).reduce((n,[t,e])=>({...n,[t]:e}),{});If.exports={[At.DISCONNECT]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readString(!0),s=D.readString();if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed DISCONNECT packet");n._debug&&n._debug(`Inbound: Received DISCONNECT (${e}, "${r}")`);let i=n._handlers.DISCONNECT;i&&i(n,e,r)},[At.IGNORE]:(n,t)=>{n._debug&&n._debug("Inbound: Received IGNORE")},[At.UNIMPLEMENTED]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed UNIMPLEMENTED packet");n._debug&&n._debug(`Inbound: Received UNIMPLEMENTED (seqno ${e})`)},[At.DEBUG]:(n,t)=>{D.init(t,1);let e=D.readBool(),r=D.readString(!0),s=D.readString();if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed DEBUG packet");n._debug&&n._debug("Inbound: Received DEBUG");let i=n._handlers.DEBUG;i&&i(n,e,r)},[At.SERVICE_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readString(!0);if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed SERVICE_REQUEST packet");n._debug&&n._debug(`Inbound: Received SERVICE_REQUEST (${e})`);let r=n._handlers.SERVICE_REQUEST;r&&r(n,e)},[At.SERVICE_ACCEPT]:(n,t)=>{D.init(t,1);let e=D.readString(!0);if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed SERVICE_ACCEPT packet");n._debug&&n._debug(`Inbound: Received SERVICE_ACCEPT (${e})`);let r=n._handlers.SERVICE_ACCEPT;r&&r(n,e)},[At.EXT_INFO]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r;if(e!==void 0){r=[];for(let i=0;i<e;++i){let o=D.readString(!0),a=D.readString();if(a!==void 0)if(o==="server-sig-algs"){let c=a.latin1Slice(0,a.length).split(",");r.push({name:o,algs:c});continue}else continue;r=void 0;break}}if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed EXT_INFO packet");n._debug&&n._debug("Inbound: Received EXT_INFO");let s=n._handlers.EXT_INFO;s&&s(n,r)},[At.USERAUTH_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readString(!0),s=D.readString(!0),i,o;switch(s){case"none":i=null;break;case"password":{let c=D.readBool();if(c!==void 0&&(i=D.readString(!0),i!==void 0&&c)){let f=D.readString(!0);f!==void 0?i={oldPassword:i,newPassword:f}:i=void 0}break}case"publickey":{let c=D.readBool();if(c!==void 0){let f=D.readString(!0),l=f,u=D.readString(),h;switch(f){case"rsa-sha2-256":l="ssh-rsa",h="sha256";break;case"rsa-sha2-512":l="ssh-rsa",h="sha512";break}if(c){let p=D.pos(),y=D.readString();if(y!==void 0&&(y.length>4+f.length+4&&y.utf8Slice(4,4+f.length)===f&&(y=ua(y,4+f.length+4)),y=xf(y,l),y)){let E=n._kex.sessionID,b=Buffer.allocUnsafe(4+E.length+p);Sf(b,E.length,0),b.set(E,4),b.set(new Uint8Array(t.buffer,t.byteOffset,p),4+E.length),i={keyAlgo:l,key:u,signature:y,blob:b,hashAlgo:h}}}else i={keyAlgo:l,key:u,hashAlgo:h},o="publickey -- check"}break}case"hostbased":{let c=D.readString(!0),f=c,l=D.readString(),u=D.readString(!0),h=D.readString(!0),p;switch(c){case"rsa-sha2-256":f="ssh-rsa",p="sha256";break;case"rsa-sha2-512":f="ssh-rsa",p="sha512";break}let y=D.pos(),E=D.readString();if(E!==void 0&&(E.length>4+c.length+4&&E.utf8Slice(4,4+c.length)===c&&(E=ua(E,4+c.length+4)),E=xf(E,f),E!==void 0)){let b=n._kex.sessionID,C=Buffer.allocUnsafe(4+b.length+y);Sf(C,b.length,0),C.set(b,4),C.set(new Uint8Array(t.buffer,t.byteOffset,y),4+b.length),i={keyAlgo:f,key:l,signature:E,blob:C,localHostname:u,localUsername:h,hashAlgo:p}}break}case"keyboard-interactive":D.skipString(),i=D.readList();break;default:s!==void 0&&(i=D.readRaw())}if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed USERAUTH_REQUEST packet");o===void 0&&(o=s),n._authsQueue.push(s),n._debug&&n._debug(`Inbound: Received USERAUTH_REQUEST (${o})`);let a=n._handlers.USERAUTH_REQUEST;a&&a(n,e,r,s,i)},[At.USERAUTH_FAILURE]:(n,t)=>{D.init(t,1);let e=D.readList(),r=D.readBool();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_FAILURE packet");n._debug&&n._debug(`Inbound: Received USERAUTH_FAILURE (${e})`),n._authsQueue.shift();let s=n._handlers.USERAUTH_FAILURE;s&&s(n,e,r)},[At.USERAUTH_SUCCESS]:(n,t)=>{n._debug&&n._debug("Inbound: Received USERAUTH_SUCCESS"),n._authsQueue.shift();let e=n._handlers.USERAUTH_SUCCESS;e&&e(n)},[At.USERAUTH_BANNER]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_BANNER packet");n._debug&&n._debug("Inbound: Received USERAUTH_BANNER");let s=n._handlers.USERAUTH_BANNER;s&&s(n,e)},60:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 60 without auth");return}switch(n._authsQueue[0]){case"password":{D.init(t,1);let e=D.readString(!0),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_PASSWD_CHANGEREQ packet");n._debug&&n._debug("Inbound: Received USERAUTH_PASSWD_CHANGEREQ");let s=n._handlers.USERAUTH_PASSWD_CHANGEREQ;s&&s(n,e);break}case"publickey":{D.init(t,1);let e=D.readString(!0),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_PK_OK packet");n._debug&&n._debug("Inbound: Received USERAUTH_PK_OK"),n._authsQueue.shift();let s=n._handlers.USERAUTH_PK_OK;s&&s(n,e,r);break}case"keyboard-interactive":{D.init(t,1);let e=D.readString(!0),r=D.readString(!0);D.readString();let s=D.readUInt32BE(),i;if(s!==void 0){i=new Array(s);let a;for(a=0;a<s;++a){let c=D.readString(!0),f=D.readBool();if(f===void 0)break;i[a]={prompt:c,echo:f}}a!==s&&(i=void 0)}if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed USERAUTH_INFO_REQUEST packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_REQUEST");let o=n._handlers.USERAUTH_INFO_REQUEST;o&&o(n,e,r,i);break}default:n._debug&&n._debug("Inbound: Received unexpected payload type 60")}},61:(n,t)=>{if(!n._authsQueue.length){n._debug&&n._debug("Inbound: Received payload type 61 without auth");return}if(n._authsQueue[0]!=="keyboard-interactive")return gt(n,"Inbound: Received unexpected payload type 61");D.init(t,1);let e=D.readUInt32BE(),r;if(e!==void 0){r=new Array(e);let i;for(i=0;i<e;++i){let o=D.readString(!0);if(o===void 0)break;r[i]=o}i!==e&&(r=void 0)}if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed USERAUTH_INFO_RESPONSE packet");n._debug&&n._debug("Inbound: Received USERAUTH_INFO_RESPONSE");let s=n._handlers.USERAUTH_INFO_RESPONSE;s&&s(n,r)},[At.GLOBAL_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readBool(),s;if(r!==void 0)switch(e){case"tcpip-forward":case"cancel-tcpip-forward":{let o=D.readString(!0),a=D.readUInt32BE();a!==void 0&&(s={bindAddr:o,bindPort:a});break}case"streamlocal-forward@openssh.com":case"cancel-streamlocal-forward@openssh.com":{let o=D.readString(!0);o!==void 0&&(s={socketPath:o});break}case"no-more-sessions@openssh.com":s=null;break;case"hostkeys-00@openssh.com":{for(s=[];D.avail()>0;){let o=D.readString();if(o===void 0){s=void 0;break}let a=ug(o);a instanceof Error||s.push(a)}break}default:s=D.readRaw()}if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed GLOBAL_REQUEST packet");n._debug&&n._debug(`Inbound: GLOBAL_REQUEST (${e})`);let i=n._handlers.GLOBAL_REQUEST;i?i(n,e,r,s):n.requestFailure()},[At.REQUEST_SUCCESS]:(n,t)=>{let e=t.length>1?ua(t,1):null;n._debug&&n._debug("Inbound: REQUEST_SUCCESS");let r=n._handlers.REQUEST_SUCCESS;r&&r(n,e)},[At.REQUEST_FAILURE]:(n,t)=>{n._debug&&n._debug("Inbound: Received REQUEST_FAILURE");let e=n._handlers.REQUEST_FAILURE;e&&e(n)},[At.CHANNEL_OPEN]:(n,t)=>{D.init(t,1);let e=D.readString(!0),r=D.readUInt32BE(),s=D.readUInt32BE(),i=D.readUInt32BE(),o;switch(e){case"forwarded-tcpip":case"direct-tcpip":{let c=D.readString(!0),f=D.readUInt32BE(),l=D.readString(!0),u=D.readUInt32BE();u!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{destIP:c,destPort:f,srcIP:l,srcPort:u}});break}case"forwarded-streamlocal@openssh.com":case"direct-streamlocal@openssh.com":{let c=D.readString(!0);c!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{socketPath:c}});break}case"x11":{let c=D.readString(!0),f=D.readUInt32BE();f!==void 0&&(o={type:e,sender:r,window:s,packetSize:i,data:{srcIP:c,srcPort:f}});break}default:o={type:e,sender:r,window:s,packetSize:i,data:{}}}if(D.clear(),o===void 0)return gt(n,"Inbound: Malformed CHANNEL_OPEN packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN (s:${r}, ${e})`);let a=n._handlers.CHANNEL_OPEN;a?a(n,o):n.channelOpenFail(o.sender,fg.ADMINISTRATIVELY_PROHIBITED,"","")},[At.CHANNEL_OPEN_CONFIRMATION]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE(),s=D.readUInt32BE(),i=D.readUInt32BE(),o=D.avail()?D.readRaw():void 0;if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed CHANNEL_OPEN_CONFIRMATION packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_CONFIRMATION (r:${e}, s:${r})`);let a=n._handlers.CHANNEL_OPEN_CONFIRMATION;a&&a(n,{recipient:e,sender:r,window:s,packetSize:i,data:o})},[At.CHANNEL_OPEN_FAILURE]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE(),s=D.readString(!0),i=D.readString();if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed CHANNEL_OPEN_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_OPEN_FAILURE (r:${e})`);let o=n._handlers.CHANNEL_OPEN_FAILURE;o&&o(n,e,r,s)},[At.CHANNEL_WINDOW_ADJUST]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed CHANNEL_WINDOW_ADJUST packet");n._debug&&n._debug(`Inbound: CHANNEL_WINDOW_ADJUST (r:${e}, ${r})`);let s=n._handlers.CHANNEL_WINDOW_ADJUST;s&&s(n,e,r)},[At.CHANNEL_DATA]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readString();if(D.clear(),r===void 0)return gt(n,"Inbound: Malformed CHANNEL_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_DATA (r:${e}, ${r.length})`);let s=n._handlers.CHANNEL_DATA;s&&s(n,e,r)},[At.CHANNEL_EXTENDED_DATA]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readUInt32BE(),s=D.readString();if(D.clear(),s===void 0)return gt(n,"Inbound: Malformed CHANNEL_EXTENDED_DATA packet");n._debug&&n._debug(`Inbound: CHANNEL_EXTENDED_DATA (r:${e}, ${s.length})`);let i=n._handlers.CHANNEL_EXTENDED_DATA;i&&i(n,e,s,r)},[At.CHANNEL_EOF]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_EOF packet");n._debug&&n._debug(`Inbound: CHANNEL_EOF (r:${e})`);let r=n._handlers.CHANNEL_EOF;r&&r(n,e)},[At.CHANNEL_CLOSE]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_CLOSE packet");n._debug&&n._debug(`Inbound: CHANNEL_CLOSE (r:${e})`);let r=n._handlers.CHANNEL_CLOSE;r&&r(n,e)},[At.CHANNEL_REQUEST]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE(),r=D.readString(!0),s=D.readBool(),i;if(s!==void 0)switch(r){case"exit-status":i=D.readUInt32BE(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"exit-signal":{let a,c;if(n._compatFlags&lg.OLD_EXIT){let l=D.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})`)}c=!1}else a=D.readString(!0),c=D.readBool(),c===void 0&&(a=void 0);let f=D.readString(!0);D.skipString()!==void 0&&(i={signal:a,coreDumped:c,errorMessage:f}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a})`);break}case"pty-req":{let a=D.readString(!0),c=D.readUInt32BE(),f=D.readUInt32BE(),l=D.readUInt32BE(),u=D.readUInt32BE(),h=D.readString();if(h!==void 0){D.init(h,1);let p={};for(;D.avail();){let y=D.readByte();if(y===wf.TTY_OP_END)break;let E=dg[y],b=D.readUInt32BE();if(y===void 0||E===void 0||b===void 0){p=void 0;break}p[E]=b}p!==void 0&&(i={term:a,cols:c,rows:f,width:l,height:u,modes:p})}n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"window-change":{let a=D.readUInt32BE(),c=D.readUInt32BE(),f=D.readUInt32BE(),l=D.readUInt32BE();l!==void 0&&(i={cols:a,rows:c,width:f,height:l}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"x11-req":{let a=D.readBool(),c=D.readString(!0),f=D.readString(),l=D.readUInt32BE();l!==void 0&&(i={single:a,protocol:c,cookie:f,screen:l}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break}case"env":{let a=D.readString(!0),c=D.readString(!0);c!==void 0&&(i={name:a,value:c}),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${a}=${c})`);break}case"shell":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;case"exec":i=D.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"subsystem":i=D.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"signal":i=D.readString(!0),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"xon-xoff":i=D.readBool(),n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r}: ${i})`);break;case"auth-agent-req@openssh.com":i=null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`);break;default:i=D.avail()?D.readRaw():null,n._debug&&n._debug(`Inbound: CHANNEL_REQUEST (r:${e}, ${r})`)}if(D.clear(),i===void 0)return gt(n,"Inbound: Malformed CHANNEL_REQUEST packet");let o=n._handlers.CHANNEL_REQUEST;o&&o(n,e,r,s,i)},[At.CHANNEL_SUCCESS]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_SUCCESS packet");n._debug&&n._debug(`Inbound: CHANNEL_SUCCESS (r:${e})`);let r=n._handlers.CHANNEL_SUCCESS;r&&r(n,e)},[At.CHANNEL_FAILURE]:(n,t)=>{D.init(t,1);let e=D.readUInt32BE();if(D.clear(),e===void 0)return gt(n,"Inbound: Malformed CHANNEL_FAILURE packet");n._debug&&n._debug(`Inbound: CHANNEL_FAILURE (r:${e})`);let r=n._handlers.CHANNEL_FAILURE;r&&r(n,e)}}});var gs=ct((ME,vf)=>{"use strict";var da=new Array(256);[ms().HANDLERS,Cf()].forEach(n=>{for(let[t,e]of Object.entries(n))t=+t,isFinite(t)&&t>=0&&t<da.length&&(da[t]=e)});vf.exports=da});var ms=ct((HE,$f)=>{"use strict";var{createDiffieHellman:hg,createDiffieHellmanGroup:pg,createECDH:gg,createHash:pa,createPublicKey:mg,diffieHellman:Ag,generateKeyPairSync:Eg,randomFillSync:yg}=require("crypto"),{Ber:kf}=ri(),{COMPAT:ga,curve25519Supported:_g,DEFAULT_KEX:Bf,DEFAULT_SERVER_HOST_KEY:Rf,DEFAULT_CIPHER:As,DEFAULT_MAC:Es,DEFAULT_COMPRESSION:ys,DISCONNECT_REASON:Ge,MESSAGE:ht}=Tn(),{CIPHER_INFO:Lr,createCipher:bg,createDecipher:xg,MAC_INFO:Nf}=Wn(),{parseDERKey:Sg}=Vn(),{bufferFill:wg,bufferParser:Ve,convertSignature:Ig,doFatalError:ze,FastBuffer:Cg,sigSSHToASN1:vg,writeUInt32BE:Ot}=gn(),{PacketReader:Pf,PacketWriter:Tf,ZlibPacketReader:_s,ZlibPacketWriter:bs}=la(),Pr,kg=2048,Bg=8192,Rg=Buffer.alloc(0);function Lf(n){let t;if(n._compatFlags&ga.BAD_DHGEX){let e=n._offer.lists.kex,r=e.array,s=!1;for(let i=0;i<r.length;++i)r[i].includes("group-exchange")&&(s||(s=!0,r=r.slice()),r.splice(i--,1));if(s){let i=17+n._offer.totalSize+1+4,o=Buffer.from(r.join(","));i-=e.buffer.length-o.length;let a=n._offer.lists.all,c=new Uint8Array(a.buffer,a.byteOffset+4+e.buffer.length,a.length-(4+e.buffer.length));t=Buffer.allocUnsafe(i),Ot(t,o.length,17),t.set(o,21),t.set(c,21+o.length)}}t===void 0&&(t=Buffer.allocUnsafe(17+n._offer.totalSize+1+4),n._offer.copyAllTo(t,17)),n._debug&&n._debug("Outbound: Sending KEXINIT"),t[0]=ht.KEXINIT,yg(t,1,16),wg(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 Uf(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(Ve.init(t,17),(e.kex=Ve.readList())===void 0||(e.serverHostKey=Ve.readList())===void 0||(e.cs.cipher=Ve.readList())===void 0||(e.sc.cipher=Ve.readList())===void 0||(e.cs.mac=Ve.readList())===void 0||(e.sc.mac=Ve.readList())===void 0||(e.cs.compress=Ve.readList())===void 0||(e.sc.compress=Ve.readList())===void 0||(e.cs.lang=Ve.readList())===void 0||(e.sc.lang=Ve.readList())===void 0)return Ve.clear(),ze(n,"Received malformed KEXINIT","handshake",Ge.KEY_EXCHANGE_FAILED);let r=Ve.pos(),s=r<t.length&&t[r]===1;Ve.clear();let i=n._offer,o=e,a=i.lists.kex.array;if(n._compatFlags&ga.BAD_DHGEX){let v=!1;for(let M=0;M<a.length;++M)a[M].indexOf("group-exchange")!==-1&&(v||(v=!0,a=a.slice()),a.splice(M--,1))}let c,f,l,u=n._debug;u&&u("Inbound: Handshake in progress"),u&&u(`Handshake: (local) KEX method: ${a}`),u&&u(`Handshake: (remote) KEX method: ${o.kex}`);let h;if(n._server?(f=a,c=o.kex,h=c.indexOf("ext-info-c")!==-1):(f=o.kex,c=a,h=f.indexOf("ext-info-s")!==-1),n._strictMode===void 0&&(n._server?n._strictMode=c.indexOf("kex-strict-c-v00@openssh.com")!==-1:n._strictMode=f.indexOf("kex-strict-s-v00@openssh.com")!==-1,n._strictMode&&(u&&u("Handshake: strict KEX mode enabled"),n._decipher.inSeqno!==1)))return u&&u("Handshake: KEXINIT not first packet in strict KEX mode"),ze(n,"Handshake failed: KEXINIT not first packet in strict KEX mode","handshake",Ge.KEY_EXCHANGE_FAILED);for(l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: no matching key exchange algorithm"),ze(n,"Handshake failed: no matching key exchange algorithm","handshake",Ge.KEY_EXCHANGE_FAILED);e.kex=c[l],u&&u(`Handshake: KEX algorithm: ${c[l]}`),s&&(!o.kex.length||c[l]!==o.kex[0])&&(n._skipNextInboundPacket=!0);let p=i.lists.serverHostKey.array;for(u&&u(`Handshake: (local) Host key format: ${p}`),u&&u(`Handshake: (remote) Host key format: ${o.serverHostKey}`),n._server?(f=p,c=o.serverHostKey):(f=o.serverHostKey,c=p),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching host key format"),ze(n,"Handshake failed: no matching host key format","handshake",Ge.KEY_EXCHANGE_FAILED);e.serverHostKey=c[l],u&&u(`Handshake: Host key format: ${c[l]}`);let y=i.lists.cs.cipher.array;for(u&&u(`Handshake: (local) C->S cipher: ${y}`),u&&u(`Handshake: (remote) C->S cipher: ${o.cs.cipher}`),n._server?(f=y,c=o.cs.cipher):(f=o.cs.cipher,c=y),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching C->S cipher"),ze(n,"Handshake failed: no matching C->S cipher","handshake",Ge.KEY_EXCHANGE_FAILED);e.cs.cipher=c[l],u&&u(`Handshake: C->S Cipher: ${c[l]}`);let E=i.lists.sc.cipher.array;for(u&&u(`Handshake: (local) S->C cipher: ${E}`),u&&u(`Handshake: (remote) S->C cipher: ${o.sc.cipher}`),n._server?(f=E,c=o.sc.cipher):(f=o.sc.cipher,c=E),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching S->C cipher"),ze(n,"Handshake failed: no matching S->C cipher","handshake",Ge.KEY_EXCHANGE_FAILED);e.sc.cipher=c[l],u&&u(`Handshake: S->C cipher: ${c[l]}`);let b=i.lists.cs.mac.array;if(u&&u(`Handshake: (local) C->S MAC: ${b}`),u&&u(`Handshake: (remote) C->S MAC: ${o.cs.mac}`),Lr[e.cs.cipher].authLen>0)e.cs.mac="",u&&u("Handshake: C->S MAC: <implicit>");else{for(n._server?(f=b,c=o.cs.mac):(f=o.cs.mac,c=b),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching C->S MAC"),ze(n,"Handshake failed: no matching C->S MAC","handshake",Ge.KEY_EXCHANGE_FAILED);e.cs.mac=c[l],u&&u(`Handshake: C->S MAC: ${c[l]}`)}let C=i.lists.sc.mac.array;if(u&&u(`Handshake: (local) S->C MAC: ${C}`),u&&u(`Handshake: (remote) S->C MAC: ${o.sc.mac}`),Lr[e.sc.cipher].authLen>0)e.sc.mac="",u&&u("Handshake: S->C MAC: <implicit>");else{for(n._server?(f=C,c=o.sc.mac):(f=o.sc.mac,c=C),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching S->C MAC"),ze(n,"Handshake failed: no matching S->C MAC","handshake",Ge.KEY_EXCHANGE_FAILED);e.sc.mac=c[l],u&&u(`Handshake: S->C MAC: ${c[l]}`)}let N=i.lists.cs.compress.array;for(u&&u(`Handshake: (local) C->S compression: ${N}`),u&&u(`Handshake: (remote) C->S compression: ${o.cs.compress}`),n._server?(f=N,c=o.cs.compress):(f=o.cs.compress,c=N),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching C->S compression"),ze(n,"Handshake failed: no matching C->S compression","handshake",Ge.KEY_EXCHANGE_FAILED);e.cs.compress=c[l],u&&u(`Handshake: C->S compression: ${c[l]}`);let H=i.lists.sc.compress.array;for(u&&u(`Handshake: (local) S->C compression: ${H}`),u&&u(`Handshake: (remote) S->C compression: ${o.sc.compress}`),n._server?(f=H,c=o.sc.compress):(f=o.sc.compress,c=H),l=0;l<c.length&&f.indexOf(c[l])===-1;++l);if(l===c.length)return u&&u("Handshake: No matching S->C compression"),ze(n,"Handshake failed: no matching S->C compression","handshake",Ge.KEY_EXCHANGE_FAILED);e.sc.compress=c[l],u&&u(`Handshake: S->C compression: ${c[l]}`),e.cs.lang="",e.sc.lang="",n._kex&&(n._kexinit||Lf(n),n._decipher._onPayload=Df.bind(n,{firstPacket:!1})),n._kex=Ng(e,n,t),n._kex.remoteExtInfoEnabled=h,n._kex.start()}var Ng=(()=>{function n(o){let a=0,c=o.length;for(;o[a]===0;)++a,--c;let f;return o[a]&128?(f=Buffer.allocUnsafe(1+c),f[0]=0,o.copy(f,1,a),o=f):c!==o.length&&(f=Buffer.allocUnsafe(c),o.copy(f,0,a),o=f),o}class t{constructor(a,c,f){this._protocol=c,this.sessionID=c._kex?c._kex.sessionID:void 0,this.negotiated=a,this.remoteExtInfoEnabled=!1,this._step=1,this._public=null,this._dh=null,this._sentNEWKEYS=!1,this._receivedNEWKEYS=!1,this._finished=!1,this._hostVerified=!1,this._kexinit=c._kexinit,this._remoteKexinit=f,this._identRaw=c._identRaw,this._remoteIdentRaw=c._remoteIdentRaw,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0}finish(a){if(this._finished)return!1;this._finished=!0;let c=this._protocol._server,f=this.negotiated,l=this.convertPublicKey(this._dhData),u=this.computeSecret(this._dhData);if(u instanceof Error)return u.message=`Error while computing DH secret (${this.type}): ${u.message}`,u.level="handshake",ze(this._protocol,u,Ge.KEY_EXCHANGE_FAILED);let h=pa(this.hashName);Sn(h,c?this._remoteIdentRaw:this._identRaw),Sn(h,c?this._identRaw:this._remoteIdentRaw),Sn(h,c?this._remoteKexinit:this._kexinit),Sn(h,c?this._kexinit:this._remoteKexinit);let p=c?this._hostKey.getPublicSSH():this._hostKey;if(Sn(h,p),this.type==="groupex"){let H=this.getDHParams(),v=Buffer.allocUnsafe(4);Ot(v,this._minBits,0),h.update(v),Ot(v,this._prefBits,0),h.update(v),Ot(v,this._maxBits,0),h.update(v),Sn(h,H.prime),Sn(h,H.generator)}Sn(h,c?l:this.getPublicKey());let y=c?this.getPublicKey():l;Sn(h,y),Sn(h,u);let E=h.digest();if(c){let H;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":H="sha256";break;case"rsa-sha2-512":H="sha512";break}this._protocol._debug&&this._protocol._debug("Generating signature ...");let v=this._hostKey.sign(E,H);if(v instanceof Error)return ze(this._protocol,`Handshake failed: signature generation failed for ${this._hostKey.type} host key: ${v.message}`,"handshake",Ge.KEY_EXCHANGE_FAILED);if(v=Ig(v,this._hostKey.type),v===!1)return ze(this._protocol,`Handshake failed: signature conversion failed for ${this._hostKey.type} host key`,"handshake",Ge.KEY_EXCHANGE_FAILED);let M=this.negotiated.serverHostKey,Q=Buffer.byteLength(M),P=4+Q+4+v.length,x=this._protocol._packetRW.write.allocStartKEX,w=this._protocol._packetRW.write.alloc(5+p.length+4+y.length+4+P,!0);if(w[x]=ht.KEXDH_REPLY,Ot(w,p.length,++x),w.set(p,x+=4),Ot(w,y.length,x+=p.length),w.set(y,x+=4),Ot(w,P,x+=y.length),Ot(w,Q,x+=4),w.utf8Write(M,x+=4,Q),Ot(w,v.length,x+=Q),w.set(v,x+=4),this._protocol._debug){let I;switch(this.type){case"group":I="KEXDH_REPLY";break;case"groupex":I="KEXDH_GEX_REPLY";break;default:I="KEXECDH_REPLY"}this._protocol._debug(`Outbound: Sending ${I}`)}this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(w,!0))}else{Ve.init(this._sig,0);let H=Ve.readString(!0);if(!H)return ze(this._protocol,"Malformed packet while reading signature","handshake",Ge.KEY_EXCHANGE_FAILED);if(H!==f.serverHostKey)return ze(this._protocol,`Wrong signature type: ${H}, expected: ${f.serverHostKey}`,"handshake",Ge.KEY_EXCHANGE_FAILED);let v=Ve.readString();if(Ve.clear(),v===void 0)return ze(this._protocol,"Malformed packet while reading signature","handshake",Ge.KEY_EXCHANGE_FAILED);if(!(v=vg(v,H)))return ze(this._protocol,"Malformed signature","handshake",Ge.KEY_EXCHANGE_FAILED);let M;{Ve.init(this._hostKey,0);let x=Ve.readString(!0),w=this._hostKey.slice(Ve.pos());if(Ve.clear(),M=Sg(w,x),M instanceof Error)return M.level="handshake",ze(this._protocol,M,Ge.KEY_EXCHANGE_FAILED)}let Q;switch(this.negotiated.serverHostKey){case"rsa-sha2-256":Q="sha256";break;case"rsa-sha2-512":Q="sha512";break}this._protocol._debug&&this._protocol._debug("Verifying signature ...");let P=M.verify(E,v,Q);if(P!==!0)return P instanceof Error?this._protocol._debug&&this._protocol._debug(`Signature verification failed: ${P.stack}`):this._protocol._debug&&this._protocol._debug("Signature verification failed"),ze(this._protocol,"Handshake failed: signature verification failed","handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Verified signature")}(c||!a)&&xs(this);let b,C,N=H=>{if(b)return xs(this),b.outbound.seqno=this._protocol._cipher.outSeqno,this._protocol._cipher.free(),this._protocol._cipher=bg(b),this._protocol._packetRW.write=C,b=void 0,C=void 0,this._protocol._onHandshakeComplete(f),!1;this.sessionID||(this.sessionID=E);{let te=Buffer.allocUnsafe(4+u.length);Ot(te,u.length,0),te.set(u,4),u=te}let v=Lr[f.cs.cipher],M=Lr[f.sc.cipher],Q=Tr(v.ivLen,this.hashName,u,E,this.sessionID,"A"),P=Tr(M.ivLen,this.hashName,u,E,this.sessionID,"B"),x=Tr(v.keyLen,this.hashName,u,E,this.sessionID,"C"),w=Tr(M.keyLen,this.hashName,u,E,this.sessionID,"D"),I,k;v.authLen||(I=Nf[f.cs.mac],k=Tr(I.len,this.hashName,u,E,this.sessionID,"E"));let R,ne;M.authLen||(R=Nf[f.sc.mac],ne=Tr(R.len,this.hashName,u,E,this.sessionID,"F"));let z={inbound:{onPayload:this._protocol._onPayload,seqno:this._protocol._decipher.inSeqno,decipherInfo:c?v:M,decipherIV:c?Q:P,decipherKey:c?x:w,macInfo:c?I:R,macKey:c?k:ne},outbound:{onWrite:this._protocol._onWrite,seqno:this._protocol._cipher.outSeqno,cipherInfo:c?M:v,cipherIV:c?P:Q,cipherKey:c?w:x,macInfo:c?R:I,macKey:c?ne:k}};this._protocol._decipher.free(),b=z,this._protocol._decipher=xg(z);let Y={read:void 0,write:void 0};switch(f.cs.compress){case"zlib":c?Y.read=new _s:Y.write=new bs(this._protocol);break;case"zlib@openssh.com":if(this._protocol._authenticated){c?Y.read=new _s:Y.write=new bs(this._protocol);break}default:c?Y.read=new Pf:Y.write=new Tf(this._protocol)}switch(f.sc.compress){case"zlib":c?Y.write=new bs(this._protocol):Y.read=new _s;break;case"zlib@openssh.com":if(this._protocol._authenticated){c?Y.write=new bs(this._protocol):Y.read=new _s;break}default:c?Y.write=new Tf(this._protocol):Y.read=new Pf}return this._protocol._packetRW.read.cleanup(),this._protocol._packetRW.write.cleanup(),this._protocol._packetRW.read=Y.read,C=Y.write,this._public=null,this._dh=null,this._kexinit=this._protocol._kexinit=void 0,this._remoteKexinit=void 0,this._identRaw=void 0,this._remoteIdentRaw=void 0,this._hostKey=void 0,this._dhData=void 0,this._sig=void 0,H?!1:N()};if((c||a)&&(this.finish=N),!c)return N(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(),c=this._protocol._packetRW.write.allocStartKEX,f=this._protocol._packetRW.write.alloc(5+a.length,!0);f[c]=ht.KEXDH_INIT,Ot(f,a.length,++c),f.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(f,!0))}}getPublicKey(){this.generateKeys();let a=this._public;if(a)return this.convertPublicKey(a)}convertPublicKey(a){let c,f=0,l=a.length;for(;a[f]===0;)++f,--l;return a[f]&128?(c=Buffer.allocUnsafe(1+l),c[0]=0,a.copy(c,1,f),c):(l!==a.length&&(c=Buffer.allocUnsafe(l),a.copy(c,0,f),a=c),a)}computeSecret(a){this.generateKeys();try{return n(this._dh.computeSecret(a))}catch(c){return c}}parse(a){let c=a[0];switch(this._step){case 1:if(this._protocol._server){if(c!==ht.KEXDH_INIT)return ze(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_INIT}`,"handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Init"),Ve.init(a,1);let f=Ve.readString();if(Ve.clear(),f===void 0)return ze(this._protocol,"Received malformed KEX*_INIT","handshake",Ge.KEY_EXCHANGE_FAILED);this._dhData=f;let l=this._protocol._hostKeys[this.negotiated.serverHostKey];Array.isArray(l)&&(l=l[0]),this._hostKey=l,this.finish()}else{if(c!==ht.KEXDH_REPLY)return ze(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_REPLY}`,"handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH Reply"),Ve.init(a,1);let f,l,u;if((f=Ve.readString())===void 0||(l=Ve.readString())===void 0||(u=Ve.readString())===void 0)return Ve.clear(),ze(this._protocol,"Received malformed KEX*_REPLY","handshake",Ge.KEY_EXCHANGE_FAILED);Ve.clear(),Ve.init(f,0);let h=Ve.readString(!0);if(Ve.clear(),h===void 0)return ze(this._protocol,"Received malformed host public key","handshake",Ge.KEY_EXCHANGE_FAILED);if(h!==this.negotiated.serverHostKey)switch(this.negotiated.serverHostKey){case"rsa-sha2-256":case"rsa-sha2-512":if(h==="ssh-rsa")break;default:return ze(this._protocol,"Host key does not match negotiated type","handshake",Ge.KEY_EXCHANGE_FAILED)}this._hostKey=f,this._dhData=l,this._sig=u;let p=!1,y;if(this._protocol._hostVerifier===void 0?(y=!0,this._protocol._debug&&this._protocol._debug("Host accepted by default (no verification)")):y=this._protocol._hostVerifier(f,E=>{if(!p){if(p=!0,E===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),ze(this._protocol,"Host denied (verification failed)","handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,this._receivedNEWKEYS?this.finish():xs(this)}}),y===void 0){++this._step;return}if(p=!0,y===!1)return this._protocol._debug&&this._protocol._debug("Host denied (verification failed)"),ze(this._protocol,"Host denied (verification failed)","handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Host accepted (verified)"),this._hostVerified=!0,xs(this)}++this._step;break;case 2:return c!==ht.NEWKEYS?ze(this._protocol,`Received packet ${c} instead of ${ht.NEWKEYS}`,"handshake",Ge.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 ze(this._protocol,`Received unexpected packet ${c} after NEWKEYS`,"handshake",Ge.KEY_EXCHANGE_FAILED)}}}class e extends t{constructor(a,...c){super(...c),this.type="25519",this.hashName=a,this._keys=null}generateKeys(){this._keys||(this._keys=Eg("x25519"))}getPublicKey(){return this.generateKeys(),this._keys.publicKey.export({type:"spki",format:"der"}).slice(-32)}convertPublicKey(a){let c,f=0,l=a.length;for(;a[f]===0;)++f,--l;return a.length===32||l!==a.length&&(c=Buffer.allocUnsafe(l),a.copy(c,0,f),a=c),a}computeSecret(a){this.generateKeys();try{let c=new kf.Writer;return c.startSequence(),c.startSequence(),c.writeOID("1.3.101.110"),c.endSequence(),c.startSequence(kf.BitString),c.writeByte(0),c._ensure(a.length),a.copy(c._buf,c._offset,0,a.length),c._offset+=a.length,c.endSequence(),c.endSequence(),n(Ag({privateKey:this._keys.privateKey,publicKey:mg({key:c.buffer,type:"spki",format:"der"})}))}catch(c){return c}}}class r extends t{constructor(a,c,...f){super(...f),this.type="ecdh",this.curveName=a,this.hashName=c}generateKeys(){this._dh||(this._dh=gg(this.curveName),this._public=this._dh.generateKeys())}}class s extends t{constructor(a,...c){super(...c),this.type="groupex",this.hashName=a,this._prime=null,this._generator=null,this._minBits=kg,this._prefBits=Pg(this.negotiated),this._protocol._compatFlags&ga.BUG_DHGEX_LARGE&&(this._prefBits=Math.min(this._prefBits,4096)),this._maxBits=Bg}start(){if(this._protocol._server)return;this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_REQUEST");let a=this._protocol._packetRW.write.allocStartKEX,c=this._protocol._packetRW.write.alloc(13,!0);c[a]=ht.KEXDH_GEX_REQUEST,Ot(c,this._minBits,++a),Ot(c,this._prefBits,a+=4),Ot(c,this._maxBits,a+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(c,!0))}generateKeys(){!this._dh&&this._prime&&this._generator&&(this._dh=hg(this._prime,this._generator),this._public=this._dh.generateKeys())}setDHParams(a,c){if(!Buffer.isBuffer(a))throw new Error("Invalid prime value");if(!Buffer.isBuffer(c))throw new Error("Invalid generator value");this._prime=a,this._generator=c}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}parse(a){let c=a[0];switch(this._step){case 1:{if(this._protocol._server)return c!==ht.KEXDH_GEX_REQUEST?ze(this._protocol,`Received packet ${c} instead of `+ht.KEXDH_GEX_REQUEST,"handshake",Ge.KEY_EXCHANGE_FAILED):ze(this._protocol,"Group exchange not implemented for server","handshake",Ge.KEY_EXCHANGE_FAILED);if(c!==ht.KEXDH_GEX_GROUP)return ze(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_GEX_GROUP}`,"handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Group"),Ve.init(a,1);let f,l;if((f=Ve.readString())===void 0||(l=Ve.readString())===void 0)return Ve.clear(),ze(this._protocol,"Received malformed KEXDH_GEX_GROUP","handshake",Ge.KEY_EXCHANGE_FAILED);Ve.clear(),this.setDHParams(f,l),this.generateKeys();let u=this.getPublicKey();this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_GEX_INIT");let h=this._protocol._packetRW.write.allocStartKEX,p=this._protocol._packetRW.write.alloc(5+u.length,!0);p[h]=ht.KEXDH_GEX_INIT,Ot(p,u.length,++h),p.set(u,h+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(p,!0)),++this._step;break}case 2:if(this._protocol._server)return c!==ht.KEXDH_GEX_INIT?ze(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_GEX_INIT}`,"handshake",Ge.KEY_EXCHANGE_FAILED):(this._protocol._debug&&this._protocol._debug("Received DH GEX Init"),ze(this._protocol,"Group exchange not implemented for server","handshake",Ge.KEY_EXCHANGE_FAILED));if(c!==ht.KEXDH_GEX_REPLY)return ze(this._protocol,`Received packet ${c} instead of ${ht.KEXDH_GEX_REPLY}`,"handshake",Ge.KEY_EXCHANGE_FAILED);this._protocol._debug&&this._protocol._debug("Received DH GEX Reply"),this._step=1,a[0]=ht.KEXDH_REPLY,this.parse=t.prototype.parse,this.parse(a)}}}class i extends t{constructor(a,c,...f){super(...f),this.type="group",this.groupName=a,this.hashName=c}start(){if(!this._protocol._server){this._protocol._debug&&this._protocol._debug("Outbound: Sending KEXDH_INIT");let a=this.getPublicKey(),c=this._protocol._packetRW.write.allocStartKEX,f=this._protocol._packetRW.write.alloc(5+a.length,!0);f[c]=ht.KEXDH_INIT,Ot(f,a.length,++c),f.set(a,c+=4),this._protocol._cipher.encrypt(this._protocol._packetRW.write.finalize(f,!0))}}generateKeys(){this._dh||(this._dh=pg(this.groupName),this._public=this._dh.generateKeys())}getDHParams(){if(this._dh)return{prime:n(this._dh.getPrime()),generator:n(this._dh.getGenerator())}}}return(o,...a)=>{if(typeof o!="object"||o===null)throw new Error("Invalid negotiated argument");let c=o.kex;if(typeof c=="string"){switch(a=[o,...a],c){case"curve25519-sha256":case"curve25519-sha256@libssh.org":if(!_g)break;return new e("sha256",...a);case"ecdh-sha2-nistp256":return new r("prime256v1","sha256",...a);case"ecdh-sha2-nistp384":return new r("secp384r1","sha384",...a);case"ecdh-sha2-nistp521":return new r("secp521r1","sha512",...a);case"diffie-hellman-group1-sha1":return new i("modp2","sha1",...a);case"diffie-hellman-group14-sha1":return new i("modp14","sha1",...a);case"diffie-hellman-group14-sha256":return new i("modp14","sha256",...a);case"diffie-hellman-group15-sha512":return new i("modp15","sha512",...a);case"diffie-hellman-group16-sha512":return new i("modp16","sha512",...a);case"diffie-hellman-group17-sha512":return new i("modp17","sha512",...a);case"diffie-hellman-group18-sha512":return new i("modp18","sha512",...a);case"diffie-hellman-group-exchange-sha1":return new s("sha1",...a);case"diffie-hellman-group-exchange-sha256":return new s("sha256",...a)}throw new Error(`Unsupported key exchange algorithm: ${c}`)}throw new Error(`Invalid key exchange type: ${c}`)}})(),ha=(()=>{let n=["kex","serverHostKey",["cs","cipher"],["sc","cipher"],["cs","mac"],["sc","mac"],["cs","compress"],["sc","compress"],["cs","lang"],["sc","lang"]];return class{constructor(e){if(typeof e!="object"||e===null)throw new TypeError("Argument must be an object");let r={kex:void 0,serverHostKey:void 0,cs:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},sc:{cipher:void 0,mac:void 0,compress:void 0,lang:void 0},all:void 0},s=0;for(let a of n){let c,f,l,u;if(typeof a=="string")c=r,f=e[a],l=u=a;else{let p=a[0];c=r[p],u=a[1],f=e[p][u],l=`${p}.${u}`}let h={array:void 0,buffer:void 0};if(Buffer.isBuffer(f))h.array=(""+f).split(","),h.buffer=f,s+=4+f.length;else{if(typeof f=="string"&&(f=f.split(",")),Array.isArray(f))h.array=f,h.buffer=Buffer.from(f.join(","));else throw new TypeError(`Invalid \`${l}\` type: ${typeof f}`);s+=4+h.buffer.length}c[u]=h}let i=Buffer.allocUnsafe(s);r.all=i;let o=0;for(let a of n){let c;typeof a=="string"?c=r[a].buffer:c=r[a[0]][a[1]].buffer,o=Ot(i,c.length,o),i.set(c,o),o+=c.length}this.totalSize=s,this.lists=r}copyAllTo(e,r){let s=this.lists.all;if(typeof r!="number")throw new TypeError(`Invalid offset value: ${typeof r}`);if(e.length-r<s.length)throw new Error("Insufficient space to copy list");return e.set(s,r),s.length}}})(),Sn=(()=>{let n=Buffer.allocUnsafe(4);return(t,e)=>{Ot(n,e.length,0),t.update(n),t.update(e)}})();function Tr(n,t,e,r,s,i){let o;if(n){let a=pa(t).update(e).update(r).update(i).update(s).digest();for(;a.length<n;){let c=pa(t).update(e).update(r).update(a).digest(),f=Buffer.allocUnsafe(a.length+c.length);f.set(a,0),f.set(c,a.length),a=f}a.length===n?o=a:o=new Cg(a.buffer,a.byteOffset,n)}else o=Rg;return o}function Df(n,t){if(t.length===0){this._debug&&this._debug("Inbound: Skipping empty packet payload");return}if(this._skipNextInboundPacket){this._skipNextInboundPacket=!1;return}t=this._packetRW.read.read(t);let e=t[0];if(!this._strictMode)switch(e){case ht.IGNORE:case ht.UNIMPLEMENTED:case ht.DEBUG:return Pr||(Pr=gs()),Pr[e](this,t)}switch(e){case ht.DISCONNECT:return Pr||(Pr=gs()),Pr[e](this,t);case ht.KEXINIT:return n.firstPacket?(n.firstPacket=!1,Uf(this,t)):ze(this,"Received extra KEXINIT during handshake","handshake",Ge.KEY_EXCHANGE_FAILED);default:if(e<20||e>49)return ze(this,`Received unexpected packet type ${e}`,"handshake",Ge.KEY_EXCHANGE_FAILED)}return this._kex.parse(t)}function Pg(n){let t=Lr[n.cs.cipher],e=Lr[n.sc.cipher],r=Math.max(0,t.sslName==="des-ede3-cbc"?14:t.keyLen,t.blockLen,t.ivLen,e.sslName==="des-ede3-cbc"?14:e.keyLen,e.blockLen,e.ivLen)*8;return r<=112?2048:r<=128?3072:r<=192?7680:8192}function xs(n){if(!n._sentNEWKEYS){n._protocol._debug&&n._protocol._debug("Outbound: Sending NEWKEYS");let t=n._protocol._packetRW.write.allocStartKEX,e=n._protocol._packetRW.write.alloc(1,!0);e[t]=ht.NEWKEYS,n._protocol._cipher.encrypt(n._protocol._packetRW.write.finalize(e,!0)),n._sentNEWKEYS=!0,n._protocol._strictMode&&(n._protocol._cipher.outSeqno=0)}}$f.exports={KexInit:ha,kexinit:Lf,onKEXPayload:Df,DEFAULT_KEXINIT_CLIENT:new ha({kex:Bf.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),serverHostKey:Rf,cs:{cipher:As,mac:Es,compress:ys,lang:[]},sc:{cipher:As,mac:Es,compress:ys,lang:[]}}),DEFAULT_KEXINIT_SERVER:new ha({kex:Bf.concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:Rf,cs:{cipher:As,mac:Es,compress:ys,lang:[]},sc:{cipher:As,mac:Es,compress:ys,lang:[]}}),HANDLERS:{[ht.KEXINIT]:Uf}}});var Of=ct((QE,Tg)=>{Tg.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 ya=ct((WE,Xf)=>{"use strict";var{inspect:qf}=require("util"),{bindingAvailable:Lg,NullCipher:Ug,NullDecipher:Dg}=Wn(),{COMPAT_CHECKS:$g,DISCONNECT_REASON:Kf,eddsaSupported:Og,MESSAGE:Se,SIGNALS:Mf,TERMINAL_MODE:Aa}=Tn(),{DEFAULT_KEXINIT_CLIENT:Mg,DEFAULT_KEXINIT_SERVER:Fg,KexInit:Ff,kexinit:Vf,onKEXPayload:Hg}=ms(),{parseKey:Hf}=Vn(),Qg=gs(),{bufferCopy:Ss,bufferFill:Wg,bufferSlice:Gf,convertSignature:Qf,sendPacket:we,writeUInt32BE:T}=gn(),{PacketReader:qg,PacketWriter:Kg,ZlibPacketReader:zf,ZlibPacketWriter:Yf}=la(),Vg=Of().version,Gg=new Map(Object.values(Kf).map(n=>[n,1])),jf=Buffer.from(`SSH-2.0-ssh2js${Vg}`),zg=Buffer.from(`${jf}\r
7
+ `),Yg=8192,jg=1024,Wf=Buffer.from([Se.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]),Xg=Buffer.from([Aa.TTY_OP_END]);function ma(){}var Ea=class{constructor(t){let e=t.onWrite;if(typeof e!="function")throw new Error("Missing onWrite function");this._onWrite=p=>{e(p)};let r=t.onError;if(typeof r!="function")throw new Error("Missing onError function");this._onError=p=>{r(p)};let s=t.debug;this._debug=typeof s=="function"?p=>{s(p)}:void 0;let i=t.onHeader;this._onHeader=typeof i=="function"?(...p)=>{i(...p)}:ma;let o=t.onPacket;this._onPacket=typeof o=="function"?()=>{o()}:ma;let a=t.onHandshakeComplete;typeof a!="function"&&(a=ma);let c;this._onHandshakeComplete=(...p)=>{this._debug&&this._debug("Handshake completed"),c===void 0?c=!0:c=!1;let y=this._queue;if(y){this._queue=void 0,this._debug&&this._debug(`Draining outbound queue (${y.length}) ...`);for(let E=0;E<y.length;++E){let b=y[E],C=this._packetRW.write.finalize(b);if(C===b){let N=this._cipher.allocPacket(b.length);N.set(b,5),C=N}we(this,C)}this._debug&&this._debug("... finished draining outbound queue")}c&&this._server&&this._kex.remoteExtInfoEnabled&&im(this),a(...p)},this._queue=void 0;let f=t.messageHandlers;typeof f=="object"&&f!==null?this._handlers=f:this._handlers={},this._onPayload=tm.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
8
8
  `?t.greeting:`${t.greeting}\r
9
9
  `),typeof t.banner=="string"&&t.banner.length&&(this._banner=t.banner.slice(-2)===`\r
10
10
  `?t.banner:`${t.banner}\r
11
- `)}else this._hostKeys=void 0;let u=t.offer;typeof u!="object"||u===null?u=this._server?Pg:Ng:u.constructor!==$f&&(this._server?u.kex=u.kex.concat(["kex-strict-s-v00@openssh.com"]):u.kex=u.kex.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),u=new $f(u)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=u,this._cipher=new kg(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new Dg,write:new $g(this)},this._hostVerifier=!this._server&&typeof t.hostVerifier=="function"?t.hostVerifier:void 0,this._parse=Kg,this._buffer=void 0,this._authsQueue=[],this._authenticated=!1,this._remoteIdentRaw=void 0;let h;if(typeof t.ident=="string")this._identRaw=Buffer.from(`SSH-2.0-${t.ident}`),h=Buffer.allocUnsafe(this._identRaw.length+2),h.set(this._identRaw,0),h[h.length-2]=13,h[h.length-1]=10;else if(Buffer.isBuffer(t.ident)){let p=Buffer.allocUnsafe(8+t.ident.length);p.latin1Write("SSH-2.0-",0,8),p.set(t.ident,8),this._identRaw=p,h=Buffer.allocUnsafe(p.length+2),h.set(p,0),h[h.length-2]=13,h[h.length-1]=10}else this._identRaw=Gf,h=Fg;this._compatFlags=0,this._debug&&(Cg?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${Hf(this._identRaw.toString())}`),this.start=()=>{this.start=void 0,l&&this._onWrite(l),this._onWrite(h)}}_destruct(t){this._packetRW.read.cleanup(),this._packetRW.write.cleanup(),this._cipher&&this._cipher.free(),this._decipher&&this._decipher.free(),(typeof t!="string"||t.length===0)&&(t="fatal error"),this.parse=()=>{throw new Error(`Instance unusable after ${t}`)},this._onWrite=()=>{throw new Error(`Instance unusable after ${t}`)},this._destruct=void 0}cleanup(){this._destruct&&this._destruct()}parse(t,e,r){for(;e<r;)e=this._parse(t,e,r)}disconnect(t){let r=this._packetRW.write.allocStartKEX,s=this._packetRW.write.alloc(13,!0),i=r+13;Mg.has(t)||(t=Qf.PROTOCOL_ERROR),s[r]=Se.DISCONNECT,P(s,t,++r),s.fill(0,r+=4,i),this._debug&&this._debug(`Outbound: Sending DISCONNECT (${t})`),we(this,this._packetRW.write.finalize(s,!0),!0)}ping(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(Ff.length);e.set(Ff,t),this._debug&&this._debug("Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)"),we(this,this._packetRW.write.finalize(e))}rekey(){this._kexinit===void 0?(this._debug&&this._debug("Outbound: Initiated explicit rekey"),this._queue=[],Wf(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]=Se.REQUEST_SUCCESS,r.set(t,++e)):(r=this._packetRW.write.alloc(1),r[e]=Se.REQUEST_SUCCESS),this._debug&&this._debug("Outbound: Sending REQUEST_SUCCESS"),we(this,this._packetRW.write.finalize(r))}requestFailure(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=Se.REQUEST_FAILURE,this._debug&&this._debug("Outbound: Sending REQUEST_FAILURE"),we(this,this._packetRW.write.finalize(e))}channelSuccess(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Se.CHANNEL_SUCCESS,P(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${t})`),we(this,this._packetRW.write.finalize(r))}channelFailure(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Se.CHANNEL_FAILURE,P(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${t})`),we(this,this._packetRW.write.finalize(r))}channelEOF(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Se.CHANNEL_EOF,P(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_EOF (r:${t})`),we(this,this._packetRW.write.finalize(r))}channelClose(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Se.CHANNEL_CLOSE,P(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${t})`),we(this,this._packetRW.write.finalize(r))}channelWindowAdjust(t,e){let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(9);s[r]=Se.CHANNEL_WINDOW_ADJUST,P(s,t,++r),P(s,e,r+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${t}, ${e})`),we(this,this._packetRW.write.finalize(s))}channelData(t,e){let r=Buffer.isBuffer(e),s=r?e.length:Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(9+s);o[i]=Se.CHANNEL_DATA,P(o,t,++i),P(o,s,i+=4),r?o.set(e,i+=4):o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_DATA (r:${t}, ${s})`),we(this,this._packetRW.write.finalize(o))}channelExtData(t,e,r){let s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(13+i);a[o]=Se.CHANNEL_EXTENDED_DATA,P(a,t,++o),P(a,r,o+=4),P(a,i,o+=4),s?a.set(e,o+=4):a.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${t})`),we(this,this._packetRW.write.finalize(a))}channelOpenConfirm(t,e,r,s){let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(17);o[i]=Se.CHANNEL_OPEN_CONFIRMATION,P(o,t,++i),P(o,e,i+=4),P(o,r,i+=4),P(o,s,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${t}, l:${e})`),we(this,this._packetRW.write.finalize(o))}channelOpenFail(t,e,r){typeof r!="string"&&(r="");let s=Buffer.byteLength(r),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(13+s+4);o[i]=Se.CHANNEL_OPEN_FAILURE,P(o,t,++i),P(o,e,i+=4),P(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),P(o,0,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${t})`),we(this,this._packetRW.write.finalize(o))}service(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);s[r]=Se.SERVICE_REQUEST,P(s,e,++r),s.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_REQUEST (${t})`),we(this,this._packetRW.write.finalize(s))}authPassword(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=r?Buffer.byteLength(r):0,a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(5+s+4+14+4+8+1+4+i+(r?4+o:0));c[a]=Se.USERAUTH_REQUEST,P(c,s,++a),c.utf8Write(t,a+=4,s),P(c,14,a+=s),c.utf8Write("ssh-connection",a+=4,14),P(c,8,a+=14),c.utf8Write("password",a+=4,8),c[a+=8]=r?1:0,P(c,i,++a),Buffer.isBuffer(e)?ys(e,c,0,i,a+=4):c.utf8Write(e,a+=4,i),r?(P(c,o,a+=i),Buffer.isBuffer(r)?ys(r,c,0,o,a+=4):c.utf8Write(r,a+=4,o),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (changed password)")):this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (password)"),this._authsQueue.push("password"),we(this,this._packetRW.write.finalize(c))}authPK(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");if(e=Of(e),e instanceof Error)throw new Error("Invalid key");let i=e.type;e=e.getPublicSSH(),typeof r=="function"&&(s=r,r=void 0),r||(r=i);let o=Buffer.byteLength(t),a=Buffer.byteLength(r),c=e.length,f=this._kex.sessionID,l=f.length,u=(s?4+l:0)+1+4+o+4+14+4+9+1+4+a+4+c,h,p;if(s?(h=Buffer.allocUnsafe(u),p=0,P(h,l,p),h.set(f,p+=4),p+=l):(h=this._packetRW.write.alloc(u),p=this._packetRW.write.allocStart),h[p]=Se.USERAUTH_REQUEST,P(h,o,++p),h.utf8Write(t,p+=4,o),P(h,14,p+=o),h.utf8Write("ssh-connection",p+=4,14),P(h,9,p+=14),h.utf8Write("publickey",p+=4,9),h[p+=9]=s?1:0,P(h,a,++p),h.utf8Write(r,p+=4,a),P(h,c,p+=a),h.set(e,p+=4),!s){this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),we(this,this._packetRW.write.finalize(h));return}s(h,y=>{if(y=Mf(y,i),y===!1)throw new Error("Error while converting handshake signature");let E=y.length;p=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(5+o+4+14+4+9+1+4+a+4+c+4+4+a+4+E),h[p]=Se.USERAUTH_REQUEST,P(h,o,++p),h.utf8Write(t,p+=4,o),P(h,14,p+=o),h.utf8Write("ssh-connection",p+=4,14),P(h,9,p+=14),h.utf8Write("publickey",p+=4,9),h[p+=9]=1,P(h,a,++p),h.utf8Write(r,p+=4,a),P(h,c,p+=a),h.set(e,p+=4),P(h,4+a+4+E,p+=c),P(h,a,p+=4),h.utf8Write(r,p+=4,a),P(h,E,p+=a),h.set(y,p+=4),this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey)"),we(this,this._packetRW.write.finalize(h))})}authHostbased(t,e,r,s,i,o){if(this._server)throw new Error("Client-only method called in server mode");if(e=Of(e),e instanceof Error)throw new Error("Invalid key");let a=e.type;e=e.getPublicSSH(),typeof i=="function"&&(o=i,i=void 0),i||(i=a);let c=Buffer.byteLength(t),f=Buffer.byteLength(i),l=e.length,u=this._kex.sessionID,h=u.length,p=Buffer.byteLength(r),y=Buffer.byteLength(s),E=Buffer.allocUnsafe(4+h+1+4+c+4+14+4+9+4+f+4+l+4+p+4+y),x=0;P(E,h,x),E.set(u,x+=4),E[x+=h]=Se.USERAUTH_REQUEST,P(E,c,++x),E.utf8Write(t,x+=4,c),P(E,14,x+=c),E.utf8Write("ssh-connection",x+=4,14),P(E,9,x+=14),E.utf8Write("hostbased",x+=4,9),P(E,f,x+=9),E.utf8Write(i,x+=4,f),P(E,l,x+=f),E.set(e,x+=4),P(E,p,x+=l),E.utf8Write(r,x+=4,p),P(E,y,x+=p),E.utf8Write(s,x+=4,y),o(E,k=>{if(k=Mf(k,a),!k)throw new Error("Error while converting handshake signature");let D=k.length,H=E.length-h-4;x=this._packetRW.write.allocStart;let C=this._packetRW.write.alloc(H+4+4+f+4+D);ys(E,C,4+h,E.length,x),P(C,4+f+4+D,x+=H),P(C,f,x+=4),C.utf8Write(i,x+=4,f),P(C,D,x+=f),C.set(k,x+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),we(this,this._packetRW.write.finalize(C))})}authKeyboard(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4+14+4+20+4+4);s[r]=Se.USERAUTH_REQUEST,P(s,e,++r),s.utf8Write(t,r+=4,e),P(s,14,r+=e),s.utf8Write("ssh-connection",r+=4,14),P(s,20,r+=14),s.utf8Write("keyboard-interactive",r+=4,20),P(s,0,r+=20),P(s,0,r+=4),this._authsQueue.push("keyboard-interactive"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)"),we(this,this._packetRW.write.finalize(s))}authNone(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4+14+4+4);s[r]=Se.USERAUTH_REQUEST,P(s,e,++r),s.utf8Write(t,r+=4,e),P(s,14,r+=e),s.utf8Write("ssh-connection",r+=4,14),P(s,4,r+=14),s.utf8Write("none",r+=4,4),this._authsQueue.push("none"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (none)"),we(this,this._packetRW.write.finalize(s))}authInfoRes(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,r;if(t){r=new Array(t.length);for(let o=0;o<t.length;++o){let a=Buffer.byteLength(t[o]);r[o]=a,e+=4+a}}let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+e);if(i[s]=Se.USERAUTH_INFO_RESPONSE,t){P(i,t.length,++s),s+=4;for(let o=0;o<t.length;++o){let a=r[o];P(i,a,s),s+=4,a&&(i.utf8Write(t[o],s,a),s+=a)}}else P(i,0,++s);this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_RESPONSE"),we(this,this._packetRW.write.finalize(i))}tcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+s+4);o[i]=Se.GLOBAL_REQUEST,P(o,13,++i),o.utf8Write("tcpip-forward",i+=4,13),o[i+=13]=r===void 0||r===!0?1:0,P(o,s,++i),o.utf8Write(t,i+=4,s),P(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (tcpip-forward)"),we(this,this._packetRW.write.finalize(o))}cancelTcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(30+s+4);o[i]=Se.GLOBAL_REQUEST,P(o,20,++i),o.utf8Write("cancel-tcpip-forward",i+=4,20),o[i+=20]=r===void 0||r===!0?1:0,P(o,s,++i),o.utf8Write(t,i+=4,s),P(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)"),we(this,this._packetRW.write.finalize(o))}openssh_streamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(41+r);i[s]=Se.GLOBAL_REQUEST,P(i,31,++s),i.utf8Write("streamlocal-forward@openssh.com",s+=4,31),i[s+=31]=e===void 0||e===!0?1:0,P(i,r,++s),i.utf8Write(t,s+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)"),we(this,this._packetRW.write.finalize(i))}openssh_cancelStreamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(48+r);i[s]=Se.GLOBAL_REQUEST,P(i,38,++s),i.utf8Write("cancel-streamlocal-forward@openssh.com",s+=4,38),i[s+=38]=e===void 0||e===!0?1:0,P(i,r,++s),i.utf8Write(t,s+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-streamlocal-forward@openssh.com)"),we(this,this._packetRW.write.finalize(i))}directTcpip(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(s.srcIP),o=Buffer.byteLength(s.dstIP),a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(33+i+4+4+o+4);c[a]=Se.CHANNEL_OPEN,P(c,12,++a),c.utf8Write("direct-tcpip",a+=4,12),P(c,t,a+=12),P(c,e,a+=4),P(c,r,a+=4),P(c,o,a+=4),c.utf8Write(s.dstIP,a+=4,o),P(c,s.dstPort,a+=o),P(c,i,a+=4),c.utf8Write(s.srcIP,a+=4,i),P(c,s.srcPort,a+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-tcpip)`),we(this,this._packetRW.write.finalize(c))}openssh_directStreamLocal(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(s.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(51+i+4+4);a[o]=Se.CHANNEL_OPEN,P(a,30,++o),a.utf8Write("direct-streamlocal@openssh.com",o+=4,30),P(a,t,o+=30),P(a,e,o+=4),P(a,r,o+=4),P(a,i,o+=4),a.utf8Write(s.socketPath,o+=4,i),Ug(a,0,o+=i,o+8),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-streamlocal@openssh.com)`),we(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]=Se.GLOBAL_REQUEST,P(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)"),we(this,this._packetRW.write.finalize(r))}session(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(24);i[s]=Se.CHANNEL_OPEN,P(i,7,++s),i.utf8Write("session",s+=4,7),P(i,t,s+=7),P(i,e,s+=4),P(i,r,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, session)`),we(this,this._packetRW.write.finalize(i))}windowChange(t,e,r,s,i){if(this._server)throw new Error("Client-only method called in server mode");let o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(39);a[o]=Se.CHANNEL_REQUEST,P(a,t,++o),P(a,13,o+=4),a.utf8Write("window-change",o+=4,13),a[o+=13]=0,P(a,r,++o),P(a,e,o+=4),P(a,i,o+=4),P(a,s,o+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, window-change)`),we(this,this._packetRW.write.finalize(a))}pty(t,e,r,s,i,o,a,c){if(this._server)throw new Error("Client-only method called in server mode");(!o||!o.length)&&(o="vt100"),a&&!Buffer.isBuffer(a)&&!Array.isArray(a)&&typeof a=="object"&&a!==null&&(a=Yg(a)),(!a||!a.length)&&(a=Wg);let f=o.length,l=a.length,u=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(21+f+4+4+4+4+4+l);if(h[u]=Se.CHANNEL_REQUEST,P(h,t,++u),P(h,7,u+=4),h.utf8Write("pty-req",u+=4,7),h[u+=7]=c===void 0||c===!0?1:0,P(h,f,++u),h.utf8Write(o,u+=4,f),P(h,r,u+=f),P(h,e,u+=4),P(h,i,u+=4),P(h,s,u+=4),P(h,l,u+=4),u+=4,Array.isArray(a))for(let p=0;p<l;++p)h[u++]=a[p];else Buffer.isBuffer(a)&&h.set(a,u);this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, pty-req)`),we(this,this._packetRW.write.finalize(h))}shell(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(15);s[r]=Se.CHANNEL_REQUEST,P(s,t,++r),P(s,5,r+=4),s.utf8Write("shell",r+=4,5),s[r+=5]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, shell)`),we(this,this._packetRW.write.finalize(s))}exec(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(18+i);a[o]=Se.CHANNEL_REQUEST,P(a,t,++o),P(a,4,o+=4),a.utf8Write("exec",o+=4,4),a[o+=4]=r===void 0||r===!0?1:0,P(a,i,++o),s?a.set(e,o+=4):a.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exec: ${e})`),we(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)),Df[e]!==1)throw new Error(`Invalid signal: ${r}`);let s=e.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(20+s);o[i]=Se.CHANNEL_REQUEST,P(o,t,++i),P(o,6,i+=4),o.utf8Write("signal",i+=4,6),o[i+=6]=0,P(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, signal: ${e})`),we(this,this._packetRW.write.finalize(o))}env(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=Buffer.isBuffer(r),a=o?r.length:Buffer.byteLength(r),c=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(17+i+4+a);f[c]=Se.CHANNEL_REQUEST,P(f,t,++c),P(f,3,c+=4),f.utf8Write("env",c+=4,3),f[c+=3]=s===void 0||s===!0?1:0,P(f,i,++c),f.utf8Write(e,c+=4,i),P(f,a,c+=i),o?f.set(r,c+=4):f.utf8Write(r,c+=4,a),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, env: ${e}=${r})`),we(this,this._packetRW.write.finalize(f))}x11Forward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=e.protocol,i=e.cookie,o=Buffer.isBuffer(s),a=o?s.length:Buffer.byteLength(s),c=Buffer.isBuffer(i),f=c?i.length:Buffer.byteLength(i),l=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(22+a+4+f+4);u[l]=Se.CHANNEL_REQUEST,P(u,t,++l),P(u,7,l+=4),u.utf8Write("x11-req",l+=4,7),u[l+=7]=r===void 0||r===!0?1:0,u[++l]=e.single?1:0,P(u,a,++l),o?u.set(s,l+=4):u.utf8Write(s,l+=4,a),P(u,f,l+=a),c?u.set(i,l+=4):u.latin1Write(i,l+=4,f),P(u,e.screen||0,l+=f),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, x11-req)`),we(this,this._packetRW.write.finalize(u))}subsystem(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+s);o[i]=Se.CHANNEL_REQUEST,P(o,t,++i),P(o,9,i+=4),o.utf8Write("subsystem",i+=4,9),o[i+=9]=r===void 0||r===!0?1:0,P(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, subsystem: ${e})`),we(this,this._packetRW.write.finalize(o))}openssh_agentForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(36);s[r]=Se.CHANNEL_REQUEST,P(s,t,++r),P(s,26,r+=4),s.utf8Write("auth-agent-req@openssh.com",r+=4,26),s[r+=26]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, auth-agent-req@openssh.com)`),we(this,this._packetRW.write.finalize(s))}openssh_hostKeysProve(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,r=[];for(let o of t){let a=o.getPublicSSH();e+=4+a.length,r.push(a)}let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(35+e);i[s]=Se.GLOBAL_REQUEST,P(i,29,++s),i.utf8Write("hostkeys-prove-00@openssh.com",s+=4,29),i[s+=29]=1,++s;for(let o of r)P(i,o.length,s),ys(o,i,0,o.length,s+=4),s+=o.length;this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)"),we(this,this._packetRW.write.finalize(i))}serviceAccept(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);if(s[r]=Se.SERVICE_ACCEPT,P(s,e,++r),s.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_ACCEPT (${t})`),we(this,this._packetRW.write.finalize(s)),this._server&&this._banner&&t==="ssh-userauth"){let i=this._banner;this._banner=void 0;let o=Buffer.byteLength(i);r=this._packetRW.write.allocStart;let a=this._packetRW.write.alloc(5+o+4);a[r]=Se.USERAUTH_BANNER,P(a,o,++r),a.utf8Write(i,r+=4,o),P(a,0,r+=o),this._debug&&this._debug("Outbound: Sending USERAUTH_BANNER"),we(this,this._packetRW.write.finalize(a))}}forwardedTcpip(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.boundAddr),o=Buffer.byteLength(s.remoteAddr),a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(36+i+4+4+o+4);c[a]=Se.CHANNEL_OPEN,P(c,15,++a),c.utf8Write("forwarded-tcpip",a+=4,15),P(c,t,a+=15),P(c,e,a+=4),P(c,r,a+=4),P(c,i,a+=4),c.utf8Write(s.boundAddr,a+=4,i),P(c,s.boundPort,a+=i),P(c,o,a+=4),c.utf8Write(s.remoteAddr,a+=4,o),P(c,s.remotePort,a+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-tcpip)`),we(this,this._packetRW.write.finalize(c))}x11(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.originAddr),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(24+i+4);a[o]=Se.CHANNEL_OPEN,P(a,3,++o),a.utf8Write("x11",o+=4,3),P(a,t,o+=3),P(a,e,o+=4),P(a,r,o+=4),P(a,i,o+=4),a.utf8Write(s.originAddr,o+=4,i),P(a,s.originPort,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, x11)`),we(this,this._packetRW.write.finalize(a))}openssh_authAgent(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(39);i[s]=Se.CHANNEL_OPEN,P(i,22,++s),i.utf8Write("auth-agent@openssh.com",s+=4,22),P(i,t,s+=22),P(i,e,s+=4),P(i,r,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, auth-agent@openssh.com)`),we(this,this._packetRW.write.finalize(i))}openssh_forwardedStreamLocal(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(54+i+4);a[o]=Se.CHANNEL_OPEN,P(a,33,++o),a.utf8Write("forwarded-streamlocal@openssh.com",o+=4,33),P(a,t,o+=33),P(a,e,o+=4),P(a,r,o+=4),P(a,i,o+=4),a.utf8Write(s.socketPath,o+=4,i),P(a,0,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-streamlocal@openssh.com)`),we(this,this._packetRW.write.finalize(a))}exitStatus(t,e){if(!this._server)throw new Error("Server-only method called in client mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(25);s[r]=Se.CHANNEL_REQUEST,P(s,t,++r),P(s,11,r+=4),s.utf8Write("exit-status",r+=4,11),s[r+=11]=0,P(s,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-status: ${e})`),we(this,this._packetRW.write.finalize(s))}exitSignal(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=e;if(typeof i!="string"||!i)throw new Error(`Invalid signal: ${i}`);let o=e.toUpperCase();if(o.slice(0,3)==="SIG"&&(o=o.slice(3)),Df[o]!==1)throw new Error(`Invalid signal: ${i}`);let a=Buffer.byteLength(o),c=s?Buffer.byteLength(s):0,f=this._packetRW.write.allocStart,l=this._packetRW.write.alloc(25+a+1+4+c+4);l[f]=Se.CHANNEL_REQUEST,P(l,t,++f),P(l,11,f+=4),l.utf8Write("exit-signal",f+=4,11),l[f+=11]=0,P(l,a,++f),l.utf8Write(o,f+=4,a),l[f+=a]=r?1:0,P(l,c,++f),f+=4,c&&(l.utf8Write(s,f,c),f+=c),P(l,0,f),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-signal: ${e})`),we(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 s=r.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+s+1);o[i]=Se.USERAUTH_FAILURE,P(o,s,++i),o.utf8Write(r,i+=4,s),o[i+=s]=e===!0?1:0,this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_FAILURE"),we(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]=Se.USERAUTH_SUCCESS,this._authsQueue.shift(),this._authenticated=!0,this._debug&&this._debug("Outbound: Sending USERAUTH_SUCCESS"),we(this,this._packetRW.write.finalize(e)),this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.read=new Kf),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new Vf(this))}authPKOK(t,e){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0||this._authsQueue[0]!=="publickey")throw new Error('"publickey" auth not in progress');let r=Buffer.byteLength(t),s=e.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+r+4+s);o[i]=Se.USERAUTH_PK_OK,P(o,r,++i),o.utf8Write(t,i+=4,r),P(o,s,i+=r),o.set(e,i+=4),this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_PK_OK"),we(this,this._packetRW.write.finalize(o))}authPasswdChg(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4);s[r]=Se.USERAUTH_PASSWD_CHANGEREQ,P(s,e,++r),s.utf8Write(t,r+=4,e),P(s,0,r+=e),this._debug&&this._debug("Outbound: Sending USERAUTH_PASSWD_CHANGEREQ"),we(this,this._packetRW.write.finalize(s))}authInfoReq(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let s=0,i=t?Buffer.byteLength(t):0,o=e?Buffer.byteLength(e):0;for(let f=0;f<r.length;++f)s+=4+Buffer.byteLength(r[f].prompt)+1;let a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(5+i+4+o+4+4+s);c[a]=Se.USERAUTH_INFO_REQUEST,P(c,i,++a),a+=4,t&&(c.utf8Write(t,a,i),a+=i),P(c,o,a),a+=4,e&&(c.utf8Write(e,a,o),a+=o),P(c,0,a),P(c,r.length,a+=4),a+=4;for(let f=0;f<r.length;++f){let l=r[f],u=Buffer.byteLength(l.prompt);P(c,u,a),a+=4,u&&(c.utf8Write(l.prompt,a,u),a+=u),c[a++]=l.echo?1:0}this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_REQUEST"),we(this,this._packetRW.write.finalize(c))}},qg=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function Kg(n,t,e){let r,s;this._buffer?(r=Buffer.allocUnsafe(this._buffer.length+(e-t)),r.set(this._buffer,0),t===0?r.set(n,this._buffer.length):r.set(new Uint8Array(n.buffer,n.byteOffset+t,e-t),this._buffer.length),s=this._buffer.length,t=0):(r=n,s=0);let i=t,o=t,a=t,c=!1,f=0,l=0;for(;t<r.length;++t){let u=r[t];if(u===13){c=!0;continue}if(u===10){if(a>o&&a-o>4&&r[o]===83&&r[o+1]===83&&r[o+2]===72&&r[o+3]===45){let h=r.latin1Slice(i,a+1),p=o===i?h:h.slice(o-i),y=qg.exec(p);if(!y)throw new Error("Invalid identification string");let E={greeting:o===i?"":h.slice(0,o-i),identRaw:p,versions:{protocol:y[1],software:y[2]},comments:y[3]};return this._remoteIdentRaw=Buffer.from(p),this._debug&&this._debug(`Remote ident: ${Hf(p)}`),this._compatFlags=zg(E),this._buffer=void 0,this._decipher=new vg(0,Tg.bind(this,{firstPacket:!0})),this._parse=Vg,this._onHeader(E),this._destruct?(Wf(this),t+1-s):e}if(this._server)throw new Error("Greetings from clients not permitted");if(++l>Qg)throw new Error("Max greeting lines exceeded");c=!1,o=t+1,f=0}else{if(c)throw new Error("Invalid header: expected newline");if(++f>=Hg)throw new Error("Header line too long")}a=t}return this._buffer||(this._buffer=qf(r,i)),t-s}function Vg(n,t,e){return this._decipher.decrypt(n,t,e)}function Gg(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===Se.USERAUTH_SUCCESS&&!this._server&&!this._authenticated&&(this._authenticated=!0,this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.write=new Vf(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new Kf));let e=Lg[t];if(e===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${t}`);return}return e(this,n)}function zg(n){let t=n.versions.software,e=0;for(let r of Bg)typeof r[0]=="string"?t===r[0]&&(e|=r[1]):r[0].test(t)&&(e|=r[1]);return e}function Yg(n){let t=Object.keys(n),e=Buffer.allocUnsafe(5*t.length+1),r=0;for(let s=0;s<t.length;++s){let i=t[s];if(i==="TTY_OP_END")continue;let o=ha[i];if(o===void 0)continue;let a=n[i];typeof a=="number"&&isFinite(a)&&(e[r++]=o,e[r++]=a>>>24,e[r++]=a>>>16,e[r++]=a>>>8,e[r++]=a)}return e[r++]=ha.TTY_OP_END,r<e.length?qf(e,0,r):e}function jg(n){let t="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";Rg&&(t=`ssh-ed25519,${t}`);let e=Buffer.byteLength(t),r=n._packetRW.write.allocStart,s=n._packetRW.write.alloc(28+e);s[r]=Se.EXT_INFO,P(s,1,++r),P(s,15,r+=4),s.utf8Write("server-sig-algs",r+=4,15),P(s,e,r+=15),s.utf8Write(t,r+=4,e),n._debug&&n._debug("Outbound: Sending EXT_INFO"),we(n,n._packetRW.write.finalize(s))}zf.exports=pa});var el=at(yi=>{"use strict";var bs=require("assert"),{inspect:Xg}=require("util");function Yf(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 jf(n,t){if(bs(typeof t=="string","`thing` has to be of type string"),Array.isArray(n)){let e=n.length;return bs(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)}`}yi.ERR_INTERNAL_ASSERTION=class Jf extends Error{constructor(t){super(),Error.captureStackTrace(this,Jf);let e=`This is caused by either a bug in ssh2 or incorrect usage of ssh2 internals.
11
+ `)}else this._hostKeys=void 0;let u=t.offer;typeof u!="object"||u===null?u=this._server?Fg:Mg:u.constructor!==Ff&&(this._server?u.kex=u.kex.concat(["kex-strict-s-v00@openssh.com"]):u.kex=u.kex.concat(["ext-info-c","kex-strict-c-v00@openssh.com"]),u=new Ff(u)),this._kex=void 0,this._strictMode=void 0,this._kexinit=void 0,this._offer=u,this._cipher=new Ug(0,this._onWrite),this._decipher=void 0,this._skipNextInboundPacket=!1,this._packetRW={read:new qg,write:new Kg(this)},this._hostVerifier=!this._server&&typeof t.hostVerifier=="function"?t.hostVerifier:void 0,this._parse=Zg,this._buffer=void 0,this._authsQueue=[],this._authenticated=!1,this._remoteIdentRaw=void 0;let h;if(typeof t.ident=="string")this._identRaw=Buffer.from(`SSH-2.0-${t.ident}`),h=Buffer.allocUnsafe(this._identRaw.length+2),h.set(this._identRaw,0),h[h.length-2]=13,h[h.length-1]=10;else if(Buffer.isBuffer(t.ident)){let p=Buffer.allocUnsafe(8+t.ident.length);p.latin1Write("SSH-2.0-",0,8),p.set(t.ident,8),this._identRaw=p,h=Buffer.allocUnsafe(p.length+2),h.set(p,0),h[h.length-2]=13,h[h.length-1]=10}else this._identRaw=jf,h=zg;this._compatFlags=0,this._debug&&(Lg?this._debug("Custom crypto binding available"):this._debug("Custom crypto binding not available")),this._debug&&this._debug(`Local ident: ${qf(this._identRaw.toString())}`),this.start=()=>{this.start=void 0,l&&this._onWrite(l),this._onWrite(h)}}_destruct(t){this._packetRW.read.cleanup(),this._packetRW.write.cleanup(),this._cipher&&this._cipher.free(),this._decipher&&this._decipher.free(),(typeof t!="string"||t.length===0)&&(t="fatal error"),this.parse=()=>{throw new Error(`Instance unusable after ${t}`)},this._onWrite=()=>{throw new Error(`Instance unusable after ${t}`)},this._destruct=void 0}cleanup(){this._destruct&&this._destruct()}parse(t,e,r){for(;e<r;)e=this._parse(t,e,r)}disconnect(t){let r=this._packetRW.write.allocStartKEX,s=this._packetRW.write.alloc(13,!0),i=r+13;Gg.has(t)||(t=Kf.PROTOCOL_ERROR),s[r]=Se.DISCONNECT,T(s,t,++r),s.fill(0,r+=4,i),this._debug&&this._debug(`Outbound: Sending DISCONNECT (${t})`),we(this,this._packetRW.write.finalize(s,!0),!0)}ping(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(Wf.length);e.set(Wf,t),this._debug&&this._debug("Outbound: Sending ping (GLOBAL_REQUEST: keepalive@openssh.com)"),we(this,this._packetRW.write.finalize(e))}rekey(){this._kexinit===void 0?(this._debug&&this._debug("Outbound: Initiated explicit rekey"),this._queue=[],Vf(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]=Se.REQUEST_SUCCESS,r.set(t,++e)):(r=this._packetRW.write.alloc(1),r[e]=Se.REQUEST_SUCCESS),this._debug&&this._debug("Outbound: Sending REQUEST_SUCCESS"),we(this,this._packetRW.write.finalize(r))}requestFailure(){let t=this._packetRW.write.allocStart,e=this._packetRW.write.alloc(1);e[t]=Se.REQUEST_FAILURE,this._debug&&this._debug("Outbound: Sending REQUEST_FAILURE"),we(this,this._packetRW.write.finalize(e))}channelSuccess(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Se.CHANNEL_SUCCESS,T(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_SUCCESS (r:${t})`),we(this,this._packetRW.write.finalize(r))}channelFailure(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Se.CHANNEL_FAILURE,T(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_FAILURE (r:${t})`),we(this,this._packetRW.write.finalize(r))}channelEOF(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Se.CHANNEL_EOF,T(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_EOF (r:${t})`),we(this,this._packetRW.write.finalize(r))}channelClose(t){let e=this._packetRW.write.allocStart,r=this._packetRW.write.alloc(5);r[e]=Se.CHANNEL_CLOSE,T(r,t,++e),this._debug&&this._debug(`Outbound: Sending CHANNEL_CLOSE (r:${t})`),we(this,this._packetRW.write.finalize(r))}channelWindowAdjust(t,e){let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(9);s[r]=Se.CHANNEL_WINDOW_ADJUST,T(s,t,++r),T(s,e,r+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_WINDOW_ADJUST (r:${t}, ${e})`),we(this,this._packetRW.write.finalize(s))}channelData(t,e){let r=Buffer.isBuffer(e),s=r?e.length:Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(9+s);o[i]=Se.CHANNEL_DATA,T(o,t,++i),T(o,s,i+=4),r?o.set(e,i+=4):o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_DATA (r:${t}, ${s})`),we(this,this._packetRW.write.finalize(o))}channelExtData(t,e,r){let s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(13+i);a[o]=Se.CHANNEL_EXTENDED_DATA,T(a,t,++o),T(a,r,o+=4),T(a,i,o+=4),s?a.set(e,o+=4):a.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_EXTENDED_DATA (r:${t})`),we(this,this._packetRW.write.finalize(a))}channelOpenConfirm(t,e,r,s){let i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(17);o[i]=Se.CHANNEL_OPEN_CONFIRMATION,T(o,t,++i),T(o,e,i+=4),T(o,r,i+=4),T(o,s,i+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_CONFIRMATION (r:${t}, l:${e})`),we(this,this._packetRW.write.finalize(o))}channelOpenFail(t,e,r){typeof r!="string"&&(r="");let s=Buffer.byteLength(r),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(13+s+4);o[i]=Se.CHANNEL_OPEN_FAILURE,T(o,t,++i),T(o,e,i+=4),T(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),T(o,0,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN_FAILURE (r:${t})`),we(this,this._packetRW.write.finalize(o))}service(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);s[r]=Se.SERVICE_REQUEST,T(s,e,++r),s.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_REQUEST (${t})`),we(this,this._packetRW.write.finalize(s))}authPassword(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=r?Buffer.byteLength(r):0,a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(5+s+4+14+4+8+1+4+i+(r?4+o:0));c[a]=Se.USERAUTH_REQUEST,T(c,s,++a),c.utf8Write(t,a+=4,s),T(c,14,a+=s),c.utf8Write("ssh-connection",a+=4,14),T(c,8,a+=14),c.utf8Write("password",a+=4,8),c[a+=8]=r?1:0,T(c,i,++a),Buffer.isBuffer(e)?Ss(e,c,0,i,a+=4):c.utf8Write(e,a+=4,i),r?(T(c,o,a+=i),Buffer.isBuffer(r)?Ss(r,c,0,o,a+=4):c.utf8Write(r,a+=4,o),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (changed password)")):this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (password)"),this._authsQueue.push("password"),we(this,this._packetRW.write.finalize(c))}authPK(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");if(e=Hf(e),e instanceof Error)throw new Error("Invalid key");let i=e.type;e=e.getPublicSSH(),typeof r=="function"&&(s=r,r=void 0),r||(r=i);let o=Buffer.byteLength(t),a=Buffer.byteLength(r),c=e.length,f=this._kex.sessionID,l=f.length,u=(s?4+l:0)+1+4+o+4+14+4+9+1+4+a+4+c,h,p;if(s?(h=Buffer.allocUnsafe(u),p=0,T(h,l,p),h.set(f,p+=4),p+=l):(h=this._packetRW.write.alloc(u),p=this._packetRW.write.allocStart),h[p]=Se.USERAUTH_REQUEST,T(h,o,++p),h.utf8Write(t,p+=4,o),T(h,14,p+=o),h.utf8Write("ssh-connection",p+=4,14),T(h,9,p+=14),h.utf8Write("publickey",p+=4,9),h[p+=9]=s?1:0,T(h,a,++p),h.utf8Write(r,p+=4,a),T(h,c,p+=a),h.set(e,p+=4),!s){this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),we(this,this._packetRW.write.finalize(h));return}s(h,y=>{if(y=Qf(y,i),y===!1)throw new Error("Error while converting handshake signature");let E=y.length;p=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(5+o+4+14+4+9+1+4+a+4+c+4+4+a+4+E),h[p]=Se.USERAUTH_REQUEST,T(h,o,++p),h.utf8Write(t,p+=4,o),T(h,14,p+=o),h.utf8Write("ssh-connection",p+=4,14),T(h,9,p+=14),h.utf8Write("publickey",p+=4,9),h[p+=9]=1,T(h,a,++p),h.utf8Write(r,p+=4,a),T(h,c,p+=a),h.set(e,p+=4),T(h,4+a+4+E,p+=c),T(h,a,p+=4),h.utf8Write(r,p+=4,a),T(h,E,p+=a),h.set(y,p+=4),this._authsQueue.push("publickey"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (publickey)"),we(this,this._packetRW.write.finalize(h))})}authHostbased(t,e,r,s,i,o){if(this._server)throw new Error("Client-only method called in server mode");if(e=Hf(e),e instanceof Error)throw new Error("Invalid key");let a=e.type;e=e.getPublicSSH(),typeof i=="function"&&(o=i,i=void 0),i||(i=a);let c=Buffer.byteLength(t),f=Buffer.byteLength(i),l=e.length,u=this._kex.sessionID,h=u.length,p=Buffer.byteLength(r),y=Buffer.byteLength(s),E=Buffer.allocUnsafe(4+h+1+4+c+4+14+4+9+4+f+4+l+4+p+4+y),b=0;T(E,h,b),E.set(u,b+=4),E[b+=h]=Se.USERAUTH_REQUEST,T(E,c,++b),E.utf8Write(t,b+=4,c),T(E,14,b+=c),E.utf8Write("ssh-connection",b+=4,14),T(E,9,b+=14),E.utf8Write("hostbased",b+=4,9),T(E,f,b+=9),E.utf8Write(i,b+=4,f),T(E,l,b+=f),E.set(e,b+=4),T(E,p,b+=l),E.utf8Write(r,b+=4,p),T(E,y,b+=p),E.utf8Write(s,b+=4,y),o(E,C=>{if(C=Qf(C,a),!C)throw new Error("Error while converting handshake signature");let N=C.length,H=E.length-h-4;b=this._packetRW.write.allocStart;let v=this._packetRW.write.alloc(H+4+4+f+4+N);Ss(E,v,4+h,E.length,b),T(v,4+f+4+N,b+=H),T(v,f,b+=4),v.utf8Write(i,b+=4,f),T(v,N,b+=f),v.set(C,b+=4),this._authsQueue.push("hostbased"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (hostbased)"),we(this,this._packetRW.write.finalize(v))})}authKeyboard(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4+14+4+20+4+4);s[r]=Se.USERAUTH_REQUEST,T(s,e,++r),s.utf8Write(t,r+=4,e),T(s,14,r+=e),s.utf8Write("ssh-connection",r+=4,14),T(s,20,r+=14),s.utf8Write("keyboard-interactive",r+=4,20),T(s,0,r+=20),T(s,0,r+=4),this._authsQueue.push("keyboard-interactive"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (keyboard-interactive)"),we(this,this._packetRW.write.finalize(s))}authNone(t){if(this._server)throw new Error("Client-only method called in server mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4+14+4+4);s[r]=Se.USERAUTH_REQUEST,T(s,e,++r),s.utf8Write(t,r+=4,e),T(s,14,r+=e),s.utf8Write("ssh-connection",r+=4,14),T(s,4,r+=14),s.utf8Write("none",r+=4,4),this._authsQueue.push("none"),this._debug&&this._debug("Outbound: Sending USERAUTH_REQUEST (none)"),we(this,this._packetRW.write.finalize(s))}authInfoRes(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,r;if(t){r=new Array(t.length);for(let o=0;o<t.length;++o){let a=Buffer.byteLength(t[o]);r[o]=a,e+=4+a}}let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(5+e);if(i[s]=Se.USERAUTH_INFO_RESPONSE,t){T(i,t.length,++s),s+=4;for(let o=0;o<t.length;++o){let a=r[o];T(i,a,s),s+=4,a&&(i.utf8Write(t[o],s,a),s+=a)}}else T(i,0,++s);this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_RESPONSE"),we(this,this._packetRW.write.finalize(i))}tcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+s+4);o[i]=Se.GLOBAL_REQUEST,T(o,13,++i),o.utf8Write("tcpip-forward",i+=4,13),o[i+=13]=r===void 0||r===!0?1:0,T(o,s,++i),o.utf8Write(t,i+=4,s),T(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (tcpip-forward)"),we(this,this._packetRW.write.finalize(o))}cancelTcpipForward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(30+s+4);o[i]=Se.GLOBAL_REQUEST,T(o,20,++i),o.utf8Write("cancel-tcpip-forward",i+=4,20),o[i+=20]=r===void 0||r===!0?1:0,T(o,s,++i),o.utf8Write(t,i+=4,s),T(o,e,i+=s),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-tcpip-forward)"),we(this,this._packetRW.write.finalize(o))}openssh_streamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(41+r);i[s]=Se.GLOBAL_REQUEST,T(i,31,++s),i.utf8Write("streamlocal-forward@openssh.com",s+=4,31),i[s+=31]=e===void 0||e===!0?1:0,T(i,r,++s),i.utf8Write(t,s+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (streamlocal-forward@openssh.com)"),we(this,this._packetRW.write.finalize(i))}openssh_cancelStreamLocalForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(48+r);i[s]=Se.GLOBAL_REQUEST,T(i,38,++s),i.utf8Write("cancel-streamlocal-forward@openssh.com",s+=4,38),i[s+=38]=e===void 0||e===!0?1:0,T(i,r,++s),i.utf8Write(t,s+=4,r),this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (cancel-streamlocal-forward@openssh.com)"),we(this,this._packetRW.write.finalize(i))}directTcpip(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(s.srcIP),o=Buffer.byteLength(s.dstIP),a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(33+i+4+4+o+4);c[a]=Se.CHANNEL_OPEN,T(c,12,++a),c.utf8Write("direct-tcpip",a+=4,12),T(c,t,a+=12),T(c,e,a+=4),T(c,r,a+=4),T(c,o,a+=4),c.utf8Write(s.dstIP,a+=4,o),T(c,s.dstPort,a+=o),T(c,i,a+=4),c.utf8Write(s.srcIP,a+=4,i),T(c,s.srcPort,a+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-tcpip)`),we(this,this._packetRW.write.finalize(c))}openssh_directStreamLocal(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(s.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(51+i+4+4);a[o]=Se.CHANNEL_OPEN,T(a,30,++o),a.utf8Write("direct-streamlocal@openssh.com",o+=4,30),T(a,t,o+=30),T(a,e,o+=4),T(a,r,o+=4),T(a,i,o+=4),a.utf8Write(s.socketPath,o+=4,i),Wg(a,0,o+=i,o+8),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, direct-streamlocal@openssh.com)`),we(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]=Se.GLOBAL_REQUEST,T(r,28,++e),r.utf8Write("no-more-sessions@openssh.com",e+=4,28),r[e+=28]=t===void 0||t===!0?1:0,this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (no-more-sessions@openssh.com)"),we(this,this._packetRW.write.finalize(r))}session(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(24);i[s]=Se.CHANNEL_OPEN,T(i,7,++s),i.utf8Write("session",s+=4,7),T(i,t,s+=7),T(i,e,s+=4),T(i,r,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, session)`),we(this,this._packetRW.write.finalize(i))}windowChange(t,e,r,s,i){if(this._server)throw new Error("Client-only method called in server mode");let o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(39);a[o]=Se.CHANNEL_REQUEST,T(a,t,++o),T(a,13,o+=4),a.utf8Write("window-change",o+=4,13),a[o+=13]=0,T(a,r,++o),T(a,e,o+=4),T(a,i,o+=4),T(a,s,o+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, window-change)`),we(this,this._packetRW.write.finalize(a))}pty(t,e,r,s,i,o,a,c){if(this._server)throw new Error("Client-only method called in server mode");(!o||!o.length)&&(o="vt100"),a&&!Buffer.isBuffer(a)&&!Array.isArray(a)&&typeof a=="object"&&a!==null&&(a=rm(a)),(!a||!a.length)&&(a=Xg);let f=o.length,l=a.length,u=this._packetRW.write.allocStart,h=this._packetRW.write.alloc(21+f+4+4+4+4+4+l);if(h[u]=Se.CHANNEL_REQUEST,T(h,t,++u),T(h,7,u+=4),h.utf8Write("pty-req",u+=4,7),h[u+=7]=c===void 0||c===!0?1:0,T(h,f,++u),h.utf8Write(o,u+=4,f),T(h,r,u+=f),T(h,e,u+=4),T(h,i,u+=4),T(h,s,u+=4),T(h,l,u+=4),u+=4,Array.isArray(a))for(let p=0;p<l;++p)h[u++]=a[p];else Buffer.isBuffer(a)&&h.set(a,u);this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, pty-req)`),we(this,this._packetRW.write.finalize(h))}shell(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(15);s[r]=Se.CHANNEL_REQUEST,T(s,t,++r),T(s,5,r+=4),s.utf8Write("shell",r+=4,5),s[r+=5]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, shell)`),we(this,this._packetRW.write.finalize(s))}exec(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.isBuffer(e),i=s?e.length:Buffer.byteLength(e),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(18+i);a[o]=Se.CHANNEL_REQUEST,T(a,t,++o),T(a,4,o+=4),a.utf8Write("exec",o+=4,4),a[o+=4]=r===void 0||r===!0?1:0,T(a,i,++o),s?a.set(e,o+=4):a.utf8Write(e,o+=4,i),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exec: ${e})`),we(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)),Mf[e]!==1)throw new Error(`Invalid signal: ${r}`);let s=e.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(20+s);o[i]=Se.CHANNEL_REQUEST,T(o,t,++i),T(o,6,i+=4),o.utf8Write("signal",i+=4,6),o[i+=6]=0,T(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, signal: ${e})`),we(this,this._packetRW.write.finalize(o))}env(t,e,r,s){if(this._server)throw new Error("Client-only method called in server mode");let i=Buffer.byteLength(e),o=Buffer.isBuffer(r),a=o?r.length:Buffer.byteLength(r),c=this._packetRW.write.allocStart,f=this._packetRW.write.alloc(17+i+4+a);f[c]=Se.CHANNEL_REQUEST,T(f,t,++c),T(f,3,c+=4),f.utf8Write("env",c+=4,3),f[c+=3]=s===void 0||s===!0?1:0,T(f,i,++c),f.utf8Write(e,c+=4,i),T(f,a,c+=i),o?f.set(r,c+=4):f.utf8Write(r,c+=4,a),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, env: ${e}=${r})`),we(this,this._packetRW.write.finalize(f))}x11Forward(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=e.protocol,i=e.cookie,o=Buffer.isBuffer(s),a=o?s.length:Buffer.byteLength(s),c=Buffer.isBuffer(i),f=c?i.length:Buffer.byteLength(i),l=this._packetRW.write.allocStart,u=this._packetRW.write.alloc(22+a+4+f+4);u[l]=Se.CHANNEL_REQUEST,T(u,t,++l),T(u,7,l+=4),u.utf8Write("x11-req",l+=4,7),u[l+=7]=r===void 0||r===!0?1:0,u[++l]=e.single?1:0,T(u,a,++l),o?u.set(s,l+=4):u.utf8Write(s,l+=4,a),T(u,f,l+=a),c?u.set(i,l+=4):u.latin1Write(i,l+=4,f),T(u,e.screen||0,l+=f),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, x11-req)`),we(this,this._packetRW.write.finalize(u))}subsystem(t,e,r){if(this._server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(23+s);o[i]=Se.CHANNEL_REQUEST,T(o,t,++i),T(o,9,i+=4),o.utf8Write("subsystem",i+=4,9),o[i+=9]=r===void 0||r===!0?1:0,T(o,s,++i),o.utf8Write(e,i+=4,s),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, subsystem: ${e})`),we(this,this._packetRW.write.finalize(o))}openssh_agentForward(t,e){if(this._server)throw new Error("Client-only method called in server mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(36);s[r]=Se.CHANNEL_REQUEST,T(s,t,++r),T(s,26,r+=4),s.utf8Write("auth-agent-req@openssh.com",r+=4,26),s[r+=26]=e===void 0||e===!0?1:0,this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, auth-agent-req@openssh.com)`),we(this,this._packetRW.write.finalize(s))}openssh_hostKeysProve(t){if(this._server)throw new Error("Client-only method called in server mode");let e=0,r=[];for(let o of t){let a=o.getPublicSSH();e+=4+a.length,r.push(a)}let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(35+e);i[s]=Se.GLOBAL_REQUEST,T(i,29,++s),i.utf8Write("hostkeys-prove-00@openssh.com",s+=4,29),i[s+=29]=1,++s;for(let o of r)T(i,o.length,s),Ss(o,i,0,o.length,s+=4),s+=o.length;this._debug&&this._debug("Outbound: Sending GLOBAL_REQUEST (hostkeys-prove-00@openssh.com)"),we(this,this._packetRW.write.finalize(i))}serviceAccept(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e);if(s[r]=Se.SERVICE_ACCEPT,T(s,e,++r),s.utf8Write(t,r+=4,e),this._debug&&this._debug(`Outbound: Sending SERVICE_ACCEPT (${t})`),we(this,this._packetRW.write.finalize(s)),this._server&&this._banner&&t==="ssh-userauth"){let i=this._banner;this._banner=void 0;let o=Buffer.byteLength(i);r=this._packetRW.write.allocStart;let a=this._packetRW.write.alloc(5+o+4);a[r]=Se.USERAUTH_BANNER,T(a,o,++r),a.utf8Write(i,r+=4,o),T(a,0,r+=o),this._debug&&this._debug("Outbound: Sending USERAUTH_BANNER"),we(this,this._packetRW.write.finalize(a))}}forwardedTcpip(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.boundAddr),o=Buffer.byteLength(s.remoteAddr),a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(36+i+4+4+o+4);c[a]=Se.CHANNEL_OPEN,T(c,15,++a),c.utf8Write("forwarded-tcpip",a+=4,15),T(c,t,a+=15),T(c,e,a+=4),T(c,r,a+=4),T(c,i,a+=4),c.utf8Write(s.boundAddr,a+=4,i),T(c,s.boundPort,a+=i),T(c,o,a+=4),c.utf8Write(s.remoteAddr,a+=4,o),T(c,s.remotePort,a+=o),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-tcpip)`),we(this,this._packetRW.write.finalize(c))}x11(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.originAddr),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(24+i+4);a[o]=Se.CHANNEL_OPEN,T(a,3,++o),a.utf8Write("x11",o+=4,3),T(a,t,o+=3),T(a,e,o+=4),T(a,r,o+=4),T(a,i,o+=4),a.utf8Write(s.originAddr,o+=4,i),T(a,s.originPort,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, x11)`),we(this,this._packetRW.write.finalize(a))}openssh_authAgent(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let s=this._packetRW.write.allocStart,i=this._packetRW.write.alloc(39);i[s]=Se.CHANNEL_OPEN,T(i,22,++s),i.utf8Write("auth-agent@openssh.com",s+=4,22),T(i,t,s+=22),T(i,e,s+=4),T(i,r,s+=4),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, auth-agent@openssh.com)`),we(this,this._packetRW.write.finalize(i))}openssh_forwardedStreamLocal(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=Buffer.byteLength(s.socketPath),o=this._packetRW.write.allocStart,a=this._packetRW.write.alloc(54+i+4);a[o]=Se.CHANNEL_OPEN,T(a,33,++o),a.utf8Write("forwarded-streamlocal@openssh.com",o+=4,33),T(a,t,o+=33),T(a,e,o+=4),T(a,r,o+=4),T(a,i,o+=4),a.utf8Write(s.socketPath,o+=4,i),T(a,0,o+=i),this._debug&&this._debug(`Outbound: Sending CHANNEL_OPEN (r:${t}, forwarded-streamlocal@openssh.com)`),we(this,this._packetRW.write.finalize(a))}exitStatus(t,e){if(!this._server)throw new Error("Server-only method called in client mode");let r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(25);s[r]=Se.CHANNEL_REQUEST,T(s,t,++r),T(s,11,r+=4),s.utf8Write("exit-status",r+=4,11),s[r+=11]=0,T(s,e,++r),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-status: ${e})`),we(this,this._packetRW.write.finalize(s))}exitSignal(t,e,r,s){if(!this._server)throw new Error("Server-only method called in client mode");let i=e;if(typeof i!="string"||!i)throw new Error(`Invalid signal: ${i}`);let o=e.toUpperCase();if(o.slice(0,3)==="SIG"&&(o=o.slice(3)),Mf[o]!==1)throw new Error(`Invalid signal: ${i}`);let a=Buffer.byteLength(o),c=s?Buffer.byteLength(s):0,f=this._packetRW.write.allocStart,l=this._packetRW.write.alloc(25+a+1+4+c+4);l[f]=Se.CHANNEL_REQUEST,T(l,t,++f),T(l,11,f+=4),l.utf8Write("exit-signal",f+=4,11),l[f+=11]=0,T(l,a,++f),l.utf8Write(o,f+=4,a),l[f+=a]=r?1:0,T(l,c,++f),f+=4,c&&(l.utf8Write(s,f,c),f+=c),T(l,0,f),this._debug&&this._debug(`Outbound: Sending CHANNEL_REQUEST (r:${t}, exit-signal: ${e})`),we(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 s=r.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+s+1);o[i]=Se.USERAUTH_FAILURE,T(o,s,++i),o.utf8Write(r,i+=4,s),o[i+=s]=e===!0?1:0,this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_FAILURE"),we(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]=Se.USERAUTH_SUCCESS,this._authsQueue.shift(),this._authenticated=!0,this._debug&&this._debug("Outbound: Sending USERAUTH_SUCCESS"),we(this,this._packetRW.write.finalize(e)),this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.read=new zf),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.write=new Yf(this))}authPKOK(t,e){if(!this._server)throw new Error("Server-only method called in client mode");if(this._authsQueue.length===0||this._authsQueue[0]!=="publickey")throw new Error('"publickey" auth not in progress');let r=Buffer.byteLength(t),s=e.length,i=this._packetRW.write.allocStart,o=this._packetRW.write.alloc(5+r+4+s);o[i]=Se.USERAUTH_PK_OK,T(o,r,++i),o.utf8Write(t,i+=4,r),T(o,s,i+=r),o.set(e,i+=4),this._authsQueue.shift(),this._debug&&this._debug("Outbound: Sending USERAUTH_PK_OK"),we(this,this._packetRW.write.finalize(o))}authPasswdChg(t){if(!this._server)throw new Error("Server-only method called in client mode");let e=Buffer.byteLength(t),r=this._packetRW.write.allocStart,s=this._packetRW.write.alloc(5+e+4);s[r]=Se.USERAUTH_PASSWD_CHANGEREQ,T(s,e,++r),s.utf8Write(t,r+=4,e),T(s,0,r+=e),this._debug&&this._debug("Outbound: Sending USERAUTH_PASSWD_CHANGEREQ"),we(this,this._packetRW.write.finalize(s))}authInfoReq(t,e,r){if(!this._server)throw new Error("Server-only method called in client mode");let s=0,i=t?Buffer.byteLength(t):0,o=e?Buffer.byteLength(e):0;for(let f=0;f<r.length;++f)s+=4+Buffer.byteLength(r[f].prompt)+1;let a=this._packetRW.write.allocStart,c=this._packetRW.write.alloc(5+i+4+o+4+4+s);c[a]=Se.USERAUTH_INFO_REQUEST,T(c,i,++a),a+=4,t&&(c.utf8Write(t,a,i),a+=i),T(c,o,a),a+=4,e&&(c.utf8Write(e,a,o),a+=o),T(c,0,a),T(c,r.length,a+=4),a+=4;for(let f=0;f<r.length;++f){let l=r[f],u=Buffer.byteLength(l.prompt);T(c,u,a),a+=4,u&&(c.utf8Write(l.prompt,a,u),a+=u),c[a++]=l.echo?1:0}this._debug&&this._debug("Outbound: Sending USERAUTH_INFO_REQUEST"),we(this,this._packetRW.write.finalize(c))}},Jg=/^SSH-(2\.0|1\.99)-([^ ]+)(?: (.*))?$/;function Zg(n,t,e){let r,s;this._buffer?(r=Buffer.allocUnsafe(this._buffer.length+(e-t)),r.set(this._buffer,0),t===0?r.set(n,this._buffer.length):r.set(new Uint8Array(n.buffer,n.byteOffset+t,e-t),this._buffer.length),s=this._buffer.length,t=0):(r=n,s=0);let i=t,o=t,a=t,c=!1,f=0,l=0;for(;t<r.length;++t){let u=r[t];if(u===13){c=!0;continue}if(u===10){if(a>o&&a-o>4&&r[o]===83&&r[o+1]===83&&r[o+2]===72&&r[o+3]===45){let h=r.latin1Slice(i,a+1),p=o===i?h:h.slice(o-i),y=Jg.exec(p);if(!y)throw new Error("Invalid identification string");let E={greeting:o===i?"":h.slice(0,o-i),identRaw:p,versions:{protocol:y[1],software:y[2]},comments:y[3]};return this._remoteIdentRaw=Buffer.from(p),this._debug&&this._debug(`Remote ident: ${qf(p)}`),this._compatFlags=nm(E),this._buffer=void 0,this._decipher=new Dg(0,Hg.bind(this,{firstPacket:!0})),this._parse=em,this._onHeader(E),this._destruct?(Vf(this),t+1-s):e}if(this._server)throw new Error("Greetings from clients not permitted");if(++l>jg)throw new Error("Max greeting lines exceeded");c=!1,o=t+1,f=0}else{if(c)throw new Error("Invalid header: expected newline");if(++f>=Yg)throw new Error("Header line too long")}a=t}return this._buffer||(this._buffer=Gf(r,i)),t-s}function em(n,t,e){return this._decipher.decrypt(n,t,e)}function tm(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===Se.USERAUTH_SUCCESS&&!this._server&&!this._authenticated&&(this._authenticated=!0,this._kex.negotiated.cs.compress==="zlib@openssh.com"&&(this._packetRW.write=new Yf(this)),this._kex.negotiated.sc.compress==="zlib@openssh.com"&&(this._packetRW.read=new zf));let e=Qg[t];if(e===void 0){this._debug&&this._debug(`Inbound: Unsupported message type: ${t}`);return}return e(this,n)}function nm(n){let t=n.versions.software,e=0;for(let r of $g)typeof r[0]=="string"?t===r[0]&&(e|=r[1]):r[0].test(t)&&(e|=r[1]);return e}function rm(n){let t=Object.keys(n),e=Buffer.allocUnsafe(5*t.length+1),r=0;for(let s=0;s<t.length;++s){let i=t[s];if(i==="TTY_OP_END")continue;let o=Aa[i];if(o===void 0)continue;let a=n[i];typeof a=="number"&&isFinite(a)&&(e[r++]=o,e[r++]=a>>>24,e[r++]=a>>>16,e[r++]=a>>>8,e[r++]=a)}return e[r++]=Aa.TTY_OP_END,r<e.length?Gf(e,0,r):e}function im(n){let t="ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss";Og&&(t=`ssh-ed25519,${t}`);let e=Buffer.byteLength(t),r=n._packetRW.write.allocStart,s=n._packetRW.write.alloc(28+e);s[r]=Se.EXT_INFO,T(s,1,++r),T(s,15,r+=4),s.utf8Write("server-sig-algs",r+=4,15),T(s,e,r+=15),s.utf8Write(t,r+=4,e),n._debug&&n._debug("Outbound: Sending EXT_INFO"),we(n,n._packetRW.write.finalize(s))}Xf.exports=Ea});var rl=ct(bi=>{"use strict";var ws=require("assert"),{inspect:sm}=require("util");function Jf(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 Zf(n,t){if(ws(typeof t=="string","`thing` has to be of type string"),Array.isArray(n)){let e=n.length;return ws(e>0,"At least one expected value needs to be specified"),n=n.map(r=>String(r)),e>2?`one of ${t} ${n.slice(0,e-1).join(", ")}, or `+n[e-1]:e===2?`one of ${t} ${n[0]} or ${n[1]}`:`of ${t} ${n[0]}`}return`of ${t} ${String(n)}`}bi.ERR_INTERNAL_ASSERTION=class tl extends Error{constructor(t){super(),Error.captureStackTrace(this,tl);let e=`This is caused by either a bug in ssh2 or incorrect usage of ssh2 internals.
12
12
  Please open an issue with this stack trace at https://github.com/mscdex/ssh2/issues
13
13
  `;this.message=t===void 0?e:`${t}
14
- ${e}`}};var Jg=2**32,Xf=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();yi.ERR_OUT_OF_RANGE=class Zf extends RangeError{constructor(t,e,r,s){super(),Error.captureStackTrace(this,Zf),bs(e,'Missing "range" argument');let i=s?t:`The value of "${t}" is out of range.`,o;Number.isInteger(r)&&Math.abs(r)>Jg?o=Yf(String(r)):typeof r=="bigint"?(o=String(r),(r>Xf||r<-Xf)&&(o=Yf(o)),o+="n"):o=Xg(r),i+=` It must be ${e}. Received ${o}`,this.message=i}};var xs=class n extends TypeError{constructor(t,e,r){super(),Error.captureStackTrace(this,n),bs(typeof t=="string","'name' must be a string");let s;typeof e=="string"&&e.startsWith("not ")?(s="must not be",e=e.replace(/^not /,"")):s="must be";let i;if(t.endsWith(" argument"))i=`The ${t} ${s} ${jf(e,"type")}`;else{let o=t.includes(".")?"property":"argument";i=`The "${t}" ${o} ${s} ${jf(e,"type")}`}i+=`. Received type ${typeof r}`,this.message=i}};yi.ERR_INVALID_ARG_TYPE=xs;yi.validateNumber=function(t,e){if(typeof t!="number")throw new xs(e,"number",t)}});var bi=at((OE,hl)=>{"use strict";var Zg=require("events"),Gn=require("fs"),{constants:Jt}=Gn,{Readable:ol,Writable:wa}=require("stream"),{inherits:al,types:{isDate:Ea}}=require("util"),e0=Buffer[Symbol.species],{bufferCopy:Vn,bufferSlice:$r,makeBufferParser:t0,writeUInt32BE:K}=hn(),Un={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},Re=Buffer.alloc(28),et={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},n0=new Map(Object.values(et).map(n=>[n,1])),r0={[et.OK]:"No error",[et.EOF]:"End of file",[et.NO_SUCH_FILE]:"No such file or directory",[et.PERMISSION_DENIED]:"Permission denied",[et.FAILURE]:"Failure",[et.BAD_MESSAGE]:"Bad message",[et.NO_CONNECTION]:"No connection",[et.CONNECTION_LOST]:"Connection lost",[et.OP_UNSUPPORTED]:"Operation unsupported"},ve={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},Zt={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},Ie={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},tl=2*1024,lt=2**32-1,i0=Buffer.from([0,0,0,5,ve.INIT,0,0,0,3]),s0=Buffer.from([0,0,0,5,Zt.VERSION,0,0,0,3]),o0=/^SSH-2.0-(?:OpenSSH|dropbear)/,ma=256*1024,O=t0(),a0={readable:!1,writable:!1,push:n=>{},once:()=>{},on:()=>{},emit:()=>{},end:()=>{}};function cl(){}var _a=class extends Zg{constructor(t,e,r){super(),(typeof r!="object"||!r)&&(r={});let s=t._protocol._remoteIdentRaw;this.server=!!r.server,this._debug=typeof r.debug=="function"?r.debug:void 0,this._isOpenSSH=s&&o0.test(s),this._version=-1,this._extensions={},this._biOpt=r.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=ma,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?ma:34e3)-tl,this._maxWriteLen=(this._isOpenSSH?ma:34e3)-tl,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=a0,this.readable=!0}push(t){if(t===null){if(dl(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 it(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return it(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 e0(t.buffer,t.byteOffset+e,o):(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._pktPos)):o===this._pktLen?this._pkt=t:(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(t,this._pktPos)),e+=o,this._pktPos+=o,this._pktPos<this._pktLen)return}let r=this._pkt[0],s=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let i=this.server?d0[r]:u0[r];if(!i)return it(this,`Unknown packet type ${r}`);if(this._version===-1){if(this.server){if(r!==ve.INIT)return it(this,`Expected INIT packet, got ${r}`)}else if(r!==Zt.VERSION)return it(this,`Expected VERSION packet, got ${r}`)}if(i(this,s)===!1)return}}end(){this.destroy()}destroy(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._protocol.channelClose(this.outgoing.id))}_init(){this._init=cl,this.server||Xe(this,i0)}createReadStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new Dn(this,t,e)}createWriteStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new dn(this,t,e)}open(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(s=r,r=void 0);let i=typeof e=="number"?e:ll(e);if(i===null)throw new Error(`Unknown flags string: ${e}`);let o=0,a=0;(typeof r=="string"||typeof r=="number")&&(r={mode:r}),typeof r=="object"&&r!==null&&(r=cr(r),o=r.flags,a=r.nb);let c=Buffer.byteLength(t),f=9,l=Buffer.allocUnsafe(13+c+4+4+a);K(l,l.length-4,0),l[4]=ve.OPEN;let u=this._writeReqid=this._writeReqid+1&lt;K(l,u,5),K(l,c,f),l.utf8Write(t,f+=4,c),K(l,i,f+=c),K(l,o,f+=4),a&&(f+=4,a===Re.length?l.set(Re,f):Vn(Re,l,0,a,f),f+=a),this._requests[u]={cb:s};let h=Xe(this,l);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} OPEN`)}close(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=ve.CLOSE;let o=this._writeReqid=this._writeReqid+1&lt;K(i,o,5),K(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} CLOSE`)}read(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>=e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");fl(this,t,e,r,s,i,o)}readData(t,e,r,s,i,o){this.read(t,e,r,s,i,o)}write(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");if(!s){o&&process.nextTick(o,void 0,0);return}let a=this._maxWriteLen,c=Math.max(s-a,0),f=i;c&&(s=a);let l=t.length,u=9,h=Buffer.allocUnsafe(13+l+8+4+s);K(h,h.length-4,0),h[4]=ve.WRITE;let p=this._writeReqid=this._writeReqid+1&lt;K(h,p,5),K(h,l,u),h.set(t,u+=4),u+=l;for(let E=7;E>=0;--E)h[u+E]=i&255,i/=256;K(h,s,u+=8),Vn(e,h,r,r+s,u+=4),this._requests[p]={cb:E=>{E?typeof o=="function"&&o(E):c?this.write(t,e,r+s,c,f+s,o):typeof o=="function"&&o(void 0,r+s)}};let y=Xe(this,h);if(this._debug){let E=y?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${E} WRITE (id:${p})`)}}writeData(t,e,r,s,i,o){this.write(t,e,r,s,i,o)}fastGet(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");nl(this,Gn,t,e,r,s)}fastPut(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");nl(Gn,this,t,e,r,s)}readFile(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof r=="function"?s=r:typeof e=="function"&&(s=e,e=void 0),typeof e=="string")e={encoding:e,flag:"r"};else if(!e)e={encoding:null,flag:"r"};else if(typeof e!="object")throw new TypeError("Bad arguments");let i=e.encoding;if(i&&!Buffer.isEncoding(i))throw new Error(`Unknown encoding: ${i}`);let o,a,c,f=0,l,u=0,h=e.flag||"r",p=()=>{o===0?(a=Buffer.allocUnsafe(8192),this.read(l,a,0,8192,u,y)):this.read(l,a,f,o-f,u,y)},y=(x,k)=>{let D;if(x){if(D=x.code===et.EOF,!D)return this.close(l,()=>s&&s(x))}else D=!1;if(D||o===0&&k===0)return E();u+=k,f+=k,o!==0?f===o?E():p():(c.push($r(a,0,k)),p())};y._wantEOFError=!0;let E=()=>{this.close(l,x=>(o===0?a=Buffer.concat(c,f):f<o&&(a=$r(a,0,f)),i&&(a=a.toString(i)),s&&s(x,a)))};this.open(t,h,438,(x,k)=>{if(x)return s&&s(x);l=k;let D=(H,C)=>{if(H){this.stat(t,(F,V)=>{if(F)return this.close(l,()=>{s&&s(H)});D(null,V)});return}if(o=C.size||0,o===0)return c=[],p();a=Buffer.allocUnsafe(o),p()};this.fstat(l,D)})}writeFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"w"};else if(!r)r={encoding:"utf8",mode:438,flag:"w"};else if(typeof r!="object")throw new TypeError("Bad arguments");if(r.encoding&&!Buffer.isEncoding(r.encoding))throw new Error(`Unknown encoding: ${r.encoding}`);let o=r.flag||"w";this.open(t,o,r.mode,(a,c)=>{if(a)i&&i(a);else{let f=Buffer.isBuffer(e)?e:Buffer.from(""+e,r.encoding||"utf8"),l=/a/.test(o)?null:0;if(l===null){let u=(h,p)=>{if(h){this.stat(t,(y,E)=>{if(y)return this.close(c,()=>{i&&i(h)});u(null,E)});return}ya(this,c,f,0,f.length,p.size,i)};this.fstat(c,u);return}ya(this,c,f,0,f.length,l,i)}})}appendFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"a"};else if(!r)r={encoding:"utf8",mode:438,flag:"a"};else if(typeof r!="object")throw new TypeError("Bad arguments");r.flag||(r=Object.assign({flag:"a"},r)),this.writeFile(t,e,r,i)}exists(t,e){if(this.server)throw new Error("Client-only method called in server mode");this.stat(t,r=>{e&&e(!r)})}unlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=ve.REMOVE;let o=this._writeReqid=this._writeReqid+1&lt;K(i,o,5),K(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REMOVE`)}rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=9,a=Buffer.allocUnsafe(13+s+4+i);K(a,a.length-4,0),a[4]=ve.RENAME;let c=this._writeReqid=this._writeReqid+1&lt;K(a,c,5),K(a,s,o),a.utf8Write(t,o+=4,s),K(a,i,o+=s),a.utf8Write(e,o+=4,i),this._requests[c]={cb:r};let f=Xe(this,a);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} RENAME`)}mkdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="function"&&(r=e,e=void 0),typeof e=="object"&&e!==null&&(e=cr(e),s=e.flags,i=e.nb);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);K(c,c.length-4,0),c[4]=ve.MKDIR;let f=this._writeReqid=this._writeReqid+1&lt;K(c,f,5),K(c,o,a),c.utf8Write(t,a+=4,o),K(c,s,a+=o),i&&(a+=4,i===Re.length?c.set(Re,a):Vn(Re,c,0,i,a),a+=i),this._requests[f]={cb:r};let l=Xe(this,c);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),s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=ve.RMDIR;let o=this._writeReqid=this._writeReqid+1&lt;K(i,o,5),K(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} RMDIR`)}readdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");typeof e=="function"&&(r=e,e={}),(typeof e!="object"||e===null)&&(e={});let s=!(e&&e.full);if(!Buffer.isBuffer(t)&&typeof t!="string")throw new Error("missing directory handle or path");if(typeof t=="string"){let l=[],u=0,h=(p,y)=>{if(p)return r(p);this.readdir(y,e,(E,x)=>{let k=E&&E.code===et.EOF;if(E&&!k)return this.close(y,()=>r(E));if(k)return this.close(y,D=>{if(D)return r(D);r(void 0,l)});for(let D=0;D<x.length;++D,++u)l[u]=x[D];h(void 0,y)})};return this.opendir(t,h)}let i=t.length,o=9,a=Buffer.allocUnsafe(13+i);K(a,a.length-4,0),a[4]=ve.READDIR;let c=this._writeReqid=this._writeReqid+1&lt;K(a,c,5),K(a,i,o),a.set(t,o+=4),this._requests[c]={cb:s?(l,u)=>{if(typeof r=="function"){if(l)return r(l);for(let h=u.length-1;h>=0;--h)(u[h].filename==="."||u[h].filename==="..")&&u.splice(h,1);r(void 0,u)}}:r};let f=Xe(this,a);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} READDIR`)}fstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=ve.FSTAT;let o=this._writeReqid=this._writeReqid+1&lt;K(i,o,5),K(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} FSTAT`)}stat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=ve.STAT;let o=this._writeReqid=this._writeReqid+1&lt;K(i,o,5),K(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STAT`)}lstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=ve.LSTAT;let o=this._writeReqid=this._writeReqid+1&lt;K(i,o,5),K(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} LSTAT`)}opendir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=ve.OPENDIR;let o=this._writeReqid=this._writeReqid+1&lt;K(i,o,5),K(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} OPENDIR`)}setstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="object"&&e!==null?(e=cr(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);K(c,c.length-4,0),c[4]=ve.SETSTAT;let f=this._writeReqid=this._writeReqid+1&lt;K(c,f,5),K(c,o,a),c.utf8Write(t,a+=4,o),K(c,s,a+=o),i&&(a+=4,i===Re.length?c.set(Re,a):Vn(Re,c,0,i,a),a+=i),this._requests[f]={cb:r};let l=Xe(this,c);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 s=0,i=0;typeof e=="object"&&e!==null?(e=cr(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=t.length,a=9,c=Buffer.allocUnsafe(13+o+4+i);K(c,c.length-4,0),c[4]=ve.FSETSTAT;let f=this._writeReqid=this._writeReqid+1&lt;K(c,f,5),K(c,o,a),c.set(t,a+=4),K(c,s,a+=o),i&&(a+=4,i===Re.length?c.set(Re,a):Vn(Re,c,0,i,a),a+=i),this._requests[f]={cb:r};let l=Xe(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} FSETSTAT`)}futimes(t,e,r,s){return this.fsetstat(t,{atime:Ur(e),mtime:Ur(r)},s)}utimes(t,e,r,s){return this.setstat(t,{atime:Ur(e),mtime:Ur(r)},s)}fchown(t,e,r,s){return this.fsetstat(t,{uid:e,gid:r},s)}chown(t,e,r,s){return this.setstat(t,{uid:e,gid:r},s)}fchmod(t,e,r){return this.fsetstat(t,{mode:e},r)}chmod(t,e,r){return this.setstat(t,{mode:e},r)}readlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=ve.READLINK;let o=this._writeReqid=this._writeReqid+1&lt;K(i,o,5),K(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,f)=>{if(typeof e=="function"){if(c)return e(c);if(!f||!f.length)return e(new Error("Response missing link info"));e(void 0,f[0].filename)}}};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} READLINK`)}symlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=Buffer.byteLength(t),o=9,a=Buffer.allocUnsafe(13+s+4+i);K(a,a.length-4,0),a[4]=ve.SYMLINK;let c=this._writeReqid=this._writeReqid+1&lt;K(a,c,5),this._isOpenSSH?(K(a,i,o),a.utf8Write(t,o+=4,i),K(a,s,o+=i),a.utf8Write(e,o+=4,s)):(K(a,s,o),a.utf8Write(e,o+=4,s),K(a,i,o+=s),a.utf8Write(t,o+=4,i)),this._requests[c]={cb:r};let f=Xe(this,a);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} SYMLINK`)}realpath(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=ve.REALPATH;let o=this._writeReqid=this._writeReqid+1&lt;K(i,o,5),K(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,f)=>{if(typeof e=="function"){if(c)return e(c);if(!f||!f.length)return e(new Error("Response missing path info"));e(void 0,f[0].filename)}}};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=this._extensions["posix-rename@openssh.com"];if(!s||s!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(41+i+4+o);K(c,c.length-4,0),c[4]=ve.EXTENDED;let f=this._writeReqid=this._writeReqid+1&lt;K(c,f,5),K(c,24,a),c.utf8Write("posix-rename@openssh.com",a+=4,24),K(c,i,a+=24),c.utf8Write(t,a+=4,i),K(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[f]={cb:r};let l=Xe(this,c);if(this._debug){let u=l?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${u} posix-rename@openssh.com`)}}ext_openssh_statvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["statvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(36+s);K(o,o.length-4,0),o[4]=ve.EXTENDED;let a=this._writeReqid=this._writeReqid+1&lt;K(o,a,5),K(o,19,i),o.utf8Write("statvfs@openssh.com",i+=4,19),K(o,s,i+=19),o.utf8Write(t,i+=4,s),this._requests[a]={extended:"statvfs@openssh.com",cb:e};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} statvfs@openssh.com`)}}ext_openssh_fstatvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["fstatvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(37+s);K(o,o.length-4,0),o[4]=ve.EXTENDED;let a=this._writeReqid=this._writeReqid+1&lt;K(o,a,5),K(o,20,i),o.utf8Write("fstatvfs@openssh.com",i+=4,20),K(o,s,i+=20),o.set(t,i+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:e};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} fstatvfs@openssh.com`)}}ext_openssh_hardlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["hardlink@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(37+i+4+o);K(c,c.length-4,0),c[4]=ve.EXTENDED;let f=this._writeReqid=this._writeReqid+1&lt;K(c,f,5),K(c,20,a),c.utf8Write("hardlink@openssh.com",a+=4,20),K(c,i,a+=20),c.utf8Write(t,a+=4,i),K(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[f]={cb:r};let l=Xe(this,c);if(this._debug){let u=l?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${u} hardlink@openssh.com`)}}ext_openssh_fsync(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["fsync@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(34+s);K(o,o.length-4,0),o[4]=ve.EXTENDED;let a=this._writeReqid=this._writeReqid+1&lt;K(o,a,5),K(o,17,i),o.utf8Write("fsync@openssh.com",i+=4,17),K(o,s,i+=17),o.set(t,i+=4),this._requests[a]={cb:e};let c=Xe(this,o);this._debug&&this._debug(`SFTP: Outbound: ${c?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["lsetstat@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=0,o=0;typeof e=="object"&&e!==null?(e=cr(e),i=e.flags,o=e.nb):typeof e=="function"&&(r=e);let a=Buffer.byteLength(t),c=9,f=Buffer.allocUnsafe(37+a+4+o);K(f,f.length-4,0),f[4]=ve.EXTENDED;let l=this._writeReqid=this._writeReqid+1&lt;K(f,l,5),K(f,20,c),f.utf8Write("lsetstat@openssh.com",c+=4,20),K(f,a,c+=20),f.utf8Write(t,c+=4,a),K(f,i,c+=a),o&&(c+=4,o===Re.length?f.set(Re,c):Vn(Re,f,0,o,c),c+=o),this._requests[l]={cb:r};let u=Xe(this,f);if(this._debug){let h=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} lsetstat@openssh.com`)}}ext_openssh_expandPath(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["expand-path@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(40+s);K(o,o.length-4,0),o[4]=ve.EXTENDED;let a=this._writeReqid=this._writeReqid+1&lt;K(o,a,5),K(o,23,i),o.utf8Write("expand-path@openssh.com",i+=4,23),K(o,s,i+=20),o.utf8Write(t,i+=4,s),this._requests[a]={cb:(f,l)=>{if(typeof e=="function"){if(f)return e(f);if(!l||!l.length)return e(new Error("Response missing expanded path"));e(void 0,l[0].filename)}}};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} expand-path@openssh.com`)}}ext_copy_data(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["copy-data"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("Source handle is not a Buffer");if(!Buffer.isBuffer(s))throw new Error("Destination handle is not a Buffer");let c=0,f=Buffer.allocUnsafe(26+t.length+8+8+4+s.length+8);K(f,f.length-4,c),c+=4,f[c]=ve.EXTENDED,++c;let l=this._writeReqid=this._writeReqid+1&lt;K(f,l,c),c+=4,K(f,9,c),c+=4,f.utf8Write("copy-data",c,9),c+=9,K(f,t.length,c),c+=4,f.set(t,c),c+=t.length;for(let h=7;h>=0;--h)f[c+h]=e&255,e/=256;c+=8;for(let h=7;h>=0;--h)f[c+h]=r&255,r/=256;c+=8,K(f,s.length,c),c+=4,f.set(s,c),c+=s.length;for(let h=7;h>=0;--h)f[c+h]=i&255,i/=256;this._requests[l]={cb:o};let u=Xe(this,f);if(this._debug){let h=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} copy-data`)}}ext_home_dir(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["home-directory"]!=="1")throw new Error("Server does not support this extended request");if(typeof t!="string")throw new TypeError("username is not a string");let s=0,i=Buffer.byteLength(t),o=Buffer.allocUnsafe(31+i);K(o,o.length-4,s),s+=4,o[s]=ve.EXTENDED,++s;let a=this._writeReqid=this._writeReqid+1&lt;K(o,a,s),s+=4,K(o,14,s),s+=4,o.utf8Write("home-directory",s,14),s+=14,K(o,i,s),s+=4,o.utf8Write(t,s,i),s+=i,this._requests[a]={cb:(f,l)=>{if(typeof e=="function"){if(f)return e(f);if(!l||!l.length)return e(new Error("Response missing home directory"));e(void 0,l[0].filename)}}};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} 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 f of t)if(!Number.isInteger(f)||f<0||f>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 f of e)if(!Number.isInteger(f)||f<0||f>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let i=0,o=Buffer.allocUnsafe(47+4*t.length+4+4*e.length);K(o,o.length-4,i),i+=4,o[i]=ve.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&lt;K(o,a,i),i+=4,K(o,30,i),i+=4,o.utf8Write("users-groups-by-id@openssh.com",i,30),i+=30,K(o,4*t.length,i),i+=4;for(let f of t)K(o,f,i),i+=4;K(o,4*e.length,i),i+=4;for(let f of e)K(o,f,i),i+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:r};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} users-groups-by-id@openssh.com`)}}handle(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let r=e.length;if(r>256)throw new Error("handle too large (> 256 bytes)");let s=9,i=Buffer.allocUnsafe(13+r);K(i,i.length-4,0),i[4]=Zt.HANDLE,K(i,t,5),K(i,r,s),r&&i.set(e,s+=4);let o=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${o?"Buffered":"Sending"} HANDLE`)}status(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!n0.has(e))throw new Error(`Bad status code: ${e}`);r||(r="");let s=Buffer.byteLength(r),i=9,o=Buffer.allocUnsafe(17+s+4);K(o,o.length-4,0),o[4]=Zt.STATUS,K(o,t,5),K(o,e,i),K(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),K(o,0,i);let a=Xe(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STATUS`)}data(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");let s=Buffer.isBuffer(e);if(!s&&typeof e!="string")throw new Error("data is not a Buffer or string");let i;!s&&!r&&(r=void 0,i=!0);let o=s?e.length:Buffer.byteLength(e,r),a=9,c=Buffer.allocUnsafe(13+o);K(c,c.length-4,0),c[4]=Zt.DATA,K(c,t,5),K(c,o,a),o&&(s?c.set(e,a+=4):i?c.utf8Write(e,a+=4,o):c.write(e,a+=4,o,r));let f=Xe(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} DATA`)}name(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Array.isArray(e)){if(typeof e!="object"||e===null)throw new Error("names is not an object or array");e=[e]}let r=e.length,s=0,i,o=[];for(let l=0;l<r;++l){let u=e[l],h=!u||!u.filename||typeof u.filename!="string"?"":u.filename;s+=4+Buffer.byteLength(h);let p=!u||!u.longname||typeof u.longname!="string"?"":u.longname;if(s+=4+Buffer.byteLength(p),typeof u.attrs=="object"&&u.attrs!==null){if(i=cr(u.attrs),s+=4+i.nb,i.nb){let y;i.nb===Re.length?y=new Uint8Array(Re):(y=new Uint8Array(i.nb),Vn(Re,y,0,i.nb,0)),i.bytes=y}o.push(i)}else s+=4,o.push(null)}let a=9,c=Buffer.allocUnsafe(13+s);K(c,c.length-4,0),c[4]=Zt.NAME,K(c,t,5),K(c,r,a),a+=4;for(let l=0;l<r;++l){let u=e[l];{let p=!u||!u.filename||typeof u.filename!="string"?"":u.filename,y=Buffer.byteLength(p);K(c,y,a),a+=4,y&&(c.utf8Write(p,a,y),a+=y)}{let p=!u||!u.longname||typeof u.longname!="string"?"":u.longname,y=Buffer.byteLength(p);K(c,y,a),a+=4,y&&(c.utf8Write(p,a,y),a+=y)}let h=o[l];h?(K(c,h.flags,a),a+=4,h.flags&&h.bytes&&(c.set(h.bytes,a),a+=h.nb)):(K(c,0,a),a+=4)}let f=Xe(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"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=cr(e);let r=e.flags,s=e.nb,i=9,o=Buffer.allocUnsafe(13+s);K(o,o.length-4,0),o[4]=Zt.ATTRS,K(o,t,5),K(o,r,i),s&&(i+=4,s===Re.length?o.set(Re,i):Vn(Re,o,0,s,i),i+=s);let a=Xe(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function c0(n){try{return Buffer.allocUnsafe(n)}catch(t){return t}}function fl(n,t,e,r,s,i,o,a){let c=n._maxReadLen,f=Math.max(s-c,0);f&&(s=c);let l=t.length,u=9,h=i,p=Buffer.allocUnsafe(13+l+8+4);K(p,p.length-4,0),p[4]=ve.READ;let y=n._writeReqid=n._writeReqid+1&lt;K(p,y,5),K(p,l,u),p.set(t,u+=4),u+=l;for(let k=7;k>=0;--k)p[u+k]=h&255,h/=256;K(p,s,u+=8),typeof o!="function"&&(o=cl);let E=a||{nb:0,position:i,off:r,origOff:r,len:void 0,overflow:void 0,cb:(k,D,H)=>{let C=E.len,F=E.overflow;if(k){if(o._wantEOFError||k.code!==et.EOF)return o(k)}else{if(H>C)return o(new Error("Received more data than requested"));if(H===C&&F){E.nb+=H,E.position+=H,E.off+=H,fl(n,t,e,E.off,F,E.position,o,E);return}}H=H||0,E.origOff===0&&e.length===E.nb?D=e:D=$r(e,E.origOff,E.origOff+E.nb+H),o(void 0,E.nb+H,D,E.position)},buffer:void 0};E.len=s,E.overflow=f,E.buffer=$r(e,r,r+s),n._requests[y]=E;let x=Xe(n,p);n._debug&&n._debug(`SFTP: Outbound: ${x?"Buffered":"Sending"} READ`)}function nl(n,t,e,r,s,i){let o=64,a=32768,c,f,l;typeof s=="function"?i=s:typeof s=="object"&&s!==null&&(typeof s.concurrency=="number"&&s.concurrency>0&&!isNaN(s.concurrency)&&(o=s.concurrency),typeof s.chunkSize=="number"&&s.chunkSize>0&&!isNaN(s.chunkSize)&&(a=s.chunkSize),typeof s.fileSize=="number"&&s.fileSize>0&&!isNaN(s.fileSize)&&(l=s.fileSize),typeof s.step=="function"&&(c=s.step),(typeof s.mode=="string"||typeof s.mode=="number")&&(f=Ia(s.mode)));let u,h=0,p=0,y=!1,E,x,k,D=a*o;function H(C){if(y)return;y=!0;let F=0,V;E||x?(V=()=>{--F===0&&i(C)},E&&(n===Gn||n.outgoing.state==="open")&&++F,x&&(t===Gn||t.outgoing.state==="open")&&++F,E&&(n===Gn||n.outgoing.state==="open")&&n.close(E,V),x&&(t===Gn||t.outgoing.state==="open")&&t.close(x,V)):i(C)}n.open(e,"r",(C,F)=>{if(C)return H(C);E=F,l===void 0?n.fstat(E,V):V(null,{size:l});function V(N,b){if(N){if(n!==Gn){n.stat(e,(S,I)=>{if(S)return H(N);V(null,I)});return}return H(N)}u=b.size,t.open(r,"w",(S,I)=>{if(S)return H(S);if(x=I,u<=0)return H();for(;D>u;){if(o===1){D=u;break}D-=a,--o}if(k=c0(D),k instanceof Error)return H(k);f!==void 0?t.fchmod(x,f,function Y(te){if(te){t.chmod(r,f,ce=>Y());return}z()}):z();function v(Y,te,ce,$,B,T){if(Y)return H(Y);B=B||0,t.write(x,k,B,te,$,Q);function Q(ee){if(ee)return H(ee);if(p+=te,c&&c(p,te,u),te<T)return ne(B,$+te,T-te);if(p===u){t.close(x,ie=>{if(x=void 0,ie)return H(ie);n.close(E,Ye=>{if(E=void 0,Ye)return H(Ye);i()})});return}if(h>=u)return;let fe=h+a>u?u-h:a;ne(B,h,fe),h+=fe}}function R(Y,te,ce){return($,B,T)=>{v($,B,T,te,Y,ce)}}function ne(Y,te,ce){n.read(E,k,Y,ce,te,R(Y,te,ce))}function z(){let Y=0,te=0;for(;h<u&&Y<o;){let ce=h+a>u?u-h:a;ne(te,h,ce),te+=ce,h+=ce,++Y}}})}})}function ya(n,t,e,r,s,i,o){let a=typeof o=="function"?o:void 0;n.write(t,e,r,s,i,(c,f)=>{if(c)return n.close(t,()=>{a&&a(c)});f===s?n.close(t,a):(r+=f,s-=f,i+=f,ya(n,t,e,r,s,i,a))})}var ws=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&Jt.S_IFMT)===Jt.S_IFDIR}isFile(){return(this.mode&Jt.S_IFMT)===Jt.S_IFREG}isBlockDevice(){return(this.mode&Jt.S_IFMT)===Jt.S_IFBLK}isCharacterDevice(){return(this.mode&Jt.S_IFMT)===Jt.S_IFCHR}isSymbolicLink(){return(this.mode&Jt.S_IFMT)===Jt.S_IFLNK}isFIFO(){return(this.mode&Jt.S_IFMT)===Jt.S_IFIFO}isSocket(){return(this.mode&Jt.S_IFMT)===Jt.S_IFSOCK}};function cr(n){let t=0,e=0;if(typeof n=="object"&&n!==null){if(typeof n.size=="number"){t|=Un.SIZE;let r=n.size;Re[e++]=r/72057594037927940,Re[e++]=r/281474976710656,Re[e++]=r/1099511627776,Re[e++]=r/4294967296,Re[e++]=r/16777216,Re[e++]=r/65536,Re[e++]=r/256,Re[e++]=r}if(typeof n.uid=="number"&&typeof n.gid=="number"){t|=Un.UIDGID;let r=n.uid,s=n.gid;Re[e++]=r>>>24,Re[e++]=r>>>16,Re[e++]=r>>>8,Re[e++]=r,Re[e++]=s>>>24,Re[e++]=s>>>16,Re[e++]=s>>>8,Re[e++]=s}if(typeof n.mode=="number"||typeof n.mode=="string"){let r=Ia(n.mode);t|=Un.PERMISSIONS,Re[e++]=r>>>24,Re[e++]=r>>>16,Re[e++]=r>>>8,Re[e++]=r}if((typeof n.atime=="number"||Ea(n.atime))&&(typeof n.mtime=="number"||Ea(n.mtime))){let r=Ur(n.atime),s=Ur(n.mtime);t|=Un.ACMODTIME,Re[e++]=r>>>24,Re[e++]=r>>>16,Re[e++]=r>>>8,Re[e++]=r,Re[e++]=s>>>24,Re[e++]=s>>>16,Re[e++]=s>>>8,Re[e++]=s}}return{flags:t,nb:e}}function Ur(n){if(typeof n=="number"&&n===n)return n;if(Ea(n))return parseInt(n.getTime()/1e3,10);throw new Error(`Cannot parse time: ${n}`)}function Ia(n){if(typeof n=="number"&&n===n)return n;if(typeof n=="string")return Ia(parseInt(n,8));throw new Error(`Cannot parse mode: ${n}`)}var ba={r:Ie.READ,"r+":Ie.READ|Ie.WRITE,w:Ie.TRUNC|Ie.CREAT|Ie.WRITE,wx:Ie.TRUNC|Ie.CREAT|Ie.WRITE|Ie.EXCL,xw:Ie.TRUNC|Ie.CREAT|Ie.WRITE|Ie.EXCL,"w+":Ie.TRUNC|Ie.CREAT|Ie.READ|Ie.WRITE,"wx+":Ie.TRUNC|Ie.CREAT|Ie.READ|Ie.WRITE|Ie.EXCL,"xw+":Ie.TRUNC|Ie.CREAT|Ie.READ|Ie.WRITE|Ie.EXCL,a:Ie.APPEND|Ie.CREAT|Ie.WRITE,ax:Ie.APPEND|Ie.CREAT|Ie.WRITE|Ie.EXCL,xa:Ie.APPEND|Ie.CREAT|Ie.WRITE|Ie.EXCL,"a+":Ie.APPEND|Ie.CREAT|Ie.READ|Ie.WRITE,"ax+":Ie.APPEND|Ie.CREAT|Ie.READ|Ie.WRITE|Ie.EXCL,"xa+":Ie.APPEND|Ie.CREAT|Ie.READ|Ie.WRITE|Ie.EXCL};function ll(n){let t=ba[n];return t!==void 0?t:null}var f0=(()=>{let n=Object.keys(ba);return t=>{for(let e=0;e<n.length;++e){let r=n[e];if(ba[r]===t)return r}return null}})();function Dr(n){let t=O.readUInt32BE();if(t===void 0)return;let e=new ws;if(t&Un.SIZE){let r=O.readUInt64BE(n);if(r===void 0)return;e.size=r}if(t&Un.UIDGID){let r=O.readUInt32BE(),s=O.readUInt32BE();if(s===void 0)return;e.uid=r,e.gid=s}if(t&Un.PERMISSIONS){let r=O.readUInt32BE();if(r===void 0)return;e.mode=r}if(t&Un.ACMODTIME){let r=O.readUInt32BE(),s=O.readUInt32BE();if(s===void 0)return;e.atime=r,e.mtime=s}if(t&Un.EXTENDED){let r=O.readUInt32BE();if(r===void 0)return;let s={};for(let i=0;i<r;++i){let o=O.readString(!0),a=O.readString();if(a===void 0)return;s[o]=a}e.extended=s}return e}function Xe(n,t){let e=ul(n,t);return e!==void 0?(n._buffer.push(e),!1):!0}function ul(n,t){let e=n.outgoing;if(e.state!=="open")return;if(e.window===0)return n._waitWindow=!0,n._chunkcb=rl,t;let r,s=t.length,i=0;for(;s-i>0&&e.window>0;){let o=Math.min(s-i,e.window,e.packetSize);e.window-=o,e.window===0&&(n._waitWindow=!0,n._chunkcb=rl),i===0&&o===s?n._protocol.channelData(n.outgoing.id,t):n._protocol.channelData(n.outgoing.id,$r(t,i,i+o)),i+=o}return s-i>0&&(i>0?r=$r(t,i,s):r=t),r}function rl(){this._chunkcb=void 0;let n=this._buffer,t=0;for(;t<n.length;){let e=n[t],r=ul(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 it(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(),dl(n),!1}function dl(n){let t=Object.keys(n._requests);if(t.length===0)return;let e=n._requests;n._requests={};let r=new Error("No response from server");for(let s=0;s<t.length;++s){let i=e[t[s]];typeof i.cb=="function"&&i.cb(r)}}function l0(n,t){let e=9,r=Buffer.allocUnsafe(31);K(r,r.length-4,0),r[4]=ve.EXTENDED;let s=n._writeReqid=n._writeReqid+1&lt;K(r,s,5),K(r,18,e),r.utf8Write("limits@openssh.com",e+=4,18),n._requests[s]={extended:"limits@openssh.com",cb:t};let i=Xe(n,r);if(n._debug){let o=i?"Buffered":"Sending";n._debug(`SFTP: Outbound: ${o} limits@openssh.com`)}}var u0={[Zt.VERSION]:(n,t)=>{if(n._version!==-1)return it(n,"Duplicate VERSION packet");let e={};O.init(t,1);let r=O.readUInt32BE();for(;O.avail();){let s=O.readString(!0),i=O.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(O.clear(),r===void 0)return it(n,"Malformed VERSION packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received VERSION (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received VERSION (v${r})`)}if(n._version=r,n._extensions=e,e["limits@openssh.com"]==="1")return l0(n,(s,i)=>{s||(i.maxPktLen>0&&(n._maxOutPktLen=i.maxPktLen),i.maxReadLen>0&&(n._maxReadLen=i.maxReadLen),i.maxWriteLen>0&&(n._maxWriteLen=i.maxWriteLen),n.maxOpenHandles=i.maxOpenHandles>0?i.maxOpenHandles:1/0),n.emit("ready")});n.emit("ready")},[Zt.STATUS]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readUInt32BE(),s=O.readString(!0);if(O.clear(),n._debug){let o=JSON.stringify(s);n._debug(`SFTP: Inbound: Received STATUS (id:${e}, ${r}, ${o})`)}let i=n._requests[e];if(delete n._requests[e],i&&typeof i.cb=="function"){if(r===et.OK){i.cb();return}let o=new Error(s||r0[r]||"Unknown status");o.code=r,i.cb(o)}},[Zt.HANDLE]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString();if(O.clear(),r===void 0)return e!==void 0&&delete n._requests[e],it(n,"Malformed HANDLE packet");n._debug&&n._debug(`SFTP: Inbound: Received HANDLE (id:${e})`);let s=n._requests[e];delete n._requests[e],s&&typeof s.cb=="function"&&s.cb(void 0,r)},[Zt.DATA]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r;if(e!==void 0&&(r=n._requests[e],delete n._requests[e]),r&&typeof r.cb=="function")if(r.buffer){let s=O.readString(r.buffer);if(O.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`),r.cb(void 0,r.buffer,s);return}}else{let s=O.readString();if(O.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s.length})`),r.cb(void 0,s);return}}else{let s=O.skipString();if(O.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`);return}}return it(n,"Malformed DATA packet")},[Zt.NAME]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=O.readUInt32BE();if(s!==void 0){let i=[];for(let o=0;o<s;++o){let a=O.readString(!0),c=O.readString(!0),f=Dr(n._biOpt);if(f===void 0){i=void 0;break}i.push({filename:a,longname:c,attrs:f})}if(i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received NAME (id:${e}, ${i.length})`),O.clear(),r&&typeof r.cb=="function"&&r.cb(void 0,i);return}}return O.clear(),it(n,"Malformed NAME packet")},[Zt.ATTRS]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=Dr(n._biOpt);if(O.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received ATTRS (id:${e})`),r&&typeof r.cb=="function"&&r.cb(void 0,s);return}return it(n,"Malformed ATTRS packet")},[Zt.EXTENDED]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE();if(e!==void 0){let r=n._requests[e];if(r)switch(delete n._requests[e],r.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{let s=n._biOpt,i={f_bsize:O.readUInt64BE(s),f_frsize:O.readUInt64BE(s),f_blocks:O.readUInt64BE(s),f_bfree:O.readUInt64BE(s),f_bavail:O.readUInt64BE(s),f_files:O.readUInt64BE(s),f_ffree:O.readUInt64BE(s),f_favail:O.readUInt64BE(s),f_sid:O.readUInt64BE(s),f_flag:O.readUInt64BE(s),f_namemax:O.readUInt64BE(s)};if(i.f_namemax===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),O.clear(),typeof r.cb=="function"&&r.cb(void 0,i);return}case"limits@openssh.com":{let s={maxPktLen:O.readUInt64BE(),maxReadLen:O.readUInt64BE(),maxWriteLen:O.readUInt64BE(),maxOpenHandles:O.readUInt64BE()};if(s.maxOpenHandles===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),O.clear(),typeof r.cb=="function"&&r.cb(void 0,s);return}case"users-groups-by-id@openssh.com":{let s=O.readUInt32BE();if(s===void 0)break;let i=new Array(s);for(let c=0;c<i.length;++c)i[c]=O.readString(!0);let o=O.readUInt32BE();if(o===void 0)break;let a=new Array(o);for(let c=0;c<a.length;++c)a[c]=O.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})`),O.clear(),typeof r.cb=="function"&&r.cb(void 0,i,a);return}default:n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),O.clear(),typeof r.cb=="function"&&r.cb();return}else{n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),O.clear();return}}return O.clear(),it(n,"Malformed EXTENDED_REPLY packet")}},d0={[ve.INIT]:(n,t)=>{if(n._version!==-1)return it(n,"Duplicate INIT packet");let e={};O.init(t,1);let r=O.readUInt32BE();for(;O.avail();){let s=O.readString(!0),i=O.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(O.clear(),r===void 0)return it(n,"Malformed INIT packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received INIT (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received INIT (v${r})`)}Xe(n,s0),n._version=r,n._extensions=e,n.emit("ready")},[ve.OPEN]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=O.readUInt32BE(),i=Dr(n._biOpt);if(O.clear(),i===void 0)return it(n,"Malformed OPEN packet");n._debug&&n._debug(`SFTP: Inbound: Received OPEN (id:${e})`),n.emit("OPEN",e,r,s,i)||n.status(e,et.OP_UNSUPPORTED)},[ve.CLOSE]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString();if(O.clear(),r===void 0||r.length>256)return it(n,"Malformed CLOSE packet");n._debug&&n._debug(`SFTP: Inbound: Received CLOSE (id:${e})`),n.emit("CLOSE",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.READ]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(),s=O.readUInt64BE(n._biOpt),i=O.readUInt32BE();if(O.clear(),i===void 0||r.length>256)return it(n,"Malformed READ packet");n._debug&&n._debug(`SFTP: Inbound: Received READ (id:${e})`),n.emit("READ",e,r,s,i)||n.status(e,et.OP_UNSUPPORTED)},[ve.WRITE]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(),s=O.readUInt64BE(n._biOpt),i=O.readString();if(O.clear(),i===void 0||r.length>256)return it(n,"Malformed WRITE packet");n._debug&&n._debug(`SFTP: Inbound: Received WRITE (id:${e})`),n.emit("WRITE",e,r,s,i)||n.status(e,et.OP_UNSUPPORTED)},[ve.LSTAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed LSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received LSTAT (id:${e})`),n.emit("LSTAT",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.FSTAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString();if(O.clear(),r===void 0||r.length>256)return it(n,"Malformed FSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSTAT (id:${e})`),n.emit("FSTAT",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.SETSTAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=Dr(n._biOpt);if(O.clear(),s===void 0)return it(n,"Malformed SETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received SETSTAT (id:${e})`),n.emit("SETSTAT",e,r,s)||n.status(e,et.OP_UNSUPPORTED)},[ve.FSETSTAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(),s=Dr(n._biOpt);if(O.clear(),s===void 0||r.length>256)return it(n,"Malformed FSETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSETSTAT (id:${e})`),n.emit("FSETSTAT",e,r,s)||n.status(e,et.OP_UNSUPPORTED)},[ve.OPENDIR]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed OPENDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received OPENDIR (id:${e})`),n.emit("OPENDIR",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.READDIR]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString();if(O.clear(),r===void 0||r.length>256)return it(n,"Malformed READDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received READDIR (id:${e})`),n.emit("READDIR",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.REMOVE]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed REMOVE packet");n._debug&&n._debug(`SFTP: Inbound: Received REMOVE (id:${e})`),n.emit("REMOVE",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.MKDIR]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=Dr(n._biOpt);if(O.clear(),s===void 0)return it(n,"Malformed MKDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received MKDIR (id:${e})`),n.emit("MKDIR",e,r,s)||n.status(e,et.OP_UNSUPPORTED)},[ve.RMDIR]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed RMDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received RMDIR (id:${e})`),n.emit("RMDIR",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.REALPATH]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed REALPATH packet");n._debug&&n._debug(`SFTP: Inbound: Received REALPATH (id:${e})`),n.emit("REALPATH",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.STAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed STAT packet");n._debug&&n._debug(`SFTP: Inbound: Received STAT (id:${e})`),n.emit("STAT",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.RENAME]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=O.readString(!0);if(O.clear(),s===void 0)return it(n,"Malformed RENAME packet");n._debug&&n._debug(`SFTP: Inbound: Received RENAME (id:${e})`),n.emit("RENAME",e,r,s)||n.status(e,et.OP_UNSUPPORTED)},[ve.READLINK]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed READLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received READLINK (id:${e})`),n.emit("READLINK",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ve.SYMLINK]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=O.readString(!0);if(O.clear(),s===void 0)return it(n,"Malformed SYMLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received SYMLINK (id:${e})`);let i;n._isOpenSSH?i=n.emit("SYMLINK",e,s,r):i=n.emit("SYMLINK",e,r,s),i||n.status(e,et.OP_UNSUPPORTED)},[ve.EXTENDED]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(r===void 0)return O.clear(),it(n,"Malformed EXTENDED packet");let s;O.avail()&&(s=O.readRaw()),O.clear(),n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED (id:${e})`),n.emit("EXTENDED",e,r,s)||n.status(e,et.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:h0,ERR_OUT_OF_RANGE:Ss,validateNumber:p0}=el(),il=128,zt,xa=[];function g0(n){xa.length>0?zt=xa.pop():zt=Buffer.allocUnsafe(n),zt.used=0}function Sa(n,t){if(!Number.isSafeInteger(n))throw p0(n,t),Number.isInteger(n)?new Ss(t,">= 0 and <= 2 ** 53 - 1",n):new Ss(t,"an integer",n);if(n<0)throw new Ss(t,">= 0 and <= 2 ** 53 - 1",n)}function Aa(n){return n+7&-8}function Dn(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,ol.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&&(Sa(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(Sa(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new Ss("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}al(Dn,ol);Dn.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()}))};Dn.prototype._read=function(n){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(n));if(this.destroyed)return;(!zt||zt.length-zt.used<il)&&g0(this.readableHighWaterMark||this._readableState.highWaterMark);let t=zt,e=Math.min(zt.length-zt.used,n),r=zt.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,zt,zt.used,e,this.pos,(s,i)=>{if(s){this.emit("error",s),this.autoClose&&this.destroy();return}let o=null;if(r+e===t.used&&t===zt)t.used=Aa(t.used+i-e);else{let a=r+e&-8,c=Aa(r+i);a-c>=il&&xa.push(t.slice(c,a))}i>0&&(this.bytesRead+=i,o=t.slice(r,r+i)),this.pos+=i,this.push(o)}),zt.used=Aa(zt.used+e)};Dn.prototype._destroy=function(n,t){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",sl.bind(null,this,t,n));return}sl(this,t,n),this.handle=null,this._opening=!1};function sl(n,t,e){if(!n.handle)return r();n.sftp.close(n.handle,r);function r(s){s=s||e,t(s),n.isClosed=!0,s||n.emit("close")}}Dn.prototype.close=function(n){this.destroy(null,n)};Object.defineProperty(Dn.prototype,"pending",{get(){return this.handle===null},configurable:!0});function dn(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,wa.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&&(Sa(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()}al(dn,wa);dn.prototype._final=function(n){this.autoClose&&this.destroy(),n()};dn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t;let e=r=>{if(r){this.sftp.chmod(this.path,this.mode,s=>e());return}if(this.flags[0]==="a"){let s=(i,o)=>{if(i){this.sftp.stat(this.path,(a,c)=>{if(a){this.destroy(),this.emit("error",i);return}s(null,c)});return}this.pos=o.size,this.emit("open",t),this.emit("ready")};this.sftp.fstat(t,s);return}this.emit("open",t),this.emit("ready")};this.sftp.fchmod(t,this.mode,e)}))};dn.prototype._write=function(n,t,e){if(!Buffer.isBuffer(n)){let r=new h0("data","Buffer",n);return this.emit("error",r)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(n,t,e)});this.sftp.write(this.handle,n,0,n.length,this.pos,(r,s)=>{if(r)return this.autoClose&&this.destroy(),e(r);this.bytesWritten+=s,e()}),this.pos+=n.length};dn.prototype._writev=function(n,t){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(n,t)});let e=this.sftp,r=this.handle,s=n.length,i=(o,a)=>{if(o)return this.destroy(),t(o);this.bytesWritten+=a,--s===0&&t()};for(let o=0;o<n.length;++o){let a=n[o].chunk;e.write(r,a,0,a.length,this.pos,i),this.pos+=a.length}};typeof wa.prototype.destroy!="function"&&(dn.prototype.destroy=Dn.prototype.destroy);dn.prototype._destroy=Dn.prototype._destroy;dn.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()};dn.prototype.destroySoon=dn.prototype.end;Object.defineProperty(dn.prototype,"pending",{get(){return this.handle===null},configurable:!0});hl.exports={flagsToString:f0,OPEN_MODE:Ie,SFTP:_a,Stats:ws,STATUS_CODE:et,stringToFlags:ll}});var Na=at((ME,Al)=>{"use strict";var{Duplex:m0,Readable:A0,Writable:E0}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:pl}}=Pn(),{bufferSlice:Is}=hn(),_0=32*1024,xi=2*1024*1024,Ba=xi/2,Ca=class extends A0{constructor(t,e){super(e),this._channel=t}_read(t){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=Ba&&Ra(this._channel))}},ka=class extends E0{constructor(t){super({highWaterMark:xi}),this._channel=t}_write(t,e,r){let s=this._channel,i=s._client._protocol,o=s.outgoing,a=o.packetSize,c=o.id,f=o.window,l=t.length,u=0;if(o.state==="open"){for(;l-u>0&&f>0;){let h=l-u;h>f&&(h=f),h>a&&(h=a),u===0&&h===l?i.channelExtData(c,t,pl):i.channelExtData(c,Is(t,u,u+h),pl),u+=h,f-=h}if(o.window=f,l-u>0){f===0&&(s._waitWindow=!0),u>0?s._chunkErr=Is(t,u,l):s._chunkErr=t,s._chunkcbErr=r;return}r()}}},va=class extends m0{constructor(t,e,r){let s={highWaterMark:xi,allowHalfOpen:!r||r&&r.allowHalfOpen!==!1,emitClose:!1};super(s),this.allowHalfOpen=s.allowHalfOpen;let i=!!(r&&r.server);this.server=i,this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this._callbacks=[],this._client=t,this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this.stdin=this.stdout=this,i?this.stderr=new ka(this):this.stderr=new Ca(this,s),this._waitWindow=!1,this._waitChanDrain=!1,this._chunk=void 0,this._chunkcb=void 0,this._chunkErr=void 0,this._chunkcbErr=void 0,this.on("finish",gl).on("prefinish",gl),this.on("end",ml).on("close",ml)}_read(t){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=Ba&&Ra(this))}_write(t,e,r){let s=this._client._protocol,i=this.outgoing,o=i.packetSize,a=i.id,c=i.window,f=t.length,l=0;if(i.state==="open"){for(;f-l>0&&c>0;){let u=f-l;u>c&&(u=c),u>o&&(u=o),l===0&&u===f?s.channelData(a,t):s.channelData(a,Is(t,l,l+u)),l+=u,c-=u}if(i.window=c,f-l>0){c===0&&(this._waitWindow=!0),l>0?this._chunk=Is(t,l,f):this._chunk=t,this._chunkcb=r;return}r()}}eof(){this.outgoing.state==="open"&&(this.outgoing.state="eof",this._client._protocol.channelEOF(this.outgoing.id))}close(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._client._protocol.channelClose(this.outgoing.id))}destroy(){return this.end(),this.close(),this}setWindow(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&(this.subtype==="shell"||this.subtype==="exec")&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.windowChange(this.outgoing.id,t,e,r,s)}signal(t){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.signal(this.outgoing.id,t)}exit(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&(typeof t=="number"?this._client._protocol.exitStatus(this.outgoing.id,t):this._client._protocol.exitSignal(this.outgoing.id,t,e,r))}};function gl(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}function ml(){this.readable=!1}function Ra(n){if(n.outgoing.state==="closed")return;let t=xi-n.incoming.window;t<=0||(n.incoming.window+=t,n._client._protocol.channelWindowAdjust(n.outgoing.id,t))}Al.exports={Channel:va,MAX_WINDOW:xi,PACKET_SIZE:_0,windowAdjust:Ra,WINDOW_THRESHOLD:Ba}});var La=at((FE,yl)=>{"use strict";var{SFTP:y0}=bi(),Si=2**32-1;function El(n,t,e,r){if(n._chanMgr.remove(t),typeof r!="function")return;let s;e instanceof Error?s=e:typeof e=="object"&&e!==null?(s=new Error(`(SSH) Channel open failure: ${e.description}`),s.reason=e.reason):(s=new Error("(SSH) Channel open failure: server closed channel unexpectedly"),s.reason=""),r(s)}function _l(n,t,e,r,s){if(typeof e=="function"){El(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!==y0&&(e.outgoing.state==="open"||e.outgoing.state==="eof")&&!s&&e.close(),e.outgoing.state==="closing"&&(e.outgoing.state="closed");let i=e._readableState,o=e._writableState;o&&!o.ending&&!o.finished&&!s&&e.end();let a=e._callbacks;e._callbacks=[];for(let c=0;c<a.length;++c)a[c](!0);if(e.server)!e.readable||e.destroyed||i&&i.endEmitted?e.emit("close"):e.once("end",()=>e.emit("close"));else{let c;switch(e.type){case"direct-streamlocal@openssh.com":case"direct-tcpip":c=()=>e.emit("close");break;default:{let l=e._exit;c=()=>{l.code===null?e.emit("close",l.code,l.signal,l.dump,l.desc):e.emit("close",l.code)}}}!e.readable||e.destroyed||i&&i.endEmitted?c():e.once("end",c);let f=e.stderr._readableState;!e.stderr.readable||e.stderr.destroyed||f&&f.endEmitted?e.stderr.emit("close"):e.stderr.once("end",()=>e.stderr.emit("close"))}}var Ta=class{constructor(t){this._client=t,this._channels={},this._cur=-1,this._count=0}add(t){let e;if(this._cur<Si)e=++this._cur;else if(this._count===0)this._cur=0,e=0;else{let r=this._channels;for(let s=0;s<Si;++s)if(r[s]===void 0){e=s;break}}return e===void 0?-1:(this._channels[e]=t||!0,++this._count,e)}update(t,e){if(typeof t!="number"||t<0||t>=Si||!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>=Si||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);return this._channels[t]}remove(t){if(typeof t!="number"||t<0||t>=Si||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);this._channels[t]&&(delete this._channels[t],this._count&&--this._count)}cleanup(t){let e=this._channels;this._channels={},this._cur=-1,this._count=0;let r=Object.keys(e),s=this._client;for(let i=0;i<r.length;++i){let o=+r[i],a=e[o];_l(s,o,a._channel||a,t,!0)}}},Pa=(()=>{let n=Object.prototype.toString;return t=>n.call(t)==="[object RegExp]"})();function b0(n,t,e){if(Array.isArray(n)&&n.length>0){for(let r=0;r<n.length;++r)if(e.indexOf(n[r])===-1)throw new Error(`Unsupported algorithm: ${n[r]}`);return n}if(typeof n=="object"&&n!==null){let r=Object.keys(n),s=t;for(let i=0;i<r.length;++i){let o=r[i],a=n[o];switch(o){case"append":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let f=a[c];if(typeof f=="string"){if(!f||s.indexOf(f)!==-1)continue;if(e.indexOf(f)===-1)throw new Error(`Unsupported algorithm: ${f}`);s===t&&(s=s.slice()),s.push(f)}else if(Pa(f))for(let l=0;l<e.length;++l){let u=e[l];if(f.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.push(u)}}}break;case"prepend":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=a.length;c>=0;--c){let f=a[c];if(typeof f=="string"){if(!f||s.indexOf(f)!==-1)continue;if(e.indexOf(f)===-1)throw new Error(`Unsupported algorithm: ${f}`);s===t&&(s=s.slice()),s.unshift(f)}else if(Pa(f))for(let l=e.length;l>=0;--l){let u=e[l];if(f.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.unshift(u)}}}break;case"remove":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let f=a[c];if(typeof f=="string"){if(!f)continue;let l=s.indexOf(f);if(l===-1)continue;s===t&&(s=s.slice()),s.splice(l,1)}else if(Pa(f))for(let l=0;l<s.length;++l)f.test(s[l])&&(s===t&&(s=s.slice()),s.splice(l,1),--l)}break}}return s}return t}yl.exports={ChannelManager:Ta,generateAlgorithmList:b0,onChannelOpenFailure:El,onCHANNEL_CLOSE:_l,isWritable:n=>n&&n.writable&&n._readableState&&n._readableState.ended===!1}});var Ha=at((HE,Fl)=>{"use strict";var{createHash:x0,getHashes:S0,randomFillSync:w0}=require("crypto"),{Socket:I0}=require("net"),{lookup:C0}=require("dns"),k0=require("events"),v0=S0(),{COMPAT:$l,CHANNEL_EXTENDED_DATATYPE:{STDERR:B0},CHANNEL_OPEN_FAILURE:wi,DEFAULT_CIPHER:bl,DEFAULT_COMPRESSION:xl,DEFAULT_KEX:Sl,DEFAULT_MAC:wl,DEFAULT_SERVER_HOST_KEY:Il,DISCONNECT_REASON:Cl,DISCONNECT_REASON_BY_VALUE:R0,SUPPORTED_CIPHER:N0,SUPPORTED_COMPRESSION:P0,SUPPORTED_KEX:T0,SUPPORTED_MAC:L0,SUPPORTED_SERVER_HOST_KEY:U0}=Pn(),{init:D0}=Qn(),$0=ga(),{parseKey:vs}=Kn(),{SFTP:O0}=bi(),{bufferCopy:kl,makeBufferParser:Ol,makeError:M0,readUInt32BE:F0,sigSSHToASN1:H0,writeUInt32BE:Ua}=hn(),{AgentContext:vl,createAgent:Bl,isAgent:Rl}=ea(),{Channel:Ml,MAX_WINDOW:Bs,PACKET_SIZE:Rs,windowAdjust:Nl,WINDOW_THRESHOLD:Pl}=Na(),{ChannelManager:Q0,generateAlgorithmList:Ii,isWritable:Pt,onChannelOpenFailure:W0,onCHANNEL_CLOSE:q0}=La(),Cs=Ol(),ks=Ol(),Ci=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,Ma=n=>{},Fa=class extends k0{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&&Pt(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=Ii(t.algorithms.kex,Sl,T0),e.kex!==Sl&&(r=!1),e.serverHostKey=Ii(t.algorithms.serverHostKey,Il,U0),e.serverHostKey!==Il&&(r=!1),e.cs.cipher=Ii(t.algorithms.cipher,bl,N0),e.cs.cipher!==bl&&(r=!1),e.cs.mac=Ii(t.algorithms.hmac,wl,L0),e.cs.mac!==wl&&(r=!1),e.cs.compress=Ii(t.algorithms.compress,xl,P0),e.cs.compress!==xl&&(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=Bl(t.agent):Rl(t.agent)?this.config.agent=t.agent:this.config.agent=void 0,this.config.allowAgentFwd=t.agentForward===!0&&this.config.agent!==void 0;let s=this.config.authHandler=typeof t.authHandler=="function"||Array.isArray(t.authHandler)?t.authHandler:void 0;this.config.strictVendor=typeof t.strictVendor=="boolean"?t.strictVendor:!0;let i=this.config.debug=typeof t.debug=="function"?t.debug:void 0;if(t.agentForward===!0&&!this.config.allowAgentFwd)throw new Error("You must set a valid agent path to allow agent forwarding");let o=this._callbacks=[];this._chanMgr=new Q0(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=vs(this.config.privateKey,t.passphrase),a instanceof Error)throw new Error(`Cannot parse privateKey: ${a.message}`);if(Array.isArray(a)&&(a=a[0]),a.getPrivatePEM()===null)throw new Error("privateKey value does not contain a (valid) private key")}let c;if(typeof t.hostVerifier=="function"){let $=t.hostVerifier,B;v0.indexOf(t.hostHash)!==-1&&(B=t.hostHash),c=(T,Q)=>{B&&(T=x0(B).update(T).digest("hex"));let ee=$(T,Q);ee!==void 0&&Q(ee)}}let f=this._sock=t.sock||new I0,l=!1,u=!1;this._protocol&&this._protocol.cleanup();let h=i?($,B,T)=>{i(`Debug output from server: ${JSON.stringify(T)}`)}:void 0,p,y=this._protocol=new $0({ident:this.config.ident,offer:r?void 0:e,onWrite:$=>{Pt(f)&&f.write($)},onError:$=>{$.level==="handshake"&&clearTimeout(this._readyTimeout),y._destruct||f.removeAllListeners("data"),this.emit("error",$);try{f.end()}catch{}},onHeader:$=>{u=!0,this._remoteVer=$.versions.software,$.greeting&&this.emit("greeting",$.greeting)},onHandshakeComplete:$=>{this.emit("handshake",$),l||(l=!0,y.service("ssh-userauth"))},debug:i,hostVerifier:c,messageHandlers:{DEBUG:h,DISCONNECT:($,B,T)=>{if(B!==Cl.BY_APPLICATION){T||(T=R0[B],T===void 0&&(T=`Unexpected disconnection reason: ${B}`));let Q=new Error(T);Q.code=B,this.emit("error",Q)}f.end()},SERVICE_ACCEPT:($,B)=>{B==="ssh-userauth"&&Y()},EXT_INFO:($,B)=>{if(p===void 0){for(let T of B)if(T.name==="server-sig-algs"){p=T.algs;return}p=null}},USERAUTH_BANNER:($,B)=>{this.emit("banner",B)},USERAUTH_SUCCESS:$=>{C(),clearTimeout(this._readyTimeout),this.emit("ready")},USERAUTH_FAILURE:($,B,T)=>{if(b.keyAlgos){let Q=b.keyAlgos[0][0];if(i&&i(`Client: ${b.type} (${Q}) auth failed`),b.keyAlgos.shift(),b.keyAlgos.length){let[ee,fe]=b.keyAlgos[0];switch(b.type){case"agent":y.authPK(b.username,b.agentCtx.currentKey(),ee);return;case"publickey":y.authPK(b.username,b.key,ee);return;case"hostbased":y.authHostbased(b.username,b.key,b.localHostname,b.localUsername,ee,(ie,Ye)=>{let ct=b.key.sign(ie,fe);if(ct instanceof Error)return ct.message=`Error while signing with key: ${ct.message}`,ct.level="client-authentication",this.emit("error",ct),Y();Ye(ct)});return}}else b.keyAlgos=void 0}if(b.type==="agent"){let Q=b.agentCtx.pos();return i&&i(`Client: Agent key #${Q+1} failed`),te()}i&&i(`Client: ${b.type} auth failed`),S=T,I=B,Y()},USERAUTH_PASSWD_CHANGEREQ:($,B)=>{b.type==="password"&&this.emit("change password",B,T=>{y.authPassword(this.config.username,this.config.password,T)})},USERAUTH_PK_OK:$=>{let B,T;if(b.keyAlgos&&([B,T]=b.keyAlgos[0]),b.type==="agent"){let Q=b.agentCtx.currentKey();y.authPK(b.username,Q,B,(ee,fe)=>{let ie={hash:T};b.agentCtx.sign(Q,ee,ie,(Ye,ct)=>{if(Ye)Ye.level="agent",this.emit("error",Ye);else return fe(ct);te()})})}else b.type==="publickey"&&y.authPK(b.username,b.key,B,(Q,ee)=>{let fe=b.key.sign(Q,T);if(fe instanceof Error)return fe.message=`Error signing data with key: ${fe.message}`,fe.level="client-authentication",this.emit("error",fe),Y();ee(fe)})},USERAUTH_INFO_REQUEST:($,B,T,Q)=>{if(b.type==="keyboard-interactive"){if((Array.isArray(Q)?Q.length:0)===0){i&&i("Client: Sending automatic USERAUTH_INFO_RESPONSE"),y.authInfoRes();return}b.prompt(B,T,"",Q,fe=>{y.authInfoRes(fe)})}},REQUEST_SUCCESS:($,B)=>{o.length&&o.shift()(!1,B)},REQUEST_FAILURE:$=>{o.length&&o.shift()(!0)},GLOBAL_REQUEST:($,B,T,Q)=>{B==="hostkeys-00@openssh.com"?(Y0(this,Q,(ee,fe)=>{ee||this.emit("hostkeys",fe)}),T&&y.requestSuccess()):T&&y.requestFailure()},CHANNEL_OPEN:($,B)=>{G0(this,B)},CHANNEL_OPEN_CONFIRMATION:($,B)=>{let T=this._chanMgr.get(B.recipient);if(typeof T!="function")return;let Q=T.type==="sftp",fe={type:Q?"session":T.type,incoming:{id:B.recipient,window:Bs,packetSize:Rs,state:"open"},outgoing:{id:B.sender,window:B.window,packetSize:B.packetSize,state:"open"}},ie=Q?new O0(this,fe,{debug:i}):new Ml(this,fe);this._chanMgr.update(B.recipient,ie),T(void 0,ie)},CHANNEL_OPEN_FAILURE:($,B,T,Q)=>{let ee=this._chanMgr.get(B);if(typeof ee!="function")return;W0(this,B,{reason:T,description:Q},ee)},CHANNEL_DATA:($,B,T)=>{let Q=this._chanMgr.get(B);if(!(typeof Q!="object"||Q===null)&&Q.incoming.window!==0){if(Q.incoming.window-=T.length,Q.push(T)===!1){Q._waitChanDrain=!0;return}Q.incoming.window<=Pl&&Nl(Q)}},CHANNEL_EXTENDED_DATA:($,B,T,Q)=>{if(Q!==B0)return;let ee=this._chanMgr.get(B);if(!(typeof ee!="object"||ee===null)&&ee.incoming.window!==0){if(ee.incoming.window-=T.length,!ee.stderr.push(T)){ee._waitChanDrain=!0;return}ee.incoming.window<=Pl&&Nl(ee)}},CHANNEL_WINDOW_ADJUST:($,B,T)=>{let Q=this._chanMgr.get(B);typeof Q!="object"||Q===null||(Q.outgoing.window+=T,Q._waitWindow&&(Q._waitWindow=!1,Q._chunk?Q._write(Q._chunk,null,Q._chunkcb):Q._chunkcb?Q._chunkcb():Q._chunkErr?Q.stderr._write(Q._chunkErr,null,Q._chunkcbErr):Q._chunkcbErr&&Q._chunkcbErr()))},CHANNEL_SUCCESS:($,B)=>{let T=this._chanMgr.get(B);typeof T!="object"||T===null||(this._resetKA(),T._callbacks.length&&T._callbacks.shift()(!1))},CHANNEL_FAILURE:($,B)=>{let T=this._chanMgr.get(B);typeof T!="object"||T===null||(this._resetKA(),T._callbacks.length&&T._callbacks.shift()(!0))},CHANNEL_REQUEST:($,B,T,Q,ee)=>{let fe=this._chanMgr.get(B);if(typeof fe!="object"||fe===null)return;let ie=fe._exit;if(ie.code===void 0){switch(T){case"exit-status":fe.emit("exit",ie.code=ee);return;case"exit-signal":fe.emit("exit",ie.code=null,ie.signal=`SIG${ee.signal}`,ie.dump=ee.coreDumped,ie.desc=ee.errorMessage);return}Q&&$.channelFailure(fe.outgoing.id)}},CHANNEL_EOF:($,B)=>{let T=this._chanMgr.get(B);typeof T!="object"||T===null||T.incoming.state==="open"&&(T.incoming.state="eof",T.readable&&T.push(null),T.stderr.readable&&T.stderr.push(null))},CHANNEL_CLOSE:($,B)=>{q0(this,B,this._chanMgr.get(B))}}});f.pause();let E=this.config.keepaliveInterval,x=this.config.keepaliveCountMax,k=0,D,H=()=>{if(++k>x){if(clearInterval(D),f.readable){let $=new Error("Keepalive timeout");$.level="client-timeout",this.emit("error",$),f.destroy()}return}Pt(f)?(o.push(C),y.ping()):clearInterval(D)};function C(){E>0&&(k=0,clearInterval(D),Pt(f)&&(D=setInterval(H,E)))}this._resetKA=C;let F=(()=>{let $=!1;return()=>{if(!$&&($=!0,N&&!u)){let B=M0("Connection lost before handshake","protocol",!0);this.emit("error",B)}}})(),V=(()=>{let $=!1;return()=>{$||($=!0,N=!0,i&&i("Socket connected"),this.emit("connect"),D0.then(()=>{y.start(),f.on("data",B=>{try{y.parse(B,0,B.length)}catch(T){this.emit("error",T);try{Pt(f)&&f.end()}catch{}}}),f.stderr&&typeof f.stderr.resume=="function"&&f.stderr.resume(),f.resume()}).catch(B=>{this.emit("error",B);try{Pt(f)&&f.end()}catch{}}))}})(),N=!1;f.on("connect",V).on("timeout",()=>{this.emit("timeout")}).on("error",$=>{i&&i(`Socket error: ${$.message}`),clearTimeout(this._readyTimeout),$.level="client-socket",this.emit("error",$)}).on("end",()=>{i&&i("Socket ended"),F(),y.cleanup(),clearTimeout(this._readyTimeout),clearInterval(D),this.emit("end")}).on("close",()=>{i&&i("Socket closed"),F(),y.cleanup(),clearTimeout(this._readyTimeout),clearInterval(D),this.emit("close");let $=o;o=this._callbacks=[];let B=new Error("No response from server");for(let T=0;T<$.length;++T)$[T](B);this._chanMgr.cleanup(B)});let b,S=null,I=null,v=["none"];this.config.password!==void 0&&v.push("password"),a!==void 0&&v.push("publickey"),this._agent!==void 0&&v.push("agent"),this.config.tryKeyboard&&v.push("keyboard-interactive"),a!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&v.push("hostbased"),Array.isArray(s)?s=Dl(s):typeof s!="function"&&(s=Dl(v));let R=!1,ne=$=>{if(!R){if(R=!0,$===!1){let B=new Error("All configured authentication methods failed");B.level="client-authentication",this.emit("error",B),this.end();return}if(typeof $=="string"){let B=$;if(v.indexOf(B)===-1)return z(`Authentication method not allowed: ${B}`);let T=this.config.username;switch(B){case"password":$={type:B,username:T,password:this.config.password};break;case"publickey":$={type:B,username:T,key:a};break;case"hostbased":$={type:B,username:T,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":$={type:B,username:T,agentCtx:new vl(this._agent)};break;case"keyboard-interactive":$={type:B,username:T,prompt:(...Q)=>this.emit("keyboard-interactive",...Q)};break;case"none":$={type:B,username:T};break;default:return z(`Skipping unsupported authentication method: ${$}`)}}else{if(typeof $!="object"||$===null)return z(`Skipping invalid authentication attempt: ${$}`);{let B=$.username;if(typeof B!="string")return z(`Skipping invalid authentication attempt: ${$}`);let T=$.type;switch(T){case"password":{let{password:Q}=$;if(typeof Q!="string"&&!Buffer.isBuffer(Q))return z("Skipping invalid password auth attempt");$={type:T,username:B,password:Q};break}case"publickey":{let Q=vs($.key,$.passphrase);if(Q instanceof Error)return z("Skipping invalid key auth attempt");if(!Q.isPrivateKey())return z("Skipping non-private key");$={type:T,username:B,key:Q};break}case"hostbased":{let{localHostname:Q,localUsername:ee}=$,fe=vs($.key,$.passphrase);if(fe instanceof Error||typeof Q!="string"||typeof ee!="string")return z("Skipping invalid hostbased auth attempt");if(!fe.isPrivateKey())return z("Skipping non-private key");$={type:T,username:B,key:fe,localHostname:Q,localUsername:ee};break}case"agent":{let Q=$.agent;if(typeof Q=="string"&&Q.length)Q=Bl(Q);else if(!Rl(Q))return z(`Skipping invalid agent: ${$.agent}`);$={type:T,username:B,agentCtx:new vl(Q)};break}case"keyboard-interactive":{let{prompt:Q}=$;if(typeof Q!="function")return z("Skipping invalid keyboard-interactive auth attempt");$={type:T,username:B,prompt:Q};break}case"none":$={type:T,username:B};break;default:return z(`Skipping unsupported authentication method: ${$}`)}}}b=$;try{let B=b.username;switch(b.type){case"password":y.authPassword(B,b.password);break;case"publickey":{let T;if(b.keyAlgos=Oa(this,b.key,p),b.keyAlgos)if(b.keyAlgos.length)T=b.keyAlgos[0][0];else return z("Skipping key authentication (no mutual hash algorithm)");y.authPK(B,b.key,T);break}case"hostbased":{let T,Q;if(b.keyAlgos=Oa(this,b.key,p),b.keyAlgos)if(b.keyAlgos.length)[T,Q]=b.keyAlgos[0];else return z("Skipping hostbased authentication (no mutual hash algorithm)");y.authHostbased(B,b.key,b.localHostname,b.localUsername,T,(ee,fe)=>{let ie=b.key.sign(ee,Q);if(ie instanceof Error)return ie.message=`Error while signing with key: ${ie.message}`,ie.level="client-authentication",this.emit("error",ie),Y();fe(ie)});break}case"agent":b.agentCtx.init(T=>{if(T)return T.level="agent",this.emit("error",T),Y();te()});break;case"keyboard-interactive":y.authKeyboard(B);break;case"none":y.authNone(B);break}}finally{R=!1}}};function z($){i&&i($),process.nextTick(Y)}function Y(){R=!1;let $=s(I,S,ne);R||$===void 0||ne($)}let te=()=>{if(b.type==="agent"){let $=b.agentCtx.nextKey();if($===!1)i&&i("Agent: No more keys left to try"),i&&i("Client: agent auth failed"),Y();else{let B=b.agentCtx.pos(),T;if(b.keyAlgos=Oa(this,$,p),b.keyAlgos)if(b.keyAlgos.length)T=b.keyAlgos[0][0];else{i&&i(`Agent: Skipping key #${B+1} (no mutual hash algorithm)`),te();return}i&&i(`Agent: Trying key #${B+1}`),y.authPK(b.username,$,T)}}},ce=()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let $=new Error("Timed out while waiting for handshake");$.level="client-timeout",this.emit("error",$),f.destroy()},this.config.readyTimeout))};if(t.sock)ce(),typeof f.connecting=="boolean"&&f.connecting||V();else{let $=this.config.host,B=this.config.forceIPv4,T=this.config.forceIPv6;i&&i(`Client: Trying ${$} on port ${this.config.port} ...`);let Q=()=>{ce(),f.connect({host:$,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),f.setMaxListeners(0),f.setTimeout(typeof t.timeout=="number"?t.timeout:0)};!B&&!T||B&&T?Q():C0($,B?4:6,(ee,fe,ie)=>{if(ee){let Ye=B?"IPv4":"IPv6",ct=new Error(`Error while looking up ${Ye} address for '${$}': ${ee}`);clearTimeout(this._readyTimeout),ct.level="client-dns",this.emit("error",ct),this.emit("close");return}$=fe,Q()})}return this}end(){return this._sock&&Pt(this._sock)&&(this._protocol.disconnect(Cl.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&Pt(this._sock)&&this._sock.destroy(),this}exec(t,e,r){if(!this._sock||!Pt(this._sock))throw new Error("Not connected");typeof e=="function"&&(r=e,e={});let s={allowHalfOpen:e.allowHalfOpen!==!1};return Or(this,"session",s,(i,o)=>{if(i){r(i);return}let a=[];function c(f){if(f){o.close(),r(f);return}a.length&&a.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&a.push(()=>Ul(o,c)),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(()=>Ll(o,e.pty,c)),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&a.push(()=>Tl(o,e.x11,c))),a.push(()=>V0(o,t,e,r)),a.shift()()}),this}shell(t,e,r){if(!this._sock||!Pt(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),Or(this,"session",(s,i)=>{if(s){r(s);return}let o=[];function a(c){if(c){i.close(),r(c);return}o.length&&o.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&o.push(()=>Ul(i,a)),t!==!1&&o.push(()=>Ll(i,t,a)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&Da(i,e.env),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&o.push(()=>Tl(i,e.x11,a))),o.push(()=>K0(i,r)),o.shift()()}),this}subsys(t,e){if(!this._sock||!Pt(this._sock))throw new Error("Not connected");return Or(this,"session",(r,s)=>{if(r){e(r);return}$a(s,t,(i,o)=>{if(i){e(i);return}e(void 0,o)})}),this}forwardIn(t,e,r){if(!this._sock||!Pt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push((i,o)=>{if(i){r(i!==!0?i:new Error(`Unable to bind to ${t}:${e}`));return}let a=e;e===0&&o&&o.length>=4&&(a=F0(o,0),this._protocol._compatFlags&$l.DYN_RPORT_BUG||(e=a)),this._forwarding[`${t}:${e}`]=a,r(void 0,a)}),this._protocol.tcpipForward(t,e,s),this}unforwardIn(t,e,r){if(!this._sock||!Pt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to unbind from ${t}:${e}`));return}delete this._forwarding[`${t}:${e}`],r()}),this._protocol.cancelTcpipForward(t,e,s),this}forwardOut(t,e,r,s,i){if(!this._sock||!Pt(this._sock))throw new Error("Not connected");let o={srcIP:t,srcPort:e,dstIP:r,dstPort:s};return typeof i!="function"&&(i=Ma),Or(this,"direct-tcpip",o,i),this}openssh_noMoreSessions(t){if(!this._sock||!Pt(this._sock))throw new Error("Not connected");let e=typeof t=="function";return!this.config.strictVendor||this.config.strictVendor&&Ci.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||!Pt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Ci.test(this._remoteVer)?(r&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to bind to ${t}`));return}this._forwardingUnix[t]=!0,e()}),this._protocol.openssh_streamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(t,e){if(!this._sock||!Pt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&Ci.test(this._remoteVer)?(r&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to unbind from ${t}`));return}delete this._forwardingUnix[t],e()}),this._protocol.openssh_cancelStreamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(t,e){if(!this._sock||!Pt(this._sock))throw new Error("Not connected");return typeof e!="function"&&(e=Ma),!this.config.strictVendor||this.config.strictVendor&&Ci.test(this._remoteVer)?(Or(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||!Pt(this._sock))throw new Error("Not connected");return typeof t=="function"&&(e=t,t=void 0),Or(this,"sftp",(r,s)=>{if(r){e(r);return}let i=(o,a)=>{if(o){e(o);return}function c(){s.removeListener("ready",f),s.removeListener("error",l),s.removeListener("exit",u),s.removeListener("close",u)}function f(){c(),e(void 0,s)}function l(h){c(),e(h)}function u(h,p){c();let y;typeof h=="number"?y=`Received exit code ${h} while establishing SFTP session`:p!==void 0?y=`Received signal ${p} while establishing SFTP session`:y="Received unexpected SFTP session termination";let E=new Error(y);E.code=h,E.signal=p,e(E)}s.on("ready",f).on("error",l).on("exit",u).on("close",u),s._init()};typeof t=="object"&&t!==null?Da(s,t,o=>{if(o){e(o);return}$a(s,"sftp",i)}):$a(s,"sftp",i)}),this}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function Or(n,t,e,r){let s=Bs,i=Rs;typeof e=="function"&&(r=e,e={});let o=(c,f)=>{r(c,f)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"session":case"sftp":n._protocol.session(a,s,i);break;case"direct-tcpip":n._protocol.directTcpip(a,s,i,e);break;case"direct-streamlocal@openssh.com":n._protocol.openssh_directStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Tl(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=z0());let s=typeof e=="function";if(n.outgoing.state!=="open"){s&&e(new Error("Channel is not open"));return}s&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to request X11"));return}n._hasX11=!0,++n._client._acceptX11,n.once("close",()=>{n._client._acceptX11&&--n._client._acceptX11}),e()}),n._client._protocol.x11Forward(n.outgoing.id,r,s)}function Ll(n,t,e){let r=24,s=80,i=640,o=480,a="vt100",c=null;typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.rows=="number"&&(r=t.rows),typeof t.cols=="number"&&(s=t.cols),typeof t.width=="number"&&(i=t.width),typeof t.height=="number"&&(o=t.height),typeof t.term=="string"&&(a=t.term),typeof t.modes=="object"&&(c=t.modes));let f=typeof e=="function";if(n.outgoing.state!=="open"){f&&e(new Error("Channel is not open"));return}f&&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,s,o,i,a,c,f)}function Ul(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 K0(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 V0(n,t,e,r){if(n.outgoing.state!=="open"){r(new Error("Channel is not open"));return}n._callbacks.push(s=>{if(s){r(s!==!0?s:new Error("Unable to exec"));return}n.subtype="exec",n.allowHalfOpen=e.allowHalfOpen!==!1,r(void 0,n)}),n._client._protocol.exec(n.outgoing.id,t,!0)}function 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(i=>{if(i){e(i!==!0?i:new Error("Unable to set environment"));return}e()});let s=Object.keys(t||{});for(let i=0;i<s.length;++i){let o=s[i],a=t[o];n._client._protocol.env(n.outgoing.id,o,a,r)}}function $a(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 G0(n,t){let e=-1,r,s=()=>{let c={type:t.type,incoming:{id:e,window:Bs,packetSize:Rs,state:"open"},outgoing:{id:t.sender,window:t.window,packetSize:t.packetSize,state:"open"}},f=new Ml(n,c);return n._chanMgr.update(e,f),n._protocol.channelOpenConfirm(t.sender,e,Bs,Rs),f},i=()=>{r===void 0&&(e===-1?r=wi.RESOURCE_SHORTAGE:r=wi.CONNECT_FAILED),e!==-1&&n._chanMgr.remove(e),n._protocol.channelOpenFail(t.sender,r,"")},o=()=>(e=n._chanMgr.add(),e===-1&&(r=wi.RESOURCE_SHORTAGE,n.config.debug&&n.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),e!==-1),a=t.data;switch(t.type){case"forwarded-tcpip":{let c=n._forwarding[`${a.destIP}:${a.destPort}`];if(c!==void 0&&o()){a.destPort===0&&(a.destPort=c),n.emit("tcp connection",a,s,i);return}break}case"forwarded-streamlocal@openssh.com":if(n._forwardingUnix[a.socketPath]!==void 0&&o()){n.emit("unix connection",a,s,i);return}break;case"auth-agent@openssh.com":if(n._agentFwdEnabled&&typeof n._agent.getStream=="function"&&o()){n._agent.getStream((c,f)=>{if(c)return i();let l=s();l.pipe(f).pipe(l)});return}break;case"x11":if(n._acceptX11!==0&&o()){n.emit("x11",a,s,i);return}break;default:r=wi.UNKNOWN_CHANNEL_TYPE,n.config.debug&&n.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${t.type}`)}r===void 0&&(r=wi.ADMINISTRATIVELY_PROHIBITED,n.config.debug&&n.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+t.type)),i()}var z0=(()=>{let n=Buffer.allocUnsafe(16);return()=>(w0(n,0,16),n.hexSlice(0,16))})();function Dl(n){if(!Array.isArray(n))throw new Error("authList must be an array");let t=0;return(e,r,s)=>t===n.length?!1:n[t++]}function Y0(n,t,e){if(!n._sock||!Pt(n._sock))return;if(typeof e!="function"&&(e=Ma),!Array.isArray(t))throw new TypeError("Invalid keys argument type");let r=[];for(let s of t){let i=vs(s);if(i instanceof Error)throw i;r.push(i)}if(!n.config.strictVendor||n.config.strictVendor&&Ci.test(n._remoteVer)){n._callbacks.push((s,i)=>{if(s){e(s!==!0?s:new Error("Server failed to prove supplied keys"));return}let o=[],a=0;for(Cs.init(i,0);Cs.avail()&&a!==r.length;){let c=r[a++],f=c.getPublicSSH(),l=Cs.readString();ks.init(l,0);let u=ks.readString(!0),h=ks.readString(),p;if(u!==c.type)if(c.type==="ssh-rsa")switch(u){case"rsa-sha2-256":p="sha256";break;case"rsa-sha2-512":p="sha512";break;default:continue}else continue;let y=n._protocol._kex.sessionID,E=Buffer.allocUnsafe(37+y.length+4+f.length),x=0;Ua(E,29,x),E.utf8Write("hostkeys-prove-00@openssh.com",x+=4,29),Ua(E,y.length,x+=29),kl(y,E,0,y.length,x+=4),Ua(E,f.length,x+=y.length),kl(f,E,0,f.length,x+=4),(h=H0(h,u))&&c.verify(E,h,p)===!0&&o.push(c)}ks.clear(),Cs.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 Oa(n,t,e){switch(t.type){case"ssh-rsa":if(n._protocol._compatFlags&$l.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"]]}}Fl.exports=Fa});var Ql=at(Hl=>{"use strict";var{Agent:Wa}=require("http"),{Agent:j0}=require("https"),{connect:X0}=require("tls"),Qa;for(let n of[Wa,j0]){class t extends n{constructor(r,s){super(s),this._connectCfg=r,this._defaultSrcIP=s&&s.srcIP||"localhost"}createConnection(r,s){let i=r&&r.localAddress||this._defaultSrcIP,o=r&&r.localPort||0,a=r.host,c=r.port;Qa===void 0&&(Qa=Ha());let f=new Qa,l=!1;f.on("ready",()=>{f.forwardOut(i,o,a,c,(u,h)=>{if(l=!0,u)return f.end(),s(u);h.once("close",()=>f.end()),s(null,J0(h,n,r))})}).on("error",s).on("close",()=>{l||s(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}Hl[n===Wa?"SSHTTPAgent":"SSHTTPSAgent"]=t}function ki(){}function J0(n,t,e){if(t===Wa)return n.setKeepAlive=ki,n.setNoDelay=ki,n.setTimeout=ki,n.ref=ki,n.unref=ki,n.destroySoon=n.destroy,n;e.socket=n;let r=X0(e),s=(()=>{let i=!1;return()=>{i||(i=!0,n.isPaused()&&n.resume())}})();return r.on("end",s).on("close",s),r}});var ql=at((WE,Ga)=>{"use strict";var{Server:Z0}=require("net"),Bi=require("events"),{listenerCount:Kt}=Bi,{CHANNEL_OPEN_FAILURE:Mr,DEFAULT_CIPHER:em,DEFAULT_COMPRESSION:tm,DEFAULT_KEX:nm,DEFAULT_MAC:rm,DEFAULT_SERVER_HOST_KEY:im,DISCONNECT_REASON:Fr,DISCONNECT_REASON_BY_VALUE:sm,SUPPORTED_CIPHER:om,SUPPORTED_COMPRESSION:am,SUPPORTED_KEX:cm,SUPPORTED_MAC:fm,SUPPORTED_SERVER_HOST_KEY:lm}=Pn(),{init:um}=Qn(),{KexInit:dm}=hs(),{parseKey:Wl}=Kn(),hm=ga(),{SFTP:pm}=bi(),{writeUInt32BE:gm}=hn(),{Channel:Hr,MAX_WINDOW:zn,PACKET_SIZE:Yn,windowAdjust:mm,WINDOW_THRESHOLD:Am}=Na(),{ChannelManager:Em,generateAlgorithmList:vi,isWritable:Ns,onChannelOpenFailure:_m,onCHANNEL_CLOSE:ym}=La(),bm=10,jn=class extends Bi{constructor(t,e,r,s,i){super(),this.username=this.user=e,this.service=r,this.method=s,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(o,a,c)=>{this._finalResponse||(this._finalResponse=!0,i(this,o,a,c))},this._protocol=t}accept(){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!0)}reject(t,e){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!1,t,e)}},Ps=class extends jn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this._multistep=!0,this._cb=void 0,this._onInfoResponse=a=>{let c=this._cb;c&&(this._cb=void 0,c(a))},this.submethods=i,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(t,e,r,s){Array.isArray(t)||(t=[t]),typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"?(s=r,r=void 0):typeof s!="function"&&(s=void 0);for(let i=0;i<t.length;++i)typeof t[i]=="string"&&(t[i]={prompt:t[i],echo:!0});this._cb=s,this._initialResponse=!0,this._protocol.authInfoReq(e,r,t)}},Ka=class extends jn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob}accept(){this.signature?jn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},Va=class extends jn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob,this.localHostname=i.localHostname,this.localUsername=i.localUsername}},Ts=class extends jn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.password=i,this._changeCb=void 0}requestChange(t,e){if(this._changeCb)throw new Error("Change request already in progress");if(typeof t!="string")throw new Error("prompt argument must be a string");if(typeof e!="function")throw new Error("Callback argument must be a function");this._changeCb=e,this._protocol.authPasswdChg(t)}},bn=class extends Bi{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:zn,packetSize:Yn,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}}}},on=class extends Bi{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new Error("Missing configuration object");let r=Object.create(null),s=[],i=t.hostKeys;if(!Array.isArray(i))throw new Error("hostKeys must be an array");let o=typeof t.algorithms=="object"&&t.algorithms!==null?t.algorithms:{},a=vi(o.serverHostKey,im,lm);for(let h=0;h<i.length;++h){let p;if(Buffer.isBuffer(i[h])||typeof i[h]=="string"?p=Wl(i[h]):p=Wl(i[h].key,i[h].passphrase),p instanceof Error)throw new Error(`Cannot parse privateKey: ${p.message}`);if(Array.isArray(p)&&(p=p[0]),p.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!s.includes(p.type))if(p.type==="ssh-rsa"){let y=a.indexOf("ssh-rsa"),E=a.indexOf("rsa-sha2-256"),x=a.indexOf("rsa-sha2-512");y===-1&&(y=1/0),[y,E,x].sort(xm).forEach(k=>{if(k===-1)return;let D;switch(k){case y:D="ssh-rsa";break;case E:D="rsa-sha2-256";break;case x:D="rsa-sha2-512";break;default:return}r[D]=p,s.push(D)})}else r[p.type]=p,s.push(p.type)}let c={kex:vi(o.kex,nm,cm).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:s,cs:{cipher:vi(o.cipher,em,om),mac:vi(o.hmac,rm,fm),compress:vi(o.compress,tm,am),lang:[]},sc:void 0};c.sc=c.cs,typeof e=="function"&&this.on("connection",e);let f=typeof t.debug=="function"?t.debug:void 0,l=t.ident?Buffer.from(t.ident):void 0,u=new dm(c);this._srv=new Z0(h=>{if(this._connections>=this.maxConnections){h.destroy();return}++this._connections,h.once("close",()=>{--this._connections});let p;if(f){let y=`[${process.hrtime().join(".")}] `;p=E=>{f(`${y}${E}`)}}new Ls(h,r,l,u,p,this,t)}).on("error",h=>{this.emit("error",h)}).on("listening",()=>{this.emit("listening")}).on("close",()=>{this.emit("close")}),this._connections=0,this.maxConnections=1/0}injectSocket(t){this._srv.emit("connection",t)}listen(...t){return this._srv.listen(...t),this}address(){return this._srv.address()}getConnections(t){return this._srv.getConnections(t),this}close(t){return this._srv.close(t),this}ref(){return this._srv.ref(),this}unref(){return this._srv.unref(),this}};on.KEEPALIVE_CLIENT_INTERVAL=15e3;on.KEEPALIVE_CLIENT_COUNT_MAX=3;var Ls=class extends Bi{constructor(t,e,r,s,i,o,a){super();let c=0,f=!1,l=[],u,h,p,y=[];this._sock=t,this._chanMgr=new Em(this),this._debug=i,this.noMoreSessions=!1,this.authenticated=!1;function E(N){}this.on("error",E);let x=i?(N,b,S)=>{i(`Debug output from client: ${JSON.stringify(S)}`)}:void 0,k=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof on.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(on.KEEPALIVE_CLIENT_INTERVAL)&&on.KEEPALIVE_CLIENT_INTERVAL>0?on.KEEPALIVE_CLIENT_INTERVAL:-1,D=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof on.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(on.KEEPALIVE_CLIENT_COUNT_MAX)&&on.KEEPALIVE_CLIENT_COUNT_MAX>=0?on.KEEPALIVE_CLIENT_COUNT_MAX:-1,H=0;k!==-1&&D!==-1&&(this.once("ready",()=>{let N=()=>{clearInterval(h)};this.on("close",N).on("end",N),h=setInterval(()=>{if(++H>D){clearInterval(h);let b=new Error("Keepalive timeout");b.level="client-timeout",this.emit("error",b),this.end()}else C.ping()},k)}),p=()=>{h&&h.refresh(),H=0});let C=this._protocol=new hm({server:!0,hostKeys:e,ident:r,offer:s,onPacket:p,greeting:a.greeting,banner:a.banner,onWrite:N=>{Ns(t)&&t.write(N)},onError:N=>{C._destruct||t.removeAllListeners("data"),this.emit("error",N);try{t.end()}catch{}},onHeader:N=>{this.removeListener("error",E);let b={ip:t.remoteAddress,family:t.remoteFamily,port:t.remotePort,header:N};if(!o.emit("connection",this,b)){C.disconnect(Fr.BY_APPLICATION),t.end();return}N.greeting&&this.emit("greeting",N.greeting)},onHandshakeComplete:N=>{++c>1&&this.emit("rekey"),this.emit("handshake",N)},debug:i,messageHandlers:{DEBUG:x,DISCONNECT:(N,b,S)=>{if(b!==Fr.BY_APPLICATION){S||(S=sm[b],S===void 0&&(S=`Unexpected disconnection reason: ${b}`));let I=new Error(S);I.code=b,this.emit("error",I)}t.end()},CHANNEL_OPEN:(N,b)=>{if(b.type==="session"&&this.noMoreSessions||!this.authenticated){let te=Mr.ADMINISTRATIVELY_PROHIBITED;return C.channelOpenFail(b.sender,te)}let S=-1,I,v=!1,R,ne=()=>{v||(v=!0,I===void 0&&(S===-1?I=Mr.RESOURCE_SHORTAGE:I=Mr.CONNECT_FAILED),S!==-1&&this._chanMgr.remove(S),C.channelOpenFail(b.sender,I,""))},z=()=>(S=this._chanMgr.add(),S===-1&&(I=Mr.RESOURCE_SHORTAGE,i&&i("Automatic rejection of incoming channel open: no channels available")),S!==-1),Y=b.data;switch(b.type){case"session":if(Kt(this,"session")&&z()){R=()=>{if(v)return;v=!0;let te=new bn(this,b,S);return this._chanMgr.update(S,te),C.channelOpenConfirm(b.sender,S,zn,Yn),te},this.emit("session",R,ne);return}break;case"direct-tcpip":if(Kt(this,"tcpip")&&z()){R=()=>{if(v)return;v=!0;let te={type:void 0,incoming:{id:S,window:zn,packetSize:Yn,state:"open"},outgoing:{id:b.sender,window:b.window,packetSize:b.packetSize,state:"open"}},ce=new Hr(this,te,{server:!0});return this._chanMgr.update(S,ce),C.channelOpenConfirm(b.sender,S,zn,Yn),ce},this.emit("tcpip",R,ne,Y);return}break;case"direct-streamlocal@openssh.com":if(Kt(this,"openssh.streamlocal")&&z()){R=()=>{if(v)return;v=!0;let te={type:void 0,incoming:{id:S,window:zn,packetSize:Yn,state:"open"},outgoing:{id:b.sender,window:b.window,packetSize:b.packetSize,state:"open"}},ce=new Hr(this,te,{server:!0});return this._chanMgr.update(S,ce),C.channelOpenConfirm(b.sender,S,zn,Yn),ce},this.emit("openssh.streamlocal",R,ne,Y);return}break;default:I=Mr.UNKNOWN_CHANNEL_TYPE,i&&i(`Automatic rejection of unsupported incoming channel open type: ${b.type}`)}I===void 0&&(I=Mr.ADMINISTRATIVELY_PROHIBITED,i&&i(`Automatic rejection of unexpected incoming channel open for: ${b.type}`)),ne()},CHANNEL_OPEN_CONFIRMATION:(N,b)=>{let S=this._chanMgr.get(b.recipient);if(typeof S!="function")return;let I={type:S.type,incoming:{id:b.recipient,window:zn,packetSize:Yn,state:"open"},outgoing:{id:b.sender,window:b.window,packetSize:b.packetSize,state:"open"}},v=new Hr(this,I,{server:!0});this._chanMgr.update(b.recipient,v),S(void 0,v)},CHANNEL_OPEN_FAILURE:(N,b,S,I)=>{let v=this._chanMgr.get(b);if(typeof v!="function")return;_m(this,b,{reason:S,description:I},v)},CHANNEL_DATA:(N,b,S)=>{let I=this._chanMgr.get(b);if(!(typeof I!="object"||I===null)&&!(I.constructor===bn&&(I=I._channel,!I))&&I.incoming.window!==0){if(I.incoming.window-=S.length,I.push(S)===!1){I._waitChanDrain=!0;return}I.incoming.window<=Am&&mm(I)}},CHANNEL_EXTENDED_DATA:(N,b,S,I)=>{},CHANNEL_WINDOW_ADJUST:(N,b,S)=>{let I=this._chanMgr.get(b);typeof I!="object"||I===null||I.constructor===bn&&(I=I._channel,!I)||(I.outgoing.window+=S,I._waitWindow&&(I._waitWindow=!1,I._chunk?I._write(I._chunk,null,I._chunkcb):I._chunkcb?I._chunkcb():I._chunkErr?I.stderr._write(I._chunkErr,null,I._chunkcbErr):I._chunkcbErr&&I._chunkcbErr()))},CHANNEL_SUCCESS:(N,b)=>{let S=this._chanMgr.get(b);typeof S!="object"||S===null||S.constructor===bn&&(S=S._channel,!S)||S._callbacks.length&&S._callbacks.shift()(!1)},CHANNEL_FAILURE:(N,b)=>{let S=this._chanMgr.get(b);typeof S!="object"||S===null||S.constructor===bn&&(S=S._channel,!S)||S._callbacks.length&&S._callbacks.shift()(!0)},CHANNEL_REQUEST:(N,b,S,I,v)=>{let R=this._chanMgr.get(b);if(typeof R!="object"||R===null)return;let ne=!1,z,Y;if(R.constructor!==bn){I&&C.channelFailure(R.outgoing.id);return}if(I&&(S!=="shell"&&S!=="exec"&&S!=="subsystem"&&(z=()=>{ne||R._ending||R._channel||(ne=!0,C.channelSuccess(R._chanInfo.outgoing.id))}),Y=()=>{ne||R._ending||R._channel||(ne=!0,C.channelFailure(R._chanInfo.outgoing.id))}),R._ending){Y&&Y();return}switch(S){case"env":if(Kt(R,"env")){R.emit("env",z,Y,{key:v.name,val:v.value});return}break;case"pty-req":if(Kt(R,"pty")){R.emit("pty",z,Y,v);return}break;case"window-change":Kt(R,"window-change")?R.emit("window-change",z,Y,v):Y&&Y();break;case"x11-req":if(Kt(R,"x11")){R.emit("x11",z,Y,v);return}break;case"signal":if(Kt(R,"signal")){R.emit("signal",z,Y,{name:v});return}break;case"auth-agent-req@openssh.com":if(Kt(R,"auth-agent")){R.emit("auth-agent",z,Y);return}break;case"shell":if(Kt(R,"shell")){z=()=>{if(ne||R._ending||R._channel)return;ne=!0,I&&C.channelSuccess(R._chanInfo.outgoing.id);let te=new Hr(this,R._chanInfo,{server:!0});return te.subtype=R.subtype=S,R._channel=te,te},R.emit("shell",z,Y);return}break;case"exec":if(Kt(R,"exec")){z=()=>{if(ne||R._ending||R._channel)return;ne=!0,I&&C.channelSuccess(R._chanInfo.outgoing.id);let te=new Hr(this,R._chanInfo,{server:!0});return te.subtype=R.subtype=S,R._channel=te,te},R.emit("exec",z,Y,{command:v});return}break;case"subsystem":{let te=v==="sftp";if(z=()=>{if(ne||R._ending||R._channel)return;ne=!0,I&&C.channelSuccess(R._chanInfo.outgoing.id);let ce;return te?ce=new pm(this,R._chanInfo,{server:!0,debug:i}):(ce=new Hr(this,R._chanInfo,{server:!0}),ce.subtype=R.subtype=`${S}:${v}`),R._channel=ce,ce},v==="sftp"){if(Kt(R,"sftp")){R.emit("sftp",z,Y);return}te=!1}if(Kt(R,"subsystem")){R.emit("subsystem",z,Y,{name:v});return}break}}i&&i(`Automatic rejection of incoming channel request: ${S}`),Y&&Y()},CHANNEL_EOF:(N,b)=>{let S=this._chanMgr.get(b);typeof S!="object"||S===null||S.constructor===bn&&(S._ending||(S._ending=!0,S.emit("eof"),S.emit("end")),S=S._channel,!S)||S.incoming.state==="open"&&(S.incoming.state="eof",S.readable&&S.push(null))},CHANNEL_CLOSE:(N,b)=>{let S=this._chanMgr.get(b);typeof S!="object"||S===null||S.constructor===bn&&(S._ending=!0,S.emit("close"),S=S._channel,!S)||ym(this,b,S)},SERVICE_REQUEST:(N,b)=>{if(c===0||f||this.authenticated||b!=="ssh-userauth"){C.disconnect(Fr.SERVICE_NOT_AVAILABLE),t.end();return}f=!0,C.serviceAccept(b)},USERAUTH_REQUEST:(N,b,S,I,v)=>{if(c===0||this.authenticated||u&&(u.username!==b||u.service!==S)||I!=="password"&&I!=="publickey"&&I!=="hostbased"&&I!=="keyboard-interactive"&&I!=="none"||l.length===bm){C.disconnect(Fr.PROTOCOL_ERROR),t.end();return}else if(S!=="ssh-connection"){C.disconnect(Fr.SERVICE_NOT_AVAILABLE),t.end();return}let R;switch(I){case"keyboard-interactive":R=new Ps(C,b,S,I,v,F);break;case"publickey":R=new Ka(C,b,S,I,v,F);break;case"hostbased":R=new Va(C,b,S,I,v,F);break;case"password":if(u&&u instanceof Ts&&u._changeCb){let ne=u._changeCb;u._changeCb=void 0,ne(v.newPassword);return}R=new Ts(C,b,S,I,v,F);break;case"none":R=new jn(C,b,S,I,F);break}if(u)if(u._initialResponse)u._multistep&&!u._finalResponse&&(u._cleanup&&u._cleanup(),u.emit("abort"));else return l.push(R);u=R,Kt(this,"authentication")?this.emit("authentication",u):u.reject()},USERAUTH_INFO_RESPONSE:(N,b)=>{u&&u instanceof Ps&&u._onInfoResponse(b)},GLOBAL_REQUEST:(N,b,S,I)=>{let v={type:null,buf:null};function R(ne,z){v.type=ne,v.buf=z,V()}if(S&&y.push(v),(b==="tcpip-forward"||b==="cancel-tcpip-forward"||b==="no-more-sessions@openssh.com"||b==="streamlocal-forward@openssh.com"||b==="cancel-streamlocal-forward@openssh.com")&&Kt(this,"request")&&this.authenticated){let ne,z;if(S){let Y=!1;ne=te=>{if(Y)return;Y=!0;let ce;b==="tcpip-forward"&&I.bindPort===0&&typeof te=="number"&&(ce=Buffer.allocUnsafe(4),gm(ce,te,0)),R("SUCCESS",ce)},z=()=>{Y||(Y=!0,R("FAILURE"))}}if(b==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,ne&&ne();return}this.emit("request",ne,z,b,I)}else S&&R("FAILURE")}}});t.pause(),um.then(()=>{C.start(),t.on("data",N=>{try{C.parse(N,0,N.length)}catch(b){this.emit("error",b);try{Ns(t)&&t.end()}catch{}}}),t.resume()}).catch(N=>{this.emit("error",N);try{Ns(t)&&t.end()}catch{}}),t.on("error",N=>{N.level="socket",this.emit("error",N)}).once("end",()=>{i&&i("Socket ended"),C.cleanup(),this.emit("end")}).once("close",()=>{i&&i("Socket closed"),C.cleanup(),this.emit("close");let N=new Error("No response from server");this._chanMgr.cleanup(N)});let F=(N,b,S,I)=>{u===N&&!this.authenticated&&(b?(u=void 0,this.authenticated=!0,C.authSuccess(),l=[],this.emit("ready")):(C.authFailure(S,I),l.length&&(u=l.pop(),Kt(this,"authentication")?this.emit("authentication",u):u.reject())))};function V(){for(;y.length>0&&y[0].type;){let N=y.shift();N.type==="SUCCESS"&&C.requestSuccess(N.buf),N.type==="FAILURE"&&C.requestFailure()}}}end(){return this._sock&&Ns(this._sock)&&(this._protocol.disconnect(Fr.BY_APPLICATION),this._sock.end()),this}x11(t,e,r){return qa(this,"x11",{originAddr:t,originPort:e},r),this}forwardOut(t,e,r,s,i){return qa(this,"forwarded-tcpip",{boundAddr:t,boundPort:e,remoteAddr:r,remotePort:s},i),this}openssh_forwardOutStreamLocal(t,e){return qa(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 qa(n,t,e,r){let s=zn,i=Yn;typeof e=="function"&&(r=e,e={});let o=(c,f)=>{r(c,f)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"forwarded-tcpip":n._protocol.forwardedTcpip(a,s,i,e);break;case"x11":n._protocol.x11(a,s,i,e);break;case"forwarded-streamlocal@openssh.com":n._protocol.openssh_forwardedStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function xm(n,t){return n-t}Ga.exports=on;Ga.exports.IncomingClient=Ls});var Yl=at((qE,zl)=>{"use strict";var{createCipheriv:Sm,generateKeyPair:wm,generateKeyPairSync:Im,getCurves:Cm,randomBytes:Kl}=require("crypto"),{Ber:Et}=ni(),km=uo().pbkdf,{CIPHER_INFO:vm}=Qn(),Bm=16,Rm=16,Nm=Cm(),Pm=new Map(Object.entries(vm));function Vl(n,t){if(typeof n!="string")throw new TypeError("Key type must be a string");let e={type:"spki",format:"der"},r={type:"pkcs8",format:"der"};switch(n.toLowerCase()){case"rsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for RSA key");let s=t.bits;if(!Number.isInteger(s))throw new TypeError("RSA bits must be an integer");if(s<=0||s>16384)throw new RangeError("RSA bits must be non-zero and <= 16384");return["rsa",{modulusLength:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ecdsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for ECDSA key");if(!Number.isInteger(t.bits))throw new TypeError("ECDSA bits must be an integer");let s;switch(t.bits){case 256:s="prime256v1";break;case 384:s="secp384r1";break;case 521:s="secp521r1";break;default:throw new Error("ECDSA bits must be 256, 384, or 521")}if(!Nm.includes(s))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ed25519":return["ed25519",{publicKeyEncoding:e,privateKeyEncoding:r}];default:throw new Error(`Unsupported key type: ${n}`)}}function Tm(n,t,e){switch(n){case"rsa":{let r=new Et.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()!==Et.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 Et.Reader(r.readString(Et.OctetString,!0)),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");let s=r.readString(Et.Integer,!0),i=r.readString(Et.Integer,!0),o=r.readString(Et.Integer,!0),a=r.readString(Et.Integer,!0),c=r.readString(Et.Integer,!0);r.readString(Et.Integer,!0),r.readString(Et.Integer,!0);let f=r.readString(Et.Integer,!0),l=Buffer.from("ssh-rsa"),u=Buffer.allocUnsafe(4+l.length+4+s.length+4+i.length+4+o.length+4+f.length+4+a.length+4+c.length),h=0;u.writeUInt32BE(l.length,h+=0),u.set(l,h+=4),u.writeUInt32BE(s.length,h+=l.length),u.set(s,h+=4),u.writeUInt32BE(i.length,h+=s.length),u.set(i,h+=4),u.writeUInt32BE(o.length,h+=i.length),u.set(o,h+=4),u.writeUInt32BE(f.length,h+=o.length),u.set(f,h+=4),u.writeUInt32BE(a.length,h+=f.length),u.set(a,h+=4),u.writeUInt32BE(c.length,h+=a.length),u.set(c,h+=4);let p=Buffer.allocUnsafe(4+l.length+4+i.length+4+s.length);return h=0,p.writeUInt32BE(l.length,h+=0),p.set(l,h+=4),p.writeUInt32BE(i.length,h+=l.length),p.set(i,h+=4),p.writeUInt32BE(s.length,h+=i.length),p.set(s,h+=4),{sshName:l.toString(),priv:u,pub:p}}case"ec":{let r=new Et.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");r.readOID();let s=r.readString(Et.BitString,!0);{let h=0;for(;h<s.length&&s[h]===0;++h);h>0&&(s=s.slice(h))}if(r=new Et.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");let i=r.readOID(),o;switch(i){case"1.2.840.10045.3.1.7":o="nistp256";break;case"1.3.132.0.34":o="nistp384";break;case"1.3.132.0.35":o="nistp521";break;default:throw new Error("Unsupported curve in ECDSA private key")}if(r=new Et.Reader(r.readString(Et.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(Et.OctetString,!0)]),c=Buffer.from(`ecdsa-sha2-${o}`);o=Buffer.from(o);let f=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length+4+a.length),l=0;f.writeUInt32BE(c.length,l+=0),f.set(c,l+=4),f.writeUInt32BE(o.length,l+=c.length),f.set(o,l+=4),f.writeUInt32BE(s.length,l+=o.length),f.set(s,l+=4),f.writeUInt32BE(a.length,l+=s.length),f.set(a,l+=4);let u=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length);return l=0,u.writeUInt32BE(c.length,l+=0),u.set(c,l+=4),u.writeUInt32BE(o.length,l+=c.length),u.set(o,l+=4),u.writeUInt32BE(s.length,l+=o.length),u.set(s,l+=4),{sshName:c.toString(),priv:f,pub:u}}case"ed25519":{let r=new Et.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let s=r.readString(Et.BitString,!0);{let l=0;for(;l<s.length&&s[l]===0;++l);l>0&&(s=s.slice(l))}if(r=new Et.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 Et.Reader(r.readString(Et.OctetString,!0));let i=r.readString(Et.OctetString,!0),o=Buffer.from("ssh-ed25519"),a=Buffer.allocUnsafe(4+o.length+4+s.length+4+(i.length+s.length)),c=0;a.writeUInt32BE(o.length,c+=0),a.set(o,c+=4),a.writeUInt32BE(s.length,c+=o.length),a.set(s,c+=4),a.writeUInt32BE(i.length+s.length,c+=s.length),a.set(i,c+=4),a.set(s,c+=i.length);let f=Buffer.allocUnsafe(4+o.length+4+s.length);return c=0,f.writeUInt32BE(o.length,c+=0),f.set(o,c+=4),f.writeUInt32BE(s.length,c+=o.length),f.set(s,c+=4),{sshName:o.toString(),priv:a,pub:f}}}}function Gl(n,t,e,r){let s="new",i,o="";if(typeof r=="object"&&r!==null&&(typeof r.comment=="string"&&r.comment&&(o=r.comment),typeof r.format=="string"&&r.format&&(s=r.format),r.passphrase)){let a;if(typeof r.passphrase=="string")a=Buffer.from(r.passphrase);else if(Buffer.isBuffer(r.passphrase))a=r.passphrase;else throw new Error("Invalid passphrase");if(r.cipher===void 0)throw new Error("Missing cipher name");let c=Pm.get(r.cipher);if(c===void 0)throw new Error("Invalid cipher name");if(s==="new"){let f=Rm;if(r.rounds!==void 0){if(!Number.isInteger(r.rounds))throw new TypeError("rounds must be an integer");r.rounds>0&&(f=r.rounds)}let l=Buffer.allocUnsafe(c.keyLen+c.ivLen),u=Kl(Bm);if(km(a,a.length,u,u.length,l,l.length,f)!==0)return new Error("Failed to generate information to encrypt key");let p=Buffer.allocUnsafe(4+u.length+4);{let y=0;p.writeUInt32BE(u.length,y+=0),p.set(u,y+=4),p.writeUInt32BE(f,y+=u.length)}i={cipher:c,cipherName:r.cipher,kdfName:"bcrypt",kdfOptions:p,key:l.slice(0,c.keyLen),iv:l.slice(c.keyLen)}}}switch(s){case"new":{let a=`-----BEGIN OPENSSH PRIVATE KEY-----
15
- `,c,f=Buffer.from(i?i.cipherName:"none"),l=Buffer.from(i?i.kdfName:"none"),u=i?i.kdfOptions:Buffer.alloc(0),h=i?i.cipher.blockLen:8,p=Tm(n,t,e),y=Kl(4),E=Buffer.from(o),x=8+p.priv.length+4+E.length,k=[];for(let V=1;(x+k.length)%h;++V)k.push(V&255);k=Buffer.from(k);let D=Buffer.allocUnsafe(x+k.length),H;{let V=0;D.set(y,V+=0),D.set(y,V+=4),D.set(p.priv,V+=4),D.writeUInt32BE(E.length,V+=p.priv.length),D.set(E,V+=4),D.set(k,V+=E.length)}if(i){let V={authTagLength:i.cipher.authLen},N=Sm(i.cipher.sslName,i.key,i.iv,V);N.setAutoPadding(!1),D=Buffer.concat([N.update(D),N.final()]),i.cipher.authLen>0?H=N.getAuthTag():H=Buffer.alloc(0),i.key.fill(0),i.iv.fill(0)}else H=Buffer.alloc(0);let C=Buffer.from("openssh-key-v1\0"),F=Buffer.allocUnsafe(C.length+4+f.length+4+l.length+4+u.length+4+4+p.pub.length+4+D.length+H.length);{let V=0;F.set(C,V+=0),F.writeUInt32BE(f.length,V+=C.length),F.set(f,V+=4),F.writeUInt32BE(l.length,V+=f.length),F.set(l,V+=4),F.writeUInt32BE(u.length,V+=l.length),F.set(u,V+=4),F.writeUInt32BE(1,V+=u.length),F.writeUInt32BE(p.pub.length,V+=4),F.set(p.pub,V+=4),F.writeUInt32BE(D.length,V+=p.pub.length),F.set(D,V+=4),F.set(H,V+=D.length)}{let V=F.base64Slice(0,F.length),N=V.replace(/.{64}/g,`$&
16
- `);V.length&63&&(N+=`
17
- `),a+=N}{let V=p.pub.base64Slice(0,p.pub.length);c=`${p.sshName} ${V}${o?` ${o}`:""}`}return a+=`-----END OPENSSH PRIVATE KEY-----
18
- `,{private:a,public:c}}default:throw new Error("Invalid output key format")}}function Lm(){}zl.exports={generateKeyPair:(n,t,e)=>{typeof t=="function"&&(e=t,t=void 0),typeof e!="function"&&(e=Lm);let r=Vl(n,t);wm(...r,(s,i,o)=>{if(s)return e(s);let a;try{a=Gl(r[0],i,o,t)}catch(c){return e(c)}e(null,a)})},generateKeyPairSync:(n,t)=>{let e=Vl(n,t),{publicKey:r,privateKey:s}=Im(...e);return Gl(e[0],r,s,t)}}});var za=at((KE,jl)=>{"use strict";var{AgentProtocol:Um,BaseAgent:Dm,createAgent:$m,CygwinAgent:Om,OpenSSHAgent:Mm,PageantAgent:Fm}=ea(),{SSHTTPAgent:Hm,SSHTTPSAgent:Qm}=Ql(),{parseKey:Wm}=Kn(),{flagsToString:qm,OPEN_MODE:Km,STATUS_CODE:Vm,stringToFlags:Gm}=bi();jl.exports={AgentProtocol:Um,BaseAgent:Dm,createAgent:$m,Client:Ha(),CygwinAgent:Om,HTTPAgent:Hm,HTTPSAgent:Qm,OpenSSHAgent:Mm,PageantAgent:Fm,Server:ql(),utils:{parseKey:Wm,...Yl(),sftp:{flagsToString:qm,OPEN_MODE:Km,STATUS_CODE:Vm,stringToFlags:Gm}}}});var Qh=require("node:events"),Wh=Vt(za(),1);var Dh=require("node:events");var Xl={name:"adduser",description:"Add a new user",category:"users",params:["<username>"],run:({authUser:n,shell:t,args:e})=>{if(n!=="root")return{stderr:`adduser: permission denied
14
+ ${e}`}};var om=2**32,el=(()=>{try{return new Function("return 2n ** 32n")()}catch{}})();bi.ERR_OUT_OF_RANGE=class nl extends RangeError{constructor(t,e,r,s){super(),Error.captureStackTrace(this,nl),ws(e,'Missing "range" argument');let i=s?t:`The value of "${t}" is out of range.`,o;Number.isInteger(r)&&Math.abs(r)>om?o=Jf(String(r)):typeof r=="bigint"?(o=String(r),(r>el||r<-el)&&(o=Jf(o)),o+="n"):o=sm(r),i+=` It must be ${e}. Received ${o}`,this.message=i}};var Is=class n extends TypeError{constructor(t,e,r){super(),Error.captureStackTrace(this,n),ws(typeof t=="string","'name' must be a string");let s;typeof e=="string"&&e.startsWith("not ")?(s="must not be",e=e.replace(/^not /,"")):s="must be";let i;if(t.endsWith(" argument"))i=`The ${t} ${s} ${Zf(e,"type")}`;else{let o=t.includes(".")?"property":"argument";i=`The "${t}" ${o} ${s} ${Zf(e,"type")}`}i+=`. Received type ${typeof r}`,this.message=i}};bi.ERR_INVALID_ARG_TYPE=Is;bi.validateNumber=function(t,e){if(typeof t!="number")throw new Is(e,"number",t)}});var xi=ct((KE,ml)=>{"use strict";var am=require("events"),zn=require("fs"),{constants:Zt}=zn,{Readable:fl,Writable:ka}=require("stream"),{inherits:ll,types:{isDate:xa}}=require("util"),cm=Buffer[Symbol.species],{bufferCopy:Gn,bufferSlice:$r,makeBufferParser:fm,writeUInt32BE:V}=gn(),Dn={SIZE:1,UIDGID:2,PERMISSIONS:4,ACMODTIME:8,EXTENDED:2147483648},Re=Buffer.alloc(28),et={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},lm=new Map(Object.values(et).map(n=>[n,1])),um={[et.OK]:"No error",[et.EOF]:"End of file",[et.NO_SUCH_FILE]:"No such file or directory",[et.PERMISSION_DENIED]:"Permission denied",[et.FAILURE]:"Failure",[et.BAD_MESSAGE]:"Bad message",[et.NO_CONNECTION]:"No connection",[et.CONNECTION_LOST]:"Connection lost",[et.OP_UNSUPPORTED]:"Operation unsupported"},ke={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},en={VERSION:2,STATUS:101,HANDLE:102,DATA:103,NAME:104,ATTRS:105,EXTENDED:201},Ie={READ:1,WRITE:2,APPEND:4,CREAT:8,TRUNC:16,EXCL:32},il=2*1024,ut=2**32-1,dm=Buffer.from([0,0,0,5,ke.INIT,0,0,0,3]),hm=Buffer.from([0,0,0,5,en.VERSION,0,0,0,3]),pm=/^SSH-2.0-(?:OpenSSH|dropbear)/,_a=256*1024,O=fm(),gm={readable:!1,writable:!1,push:n=>{},once:()=>{},on:()=>{},emit:()=>{},end:()=>{}};function ul(){}var Sa=class extends am{constructor(t,e,r){super(),(typeof r!="object"||!r)&&(r={});let s=t._protocol._remoteIdentRaw;this.server=!!r.server,this._debug=typeof r.debug=="function"?r.debug:void 0,this._isOpenSSH=s&&pm.test(s),this._version=-1,this._extensions={},this._biOpt=r.biOpt,this._pktLenBytes=0,this._pktLen=0,this._pktPos=0,this._pktType=0,this._pktData=void 0,this._writeReqid=-1,this._requests={},this._maxInPktLen=_a,this._maxOutPktLen=34e3,this._maxReadLen=(this._isOpenSSH?_a:34e3)-il,this._maxWriteLen=(this._isOpenSSH?_a:34e3)-il,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=gm,this.readable=!0}push(t){if(t===null){if(gl(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 it(this,"Invalid packet length");if(this._pktLen>this._maxInPktLen){let a=this._maxInPktLen;return it(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 cm(t.buffer,t.byteOffset+e,o):(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(new Uint8Array(t.buffer,t.byteOffset+e,o),this._pktPos)):o===this._pktLen?this._pkt=t:(this._pkt||(this._pkt=Buffer.allocUnsafe(this._pktLen)),this._pkt.set(t,this._pktPos)),e+=o,this._pktPos+=o,this._pktPos<this._pktLen)return}let r=this._pkt[0],s=this._pkt;this._pktLen=0,this._pktLenBytes=0,this._pkt=void 0,this._pktPos=0;let i=this.server?_m[r]:ym[r];if(!i)return it(this,`Unknown packet type ${r}`);if(this._version===-1){if(this.server){if(r!==ke.INIT)return it(this,`Expected INIT packet, got ${r}`)}else if(r!==en.VERSION)return it(this,`Expected VERSION packet, got ${r}`)}if(i(this,s)===!1)return}}end(){this.destroy()}destroy(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._protocol.channelClose(this.outgoing.id))}_init(){this._init=ul,this.server||Xe(this,dm)}createReadStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new $n(this,t,e)}createWriteStream(t,e){if(this.server)throw new Error("Client-only method called in server mode");return new pn(this,t,e)}open(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");typeof r=="function"&&(s=r,r=void 0);let i=typeof e=="number"?e:hl(e);if(i===null)throw new Error(`Unknown flags string: ${e}`);let o=0,a=0;(typeof r=="string"||typeof r=="number")&&(r={mode:r}),typeof r=="object"&&r!==null&&(r=lr(r),o=r.flags,a=r.nb);let c=Buffer.byteLength(t),f=9,l=Buffer.allocUnsafe(13+c+4+4+a);V(l,l.length-4,0),l[4]=ke.OPEN;let u=this._writeReqid=this._writeReqid+1&ut;V(l,u,5),V(l,c,f),l.utf8Write(t,f+=4,c),V(l,i,f+=c),V(l,o,f+=4),a&&(f+=4,a===Re.length?l.set(Re,f):Gn(Re,l,0,a,f),f+=a),this._requests[u]={cb:s};let h=Xe(this,l);this._debug&&this._debug(`SFTP: Outbound: ${h?"Buffered":"Sending"} OPEN`)}close(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=ke.CLOSE;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} CLOSE`)}read(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>=e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");dl(this,t,e,r,s,i,o)}readData(t,e,r,s,i,o){this.read(t,e,r,s,i,o)}write(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");if(!Buffer.isBuffer(e))throw new Error("buffer is not a Buffer");if(r>e.length)throw new Error("offset is out of bounds");if(r+s>e.length)throw new Error("length extends beyond buffer");if(i===null)throw new Error("null position currently unsupported");if(!s){o&&process.nextTick(o,void 0,0);return}let a=this._maxWriteLen,c=Math.max(s-a,0),f=i;c&&(s=a);let l=t.length,u=9,h=Buffer.allocUnsafe(13+l+8+4+s);V(h,h.length-4,0),h[4]=ke.WRITE;let p=this._writeReqid=this._writeReqid+1&ut;V(h,p,5),V(h,l,u),h.set(t,u+=4),u+=l;for(let E=7;E>=0;--E)h[u+E]=i&255,i/=256;V(h,s,u+=8),Gn(e,h,r,r+s,u+=4),this._requests[p]={cb:E=>{E?typeof o=="function"&&o(E):c?this.write(t,e,r+s,c,f+s,o):typeof o=="function"&&o(void 0,r+s)}};let y=Xe(this,h);if(this._debug){let E=y?"Sent":"Buffered";this._debug(`SFTP: Outbound: ${E} WRITE (id:${p})`)}}writeData(t,e,r,s,i,o){this.write(t,e,r,s,i,o)}fastGet(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");sl(this,zn,t,e,r,s)}fastPut(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");sl(zn,this,t,e,r,s)}readFile(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s;if(typeof r=="function"?s=r:typeof e=="function"&&(s=e,e=void 0),typeof e=="string")e={encoding:e,flag:"r"};else if(!e)e={encoding:null,flag:"r"};else if(typeof e!="object")throw new TypeError("Bad arguments");let i=e.encoding;if(i&&!Buffer.isEncoding(i))throw new Error(`Unknown encoding: ${i}`);let o,a,c,f=0,l,u=0,h=e.flag||"r",p=()=>{o===0?(a=Buffer.allocUnsafe(8192),this.read(l,a,0,8192,u,y)):this.read(l,a,f,o-f,u,y)},y=(b,C)=>{let N;if(b){if(N=b.code===et.EOF,!N)return this.close(l,()=>s&&s(b))}else N=!1;if(N||o===0&&C===0)return E();u+=C,f+=C,o!==0?f===o?E():p():(c.push($r(a,0,C)),p())};y._wantEOFError=!0;let E=()=>{this.close(l,b=>(o===0?a=Buffer.concat(c,f):f<o&&(a=$r(a,0,f)),i&&(a=a.toString(i)),s&&s(b,a)))};this.open(t,h,438,(b,C)=>{if(b)return s&&s(b);l=C;let N=(H,v)=>{if(H){this.stat(t,(M,Q)=>{if(M)return this.close(l,()=>{s&&s(H)});N(null,Q)});return}if(o=v.size||0,o===0)return c=[],p();a=Buffer.allocUnsafe(o),p()};this.fstat(l,N)})}writeFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"w"};else if(!r)r={encoding:"utf8",mode:438,flag:"w"};else if(typeof r!="object")throw new TypeError("Bad arguments");if(r.encoding&&!Buffer.isEncoding(r.encoding))throw new Error(`Unknown encoding: ${r.encoding}`);let o=r.flag||"w";this.open(t,o,r.mode,(a,c)=>{if(a)i&&i(a);else{let f=Buffer.isBuffer(e)?e:Buffer.from(""+e,r.encoding||"utf8"),l=/a/.test(o)?null:0;if(l===null){let u=(h,p)=>{if(h){this.stat(t,(y,E)=>{if(y)return this.close(c,()=>{i&&i(h)});u(null,E)});return}wa(this,c,f,0,f.length,p.size,i)};this.fstat(c,u);return}wa(this,c,f,0,f.length,l,i)}})}appendFile(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");let i;if(typeof s=="function"?i=s:typeof r=="function"&&(i=r,r=void 0),typeof r=="string")r={encoding:r,mode:438,flag:"a"};else if(!r)r={encoding:"utf8",mode:438,flag:"a"};else if(typeof r!="object")throw new TypeError("Bad arguments");r.flag||(r=Object.assign({flag:"a"},r)),this.writeFile(t,e,r,i)}exists(t,e){if(this.server)throw new Error("Client-only method called in server mode");this.stat(t,r=>{e&&e(!r)})}unlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=ke.REMOVE;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REMOVE`)}rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(t),i=Buffer.byteLength(e),o=9,a=Buffer.allocUnsafe(13+s+4+i);V(a,a.length-4,0),a[4]=ke.RENAME;let c=this._writeReqid=this._writeReqid+1&ut;V(a,c,5),V(a,s,o),a.utf8Write(t,o+=4,s),V(a,i,o+=s),a.utf8Write(e,o+=4,i),this._requests[c]={cb:r};let f=Xe(this,a);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} RENAME`)}mkdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="function"&&(r=e,e=void 0),typeof e=="object"&&e!==null&&(e=lr(e),s=e.flags,i=e.nb);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);V(c,c.length-4,0),c[4]=ke.MKDIR;let f=this._writeReqid=this._writeReqid+1&ut;V(c,f,5),V(c,o,a),c.utf8Write(t,a+=4,o),V(c,s,a+=o),i&&(a+=4,i===Re.length?c.set(Re,a):Gn(Re,c,0,i,a),a+=i),this._requests[f]={cb:r};let l=Xe(this,c);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),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=ke.RMDIR;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} RMDIR`)}readdir(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");typeof e=="function"&&(r=e,e={}),(typeof e!="object"||e===null)&&(e={});let s=!(e&&e.full);if(!Buffer.isBuffer(t)&&typeof t!="string")throw new Error("missing directory handle or path");if(typeof t=="string"){let l=[],u=0,h=(p,y)=>{if(p)return r(p);this.readdir(y,e,(E,b)=>{let C=E&&E.code===et.EOF;if(E&&!C)return this.close(y,()=>r(E));if(C)return this.close(y,N=>{if(N)return r(N);r(void 0,l)});for(let N=0;N<b.length;++N,++u)l[u]=b[N];h(void 0,y)})};return this.opendir(t,h)}let i=t.length,o=9,a=Buffer.allocUnsafe(13+i);V(a,a.length-4,0),a[4]=ke.READDIR;let c=this._writeReqid=this._writeReqid+1&ut;V(a,c,5),V(a,i,o),a.set(t,o+=4),this._requests[c]={cb:s?(l,u)=>{if(typeof r=="function"){if(l)return r(l);for(let h=u.length-1;h>=0;--h)(u[h].filename==="."||u[h].filename==="..")&&u.splice(h,1);r(void 0,u)}}:r};let f=Xe(this,a);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} READDIR`)}fstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let r=t.length,s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=ke.FSTAT;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.set(t,s+=4),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} FSTAT`)}stat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=ke.STAT;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STAT`)}lstat(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=ke.LSTAT;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} LSTAT`)}opendir(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=ke.OPENDIR;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:e};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} OPENDIR`)}setstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=0,i=0;typeof e=="object"&&e!==null?(e=lr(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=Buffer.byteLength(t),a=9,c=Buffer.allocUnsafe(13+o+4+i);V(c,c.length-4,0),c[4]=ke.SETSTAT;let f=this._writeReqid=this._writeReqid+1&ut;V(c,f,5),V(c,o,a),c.utf8Write(t,a+=4,o),V(c,s,a+=o),i&&(a+=4,i===Re.length?c.set(Re,a):Gn(Re,c,0,i,a),a+=i),this._requests[f]={cb:r};let l=Xe(this,c);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 s=0,i=0;typeof e=="object"&&e!==null?(e=lr(e),s=e.flags,i=e.nb):typeof e=="function"&&(r=e);let o=t.length,a=9,c=Buffer.allocUnsafe(13+o+4+i);V(c,c.length-4,0),c[4]=ke.FSETSTAT;let f=this._writeReqid=this._writeReqid+1&ut;V(c,f,5),V(c,o,a),c.set(t,a+=4),V(c,s,a+=o),i&&(a+=4,i===Re.length?c.set(Re,a):Gn(Re,c,0,i,a),a+=i),this._requests[f]={cb:r};let l=Xe(this,c);this._debug&&this._debug(`SFTP: Outbound: ${l?"Buffered":"Sending"} FSETSTAT`)}futimes(t,e,r,s){return this.fsetstat(t,{atime:Ur(e),mtime:Ur(r)},s)}utimes(t,e,r,s){return this.setstat(t,{atime:Ur(e),mtime:Ur(r)},s)}fchown(t,e,r,s){return this.fsetstat(t,{uid:e,gid:r},s)}chown(t,e,r,s){return this.setstat(t,{uid:e,gid:r},s)}fchmod(t,e,r){return this.fsetstat(t,{mode:e},r)}chmod(t,e,r){return this.setstat(t,{mode:e},r)}readlink(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=ke.READLINK;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,f)=>{if(typeof e=="function"){if(c)return e(c);if(!f||!f.length)return e(new Error("Response missing link info"));e(void 0,f[0].filename)}}};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} READLINK`)}symlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=Buffer.byteLength(e),i=Buffer.byteLength(t),o=9,a=Buffer.allocUnsafe(13+s+4+i);V(a,a.length-4,0),a[4]=ke.SYMLINK;let c=this._writeReqid=this._writeReqid+1&ut;V(a,c,5),this._isOpenSSH?(V(a,i,o),a.utf8Write(t,o+=4,i),V(a,s,o+=i),a.utf8Write(e,o+=4,s)):(V(a,s,o),a.utf8Write(e,o+=4,s),V(a,i,o+=s),a.utf8Write(t,o+=4,i)),this._requests[c]={cb:r};let f=Xe(this,a);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} SYMLINK`)}realpath(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=Buffer.byteLength(t),s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=ke.REALPATH;let o=this._writeReqid=this._writeReqid+1&ut;V(i,o,5),V(i,r,s),i.utf8Write(t,s+=4,r),this._requests[o]={cb:(c,f)=>{if(typeof e=="function"){if(c)return e(c);if(!f||!f.length)return e(new Error("Response missing path info"));e(void 0,f[0].filename)}}};let a=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} REALPATH`)}ext_openssh_rename(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");let s=this._extensions["posix-rename@openssh.com"];if(!s||s!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(41+i+4+o);V(c,c.length-4,0),c[4]=ke.EXTENDED;let f=this._writeReqid=this._writeReqid+1&ut;V(c,f,5),V(c,24,a),c.utf8Write("posix-rename@openssh.com",a+=4,24),V(c,i,a+=24),c.utf8Write(t,a+=4,i),V(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[f]={cb:r};let l=Xe(this,c);if(this._debug){let u=l?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${u} posix-rename@openssh.com`)}}ext_openssh_statvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["statvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(36+s);V(o,o.length-4,0),o[4]=ke.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,19,i),o.utf8Write("statvfs@openssh.com",i+=4,19),V(o,s,i+=19),o.utf8Write(t,i+=4,s),this._requests[a]={extended:"statvfs@openssh.com",cb:e};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} statvfs@openssh.com`)}}ext_openssh_fstatvfs(t,e){if(this.server)throw new Error("Client-only method called in server mode");let r=this._extensions["fstatvfs@openssh.com"];if(!r||r!=="2")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(37+s);V(o,o.length-4,0),o[4]=ke.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,20,i),o.utf8Write("fstatvfs@openssh.com",i+=4,20),V(o,s,i+=20),o.set(t,i+=4),this._requests[a]={extended:"fstatvfs@openssh.com",cb:e};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} fstatvfs@openssh.com`)}}ext_openssh_hardlink(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["hardlink@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=Buffer.byteLength(t),o=Buffer.byteLength(e),a=9,c=Buffer.allocUnsafe(37+i+4+o);V(c,c.length-4,0),c[4]=ke.EXTENDED;let f=this._writeReqid=this._writeReqid+1&ut;V(c,f,5),V(c,20,a),c.utf8Write("hardlink@openssh.com",a+=4,20),V(c,i,a+=20),c.utf8Write(t,a+=4,i),V(c,o,a+=i),c.utf8Write(e,a+=4,o),this._requests[f]={cb:r};let l=Xe(this,c);if(this._debug){let u=l?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${u} hardlink@openssh.com`)}}ext_openssh_fsync(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["fsync@openssh.com"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("handle is not a Buffer");let s=t.length,i=9,o=Buffer.allocUnsafe(34+s);V(o,o.length-4,0),o[4]=ke.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,17,i),o.utf8Write("fsync@openssh.com",i+=4,17),V(o,s,i+=17),o.set(t,i+=4),this._requests[a]={cb:e};let c=Xe(this,o);this._debug&&this._debug(`SFTP: Outbound: ${c?"Buffered":"Sending"} fsync@openssh.com`)}ext_openssh_lsetstat(t,e,r){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["lsetstat@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let i=0,o=0;typeof e=="object"&&e!==null?(e=lr(e),i=e.flags,o=e.nb):typeof e=="function"&&(r=e);let a=Buffer.byteLength(t),c=9,f=Buffer.allocUnsafe(37+a+4+o);V(f,f.length-4,0),f[4]=ke.EXTENDED;let l=this._writeReqid=this._writeReqid+1&ut;V(f,l,5),V(f,20,c),f.utf8Write("lsetstat@openssh.com",c+=4,20),V(f,a,c+=20),f.utf8Write(t,c+=4,a),V(f,i,c+=a),o&&(c+=4,o===Re.length?f.set(Re,c):Gn(Re,f,0,o,c),c+=o),this._requests[l]={cb:r};let u=Xe(this,f);if(this._debug){let h=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} lsetstat@openssh.com`)}}ext_openssh_expandPath(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["expand-path@openssh.com"]!=="1")throw new Error("Server does not support this extended request");let s=Buffer.byteLength(t),i=9,o=Buffer.allocUnsafe(40+s);V(o,o.length-4,0),o[4]=ke.EXTENDED;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,5),V(o,23,i),o.utf8Write("expand-path@openssh.com",i+=4,23),V(o,s,i+=20),o.utf8Write(t,i+=4,s),this._requests[a]={cb:(f,l)=>{if(typeof e=="function"){if(f)return e(f);if(!l||!l.length)return e(new Error("Response missing expanded path"));e(void 0,l[0].filename)}}};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} expand-path@openssh.com`)}}ext_copy_data(t,e,r,s,i,o){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["copy-data"]!=="1")throw new Error("Server does not support this extended request");if(!Buffer.isBuffer(t))throw new Error("Source handle is not a Buffer");if(!Buffer.isBuffer(s))throw new Error("Destination handle is not a Buffer");let c=0,f=Buffer.allocUnsafe(26+t.length+8+8+4+s.length+8);V(f,f.length-4,c),c+=4,f[c]=ke.EXTENDED,++c;let l=this._writeReqid=this._writeReqid+1&ut;V(f,l,c),c+=4,V(f,9,c),c+=4,f.utf8Write("copy-data",c,9),c+=9,V(f,t.length,c),c+=4,f.set(t,c),c+=t.length;for(let h=7;h>=0;--h)f[c+h]=e&255,e/=256;c+=8;for(let h=7;h>=0;--h)f[c+h]=r&255,r/=256;c+=8,V(f,s.length,c),c+=4,f.set(s,c),c+=s.length;for(let h=7;h>=0;--h)f[c+h]=i&255,i/=256;this._requests[l]={cb:o};let u=Xe(this,f);if(this._debug){let h=u?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${h} copy-data`)}}ext_home_dir(t,e){if(this.server)throw new Error("Client-only method called in server mode");if(this._extensions["home-directory"]!=="1")throw new Error("Server does not support this extended request");if(typeof t!="string")throw new TypeError("username is not a string");let s=0,i=Buffer.byteLength(t),o=Buffer.allocUnsafe(31+i);V(o,o.length-4,s),s+=4,o[s]=ke.EXTENDED,++s;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,s),s+=4,V(o,14,s),s+=4,o.utf8Write("home-directory",s,14),s+=14,V(o,i,s),s+=4,o.utf8Write(t,s,i),s+=i,this._requests[a]={cb:(f,l)=>{if(typeof e=="function"){if(f)return e(f);if(!l||!l.length)return e(new Error("Response missing home directory"));e(void 0,l[0].filename)}}};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} 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 f of t)if(!Number.isInteger(f)||f<0||f>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 f of e)if(!Number.isInteger(f)||f<0||f>2**32-1)throw new Error("gid values must all be 32-bit unsigned integers");let i=0,o=Buffer.allocUnsafe(47+4*t.length+4+4*e.length);V(o,o.length-4,i),i+=4,o[i]=ke.EXTENDED,++i;let a=this._writeReqid=this._writeReqid+1&ut;V(o,a,i),i+=4,V(o,30,i),i+=4,o.utf8Write("users-groups-by-id@openssh.com",i,30),i+=30,V(o,4*t.length,i),i+=4;for(let f of t)V(o,f,i),i+=4;V(o,4*e.length,i),i+=4;for(let f of e)V(o,f,i),i+=4;this._requests[a]={extended:"users-groups-by-id@openssh.com",cb:r};let c=Xe(this,o);if(this._debug){let f=c?"Buffered":"Sending";this._debug(`SFTP: Outbound: ${f} users-groups-by-id@openssh.com`)}}handle(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Buffer.isBuffer(e))throw new Error("handle is not a Buffer");let r=e.length;if(r>256)throw new Error("handle too large (> 256 bytes)");let s=9,i=Buffer.allocUnsafe(13+r);V(i,i.length-4,0),i[4]=en.HANDLE,V(i,t,5),V(i,r,s),r&&i.set(e,s+=4);let o=Xe(this,i);this._debug&&this._debug(`SFTP: Outbound: ${o?"Buffered":"Sending"} HANDLE`)}status(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");if(!lm.has(e))throw new Error(`Bad status code: ${e}`);r||(r="");let s=Buffer.byteLength(r),i=9,o=Buffer.allocUnsafe(17+s+4);V(o,o.length-4,0),o[4]=en.STATUS,V(o,t,5),V(o,e,i),V(o,s,i+=4),i+=4,s&&(o.utf8Write(r,i,s),i+=s),V(o,0,i);let a=Xe(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} STATUS`)}data(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");let s=Buffer.isBuffer(e);if(!s&&typeof e!="string")throw new Error("data is not a Buffer or string");let i;!s&&!r&&(r=void 0,i=!0);let o=s?e.length:Buffer.byteLength(e,r),a=9,c=Buffer.allocUnsafe(13+o);V(c,c.length-4,0),c[4]=en.DATA,V(c,t,5),V(c,o,a),o&&(s?c.set(e,a+=4):i?c.utf8Write(e,a+=4,o):c.write(e,a+=4,o,r));let f=Xe(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"Buffered":"Sending"} DATA`)}name(t,e){if(!this.server)throw new Error("Server-only method called in client mode");if(!Array.isArray(e)){if(typeof e!="object"||e===null)throw new Error("names is not an object or array");e=[e]}let r=e.length,s=0,i,o=[];for(let l=0;l<r;++l){let u=e[l],h=!u||!u.filename||typeof u.filename!="string"?"":u.filename;s+=4+Buffer.byteLength(h);let p=!u||!u.longname||typeof u.longname!="string"?"":u.longname;if(s+=4+Buffer.byteLength(p),typeof u.attrs=="object"&&u.attrs!==null){if(i=lr(u.attrs),s+=4+i.nb,i.nb){let y;i.nb===Re.length?y=new Uint8Array(Re):(y=new Uint8Array(i.nb),Gn(Re,y,0,i.nb,0)),i.bytes=y}o.push(i)}else s+=4,o.push(null)}let a=9,c=Buffer.allocUnsafe(13+s);V(c,c.length-4,0),c[4]=en.NAME,V(c,t,5),V(c,r,a),a+=4;for(let l=0;l<r;++l){let u=e[l];{let p=!u||!u.filename||typeof u.filename!="string"?"":u.filename,y=Buffer.byteLength(p);V(c,y,a),a+=4,y&&(c.utf8Write(p,a,y),a+=y)}{let p=!u||!u.longname||typeof u.longname!="string"?"":u.longname,y=Buffer.byteLength(p);V(c,y,a),a+=4,y&&(c.utf8Write(p,a,y),a+=y)}let h=o[l];h?(V(c,h.flags,a),a+=4,h.flags&&h.bytes&&(c.set(h.bytes,a),a+=h.nb)):(V(c,0,a),a+=4)}let f=Xe(this,c);this._debug&&this._debug(`SFTP: Outbound: ${f?"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=lr(e);let r=e.flags,s=e.nb,i=9,o=Buffer.allocUnsafe(13+s);V(o,o.length-4,0),o[4]=en.ATTRS,V(o,t,5),V(o,r,i),s&&(i+=4,s===Re.length?o.set(Re,i):Gn(Re,o,0,s,i),i+=s);let a=Xe(this,o);this._debug&&this._debug(`SFTP: Outbound: ${a?"Buffered":"Sending"} ATTRS`)}};function mm(n){try{return Buffer.allocUnsafe(n)}catch(t){return t}}function dl(n,t,e,r,s,i,o,a){let c=n._maxReadLen,f=Math.max(s-c,0);f&&(s=c);let l=t.length,u=9,h=i,p=Buffer.allocUnsafe(13+l+8+4);V(p,p.length-4,0),p[4]=ke.READ;let y=n._writeReqid=n._writeReqid+1&ut;V(p,y,5),V(p,l,u),p.set(t,u+=4),u+=l;for(let C=7;C>=0;--C)p[u+C]=h&255,h/=256;V(p,s,u+=8),typeof o!="function"&&(o=ul);let E=a||{nb:0,position:i,off:r,origOff:r,len:void 0,overflow:void 0,cb:(C,N,H)=>{let v=E.len,M=E.overflow;if(C){if(o._wantEOFError||C.code!==et.EOF)return o(C)}else{if(H>v)return o(new Error("Received more data than requested"));if(H===v&&M){E.nb+=H,E.position+=H,E.off+=H,dl(n,t,e,E.off,M,E.position,o,E);return}}H=H||0,E.origOff===0&&e.length===E.nb?N=e:N=$r(e,E.origOff,E.origOff+E.nb+H),o(void 0,E.nb+H,N,E.position)},buffer:void 0};E.len=s,E.overflow=f,E.buffer=$r(e,r,r+s),n._requests[y]=E;let b=Xe(n,p);n._debug&&n._debug(`SFTP: Outbound: ${b?"Buffered":"Sending"} READ`)}function sl(n,t,e,r,s,i){let o=64,a=32768,c,f,l;typeof s=="function"?i=s:typeof s=="object"&&s!==null&&(typeof s.concurrency=="number"&&s.concurrency>0&&!isNaN(s.concurrency)&&(o=s.concurrency),typeof s.chunkSize=="number"&&s.chunkSize>0&&!isNaN(s.chunkSize)&&(a=s.chunkSize),typeof s.fileSize=="number"&&s.fileSize>0&&!isNaN(s.fileSize)&&(l=s.fileSize),typeof s.step=="function"&&(c=s.step),(typeof s.mode=="string"||typeof s.mode=="number")&&(f=Ba(s.mode)));let u,h=0,p=0,y=!1,E,b,C,N=a*o;function H(v){if(y)return;y=!0;let M=0,Q;E||b?(Q=()=>{--M===0&&i(v)},E&&(n===zn||n.outgoing.state==="open")&&++M,b&&(t===zn||t.outgoing.state==="open")&&++M,E&&(n===zn||n.outgoing.state==="open")&&n.close(E,Q),b&&(t===zn||t.outgoing.state==="open")&&t.close(b,Q)):i(v)}n.open(e,"r",(v,M)=>{if(v)return H(v);E=M,l===void 0?n.fstat(E,Q):Q(null,{size:l});function Q(P,x){if(P){if(n!==zn){n.stat(e,(w,I)=>{if(w)return H(P);Q(null,I)});return}return H(P)}u=x.size,t.open(r,"w",(w,I)=>{if(w)return H(w);if(b=I,u<=0)return H();for(;N>u;){if(o===1){N=u;break}N-=a,--o}if(C=mm(N),C instanceof Error)return H(C);f!==void 0?t.fchmod(b,f,function Y(te){if(te){t.chmod(r,f,ce=>Y());return}z()}):z();function k(Y,te,ce,$,B,L){if(Y)return H(Y);B=B||0,t.write(b,C,B,te,$,K);function K(ee){if(ee)return H(ee);if(p+=te,c&&c(p,te,u),te<L)return ne(B,$+te,L-te);if(p===u){t.close(b,ie=>{if(b=void 0,ie)return H(ie);n.close(E,Ye=>{if(E=void 0,Ye)return H(Ye);i()})});return}if(h>=u)return;let fe=h+a>u?u-h:a;ne(B,h,fe),h+=fe}}function R(Y,te,ce){return($,B,L)=>{k($,B,L,te,Y,ce)}}function ne(Y,te,ce){n.read(E,C,Y,ce,te,R(Y,te,ce))}function z(){let Y=0,te=0;for(;h<u&&Y<o;){let ce=h+a>u?u-h:a;ne(te,h,ce),te+=ce,h+=ce,++Y}}})}})}function wa(n,t,e,r,s,i,o){let a=typeof o=="function"?o:void 0;n.write(t,e,r,s,i,(c,f)=>{if(c)return n.close(t,()=>{a&&a(c)});f===s?n.close(t,a):(r+=f,s-=f,i+=f,wa(n,t,e,r,s,i,a))})}var vs=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&Zt.S_IFMT)===Zt.S_IFDIR}isFile(){return(this.mode&Zt.S_IFMT)===Zt.S_IFREG}isBlockDevice(){return(this.mode&Zt.S_IFMT)===Zt.S_IFBLK}isCharacterDevice(){return(this.mode&Zt.S_IFMT)===Zt.S_IFCHR}isSymbolicLink(){return(this.mode&Zt.S_IFMT)===Zt.S_IFLNK}isFIFO(){return(this.mode&Zt.S_IFMT)===Zt.S_IFIFO}isSocket(){return(this.mode&Zt.S_IFMT)===Zt.S_IFSOCK}};function lr(n){let t=0,e=0;if(typeof n=="object"&&n!==null){if(typeof n.size=="number"){t|=Dn.SIZE;let r=n.size;Re[e++]=r/72057594037927940,Re[e++]=r/281474976710656,Re[e++]=r/1099511627776,Re[e++]=r/4294967296,Re[e++]=r/16777216,Re[e++]=r/65536,Re[e++]=r/256,Re[e++]=r}if(typeof n.uid=="number"&&typeof n.gid=="number"){t|=Dn.UIDGID;let r=n.uid,s=n.gid;Re[e++]=r>>>24,Re[e++]=r>>>16,Re[e++]=r>>>8,Re[e++]=r,Re[e++]=s>>>24,Re[e++]=s>>>16,Re[e++]=s>>>8,Re[e++]=s}if(typeof n.mode=="number"||typeof n.mode=="string"){let r=Ba(n.mode);t|=Dn.PERMISSIONS,Re[e++]=r>>>24,Re[e++]=r>>>16,Re[e++]=r>>>8,Re[e++]=r}if((typeof n.atime=="number"||xa(n.atime))&&(typeof n.mtime=="number"||xa(n.mtime))){let r=Ur(n.atime),s=Ur(n.mtime);t|=Dn.ACMODTIME,Re[e++]=r>>>24,Re[e++]=r>>>16,Re[e++]=r>>>8,Re[e++]=r,Re[e++]=s>>>24,Re[e++]=s>>>16,Re[e++]=s>>>8,Re[e++]=s}}return{flags:t,nb:e}}function Ur(n){if(typeof n=="number"&&n===n)return n;if(xa(n))return parseInt(n.getTime()/1e3,10);throw new Error(`Cannot parse time: ${n}`)}function Ba(n){if(typeof n=="number"&&n===n)return n;if(typeof n=="string")return Ba(parseInt(n,8));throw new Error(`Cannot parse mode: ${n}`)}var Ia={r:Ie.READ,"r+":Ie.READ|Ie.WRITE,w:Ie.TRUNC|Ie.CREAT|Ie.WRITE,wx:Ie.TRUNC|Ie.CREAT|Ie.WRITE|Ie.EXCL,xw:Ie.TRUNC|Ie.CREAT|Ie.WRITE|Ie.EXCL,"w+":Ie.TRUNC|Ie.CREAT|Ie.READ|Ie.WRITE,"wx+":Ie.TRUNC|Ie.CREAT|Ie.READ|Ie.WRITE|Ie.EXCL,"xw+":Ie.TRUNC|Ie.CREAT|Ie.READ|Ie.WRITE|Ie.EXCL,a:Ie.APPEND|Ie.CREAT|Ie.WRITE,ax:Ie.APPEND|Ie.CREAT|Ie.WRITE|Ie.EXCL,xa:Ie.APPEND|Ie.CREAT|Ie.WRITE|Ie.EXCL,"a+":Ie.APPEND|Ie.CREAT|Ie.READ|Ie.WRITE,"ax+":Ie.APPEND|Ie.CREAT|Ie.READ|Ie.WRITE|Ie.EXCL,"xa+":Ie.APPEND|Ie.CREAT|Ie.READ|Ie.WRITE|Ie.EXCL};function hl(n){let t=Ia[n];return t!==void 0?t:null}var Am=(()=>{let n=Object.keys(Ia);return t=>{for(let e=0;e<n.length;++e){let r=n[e];if(Ia[r]===t)return r}return null}})();function Dr(n){let t=O.readUInt32BE();if(t===void 0)return;let e=new vs;if(t&Dn.SIZE){let r=O.readUInt64BE(n);if(r===void 0)return;e.size=r}if(t&Dn.UIDGID){let r=O.readUInt32BE(),s=O.readUInt32BE();if(s===void 0)return;e.uid=r,e.gid=s}if(t&Dn.PERMISSIONS){let r=O.readUInt32BE();if(r===void 0)return;e.mode=r}if(t&Dn.ACMODTIME){let r=O.readUInt32BE(),s=O.readUInt32BE();if(s===void 0)return;e.atime=r,e.mtime=s}if(t&Dn.EXTENDED){let r=O.readUInt32BE();if(r===void 0)return;let s={};for(let i=0;i<r;++i){let o=O.readString(!0),a=O.readString();if(a===void 0)return;s[o]=a}e.extended=s}return e}function Xe(n,t){let e=pl(n,t);return e!==void 0?(n._buffer.push(e),!1):!0}function pl(n,t){let e=n.outgoing;if(e.state!=="open")return;if(e.window===0)return n._waitWindow=!0,n._chunkcb=ol,t;let r,s=t.length,i=0;for(;s-i>0&&e.window>0;){let o=Math.min(s-i,e.window,e.packetSize);e.window-=o,e.window===0&&(n._waitWindow=!0,n._chunkcb=ol),i===0&&o===s?n._protocol.channelData(n.outgoing.id,t):n._protocol.channelData(n.outgoing.id,$r(t,i,i+o)),i+=o}return s-i>0&&(i>0?r=$r(t,i,s):r=t),r}function ol(){this._chunkcb=void 0;let n=this._buffer,t=0;for(;t<n.length;){let e=n[t],r=pl(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 it(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(),gl(n),!1}function gl(n){let t=Object.keys(n._requests);if(t.length===0)return;let e=n._requests;n._requests={};let r=new Error("No response from server");for(let s=0;s<t.length;++s){let i=e[t[s]];typeof i.cb=="function"&&i.cb(r)}}function Em(n,t){let e=9,r=Buffer.allocUnsafe(31);V(r,r.length-4,0),r[4]=ke.EXTENDED;let s=n._writeReqid=n._writeReqid+1&ut;V(r,s,5),V(r,18,e),r.utf8Write("limits@openssh.com",e+=4,18),n._requests[s]={extended:"limits@openssh.com",cb:t};let i=Xe(n,r);if(n._debug){let o=i?"Buffered":"Sending";n._debug(`SFTP: Outbound: ${o} limits@openssh.com`)}}var ym={[en.VERSION]:(n,t)=>{if(n._version!==-1)return it(n,"Duplicate VERSION packet");let e={};O.init(t,1);let r=O.readUInt32BE();for(;O.avail();){let s=O.readString(!0),i=O.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(O.clear(),r===void 0)return it(n,"Malformed VERSION packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received VERSION (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received VERSION (v${r})`)}if(n._version=r,n._extensions=e,e["limits@openssh.com"]==="1")return Em(n,(s,i)=>{s||(i.maxPktLen>0&&(n._maxOutPktLen=i.maxPktLen),i.maxReadLen>0&&(n._maxReadLen=i.maxReadLen),i.maxWriteLen>0&&(n._maxWriteLen=i.maxWriteLen),n.maxOpenHandles=i.maxOpenHandles>0?i.maxOpenHandles:1/0),n.emit("ready")});n.emit("ready")},[en.STATUS]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readUInt32BE(),s=O.readString(!0);if(O.clear(),n._debug){let o=JSON.stringify(s);n._debug(`SFTP: Inbound: Received STATUS (id:${e}, ${r}, ${o})`)}let i=n._requests[e];if(delete n._requests[e],i&&typeof i.cb=="function"){if(r===et.OK){i.cb();return}let o=new Error(s||um[r]||"Unknown status");o.code=r,i.cb(o)}},[en.HANDLE]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString();if(O.clear(),r===void 0)return e!==void 0&&delete n._requests[e],it(n,"Malformed HANDLE packet");n._debug&&n._debug(`SFTP: Inbound: Received HANDLE (id:${e})`);let s=n._requests[e];delete n._requests[e],s&&typeof s.cb=="function"&&s.cb(void 0,r)},[en.DATA]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r;if(e!==void 0&&(r=n._requests[e],delete n._requests[e]),r&&typeof r.cb=="function")if(r.buffer){let s=O.readString(r.buffer);if(O.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`),r.cb(void 0,r.buffer,s);return}}else{let s=O.readString();if(O.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s.length})`),r.cb(void 0,s);return}}else{let s=O.skipString();if(O.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received DATA (id:${e}, ${s})`);return}}return it(n,"Malformed DATA packet")},[en.NAME]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=O.readUInt32BE();if(s!==void 0){let i=[];for(let o=0;o<s;++o){let a=O.readString(!0),c=O.readString(!0),f=Dr(n._biOpt);if(f===void 0){i=void 0;break}i.push({filename:a,longname:c,attrs:f})}if(i!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received NAME (id:${e}, ${i.length})`),O.clear(),r&&typeof r.cb=="function"&&r.cb(void 0,i);return}}return O.clear(),it(n,"Malformed NAME packet")},[en.ATTRS]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r;e!==void 0&&(r=n._requests[e],delete n._requests[e]);let s=Dr(n._biOpt);if(O.clear(),s!==void 0){n._debug&&n._debug(`SFTP: Inbound: Received ATTRS (id:${e})`),r&&typeof r.cb=="function"&&r.cb(void 0,s);return}return it(n,"Malformed ATTRS packet")},[en.EXTENDED]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE();if(e!==void 0){let r=n._requests[e];if(r)switch(delete n._requests[e],r.extended){case"statvfs@openssh.com":case"fstatvfs@openssh.com":{let s=n._biOpt,i={f_bsize:O.readUInt64BE(s),f_frsize:O.readUInt64BE(s),f_blocks:O.readUInt64BE(s),f_bfree:O.readUInt64BE(s),f_bavail:O.readUInt64BE(s),f_files:O.readUInt64BE(s),f_ffree:O.readUInt64BE(s),f_favail:O.readUInt64BE(s),f_sid:O.readUInt64BE(s),f_flag:O.readUInt64BE(s),f_namemax:O.readUInt64BE(s)};if(i.f_namemax===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),O.clear(),typeof r.cb=="function"&&r.cb(void 0,i);return}case"limits@openssh.com":{let s={maxPktLen:O.readUInt64BE(),maxReadLen:O.readUInt64BE(),maxWriteLen:O.readUInt64BE(),maxOpenHandles:O.readUInt64BE()};if(s.maxOpenHandles===void 0)break;n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ${r.extended})`),O.clear(),typeof r.cb=="function"&&r.cb(void 0,s);return}case"users-groups-by-id@openssh.com":{let s=O.readUInt32BE();if(s===void 0)break;let i=new Array(s);for(let c=0;c<i.length;++c)i[c]=O.readString(!0);let o=O.readUInt32BE();if(o===void 0)break;let a=new Array(o);for(let c=0;c<a.length;++c)a[c]=O.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})`),O.clear(),typeof r.cb=="function"&&r.cb(void 0,i,a);return}default:n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),O.clear(),typeof r.cb=="function"&&r.cb();return}else{n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED_REPLY (id:${e}, ???)`),O.clear();return}}return O.clear(),it(n,"Malformed EXTENDED_REPLY packet")}},_m={[ke.INIT]:(n,t)=>{if(n._version!==-1)return it(n,"Duplicate INIT packet");let e={};O.init(t,1);let r=O.readUInt32BE();for(;O.avail();){let s=O.readString(!0),i=O.readString(!0);if(i===void 0){r=void 0;break}e[s]=i}if(O.clear(),r===void 0)return it(n,"Malformed INIT packet");if(n._debug){let s=Object.keys(e);s.length?n._debug(`SFTP: Inbound: Received INIT (v${r}, exts:${s})`):n._debug(`SFTP: Inbound: Received INIT (v${r})`)}Xe(n,hm),n._version=r,n._extensions=e,n.emit("ready")},[ke.OPEN]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=O.readUInt32BE(),i=Dr(n._biOpt);if(O.clear(),i===void 0)return it(n,"Malformed OPEN packet");n._debug&&n._debug(`SFTP: Inbound: Received OPEN (id:${e})`),n.emit("OPEN",e,r,s,i)||n.status(e,et.OP_UNSUPPORTED)},[ke.CLOSE]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString();if(O.clear(),r===void 0||r.length>256)return it(n,"Malformed CLOSE packet");n._debug&&n._debug(`SFTP: Inbound: Received CLOSE (id:${e})`),n.emit("CLOSE",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.READ]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(),s=O.readUInt64BE(n._biOpt),i=O.readUInt32BE();if(O.clear(),i===void 0||r.length>256)return it(n,"Malformed READ packet");n._debug&&n._debug(`SFTP: Inbound: Received READ (id:${e})`),n.emit("READ",e,r,s,i)||n.status(e,et.OP_UNSUPPORTED)},[ke.WRITE]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(),s=O.readUInt64BE(n._biOpt),i=O.readString();if(O.clear(),i===void 0||r.length>256)return it(n,"Malformed WRITE packet");n._debug&&n._debug(`SFTP: Inbound: Received WRITE (id:${e})`),n.emit("WRITE",e,r,s,i)||n.status(e,et.OP_UNSUPPORTED)},[ke.LSTAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed LSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received LSTAT (id:${e})`),n.emit("LSTAT",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.FSTAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString();if(O.clear(),r===void 0||r.length>256)return it(n,"Malformed FSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSTAT (id:${e})`),n.emit("FSTAT",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.SETSTAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=Dr(n._biOpt);if(O.clear(),s===void 0)return it(n,"Malformed SETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received SETSTAT (id:${e})`),n.emit("SETSTAT",e,r,s)||n.status(e,et.OP_UNSUPPORTED)},[ke.FSETSTAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(),s=Dr(n._biOpt);if(O.clear(),s===void 0||r.length>256)return it(n,"Malformed FSETSTAT packet");n._debug&&n._debug(`SFTP: Inbound: Received FSETSTAT (id:${e})`),n.emit("FSETSTAT",e,r,s)||n.status(e,et.OP_UNSUPPORTED)},[ke.OPENDIR]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed OPENDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received OPENDIR (id:${e})`),n.emit("OPENDIR",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.READDIR]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString();if(O.clear(),r===void 0||r.length>256)return it(n,"Malformed READDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received READDIR (id:${e})`),n.emit("READDIR",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.REMOVE]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed REMOVE packet");n._debug&&n._debug(`SFTP: Inbound: Received REMOVE (id:${e})`),n.emit("REMOVE",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.MKDIR]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=Dr(n._biOpt);if(O.clear(),s===void 0)return it(n,"Malformed MKDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received MKDIR (id:${e})`),n.emit("MKDIR",e,r,s)||n.status(e,et.OP_UNSUPPORTED)},[ke.RMDIR]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed RMDIR packet");n._debug&&n._debug(`SFTP: Inbound: Received RMDIR (id:${e})`),n.emit("RMDIR",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.REALPATH]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed REALPATH packet");n._debug&&n._debug(`SFTP: Inbound: Received REALPATH (id:${e})`),n.emit("REALPATH",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.STAT]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed STAT packet");n._debug&&n._debug(`SFTP: Inbound: Received STAT (id:${e})`),n.emit("STAT",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.RENAME]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=O.readString(!0);if(O.clear(),s===void 0)return it(n,"Malformed RENAME packet");n._debug&&n._debug(`SFTP: Inbound: Received RENAME (id:${e})`),n.emit("RENAME",e,r,s)||n.status(e,et.OP_UNSUPPORTED)},[ke.READLINK]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(O.clear(),r===void 0)return it(n,"Malformed READLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received READLINK (id:${e})`),n.emit("READLINK",e,r)||n.status(e,et.OP_UNSUPPORTED)},[ke.SYMLINK]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0),s=O.readString(!0);if(O.clear(),s===void 0)return it(n,"Malformed SYMLINK packet");n._debug&&n._debug(`SFTP: Inbound: Received SYMLINK (id:${e})`);let i;n._isOpenSSH?i=n.emit("SYMLINK",e,s,r):i=n.emit("SYMLINK",e,r,s),i||n.status(e,et.OP_UNSUPPORTED)},[ke.EXTENDED]:(n,t)=>{O.init(t,1);let e=O.readUInt32BE(),r=O.readString(!0);if(r===void 0)return O.clear(),it(n,"Malformed EXTENDED packet");let s;O.avail()&&(s=O.readRaw()),O.clear(),n._debug&&n._debug(`SFTP: Inbound: Received EXTENDED (id:${e})`),n.emit("EXTENDED",e,r,s)||n.status(e,et.OP_UNSUPPORTED)}},{ERR_INVALID_ARG_TYPE:bm,ERR_OUT_OF_RANGE:Cs,validateNumber:xm}=rl(),al=128,Yt,Ca=[];function Sm(n){Ca.length>0?Yt=Ca.pop():Yt=Buffer.allocUnsafe(n),Yt.used=0}function va(n,t){if(!Number.isSafeInteger(n))throw xm(n,t),Number.isInteger(n)?new Cs(t,">= 0 and <= 2 ** 53 - 1",n):new Cs(t,"an integer",n);if(n<0)throw new Cs(t,">= 0 and <= 2 ** 53 - 1",n)}function ba(n){return n+7&-8}function $n(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,fl.call(this,e),this.path=t,this.flags=e.flags===void 0?"r":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.end=e.end,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesRead=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=n,this._opening=!1,this.start!==void 0&&(va(this.start,"start"),this.pos=this.start),this.end===void 0)this.end=1/0;else if(this.end!==1/0&&(va(this.end,"end"),this.start!==void 0&&this.start>this.end))throw new Cs("start",`<= "end" (here: ${this.end})`,this.start);this.on("end",function(){this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}ll($n,fl);$n.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()}))};$n.prototype._read=function(n){if(!Buffer.isBuffer(this.handle))return this.once("open",()=>this._read(n));if(this.destroyed)return;(!Yt||Yt.length-Yt.used<al)&&Sm(this.readableHighWaterMark||this._readableState.highWaterMark);let t=Yt,e=Math.min(Yt.length-Yt.used,n),r=Yt.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,Yt,Yt.used,e,this.pos,(s,i)=>{if(s){this.emit("error",s),this.autoClose&&this.destroy();return}let o=null;if(r+e===t.used&&t===Yt)t.used=ba(t.used+i-e);else{let a=r+e&-8,c=ba(r+i);a-c>=al&&Ca.push(t.slice(c,a))}i>0&&(this.bytesRead+=i,o=t.slice(r,r+i)),this.pos+=i,this.push(o)}),Yt.used=ba(Yt.used+e)};$n.prototype._destroy=function(n,t){if(this._opening&&!Buffer.isBuffer(this.handle)){this.once("open",cl.bind(null,this,t,n));return}cl(this,t,n),this.handle=null,this._opening=!1};function cl(n,t,e){if(!n.handle)return r();n.sftp.close(n.handle,r);function r(s){s=s||e,t(s),n.isClosed=!0,s||n.emit("close")}}$n.prototype.close=function(n){this.destroy(null,n)};Object.defineProperty($n.prototype,"pending",{get(){return this.handle===null},configurable:!0});function pn(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,ka.call(this,e),this.path=t,this.flags=e.flags===void 0?"w":e.flags,this.mode=e.mode===void 0?438:e.mode,this.start=e.start,this.autoClose=e.autoClose===void 0?!0:e.autoClose,this.pos=0,this.bytesWritten=0,this.isClosed=!1,this.handle=e.handle===void 0?null:e.handle,this.sftp=n,this._opening=!1,this.start!==void 0&&(va(this.start,"start"),this.pos=this.start),e.encoding&&this.setDefaultEncoding(e.encoding),this.on("finish",function(){this._writableState.finalCalled||this.autoClose&&this.destroy()}),Buffer.isBuffer(this.handle)||this.open()}ll(pn,ka);pn.prototype._final=function(n){this.autoClose&&this.destroy(),n()};pn.prototype.open=function(){this._opening||(this._opening=!0,this.sftp.open(this.path,this.flags,this.mode,(n,t)=>{if(this._opening=!1,n){this.emit("error",n),this.autoClose&&this.destroy();return}this.handle=t;let e=r=>{if(r){this.sftp.chmod(this.path,this.mode,s=>e());return}if(this.flags[0]==="a"){let s=(i,o)=>{if(i){this.sftp.stat(this.path,(a,c)=>{if(a){this.destroy(),this.emit("error",i);return}s(null,c)});return}this.pos=o.size,this.emit("open",t),this.emit("ready")};this.sftp.fstat(t,s);return}this.emit("open",t),this.emit("ready")};this.sftp.fchmod(t,this.mode,e)}))};pn.prototype._write=function(n,t,e){if(!Buffer.isBuffer(n)){let r=new bm("data","Buffer",n);return this.emit("error",r)}if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._write(n,t,e)});this.sftp.write(this.handle,n,0,n.length,this.pos,(r,s)=>{if(r)return this.autoClose&&this.destroy(),e(r);this.bytesWritten+=s,e()}),this.pos+=n.length};pn.prototype._writev=function(n,t){if(!Buffer.isBuffer(this.handle))return this.once("open",function(){this._writev(n,t)});let e=this.sftp,r=this.handle,s=n.length,i=(o,a)=>{if(o)return this.destroy(),t(o);this.bytesWritten+=a,--s===0&&t()};for(let o=0;o<n.length;++o){let a=n[o].chunk;e.write(r,a,0,a.length,this.pos,i),this.pos+=a.length}};typeof ka.prototype.destroy!="function"&&(pn.prototype.destroy=$n.prototype.destroy);pn.prototype._destroy=$n.prototype._destroy;pn.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()};pn.prototype.destroySoon=pn.prototype.end;Object.defineProperty(pn.prototype,"pending",{get(){return this.handle===null},configurable:!0});ml.exports={flagsToString:Am,OPEN_MODE:Ie,SFTP:Sa,Stats:vs,STATUS_CODE:et,stringToFlags:hl}});var Ua=ct((VE,_l)=>{"use strict";var{Duplex:wm,Readable:Im,Writable:Cm}=require("stream"),{CHANNEL_EXTENDED_DATATYPE:{STDERR:Al}}=Tn(),{bufferSlice:ks}=gn(),vm=32*1024,Si=2*1024*1024,Ta=Si/2,Ra=class extends Im{constructor(t,e){super(e),this._channel=t}_read(t){this._channel._waitChanDrain&&(this._channel._waitChanDrain=!1,this._channel.incoming.window<=Ta&&La(this._channel))}},Na=class extends Cm{constructor(t){super({highWaterMark:Si}),this._channel=t}_write(t,e,r){let s=this._channel,i=s._client._protocol,o=s.outgoing,a=o.packetSize,c=o.id,f=o.window,l=t.length,u=0;if(o.state==="open"){for(;l-u>0&&f>0;){let h=l-u;h>f&&(h=f),h>a&&(h=a),u===0&&h===l?i.channelExtData(c,t,Al):i.channelExtData(c,ks(t,u,u+h),Al),u+=h,f-=h}if(o.window=f,l-u>0){f===0&&(s._waitWindow=!0),u>0?s._chunkErr=ks(t,u,l):s._chunkErr=t,s._chunkcbErr=r;return}r()}}},Pa=class extends wm{constructor(t,e,r){let s={highWaterMark:Si,allowHalfOpen:!r||r&&r.allowHalfOpen!==!1,emitClose:!1};super(s),this.allowHalfOpen=s.allowHalfOpen;let i=!!(r&&r.server);this.server=i,this.type=e.type,this.subtype=void 0,this.incoming=e.incoming,this.outgoing=e.outgoing,this._callbacks=[],this._client=t,this._hasX11=!1,this._exit={code:void 0,signal:void 0,dump:void 0,desc:void 0},this.stdin=this.stdout=this,i?this.stderr=new Na(this):this.stderr=new Ra(this,s),this._waitWindow=!1,this._waitChanDrain=!1,this._chunk=void 0,this._chunkcb=void 0,this._chunkErr=void 0,this._chunkcbErr=void 0,this.on("finish",El).on("prefinish",El),this.on("end",yl).on("close",yl)}_read(t){this._waitChanDrain&&(this._waitChanDrain=!1,this.incoming.window<=Ta&&La(this))}_write(t,e,r){let s=this._client._protocol,i=this.outgoing,o=i.packetSize,a=i.id,c=i.window,f=t.length,l=0;if(i.state==="open"){for(;f-l>0&&c>0;){let u=f-l;u>c&&(u=c),u>o&&(u=o),l===0&&u===f?s.channelData(a,t):s.channelData(a,ks(t,l,l+u)),l+=u,c-=u}if(i.window=c,f-l>0){c===0&&(this._waitWindow=!0),l>0?this._chunk=ks(t,l,f):this._chunk=t,this._chunkcb=r;return}r()}}eof(){this.outgoing.state==="open"&&(this.outgoing.state="eof",this._client._protocol.channelEOF(this.outgoing.id))}close(){(this.outgoing.state==="open"||this.outgoing.state==="eof")&&(this.outgoing.state="closing",this._client._protocol.channelClose(this.outgoing.id))}destroy(){return this.end(),this.close(),this}setWindow(t,e,r,s){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&(this.subtype==="shell"||this.subtype==="exec")&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.windowChange(this.outgoing.id,t,e,r,s)}signal(t){if(this.server)throw new Error("Client-only method called in server mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&this._client._protocol.signal(this.outgoing.id,t)}exit(t,e,r){if(!this.server)throw new Error("Server-only method called in client mode");this.type==="session"&&this.writable&&this.outgoing.state==="open"&&(typeof t=="number"?this._client._protocol.exitStatus(this.outgoing.id,t):this._client._protocol.exitSignal(this.outgoing.id,t,e,r))}};function El(){this.eof(),(this.server||!this.allowHalfOpen)&&this.close(),this.writable=!1}function yl(){this.readable=!1}function La(n){if(n.outgoing.state==="closed")return;let t=Si-n.incoming.window;t<=0||(n.incoming.window+=t,n._client._protocol.channelWindowAdjust(n.outgoing.id,t))}_l.exports={Channel:Pa,MAX_WINDOW:Si,PACKET_SIZE:vm,windowAdjust:La,WINDOW_THRESHOLD:Ta}});var Oa=ct((GE,Sl)=>{"use strict";var{SFTP:km}=xi(),wi=2**32-1;function bl(n,t,e,r){if(n._chanMgr.remove(t),typeof r!="function")return;let s;e instanceof Error?s=e:typeof e=="object"&&e!==null?(s=new Error(`(SSH) Channel open failure: ${e.description}`),s.reason=e.reason):(s=new Error("(SSH) Channel open failure: server closed channel unexpectedly"),s.reason=""),r(s)}function xl(n,t,e,r,s){if(typeof e=="function"){bl(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!==km&&(e.outgoing.state==="open"||e.outgoing.state==="eof")&&!s&&e.close(),e.outgoing.state==="closing"&&(e.outgoing.state="closed");let i=e._readableState,o=e._writableState;o&&!o.ending&&!o.finished&&!s&&e.end();let a=e._callbacks;e._callbacks=[];for(let c=0;c<a.length;++c)a[c](!0);if(e.server)!e.readable||e.destroyed||i&&i.endEmitted?e.emit("close"):e.once("end",()=>e.emit("close"));else{let c;switch(e.type){case"direct-streamlocal@openssh.com":case"direct-tcpip":c=()=>e.emit("close");break;default:{let l=e._exit;c=()=>{l.code===null?e.emit("close",l.code,l.signal,l.dump,l.desc):e.emit("close",l.code)}}}!e.readable||e.destroyed||i&&i.endEmitted?c():e.once("end",c);let f=e.stderr._readableState;!e.stderr.readable||e.stderr.destroyed||f&&f.endEmitted?e.stderr.emit("close"):e.stderr.once("end",()=>e.stderr.emit("close"))}}var $a=class{constructor(t){this._client=t,this._channels={},this._cur=-1,this._count=0}add(t){let e;if(this._cur<wi)e=++this._cur;else if(this._count===0)this._cur=0,e=0;else{let r=this._channels;for(let s=0;s<wi;++s)if(r[s]===void 0){e=s;break}}return e===void 0?-1:(this._channels[e]=t||!0,++this._count,e)}update(t,e){if(typeof t!="number"||t<0||t>=wi||!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>=wi||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);return this._channels[t]}remove(t){if(typeof t!="number"||t<0||t>=wi||!isFinite(t))throw new Error(`Invalid channel id: ${t}`);this._channels[t]&&(delete this._channels[t],this._count&&--this._count)}cleanup(t){let e=this._channels;this._channels={},this._cur=-1,this._count=0;let r=Object.keys(e),s=this._client;for(let i=0;i<r.length;++i){let o=+r[i],a=e[o];xl(s,o,a._channel||a,t,!0)}}},Da=(()=>{let n=Object.prototype.toString;return t=>n.call(t)==="[object RegExp]"})();function Bm(n,t,e){if(Array.isArray(n)&&n.length>0){for(let r=0;r<n.length;++r)if(e.indexOf(n[r])===-1)throw new Error(`Unsupported algorithm: ${n[r]}`);return n}if(typeof n=="object"&&n!==null){let r=Object.keys(n),s=t;for(let i=0;i<r.length;++i){let o=r[i],a=n[o];switch(o){case"append":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let f=a[c];if(typeof f=="string"){if(!f||s.indexOf(f)!==-1)continue;if(e.indexOf(f)===-1)throw new Error(`Unsupported algorithm: ${f}`);s===t&&(s=s.slice()),s.push(f)}else if(Da(f))for(let l=0;l<e.length;++l){let u=e[l];if(f.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.push(u)}}}break;case"prepend":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=a.length;c>=0;--c){let f=a[c];if(typeof f=="string"){if(!f||s.indexOf(f)!==-1)continue;if(e.indexOf(f)===-1)throw new Error(`Unsupported algorithm: ${f}`);s===t&&(s=s.slice()),s.unshift(f)}else if(Da(f))for(let l=e.length;l>=0;--l){let u=e[l];if(f.test(u)){if(s.indexOf(u)!==-1)continue;s===t&&(s=s.slice()),s.unshift(u)}}}break;case"remove":if(Array.isArray(a)||(a=[a]),Array.isArray(a))for(let c=0;c<a.length;++c){let f=a[c];if(typeof f=="string"){if(!f)continue;let l=s.indexOf(f);if(l===-1)continue;s===t&&(s=s.slice()),s.splice(l,1)}else if(Da(f))for(let l=0;l<s.length;++l)f.test(s[l])&&(s===t&&(s=s.slice()),s.splice(l,1),--l)}break}}return s}return t}Sl.exports={ChannelManager:$a,generateAlgorithmList:Bm,onChannelOpenFailure:bl,onCHANNEL_CLOSE:xl,isWritable:n=>n&&n.writable&&n._readableState&&n._readableState.ended===!1}});var Ka=ct((zE,Wl)=>{"use strict";var{createHash:Rm,getHashes:Nm,randomFillSync:Pm}=require("crypto"),{Socket:Tm}=require("net"),{lookup:Lm}=require("dns"),Um=require("events"),Dm=Nm(),{COMPAT:Fl,CHANNEL_EXTENDED_DATATYPE:{STDERR:$m},CHANNEL_OPEN_FAILURE:Ii,DEFAULT_CIPHER:wl,DEFAULT_COMPRESSION:Il,DEFAULT_KEX:Cl,DEFAULT_MAC:vl,DEFAULT_SERVER_HOST_KEY:kl,DISCONNECT_REASON:Bl,DISCONNECT_REASON_BY_VALUE:Om,SUPPORTED_CIPHER:Mm,SUPPORTED_COMPRESSION:Fm,SUPPORTED_KEX:Hm,SUPPORTED_MAC:Qm,SUPPORTED_SERVER_HOST_KEY:Wm}=Tn(),{init:qm}=Wn(),Km=ya(),{parseKey:Ns}=Vn(),{SFTP:Vm}=xi(),{bufferCopy:Rl,makeBufferParser:Hl,makeError:Gm,readUInt32BE:zm,sigSSHToASN1:Ym,writeUInt32BE:Ma}=gn(),{AgentContext:Nl,createAgent:Pl,isAgent:Tl}=ia(),{Channel:Ql,MAX_WINDOW:Ps,PACKET_SIZE:Ts,windowAdjust:Ll,WINDOW_THRESHOLD:Ul}=Ua(),{ChannelManager:jm,generateAlgorithmList:Ci,isWritable:Tt,onChannelOpenFailure:Xm,onCHANNEL_CLOSE:Jm}=Oa(),Bs=Hl(),Rs=Hl(),vi=/^OpenSSH_(?:(?![0-4])\d)|(?:\d{2,})/,Wa=n=>{},qa=class extends Um{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&&Tt(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=Ci(t.algorithms.kex,Cl,Hm),e.kex!==Cl&&(r=!1),e.serverHostKey=Ci(t.algorithms.serverHostKey,kl,Wm),e.serverHostKey!==kl&&(r=!1),e.cs.cipher=Ci(t.algorithms.cipher,wl,Mm),e.cs.cipher!==wl&&(r=!1),e.cs.mac=Ci(t.algorithms.hmac,vl,Qm),e.cs.mac!==vl&&(r=!1),e.cs.compress=Ci(t.algorithms.compress,Il,Fm),e.cs.compress!==Il&&(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=Pl(t.agent):Tl(t.agent)?this.config.agent=t.agent:this.config.agent=void 0,this.config.allowAgentFwd=t.agentForward===!0&&this.config.agent!==void 0;let s=this.config.authHandler=typeof t.authHandler=="function"||Array.isArray(t.authHandler)?t.authHandler:void 0;this.config.strictVendor=typeof t.strictVendor=="boolean"?t.strictVendor:!0;let i=this.config.debug=typeof t.debug=="function"?t.debug:void 0;if(t.agentForward===!0&&!this.config.allowAgentFwd)throw new Error("You must set a valid agent path to allow agent forwarding");let o=this._callbacks=[];this._chanMgr=new jm(this),this._forwarding={},this._forwardingUnix={},this._acceptX11=0,this._agentFwdEnabled=!1,this._agent=this.config.agent?this.config.agent:void 0,this._remoteVer=void 0;let a;if(this.config.privateKey){if(a=Ns(this.config.privateKey,t.passphrase),a instanceof Error)throw new Error(`Cannot parse privateKey: ${a.message}`);if(Array.isArray(a)&&(a=a[0]),a.getPrivatePEM()===null)throw new Error("privateKey value does not contain a (valid) private key")}let c;if(typeof t.hostVerifier=="function"){let $=t.hostVerifier,B;Dm.indexOf(t.hostHash)!==-1&&(B=t.hostHash),c=(L,K)=>{B&&(L=Rm(B).update(L).digest("hex"));let ee=$(L,K);ee!==void 0&&K(ee)}}let f=this._sock=t.sock||new Tm,l=!1,u=!1;this._protocol&&this._protocol.cleanup();let h=i?($,B,L)=>{i(`Debug output from server: ${JSON.stringify(L)}`)}:void 0,p,y=this._protocol=new Km({ident:this.config.ident,offer:r?void 0:e,onWrite:$=>{Tt(f)&&f.write($)},onError:$=>{$.level==="handshake"&&clearTimeout(this._readyTimeout),y._destruct||f.removeAllListeners("data"),this.emit("error",$);try{f.end()}catch{}},onHeader:$=>{u=!0,this._remoteVer=$.versions.software,$.greeting&&this.emit("greeting",$.greeting)},onHandshakeComplete:$=>{this.emit("handshake",$),l||(l=!0,y.service("ssh-userauth"))},debug:i,hostVerifier:c,messageHandlers:{DEBUG:h,DISCONNECT:($,B,L)=>{if(B!==Bl.BY_APPLICATION){L||(L=Om[B],L===void 0&&(L=`Unexpected disconnection reason: ${B}`));let K=new Error(L);K.code=B,this.emit("error",K)}f.end()},SERVICE_ACCEPT:($,B)=>{B==="ssh-userauth"&&Y()},EXT_INFO:($,B)=>{if(p===void 0){for(let L of B)if(L.name==="server-sig-algs"){p=L.algs;return}p=null}},USERAUTH_BANNER:($,B)=>{this.emit("banner",B)},USERAUTH_SUCCESS:$=>{v(),clearTimeout(this._readyTimeout),this.emit("ready")},USERAUTH_FAILURE:($,B,L)=>{if(x.keyAlgos){let K=x.keyAlgos[0][0];if(i&&i(`Client: ${x.type} (${K}) auth failed`),x.keyAlgos.shift(),x.keyAlgos.length){let[ee,fe]=x.keyAlgos[0];switch(x.type){case"agent":y.authPK(x.username,x.agentCtx.currentKey(),ee);return;case"publickey":y.authPK(x.username,x.key,ee);return;case"hostbased":y.authHostbased(x.username,x.key,x.localHostname,x.localUsername,ee,(ie,Ye)=>{let ft=x.key.sign(ie,fe);if(ft instanceof Error)return ft.message=`Error while signing with key: ${ft.message}`,ft.level="client-authentication",this.emit("error",ft),Y();Ye(ft)});return}}else x.keyAlgos=void 0}if(x.type==="agent"){let K=x.agentCtx.pos();return i&&i(`Client: Agent key #${K+1} failed`),te()}i&&i(`Client: ${x.type} auth failed`),w=L,I=B,Y()},USERAUTH_PASSWD_CHANGEREQ:($,B)=>{x.type==="password"&&this.emit("change password",B,L=>{y.authPassword(this.config.username,this.config.password,L)})},USERAUTH_PK_OK:$=>{let B,L;if(x.keyAlgos&&([B,L]=x.keyAlgos[0]),x.type==="agent"){let K=x.agentCtx.currentKey();y.authPK(x.username,K,B,(ee,fe)=>{let ie={hash:L};x.agentCtx.sign(K,ee,ie,(Ye,ft)=>{if(Ye)Ye.level="agent",this.emit("error",Ye);else return fe(ft);te()})})}else x.type==="publickey"&&y.authPK(x.username,x.key,B,(K,ee)=>{let fe=x.key.sign(K,L);if(fe instanceof Error)return fe.message=`Error signing data with key: ${fe.message}`,fe.level="client-authentication",this.emit("error",fe),Y();ee(fe)})},USERAUTH_INFO_REQUEST:($,B,L,K)=>{if(x.type==="keyboard-interactive"){if((Array.isArray(K)?K.length:0)===0){i&&i("Client: Sending automatic USERAUTH_INFO_RESPONSE"),y.authInfoRes();return}x.prompt(B,L,"",K,fe=>{y.authInfoRes(fe)})}},REQUEST_SUCCESS:($,B)=>{o.length&&o.shift()(!1,B)},REQUEST_FAILURE:$=>{o.length&&o.shift()(!0)},GLOBAL_REQUEST:($,B,L,K)=>{B==="hostkeys-00@openssh.com"?(r0(this,K,(ee,fe)=>{ee||this.emit("hostkeys",fe)}),L&&y.requestSuccess()):L&&y.requestFailure()},CHANNEL_OPEN:($,B)=>{t0(this,B)},CHANNEL_OPEN_CONFIRMATION:($,B)=>{let L=this._chanMgr.get(B.recipient);if(typeof L!="function")return;let K=L.type==="sftp",fe={type:K?"session":L.type,incoming:{id:B.recipient,window:Ps,packetSize:Ts,state:"open"},outgoing:{id:B.sender,window:B.window,packetSize:B.packetSize,state:"open"}},ie=K?new Vm(this,fe,{debug:i}):new Ql(this,fe);this._chanMgr.update(B.recipient,ie),L(void 0,ie)},CHANNEL_OPEN_FAILURE:($,B,L,K)=>{let ee=this._chanMgr.get(B);if(typeof ee!="function")return;Xm(this,B,{reason:L,description:K},ee)},CHANNEL_DATA:($,B,L)=>{let K=this._chanMgr.get(B);if(!(typeof K!="object"||K===null)&&K.incoming.window!==0){if(K.incoming.window-=L.length,K.push(L)===!1){K._waitChanDrain=!0;return}K.incoming.window<=Ul&&Ll(K)}},CHANNEL_EXTENDED_DATA:($,B,L,K)=>{if(K!==$m)return;let ee=this._chanMgr.get(B);if(!(typeof ee!="object"||ee===null)&&ee.incoming.window!==0){if(ee.incoming.window-=L.length,!ee.stderr.push(L)){ee._waitChanDrain=!0;return}ee.incoming.window<=Ul&&Ll(ee)}},CHANNEL_WINDOW_ADJUST:($,B,L)=>{let K=this._chanMgr.get(B);typeof K!="object"||K===null||(K.outgoing.window+=L,K._waitWindow&&(K._waitWindow=!1,K._chunk?K._write(K._chunk,null,K._chunkcb):K._chunkcb?K._chunkcb():K._chunkErr?K.stderr._write(K._chunkErr,null,K._chunkcbErr):K._chunkcbErr&&K._chunkcbErr()))},CHANNEL_SUCCESS:($,B)=>{let L=this._chanMgr.get(B);typeof L!="object"||L===null||(this._resetKA(),L._callbacks.length&&L._callbacks.shift()(!1))},CHANNEL_FAILURE:($,B)=>{let L=this._chanMgr.get(B);typeof L!="object"||L===null||(this._resetKA(),L._callbacks.length&&L._callbacks.shift()(!0))},CHANNEL_REQUEST:($,B,L,K,ee)=>{let fe=this._chanMgr.get(B);if(typeof fe!="object"||fe===null)return;let ie=fe._exit;if(ie.code===void 0){switch(L){case"exit-status":fe.emit("exit",ie.code=ee);return;case"exit-signal":fe.emit("exit",ie.code=null,ie.signal=`SIG${ee.signal}`,ie.dump=ee.coreDumped,ie.desc=ee.errorMessage);return}K&&$.channelFailure(fe.outgoing.id)}},CHANNEL_EOF:($,B)=>{let L=this._chanMgr.get(B);typeof L!="object"||L===null||L.incoming.state==="open"&&(L.incoming.state="eof",L.readable&&L.push(null),L.stderr.readable&&L.stderr.push(null))},CHANNEL_CLOSE:($,B)=>{Jm(this,B,this._chanMgr.get(B))}}});f.pause();let E=this.config.keepaliveInterval,b=this.config.keepaliveCountMax,C=0,N,H=()=>{if(++C>b){if(clearInterval(N),f.readable){let $=new Error("Keepalive timeout");$.level="client-timeout",this.emit("error",$),f.destroy()}return}Tt(f)?(o.push(v),y.ping()):clearInterval(N)};function v(){E>0&&(C=0,clearInterval(N),Tt(f)&&(N=setInterval(H,E)))}this._resetKA=v;let M=(()=>{let $=!1;return()=>{if(!$&&($=!0,P&&!u)){let B=Gm("Connection lost before handshake","protocol",!0);this.emit("error",B)}}})(),Q=(()=>{let $=!1;return()=>{$||($=!0,P=!0,i&&i("Socket connected"),this.emit("connect"),qm.then(()=>{y.start(),f.on("data",B=>{try{y.parse(B,0,B.length)}catch(L){this.emit("error",L);try{Tt(f)&&f.end()}catch{}}}),f.stderr&&typeof f.stderr.resume=="function"&&f.stderr.resume(),f.resume()}).catch(B=>{this.emit("error",B);try{Tt(f)&&f.end()}catch{}}))}})(),P=!1;f.on("connect",Q).on("timeout",()=>{this.emit("timeout")}).on("error",$=>{i&&i(`Socket error: ${$.message}`),clearTimeout(this._readyTimeout),$.level="client-socket",this.emit("error",$)}).on("end",()=>{i&&i("Socket ended"),M(),y.cleanup(),clearTimeout(this._readyTimeout),clearInterval(N),this.emit("end")}).on("close",()=>{i&&i("Socket closed"),M(),y.cleanup(),clearTimeout(this._readyTimeout),clearInterval(N),this.emit("close");let $=o;o=this._callbacks=[];let B=new Error("No response from server");for(let L=0;L<$.length;++L)$[L](B);this._chanMgr.cleanup(B)});let x,w=null,I=null,k=["none"];this.config.password!==void 0&&k.push("password"),a!==void 0&&k.push("publickey"),this._agent!==void 0&&k.push("agent"),this.config.tryKeyboard&&k.push("keyboard-interactive"),a!==void 0&&this.config.localHostname!==void 0&&this.config.localUsername!==void 0&&k.push("hostbased"),Array.isArray(s)?s=Ml(s):typeof s!="function"&&(s=Ml(k));let R=!1,ne=$=>{if(!R){if(R=!0,$===!1){let B=new Error("All configured authentication methods failed");B.level="client-authentication",this.emit("error",B),this.end();return}if(typeof $=="string"){let B=$;if(k.indexOf(B)===-1)return z(`Authentication method not allowed: ${B}`);let L=this.config.username;switch(B){case"password":$={type:B,username:L,password:this.config.password};break;case"publickey":$={type:B,username:L,key:a};break;case"hostbased":$={type:B,username:L,key:a,localHostname:this.config.localHostname,localUsername:this.config.localUsername};break;case"agent":$={type:B,username:L,agentCtx:new Nl(this._agent)};break;case"keyboard-interactive":$={type:B,username:L,prompt:(...K)=>this.emit("keyboard-interactive",...K)};break;case"none":$={type:B,username:L};break;default:return z(`Skipping unsupported authentication method: ${$}`)}}else{if(typeof $!="object"||$===null)return z(`Skipping invalid authentication attempt: ${$}`);{let B=$.username;if(typeof B!="string")return z(`Skipping invalid authentication attempt: ${$}`);let L=$.type;switch(L){case"password":{let{password:K}=$;if(typeof K!="string"&&!Buffer.isBuffer(K))return z("Skipping invalid password auth attempt");$={type:L,username:B,password:K};break}case"publickey":{let K=Ns($.key,$.passphrase);if(K instanceof Error)return z("Skipping invalid key auth attempt");if(!K.isPrivateKey())return z("Skipping non-private key");$={type:L,username:B,key:K};break}case"hostbased":{let{localHostname:K,localUsername:ee}=$,fe=Ns($.key,$.passphrase);if(fe instanceof Error||typeof K!="string"||typeof ee!="string")return z("Skipping invalid hostbased auth attempt");if(!fe.isPrivateKey())return z("Skipping non-private key");$={type:L,username:B,key:fe,localHostname:K,localUsername:ee};break}case"agent":{let K=$.agent;if(typeof K=="string"&&K.length)K=Pl(K);else if(!Tl(K))return z(`Skipping invalid agent: ${$.agent}`);$={type:L,username:B,agentCtx:new Nl(K)};break}case"keyboard-interactive":{let{prompt:K}=$;if(typeof K!="function")return z("Skipping invalid keyboard-interactive auth attempt");$={type:L,username:B,prompt:K};break}case"none":$={type:L,username:B};break;default:return z(`Skipping unsupported authentication method: ${$}`)}}}x=$;try{let B=x.username;switch(x.type){case"password":y.authPassword(B,x.password);break;case"publickey":{let L;if(x.keyAlgos=Qa(this,x.key,p),x.keyAlgos)if(x.keyAlgos.length)L=x.keyAlgos[0][0];else return z("Skipping key authentication (no mutual hash algorithm)");y.authPK(B,x.key,L);break}case"hostbased":{let L,K;if(x.keyAlgos=Qa(this,x.key,p),x.keyAlgos)if(x.keyAlgos.length)[L,K]=x.keyAlgos[0];else return z("Skipping hostbased authentication (no mutual hash algorithm)");y.authHostbased(B,x.key,x.localHostname,x.localUsername,L,(ee,fe)=>{let ie=x.key.sign(ee,K);if(ie instanceof Error)return ie.message=`Error while signing with key: ${ie.message}`,ie.level="client-authentication",this.emit("error",ie),Y();fe(ie)});break}case"agent":x.agentCtx.init(L=>{if(L)return L.level="agent",this.emit("error",L),Y();te()});break;case"keyboard-interactive":y.authKeyboard(B);break;case"none":y.authNone(B);break}}finally{R=!1}}};function z($){i&&i($),process.nextTick(Y)}function Y(){R=!1;let $=s(I,w,ne);R||$===void 0||ne($)}let te=()=>{if(x.type==="agent"){let $=x.agentCtx.nextKey();if($===!1)i&&i("Agent: No more keys left to try"),i&&i("Client: agent auth failed"),Y();else{let B=x.agentCtx.pos(),L;if(x.keyAlgos=Qa(this,$,p),x.keyAlgos)if(x.keyAlgos.length)L=x.keyAlgos[0][0];else{i&&i(`Agent: Skipping key #${B+1} (no mutual hash algorithm)`),te();return}i&&i(`Agent: Trying key #${B+1}`),y.authPK(x.username,$,L)}}},ce=()=>{this.config.readyTimeout>0&&(this._readyTimeout=setTimeout(()=>{let $=new Error("Timed out while waiting for handshake");$.level="client-timeout",this.emit("error",$),f.destroy()},this.config.readyTimeout))};if(t.sock)ce(),typeof f.connecting=="boolean"&&f.connecting||Q();else{let $=this.config.host,B=this.config.forceIPv4,L=this.config.forceIPv6;i&&i(`Client: Trying ${$} on port ${this.config.port} ...`);let K=()=>{ce(),f.connect({host:$,port:this.config.port,localAddress:this.config.localAddress,localPort:this.config.localPort}),f.setMaxListeners(0),f.setTimeout(typeof t.timeout=="number"?t.timeout:0)};!B&&!L||B&&L?K():Lm($,B?4:6,(ee,fe,ie)=>{if(ee){let Ye=B?"IPv4":"IPv6",ft=new Error(`Error while looking up ${Ye} address for '${$}': ${ee}`);clearTimeout(this._readyTimeout),ft.level="client-dns",this.emit("error",ft),this.emit("close");return}$=fe,K()})}return this}end(){return this._sock&&Tt(this._sock)&&(this._protocol.disconnect(Bl.BY_APPLICATION),this._sock.end()),this}destroy(){return this._sock&&Tt(this._sock)&&this._sock.destroy(),this}exec(t,e,r){if(!this._sock||!Tt(this._sock))throw new Error("Not connected");typeof e=="function"&&(r=e,e={});let s={allowHalfOpen:e.allowHalfOpen!==!1};return Or(this,"session",s,(i,o)=>{if(i){r(i);return}let a=[];function c(f){if(f){o.close(),r(f);return}a.length&&a.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&a.push(()=>Ol(o,c)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&Fa(o,e.env),(typeof e.pty=="object"&&e.pty!==null||e.pty===!0)&&a.push(()=>$l(o,e.pty,c)),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&a.push(()=>Dl(o,e.x11,c))),a.push(()=>e0(o,t,e,r)),a.shift()()}),this}shell(t,e,r){if(!this._sock||!Tt(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),Or(this,"session",(s,i)=>{if(s){r(s);return}let o=[];function a(c){if(c){i.close(),r(c);return}o.length&&o.shift()()}(this.config.allowAgentFwd===!0||e&&e.agentForward===!0&&this._agent!==void 0)&&o.push(()=>Ol(i,a)),t!==!1&&o.push(()=>$l(i,t,a)),typeof e=="object"&&e!==null&&(typeof e.env=="object"&&e.env!==null&&Fa(i,e.env),(typeof e.x11=="object"&&e.x11!==null||e.x11==="number"||e.x11===!0)&&o.push(()=>Dl(i,e.x11,a))),o.push(()=>Zm(i,r)),o.shift()()}),this}subsys(t,e){if(!this._sock||!Tt(this._sock))throw new Error("Not connected");return Or(this,"session",(r,s)=>{if(r){e(r);return}Ha(s,t,(i,o)=>{if(i){e(i);return}e(void 0,o)})}),this}forwardIn(t,e,r){if(!this._sock||!Tt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push((i,o)=>{if(i){r(i!==!0?i:new Error(`Unable to bind to ${t}:${e}`));return}let a=e;e===0&&o&&o.length>=4&&(a=zm(o,0),this._protocol._compatFlags&Fl.DYN_RPORT_BUG||(e=a)),this._forwarding[`${t}:${e}`]=a,r(void 0,a)}),this._protocol.tcpipForward(t,e,s),this}unforwardIn(t,e,r){if(!this._sock||!Tt(this._sock))throw new Error("Not connected");let s=typeof r=="function";return s&&this._callbacks.push(i=>{if(i){r(i!==!0?i:new Error(`Unable to unbind from ${t}:${e}`));return}delete this._forwarding[`${t}:${e}`],r()}),this._protocol.cancelTcpipForward(t,e,s),this}forwardOut(t,e,r,s,i){if(!this._sock||!Tt(this._sock))throw new Error("Not connected");let o={srcIP:t,srcPort:e,dstIP:r,dstPort:s};return typeof i!="function"&&(i=Wa),Or(this,"direct-tcpip",o,i),this}openssh_noMoreSessions(t){if(!this._sock||!Tt(this._sock))throw new Error("Not connected");let e=typeof t=="function";return!this.config.strictVendor||this.config.strictVendor&&vi.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||!Tt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&vi.test(this._remoteVer)?(r&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to bind to ${t}`));return}this._forwardingUnix[t]=!0,e()}),this._protocol.openssh_streamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_unforwardInStreamLocal(t,e){if(!this._sock||!Tt(this._sock))throw new Error("Not connected");let r=typeof e=="function";return!this.config.strictVendor||this.config.strictVendor&&vi.test(this._remoteVer)?(r&&this._callbacks.push(s=>{if(s){e(s!==!0?s:new Error(`Unable to unbind from ${t}`));return}delete this._forwardingUnix[t],e()}),this._protocol.openssh_cancelStreamLocalForward(t,r),this):r?(process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version")),this):this}openssh_forwardOutStreamLocal(t,e){if(!this._sock||!Tt(this._sock))throw new Error("Not connected");return typeof e!="function"&&(e=Wa),!this.config.strictVendor||this.config.strictVendor&&vi.test(this._remoteVer)?(Or(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||!Tt(this._sock))throw new Error("Not connected");return typeof t=="function"&&(e=t,t=void 0),Or(this,"sftp",(r,s)=>{if(r){e(r);return}let i=(o,a)=>{if(o){e(o);return}function c(){s.removeListener("ready",f),s.removeListener("error",l),s.removeListener("exit",u),s.removeListener("close",u)}function f(){c(),e(void 0,s)}function l(h){c(),e(h)}function u(h,p){c();let y;typeof h=="number"?y=`Received exit code ${h} while establishing SFTP session`:p!==void 0?y=`Received signal ${p} while establishing SFTP session`:y="Received unexpected SFTP session termination";let E=new Error(y);E.code=h,E.signal=p,e(E)}s.on("ready",f).on("error",l).on("exit",u).on("close",u),s._init()};typeof t=="object"&&t!==null?Fa(s,t,o=>{if(o){e(o);return}Ha(s,"sftp",i)}):Ha(s,"sftp",i)}),this}setNoDelay(t){return this._sock&&typeof this._sock.setNoDelay=="function"&&this._sock.setNoDelay(t),this}};function Or(n,t,e,r){let s=Ps,i=Ts;typeof e=="function"&&(r=e,e={});let o=(c,f)=>{r(c,f)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"session":case"sftp":n._protocol.session(a,s,i);break;case"direct-tcpip":n._protocol.directTcpip(a,s,i,e);break;case"direct-streamlocal@openssh.com":n._protocol.openssh_directStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function Dl(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=n0());let s=typeof e=="function";if(n.outgoing.state!=="open"){s&&e(new Error("Channel is not open"));return}s&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to request X11"));return}n._hasX11=!0,++n._client._acceptX11,n.once("close",()=>{n._client._acceptX11&&--n._client._acceptX11}),e()}),n._client._protocol.x11Forward(n.outgoing.id,r,s)}function $l(n,t,e){let r=24,s=80,i=640,o=480,a="vt100",c=null;typeof t=="function"?e=t:typeof t=="object"&&t!==null&&(typeof t.rows=="number"&&(r=t.rows),typeof t.cols=="number"&&(s=t.cols),typeof t.width=="number"&&(i=t.width),typeof t.height=="number"&&(o=t.height),typeof t.term=="string"&&(a=t.term),typeof t.modes=="object"&&(c=t.modes));let f=typeof e=="function";if(n.outgoing.state!=="open"){f&&e(new Error("Channel is not open"));return}f&&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,s,o,i,a,c,f)}function Ol(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 Zm(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 e0(n,t,e,r){if(n.outgoing.state!=="open"){r(new Error("Channel is not open"));return}n._callbacks.push(s=>{if(s){r(s!==!0?s:new Error("Unable to exec"));return}n.subtype="exec",n.allowHalfOpen=e.allowHalfOpen!==!1,r(void 0,n)}),n._client._protocol.exec(n.outgoing.id,t,!0)}function Fa(n,t,e){let r=typeof e=="function";if(n.outgoing.state!=="open"){r&&e(new Error("Channel is not open"));return}r&&n._callbacks.push(i=>{if(i){e(i!==!0?i:new Error("Unable to set environment"));return}e()});let s=Object.keys(t||{});for(let i=0;i<s.length;++i){let o=s[i],a=t[o];n._client._protocol.env(n.outgoing.id,o,a,r)}}function Ha(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 t0(n,t){let e=-1,r,s=()=>{let c={type:t.type,incoming:{id:e,window:Ps,packetSize:Ts,state:"open"},outgoing:{id:t.sender,window:t.window,packetSize:t.packetSize,state:"open"}},f=new Ql(n,c);return n._chanMgr.update(e,f),n._protocol.channelOpenConfirm(t.sender,e,Ps,Ts),f},i=()=>{r===void 0&&(e===-1?r=Ii.RESOURCE_SHORTAGE:r=Ii.CONNECT_FAILED),e!==-1&&n._chanMgr.remove(e),n._protocol.channelOpenFail(t.sender,r,"")},o=()=>(e=n._chanMgr.add(),e===-1&&(r=Ii.RESOURCE_SHORTAGE,n.config.debug&&n.config.debug("Client: Automatic rejection of incoming channel open: no channels available")),e!==-1),a=t.data;switch(t.type){case"forwarded-tcpip":{let c=n._forwarding[`${a.destIP}:${a.destPort}`];if(c!==void 0&&o()){a.destPort===0&&(a.destPort=c),n.emit("tcp connection",a,s,i);return}break}case"forwarded-streamlocal@openssh.com":if(n._forwardingUnix[a.socketPath]!==void 0&&o()){n.emit("unix connection",a,s,i);return}break;case"auth-agent@openssh.com":if(n._agentFwdEnabled&&typeof n._agent.getStream=="function"&&o()){n._agent.getStream((c,f)=>{if(c)return i();let l=s();l.pipe(f).pipe(l)});return}break;case"x11":if(n._acceptX11!==0&&o()){n.emit("x11",a,s,i);return}break;default:r=Ii.UNKNOWN_CHANNEL_TYPE,n.config.debug&&n.config.debug(`Client: Automatic rejection of unsupported incoming channel open type: ${t.type}`)}r===void 0&&(r=Ii.ADMINISTRATIVELY_PROHIBITED,n.config.debug&&n.config.debug("Client: Automatic rejection of unexpected incoming channel open for: "+t.type)),i()}var n0=(()=>{let n=Buffer.allocUnsafe(16);return()=>(Pm(n,0,16),n.hexSlice(0,16))})();function Ml(n){if(!Array.isArray(n))throw new Error("authList must be an array");let t=0;return(e,r,s)=>t===n.length?!1:n[t++]}function r0(n,t,e){if(!n._sock||!Tt(n._sock))return;if(typeof e!="function"&&(e=Wa),!Array.isArray(t))throw new TypeError("Invalid keys argument type");let r=[];for(let s of t){let i=Ns(s);if(i instanceof Error)throw i;r.push(i)}if(!n.config.strictVendor||n.config.strictVendor&&vi.test(n._remoteVer)){n._callbacks.push((s,i)=>{if(s){e(s!==!0?s:new Error("Server failed to prove supplied keys"));return}let o=[],a=0;for(Bs.init(i,0);Bs.avail()&&a!==r.length;){let c=r[a++],f=c.getPublicSSH(),l=Bs.readString();Rs.init(l,0);let u=Rs.readString(!0),h=Rs.readString(),p;if(u!==c.type)if(c.type==="ssh-rsa")switch(u){case"rsa-sha2-256":p="sha256";break;case"rsa-sha2-512":p="sha512";break;default:continue}else continue;let y=n._protocol._kex.sessionID,E=Buffer.allocUnsafe(37+y.length+4+f.length),b=0;Ma(E,29,b),E.utf8Write("hostkeys-prove-00@openssh.com",b+=4,29),Ma(E,y.length,b+=29),Rl(y,E,0,y.length,b+=4),Ma(E,f.length,b+=y.length),Rl(f,E,0,f.length,b+=4),(h=Ym(h,u))&&c.verify(E,h,p)===!0&&o.push(c)}Rs.clear(),Bs.clear(),e(null,o)}),n._protocol.openssh_hostKeysProve(r);return}process.nextTick(e,new Error("strictVendor enabled and server is not OpenSSH or compatible version"))}function Qa(n,t,e){switch(t.type){case"ssh-rsa":if(n._protocol._compatFlags&Fl.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"]]}}Wl.exports=qa});var Kl=ct(ql=>{"use strict";var{Agent:Ga}=require("http"),{Agent:i0}=require("https"),{connect:s0}=require("tls"),Va;for(let n of[Ga,i0]){class t extends n{constructor(r,s){super(s),this._connectCfg=r,this._defaultSrcIP=s&&s.srcIP||"localhost"}createConnection(r,s){let i=r&&r.localAddress||this._defaultSrcIP,o=r&&r.localPort||0,a=r.host,c=r.port;Va===void 0&&(Va=Ka());let f=new Va,l=!1;f.on("ready",()=>{f.forwardOut(i,o,a,c,(u,h)=>{if(l=!0,u)return f.end(),s(u);h.once("close",()=>f.end()),s(null,o0(h,n,r))})}).on("error",s).on("close",()=>{l||s(new Error("Unexpected connection close"))}).connect(this._connectCfg)}}ql[n===Ga?"SSHTTPAgent":"SSHTTPSAgent"]=t}function ki(){}function o0(n,t,e){if(t===Ga)return n.setKeepAlive=ki,n.setNoDelay=ki,n.setTimeout=ki,n.ref=ki,n.unref=ki,n.destroySoon=n.destroy,n;e.socket=n;let r=s0(e),s=(()=>{let i=!1;return()=>{i||(i=!0,n.isPaused()&&n.resume())}})();return r.on("end",s).on("close",s),r}});var Gl=ct((jE,Xa)=>{"use strict";var{Server:a0}=require("net"),Ri=require("events"),{listenerCount:Vt}=Ri,{CHANNEL_OPEN_FAILURE:Mr,DEFAULT_CIPHER:c0,DEFAULT_COMPRESSION:f0,DEFAULT_KEX:l0,DEFAULT_MAC:u0,DEFAULT_SERVER_HOST_KEY:d0,DISCONNECT_REASON:Fr,DISCONNECT_REASON_BY_VALUE:h0,SUPPORTED_CIPHER:p0,SUPPORTED_COMPRESSION:g0,SUPPORTED_KEX:m0,SUPPORTED_MAC:A0,SUPPORTED_SERVER_HOST_KEY:E0}=Tn(),{init:y0}=Wn(),{KexInit:_0}=ms(),{parseKey:Vl}=Vn(),b0=ya(),{SFTP:x0}=xi(),{writeUInt32BE:S0}=gn(),{Channel:Hr,MAX_WINDOW:Yn,PACKET_SIZE:jn,windowAdjust:w0,WINDOW_THRESHOLD:I0}=Ua(),{ChannelManager:C0,generateAlgorithmList:Bi,isWritable:Ls,onChannelOpenFailure:v0,onCHANNEL_CLOSE:k0}=Oa(),B0=10,Xn=class extends Ri{constructor(t,e,r,s,i){super(),this.username=this.user=e,this.service=r,this.method=s,this._initialResponse=!1,this._finalResponse=!1,this._multistep=!1,this._cbfinal=(o,a,c)=>{this._finalResponse||(this._finalResponse=!0,i(this,o,a,c))},this._protocol=t}accept(){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!0)}reject(t,e){this._cleanup&&this._cleanup(),this._initialResponse=!0,this._cbfinal(!1,t,e)}},Us=class extends Xn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this._multistep=!0,this._cb=void 0,this._onInfoResponse=a=>{let c=this._cb;c&&(this._cb=void 0,c(a))},this.submethods=i,this.on("abort",()=>{this._cb&&this._cb(new Error("Authentication request aborted"))})}prompt(t,e,r,s){Array.isArray(t)||(t=[t]),typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"?(s=r,r=void 0):typeof s!="function"&&(s=void 0);for(let i=0;i<t.length;++i)typeof t[i]=="string"&&(t[i]={prompt:t[i],echo:!0});this._cb=s,this._initialResponse=!0,this._protocol.authInfoReq(e,r,t)}},Ya=class extends Xn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob}accept(){this.signature?Xn.prototype.accept.call(this):(this._initialResponse=!0,this._protocol.authPKOK(this.key.algo,this.key.data))}},ja=class extends Xn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.key={algo:i.keyAlgo,data:i.key},this.hashAlgo=i.hashAlgo,this.signature=i.signature,this.blob=i.blob,this.localHostname=i.localHostname,this.localUsername=i.localUsername}},Ds=class extends Xn{constructor(t,e,r,s,i,o){super(t,e,r,s,o),this.password=i,this._changeCb=void 0}requestChange(t,e){if(this._changeCb)throw new Error("Change request already in progress");if(typeof t!="string")throw new Error("prompt argument must be a string");if(typeof e!="function")throw new Error("Callback argument must be a function");this._changeCb=e,this._protocol.authPasswdChg(t)}},wn=class extends Ri{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:Yn,packetSize:jn,state:"open"},outgoing:{id:e.sender,window:e.window,packetSize:e.packetSize,state:"open"}}}},cn=class extends Ri{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new Error("Missing configuration object");let r=Object.create(null),s=[],i=t.hostKeys;if(!Array.isArray(i))throw new Error("hostKeys must be an array");let o=typeof t.algorithms=="object"&&t.algorithms!==null?t.algorithms:{},a=Bi(o.serverHostKey,d0,E0);for(let h=0;h<i.length;++h){let p;if(Buffer.isBuffer(i[h])||typeof i[h]=="string"?p=Vl(i[h]):p=Vl(i[h].key,i[h].passphrase),p instanceof Error)throw new Error(`Cannot parse privateKey: ${p.message}`);if(Array.isArray(p)&&(p=p[0]),p.getPrivatePEM()===null)throw new Error("privateKey value contains an invalid private key");if(!s.includes(p.type))if(p.type==="ssh-rsa"){let y=a.indexOf("ssh-rsa"),E=a.indexOf("rsa-sha2-256"),b=a.indexOf("rsa-sha2-512");y===-1&&(y=1/0),[y,E,b].sort(R0).forEach(C=>{if(C===-1)return;let N;switch(C){case y:N="ssh-rsa";break;case E:N="rsa-sha2-256";break;case b:N="rsa-sha2-512";break;default:return}r[N]=p,s.push(N)})}else r[p.type]=p,s.push(p.type)}let c={kex:Bi(o.kex,l0,m0).concat(["kex-strict-s-v00@openssh.com"]),serverHostKey:s,cs:{cipher:Bi(o.cipher,c0,p0),mac:Bi(o.hmac,u0,A0),compress:Bi(o.compress,f0,g0),lang:[]},sc:void 0};c.sc=c.cs,typeof e=="function"&&this.on("connection",e);let f=typeof t.debug=="function"?t.debug:void 0,l=t.ident?Buffer.from(t.ident):void 0,u=new _0(c);this._srv=new a0(h=>{if(this._connections>=this.maxConnections){h.destroy();return}++this._connections,h.once("close",()=>{--this._connections});let p;if(f){let y=`[${process.hrtime().join(".")}] `;p=E=>{f(`${y}${E}`)}}new $s(h,r,l,u,p,this,t)}).on("error",h=>{this.emit("error",h)}).on("listening",()=>{this.emit("listening")}).on("close",()=>{this.emit("close")}),this._connections=0,this.maxConnections=1/0}injectSocket(t){this._srv.emit("connection",t)}listen(...t){return this._srv.listen(...t),this}address(){return this._srv.address()}getConnections(t){return this._srv.getConnections(t),this}close(t){return this._srv.close(t),this}ref(){return this._srv.ref(),this}unref(){return this._srv.unref(),this}};cn.KEEPALIVE_CLIENT_INTERVAL=15e3;cn.KEEPALIVE_CLIENT_COUNT_MAX=3;var $s=class extends Ri{constructor(t,e,r,s,i,o,a){super();let c=0,f=!1,l=[],u,h,p,y=[];this._sock=t,this._chanMgr=new C0(this),this._debug=i,this.noMoreSessions=!1,this.authenticated=!1;function E(P){}this.on("error",E);let b=i?(P,x,w)=>{i(`Debug output from client: ${JSON.stringify(w)}`)}:void 0,C=typeof a.keepaliveInterval=="number"&&isFinite(a.keepaliveInterval)&&a.keepaliveInterval>0?a.keepaliveInterval:typeof cn.KEEPALIVE_CLIENT_INTERVAL=="number"&&isFinite(cn.KEEPALIVE_CLIENT_INTERVAL)&&cn.KEEPALIVE_CLIENT_INTERVAL>0?cn.KEEPALIVE_CLIENT_INTERVAL:-1,N=typeof a.keepaliveCountMax=="number"&&isFinite(a.keepaliveCountMax)&&a.keepaliveCountMax>=0?a.keepaliveCountMax:typeof cn.KEEPALIVE_CLIENT_COUNT_MAX=="number"&&isFinite(cn.KEEPALIVE_CLIENT_COUNT_MAX)&&cn.KEEPALIVE_CLIENT_COUNT_MAX>=0?cn.KEEPALIVE_CLIENT_COUNT_MAX:-1,H=0;C!==-1&&N!==-1&&(this.once("ready",()=>{let P=()=>{clearInterval(h)};this.on("close",P).on("end",P),h=setInterval(()=>{if(++H>N){clearInterval(h);let x=new Error("Keepalive timeout");x.level="client-timeout",this.emit("error",x),this.end()}else v.ping()},C)}),p=()=>{h&&h.refresh(),H=0});let v=this._protocol=new b0({server:!0,hostKeys:e,ident:r,offer:s,onPacket:p,greeting:a.greeting,banner:a.banner,onWrite:P=>{Ls(t)&&t.write(P)},onError:P=>{v._destruct||t.removeAllListeners("data"),this.emit("error",P);try{t.end()}catch{}},onHeader:P=>{this.removeListener("error",E);let x={ip:t.remoteAddress,family:t.remoteFamily,port:t.remotePort,header:P};if(!o.emit("connection",this,x)){v.disconnect(Fr.BY_APPLICATION),t.end();return}P.greeting&&this.emit("greeting",P.greeting)},onHandshakeComplete:P=>{++c>1&&this.emit("rekey"),this.emit("handshake",P)},debug:i,messageHandlers:{DEBUG:b,DISCONNECT:(P,x,w)=>{if(x!==Fr.BY_APPLICATION){w||(w=h0[x],w===void 0&&(w=`Unexpected disconnection reason: ${x}`));let I=new Error(w);I.code=x,this.emit("error",I)}t.end()},CHANNEL_OPEN:(P,x)=>{if(x.type==="session"&&this.noMoreSessions||!this.authenticated){let te=Mr.ADMINISTRATIVELY_PROHIBITED;return v.channelOpenFail(x.sender,te)}let w=-1,I,k=!1,R,ne=()=>{k||(k=!0,I===void 0&&(w===-1?I=Mr.RESOURCE_SHORTAGE:I=Mr.CONNECT_FAILED),w!==-1&&this._chanMgr.remove(w),v.channelOpenFail(x.sender,I,""))},z=()=>(w=this._chanMgr.add(),w===-1&&(I=Mr.RESOURCE_SHORTAGE,i&&i("Automatic rejection of incoming channel open: no channels available")),w!==-1),Y=x.data;switch(x.type){case"session":if(Vt(this,"session")&&z()){R=()=>{if(k)return;k=!0;let te=new wn(this,x,w);return this._chanMgr.update(w,te),v.channelOpenConfirm(x.sender,w,Yn,jn),te},this.emit("session",R,ne);return}break;case"direct-tcpip":if(Vt(this,"tcpip")&&z()){R=()=>{if(k)return;k=!0;let te={type:void 0,incoming:{id:w,window:Yn,packetSize:jn,state:"open"},outgoing:{id:x.sender,window:x.window,packetSize:x.packetSize,state:"open"}},ce=new Hr(this,te,{server:!0});return this._chanMgr.update(w,ce),v.channelOpenConfirm(x.sender,w,Yn,jn),ce},this.emit("tcpip",R,ne,Y);return}break;case"direct-streamlocal@openssh.com":if(Vt(this,"openssh.streamlocal")&&z()){R=()=>{if(k)return;k=!0;let te={type:void 0,incoming:{id:w,window:Yn,packetSize:jn,state:"open"},outgoing:{id:x.sender,window:x.window,packetSize:x.packetSize,state:"open"}},ce=new Hr(this,te,{server:!0});return this._chanMgr.update(w,ce),v.channelOpenConfirm(x.sender,w,Yn,jn),ce},this.emit("openssh.streamlocal",R,ne,Y);return}break;default:I=Mr.UNKNOWN_CHANNEL_TYPE,i&&i(`Automatic rejection of unsupported incoming channel open type: ${x.type}`)}I===void 0&&(I=Mr.ADMINISTRATIVELY_PROHIBITED,i&&i(`Automatic rejection of unexpected incoming channel open for: ${x.type}`)),ne()},CHANNEL_OPEN_CONFIRMATION:(P,x)=>{let w=this._chanMgr.get(x.recipient);if(typeof w!="function")return;let I={type:w.type,incoming:{id:x.recipient,window:Yn,packetSize:jn,state:"open"},outgoing:{id:x.sender,window:x.window,packetSize:x.packetSize,state:"open"}},k=new Hr(this,I,{server:!0});this._chanMgr.update(x.recipient,k),w(void 0,k)},CHANNEL_OPEN_FAILURE:(P,x,w,I)=>{let k=this._chanMgr.get(x);if(typeof k!="function")return;v0(this,x,{reason:w,description:I},k)},CHANNEL_DATA:(P,x,w)=>{let I=this._chanMgr.get(x);if(!(typeof I!="object"||I===null)&&!(I.constructor===wn&&(I=I._channel,!I))&&I.incoming.window!==0){if(I.incoming.window-=w.length,I.push(w)===!1){I._waitChanDrain=!0;return}I.incoming.window<=I0&&w0(I)}},CHANNEL_EXTENDED_DATA:(P,x,w,I)=>{},CHANNEL_WINDOW_ADJUST:(P,x,w)=>{let I=this._chanMgr.get(x);typeof I!="object"||I===null||I.constructor===wn&&(I=I._channel,!I)||(I.outgoing.window+=w,I._waitWindow&&(I._waitWindow=!1,I._chunk?I._write(I._chunk,null,I._chunkcb):I._chunkcb?I._chunkcb():I._chunkErr?I.stderr._write(I._chunkErr,null,I._chunkcbErr):I._chunkcbErr&&I._chunkcbErr()))},CHANNEL_SUCCESS:(P,x)=>{let w=this._chanMgr.get(x);typeof w!="object"||w===null||w.constructor===wn&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!1)},CHANNEL_FAILURE:(P,x)=>{let w=this._chanMgr.get(x);typeof w!="object"||w===null||w.constructor===wn&&(w=w._channel,!w)||w._callbacks.length&&w._callbacks.shift()(!0)},CHANNEL_REQUEST:(P,x,w,I,k)=>{let R=this._chanMgr.get(x);if(typeof R!="object"||R===null)return;let ne=!1,z,Y;if(R.constructor!==wn){I&&v.channelFailure(R.outgoing.id);return}if(I&&(w!=="shell"&&w!=="exec"&&w!=="subsystem"&&(z=()=>{ne||R._ending||R._channel||(ne=!0,v.channelSuccess(R._chanInfo.outgoing.id))}),Y=()=>{ne||R._ending||R._channel||(ne=!0,v.channelFailure(R._chanInfo.outgoing.id))}),R._ending){Y&&Y();return}switch(w){case"env":if(Vt(R,"env")){R.emit("env",z,Y,{key:k.name,val:k.value});return}break;case"pty-req":if(Vt(R,"pty")){R.emit("pty",z,Y,k);return}break;case"window-change":Vt(R,"window-change")?R.emit("window-change",z,Y,k):Y&&Y();break;case"x11-req":if(Vt(R,"x11")){R.emit("x11",z,Y,k);return}break;case"signal":if(Vt(R,"signal")){R.emit("signal",z,Y,{name:k});return}break;case"auth-agent-req@openssh.com":if(Vt(R,"auth-agent")){R.emit("auth-agent",z,Y);return}break;case"shell":if(Vt(R,"shell")){z=()=>{if(ne||R._ending||R._channel)return;ne=!0,I&&v.channelSuccess(R._chanInfo.outgoing.id);let te=new Hr(this,R._chanInfo,{server:!0});return te.subtype=R.subtype=w,R._channel=te,te},R.emit("shell",z,Y);return}break;case"exec":if(Vt(R,"exec")){z=()=>{if(ne||R._ending||R._channel)return;ne=!0,I&&v.channelSuccess(R._chanInfo.outgoing.id);let te=new Hr(this,R._chanInfo,{server:!0});return te.subtype=R.subtype=w,R._channel=te,te},R.emit("exec",z,Y,{command:k});return}break;case"subsystem":{let te=k==="sftp";if(z=()=>{if(ne||R._ending||R._channel)return;ne=!0,I&&v.channelSuccess(R._chanInfo.outgoing.id);let ce;return te?ce=new x0(this,R._chanInfo,{server:!0,debug:i}):(ce=new Hr(this,R._chanInfo,{server:!0}),ce.subtype=R.subtype=`${w}:${k}`),R._channel=ce,ce},k==="sftp"){if(Vt(R,"sftp")){R.emit("sftp",z,Y);return}te=!1}if(Vt(R,"subsystem")){R.emit("subsystem",z,Y,{name:k});return}break}}i&&i(`Automatic rejection of incoming channel request: ${w}`),Y&&Y()},CHANNEL_EOF:(P,x)=>{let w=this._chanMgr.get(x);typeof w!="object"||w===null||w.constructor===wn&&(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:(P,x)=>{let w=this._chanMgr.get(x);typeof w!="object"||w===null||w.constructor===wn&&(w._ending=!0,w.emit("close"),w=w._channel,!w)||k0(this,x,w)},SERVICE_REQUEST:(P,x)=>{if(c===0||f||this.authenticated||x!=="ssh-userauth"){v.disconnect(Fr.SERVICE_NOT_AVAILABLE),t.end();return}f=!0,v.serviceAccept(x)},USERAUTH_REQUEST:(P,x,w,I,k)=>{if(c===0||this.authenticated||u&&(u.username!==x||u.service!==w)||I!=="password"&&I!=="publickey"&&I!=="hostbased"&&I!=="keyboard-interactive"&&I!=="none"||l.length===B0){v.disconnect(Fr.PROTOCOL_ERROR),t.end();return}else if(w!=="ssh-connection"){v.disconnect(Fr.SERVICE_NOT_AVAILABLE),t.end();return}let R;switch(I){case"keyboard-interactive":R=new Us(v,x,w,I,k,M);break;case"publickey":R=new Ya(v,x,w,I,k,M);break;case"hostbased":R=new ja(v,x,w,I,k,M);break;case"password":if(u&&u instanceof Ds&&u._changeCb){let ne=u._changeCb;u._changeCb=void 0,ne(k.newPassword);return}R=new Ds(v,x,w,I,k,M);break;case"none":R=new Xn(v,x,w,I,M);break}if(u)if(u._initialResponse)u._multistep&&!u._finalResponse&&(u._cleanup&&u._cleanup(),u.emit("abort"));else return l.push(R);u=R,Vt(this,"authentication")?this.emit("authentication",u):u.reject()},USERAUTH_INFO_RESPONSE:(P,x)=>{u&&u instanceof Us&&u._onInfoResponse(x)},GLOBAL_REQUEST:(P,x,w,I)=>{let k={type:null,buf:null};function R(ne,z){k.type=ne,k.buf=z,Q()}if(w&&y.push(k),(x==="tcpip-forward"||x==="cancel-tcpip-forward"||x==="no-more-sessions@openssh.com"||x==="streamlocal-forward@openssh.com"||x==="cancel-streamlocal-forward@openssh.com")&&Vt(this,"request")&&this.authenticated){let ne,z;if(w){let Y=!1;ne=te=>{if(Y)return;Y=!0;let ce;x==="tcpip-forward"&&I.bindPort===0&&typeof te=="number"&&(ce=Buffer.allocUnsafe(4),S0(ce,te,0)),R("SUCCESS",ce)},z=()=>{Y||(Y=!0,R("FAILURE"))}}if(x==="no-more-sessions@openssh.com"){this.noMoreSessions=!0,ne&&ne();return}this.emit("request",ne,z,x,I)}else w&&R("FAILURE")}}});t.pause(),y0.then(()=>{v.start(),t.on("data",P=>{try{v.parse(P,0,P.length)}catch(x){this.emit("error",x);try{Ls(t)&&t.end()}catch{}}}),t.resume()}).catch(P=>{this.emit("error",P);try{Ls(t)&&t.end()}catch{}}),t.on("error",P=>{P.level="socket",this.emit("error",P)}).once("end",()=>{i&&i("Socket ended"),v.cleanup(),this.emit("end")}).once("close",()=>{i&&i("Socket closed"),v.cleanup(),this.emit("close");let P=new Error("No response from server");this._chanMgr.cleanup(P)});let M=(P,x,w,I)=>{u===P&&!this.authenticated&&(x?(u=void 0,this.authenticated=!0,v.authSuccess(),l=[],this.emit("ready")):(v.authFailure(w,I),l.length&&(u=l.pop(),Vt(this,"authentication")?this.emit("authentication",u):u.reject())))};function Q(){for(;y.length>0&&y[0].type;){let P=y.shift();P.type==="SUCCESS"&&v.requestSuccess(P.buf),P.type==="FAILURE"&&v.requestFailure()}}}end(){return this._sock&&Ls(this._sock)&&(this._protocol.disconnect(Fr.BY_APPLICATION),this._sock.end()),this}x11(t,e,r){return za(this,"x11",{originAddr:t,originPort:e},r),this}forwardOut(t,e,r,s,i){return za(this,"forwarded-tcpip",{boundAddr:t,boundPort:e,remoteAddr:r,remotePort:s},i),this}openssh_forwardOutStreamLocal(t,e){return za(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 za(n,t,e,r){let s=Yn,i=jn;typeof e=="function"&&(r=e,e={});let o=(c,f)=>{r(c,f)};o.type=t;let a=n._chanMgr.add(o);if(a===-1){r(new Error("No free channels available"));return}switch(t){case"forwarded-tcpip":n._protocol.forwardedTcpip(a,s,i,e);break;case"x11":n._protocol.x11(a,s,i,e);break;case"forwarded-streamlocal@openssh.com":n._protocol.openssh_forwardedStreamLocal(a,s,i,e);break;default:throw new Error(`Unsupported channel type: ${t}`)}}function R0(n,t){return n-t}Xa.exports=cn;Xa.exports.IncomingClient=$s});var Jl=ct((XE,Xl)=>{"use strict";var{createCipheriv:N0,generateKeyPair:P0,generateKeyPairSync:T0,getCurves:L0,randomBytes:zl}=require("crypto"),{Ber:_t}=ri(),U0=mo().pbkdf,{CIPHER_INFO:D0}=Wn(),$0=16,O0=16,M0=L0(),F0=new Map(Object.entries(D0));function Yl(n,t){if(typeof n!="string")throw new TypeError("Key type must be a string");let e={type:"spki",format:"der"},r={type:"pkcs8",format:"der"};switch(n.toLowerCase()){case"rsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for RSA key");let s=t.bits;if(!Number.isInteger(s))throw new TypeError("RSA bits must be an integer");if(s<=0||s>16384)throw new RangeError("RSA bits must be non-zero and <= 16384");return["rsa",{modulusLength:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ecdsa":{if(typeof t!="object"||t===null)throw new TypeError("Missing options object for ECDSA key");if(!Number.isInteger(t.bits))throw new TypeError("ECDSA bits must be an integer");let s;switch(t.bits){case 256:s="prime256v1";break;case 384:s="secp384r1";break;case 521:s="secp521r1";break;default:throw new Error("ECDSA bits must be 256, 384, or 521")}if(!M0.includes(s))throw new Error("Unsupported ECDSA bits value");return["ec",{namedCurve:s,publicKeyEncoding:e,privateKeyEncoding:r}]}case"ed25519":return["ed25519",{publicKeyEncoding:e,privateKeyEncoding:r}];default:throw new Error(`Unsupported key type: ${n}`)}}function H0(n,t,e){switch(n){case"rsa":{let r=new _t.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()!==_t.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 _t.Reader(r.readString(_t.OctetString,!0)),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in RSA private key");let s=r.readString(_t.Integer,!0),i=r.readString(_t.Integer,!0),o=r.readString(_t.Integer,!0),a=r.readString(_t.Integer,!0),c=r.readString(_t.Integer,!0);r.readString(_t.Integer,!0),r.readString(_t.Integer,!0);let f=r.readString(_t.Integer,!0),l=Buffer.from("ssh-rsa"),u=Buffer.allocUnsafe(4+l.length+4+s.length+4+i.length+4+o.length+4+f.length+4+a.length+4+c.length),h=0;u.writeUInt32BE(l.length,h+=0),u.set(l,h+=4),u.writeUInt32BE(s.length,h+=l.length),u.set(s,h+=4),u.writeUInt32BE(i.length,h+=s.length),u.set(i,h+=4),u.writeUInt32BE(o.length,h+=i.length),u.set(o,h+=4),u.writeUInt32BE(f.length,h+=o.length),u.set(f,h+=4),u.writeUInt32BE(a.length,h+=f.length),u.set(a,h+=4),u.writeUInt32BE(c.length,h+=a.length),u.set(c,h+=4);let p=Buffer.allocUnsafe(4+l.length+4+i.length+4+s.length);return h=0,p.writeUInt32BE(l.length,h+=0),p.set(l,h+=4),p.writeUInt32BE(i.length,h+=l.length),p.set(i,h+=4),p.writeUInt32BE(s.length,h+=i.length),p.set(s,h+=4),{sshName:l.toString(),priv:u,pub:p}}case"ec":{let r=new _t.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA public OID");r.readOID();let s=r.readString(_t.BitString,!0);{let h=0;for(;h<s.length&&s[h]===0;++h);h>0&&(s=s.slice(h))}if(r=new _t.Reader(e),r.readSequence(),r.readInt()!==0)throw new Error("Unsupported version in ECDSA private key");if(r.readSequence(),r.readOID()!=="1.2.840.10045.2.1")throw new Error("Bad ECDSA private OID");let i=r.readOID(),o;switch(i){case"1.2.840.10045.3.1.7":o="nistp256";break;case"1.3.132.0.34":o="nistp384";break;case"1.3.132.0.35":o="nistp521";break;default:throw new Error("Unsupported curve in ECDSA private key")}if(r=new _t.Reader(r.readString(_t.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(_t.OctetString,!0)]),c=Buffer.from(`ecdsa-sha2-${o}`);o=Buffer.from(o);let f=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length+4+a.length),l=0;f.writeUInt32BE(c.length,l+=0),f.set(c,l+=4),f.writeUInt32BE(o.length,l+=c.length),f.set(o,l+=4),f.writeUInt32BE(s.length,l+=o.length),f.set(s,l+=4),f.writeUInt32BE(a.length,l+=s.length),f.set(a,l+=4);let u=Buffer.allocUnsafe(4+c.length+4+o.length+4+s.length);return l=0,u.writeUInt32BE(c.length,l+=0),u.set(c,l+=4),u.writeUInt32BE(o.length,l+=c.length),u.set(o,l+=4),u.writeUInt32BE(s.length,l+=o.length),u.set(s,l+=4),{sshName:c.toString(),priv:f,pub:u}}case"ed25519":{let r=new _t.Reader(t);if(r.readSequence(),r.readSequence(),r.readOID()!=="1.3.101.112")throw new Error("Bad ED25519 public OID");let s=r.readString(_t.BitString,!0);{let l=0;for(;l<s.length&&s[l]===0;++l);l>0&&(s=s.slice(l))}if(r=new _t.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 _t.Reader(r.readString(_t.OctetString,!0));let i=r.readString(_t.OctetString,!0),o=Buffer.from("ssh-ed25519"),a=Buffer.allocUnsafe(4+o.length+4+s.length+4+(i.length+s.length)),c=0;a.writeUInt32BE(o.length,c+=0),a.set(o,c+=4),a.writeUInt32BE(s.length,c+=o.length),a.set(s,c+=4),a.writeUInt32BE(i.length+s.length,c+=s.length),a.set(i,c+=4),a.set(s,c+=i.length);let f=Buffer.allocUnsafe(4+o.length+4+s.length);return c=0,f.writeUInt32BE(o.length,c+=0),f.set(o,c+=4),f.writeUInt32BE(s.length,c+=o.length),f.set(s,c+=4),{sshName:o.toString(),priv:a,pub:f}}}}function jl(n,t,e,r){let s="new",i,o="";if(typeof r=="object"&&r!==null&&(typeof r.comment=="string"&&r.comment&&(o=r.comment),typeof r.format=="string"&&r.format&&(s=r.format),r.passphrase)){let a;if(typeof r.passphrase=="string")a=Buffer.from(r.passphrase);else if(Buffer.isBuffer(r.passphrase))a=r.passphrase;else throw new Error("Invalid passphrase");if(r.cipher===void 0)throw new Error("Missing cipher name");let c=F0.get(r.cipher);if(c===void 0)throw new Error("Invalid cipher name");if(s==="new"){let f=O0;if(r.rounds!==void 0){if(!Number.isInteger(r.rounds))throw new TypeError("rounds must be an integer");r.rounds>0&&(f=r.rounds)}let l=Buffer.allocUnsafe(c.keyLen+c.ivLen),u=zl($0);if(U0(a,a.length,u,u.length,l,l.length,f)!==0)return new Error("Failed to generate information to encrypt key");let p=Buffer.allocUnsafe(4+u.length+4);{let y=0;p.writeUInt32BE(u.length,y+=0),p.set(u,y+=4),p.writeUInt32BE(f,y+=u.length)}i={cipher:c,cipherName:r.cipher,kdfName:"bcrypt",kdfOptions:p,key:l.slice(0,c.keyLen),iv:l.slice(c.keyLen)}}}switch(s){case"new":{let a=`-----BEGIN OPENSSH PRIVATE KEY-----
15
+ `,c,f=Buffer.from(i?i.cipherName:"none"),l=Buffer.from(i?i.kdfName:"none"),u=i?i.kdfOptions:Buffer.alloc(0),h=i?i.cipher.blockLen:8,p=H0(n,t,e),y=zl(4),E=Buffer.from(o),b=8+p.priv.length+4+E.length,C=[];for(let Q=1;(b+C.length)%h;++Q)C.push(Q&255);C=Buffer.from(C);let N=Buffer.allocUnsafe(b+C.length),H;{let Q=0;N.set(y,Q+=0),N.set(y,Q+=4),N.set(p.priv,Q+=4),N.writeUInt32BE(E.length,Q+=p.priv.length),N.set(E,Q+=4),N.set(C,Q+=E.length)}if(i){let Q={authTagLength:i.cipher.authLen},P=N0(i.cipher.sslName,i.key,i.iv,Q);P.setAutoPadding(!1),N=Buffer.concat([P.update(N),P.final()]),i.cipher.authLen>0?H=P.getAuthTag():H=Buffer.alloc(0),i.key.fill(0),i.iv.fill(0)}else H=Buffer.alloc(0);let v=Buffer.from("openssh-key-v1\0"),M=Buffer.allocUnsafe(v.length+4+f.length+4+l.length+4+u.length+4+4+p.pub.length+4+N.length+H.length);{let Q=0;M.set(v,Q+=0),M.writeUInt32BE(f.length,Q+=v.length),M.set(f,Q+=4),M.writeUInt32BE(l.length,Q+=f.length),M.set(l,Q+=4),M.writeUInt32BE(u.length,Q+=l.length),M.set(u,Q+=4),M.writeUInt32BE(1,Q+=u.length),M.writeUInt32BE(p.pub.length,Q+=4),M.set(p.pub,Q+=4),M.writeUInt32BE(N.length,Q+=p.pub.length),M.set(N,Q+=4),M.set(H,Q+=N.length)}{let Q=M.base64Slice(0,M.length),P=Q.replace(/.{64}/g,`$&
16
+ `);Q.length&63&&(P+=`
17
+ `),a+=P}{let Q=p.pub.base64Slice(0,p.pub.length);c=`${p.sshName} ${Q}${o?` ${o}`:""}`}return a+=`-----END OPENSSH PRIVATE KEY-----
18
+ `,{private:a,public:c}}default:throw new Error("Invalid output key format")}}function Q0(){}Xl.exports={generateKeyPair:(n,t,e)=>{typeof t=="function"&&(e=t,t=void 0),typeof e!="function"&&(e=Q0);let r=Yl(n,t);P0(...r,(s,i,o)=>{if(s)return e(s);let a;try{a=jl(r[0],i,o,t)}catch(c){return e(c)}e(null,a)})},generateKeyPairSync:(n,t)=>{let e=Yl(n,t),{publicKey:r,privateKey:s}=T0(...e);return jl(e[0],r,s,t)}}});var Ja=ct((JE,Zl)=>{"use strict";var{AgentProtocol:W0,BaseAgent:q0,createAgent:K0,CygwinAgent:V0,OpenSSHAgent:G0,PageantAgent:z0}=ia(),{SSHTTPAgent:Y0,SSHTTPSAgent:j0}=Kl(),{parseKey:X0}=Vn(),{flagsToString:J0,OPEN_MODE:Z0,STATUS_CODE:eA,stringToFlags:tA}=xi();Zl.exports={AgentProtocol:W0,BaseAgent:q0,createAgent:K0,Client:Ka(),CygwinAgent:V0,HTTPAgent:Y0,HTTPSAgent:j0,OpenSSHAgent:G0,PageantAgent:z0,Server:Gl(),utils:{parseKey:X0,...Jl(),sftp:{flagsToString:J0,OPEN_MODE:Z0,STATUS_CODE:eA,stringToFlags:tA}}}});var Za={};ap(Za,{evalArith:()=>Cu,expandAsync:()=>Pi,expandBraces:()=>Ni,expandSync:()=>Ms});function Cu(n,t){let e=n.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\b/g,(r,s)=>{let i=t[s];return i!==void 0&&i!==""?i:"0"});if(!/^[\d\s+\-*/%()^!&|<>=,. ]+$/.test(e))return NaN;try{let r=Function(`"use strict"; return (${e.replace(/\*\*/g,"**")});`)();return typeof r=="number"?Math.trunc(r):NaN}catch{return NaN}}function aA(n,t){let e=[],r=0;for(;r<n.length;){let s=n.indexOf("'",r);if(s===-1){e.push(t(n.slice(r)));break}e.push(t(n.slice(r,s)));let i=n.indexOf("'",s+1);if(i===-1){e.push(n.slice(s));break}e.push(n.slice(s,i+1)),r=i+1}return e.join("")}function Ni(n){let t=0,e=-1;for(let r=0;r<n.length;r++){let s=n[r];if(s==="{"&&n[r-1]!=="$")t===0&&(e=r),t++;else if(s==="}"&&(t--,t===0&&e!==-1)){let i=n.slice(0,e),o=n.slice(e+1,r),a=n.slice(r+1),c=o.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.-?(\d+))?$/)||o.match(/^([a-z])\.\.([a-z])$/);if(c){let h=[];if(/\d/.test(c[1])){let y=parseInt(c[1],10),E=parseInt(c[2],10),b=c[3]?parseInt(c[3],10):1,C=y<=E?b:-b;for(let N=y;y<=E?N<=E:N>=E;N+=C)h.push(String(N))}else{let y=c[1].charCodeAt(0),E=c[2].charCodeAt(0),b=y<=E?1:-1;for(let C=y;y<=E?C<=E:C>=E;C+=b)h.push(String.fromCharCode(C))}return h.map(y=>`${i}${y}${a}`).flatMap(Ni)}let f=[],l="",u=0;for(let h of o)h==="{"?(u++,l+=h):h==="}"?(u--,l+=h):h===","&&u===0?(f.push(l),l=""):l+=h;if(f.push(l),f.length>1)return f.map(p=>`${i}${p}${a}`).flatMap(Ni);break}}return[n]}function Ms(n,t,e=0,r){let s=r??t.HOME??"/home/user";return aA(n,i=>{let o=i;return o=o.replace(/(^|[\s:])~(\/|$)/g,(a,c,f)=>`${c}${s}${f}`),o=o.replace(/\$\?/g,String(e)),o=o.replace(/\$\$/g,"1"),o=o.replace(/\$#/g,"0"),o=o.replace(/\$\(\(([^)]+(?:\([^)]*\)[^)]*)*)\)\)/g,(a,c)=>{let f=Cu(c,t);return Number.isNaN(f)?"0":String(f)}),o=o.replace(/\$\{#([A-Za-z_][A-Za-z0-9_]*)\}/g,(a,c)=>String((t[c]??"").length)),o=o.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*):-([^}]*)\}/g,(a,c,f)=>t[c]!==void 0&&t[c]!==""?t[c]:f),o=o.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*):=([^}]*)\}/g,(a,c,f)=>((t[c]===void 0||t[c]==="")&&(t[c]=f),t[c])),o=o.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*):\+([^}]*)\}/g,(a,c,f)=>t[c]!==void 0&&t[c]!==""?f:""),o=o.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(a,c)=>t[c]??""),o=o.replace(/\$([A-Za-z_][A-Za-z0-9_]*|\d+)/g,(a,c)=>t[c]??""),o})}async function Pi(n,t,e,r){if(n.includes("$(")){let s="",i=!1,o=0;for(;o<n.length;){let a=n[o];if(a==="'"&&!i){i=!0,s+=a,o++;continue}if(a==="'"&&i){i=!1,s+=a,o++;continue}if(!i&&a==="$"&&n[o+1]==="("){if(n[o+2]==="("){s+=a,o++;continue}let c=0,f=o+1;for(;f<n.length;){if(n[f]==="(")c++;else if(n[f]===")"&&(c--,c===0))break;f++}let l=n.slice(o+2,f).trim(),u=(await r(l)).replace(/\n$/,"");s+=u,o=f+1;continue}s+=a,o++}n=s}return Ms(n,t,e)}var Wr=op(()=>{"use strict"});var zh=require("node:events"),Yh=Gt(Ja(),1);var Qh=require("node:events");var eu={name:"adduser",description:"Add a new user",category:"users",params:["<username>"],run:({authUser:n,shell:t,args:e})=>{if(n!=="root")return{stderr:`adduser: permission denied
19
19
  `,exitCode:1};let r=e[0];if(!r)return{stderr:`Usage: adduser <username>
20
20
  `,exitCode:1};if(t.users.listUsers().includes(r))return{stderr:`adduser: user '${r}' already exists
21
21
  `,exitCode:1};let s="",i="new";return{sudoChallenge:{username:r,targetUser:r,commandLine:null,loginShell:!1,prompt:"New password: ",mode:"passwd",onPassword:async(a,c)=>i==="new"?a.length<1?{result:{stderr:`adduser: password cannot be empty
22
22
  `,exitCode:1}}:(s=a,i="retype",{result:null,nextPrompt:"Retype new password: "}):a!==s?{result:{stderr:`adduser: passwords do not match \u2014 user not created
23
23
  `,exitCode:1}}:(await c.users.addUser(r,s),{result:{stdout:`${[`Adding user '${r}' ...`,`Adding new group '${r}' (1001) ...`,`Adding new user '${r}' (1001) with group '${r}' ...`,`Creating home directory '/home/${r}' ...`,`passwd: password set for '${r}'`,"adduser: done."].join(`
24
24
  `)}
25
- `,exitCode:0}})},exitCode:0}}};function Jl(n){return Array.isArray(n)?n:[n]}function Us(n,t){if(n===t)return{matched:!0,inlineValue:null};let e=`${t}=`;return n.startsWith(e)?{matched:!0,inlineValue:n.slice(e.length)}:t.length===2&&t.startsWith("-")&&!t.startsWith("--")&&n.startsWith(t)&&n.length>t.length?{matched:!0,inlineValue:n.slice(t.length)}:{matched:!1,inlineValue:null}}function zm(n,t={}){let e=new Set(t.flags??[]),r=new Set(t.flagsWithValue??[]),s=[],i=!1;for(let o=0;o<n.length;o+=1){let a=n[o];if(i){s.push(a);continue}if(a==="--"){i=!0;continue}let c=!1;for(let f of e){let{matched:l}=Us(a,f);if(l){c=!0;break}}if(!c){for(let f of r){let l=Us(a,f);if(l.matched){c=!0,l.inlineValue===null&&o+1<n.length&&(o+=1);break}}c||s.push(a)}}return s}function se(n,t){let e=Jl(t);for(let r of n)for(let s of e)if(Us(r,s).matched)return!0;return!1}function en(n,t){let e=Jl(t);for(let r=0;r<n.length;r+=1){let s=n[r];for(let i of e){let o=Us(s,i);if(!o.matched)continue;if(o.inlineValue!==null)return o.inlineValue;let a=n[r+1];return a!==void 0&&a!=="--"?a:!0}}}function Xn(n,t,e={}){return zm(n,e)[t]}function Yt(n,t={}){let e=new Set,r=new Map,s=[],i=new Set(t.flags??[]),o=new Set(t.flagsWithValue??[]),a=!1;for(let c=0;c<n.length;c+=1){let f=n[c];if(a){s.push(f);continue}if(f==="--"){a=!0;continue}if(i.has(f)){e.add(f);continue}if(o.has(f)){let u=n[c+1];u&&!u.startsWith("-")?(r.set(f,u),c+=1):r.set(f,"");continue}let l=Array.from(o).find(u=>f.startsWith(`${u}=`));if(l){r.set(l,f.slice(l.length+1));continue}s.push(f)}return{flags:e,flagsWithValues:r,positionals:s}}var Zl={name:"alias",description:"Define or display aliases",category:"shell",params:["[name[=value] ...]"],run:({args:n,env:t})=>{if(!t)return{exitCode:0};if(n.length===0)return{stdout:Object.entries(t.vars).filter(([s])=>s.startsWith("__alias_")).map(([s,i])=>`alias ${s.slice(8)}='${i}'`).join(`
25
+ `,exitCode:0}})},exitCode:0}}};function tu(n){return Array.isArray(n)?n:[n]}function Os(n,t){if(n===t)return{matched:!0,inlineValue:null};let e=`${t}=`;return n.startsWith(e)?{matched:!0,inlineValue:n.slice(e.length)}:t.length===2&&t.startsWith("-")&&!t.startsWith("--")&&n.startsWith(t)&&n.length>t.length?{matched:!0,inlineValue:n.slice(t.length)}:{matched:!1,inlineValue:null}}function nA(n,t={}){let e=new Set(t.flags??[]),r=new Set(t.flagsWithValue??[]),s=[],i=!1;for(let o=0;o<n.length;o+=1){let a=n[o];if(i){s.push(a);continue}if(a==="--"){i=!0;continue}let c=!1;for(let f of e){let{matched:l}=Os(a,f);if(l){c=!0;break}}if(!c){for(let f of r){let l=Os(a,f);if(l.matched){c=!0,l.inlineValue===null&&o+1<n.length&&(o+=1);break}}c||s.push(a)}}return s}function se(n,t){let e=tu(t);for(let r of n)for(let s of e)if(Os(r,s).matched)return!0;return!1}function tn(n,t){let e=tu(t);for(let r=0;r<n.length;r+=1){let s=n[r];for(let i of e){let o=Os(s,i);if(!o.matched)continue;if(o.inlineValue!==null)return o.inlineValue;let a=n[r+1];return a!==void 0&&a!=="--"?a:!0}}}function Jn(n,t,e={}){return nA(n,e)[t]}function jt(n,t={}){let e=new Set,r=new Map,s=[],i=new Set(t.flags??[]),o=new Set(t.flagsWithValue??[]),a=!1;for(let c=0;c<n.length;c+=1){let f=n[c];if(a){s.push(f);continue}if(f==="--"){a=!0;continue}if(i.has(f)){e.add(f);continue}if(o.has(f)){let u=n[c+1];u&&!u.startsWith("-")?(r.set(f,u),c+=1):r.set(f,"");continue}let l=Array.from(o).find(u=>f.startsWith(`${u}=`));if(l){r.set(l,f.slice(l.length+1));continue}s.push(f)}return{flags:e,flagsWithValues:r,positionals:s}}var nu={name:"alias",description:"Define or display aliases",category:"shell",params:["[name[=value] ...]"],run:({args:n,env:t})=>{if(!t)return{exitCode:0};if(n.length===0)return{stdout:Object.entries(t.vars).filter(([s])=>s.startsWith("__alias_")).map(([s,i])=>`alias ${s.slice(8)}='${i}'`).join(`
26
26
  `)||"",exitCode:0};let e=[];for(let r of n){let s=r.indexOf("=");if(s===-1){let i=t.vars[`__alias_${r}`];if(i)e.push(`alias ${r}='${i}'`);else return{stderr:`alias: ${r}: not found`,exitCode:1}}else{let i=r.slice(0,s),o=r.slice(s+1).replace(/^['"]|['"]$/g,"");t.vars[`__alias_${i}`]=o}}return{stdout:e.join(`
27
- `)||void 0,exitCode:0}}},eu={name:"unalias",description:"Remove alias definitions",category:"shell",params:["<name...> | -a"],run:({args:n,env:t})=>{if(!t)return{exitCode:0};if(se(n,["-a"])){for(let e of Object.keys(t.vars))e.startsWith("__alias_")&&delete t.vars[e];return{exitCode:0}}for(let e of n)delete t.vars[`__alias_${e}`];return{exitCode:0}}};var xn=Vt(require("node:path"),1),Ym=["/.virtual-env-js/.auth"];function le(n,t){return!t||t.trim()===""?n:t.startsWith("/")?xn.posix.normalize(t):xn.posix.normalize(xn.posix.join(n,t))}function jm(n){let t=n.startsWith("/")?xn.posix.normalize(n):xn.posix.normalize(`/${n}`);return Ym.some(e=>t===e||t.startsWith(`${e}/`))}function Oe(n,t,e){if(n!=="root"&&jm(t))throw new Error(`${e}: permission denied: ${t}`)}function tu(n){let e=(n.split("?")[0]?.split("#")[0]??n).split("/").filter(Boolean).pop();return e&&e.length>0?e:"index.html"}function Xm(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 s=1;s<=t.length;s+=1){let i=n[r-1]===t[s-1]?0:1;e[r][s]=Math.min(e[r-1][s]+1,e[r][s-1]+1,e[r-1][s-1]+i)}return e[n.length][t.length]}function nu(n,t,e){let r=le(t,e);if(n.exists(r))return r;let s=xn.posix.dirname(r),i=xn.posix.basename(r),o=n.list(s),a=o.filter(f=>f.toLowerCase()===i.toLowerCase());if(a.length===1)return xn.posix.join(s,a[0]);let c=o.filter(f=>Xm(f.toLowerCase(),i.toLowerCase())<=1);return c.length===1?xn.posix.join(s,c[0]):r}function ru(n,t,e){return t.map(r=>{let s=le(n,r);return e(s).type==="directory"?`${r}/`:r}).join(" ")}function Qr(n){return n.packageManager}var iu={name:"apt",aliases:["apt-get"],description:"Package manager",category:"package",params:["<install|remove|update|upgrade|search|show|list> [pkg...]"],run:({args:n,shell:t,authUser:e})=>{let r=Qr(t);if(!r)return{stderr:"apt: package manager not initialised",exitCode:1};let s=n[0]?.toLowerCase(),i=n.slice(1),o=se(i,["-q","--quiet","-qq"]),a=se(i,["--purge"]),c=i.filter(l=>!l.startsWith("-"));if(["install","remove","purge","upgrade","update"].includes(s??"")&&e!=="root")return{stderr:`E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
27
+ `)||void 0,exitCode:0}}},ru={name:"unalias",description:"Remove alias definitions",category:"shell",params:["<name...> | -a"],run:({args:n,env:t})=>{if(!t)return{exitCode:0};if(se(n,["-a"])){for(let e of Object.keys(t.vars))e.startsWith("__alias_")&&delete t.vars[e];return{exitCode:0}}for(let e of n)delete t.vars[`__alias_${e}`];return{exitCode:0}}};var In=Gt(require("node:path"),1),rA=["/.virtual-env-js/.auth","/etc/htpasswd"];function le(n,t){return!t||t.trim()===""?n:t.startsWith("/")?In.posix.normalize(t):In.posix.normalize(In.posix.join(n,t))}function iA(n){let t=n.startsWith("/")?In.posix.normalize(n):In.posix.normalize(`/${n}`);return rA.some(e=>t===e||t.startsWith(`${e}/`))}function Oe(n,t,e){if(n!=="root"&&iA(t))throw new Error(`${e}: permission denied: ${t}`)}function iu(n){let e=(n.split("?")[0]?.split("#")[0]??n).split("/").filter(Boolean).pop();return e&&e.length>0?e:"index.html"}function sA(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 s=1;s<=t.length;s+=1){let i=n[r-1]===t[s-1]?0:1;e[r][s]=Math.min(e[r-1][s]+1,e[r][s-1]+1,e[r-1][s-1]+i)}return e[n.length][t.length]}function su(n,t,e){let r=le(t,e);if(n.exists(r))return r;let s=In.posix.dirname(r),i=In.posix.basename(r),o=n.list(s),a=o.filter(f=>f.toLowerCase()===i.toLowerCase());if(a.length===1)return In.posix.join(s,a[0]);let c=o.filter(f=>sA(f.toLowerCase(),i.toLowerCase())<=1);return c.length===1?In.posix.join(s,c[0]):r}function ou(n,t,e){return t.map(r=>{let s=le(n,r);return e(s).type==="directory"?`${r}/`:r}).join(" ")}function Qr(n){return n.packageManager}var au={name:"apt",aliases:["apt-get"],description:"Package manager",category:"package",params:["<install|remove|update|upgrade|search|show|list> [pkg...]"],run:({args:n,shell:t,authUser:e})=>{let r=Qr(t);if(!r)return{stderr:"apt: package manager not initialised",exitCode:1};let s=n[0]?.toLowerCase(),i=n.slice(1),o=se(i,["-q","--quiet","-qq"]),a=se(i,["--purge"]),c=i.filter(l=>!l.startsWith("-"));if(["install","remove","purge","upgrade","update"].includes(s??"")&&e!=="root")return{stderr:`E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
28
28
  E: Unable to acquire the dpkg frontend lock, are you root?`,exitCode:100};switch(s){case"install":{if(c.length===0)return{stderr:"apt: no packages specified",exitCode:1};let{output:l,exitCode:u}=r.install(c,{quiet:o});return{stdout:l||void 0,exitCode:u}}case"remove":case"purge":{if(c.length===0)return{stderr:"apt: no packages specified",exitCode:1};let{output:l,exitCode:u}=r.remove(c,{purge:s==="purge"||a,quiet:o});return{stdout:l||void 0,exitCode:u}}case"update":return{stdout:["Hit:1 fortune://packages.fortune.local aurora InRelease","Hit:2 fortune://security.fortune.local aurora-security InRelease","Reading package lists... Done","Building dependency tree... Done","Reading state information... Done","All packages are up to date."].join(`
29
29
  `),exitCode:0};case"upgrade":return{stdout:["Reading package lists... Done","Building dependency tree... Done","Reading state information... Done","Calculating upgrade... Done","0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."].join(`
30
30
  `),exitCode:0};case"search":{let l=c[0];if(!l)return{stderr:"apt: search requires a term",exitCode:1};let u=r.search(l);return u.length===0?{stdout:`Sorting... Done
@@ -39,23 +39,23 @@ ${p.map(E=>`${E.name}/${E.section} ${E.version} ${E.architecture} [installed]`).
39
39
  `)}`,exitCode:0}}return{stdout:`Listing... Done
40
40
  ${r.listAvailable().map(p=>`${p.name}/${p.section??"misc"} ${p.version} amd64`).join(`
41
41
  `)}`,exitCode:0}}default:return{stdout:["Usage: apt [options] command","","Commands:"," install <pkg...> Install packages"," remove <pkg...> Remove packages"," purge <pkg...> Remove packages and config files"," update Refresh package index"," upgrade Upgrade all packages"," search <term> Search in package descriptions"," show <pkg> Show package details"," list [--installed] List packages"].join(`
42
- `),exitCode:0}}}},su={name:"apt-cache",description:"Query the package cache",category:"package",params:["<search|show|policy> [pkg]"],run:({args:n,shell:t})=>{let e=Qr(t);if(!e)return{stderr:"apt-cache: package manager not initialised",exitCode:1};let r=n[0]?.toLowerCase(),s=n[1];switch(r){case"search":return s?{stdout:e.search(s).map(o=>`${o.name} - ${o.shortDesc??o.description}`).join(`
42
+ `),exitCode:0}}}},cu={name:"apt-cache",description:"Query the package cache",category:"package",params:["<search|show|policy> [pkg]"],run:({args:n,shell:t})=>{let e=Qr(t);if(!e)return{stderr:"apt-cache: package manager not initialised",exitCode:1};let r=n[0]?.toLowerCase(),s=n[1];switch(r){case"search":return s?{stdout:e.search(s).map(o=>`${o.name} - ${o.shortDesc??o.description}`).join(`
43
43
  `)||"(no results)",exitCode:0}:{stderr:"Need a search term",exitCode:1};case"show":{if(!s)return{stderr:"Need a package name",exitCode:1};let i=e.show(s);return i?{stdout:i,exitCode:0}:{stderr:`N: Unable to locate package ${s}`,exitCode:100}}case"policy":{if(!s)return{stderr:"Need a package name",exitCode:1};let i=e.findInRegistry(s);if(!i)return{stderr:`N: Unable to locate package ${s}`,exitCode:100};let o=e.isInstalled(s);return{stdout:[`${s}:`,` Installed: ${o?i.version:"(none)"}`,` Candidate: ${i.version}`," Version table:",` ${i.version} 500`," 500 fortune://packages.fortune.local aurora/main amd64 Packages"].join(`
44
- `),exitCode:0}}default:return{stderr:`apt-cache: unknown command '${r??""}'`,exitCode:1}}}};var ou={name:"awk",description:"Pattern scanning and processing language",category:"text",params:["[-F <sep>] '<program>' [file]"],run:({authUser:n,args:t,stdin:e,cwd:r,shell:s})=>{let i=en(t,["-F"])??" ",o=t.filter(C=>!C.startsWith("-")&&C!==i),a=o[0],c=o[1];if(!a)return{stderr:"awk: no program",exitCode:1};let f=e??"";if(c){let C=le(r,c);try{Oe(n,C,"awk"),f=s.vfs.readFile(C)}catch{return{stderr:`awk: ${c}: No such file or directory`,exitCode:1}}}let l=f.split(`
45
- `);l[l.length-1]===""&&l.pop();let u=[],h=a.trim();if(!h.startsWith("{")&&!h.includes("{"))u.push({pattern:h,action:"print $0"});else{let C=/([^{]*)\{([^}]*)\}/g,F=C.exec(h);for(;F!==null;)u.push({pattern:F[1].trim(),action:F[2].trim()}),F=C.exec(h);u.length===0&&u.push({pattern:"",action:h.replace(/[{}]/g,"").trim()})}let p=[],y=u.find(C=>C.pattern==="BEGIN"),E=u.find(C=>C.pattern==="END"),x=u.filter(C=>C.pattern!=="BEGIN"&&C.pattern!=="END");function k(C){return i===" "?C.trim().split(/\s+/).filter(Boolean):C.split(i)}function D(C,F,V){let N=k(F),b=N.length,S=v=>{if(v=v.trim(),v==="NR")return String(V);if(v==="NF")return String(b);if(v==="$0")return F;if(v==="$NF")return N[b-1]??"";if(/^\$\d+$/.test(v))return N[parseInt(v.slice(1),10)-1]??"";let R=v.replace(/\bNR\b/g,String(V)).replace(/\bNF\b/g,String(b));if(/^[\d\s+\-*/()]+$/.test(R))try{return String(Function(`"use strict"; return (${R});`)())}catch{}return v.replace(/"/g,"")},I=C.split(";").map(v=>v.trim()).filter(Boolean);for(let v of I)if(v==="print"||v==="print $0")p.push(F);else if(v.startsWith("print ")){let R=v.slice(6).split(/\s*,\s*/);p.push(R.map(S).join(" "))}}function H(C,F,V){if(!C||C==="1")return!0;let N=C.match(/^NR\s*([=!<>]=?|==)\s*(\d+)$/);if(N){let I=N[1],v=parseInt(N[2],10);switch(I){case"==":return V===v;case"!=":return V!==v;case">":return V>v;case">=":return V>=v;case"<":return V<v;case"<=":return V<=v}}let b=C.match(/^NR%(\d+)==(\d+)$/);if(b)return V%parseInt(b[1],10)===parseInt(b[2],10);if(C.startsWith("/")&&C.endsWith("/"))try{return new RegExp(C.slice(1,-1)).test(F)}catch{return!1}let S=C.match(/^\$(\d+)~\/(.*)\/$/);if(S){let v=k(F)[parseInt(S[1],10)-1]??"";try{return new RegExp(S[2]).test(v)}catch{return!1}}return!1}y&&D(y.action,"",0);for(let C=1;C<=l.length;C++){let F=l[C-1];for(let V of x)H(V.pattern,F,C)&&D(V.action,F,C)}return E&&D(E.action,"",l.length+1),{stdout:p.join(`
44
+ `),exitCode:0}}default:return{stderr:`apt-cache: unknown command '${r??""}'`,exitCode:1}}}};var fu={name:"awk",description:"Pattern scanning and processing language",category:"text",params:["[-F <sep>] '<program>' [file]"],run:({authUser:n,args:t,stdin:e,cwd:r,shell:s})=>{let i=tn(t,["-F"])??" ",o=t.filter(v=>!v.startsWith("-")&&v!==i),a=o[0],c=o[1];if(!a)return{stderr:"awk: no program",exitCode:1};let f=e??"";if(c){let v=le(r,c);try{Oe(n,v,"awk"),f=s.vfs.readFile(v)}catch{return{stderr:`awk: ${c}: No such file or directory`,exitCode:1}}}let l=f.split(`
45
+ `);l[l.length-1]===""&&l.pop();let u=[],h=a.trim();if(!h.startsWith("{")&&!h.includes("{"))u.push({pattern:h,action:"print $0"});else{let v=/([^{]*)\{([^}]*)\}/g,M=v.exec(h);for(;M!==null;)u.push({pattern:M[1].trim(),action:M[2].trim()}),M=v.exec(h);u.length===0&&u.push({pattern:"",action:h.replace(/[{}]/g,"").trim()})}let p=[],y=u.find(v=>v.pattern==="BEGIN"),E=u.find(v=>v.pattern==="END"),b=u.filter(v=>v.pattern!=="BEGIN"&&v.pattern!=="END");function C(v){return i===" "?v.trim().split(/\s+/).filter(Boolean):v.split(i)}function N(v,M,Q){let P=C(M),x=P.length,w=k=>{if(k=k.trim(),k==="NR")return String(Q);if(k==="NF")return String(x);if(k==="$0")return M;if(k==="$NF")return P[x-1]??"";if(/^\$\d+$/.test(k))return P[parseInt(k.slice(1),10)-1]??"";let R=k.replace(/\bNR\b/g,String(Q)).replace(/\bNF\b/g,String(x));if(/^[\d\s+\-*/()]+$/.test(R))try{return String(Function(`"use strict"; return (${R});`)())}catch{}return k.replace(/"/g,"")},I=v.split(";").map(k=>k.trim()).filter(Boolean);for(let k of I)if(k==="print"||k==="print $0")p.push(M);else if(k.startsWith("print ")){let R=k.slice(6).split(/\s*,\s*/);p.push(R.map(w).join(" "))}}function H(v,M,Q){if(!v||v==="1")return!0;let P=v.match(/^NR\s*([=!<>]=?|==)\s*(\d+)$/);if(P){let I=P[1],k=parseInt(P[2],10);switch(I){case"==":return Q===k;case"!=":return Q!==k;case">":return Q>k;case">=":return Q>=k;case"<":return Q<k;case"<=":return Q<=k}}let x=v.match(/^NR%(\d+)==(\d+)$/);if(x)return Q%parseInt(x[1],10)===parseInt(x[2],10);if(v.startsWith("/")&&v.endsWith("/"))try{return new RegExp(v.slice(1,-1)).test(M)}catch{return!1}let w=v.match(/^\$(\d+)~\/(.*)\/$/);if(w){let k=C(M)[parseInt(w[1],10)-1]??"";try{return new RegExp(w[2]).test(k)}catch{return!1}}return!1}y&&N(y.action,"",0);for(let v=1;v<=l.length;v++){let M=l[v-1];for(let Q of b)H(Q.pattern,M,v)&&N(Q.action,M,v)}return E&&N(E.action,"",l.length+1),{stdout:p.join(`
46
46
  `)+(p.length>0?`
47
- `:""),exitCode:0}}};var au={name:"base64",description:"Encode/decode base64",category:"text",params:["[-d] [file]"],run:({args:n,stdin:t})=>{let e=se(n,["-d","--decode"]),r=t??"";if(e)try{return{stdout:Buffer.from(r.trim(),"base64").toString("utf8"),exitCode:0}}catch{return{stderr:"base64: invalid input",exitCode:1}}return{stdout:Buffer.from(r).toString("base64"),exitCode:0}}};var cu={name:"cat",description:"Concatenate and print files",category:"files",params:["[-n] [-b] <file...>"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-n","--number"]),o=se(r,["-b","--number-nonblank"]),a=r.filter(h=>!h.startsWith("-"));if(a.length===0&&s!==void 0)return{stdout:s,exitCode:0};if(a.length===0)return{stderr:"cat: missing file operand",exitCode:1};let c=[];for(let h of a){let p=nu(t.vfs,e,h);Oe(n,p,"cat"),c.push(t.vfs.readFile(p))}let f=c.join("");if(!i&&!o)return{stdout:f,exitCode:0};let l=1;return{stdout:f.split(`
47
+ `:""),exitCode:0}}};var lu={name:"base64",description:"Encode/decode base64",category:"text",params:["[-d] [file]"],run:({args:n,stdin:t})=>{let e=se(n,["-d","--decode"]),r=t??"";if(e)try{return{stdout:Buffer.from(r.trim(),"base64").toString("utf8"),exitCode:0}}catch{return{stderr:"base64: invalid input",exitCode:1}}return{stdout:Buffer.from(r).toString("base64"),exitCode:0}}};var uu={name:"cat",description:"Concatenate and print files",category:"files",params:["[-n] [-b] <file...>"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-n","--number"]),o=se(r,["-b","--number-nonblank"]),a=r.filter(h=>!h.startsWith("-"));if(a.length===0&&s!==void 0)return{stdout:s,exitCode:0};if(a.length===0)return{stderr:"cat: missing file operand",exitCode:1};let c=[];for(let h of a){let p=su(t.vfs,e,h);Oe(n,p,"cat"),c.push(t.vfs.readFile(p))}let f=c.join("");if(!i&&!o)return{stdout:f,exitCode:0};let l=1;return{stdout:f.split(`
48
48
  `).map(h=>o&&h.trim()===""?h:`${String(l++).padStart(6)} ${h}`).join(`
49
- `),exitCode:0}}};var fu={name:"cd",description:"Change directory",category:"navigation",params:["[path]"],run:({authUser:n,shell:t,cwd:e,args:r,mode:s})=>{let i=le(e,r[0]??"/virtual-env-js");return Oe(n,i,"cd"),t.vfs.stat(i).type!=="directory"?{stderr:`cd: not a directory: ${i}`,exitCode:1}:{nextCwd:i,exitCode:0}}};function Jm(n,t){let e=/^([ugoa]*)([+\-=])([rwx]*)$/,r=t.split(","),s=n;for(let i of r){let o=i.trim().match(e);if(!o)return null;let[,a="a",c,f=""]=o,l=a===""||a==="a"?["u","g","o"]:a.split(""),u={u:{r:256,w:128,x:64},g:{r:32,w:16,x:8},o:{r:4,w:2,x:1}};for(let h of l)for(let p of f.split("")){let y=u[h]?.[p];if(y!==void 0){if(c==="+")s|=y;else if(c==="-")s&=~y;else if(c==="="){let E=Object.values(u[h]??{}).reduce((x,k)=>x|k,0);s=s&~E|y}}}}return s}var lu={name:"chmod",description:"Change file permissions",category:"files",params:["<mode> <file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let[s,i]=r;if(!s||!i)return{stderr:"chmod: missing operand",exitCode:1};let o=le(e,i);try{if(Oe(n,o,"chmod"),!t.vfs.exists(o))return{stderr:`chmod: ${i}: No such file or directory`,exitCode:1};let a,c=parseInt(s,8);if(!Number.isNaN(c)&&/^[0-7]+$/.test(s))a=c;else{let f=t.vfs.stat(o).mode,l=Jm(f,s);if(l===null)return{stderr:`chmod: invalid mode: ${s}`,exitCode:1};a=l}return t.vfs.chmod(o,a),{exitCode:0}}catch(a){return{stderr:`chmod: ${a instanceof Error?a.message:String(a)}`,exitCode:1}}}};var uu={name:"clear",description:"Clear the terminal screen",category:"shell",params:[],run:()=>({clearScreen:!0,stdout:"",exitCode:0})};var du={name:"cp",description:"Copy files or directories",category:"files",params:["[-r] <source> <dest>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=se(r,["-r","-R","--recursive"]),i=r.filter(l=>!l.startsWith("-")),[o,a]=i;if(!o||!a)return{stderr:"cp: missing operand",exitCode:1};let c=le(e,o),f=le(e,a);try{if(Oe(n,c,"cp"),Oe(n,f,"cp"),!t.vfs.exists(c))return{stderr:`cp: ${o}: No such file or directory`,exitCode:1};if(t.vfs.stat(c).type==="directory"){if(!s)return{stderr:`cp: ${o}: is a directory (use -r)`,exitCode:1};let u=(p,y)=>{t.vfs.mkdir(y,493);for(let E of t.vfs.list(p)){let x=`${p}/${E}`,k=`${y}/${E}`;if(t.vfs.stat(x).type==="directory")u(x,k);else{let H=t.vfs.readFileRaw(x);t.writeFileAsUser(n,k,H)}}},h=t.vfs.exists(f)&&t.vfs.stat(f).type==="directory"?`${f}/${o.split("/").pop()}`:f;u(c,h)}else{let u=t.vfs.exists(f)&&t.vfs.stat(f).type==="directory"?`${f}/${o.split("/").pop()}`:f,h=t.vfs.readFileRaw(c);t.writeFileAsUser(n,u,h)}return{exitCode:0}}catch(l){return{stderr:`cp: ${l instanceof Error?l.message:String(l)}`,exitCode:1}}}};var hu={name:"curl",description:"Transfer data from or to a server (pure fetch)",category:"network",params:["[options] <url>"],run:async({authUser:n,cwd:t,args:e,shell:r})=>{let{flagsWithValues:s,positionals:i}=Yt(e,{flagsWithValue:["-o","--output","-X","--request","-d","--data","-H","--header","-u","--user"]});if(se(e,["--help","-h"]))return{stdout:["Usage: curl [options] <url>"," -o, --output <file> Write to file"," -X, --request <method> HTTP method"," -d, --data <data> POST data"," -H, --header <hdr> Extra header"," -s, --silent Silent mode"," -I, --head Fetch headers only"," -L, --location Follow redirects"," -v, --verbose Verbose"].join(`
50
- `),exitCode:0};let o=i[0];if(!o)return{stderr:"curl: no URL specified",exitCode:1};let a=s.get("-o")??s.get("--output")??null,c=(s.get("-X")??s.get("--request")??"GET").toUpperCase(),f=s.get("-d")??s.get("--data")??null,l=s.get("-H")??s.get("--header")??null,u=se(e,["-s","--silent"]),h=se(e,["-I","--head"]),p=se(e,["-L","--location"]),y=se(e,["-v","--verbose"]),E={"User-Agent":"curl/7.88.1"};if(l){let F=l.indexOf(":");F!==-1&&(E[l.slice(0,F).trim()]=l.slice(F+1).trim())}let x=f&&c==="GET"?"POST":c,k={method:x,headers:E,redirect:p?"follow":"manual"};f&&(E["Content-Type"]??="application/x-www-form-urlencoded",k.body=f);let D=[];y&&(D.push(`* Trying ${o}...`,"* Connected"),D.push(`> ${x} / HTTP/1.1`,`> Host: ${new URL(o).host}`));let H;try{let F=o.startsWith("http://")||o.startsWith("https://")?o:`http://${o}`;H=await fetch(F,k)}catch(F){return{stderr:`curl: (6) Could not resolve host: ${F instanceof Error?F.message:String(F)}`,exitCode:6}}if(y&&D.push(`< HTTP/1.1 ${H.status} ${H.statusText}`),h){let F=[`HTTP/1.1 ${H.status} ${H.statusText}`];for(let[V,N]of H.headers.entries())F.push(`${V}: ${N}`);return{stdout:`${F.join(`\r
49
+ `),exitCode:0}}};var du={name:"cd",description:"Change directory",category:"navigation",params:["[path]"],run:({authUser:n,shell:t,cwd:e,args:r,mode:s})=>{let i=le(e,r[0]??"/virtual-env-js");return Oe(n,i,"cd"),t.vfs.stat(i).type!=="directory"?{stderr:`cd: not a directory: ${i}`,exitCode:1}:{nextCwd:i,exitCode:0}}};function oA(n,t){let e=/^([ugoa]*)([+\-=])([rwx]*)$/,r=t.split(","),s=n;for(let i of r){let o=i.trim().match(e);if(!o)return null;let[,a="a",c,f=""]=o,l=a===""||a==="a"?["u","g","o"]:a.split(""),u={u:{r:256,w:128,x:64},g:{r:32,w:16,x:8},o:{r:4,w:2,x:1}};for(let h of l)for(let p of f.split("")){let y=u[h]?.[p];if(y!==void 0){if(c==="+")s|=y;else if(c==="-")s&=~y;else if(c==="="){let E=Object.values(u[h]??{}).reduce((b,C)=>b|C,0);s=s&~E|y}}}}return s}var hu={name:"chmod",description:"Change file permissions",category:"files",params:["<mode> <file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let[s,i]=r;if(!s||!i)return{stderr:"chmod: missing operand",exitCode:1};let o=le(e,i);try{if(Oe(n,o,"chmod"),!t.vfs.exists(o))return{stderr:`chmod: ${i}: No such file or directory`,exitCode:1};let a,c=parseInt(s,8);if(!Number.isNaN(c)&&/^[0-7]+$/.test(s))a=c;else{let f=t.vfs.stat(o).mode,l=oA(f,s);if(l===null)return{stderr:`chmod: invalid mode: ${s}`,exitCode:1};a=l}return t.vfs.chmod(o,a),{exitCode:0}}catch(a){return{stderr:`chmod: ${a instanceof Error?a.message:String(a)}`,exitCode:1}}}};var pu={name:"clear",description:"Clear the terminal screen",category:"shell",params:[],run:()=>({clearScreen:!0,stdout:"",exitCode:0})};var gu={name:"cp",description:"Copy files or directories",category:"files",params:["[-r] <source> <dest>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=se(r,["-r","-R","--recursive"]),i=r.filter(l=>!l.startsWith("-")),[o,a]=i;if(!o||!a)return{stderr:"cp: missing operand",exitCode:1};let c=le(e,o),f=le(e,a);try{if(Oe(n,c,"cp"),Oe(n,f,"cp"),!t.vfs.exists(c))return{stderr:`cp: ${o}: No such file or directory`,exitCode:1};if(t.vfs.stat(c).type==="directory"){if(!s)return{stderr:`cp: ${o}: is a directory (use -r)`,exitCode:1};let u=(p,y)=>{t.vfs.mkdir(y,493);for(let E of t.vfs.list(p)){let b=`${p}/${E}`,C=`${y}/${E}`;if(t.vfs.stat(b).type==="directory")u(b,C);else{let H=t.vfs.readFileRaw(b);t.writeFileAsUser(n,C,H)}}},h=t.vfs.exists(f)&&t.vfs.stat(f).type==="directory"?`${f}/${o.split("/").pop()}`:f;u(c,h)}else{let u=t.vfs.exists(f)&&t.vfs.stat(f).type==="directory"?`${f}/${o.split("/").pop()}`:f,h=t.vfs.readFileRaw(c);t.writeFileAsUser(n,u,h)}return{exitCode:0}}catch(l){return{stderr:`cp: ${l instanceof Error?l.message:String(l)}`,exitCode:1}}}};var mu={name:"curl",description:"Transfer data from or to a server (pure fetch)",category:"network",params:["[options] <url>"],run:async({authUser:n,cwd:t,args:e,shell:r})=>{let{flagsWithValues:s,positionals:i}=jt(e,{flagsWithValue:["-o","--output","-X","--request","-d","--data","-H","--header","-u","--user"]});if(se(e,["--help","-h"]))return{stdout:["Usage: curl [options] <url>"," -o, --output <file> Write to file"," -X, --request <method> HTTP method"," -d, --data <data> POST data"," -H, --header <hdr> Extra header"," -s, --silent Silent mode"," -I, --head Fetch headers only"," -L, --location Follow redirects"," -v, --verbose Verbose"].join(`
50
+ `),exitCode:0};let o=i[0];if(!o)return{stderr:"curl: no URL specified",exitCode:1};let a=s.get("-o")??s.get("--output")??null,c=(s.get("-X")??s.get("--request")??"GET").toUpperCase(),f=s.get("-d")??s.get("--data")??null,l=s.get("-H")??s.get("--header")??null,u=se(e,["-s","--silent"]),h=se(e,["-I","--head"]),p=se(e,["-L","--location"]),y=se(e,["-v","--verbose"]),E={"User-Agent":"curl/7.88.1"};if(l){let M=l.indexOf(":");M!==-1&&(E[l.slice(0,M).trim()]=l.slice(M+1).trim())}let b=f&&c==="GET"?"POST":c,C={method:b,headers:E,redirect:p?"follow":"manual"};f&&(E["Content-Type"]??="application/x-www-form-urlencoded",C.body=f);let N=[];y&&(N.push(`* Trying ${o}...`,"* Connected"),N.push(`> ${b} / HTTP/1.1`,`> Host: ${new URL(o).host}`));let H;try{let M=o.startsWith("http://")||o.startsWith("https://")?o:`http://${o}`;H=await fetch(M,C)}catch(M){return{stderr:`curl: (6) Could not resolve host: ${M instanceof Error?M.message:String(M)}`,exitCode:6}}if(y&&N.push(`< HTTP/1.1 ${H.status} ${H.statusText}`),h){let M=[`HTTP/1.1 ${H.status} ${H.statusText}`];for(let[Q,P]of H.headers.entries())M.push(`${Q}: ${P}`);return{stdout:`${M.join(`\r
51
51
  `)}\r
52
- `,exitCode:0}}let C;try{C=await H.text()}catch{return{stderr:"curl: failed to read response body",exitCode:1}}if(a){let F=le(t,a);return Oe(n,F,"curl"),r.writeFileAsUser(n,F,C),u||D.push(` % Total % Received
53
- 100 ${C.length} 100 ${C.length}`),{stderr:D.join(`
54
- `)||void 0,exitCode:H.ok?0:22}}return{stdout:C,stderr:D.length>0?D.join(`
55
- `):void 0,exitCode:H.ok?0:22}}};var pu={name:"cut",description:"Remove sections from lines",category:"text",params:["-d <delim> -f <fields> [file]"],run:({args:n,stdin:t})=>{let e=en(n,["-d"])??" ",s=(en(n,["-f"])??"1").split(",").map(a=>{let[c,f]=a.split("-").map(Number);return f!==void 0?{from:(c??1)-1,to:f-1}:{from:(c??1)-1,to:(c??1)-1}});return{stdout:(t??"").split(`
52
+ `,exitCode:0}}let v;try{v=await H.text()}catch{return{stderr:"curl: failed to read response body",exitCode:1}}if(a){let M=le(t,a);return Oe(n,M,"curl"),r.writeFileAsUser(n,M,v),u||N.push(` % Total % Received
53
+ 100 ${v.length} 100 ${v.length}`),{stderr:N.join(`
54
+ `)||void 0,exitCode:H.ok?0:22}}return{stdout:v,stderr:N.length>0?N.join(`
55
+ `):void 0,exitCode:H.ok?0:22}}};var Au={name:"cut",description:"Remove sections from lines",category:"text",params:["-d <delim> -f <fields> [file]"],run:({args:n,stdin:t})=>{let e=tn(n,["-d"])??" ",s=(tn(n,["-f"])??"1").split(",").map(a=>{let[c,f]=a.split("-").map(Number);return f!==void 0?{from:(c??1)-1,to:f-1}:{from:(c??1)-1,to:(c??1)-1}});return{stdout:(t??"").split(`
56
56
  `).map(a=>{let c=a.split(e),f=[];for(let l of s)for(let u=l.from;u<=Math.min(l.to,c.length-1);u++)f.push(c[u]??"");return f.join(e)}).join(`
57
- `),exitCode:0}}};var gu={name:"date",description:"Print current date and time",category:"system",params:["[+format]"],run:({args:n})=>{let t=new Date,e=n[0];return e?.startsWith("+")?{stdout:e.slice(1).replace("%Y",String(t.getFullYear())).replace("%m",String(t.getMonth()+1).padStart(2,"0")).replace("%d",String(t.getDate()).padStart(2,"0")).replace("%H",String(t.getHours()).padStart(2,"0")).replace("%M",String(t.getMinutes()).padStart(2,"0")).replace("%S",String(t.getSeconds()).padStart(2,"0")).replace("%s",String(Math.floor(t.getTime()/1e3))),exitCode:0}:{stdout:t.toString(),exitCode:0}}};var mu={name:"declare",aliases:["local","typeset"],description:"Declare variables and give them attributes",category:"shell",params:["[-i] [-r] [-x] [-a] [name[=value]...]"],run:({args:n,env:t})=>{if(!t)return{exitCode:0};let e=se(n,["-i"]),r=se(n,["-r"]),s=se(n,["-x"]);if(n.filter(a=>!a.startsWith("-")).length===0)return{stdout:Object.entries(t.vars).map(([c,f])=>`declare -- ${c}="${f}"`).join(`
58
- `),exitCode:0};let o=n.filter(a=>!a.startsWith("-"));for(let a of o){let c=a.indexOf("=");if(c===-1)a in t.vars||(t.vars[a]="");else{let f=a.slice(0,c),l=a.slice(c+1);if(e){let u=parseInt(l,10);l=Number.isNaN(u)?"0":String(u)}t.vars[f]=l}}return{exitCode:0}}};var Au={name:"deluser",description:"Delete a user",category:"users",params:["[-f] <username>"],run:async({authUser:n,args:t,shell:e})=>{if(n!=="root")return{stderr:`deluser: permission denied
57
+ `),exitCode:0}}};var Eu={name:"date",description:"Print current date and time",category:"system",params:["[+format]"],run:({args:n})=>{let t=new Date,e=n[0];return e?.startsWith("+")?{stdout:e.slice(1).replace("%Y",String(t.getFullYear())).replace("%m",String(t.getMonth()+1).padStart(2,"0")).replace("%d",String(t.getDate()).padStart(2,"0")).replace("%H",String(t.getHours()).padStart(2,"0")).replace("%M",String(t.getMinutes()).padStart(2,"0")).replace("%S",String(t.getSeconds()).padStart(2,"0")).replace("%s",String(Math.floor(t.getTime()/1e3))),exitCode:0}:{stdout:t.toString(),exitCode:0}}};var yu={name:"declare",aliases:["local","typeset"],description:"Declare variables and give them attributes",category:"shell",params:["[-i] [-r] [-x] [-a] [name[=value]...]"],run:({args:n,env:t})=>{if(!t)return{exitCode:0};let e=se(n,["-i"]),r=se(n,["-r"]),s=se(n,["-x"]);if(n.filter(a=>!a.startsWith("-")).length===0)return{stdout:Object.entries(t.vars).map(([c,f])=>`declare -- ${c}="${f}"`).join(`
58
+ `),exitCode:0};let o=n.filter(a=>!a.startsWith("-"));for(let a of o){let c=a.indexOf("=");if(c===-1)a in t.vars||(t.vars[a]="");else{let f=a.slice(0,c),l=a.slice(c+1);if(e){let u=parseInt(l,10);l=Number.isNaN(u)?"0":String(u)}t.vars[f]=l}}return{exitCode:0}}};var _u={name:"deluser",description:"Delete a user",category:"users",params:["[-f] <username>"],run:async({authUser:n,args:t,shell:e})=>{if(n!=="root")return{stderr:`deluser: permission denied
59
59
  `,exitCode:1};let r=t.includes("-f")||t.includes("--force")||t.includes("-y"),s=t.find(o=>!o.startsWith("-"));if(!s)return{stderr:`Usage: deluser [-f] <username>
60
60
  `,exitCode:1};if(!e.users.listUsers().includes(s))return{stderr:`deluser: user '${s}' does not exist
61
61
  `,exitCode:1};if(s==="root")return{stderr:`deluser: cannot remove the root account
@@ -65,164 +65,171 @@ deluser: done.
65
65
  `,exitCode:1}}:(await a.users.deleteUser(s),{result:{stdout:`Removing user '${s}' ...
66
66
  deluser: done.
67
67
  `,exitCode:0}});return{sudoChallenge:{username:s,targetUser:s,commandLine:null,loginShell:!1,prompt:`Warning: deleting user '${s}'.
68
- Type the username to confirm: `,mode:"confirm",onPassword:i},exitCode:0}}};var Eu={name:"df",description:"Report filesystem disk space usage",category:"system",params:["[-h]"],run:({shell:n})=>{let e=(n.vfs.getUsageBytes()/1024).toFixed(0),r="1048576",s=String(Number(r)-Number(e)),i=Math.round(Number(e)/Number(r)*100),o="Filesystem 1K-blocks Used Available Use% Mounted on",a=`virtual-fs ${r.padStart(9)} ${e.padStart(7)} ${s.padStart(9)} ${i}% /`;return{stdout:`${o}
69
- ${a}`,exitCode:0}}};var _u={name:"diff",description:"Compare files line by line",category:"text",params:["<file1> <file2>"],run:({shell:n,cwd:t,args:e})=>{let[r,s]=e;if(!r||!s)return{stderr:"diff: missing operand",exitCode:1};let i=le(t,r),o=le(t,s),a,c;try{a=n.vfs.readFile(i).split(`
68
+ Type the username to confirm: `,mode:"confirm",onPassword:i},exitCode:0}}};var bu={name:"df",description:"Report filesystem disk space usage",category:"system",params:["[-h]"],run:({shell:n})=>{let e=(n.vfs.getUsageBytes()/1024).toFixed(0),r="1048576",s=String(Number(r)-Number(e)),i=Math.round(Number(e)/Number(r)*100),o="Filesystem 1K-blocks Used Available Use% Mounted on",a=`virtual-fs ${r.padStart(9)} ${e.padStart(7)} ${s.padStart(9)} ${i}% /`;return{stdout:`${o}
69
+ ${a}`,exitCode:0}}};var xu={name:"diff",description:"Compare files line by line",category:"text",params:["<file1> <file2>"],run:({shell:n,cwd:t,args:e})=>{let[r,s]=e;if(!r||!s)return{stderr:"diff: missing operand",exitCode:1};let i=le(t,r),o=le(t,s),a,c;try{a=n.vfs.readFile(i).split(`
70
70
  `)}catch{return{stderr:`diff: ${r}: No such file or directory`,exitCode:2}}try{c=n.vfs.readFile(o).split(`
71
71
  `)}catch{return{stderr:`diff: ${s}: No such file or directory`,exitCode:2}}let f=[],l=Math.max(a.length,c.length);for(let u=0;u<l;u++){let h=a[u],p=c[u];h!==p&&(h!==void 0&&f.push(`< ${h}`),p!==void 0&&f.push(`> ${p}`))}return{stdout:f.join(`
72
- `),exitCode:f.length>0?1:0}}};var yu={name:"dpkg",description:"Debian package manager low-level tool",category:"package",params:["[-l] [-s pkg] [-L pkg] [-i pkg] [--remove pkg]"],run:({args:n,authUser:t,shell:e})=>{let r=Qr(e);if(!r)return{stderr:"dpkg: package manager not initialised",exitCode:1};let s=se(n,["-l","--list"]),i=se(n,["-s","--status"]),o=se(n,["-L","--listfiles"]),a=se(n,["-r","--remove"]),c=se(n,["-P","--purge"]),{positionals:f}=Yt(n,{flags:["-l","--list","-s","--status","-L","--listfiles","-r","--remove","-P","--purge"]});if(s){let l=r.listInstalled();if(l.length===0)return{stdout:["Desired=Unknown/Install/Remove/Purge/Hold","|Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend","|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)","||/ Name Version Architecture Description","+++-==============-===============-============-========================================","(no packages installed)"].join(`
73
- `),exitCode:0};let u=["Desired=Unknown/Install/Remove/Purge/Hold","|Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend","|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)","||/ Name Version Architecture Description","+++-==============-===============-============-========================================"],h=l.map(p=>{let y=p.name.padEnd(14).slice(0,14),E=p.version.padEnd(15).slice(0,15),x=p.architecture.padEnd(12).slice(0,12),k=(p.description||"").slice(0,40);return`ii ${y} ${E} ${x} ${k}`});return{stdout:[...u,...h].join(`
72
+ `),exitCode:f.length>0?1:0}}};var Su={name:"dpkg",description:"Debian package manager low-level tool",category:"package",params:["[-l] [-s pkg] [-L pkg] [-i pkg] [--remove pkg]"],run:({args:n,authUser:t,shell:e})=>{let r=Qr(e);if(!r)return{stderr:"dpkg: package manager not initialised",exitCode:1};let s=se(n,["-l","--list"]),i=se(n,["-s","--status"]),o=se(n,["-L","--listfiles"]),a=se(n,["-r","--remove"]),c=se(n,["-P","--purge"]),{positionals:f}=jt(n,{flags:["-l","--list","-s","--status","-L","--listfiles","-r","--remove","-P","--purge"]});if(s){let l=r.listInstalled();if(l.length===0)return{stdout:["Desired=Unknown/Install/Remove/Purge/Hold","|Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend","|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)","||/ Name Version Architecture Description","+++-==============-===============-============-========================================","(no packages installed)"].join(`
73
+ `),exitCode:0};let u=["Desired=Unknown/Install/Remove/Purge/Hold","|Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend","|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)","||/ Name Version Architecture Description","+++-==============-===============-============-========================================"],h=l.map(p=>{let y=p.name.padEnd(14).slice(0,14),E=p.version.padEnd(15).slice(0,15),b=p.architecture.padEnd(12).slice(0,12),C=(p.description||"").slice(0,40);return`ii ${y} ${E} ${b} ${C}`});return{stdout:[...u,...h].join(`
74
74
  `),exitCode:0}}if(i){let l=f[0];if(!l)return{stderr:"dpkg: -s needs a package name",exitCode:1};let u=r.show(l);return u?{stdout:u,exitCode:0}:{stderr:`dpkg-query: package '${l}' is not installed and no information is available`,exitCode:1}}if(o){let l=f[0];if(!l)return{stderr:"dpkg: -L needs a package name",exitCode:1};let u=r.listInstalled().find(h=>h.name===l);return u?u.files.length===0?{stdout:"/.keep",exitCode:0}:{stdout:u.files.join(`
75
75
  `),exitCode:0}:{stderr:`dpkg-query: package '${l}' is not installed`,exitCode:1}}if(a||c){if(t!=="root")return{stderr:"dpkg: error: requested operation requires superuser privilege",exitCode:2};if(f.length===0)return{stderr:"dpkg: error: need an action option",exitCode:2};let{output:l,exitCode:u}=r.remove(f,{purge:c});return{stdout:l||void 0,exitCode:u}}return{stdout:["Usage: dpkg [<option>...] <command>","","Commands:"," -l, --list List packages matching given pattern"," -s, --status <pkg>... Report status of specified package"," -L, --listfiles <pkg>... List files owned by package"," -r, --remove <pkg>... Remove <pkg> but leave its configuration"," -P, --purge <pkg>... Remove <pkg> and its configuration"].join(`
76
- `),exitCode:0}}},bu={name:"dpkg-query",description:"Show information about installed packages",category:"package",params:["-W [pkg] | -l [pattern]"],run:({args:n,shell:t})=>{let e=Qr(t);if(!e)return{stderr:"dpkg-query: package manager not initialised",exitCode:1};let r=se(n,["-l"]),s=se(n,["-W","--show"]),{positionals:i}=Yt(n,{flags:["-l","-W","--show"]});if(r||s){let o=e.listInstalled(),a=i[0],c=a?o.filter(l=>l.name.includes(a)):o;return s?{stdout:c.map(l=>`${l.name} ${l.version}`).join(`
76
+ `),exitCode:0}}},wu={name:"dpkg-query",description:"Show information about installed packages",category:"package",params:["-W [pkg] | -l [pattern]"],run:({args:n,shell:t})=>{let e=Qr(t);if(!e)return{stderr:"dpkg-query: package manager not initialised",exitCode:1};let r=se(n,["-l"]),s=se(n,["-W","--show"]),{positionals:i}=jt(n,{flags:["-l","-W","--show"]});if(r||s){let o=e.listInstalled(),a=i[0],c=a?o.filter(l=>l.name.includes(a)):o;return s?{stdout:c.map(l=>`${l.name} ${l.version}`).join(`
77
77
  `),exitCode:0}:{stdout:c.map(l=>{let u=l.name.padEnd(14).slice(0,14),h=l.version.padEnd(15).slice(0,15);return`ii ${u} ${h} amd64 ${(l.description||"").slice(0,40)}`}).join(`
78
- `)||"(no packages match)",exitCode:0}}return{stderr:"dpkg-query: need a flag (-l, -W)",exitCode:1}}};var xu={name:"du",description:"Estimate file space usage",category:"system",params:["[-h] [-s] [path]"],run:({shell:n,cwd:t,args:e})=>{let r=se(e,["-h"]),s=se(e,["-s"]),i=e.find(l=>!l.startsWith("-"))??".",o=le(t,i),a=l=>r?`${(l/1024).toFixed(1)}K`:String(Math.ceil(l/1024));if(!n.vfs.exists(o))return{stderr:`du: ${i}: No such file or directory`,exitCode:1};if(s||n.vfs.stat(o).type==="file")return{stdout:`${a(n.vfs.getUsageBytes(o))} ${i}`,exitCode:0};let c=[],f=(l,u)=>{let h=0;for(let p of n.vfs.list(l)){let y=`${l}/${p}`,E=`${u}/${p}`,x=n.vfs.stat(y);x.type==="directory"?h+=f(y,E):(h+=x.size,s||c.push(`${a(x.size)} ${E}`))}return c.push(`${a(h)} ${u}`),h};return f(o,i),{stdout:c.join(`
79
- `),exitCode:0}}};function Zm(n,t){let e=n.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\b/g,(r,s)=>{let i=t[s];return i!==void 0&&i!==""?i:"0"});if(!/^[\d\s+\-*/%()^!&|<>=,. ]+$/.test(e))return NaN;try{let r=Function(`"use strict"; return (${e.replace(/\*\*/g,"**")});`)();return typeof r=="number"?Math.trunc(r):NaN}catch{return NaN}}function eA(n,t){let e=[],r=0;for(;r<n.length;){let s=n.indexOf("'",r);if(s===-1){e.push(t(n.slice(r)));break}e.push(t(n.slice(r,s)));let i=n.indexOf("'",s+1);if(i===-1){e.push(n.slice(s));break}e.push(n.slice(s,i+1)),r=i+1}return e.join("")}function Ya(n,t,e=0,r){let s=r??t.HOME??"/home/user";return eA(n,i=>{let o=i;return o=o.replace(/(^|[\s:])~(\/|$)/g,(a,c,f)=>`${c}${s}${f}`),o=o.replace(/\$\?/g,String(e)),o=o.replace(/\$\$/g,"1"),o=o.replace(/\$#/g,"0"),o=o.replace(/\$\(\(([^)]+(?:\([^)]*\)[^)]*)*)\)\)/g,(a,c)=>{let f=Zm(c,t);return Number.isNaN(f)?"0":String(f)}),o=o.replace(/\$\{#([A-Za-z_][A-Za-z0-9_]*)\}/g,(a,c)=>String((t[c]??"").length)),o=o.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*):-([^}]*)\}/g,(a,c,f)=>t[c]!==void 0&&t[c]!==""?t[c]:f),o=o.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*):=([^}]*)\}/g,(a,c,f)=>((t[c]===void 0||t[c]==="")&&(t[c]=f),t[c])),o=o.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*):\+([^}]*)\}/g,(a,c,f)=>t[c]!==void 0&&t[c]!==""?f:""),o=o.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(a,c)=>t[c]??""),o=o.replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g,(a,c)=>t[c]??""),o})}async function Ds(n,t,e,r){if(n.includes("$(")){let s="",i=!1,o=0;for(;o<n.length;){let a=n[o];if(a==="'"&&!i){i=!0,s+=a,o++;continue}if(a==="'"&&i){i=!1,s+=a,o++;continue}if(!i&&a==="$"&&n[o+1]==="("){if(n[o+2]==="("){s+=a,o++;continue}let c=0,f=o+1;for(;f<n.length;){if(n[f]==="(")c++;else if(n[f]===")"&&(c--,c===0))break;f++}let l=n.slice(o+2,f).trim(),u=(await r(l)).replace(/\n$/,"");s+=u,o=f+1;continue}s+=a,o++}n=s}return Ya(n,t,e)}function tA(n){return n.replace(/\\n/g,`
80
- `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\").replace(/\\a/g,"\x07").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\v/g,"\v").replace(/\\0(\d{1,3})/g,(t,e)=>String.fromCharCode(parseInt(e,8)))}var Su={name:"echo",description:"Display text",category:"shell",params:["[-n] [-e] [text...]"],run:({args:n,stdin:t,env:e})=>{let{flags:r,positionals:s}=Yt(n,{flags:["-n","-e","-E"]}),i=r.has("-n"),o=r.has("-e"),a=s.length>0?s.join(" "):t??"",c=Ya(a,e?.vars??{},e?.lastExitCode??0),f=o?tA(c):c;return{stdout:i?f:`${f}
81
- `,exitCode:0}}};var wu={name:"env",description:"Print environment variables",category:"shell",params:[],run:({env:n,authUser:t})=>{let e={...n.vars,USER:t,HOME:`/home/${t}`};return{stdout:Object.entries(e).map(([r,s])=>`${r}=${s}`).join(`
82
- `),exitCode:0}}};var Iu={name:"exit",aliases:["bye"],description:"Exit the shell session",category:"shell",params:["[code]"],run:({args:n})=>({closeSession:!0,exitCode:parseInt(n[0]??"0",10)||0})};var Cu={name:"export",description:"Set shell environment variable",category:"shell",params:["[VAR=value]"],run:({args:n,env:t})=>{if(n.length===0)return{stdout:Object.entries(t.vars).map(([r,s])=>`declare -x ${r}="${s}"`).join(`
83
- `),exitCode:0};for(let e of n)if(e.includes("=")){let r=e.indexOf("="),s=e.slice(0,r),i=e.slice(r+1);t.vars[s]=i}return{exitCode:0}}};var ku={name:"find",description:"Search for files",category:"files",params:["[path] [-name <pattern>] [-type f|d]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=en(r,["-name"]),i=en(r,["-type"]),a=r.filter(h=>!h.startsWith("-")&&h!==s&&h!==i)[0]??".",c=le(e,a);try{if(Oe(n,c,"find"),!t.vfs.exists(c))return{stderr:`find: ${a}: No such file or directory`,exitCode:1}}catch(h){return{stderr:`find: ${h instanceof Error?h.message:String(h)}`,exitCode:1}}let f=s?new RegExp(`^${s.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/\?/g,".")}$`):null,l=[],u=(h,p)=>{let y=t.vfs.stat(h),E=!i||i==="f"&&y.type==="file"||i==="d"&&y.type==="directory",x=!f||f.test(h.split("/").pop()??"");if(E&&x&&l.push(p),y.type==="directory")for(let k of t.vfs.list(h)){let D=`${h}/${k}`,H=`${p}/${k}`;u(D,H)}};return u(c,a),{stdout:l.join(`
84
- `),exitCode:0}}};var $s=Vt(require("node:os"),1);var vu={name:"free",description:"Display amount of free and used memory",category:"system",params:["[-h] [-m] [-g]"],run:({args:n})=>{let t=se(n,["-h","--human"]),e=se(n,["-m"]),r=se(n,["-g"]),s=$s.totalmem(),i=$s.freemem(),o=s-i,a=Math.floor(s*.02),c=Math.floor(s*.05),f=Math.floor(i*.95),l=Math.floor(s*.5),u=E=>t?E>=1024*1024*1024?`${(E/(1024*1024*1024)).toFixed(1)}G`:E>=1024*1024?`${(E/(1024*1024)).toFixed(1)}M`:`${(E/1024).toFixed(1)}K`:String(Math.floor(r?E/(1024*1024*1024):e?E/(1024*1024):E/1024)),h=" total used free shared buff/cache available",p=`Mem: ${u(s).padStart(12)} ${u(o).padStart(11)} ${u(i).padStart(11)} ${u(a).padStart(11)} ${u(c).padStart(11)} ${u(f).padStart(11)}`,y=`Swap: ${u(l).padStart(12)} ${u(0).padStart(11)} ${u(l).padStart(11)}`;return{stdout:[h,p,y].join(`
85
- `),exitCode:0}}};var Bu={name:"grep",description:"Search text patterns",category:"text",params:["[-i] [-v] [-n] [-r] <pattern> [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let{flags:i,positionals:o}=Yt(r,{flags:["-i","-v","-n","-r","-c","-l","-L","-q","--quiet","--silent"]}),a=i.has("-i"),c=i.has("-v"),f=i.has("-n"),l=i.has("-r"),u=i.has("-c"),h=i.has("-l"),p=i.has("-q")||i.has("--quiet")||i.has("--silent"),y=o[0],E=o.slice(1);if(!y)return{stderr:"grep: no pattern specified",exitCode:1};let x;try{let C=a?"mi":"m";x=new RegExp(y,C)}catch{return{stderr:`grep: invalid regex: ${y}`,exitCode:1}}let k=(C,F="")=>{let V=C.split(`
86
- `),N=[];for(let b=0;b<V.length;b++){let S=V[b]??"",I=x.test(S);if(c?!I:I){let R=f?`${b+1}:`:"";N.push(`${F}${R}${S}`)}}return N},D=C=>{if(!t.vfs.exists(C))return[];if(t.vfs.stat(C).type==="file")return[C];if(!l)return[];let V=[],N=b=>{for(let S of t.vfs.list(b)){let I=`${b}/${S}`;t.vfs.stat(I).type==="file"?V.push(I):N(I)}};return N(C),V},H=[];if(E.length===0){if(!s)return{stdout:"",exitCode:1};let C=k(s);if(u)return{stdout:`${C.length}
87
- `,exitCode:C.length>0?0:1};if(p)return{exitCode:C.length>0?0:1};H.push(...C)}else{let C=E.flatMap(F=>{let V=le(e,F);return D(V).map(N=>({file:F,path:N}))});for(let{file:F,path:V}of C)try{Oe(n,V,"grep");let N=t.vfs.readFile(V),b=C.length>1?`${F}:`:"",S=k(N,b);u?H.push(C.length>1?`${F}:${S.length}`:String(S.length)):h?S.length>0&&H.push(F):H.push(...S)}catch{return{stderr:`grep: ${F}: No such file or directory`,exitCode:1}}}return{stdout:H.length>0?`${H.join(`
78
+ `)||"(no packages match)",exitCode:0}}return{stderr:"dpkg-query: need a flag (-l, -W)",exitCode:1}}};var Iu={name:"du",description:"Estimate file space usage",category:"system",params:["[-h] [-s] [path]"],run:({shell:n,cwd:t,args:e})=>{let r=se(e,["-h"]),s=se(e,["-s"]),i=e.find(l=>!l.startsWith("-"))??".",o=le(t,i),a=l=>r?`${(l/1024).toFixed(1)}K`:String(Math.ceil(l/1024));if(!n.vfs.exists(o))return{stderr:`du: ${i}: No such file or directory`,exitCode:1};if(s||n.vfs.stat(o).type==="file")return{stdout:`${a(n.vfs.getUsageBytes(o))} ${i}`,exitCode:0};let c=[],f=(l,u)=>{let h=0;for(let p of n.vfs.list(l)){let y=`${l}/${p}`,E=`${u}/${p}`,b=n.vfs.stat(y);b.type==="directory"?h+=f(y,E):(h+=b.size,s||c.push(`${a(b.size)} ${E}`))}return c.push(`${a(h)} ${u}`),h};return f(o,i),{stdout:c.join(`
79
+ `),exitCode:0}}};Wr();function cA(n){return n.replace(/\\n/g,`
80
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\").replace(/\\a/g,"\x07").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\v/g,"\v").replace(/\\0(\d{1,3})/g,(t,e)=>String.fromCharCode(parseInt(e,8)))}var vu={name:"echo",description:"Display text",category:"shell",params:["[-n] [-e] [text...]"],run:({args:n,stdin:t,env:e})=>{let{flags:r,positionals:s}=jt(n,{flags:["-n","-e","-E"]}),i=r.has("-n"),o=r.has("-e"),a=s.length>0?s.join(" "):t??"",c=Ms(a,e?.vars??{},e?.lastExitCode??0),f=o?cA(c):c;return{stdout:i?f:`${f}
81
+ `,exitCode:0}}};var ku={name:"env",description:"Print environment variables",category:"shell",params:[],run:({env:n,authUser:t})=>{let e={...n.vars,USER:t,HOME:`/home/${t}`};return{stdout:Object.entries(e).map(([r,s])=>`${r}=${s}`).join(`
82
+ `),exitCode:0}}};var Bu={name:"exit",aliases:["bye"],description:"Exit the shell session",category:"shell",params:["[code]"],run:({args:n})=>({closeSession:!0,exitCode:parseInt(n[0]??"0",10)||0})};var Ru={name:"export",description:"Set shell environment variable",category:"shell",params:["[VAR=value]"],run:({args:n,env:t})=>{if(n.length===0||n.length===1&&n[0]==="-p"){let e=Object.entries(t.vars).filter(([r])=>r&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(r)).map(([r,s])=>`declare -x ${r}="${s}"`).join(`
83
+ `);return{stdout:e?`${e}
84
+ `:"",exitCode:0}}for(let e of n.filter(r=>r!=="-p"))if(e.includes("=")){let r=e.indexOf("="),s=e.slice(0,r),i=e.slice(r+1);t.vars[s]=i}return{exitCode:0}}};var Nu={name:"find",description:"Search for files",category:"files",params:["[path] [-name <pattern>] [-type f|d]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=tn(r,["-name"]),i=tn(r,["-type"]),a=r.filter(h=>!h.startsWith("-")&&h!==s&&h!==i)[0]??".",c=le(e,a);try{if(Oe(n,c,"find"),!t.vfs.exists(c))return{stderr:`find: ${a}: No such file or directory`,exitCode:1}}catch(h){return{stderr:`find: ${h instanceof Error?h.message:String(h)}`,exitCode:1}}let f=s?new RegExp(`^${s.replace(/\./g,"\\.").replace(/\*/g,".*").replace(/\?/g,".")}$`):null,l=[],u=(h,p)=>{let y=t.vfs.stat(h),E=!i||i==="f"&&y.type==="file"||i==="d"&&y.type==="directory",b=!f||f.test(h.split("/").pop()??"");if(E&&b&&l.push(p),y.type==="directory")for(let C of t.vfs.list(h)){let N=`${h}/${C}`,H=`${p}/${C}`;u(N,H)}};return u(c,a),{stdout:l.join(`
85
+ `),exitCode:0}}};var Fs=Gt(require("node:os"),1);var Pu={name:"free",description:"Display amount of free and used memory",category:"system",params:["[-h] [-m] [-g]"],run:({args:n})=>{let t=se(n,["-h","--human"]),e=se(n,["-m"]),r=se(n,["-g"]),s=Fs.totalmem(),i=Fs.freemem(),o=s-i,a=Math.floor(s*.02),c=Math.floor(s*.05),f=Math.floor(i*.95),l=Math.floor(s*.5),u=E=>t?E>=1024*1024*1024?`${(E/(1024*1024*1024)).toFixed(1)}G`:E>=1024*1024?`${(E/(1024*1024)).toFixed(1)}M`:`${(E/1024).toFixed(1)}K`:String(Math.floor(r?E/(1024*1024*1024):e?E/(1024*1024):E/1024)),h=" total used free shared buff/cache available",p=`Mem: ${u(s).padStart(12)} ${u(o).padStart(11)} ${u(i).padStart(11)} ${u(a).padStart(11)} ${u(c).padStart(11)} ${u(f).padStart(11)}`,y=`Swap: ${u(l).padStart(12)} ${u(0).padStart(11)} ${u(l).padStart(11)}`;return{stdout:[h,p,y].join(`
86
+ `),exitCode:0}}};var Tu={name:"grep",description:"Search text patterns",category:"text",params:["[-i] [-v] [-n] [-r] <pattern> [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let{flags:i,positionals:o}=jt(r,{flags:["-i","-v","-n","-r","-c","-l","-L","-q","--quiet","--silent"]}),a=i.has("-i"),c=i.has("-v"),f=i.has("-n"),l=i.has("-r"),u=i.has("-c"),h=i.has("-l"),p=i.has("-q")||i.has("--quiet")||i.has("--silent"),y=o[0],E=o.slice(1);if(!y)return{stderr:"grep: no pattern specified",exitCode:1};let b;try{let v=a?"mi":"m";b=new RegExp(y,v)}catch{return{stderr:`grep: invalid regex: ${y}`,exitCode:1}}let C=(v,M="")=>{let Q=v.split(`
87
+ `),P=[];for(let x=0;x<Q.length;x++){let w=Q[x]??"",I=b.test(w);if(c?!I:I){let R=f?`${x+1}:`:"";P.push(`${M}${R}${w}`)}}return P},N=v=>{if(!t.vfs.exists(v))return[];if(t.vfs.stat(v).type==="file")return[v];if(!l)return[];let Q=[],P=x=>{for(let w of t.vfs.list(x)){let I=`${x}/${w}`;t.vfs.stat(I).type==="file"?Q.push(I):P(I)}};return P(v),Q},H=[];if(E.length===0){if(!s)return{stdout:"",exitCode:1};let v=C(s);if(u)return{stdout:`${v.length}
88
+ `,exitCode:v.length>0?0:1};if(p)return{exitCode:v.length>0?0:1};H.push(...v)}else{let v=E.flatMap(M=>{let Q=le(e,M);return N(Q).map(P=>({file:M,path:P}))});for(let{file:M,path:Q}of v)try{Oe(n,Q,"grep");let P=t.vfs.readFile(Q),x=v.length>1?`${M}:`:"",w=C(P,x);u?H.push(v.length>1?`${M}:${w.length}`:String(w.length)):h?w.length>0&&H.push(M):H.push(...w)}catch{return{stderr:`grep: ${M}: No such file or directory`,exitCode:1}}}return{stdout:H.length>0?`${H.join(`
88
89
  `)}
89
- `:"",exitCode:H.length>0?0:1}}};var Ru={name:"groups",description:"Print group memberships",category:"system",params:["[user]"],run:({authUser:n,shell:t,args:e})=>{let r=e[0]??n;return{stdout:t.users.isSudoer(r)?`${r} sudo root`:r,exitCode:0}}};var Nu={name:"gzip",description:"Compress files",category:"archive",params:["[-k] [-d] <file>"],run:({shell:n,cwd:t,args:e})=>{if(!n.packageManager.isInstalled("gzip"))return{stderr:`bash: gzip: command not found
90
+ `:"",exitCode:H.length>0?0:1}}};var Lu={name:"groups",description:"Print group memberships",category:"system",params:["[user]"],run:({authUser:n,shell:t,args:e})=>{let r=e[0]??n;return{stdout:t.users.isSudoer(r)?`${r} sudo root`:r,exitCode:0}}};var Uu={name:"gzip",description:"Compress files",category:"archive",params:["[-k] [-d] <file>"],run:({shell:n,cwd:t,args:e})=>{if(!n.packageManager.isInstalled("gzip"))return{stderr:`bash: gzip: command not found
90
91
  Hint: install it with: apt install gzip
91
92
  `,exitCode:127};let r=e.includes("-k")||e.includes("--keep"),s=e.includes("-d"),i=e.find(f=>!f.startsWith("-"));if(!i)return{stderr:`gzip: no file specified
92
93
  `,exitCode:1};let o=le(t,i);if(s){if(!i.endsWith(".gz"))return{stderr:`gzip: ${i}: unknown suffix -- ignored
93
94
  `,exitCode:1};if(!n.vfs.exists(o))return{stderr:`gzip: ${i}: No such file or directory
94
95
  `,exitCode:1};let f=n.vfs.readFile(o),l=o.slice(0,-3);return n.vfs.writeFile(l,f),r||n.vfs.remove(o),{exitCode:0}}if(!n.vfs.exists(o))return{stderr:`gzip: ${i}: No such file or directory
95
96
  `,exitCode:1};if(i.endsWith(".gz"))return{stderr:`gzip: ${i}: already has .gz suffix -- unchanged
96
- `,exitCode:1};let a=n.vfs.readFileRaw(o),c=`${o}.gz`;return n.vfs.writeFile(c,a,{compress:!0}),r||n.vfs.remove(o),{exitCode:0}}},Pu={name:"gunzip",description:"Decompress files",category:"archive",aliases:["zcat"],params:["[-k] <file>"],run:({shell:n,cwd:t,args:e})=>{let r=e.includes("-k")||e.includes("--keep"),s=e.find(c=>!c.startsWith("-"));if(!s)return{stderr:`gunzip: no file specified
97
+ `,exitCode:1};let a=n.vfs.readFileRaw(o),c=`${o}.gz`;return n.vfs.writeFile(c,a,{compress:!0}),r||n.vfs.remove(o),{exitCode:0}}},Du={name:"gunzip",description:"Decompress files",category:"archive",aliases:["zcat"],params:["[-k] <file>"],run:({shell:n,cwd:t,args:e})=>{let r=e.includes("-k")||e.includes("--keep"),s=e.find(c=>!c.startsWith("-"));if(!s)return{stderr:`gunzip: no file specified
97
98
  `,exitCode:1};let i=le(t,s);if(!n.vfs.exists(i))return{stderr:`gunzip: ${s}: No such file or directory
98
99
  `,exitCode:1};if(!s.endsWith(".gz"))return{stderr:`gunzip: ${s}: unknown suffix -- ignored
99
- `,exitCode:1};let o=n.vfs.readFile(i),a=i.slice(0,-3);return n.vfs.writeFile(a,o),r||n.vfs.remove(i),{exitCode:0}}};var Tu={name:"head",description:"Output first lines",category:"text",params:["[-n <lines>] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=en(r,["-n"]),o=r.find(u=>/^-\d+$/.test(u)),a=typeof i=="string"?parseInt(i,10):o?parseInt(o.slice(1),10):10,c=r.filter(u=>!u.startsWith("-")&&u!==i&&u!==String(a)),f=u=>{let h=u.split(`
100
+ `,exitCode:1};let o=n.vfs.readFile(i),a=i.slice(0,-3);return n.vfs.writeFile(a,o),r||n.vfs.remove(i),{exitCode:0}}};var $u={name:"head",description:"Output first lines",category:"text",params:["[-n <lines>] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=tn(r,["-n"]),o=r.find(u=>/^-\d+$/.test(u)),a=typeof i=="string"?parseInt(i,10):o?parseInt(o.slice(1),10):10,c=r.filter(u=>!u.startsWith("-")&&u!==i&&u!==String(a)),f=u=>{let h=u.split(`
100
101
  `),p=h.slice(0,a);return p.join(`
101
102
  `)+(u.endsWith(`
102
103
  `)&&p.length===h.slice(0,a).length?`
103
104
  `:"")};if(c.length===0)return{stdout:f(s??""),exitCode:0};let l=[];for(let u of c){let h=le(e,u);try{Oe(n,h,"head"),l.push(f(t.vfs.readFile(h)))}catch{return{stderr:`head: ${u}: No such file or directory`,exitCode:1}}}return{stdout:l.join(`
104
- `),exitCode:0}}};var Lu=["navigation","files","text","archive","system","package","network","shell","users","misc"],Du={navigation:"Navigation",files:"Files & Filesystem",text:"Text Processing",archive:"Archive & Compression",system:"System",package:"Package Management",network:"Network",shell:"Shell & Scripting",users:"Users & Permissions",misc:"Miscellaneous"},$u="\x1B[1m",Sn="\x1B[0m",nA="\x1B[36m",rA="\x1B[33m",Ri="\x1B[2m",iA="\x1B[32m";function Uu(n,t){return n.length>=t?n:n+" ".repeat(t-n.length)}function sA(n){let t=n.aliases?.length?` ${Ri}(${n.aliases.join(", ")})${Sn}`:"";return` ${nA}${Uu(n.name,16)}${Sn}${t}${Uu("",(n.aliases?.length,0))} ${n.description??""}`}function oA(n){let t={};for(let i of n){let o=i.category??"misc";t[o]||(t[o]=[]),t[o].push(i)}let e=[`${$u}Available commands${Sn}`,`${Ri}Type 'help <command>' for detailed usage.${Sn}`,""],r=[...Lu.filter(i=>t[i]),...Object.keys(t).filter(i=>!Lu.includes(i)).sort()];for(let i of r){let o=t[i];if(!o?.length)continue;e.push(`${rA}${Du[i]??i}${Sn}`);let a=[...o].sort((c,f)=>c.name.localeCompare(f.name));for(let c of a)e.push(sA(c));e.push("")}let s=n.length;return e.push(`${Ri}${s} commands available.${Sn}`),e.join(`
105
- `)}function aA(n){let t=[];if(t.push(`${$u}${n.name}${Sn} \u2014 ${n.description??"no description"}`),n.aliases?.length&&t.push(`${Ri}Aliases: ${n.aliases.join(", ")}${Sn}`),t.push(""),t.push(`${iA}Usage:${Sn}`),n.params.length)for(let r of n.params)t.push(` ${n.name} ${r}`);else t.push(` ${n.name}`);let e=Du[n.category??"misc"]??n.category??"misc";return t.push(""),t.push(`${Ri}Category: ${e}${Sn}`),t.join(`
106
- `)}function Ou(n){return{name:"help",description:"List all commands, or show usage for a specific command",category:"shell",params:["[command]"],run:({args:t})=>{let e=ja();if(t[0]){let r=t[0].toLowerCase(),s=e.find(i=>i.name===r||i.aliases?.includes(r));return s?{stdout:aA(s),exitCode:0}:{stderr:`help: no help entry for '${t[0]}'`,exitCode:1}}return{stdout:oA(e),exitCode:0}}}}var Mu={name:"history",description:"Display command history",category:"shell",params:["[n]"],run:({args:n,shell:t,authUser:e})=>{let r=`/home/${e}/.bash_history`;if(!t.vfs.exists(r))return{stdout:"",exitCode:0};let i=t.vfs.readFile(r).split(`
105
+ `),exitCode:0}}};var Ou=["navigation","files","text","archive","system","package","network","shell","users","misc"],Fu={navigation:"Navigation",files:"Files & Filesystem",text:"Text Processing",archive:"Archive & Compression",system:"System",package:"Package Management",network:"Network",shell:"Shell & Scripting",users:"Users & Permissions",misc:"Miscellaneous"},Hu="\x1B[1m",Cn="\x1B[0m",fA="\x1B[36m",lA="\x1B[33m",Ti="\x1B[2m",uA="\x1B[32m";function Mu(n,t){return n.length>=t?n:n+" ".repeat(t-n.length)}function dA(n){let t=n.aliases?.length?` ${Ti}(${n.aliases.join(", ")})${Cn}`:"";return` ${fA}${Mu(n.name,16)}${Cn}${t}${Mu("",(n.aliases?.length,0))} ${n.description??""}`}function hA(n){let t={};for(let i of n){let o=i.category??"misc";t[o]||(t[o]=[]),t[o].push(i)}let e=[`${Hu}Available commands${Cn}`,`${Ti}Type 'help <command>' for detailed usage.${Cn}`,""],r=[...Ou.filter(i=>t[i]),...Object.keys(t).filter(i=>!Ou.includes(i)).sort()];for(let i of r){let o=t[i];if(!o?.length)continue;e.push(`${lA}${Fu[i]??i}${Cn}`);let a=[...o].sort((c,f)=>c.name.localeCompare(f.name));for(let c of a)e.push(dA(c));e.push("")}let s=n.length;return e.push(`${Ti}${s} commands available.${Cn}`),e.join(`
106
+ `)}function pA(n){let t=[];if(t.push(`${Hu}${n.name}${Cn} \u2014 ${n.description??"no description"}`),n.aliases?.length&&t.push(`${Ti}Aliases: ${n.aliases.join(", ")}${Cn}`),t.push(""),t.push(`${uA}Usage:${Cn}`),n.params.length)for(let r of n.params)t.push(` ${n.name} ${r}`);else t.push(` ${n.name}`);let e=Fu[n.category??"misc"]??n.category??"misc";return t.push(""),t.push(`${Ti}Category: ${e}${Cn}`),t.join(`
107
+ `)}function Qu(n){return{name:"help",description:"List all commands, or show usage for a specific command",category:"shell",params:["[command]"],run:({args:t})=>{let e=ec();if(t[0]){let r=t[0].toLowerCase(),s=e.find(i=>i.name===r||i.aliases?.includes(r));return s?{stdout:pA(s),exitCode:0}:{stderr:`help: no help entry for '${t[0]}'`,exitCode:1}}return{stdout:hA(e),exitCode:0}}}}var Wu={name:"history",description:"Display command history",category:"shell",params:["[n]"],run:({args:n,shell:t,authUser:e})=>{let r=`/home/${e}/.bash_history`;if(!t.vfs.exists(r))return{stdout:"",exitCode:0};let i=t.vfs.readFile(r).split(`
107
108
  `).filter(Boolean),o=n[0],a=o?parseInt(o,10):null,c=a&&!Number.isNaN(a)?i.slice(-a):i,f=i.length-c.length+1;return{stdout:c.map((u,h)=>`${String(f+h).padStart(5)} ${u}`).join(`
108
- `),exitCode:0}}};var Fu={name:"hostname",description:"Print hostname",category:"system",params:[],run:({hostname:n})=>({stdout:n,exitCode:0})};var Hu={name:"htop",description:"System monitor",category:"system",params:[],run:({mode:n})=>n==="exec"?{stderr:"htop: interactive terminal required",exitCode:1}:{openHtop:!0,exitCode:0}};var Qu={name:"id",description:"Print user identity",category:"system",params:["[user]"],run:({authUser:n,shell:t,args:e})=>{let r=e[0]??n,s=r==="root"?0:1e3,i=s,a=t.users.isSudoer(r)?`${i}(${r}),0(root)`:`${i}(${r})`;return{stdout:`uid=${s}(${r}) gid=${i}(${r}) groups=${a}`,exitCode:0}}};var Wu={name:"kill",description:"Send signal to process",category:"system",params:["[-9] <pid>"],run:({args:n})=>n.find(e=>!e.startsWith("-"))?{stdout:"",exitCode:0}:{stderr:"kill: no pid specified",exitCode:1}};var qu={name:"ln",description:"Create links",category:"files",params:["[-s] <target> <link_name>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=se(r,["-s","--symbolic"]),i=r.filter(l=>!l.startsWith("-")),[o,a]=i;if(!o||!a)return{stderr:"ln: missing operand",exitCode:1};let c=le(e,a),f=s?o:le(e,o);try{if(Oe(n,c,"ln"),s)t.vfs.symlink(f,c);else{let l=le(e,o);if(Oe(n,l,"ln"),!t.vfs.exists(l))return{stderr:`ln: ${o}: No such file or directory`,exitCode:1};let u=t.vfs.readFile(l);t.writeFileAsUser(n,c,u)}return{exitCode:0}}catch(l){return{stderr:`ln: ${l instanceof Error?l.message:String(l)}`,exitCode:1}}}},Ku={name:"readlink",description:"Print resolved path of symbolic link",category:"files",params:["[-f] <path>"],run:({shell:n,cwd:t,args:e})=>{let r=e.includes("-f")||e.includes("-e"),s=e.find(a=>!a.startsWith("-"));if(!s)return{stderr:`readlink: missing operand
109
+ `),exitCode:0}}};var qu={name:"hostname",description:"Print hostname",category:"system",params:[],run:({hostname:n})=>({stdout:n,exitCode:0})};var Ku={name:"htop",description:"System monitor",category:"system",params:[],run:({mode:n})=>n==="exec"?{stderr:"htop: interactive terminal required",exitCode:1}:{openHtop:!0,exitCode:0}};var Vu={name:"id",description:"Print user identity",category:"system",params:["[user]"],run:({authUser:n,shell:t,args:e})=>{let r=e[0]??n,s=r==="root"?0:1e3,i=s,a=t.users.isSudoer(r)?`${i}(${r}),0(root)`:`${i}(${r})`;return{stdout:`uid=${s}(${r}) gid=${i}(${r}) groups=${a}`,exitCode:0}}};var Gu={name:"kill",description:"Send signal to process",category:"system",params:["[-9] <pid>"],run:({args:n})=>n.find(e=>!e.startsWith("-"))?{stdout:"",exitCode:0}:{stderr:"kill: no pid specified",exitCode:1}};var zu={name:"ln",description:"Create links",category:"files",params:["[-s] <target> <link_name>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=se(r,["-s","--symbolic"]),i=r.filter(l=>!l.startsWith("-")),[o,a]=i;if(!o||!a)return{stderr:"ln: missing operand",exitCode:1};let c=le(e,a),f=s?o:le(e,o);try{if(Oe(n,c,"ln"),s)t.vfs.symlink(f,c);else{let l=le(e,o);if(Oe(n,l,"ln"),!t.vfs.exists(l))return{stderr:`ln: ${o}: No such file or directory`,exitCode:1};let u=t.vfs.readFile(l);t.writeFileAsUser(n,c,u)}return{exitCode:0}}catch(l){return{stderr:`ln: ${l instanceof Error?l.message:String(l)}`,exitCode:1}}}},Yu={name:"readlink",description:"Print resolved path of symbolic link",category:"files",params:["[-f] <path>"],run:({shell:n,cwd:t,args:e})=>{let r=e.includes("-f")||e.includes("-e"),s=e.find(a=>!a.startsWith("-"));if(!s)return{stderr:`readlink: missing operand
109
110
  `,exitCode:1};let i=le(t,s);return n.vfs.exists(i)?n.vfs.isSymlink(i)?{stdout:`${n.vfs.resolveSymlink(i)}
110
111
  `,exitCode:0}:{stderr:`readlink: ${s}: not a symbolic link
111
112
  `,exitCode:1}:{stderr:`readlink: ${s}: No such file or directory
112
- `,exitCode:1}}};var Vu={name:"stat",description:"Display file status",category:"files",params:["[-c <format>] <file>"],run:({shell:n,cwd:t,args:e})=>{let r=e.findIndex(k=>k==="-c"||k==="--format"),s=r!==-1?e[r+1]:void 0,i=e.find(k=>!k.startsWith("-")&&k!==s);if(!i)return{stderr:`stat: missing operand
113
+ `,exitCode:1}}};var ju={name:"seq",description:"Print a sequence of numbers",category:"text",params:["[FIRST [INCREMENT]] LAST"],run:({args:n})=>{let t=n.filter(u=>!u.startsWith("-")||/^-[\d.]/.test(u)).map(Number),e=(()=>{let u=n.indexOf("-s");return u!==-1?n[u+1]??`
114
+ `:`
115
+ `})(),r=(()=>{let u=n.indexOf("-f");return u!==-1?n[u+1]??"%g":null})(),s=n.includes("-w"),i=1,o=1,a;if(t.length===1?a=t[0]:t.length===2?(i=t[0],a=t[1]):(i=t[0],o=t[1],a=t[2]),o===0)return{stderr:`seq: zero increment
116
+ `,exitCode:1};if(o>0&&i>a||o<0&&i<a)return{stdout:"",exitCode:0};let c=[],f=1e5,l=0;for(let u=i;(o>0?u<=a:u>=a)&&!(++l>f);u=Math.round((u+o)*1e10)/1e10){let h;if(r?h=r.replace("%g",String(u)).replace("%f",u.toFixed(6)).replace("%d",String(Math.trunc(u))):h=Number.isInteger(u)?String(u):u.toPrecision(12).replace(/\.?0+$/,""),s){let p=String(Math.trunc(a)).length;h=h.padStart(p,"0")}c.push(h)}return{stdout:`${c.join(e)}
117
+ `,exitCode:0}}};var Xu={name:"stat",description:"Display file status",category:"files",params:["[-c <format>] <file>"],run:({shell:n,cwd:t,args:e})=>{let r=e.findIndex(C=>C==="-c"||C==="--format"),s=r!==-1?e[r+1]:void 0,i=e.find(C=>!C.startsWith("-")&&C!==s);if(!i)return{stderr:`stat: missing operand
113
118
  `,exitCode:1};let o=le(t,i);if(!n.vfs.exists(o))return{stderr:`stat: cannot stat '${i}': No such file or directory
114
- `,exitCode:1};let a=n.vfs.stat(o),c=a.type==="directory",f=n.vfs.isSymlink(o),l=n.vfs.isSymlink(o),u=k=>{let D=[256,128,64,32,16,8,4,2,1],H=["r","w","x","r","w","x","r","w","x"];return(c?"d":l?"l":"-")+D.map((C,F)=>k&C?H[F]:"-").join("")},h=a.mode.toString(8).padStart(4,"0"),p=u(a.mode),y="size"in a?a.size:0,E=k=>k.toISOString().replace("T"," ").replace(/\.\d+Z$/," +0000");return s?{stdout:`${s.replace("%n",i).replace("%s",String(y)).replace("%a",h.slice(1)).replace("%A",p).replace("%F",l?"symbolic link":c?"directory":"regular file").replace("%y",E(a.updatedAt)).replace("%z",E(a.updatedAt))}
119
+ `,exitCode:1};let a=n.vfs.stat(o),c=a.type==="directory",f=n.vfs.isSymlink(o),l=n.vfs.isSymlink(o),u=C=>{let N=[256,128,64,32,16,8,4,2,1],H=["r","w","x","r","w","x","r","w","x"];return(c?"d":l?"l":"-")+N.map((v,M)=>C&v?H[M]:"-").join("")},h=a.mode.toString(8).padStart(4,"0"),p=u(a.mode),y="size"in a?a.size:0,E=C=>C.toISOString().replace("T"," ").replace(/\.\d+Z$/," +0000");return s?{stdout:`${s.replace("%n",i).replace("%s",String(y)).replace("%a",h.slice(1)).replace("%A",p).replace("%F",l?"symbolic link":c?"directory":"regular file").replace("%y",E(a.updatedAt)).replace("%z",E(a.updatedAt))}
115
120
  `,exitCode:0}:{stdout:`${[` File: ${i}${l?` -> ${n.vfs.resolveSymlink(o)}`:""}`,` Size: ${y}${" ".repeat(3)}${l?"symbolic link":c?"directory":"regular file"}`,`Access: (${h}/${p}) Uid: ( 0/ root) Gid: ( 0/ root)`,`Modify: ${E(a.updatedAt)}`,`Change: ${E(a.updatedAt)}`].join(`
116
121
  `)}
117
- `,exitCode:0}}};function Gu(n,t){let e=t?"d":"-",s=[[256,"r"],[128,"w"],[64,"x"],[32,"r"],[16,"w"],[8,"x"],[4,"r"],[2,"w"],[1,"x"]].map(([i,o])=>n&i?o:"-").join("");return`${e}${s}`}function zu(n){return n.toISOString().replace("T"," ").slice(0,16)}var Yu={name:"ls",description:"List directory contents",category:"navigation",params:["[-la] [path]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=se(r,["-l","--long"]),i=se(r,["-a","--all"]),o=Xn(r,0,{flags:["-l","--long","-a","--all","-la","-al"]}),a=le(e,o??e);if(Oe(n,a,"ls"),t.vfs.exists(a)){let l=t.vfs.stat(a);if(l.type==="file"||t.vfs.isSymlink(a)){if(s){let u=a.split("/").pop()??a,h=l.type==="file"?l.size:0;return{stdout:`${Gu(l.mode,!1)} 1 root root ${h} ${zu(l.updatedAt)} ${u}
118
- `,exitCode:0}}return{stdout:a.split("/").pop()??a,exitCode:0}}}let c=t.vfs.list(a).filter(l=>i||!l.startsWith("."));return{stdout:s?c.map(l=>{let u=le(a,l),h=t.vfs.stat(u),p=h.type==="file"?h.size:h.childrenCount;return`${Gu(h.mode,h.type==="directory")} 1 ${p} ${zu(h.updatedAt)} ${l}${h.type==="directory"?"/":""}`}).join(`
119
- `):ru(a,c,l=>t.vfs.stat(l)),exitCode:0}}};var ju={name:"lsb_release",description:"Print distribution-specific information",category:"system",params:["[-a] [-i] [-d] [-r] [-c]"],run:({args:n,shell:t})=>{let e=t.properties?.os??"Fortune GNU/Linux x64",r="aurora",s="1.0";try{let u=t.vfs.readFile("/etc/os-release");for(let h of u.split(`
122
+ `,exitCode:0}}};function Ju(n,t){let e=t?"d":"-",s=[[256,"r"],[128,"w"],[64,"x"],[32,"r"],[16,"w"],[8,"x"],[4,"r"],[2,"w"],[1,"x"]].map(([i,o])=>n&i?o:"-").join("");return`${e}${s}`}function Zu(n){return n.toISOString().replace("T"," ").slice(0,16)}var ed={name:"ls",description:"List directory contents",category:"navigation",params:["[-la] [path]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=se(r,["-l","--long"]),i=se(r,["-a","--all"]),o=Jn(r,0,{flags:["-l","--long","-a","--all","-la","-al"]}),a=le(e,o??e);if(Oe(n,a,"ls"),t.vfs.exists(a)){let l=t.vfs.stat(a);if(l.type==="file"||t.vfs.isSymlink(a)){if(s){let u=a.split("/").pop()??a,h=l.type==="file"?l.size:0;return{stdout:`${Ju(l.mode,!1)} 1 root root ${h} ${Zu(l.updatedAt)} ${u}
123
+ `,exitCode:0}}return{stdout:a.split("/").pop()??a,exitCode:0}}}let c=t.vfs.list(a).filter(l=>i||!l.startsWith("."));return{stdout:s?c.map(l=>{let u=le(a,l),h=t.vfs.stat(u),p=h.type==="file"?h.size:h.childrenCount;return`${Ju(h.mode,h.type==="directory")} 1 ${p} ${Zu(h.updatedAt)} ${l}${h.type==="directory"?"/":""}`}).join(`
124
+ `):ou(a,c,l=>t.vfs.stat(l)),exitCode:0}}};var td={name:"lsb_release",description:"Print distribution-specific information",category:"system",params:["[-a] [-i] [-d] [-r] [-c]"],run:({args:n,shell:t})=>{let e=t.properties?.os??"Fortune GNU/Linux x64",r="aurora",s="1.0";try{let u=t.vfs.readFile("/etc/os-release");for(let h of u.split(`
120
125
  `))h.startsWith("PRETTY_NAME=")&&(e=h.slice(12).replace(/^"|"$/g,"").trim()),h.startsWith("VERSION_CODENAME=")&&(r=h.slice(17).trim()),h.startsWith("VERSION_ID=")&&(s=h.slice(11).replace(/^"|"$/g,"").trim())}catch{}let i=se(n,["-a","--all"]),o=se(n,["-i","--id"]),a=se(n,["-d","--description"]),c=se(n,["-r","--release"]),f=se(n,["-c","--codename"]);if(i||n.length===0)return{stdout:["Distributor ID: Fortune",`Description: ${e}`,`Release: ${s}`,`Codename: ${r}`].join(`
121
126
  `),exitCode:0};let l=[];return o&&l.push("Distributor ID: Fortune"),a&&l.push(`Description: ${e}`),c&&l.push(`Release: ${s}`),f&&l.push(`Codename: ${r}`),{stdout:l.join(`
122
- `),exitCode:0}}};var dA={},cA={gunzip:"gzip"},Os=new Map,fA=new URL("./manuals/",dA.url);async function lA(n){return new Function("moduleName","return import(moduleName)")(n)}async function uA(n){let t=n.toLowerCase(),e=cA[t]??t,r=`builtin:${e}`;if(Os.has(r))return Os.get(r)??null;try{let s=await lA("node:fs/promises"),i=new URL(`${e}.txt`,fA),a=(await s.readFile(i,"utf8")).replace(/\n$/,"");return Os.set(r,a),a}catch{return Os.set(r,null),null}}var Xu={name:"man",description:"Interface to the system reference manuals",category:"shell",params:["<command>"],run:async({args:n,shell:t})=>{let e=n[0];if(!e)return{stderr:"What manual page do you want?",exitCode:1};let r=`/usr/share/man/man1/${e}.1`;if(t.vfs.exists(r))return{stdout:t.vfs.readFile(r),exitCode:0};let s=await uA(e);return s?{stdout:s,exitCode:0}:{stderr:`No manual entry for ${e}`,exitCode:16}}};var Ju={name:"mkdir",description:"Make directories",category:"files",params:["<dir>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"mkdir: missing operand",exitCode:1};for(let s=0;s<r.length;s++){let i=Xn(r,s);if(!i)return{stderr:"mkdir: missing operand",exitCode:1};let o=le(e,i);Oe(n,o,"mkdir"),t.vfs.mkdir(o)}return{exitCode:0}}};var Zu={name:"mv",description:"Move or rename files",category:"files",params:["<source> <dest>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=r.filter(f=>!f.startsWith("-")),[i,o]=s;if(!i||!o)return{stderr:"mv: missing operand",exitCode:1};let a=le(e,i),c=le(e,o);try{if(Oe(n,a,"mv"),Oe(n,c,"mv"),!t.vfs.exists(a))return{stderr:`mv: ${i}: No such file or directory`,exitCode:1};let f=t.vfs.exists(c)&&t.vfs.stat(c).type==="directory"?`${c}/${i.split("/").pop()}`:c;return t.vfs.move(a,f),{exitCode:0}}catch(f){return{stderr:`mv: ${f instanceof Error?f.message:String(f)}`,exitCode:1}}}};var ed=Vt(require("node:path"),1);var td={name:"nano",description:"Text editor",category:"files",params:["<file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=r[0];if(!s)return{stderr:"nano: missing file operand",exitCode:1};let i=le(e,s);Oe(n,i,"nano");let o=t.vfs.exists(i)?t.vfs.readFile(i):"",a=ed.posix.basename(i)||"buffer",c=`/tmp/sshmimic-nano-${Date.now()}-${a}.tmp`;return{openEditor:{targetPath:i,tempPath:c,initialContent:o},exitCode:0}}};var $n=require("node:fs"),Ot=Vt(require("node:os"),1),cd=Vt(require("node:path"),1);function hA(n){let t=Math.max(1,Math.floor(n/60)),e=Math.floor(t/1440),r=Math.floor(t%1440/60),s=t%60,i=[];return e>0&&i.push(`${e} day${e>1?"s":""}`),r>0&&i.push(`${r} hour${r>1?"s":""}`),(s>0||i.length===0)&&i.push(`${s} min${s>1?"s":""}`),i.join(", ")}function nd(n){return`\x1B[${n}m \x1B[0m`}function pA(){let n=[40,41,42,43,44,45,46,47].map(nd).join(""),t=[100,101,102,103,104,105,106,107].map(nd).join("");return[n,t]}function rd(n,t,e){if(n.trim().length===0)return n;let r={r:255,g:255,b:255},s={r:168,g:85,b:247},i=e<=1?0:t/(e-1),o=Math.round(r.r+(s.r-r.r)*i),a=Math.round(r.g+(s.g-r.g)*i),c=Math.round(r.b+(s.b-r.b)*i);return`\x1B[38;2;${o};${a};${c}m${n}\x1B[0m`}function gA(n){if(n.trim().length===0)return n;let t=n.indexOf(":");if(t===-1)return n.includes("@")?id(n):n;let e=n.substring(0,t+1),r=n.substring(t+1);return id(e)+r}function id(n){let t=new RegExp("\x1B\\[[\\d;]*m","g"),e=n.replace(t,"");if(e.trim().length===0)return n;let r={r:255,g:255,b:255},s={r:168,g:85,b:247},i="";for(let o=0;o<e.length;o+=1){let a=e.length<=1?0:o/(e.length-1),c=Math.round(r.r+(s.r-r.r)*a),f=Math.round(r.g+(s.g-r.g)*a),l=Math.round(r.b+(s.b-r.b)*a);i+=`\x1B[38;2;${c};${f};${l}m${e[o]}\x1B[0m`}return i}function sd(n){return Math.max(0,Math.round(n/(1024*1024)))}function od(){try{let n=(0,$n.readFileSync)("/etc/os-release","utf8");for(let t of n.split(`
123
- `)){if(!t.startsWith("PRETTY_NAME="))continue;return t.slice(12).trim().replace(/^"|"$/g,"")}}catch{return}}function ad(n){try{let t=(0,$n.readFileSync)(n,"utf8").split(`
124
- `)[0]?.trim();return!t||t.length===0?void 0:t}catch{return}}function mA(n){let t=ad("/sys/devices/virtual/dmi/id/sys_vendor"),e=ad("/sys/devices/virtual/dmi/id/product_name");return t&&e?`${t} ${e}`:e||n}function AA(){let n=["/var/lib/dpkg/status","/usr/local/var/lib/dpkg/status"];for(let t of n)if((0,$n.existsSync)(t))try{return(0,$n.readFileSync)(t,"utf8").match(/^Package:\s+/gm)?.length??0}catch{}}function EA(){let n=["/snap","/var/lib/snapd/snaps"];for(let t of n)if((0,$n.existsSync)(t))try{return(0,$n.readdirSync)(t,{withFileTypes:!0}).filter(s=>s.isDirectory()).length}catch{}}function _A(){let n=AA(),t=EA();return n!==void 0&&t!==void 0?`${n} (dpkg), ${t} (snap)`:n!==void 0?`${n} (dpkg)`:t!==void 0?`${t} (snap)`:"n/a"}function yA(){let n=Ot.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 bA(n){return!n||n.trim().length===0?"unknown":cd.posix.basename(n.trim())}function xA(n){let t=Ot.totalmem(),e=Ot.freemem(),r=Math.max(0,t-e),s=n.shellProps,i=process.uptime();return n.uptimeSeconds===void 0&&(n.uptimeSeconds=Math.round(i)),{user:n.user,host:n.host,osName:s?.os??n.osName??`${od()??Ot.type()} ${Ot.arch()}`,kernel:s?.kernel??n.kernel??Ot.release(),uptimeSeconds:n.uptimeSeconds??Ot.uptime(),packages:n.packages??_A(),shell:bA(n.shell),shellProps:n.shellProps??{kernel:n.kernel??Ot.release(),os:n.osName??`${od()??Ot.type()} ${Ot.arch()}`,arch:Ot.arch()},resolution:n.resolution??"n/a (ssh)",terminal:n.terminal??"unknown",cpu:n.cpu??yA(),gpu:n.gpu??"n/a",memoryUsedMiB:n.memoryUsedMiB??sd(r),memoryTotalMiB:n.memoryTotalMiB??sd(t)}}function fd(n){let t=xA(n),e=hA(t.uptimeSeconds),r=pA(),s=[" .. .:. "," .::.. .. .. ",". .... ... .. ",": .... .:. .. ",": .:.:........:. .. ",": .. ",". : ",". : ",".. : "," :. .. "," .. .. "," :-. :: "," .:. :. "," ..: ... "," ..: :.. "," :... :...."," .. ...."," . .. "," .:. .: "," :. .. "," ::. .. ","..... ..:... ","...:. .. ",".:...:. ::. .. "," ... ..:::::.. ..:::::::.. "],i=[`${t.user}@${t.host}`,"-------------------------",`OS: ${t.osName}`,`Host: ${mA(t.host)}`,`Kernel: ${t.kernel}`,`Uptime: ${e}`,`Packages: ${t.packages}`,`Shell: ${t.shell}`,`Resolution: ${t.resolution}`,`Terminal: ${t.terminal}`,`CPU: ${t.cpu}`,`GPU: ${t.gpu}`,`Memory: ${t.memoryUsedMiB}MiB / ${t.memoryTotalMiB}MiB`,"",r[0],r[1]],o=Math.max(s.length,i.length),a=[];for(let c=0;c<o;c+=1){let f=s[c]??"",l=i[c]??"";if(l.length>0){let u=rd(f.padEnd(31," "),c,s.length),h=gA(l);a.push(`${u} ${h}`);continue}a.push(rd(f,c,s.length))}return a.join(`
125
- `)}var ld={name:"neofetch",description:"System info display",category:"system",params:["[--off]"],run:({args:n,authUser:t,hostname:e,shell:r,env:s})=>r.packageManager.isInstalled("neofetch")?se(n,"--help")?{stdout:"Usage: neofetch [--off]",exitCode:0}:se(n,"--off")?{stdout:`${t}@${e}`,exitCode:0}:{stdout:fd({user:t,host:e,shell:s.vars.SHELL,shellProps:r.properties,terminal:s.vars.TERM,uptimeSeconds:Math.floor((Date.now()-r.startTime)/1e3),packages:`${r.packageManager?.installedCount()??0} (dpkg)`}),exitCode:0}:{stderr:`bash: neofetch: command not found
127
+ `),exitCode:0}}};var yA={},gA={gunzip:"gzip"},Hs=new Map,mA=new URL("./manuals/",yA.url);async function AA(n){return new Function("moduleName","return import(moduleName)")(n)}async function EA(n){let t=n.toLowerCase(),e=gA[t]??t,r=`builtin:${e}`;if(Hs.has(r))return Hs.get(r)??null;try{let s=await AA("node:fs/promises"),i=new URL(`${e}.txt`,mA),a=(await s.readFile(i,"utf8")).replace(/\n$/,"");return Hs.set(r,a),a}catch{return Hs.set(r,null),null}}var nd={name:"man",description:"Interface to the system reference manuals",category:"shell",params:["<command>"],run:async({args:n,shell:t})=>{let e=n[0];if(!e)return{stderr:"What manual page do you want?",exitCode:1};let r=`/usr/share/man/man1/${e}.1`;if(t.vfs.exists(r))return{stdout:t.vfs.readFile(r),exitCode:0};let s=await EA(e);return s?{stdout:s,exitCode:0}:{stderr:`No manual entry for ${e}`,exitCode:16}}};var rd={name:"mkdir",description:"Make directories",category:"files",params:["<dir>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"mkdir: missing operand",exitCode:1};for(let s=0;s<r.length;s++){let i=Jn(r,s);if(!i)return{stderr:"mkdir: missing operand",exitCode:1};let o=le(e,i);Oe(n,o,"mkdir"),t.vfs.mkdir(o)}return{exitCode:0}}};var id={name:"mv",description:"Move or rename files",category:"files",params:["<source> <dest>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=r.filter(f=>!f.startsWith("-")),[i,o]=s;if(!i||!o)return{stderr:"mv: missing operand",exitCode:1};let a=le(e,i),c=le(e,o);try{if(Oe(n,a,"mv"),Oe(n,c,"mv"),!t.vfs.exists(a))return{stderr:`mv: ${i}: No such file or directory`,exitCode:1};let f=t.vfs.exists(c)&&t.vfs.stat(c).type==="directory"?`${c}/${i.split("/").pop()}`:c;return t.vfs.move(a,f),{exitCode:0}}catch(f){return{stderr:`mv: ${f instanceof Error?f.message:String(f)}`,exitCode:1}}}};var sd=Gt(require("node:path"),1);var od={name:"nano",description:"Text editor",category:"files",params:["<file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=r[0];if(!s)return{stderr:"nano: missing file operand",exitCode:1};let i=le(e,s);Oe(n,i,"nano");let o=t.vfs.exists(i)?t.vfs.readFile(i):"",a=sd.posix.basename(i)||"buffer",c=`/tmp/sshmimic-nano-${Date.now()}-${a}.tmp`;return{openEditor:{targetPath:i,tempPath:c,initialContent:o},exitCode:0}}};var On=require("node:fs"),Mt=Gt(require("node:os"),1),hd=Gt(require("node:path"),1);function _A(n){let t=Math.max(1,Math.floor(n/60)),e=Math.floor(t/1440),r=Math.floor(t%1440/60),s=t%60,i=[];return e>0&&i.push(`${e} day${e>1?"s":""}`),r>0&&i.push(`${r} hour${r>1?"s":""}`),(s>0||i.length===0)&&i.push(`${s} min${s>1?"s":""}`),i.join(", ")}function ad(n){return`\x1B[${n}m \x1B[0m`}function bA(){let n=[40,41,42,43,44,45,46,47].map(ad).join(""),t=[100,101,102,103,104,105,106,107].map(ad).join("");return[n,t]}function cd(n,t,e){if(n.trim().length===0)return n;let r={r:255,g:255,b:255},s={r:168,g:85,b:247},i=e<=1?0:t/(e-1),o=Math.round(r.r+(s.r-r.r)*i),a=Math.round(r.g+(s.g-r.g)*i),c=Math.round(r.b+(s.b-r.b)*i);return`\x1B[38;2;${o};${a};${c}m${n}\x1B[0m`}function xA(n){if(n.trim().length===0)return n;let t=n.indexOf(":");if(t===-1)return n.includes("@")?fd(n):n;let e=n.substring(0,t+1),r=n.substring(t+1);return fd(e)+r}function fd(n){let t=new RegExp("\x1B\\[[\\d;]*m","g"),e=n.replace(t,"");if(e.trim().length===0)return n;let r={r:255,g:255,b:255},s={r:168,g:85,b:247},i="";for(let o=0;o<e.length;o+=1){let a=e.length<=1?0:o/(e.length-1),c=Math.round(r.r+(s.r-r.r)*a),f=Math.round(r.g+(s.g-r.g)*a),l=Math.round(r.b+(s.b-r.b)*a);i+=`\x1B[38;2;${c};${f};${l}m${e[o]}\x1B[0m`}return i}function ld(n){return Math.max(0,Math.round(n/(1024*1024)))}function ud(){try{let n=(0,On.readFileSync)("/etc/os-release","utf8");for(let t of n.split(`
128
+ `)){if(!t.startsWith("PRETTY_NAME="))continue;return t.slice(12).trim().replace(/^"|"$/g,"")}}catch{return}}function dd(n){try{let t=(0,On.readFileSync)(n,"utf8").split(`
129
+ `)[0]?.trim();return!t||t.length===0?void 0:t}catch{return}}function SA(n){let t=dd("/sys/devices/virtual/dmi/id/sys_vendor"),e=dd("/sys/devices/virtual/dmi/id/product_name");return t&&e?`${t} ${e}`:e||n}function wA(){let n=["/var/lib/dpkg/status","/usr/local/var/lib/dpkg/status"];for(let t of n)if((0,On.existsSync)(t))try{return(0,On.readFileSync)(t,"utf8").match(/^Package:\s+/gm)?.length??0}catch{}}function IA(){let n=["/snap","/var/lib/snapd/snaps"];for(let t of n)if((0,On.existsSync)(t))try{return(0,On.readdirSync)(t,{withFileTypes:!0}).filter(s=>s.isDirectory()).length}catch{}}function CA(){let n=wA(),t=IA();return n!==void 0&&t!==void 0?`${n} (dpkg), ${t} (snap)`:n!==void 0?`${n} (dpkg)`:t!==void 0?`${t} (snap)`:"n/a"}function vA(){let n=Mt.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 kA(n){return!n||n.trim().length===0?"unknown":hd.posix.basename(n.trim())}function BA(n){let t=Mt.totalmem(),e=Mt.freemem(),r=Math.max(0,t-e),s=n.shellProps,i=process.uptime();return n.uptimeSeconds===void 0&&(n.uptimeSeconds=Math.round(i)),{user:n.user,host:n.host,osName:s?.os??n.osName??`${ud()??Mt.type()} ${Mt.arch()}`,kernel:s?.kernel??n.kernel??Mt.release(),uptimeSeconds:n.uptimeSeconds??Mt.uptime(),packages:n.packages??CA(),shell:kA(n.shell),shellProps:n.shellProps??{kernel:n.kernel??Mt.release(),os:n.osName??`${ud()??Mt.type()} ${Mt.arch()}`,arch:Mt.arch()},resolution:n.resolution??"n/a (ssh)",terminal:n.terminal??"unknown",cpu:n.cpu??vA(),gpu:n.gpu??"n/a",memoryUsedMiB:n.memoryUsedMiB??ld(r),memoryTotalMiB:n.memoryTotalMiB??ld(t)}}function pd(n){let t=BA(n),e=_A(t.uptimeSeconds),r=bA(),s=[" .. .:. "," .::.. .. .. ",". .... ... .. ",": .... .:. .. ",": .:.:........:. .. ",": .. ",". : ",". : ",".. : "," :. .. "," .. .. "," :-. :: "," .:. :. "," ..: ... "," ..: :.. "," :... :...."," .. ...."," . .. "," .:. .: "," :. .. "," ::. .. ","..... ..:... ","...:. .. ",".:...:. ::. .. "," ... ..:::::.. ..:::::::.. "],i=[`${t.user}@${t.host}`,"-------------------------",`OS: ${t.osName}`,`Host: ${SA(t.host)}`,`Kernel: ${t.kernel}`,`Uptime: ${e}`,`Packages: ${t.packages}`,`Shell: ${t.shell}`,`Resolution: ${t.resolution}`,`Terminal: ${t.terminal}`,`CPU: ${t.cpu}`,`GPU: ${t.gpu}`,`Memory: ${t.memoryUsedMiB}MiB / ${t.memoryTotalMiB}MiB`,"",r[0],r[1]],o=Math.max(s.length,i.length),a=[];for(let c=0;c<o;c+=1){let f=s[c]??"",l=i[c]??"";if(l.length>0){let u=cd(f.padEnd(31," "),c,s.length),h=xA(l);a.push(`${u} ${h}`);continue}a.push(cd(f,c,s.length))}return a.join(`
130
+ `)}var gd={name:"neofetch",description:"System info display",category:"system",params:["[--off]"],run:({args:n,authUser:t,hostname:e,shell:r,env:s})=>r.packageManager.isInstalled("neofetch")?se(n,"--help")?{stdout:"Usage: neofetch [--off]",exitCode:0}:se(n,"--off")?{stdout:`${t}@${e}`,exitCode:0}:{stdout:pd({user:t,host:e,shell:s.vars.SHELL,shellProps:r.properties,terminal:s.vars.TERM,uptimeSeconds:Math.floor((Date.now()-r.startTime)/1e3),packages:`${r.packageManager?.installedCount()??0} (dpkg)`}),exitCode:0}:{stderr:`bash: neofetch: command not found
126
131
  Hint: install it with: apt install neofetch
127
- `,exitCode:127}};var Xa=Vt(require("node:vm"),1);var Ms="v18.19.0",ud={node:Ms,npm:"9.2.0",v8:"10.2.154.26-node.22"};function SA(n,t){let e={version:Ms,versions:ud,platform:"linux",arch:"x64",env:{NODE_ENV:"production",HOME:"/root",PATH:"/usr/local/bin:/usr/bin:/bin"},argv:["node"],stdout:{write:i=>(n.push(i),!0)},stderr:{write:i=>(t.push(i),!0)},exit:(i=0)=>{throw new Fs(i)},cwd:()=>"/root",hrtime:()=>[0,0]},r={log:(...i)=>n.push(i.map(wn).join(" ")),error:(...i)=>t.push(i.map(wn).join(" ")),warn:(...i)=>t.push(i.map(wn).join(" ")),info:(...i)=>n.push(i.map(wn).join(" ")),dir:i=>n.push(wn(i))},s=i=>{switch(i){case"path":return{join:(...o)=>o.join("/").replace(/\/+/g,"/"),resolve:(...o)=>`/${o.join("/").replace(/^\/+/,"")}`,dirname:o=>o.split("/").slice(0,-1).join("/")||"/",basename:o=>o.split("/").pop()??"",extname:o=>{let a=o.split("/").pop()??"",c=a.lastIndexOf(".");return c>0?a.slice(c):""},sep:"/",delimiter:":"};case"os":return{platform:()=>"linux",arch:()=>"x64",type:()=>"Linux",hostname:()=>"fortune-vm",homedir:()=>"/root",tmpdir:()=>"/tmp",EOL:`
128
- `};case"util":return{format:(...o)=>o.map(wn).join(" "),inspect:o=>wn(o)};case"fs":case"fs/promises":throw new Error(`Cannot require '${i}': filesystem access not available in virtual runtime`);case"child_process":case"net":case"http":case"https":throw new Error(`Cannot require '${i}': not available in virtual runtime`);default:throw new Error(`Cannot find module '${i}'`)}};return s.resolve=i=>{throw new Error(`Cannot resolve '${i}'`)},s.cache={},s.extensions={},Xa.default.createContext({console:r,process:e,require:s,Math,JSON,Object,Array,String,Number,Boolean,Symbol,Date,RegExp,Error,TypeError,RangeError,SyntaxError,Promise,Map,Set,WeakMap,WeakSet,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,encodeURI,decodeURI,setTimeout:()=>{},clearTimeout:()=>{},setInterval:()=>{},clearInterval:()=>{},queueMicrotask:()=>{},globalThis:void 0,undefined:void 0,Infinity:1/0,NaN:NaN})}var Fs=class{constructor(t){this.code=t}code};function wn(n){if(n===null)return"null";if(n===void 0)return"undefined";if(typeof n=="string")return n;if(typeof n=="function")return`[Function: ${n.name||"(anonymous)"}]`;if(Array.isArray(n))return`[ ${n.map(wn).join(", ")} ]`;if(n instanceof Error)return`${n.name}: ${n.message}`;if(typeof n=="object")try{return`{ ${Object.entries(n).map(([e,r])=>`${e}: ${wn(r)}`).join(", ")} }`}catch{return"[Object]"}return String(n)}function Hs(n){let t=[],e=[],r=SA(t,e),s=0;try{let i=Xa.default.runInContext(n,r,{timeout:5e3});i!==void 0&&t.length===0&&t.push(wn(i))}catch(i){i instanceof Fs?s=i.code:i instanceof Error?(e.push(`${i.name}: ${i.message}`),s=1):(e.push(String(i)),s=1)}return{stdout:t.length?`${t.join(`
132
+ `,exitCode:127}};var tc=Gt(require("node:vm"),1);var Qs="v18.19.0",md={node:Qs,npm:"9.2.0",v8:"10.2.154.26-node.22"};function RA(n,t){let e={version:Qs,versions:md,platform:"linux",arch:"x64",env:{NODE_ENV:"production",HOME:"/root",PATH:"/usr/local/bin:/usr/bin:/bin"},argv:["node"],stdout:{write:i=>(n.push(i),!0)},stderr:{write:i=>(t.push(i),!0)},exit:(i=0)=>{throw new Ws(i)},cwd:()=>"/root",hrtime:()=>[0,0]},r={log:(...i)=>n.push(i.map(vn).join(" ")),error:(...i)=>t.push(i.map(vn).join(" ")),warn:(...i)=>t.push(i.map(vn).join(" ")),info:(...i)=>n.push(i.map(vn).join(" ")),dir:i=>n.push(vn(i))},s=i=>{switch(i){case"path":return{join:(...o)=>o.join("/").replace(/\/+/g,"/"),resolve:(...o)=>`/${o.join("/").replace(/^\/+/,"")}`,dirname:o=>o.split("/").slice(0,-1).join("/")||"/",basename:o=>o.split("/").pop()??"",extname:o=>{let a=o.split("/").pop()??"",c=a.lastIndexOf(".");return c>0?a.slice(c):""},sep:"/",delimiter:":"};case"os":return{platform:()=>"linux",arch:()=>"x64",type:()=>"Linux",hostname:()=>"fortune-vm",homedir:()=>"/root",tmpdir:()=>"/tmp",EOL:`
133
+ `};case"util":return{format:(...o)=>o.map(vn).join(" "),inspect:o=>vn(o)};case"fs":case"fs/promises":throw new Error(`Cannot require '${i}': filesystem access not available in virtual runtime`);case"child_process":case"net":case"http":case"https":throw new Error(`Cannot require '${i}': not available in virtual runtime`);default:throw new Error(`Cannot find module '${i}'`)}};return s.resolve=i=>{throw new Error(`Cannot resolve '${i}'`)},s.cache={},s.extensions={},tc.default.createContext({console:r,process:e,require:s,Math,JSON,Object,Array,String,Number,Boolean,Symbol,Date,RegExp,Error,TypeError,RangeError,SyntaxError,Promise,Map,Set,WeakMap,WeakSet,parseInt,parseFloat,isNaN,isFinite,encodeURIComponent,decodeURIComponent,encodeURI,decodeURI,setTimeout:()=>{},clearTimeout:()=>{},setInterval:()=>{},clearInterval:()=>{},queueMicrotask:()=>{},globalThis:void 0,undefined:void 0,Infinity:1/0,NaN:NaN})}var Ws=class{constructor(t){this.code=t}code};function vn(n){if(n===null)return"null";if(n===void 0)return"undefined";if(typeof n=="string")return n;if(typeof n=="function")return`[Function: ${n.name||"(anonymous)"}]`;if(Array.isArray(n))return`[ ${n.map(vn).join(", ")} ]`;if(n instanceof Error)return`${n.name}: ${n.message}`;if(typeof n=="object")try{return`{ ${Object.entries(n).map(([e,r])=>`${e}: ${vn(r)}`).join(", ")} }`}catch{return"[Object]"}return String(n)}function qs(n){let t=[],e=[],r=RA(t,e),s=0;try{let i=tc.default.runInContext(n,r,{timeout:5e3});i!==void 0&&t.length===0&&t.push(vn(i))}catch(i){i instanceof Ws?s=i.code:i instanceof Error?(e.push(`${i.name}: ${i.message}`),s=1):(e.push(String(i)),s=1)}return{stdout:t.length?`${t.join(`
129
134
  `)}
130
135
  `:"",stderr:e.length?`${e.join(`
131
136
  `)}
132
- `:"",exitCode:s}}function wA(n){let t=n.trim();return!t.includes(`
133
- `)&&!t.startsWith("const ")&&!t.startsWith("let ")&&!t.startsWith("var ")&&!t.startsWith("function ")&&!t.startsWith("class ")&&!t.startsWith("if ")&&!t.startsWith("for ")&&!t.startsWith("while ")&&!t.startsWith("import ")&&!t.startsWith("//")?Hs(t):Hs(`(async () => { ${n} })()`)}var dd={name:"node",description:"JavaScript runtime (virtual)",category:"system",params:["[--version] [-e <expr>] [-p <expr>] [file]"],run:({args:n,shell:t,cwd:e})=>{if(!t.packageManager.isInstalled("nodejs"))return{stderr:`bash: node: command not found
137
+ `:"",exitCode:s}}function NA(n){let t=n.trim();return!t.includes(`
138
+ `)&&!t.startsWith("const ")&&!t.startsWith("let ")&&!t.startsWith("var ")&&!t.startsWith("function ")&&!t.startsWith("class ")&&!t.startsWith("if ")&&!t.startsWith("for ")&&!t.startsWith("while ")&&!t.startsWith("import ")&&!t.startsWith("//")?qs(t):qs(`(async () => { ${n} })()`)}var Ad={name:"node",description:"JavaScript runtime (virtual)",category:"system",params:["[--version] [-e <expr>] [-p <expr>] [file]"],run:({args:n,shell:t,cwd:e})=>{if(!t.packageManager.isInstalled("nodejs"))return{stderr:`bash: node: command not found
134
139
  Hint: install it with: apt install nodejs
135
- `,exitCode:127};if(se(n,["--version","-v"]))return{stdout:`${Ms}
136
- `,exitCode:0};if(se(n,["--versions"]))return{stdout:`${JSON.stringify(ud,null,2)}
140
+ `,exitCode:127};if(se(n,["--version","-v"]))return{stdout:`${Qs}
141
+ `,exitCode:0};if(se(n,["--versions"]))return{stdout:`${JSON.stringify(md,null,2)}
137
142
  `,exitCode:0};let r=n.findIndex(o=>o==="-e"||o==="--eval");if(r!==-1){let o=n[r+1];if(!o)return{stderr:`node: -e requires an argument
138
- `,exitCode:1};let{stdout:a,stderr:c,exitCode:f}=Hs(o);return{stdout:a||void 0,stderr:c||void 0,exitCode:f}}let s=n.findIndex(o=>o==="-p"||o==="--print");if(s!==-1){let o=n[s+1];if(!o)return{stderr:`node: -p requires an argument
139
- `,exitCode:1};let{stdout:a,stderr:c,exitCode:f}=Hs(o);return{stdout:a||(f===0?`
143
+ `,exitCode:1};let{stdout:a,stderr:c,exitCode:f}=qs(o);return{stdout:a||void 0,stderr:c||void 0,exitCode:f}}let s=n.findIndex(o=>o==="-p"||o==="--print");if(s!==-1){let o=n[s+1];if(!o)return{stderr:`node: -p requires an argument
144
+ `,exitCode:1};let{stdout:a,stderr:c,exitCode:f}=qs(o);return{stdout:a||(f===0?`
140
145
  `:void 0),stderr:c||void 0,exitCode:f}}let i=n.find(o=>!o.startsWith("-"));if(i){let o=le(e,i);if(!t.vfs.exists(o))return{stderr:`node: cannot open file '${i}': No such file or directory
141
- `,exitCode:1};let a=t.vfs.readFile(o),{stdout:c,stderr:f,exitCode:l}=wA(a);return{stdout:c||void 0,stderr:f||void 0,exitCode:l}}return{stdout:[`Welcome to Node.js ${Ms}.`,'Type ".exit" to exit the REPL.',"> "].join(`
142
- `),exitCode:0}}};var Qs="9.2.0",IA="18.19.0",hd={name:"npm",description:"Node.js package manager (virtual)",category:"system",params:["<command> [args]"],run:({args:n,shell:t})=>{if(!t.packageManager.isInstalled("npm"))return{stderr:`bash: npm: command not found
146
+ `,exitCode:1};let a=t.vfs.readFile(o),{stdout:c,stderr:f,exitCode:l}=NA(a);return{stdout:c||void 0,stderr:f||void 0,exitCode:l}}return{stdout:[`Welcome to Node.js ${Qs}.`,'Type ".exit" to exit the REPL.',"> "].join(`
147
+ `),exitCode:0}}};var Ks="9.2.0",PA="18.19.0",Ed={name:"npm",description:"Node.js package manager (virtual)",category:"system",params:["<command> [args]"],run:({args:n,shell:t})=>{if(!t.packageManager.isInstalled("npm"))return{stderr:`bash: npm: command not found
143
148
  Hint: install it with: apt install npm
144
- `,exitCode:127};if(se(n,["--version","-v"]))return{stdout:`${Qs}
145
- `,exitCode:0};let e=n[0]?.toLowerCase();switch(e){case"version":case"-version":return{stdout:`{ npm: '${Qs}', node: '${IA}', v8: '10.2.154.26' }
149
+ `,exitCode:127};if(se(n,["--version","-v"]))return{stdout:`${Ks}
150
+ `,exitCode:0};let e=n[0]?.toLowerCase();switch(e){case"version":case"-version":return{stdout:`{ npm: '${Ks}', node: '${PA}', v8: '10.2.154.26' }
146
151
  `,exitCode:0};case"install":case"i":case"add":return{stderr:`npm warn: package installation is not available in the virtual runtime.
147
152
  npm warn: This environment simulates npm CLI behaviour only.
148
153
  `,exitCode:1};case"run":case"exec":case"x":return{stderr:`npm error: script execution is not available in the virtual runtime.
149
154
  `,exitCode:1};case"init":return{stdout:`Wrote to /home/user/package.json
150
155
  `,exitCode:0};case"list":case"ls":return{stdout:`${e==="ls"||e==="list"?"virtual-env@1.0.0":""}
151
156
  \u2514\u2500\u2500 (empty)
152
- `,exitCode:0};case"help":case void 0:return{stdout:`${[`npm ${Qs}`,"","Usage: npm <command>","","Commands:"," install (not available in virtual runtime)"," run (not available in virtual runtime)"," exec (not available in virtual runtime)"," list List installed packages"," version Print versions"," --version Print npm version"].join(`
157
+ `,exitCode:0};case"help":case void 0:return{stdout:`${[`npm ${Ks}`,"","Usage: npm <command>","","Commands:"," install (not available in virtual runtime)"," run (not available in virtual runtime)"," exec (not available in virtual runtime)"," list List installed packages"," version Print versions"," --version Print npm version"].join(`
153
158
  `)}
154
159
  `,exitCode:0};default:return{stderr:`npm error: unknown command: ${e}
155
- `,exitCode:1}}}},pd={name:"npx",description:"Node.js package runner (virtual)",category:"system",params:["<package> [args]"],run:({args:n,shell:t})=>t.packageManager.isInstalled("npm")?se(n,["--version"])?{stdout:`${Qs}
160
+ `,exitCode:1}}}},yd={name:"npx",description:"Node.js package runner (virtual)",category:"system",params:["<package> [args]"],run:({args:n,shell:t})=>t.packageManager.isInstalled("npm")?se(n,["--version"])?{stdout:`${Ks}
156
161
  `,exitCode:0}:{stderr:`npx: package execution is not available in the virtual runtime.
157
162
  `,exitCode:1}:{stderr:`bash: npx: command not found
158
163
  Hint: install it with: apt install npm
159
- `,exitCode:127}};var gd={name:"passwd",description:"Change user password",category:"users",params:["[username]"],run:async({authUser:n,args:t,shell:e,stdin:r})=>{let s=t[0]??n;if(n!=="root"&&n!==s)return{stderr:"passwd: permission denied",exitCode:1};if(!e.users.listUsers().includes(s))return{stderr:`passwd: user '${s}' does not exist`,exitCode:1};if(r!==void 0&&r.trim().length>0){let i=r.trim().split(`
164
+ `,exitCode:127}};var _d={name:"passwd",description:"Change user password",category:"users",params:["[username]"],run:async({authUser:n,args:t,shell:e,stdin:r})=>{let s=t[0]??n;if(n!=="root"&&n!==s)return{stderr:"passwd: permission denied",exitCode:1};if(!e.users.listUsers().includes(s))return{stderr:`passwd: user '${s}' does not exist`,exitCode:1};if(r!==void 0&&r.trim().length>0){let i=r.trim().split(`
160
165
  `)[0];return await e.users.setPassword(s,i),{stdout:`passwd: password updated successfully
161
- `,exitCode:0}}return{passwordChallenge:{prompt:"New password: ",confirmPrompt:"Retype new password: ",action:"passwd",targetUsername:s},exitCode:0}}};var md={name:"ping",description:"Send ICMP ECHO_REQUEST (mock)",category:"network",params:["[-c <count>] <host>"],run:({args:n})=>{let{flagsWithValues:t,positionals:e}=Yt(n,{flagsWithValue:["-c","-i","-W"]}),r=e[0]??"localhost",s=t.get("-c"),i=s?Math.max(1,parseInt(s,10)||4):4,o=[`PING ${r}: 56 data bytes`];for(let a=0;a<i;a++){let c=(Math.random()*10+1).toFixed(3);o.push(`64 bytes from ${r}: icmp_seq=${a} ttl=64 time=${c} ms`)}return o.push(`--- ${r} ping statistics ---`),o.push(`${i} packets transmitted, ${i} received, 0% packet loss`),{stdout:o.join(`
162
- `),exitCode:0}}};function CA(n,t){let e=0,r="",s=0;for(;s<n.length;){if(n[s]==="\\"&&s+1<n.length)switch(n[s+1]){case"n":r+=`
163
- `,s+=2;continue;case"t":r+=" ",s+=2;continue;case"r":r+="\r",s+=2;continue;case"\\":r+="\\",s+=2;continue;case"a":r+="\x07",s+=2;continue;case"b":r+="\b",s+=2;continue;case"f":r+="\f",s+=2;continue;case"v":r+="\v",s+=2;continue;default:r+=n[s],s++;continue}if(n[s]==="%"&&s+1<n.length){let i=s+1,o=!1;n[i]==="-"&&(o=!0,i++);let a=!1;n[i]==="0"&&(a=!0,i++);let c=0;for(;i<n.length&&/\d/.test(n[i]);)c=c*10+parseInt(n[i],10),i++;let f=-1;if(n[i]===".")for(i++,f=0;i<n.length&&/\d/.test(n[i]);)f=f*10+parseInt(n[i],10),i++;let l=n[i],u=t[e++]??"",h=(p,y=" ")=>{if(c<=0||p.length>=c)return p;let E=y.repeat(c-p.length);return o?p+E:E+p};switch(l){case"s":{let p=String(u);f>=0&&(p=p.slice(0,f)),r+=h(p);break}case"d":case"i":r+=h(String(parseInt(u,10)||0),a?"0":" ");break;case"f":{let p=f>=0?f:6;r+=h((parseFloat(u)||0).toFixed(p));break}case"o":r+=h((parseInt(u,10)||0).toString(8),a?"0":" ");break;case"x":r+=h((parseInt(u,10)||0).toString(16),a?"0":" ");break;case"X":r+=h((parseInt(u,10)||0).toString(16).toUpperCase(),a?"0":" ");break;case"%":r+="%",e--;break;default:r+=n[s],s++;continue}s=i+1;continue}r+=n[s],s++}return r}var Ad={name:"printf",description:"Format and print data",category:"shell",params:["<format> [args...]"],run:({args:n})=>{let t=n[0];return t?{stdout:CA(t,n.slice(1)),exitCode:0}:{stderr:"printf: missing format string",exitCode:1}}};var Ed={name:"ps",description:"Report process status",category:"system",params:["[-a] [-u] [-x] [aux]"],run:({authUser:n,shell:t,args:e})=>{let r=t.users.listActiveSessions(),s=se(e,["-u"])||e.includes("u")||e.includes("aux")||e.includes("au"),i=se(e,["-a","-x"])||e.includes("a")||e.includes("aux");if(s){let l=["USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND"],u=1e3;for(let h of r){let p=h.username.padEnd(10).slice(0,10),y=(Math.random()*.5).toFixed(1),E=Math.floor(Math.random()*2e4+5e3),x=Math.floor(Math.random()*5e3+1e3);l.push(`${p} ${String(u).padStart(6)} 0.0 ${y.padStart(4)} ${String(E).padStart(6)} ${String(x).padStart(5)} ${h.tty.padEnd(8)} Ss 00:00 0:00 bash`),u++}return l.push(`root ${String(u).padStart(6)} 0.0 0.0 0 0 ? S 00:00 0:00 ps`),{stdout:l.join(`
166
+ `,exitCode:0}}return{passwordChallenge:{prompt:"New password: ",confirmPrompt:"Retype new password: ",action:"passwd",targetUsername:s},exitCode:0}}};var bd={name:"ping",description:"Send ICMP ECHO_REQUEST (mock)",category:"network",params:["[-c <count>] <host>"],run:({args:n})=>{let{flagsWithValues:t,positionals:e}=jt(n,{flagsWithValue:["-c","-i","-W"]}),r=e[0]??"localhost",s=t.get("-c"),i=s?Math.max(1,parseInt(s,10)||4):4,o=[`PING ${r}: 56 data bytes`];for(let a=0;a<i;a++){let c=(Math.random()*10+1).toFixed(3);o.push(`64 bytes from ${r}: icmp_seq=${a} ttl=64 time=${c} ms`)}return o.push(`--- ${r} ping statistics ---`),o.push(`${i} packets transmitted, ${i} received, 0% packet loss`),{stdout:o.join(`
167
+ `),exitCode:0}}};function TA(n,t){let e=0,r="",s=0;for(;s<n.length;){if(n[s]==="\\"&&s+1<n.length)switch(n[s+1]){case"n":r+=`
168
+ `,s+=2;continue;case"t":r+=" ",s+=2;continue;case"r":r+="\r",s+=2;continue;case"\\":r+="\\",s+=2;continue;case"a":r+="\x07",s+=2;continue;case"b":r+="\b",s+=2;continue;case"f":r+="\f",s+=2;continue;case"v":r+="\v",s+=2;continue;default:r+=n[s],s++;continue}if(n[s]==="%"&&s+1<n.length){let i=s+1,o=!1;n[i]==="-"&&(o=!0,i++);let a=!1;n[i]==="0"&&(a=!0,i++);let c=0;for(;i<n.length&&/\d/.test(n[i]);)c=c*10+parseInt(n[i],10),i++;let f=-1;if(n[i]===".")for(i++,f=0;i<n.length&&/\d/.test(n[i]);)f=f*10+parseInt(n[i],10),i++;let l=n[i],u=t[e++]??"",h=(p,y=" ")=>{if(c<=0||p.length>=c)return p;let E=y.repeat(c-p.length);return o?p+E:E+p};switch(l){case"s":{let p=String(u);f>=0&&(p=p.slice(0,f)),r+=h(p);break}case"d":case"i":r+=h(String(parseInt(u,10)||0),a?"0":" ");break;case"f":{let p=f>=0?f:6;r+=h((parseFloat(u)||0).toFixed(p));break}case"o":r+=h((parseInt(u,10)||0).toString(8),a?"0":" ");break;case"x":r+=h((parseInt(u,10)||0).toString(16),a?"0":" ");break;case"X":r+=h((parseInt(u,10)||0).toString(16).toUpperCase(),a?"0":" ");break;case"%":r+="%",e--;break;default:r+=n[s],s++;continue}s=i+1;continue}r+=n[s],s++}return r}var xd={name:"printf",description:"Format and print data",category:"shell",params:["<format> [args...]"],run:({args:n})=>{let t=n[0];return t?{stdout:TA(t,n.slice(1)),exitCode:0}:{stderr:"printf: missing format string",exitCode:1}}};var Sd={name:"ps",description:"Report process status",category:"system",params:["[-a] [-u] [-x] [aux]"],run:({authUser:n,shell:t,args:e})=>{let r=t.users.listActiveSessions(),s=se(e,["-u"])||e.includes("u")||e.includes("aux")||e.includes("au"),i=se(e,["-a","-x"])||e.includes("a")||e.includes("aux");if(s){let l=["USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND"],u=1e3;for(let h of r){let p=h.username.padEnd(10).slice(0,10),y=(Math.random()*.5).toFixed(1),E=Math.floor(Math.random()*2e4+5e3),b=Math.floor(Math.random()*5e3+1e3);l.push(`${p} ${String(u).padStart(6)} 0.0 ${y.padStart(4)} ${String(E).padStart(6)} ${String(b).padStart(5)} ${h.tty.padEnd(8)} Ss 00:00 0:00 bash`),u++}return l.push(`root ${String(u).padStart(6)} 0.0 0.0 0 0 ? S 00:00 0:00 ps`),{stdout:l.join(`
164
169
  `),exitCode:0}}let a=[" PID TTY TIME CMD"],c=1e3;for(let f of r)!i&&f.username!==n||(a.push(`${String(c).padStart(5)} ${f.tty.padEnd(12)} 00:00:00 ${f.username===n?"bash":`bash (${f.username})`}`),c++);return a.push(`${String(c).padStart(5)} pts/0 00:00:00 ps`),{stdout:a.join(`
165
- `),exitCode:0}}};var _d={name:"pwd",description:"Print working directory",category:"navigation",params:[],run:({cwd:n})=>({stdout:n,exitCode:0})};var kA="Python 3.11.2";var Ws="3.11.2 (default, Mar 13 2023, 12:18:29) [GCC 12.2.0]",G={__pytype__:"none"};function At(n=[]){return{__pytype__:"dict",data:new Map(n)}}function Ja(n,t,e=1){return{__pytype__:"range",start:n,stop:t,step:e}}function pt(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="dict"}function qr(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="range"}function In(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="func"}function Za(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="class"}function Ni(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="instance"}function On(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="none"}function Bt(n){return n===null||On(n)?"None":n===!0?"True":n===!1?"False":typeof n=="number"?Number.isInteger(n)?String(n):n.toPrecision(12).replace(/\.?0+$/,""):typeof n=="string"?`'${n.replace(/'/g,"\\'")}'`:Array.isArray(n)?`[${n.map(Bt).join(", ")}]`:pt(n)?`{${[...n.data.entries()].map(([t,e])=>`'${t}': ${Bt(e)}`).join(", ")}}`:qr(n)?`range(${n.start}, ${n.stop}${n.step!==1?`, ${n.step}`:""})`:In(n)?`<function ${n.name} at 0x...>`:Za(n)?`<class '${n.name}'>`:Ni(n)?`<${n.cls.name} object at 0x...>`:String(n)}function Ne(n){return n===null||On(n)?"None":n===!0?"True":n===!1?"False":typeof n=="number"?Number.isInteger(n)?String(n):n.toPrecision(12).replace(/\.?0+$/,""):typeof n=="string"?n:Array.isArray(n)?`[${n.map(Bt).join(", ")}]`:pt(n)?`{${[...n.data.entries()].map(([t,e])=>`'${t}': ${Bt(e)}`).join(", ")}}`:qr(n)?`range(${n.start}, ${n.stop}${n.step!==1?`, ${n.step}`:""})`:Bt(n)}function an(n){return n===null||On(n)?!1:typeof n=="boolean"?n:typeof n=="number"?n!==0:typeof n=="string"||Array.isArray(n)?n.length>0:pt(n)?n.data.size>0:qr(n)?bd(n)>0:!0}function bd(n){if(n.step===0)return 0;let t=Math.ceil((n.stop-n.start)/n.step);return Math.max(0,t)}function vA(n){let t=[];for(let e=n.start;(n.step>0?e<n.stop:e>n.stop)&&(t.push(e),!(t.length>1e4));e+=n.step);return t}function vt(n){if(Array.isArray(n))return n;if(typeof n=="string")return[...n];if(qr(n))return vA(n);if(pt(n))return[...n.data.keys()];throw new mt("TypeError",`'${fr(n)}' object is not iterable`)}function fr(n){return n===null||On(n)?"NoneType":typeof n=="boolean"?"bool":typeof n=="number"?Number.isInteger(n)?"int":"float":typeof n=="string"?"str":Array.isArray(n)?"list":pt(n)?"dict":qr(n)?"range":In(n)?"function":Za(n)?"type":Ni(n)?n.cls.name:"object"}var mt=class{constructor(t,e){this.type=t;this.message=e}type;message;toString(){return`${this.type}: ${this.message}`}},Wr=class{constructor(t){this.value=t}value},Pi=class{},Ti=class{},Li=class{constructor(t){this.code=t}code};function BA(n){let t=new Map,e=At([["sep","/"],["linesep",`
166
- `],["curdir","."],["pardir",".."]]);return e.__methods__={getcwd:()=>n,getenv:r=>typeof r=="string"?process.env[r]??G:G,path:At([["join",G],["exists",G],["dirname",G],["basename",G]]),listdir:()=>[]},t.set("__builtins__",G),t.set("__name__","__main__"),t.set("__cwd__",n),t}function RA(n){let t=At([["sep","/"],["curdir","."]]),e=At([["sep","/"],["linesep",`
167
- `],["name","posix"]]);return e._cwd=n,t._cwd=n,e.path=t,e}function NA(){return At([["version",Ws],["version_info",At([["major",3],["minor",11],["micro",2]].map(([n,t])=>[n,t]))],["platform","linux"],["executable","/usr/bin/python3"],["prefix","/usr"],["path",["/usr/lib/python3.11","/usr/lib/python3.11/lib-dynload"]],["argv",[""]],["maxsize",9007199254740991]])}function PA(){return At([["pi",Math.PI],["e",Math.E],["tau",Math.PI*2],["inf",1/0],["nan",NaN],["sqrt",G],["floor",G],["ceil",G],["log",G],["pow",G],["sin",G],["cos",G],["tan",G],["fabs",G],["factorial",G]])}function TA(){return At([["dumps",G],["loads",G]])}function LA(){return At([["match",G],["search",G],["findall",G],["sub",G],["split",G],["compile",G]])}var yd={os:RA,sys:()=>NA(),math:()=>PA(),json:()=>TA(),re:()=>LA(),random:()=>At([["random",G],["randint",G],["choice",G],["shuffle",G]]),time:()=>At([["time",G],["sleep",G],["ctime",G]]),datetime:()=>At([["datetime",G],["date",G],["timedelta",G]]),collections:()=>At([["Counter",G],["defaultdict",G],["OrderedDict",G]]),itertools:()=>At([["chain",G],["product",G],["combinations",G],["permutations",G]]),functools:()=>At([["reduce",G],["partial",G],["lru_cache",G]]),string:()=>At([["ascii_letters","abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"],["digits","0123456789"],["punctuation","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"]])},qs=class{constructor(t){this.cwd=t}cwd;output=[];stderr=[];modules=new Map;getOutput(){return this.output.join(`
170
+ `),exitCode:0}}};var wd={name:"pwd",description:"Print working directory",category:"navigation",params:[],run:({cwd:n})=>({stdout:n,exitCode:0})};var LA="Python 3.11.2";var Vs="3.11.2 (default, Mar 13 2023, 12:18:29) [GCC 12.2.0]",G={__pytype__:"none"};function yt(n=[]){return{__pytype__:"dict",data:new Map(n)}}function nc(n,t,e=1){return{__pytype__:"range",start:n,stop:t,step:e}}function mt(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="dict"}function Kr(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="range"}function kn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="func"}function rc(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="class"}function Li(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="instance"}function Mn(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&n.__pytype__==="none"}function Rt(n){return n===null||Mn(n)?"None":n===!0?"True":n===!1?"False":typeof n=="number"?Number.isInteger(n)?String(n):n.toPrecision(12).replace(/\.?0+$/,""):typeof n=="string"?`'${n.replace(/'/g,"\\'")}'`:Array.isArray(n)?`[${n.map(Rt).join(", ")}]`:mt(n)?`{${[...n.data.entries()].map(([t,e])=>`'${t}': ${Rt(e)}`).join(", ")}}`:Kr(n)?`range(${n.start}, ${n.stop}${n.step!==1?`, ${n.step}`:""})`:kn(n)?`<function ${n.name} at 0x...>`:rc(n)?`<class '${n.name}'>`:Li(n)?`<${n.cls.name} object at 0x...>`:String(n)}function Ne(n){return n===null||Mn(n)?"None":n===!0?"True":n===!1?"False":typeof n=="number"?Number.isInteger(n)?String(n):n.toPrecision(12).replace(/\.?0+$/,""):typeof n=="string"?n:Array.isArray(n)?`[${n.map(Rt).join(", ")}]`:mt(n)?`{${[...n.data.entries()].map(([t,e])=>`'${t}': ${Rt(e)}`).join(", ")}}`:Kr(n)?`range(${n.start}, ${n.stop}${n.step!==1?`, ${n.step}`:""})`:Rt(n)}function fn(n){return n===null||Mn(n)?!1:typeof n=="boolean"?n:typeof n=="number"?n!==0:typeof n=="string"||Array.isArray(n)?n.length>0:mt(n)?n.data.size>0:Kr(n)?Cd(n)>0:!0}function Cd(n){if(n.step===0)return 0;let t=Math.ceil((n.stop-n.start)/n.step);return Math.max(0,t)}function UA(n){let t=[];for(let e=n.start;(n.step>0?e<n.stop:e>n.stop)&&(t.push(e),!(t.length>1e4));e+=n.step);return t}function Bt(n){if(Array.isArray(n))return n;if(typeof n=="string")return[...n];if(Kr(n))return UA(n);if(mt(n))return[...n.data.keys()];throw new Et("TypeError",`'${ur(n)}' object is not iterable`)}function ur(n){return n===null||Mn(n)?"NoneType":typeof n=="boolean"?"bool":typeof n=="number"?Number.isInteger(n)?"int":"float":typeof n=="string"?"str":Array.isArray(n)?"list":mt(n)?"dict":Kr(n)?"range":kn(n)?"function":rc(n)?"type":Li(n)?n.cls.name:"object"}var Et=class{constructor(t,e){this.type=t;this.message=e}type;message;toString(){return`${this.type}: ${this.message}`}},qr=class{constructor(t){this.value=t}value},Ui=class{},Di=class{},$i=class{constructor(t){this.code=t}code};function DA(n){let t=new Map,e=yt([["sep","/"],["linesep",`
171
+ `],["curdir","."],["pardir",".."]]);return e.__methods__={getcwd:()=>n,getenv:r=>typeof r=="string"?process.env[r]??G:G,path:yt([["join",G],["exists",G],["dirname",G],["basename",G]]),listdir:()=>[]},t.set("__builtins__",G),t.set("__name__","__main__"),t.set("__cwd__",n),t}function $A(n){let t=yt([["sep","/"],["curdir","."]]),e=yt([["sep","/"],["linesep",`
172
+ `],["name","posix"]]);return e._cwd=n,t._cwd=n,e.path=t,e}function OA(){return yt([["version",Vs],["version_info",yt([["major",3],["minor",11],["micro",2]].map(([n,t])=>[n,t]))],["platform","linux"],["executable","/usr/bin/python3"],["prefix","/usr"],["path",["/usr/lib/python3.11","/usr/lib/python3.11/lib-dynload"]],["argv",[""]],["maxsize",9007199254740991]])}function MA(){return yt([["pi",Math.PI],["e",Math.E],["tau",Math.PI*2],["inf",1/0],["nan",NaN],["sqrt",G],["floor",G],["ceil",G],["log",G],["pow",G],["sin",G],["cos",G],["tan",G],["fabs",G],["factorial",G]])}function FA(){return yt([["dumps",G],["loads",G]])}function HA(){return yt([["match",G],["search",G],["findall",G],["sub",G],["split",G],["compile",G]])}var Id={os:$A,sys:()=>OA(),math:()=>MA(),json:()=>FA(),re:()=>HA(),random:()=>yt([["random",G],["randint",G],["choice",G],["shuffle",G]]),time:()=>yt([["time",G],["sleep",G],["ctime",G]]),datetime:()=>yt([["datetime",G],["date",G],["timedelta",G]]),collections:()=>yt([["Counter",G],["defaultdict",G],["OrderedDict",G]]),itertools:()=>yt([["chain",G],["product",G],["combinations",G],["permutations",G]]),functools:()=>yt([["reduce",G],["partial",G],["lru_cache",G]]),string:()=>yt([["ascii_letters","abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"],["digits","0123456789"],["punctuation","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"]])},Gs=class{constructor(t){this.cwd=t}cwd;output=[];stderr=[];modules=new Map;getOutput(){return this.output.join(`
168
173
  `)+(this.output.length?`
169
174
  `:"")}getStderr(){return this.stderr.join(`
170
175
  `)+(this.stderr.length?`
171
176
  `:"")}splitArgs(t){let e=[],r=0,s="",i=!1,o="";for(let a=0;a<t.length;a++){let c=t[a];i?(s+=c,c===o&&t[a-1]!=="\\"&&(i=!1)):c==='"'||c==="'"?(i=!0,o=c,s+=c):"([{".includes(c)?(r++,s+=c):")]}".includes(c)?(r--,s+=c):c===","&&r===0?(e.push(s.trim()),s=""):s+=c}return s.trim()&&e.push(s.trim()),e}pyEval(t,e){if(t=t.trim(),!t||t==="None")return G;if(t==="True")return!0;if(t==="False")return!1;if(t==="...")return G;if(/^-?\d+$/.test(t))return parseInt(t,10);if(/^-?\d+\.\d*$/.test(t))return parseFloat(t);if(/^0x[0-9a-fA-F]+$/.test(t))return parseInt(t,16);if(/^0o[0-7]+$/.test(t))return parseInt(t.slice(2),8);if(/^('''[\s\S]*'''|"""[\s\S]*""")$/.test(t))return t.slice(3,-3);if(/^(['"])(.*)\1$/s.test(t))return t.slice(1,-1).replace(/\\n/g,`
172
- `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');let r=t.match(/^f(['"])([\s\S]*)\1$/);if(r){let f=r[2];return f=f.replace(/\{([^{}]+)\}/g,(l,u)=>{try{return Ne(this.pyEval(u.trim(),e))}catch{return`{${u}}`}}),f}let s=t.match(/^b(['"])(.*)\1$/s);if(s)return s[2];if(t.startsWith("[")&&t.endsWith("]")){let f=t.slice(1,-1).trim();if(!f)return[];let l=f.match(/^(.+?)\s+for\s+(\w+)\s+in\s+(.+?)(?:\s+if\s+(.+))?$/);if(l){let[,u,h,p,y]=l,E=vt(this.pyEval(p.trim(),e)),x=[];for(let k of E){let D=new Map(e);D.set(h,k),!(y&&!an(this.pyEval(y,D)))&&x.push(this.pyEval(u.trim(),D))}return x}return this.splitArgs(f).map(u=>this.pyEval(u,e))}if(t.startsWith("(")&&t.endsWith(")")){let f=t.slice(1,-1).trim();if(!f)return[];let l=this.splitArgs(f);return l.length===1&&!f.endsWith(",")?this.pyEval(l[0],e):l.map(u=>this.pyEval(u,e))}if(t.startsWith("{")&&t.endsWith("}")){let f=t.slice(1,-1).trim();if(!f)return At();let l=At();for(let u of this.splitArgs(f)){let h=u.indexOf(":");if(h===-1)continue;let p=Ne(this.pyEval(u.slice(0,h).trim(),e)),y=this.pyEval(u.slice(h+1).trim(),e);l.data.set(p,y)}return l}let i=t.match(/^not\s+(.+)$/);if(i)return!an(this.pyEval(i[1],e));let o=[["or"],["and"],["in","not in","is not","is","==","!=","<=",">=","<",">"],["+","-"],["**"],["*","//","/","%"]];for(let f of o){let l=this.tryBinaryOp(t,f,e);if(l!==void 0)return l}if(t.startsWith("-")){let f=this.pyEval(t.slice(1),e);if(typeof f=="number")return-f}if(process.env.PY_DEBUG&&console.error("eval:",JSON.stringify(t)),t.endsWith("]")&&!t.startsWith("[")){let f=this.findMatchingBracket(t,"[");if(f!==-1){let l=this.pyEval(t.slice(0,f),e),u=t.slice(f+1,-1);return this.subscript(l,u,e)}}let a=t.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/);if(a){let[,f,l]=a,u=(l?.trim()?this.splitArgs(l):[]).map(h=>this.pyEval(h,e));return this.callBuiltin(f,u,e)}let c=this.findDotAccess(t);if(c){let{objExpr:f,attr:l,callPart:u}=c,h=this.pyEval(f,e);if(u!==void 0){let p=u.slice(1,-1),y=p.trim()?this.splitArgs(p).map(E=>this.pyEval(E,e)):[];return this.callMethod(h,l,y,e)}return this.getAttr(h,l,e)}if(/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)){if(e.has(t))return e.get(t);throw new mt("NameError",`name '${t}' is not defined`)}if(/^[A-Za-z_][A-Za-z0-9_.]+$/.test(t)){let f=t.split("."),l=e.get(f[0])??(()=>{throw new mt("NameError",`name '${f[0]}' is not defined`)})();for(let u of f.slice(1))l=this.getAttr(l,u,e);return l}return G}findMatchingBracket(t,e){let r=e==="["?"]":e==="("?")":"}",s=0;for(let i=t.length-1;i>=0;i--)if(t[i]===r&&s++,t[i]===e&&(s--,s===0))return i;return-1}findDotAccess(t){let e=0,r=!1,s="";for(let i=t.length-1;i>0;i--){let o=t[i];if(r){o===s&&t[i-1]!=="\\"&&(r=!1);continue}if(o==='"'||o==="'"){r=!0,s=o;continue}if(")]}".includes(o)){e++;continue}if("([{".includes(o)){e--;continue}if(e!==0||o!==".")continue;let a=t.slice(0,i).trim(),f=t.slice(i+1).match(/^(\w+)(\([\s\S]*\))?$/);if(f&&!/^-?\d+$/.test(a))return{objExpr:a,attr:f[1],callPart:f[2]}}return null}tryBinaryOp(t,e,r){let s=0,i=!1,o="";for(let a=t.length-1;a>=0;a--){let c=t[a];if(i){c===o&&t[a-1]!=="\\"&&(i=!1);continue}if(c==='"'||c==="'"){i=!0,o=c;continue}if(")]}".includes(c)){s++;continue}if("([{".includes(c)){s--;continue}if(s===0){for(let f of e)if(t.slice(a,a+f.length)===f){if(f==="*"&&(t[a+1]==="*"||t[a-1]==="*"))continue;let l=t[a-1],u=t[a+f.length];if(/^[a-z]/.test(f)&&(l&&/\w/.test(l)||u&&/\w/.test(u)))continue;let p=t.slice(0,a).trim(),y=t.slice(a+f.length).trim();if(!p||!y)continue;return this.applyBinaryOp(f,p,y,r)}}}}applyBinaryOp(t,e,r,s){if(t==="and"){let a=this.pyEval(e,s);return an(a)?this.pyEval(r,s):a}if(t==="or"){let a=this.pyEval(e,s);return an(a)?a:this.pyEval(r,s)}let i=this.pyEval(e,s),o=this.pyEval(r,s);switch(t){case"+":return typeof i=="string"&&typeof o=="string"?i+o:Array.isArray(i)&&Array.isArray(o)?[...i,...o]:i+o;case"-":return i-o;case"*":if(typeof i=="string"&&typeof o=="number")return i.repeat(o);if(Array.isArray(i)&&typeof o=="number"){let a=[];for(let c=0;c<o;c++)a.push(...i);return a}return i*o;case"/":{if(o===0)throw new mt("ZeroDivisionError","division by zero");return i/o}case"//":{if(o===0)throw new mt("ZeroDivisionError","integer division or modulo by zero");return Math.floor(i/o)}case"%":{if(typeof i=="string")return this.pyStringFormat(i,Array.isArray(o)?o:[o]);if(o===0)throw new mt("ZeroDivisionError","integer division or modulo by zero");return i%o}case"**":return i**o;case"==":return Bt(i)===Bt(o)||i===o;case"!=":return Bt(i)!==Bt(o)&&i!==o;case"<":return i<o;case"<=":return i<=o;case">":return i>o;case">=":return i>=o;case"in":return this.pyIn(o,i);case"not in":return!this.pyIn(o,i);case"is":return i===o||On(i)&&On(o);case"is not":return!(i===o||On(i)&&On(o))}return G}pyIn(t,e){return typeof t=="string"?typeof e=="string"&&t.includes(e):Array.isArray(t)?t.some(r=>Bt(r)===Bt(e)):pt(t)?t.data.has(Ne(e)):!1}subscript(t,e,r){if(e.includes(":")){let i=e.split(":").map(c=>c.trim()),o=i[0]?this.pyEval(i[0],r):void 0,a=i[1]?this.pyEval(i[1],r):void 0;return typeof t=="string"||Array.isArray(t)?t.slice(o,a):G}let s=this.pyEval(e,r);if(Array.isArray(t)){let i=s;return i<0&&(i=t.length+i),t[i]??G}if(typeof t=="string"){let i=s;return i<0&&(i=t.length+i),t[i]??G}if(pt(t))return t.data.get(Ne(s))??G;throw new mt("TypeError",`'${fr(t)}' is not subscriptable`)}getAttr(t,e,r){return pt(t)?t.data.has(e)?t.data.get(e):e==="path"&&t.path?t.path:G:Ni(t)?t.attrs.get(e)??G:typeof t=="string"?{__class__:{__pytype__:"class",name:"str"}}[e]??G:G}callMethod(t,e,r,s){if(typeof t=="string")switch(e){case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();case"strip":return(r[0]?t.replace(new RegExp(`[${r[0]}]+`,"g"),""):t).trim();case"lstrip":return t.trimStart();case"rstrip":return t.trimEnd();case"split":return t.split(typeof r[0]=="string"?r[0]:/\s+/).filter((i,o)=>o>0||i!=="");case"splitlines":return t.split(`
173
- `);case"join":return vt(r[0]??[]).map(Ne).join(t);case"replace":return t.replaceAll(Ne(r[0]??""),Ne(r[1]??""));case"startswith":return t.startsWith(Ne(r[0]??""));case"endswith":return t.endsWith(Ne(r[0]??""));case"find":return t.indexOf(Ne(r[0]??""));case"index":{let i=t.indexOf(Ne(r[0]??""));if(i===-1)throw new mt("ValueError","substring not found");return i}case"count":return t.split(Ne(r[0]??"")).length-1;case"format":return this.pyStringFormat(t,r);case"encode":return t;case"decode":return t;case"isdigit":return/^\d+$/.test(t);case"isalpha":return/^[a-zA-Z]+$/.test(t);case"isalnum":return/^[a-zA-Z0-9]+$/.test(t);case"isspace":return/^\s+$/.test(t);case"isupper":return t===t.toUpperCase()&&t!==t.toLowerCase();case"islower":return t===t.toLowerCase()&&t!==t.toUpperCase();case"center":{let i=r[0]??0,o=Ne(r[1]??" ");return t.padStart(Math.floor((i+t.length)/2),o).padEnd(i,o)}case"ljust":return t.padEnd(r[0]??0,Ne(r[1]??" "));case"rjust":return t.padStart(r[0]??0,Ne(r[1]??" "));case"zfill":return t.padStart(r[0]??0,"0");case"title":return t.replace(/\b\w/g,i=>i.toUpperCase());case"capitalize":return t[0]?.toUpperCase()+t.slice(1).toLowerCase();case"swapcase":return[...t].map(i=>i===i.toUpperCase()?i.toLowerCase():i.toUpperCase()).join("")}if(Array.isArray(t))switch(e){case"append":return t.push(r[0]??G),G;case"extend":for(let i of vt(r[0]??[]))t.push(i);return G;case"insert":return t.splice(r[0]??0,0,r[1]??G),G;case"pop":{let i=r[0]!==void 0?r[0]:-1,o=i<0?t.length+i:i;return t.splice(o,1)[0]??G}case"remove":{let i=t.findIndex(o=>Bt(o)===Bt(r[0]??G));return i!==-1&&t.splice(i,1),G}case"index":{let i=t.findIndex(o=>Bt(o)===Bt(r[0]??G));if(i===-1)throw new mt("ValueError","is not in list");return i}case"count":return t.filter(i=>Bt(i)===Bt(r[0]??G)).length;case"sort":return t.sort((i,o)=>typeof i=="number"&&typeof o=="number"?i-o:Ne(i).localeCompare(Ne(o))),G;case"reverse":return t.reverse(),G;case"copy":return[...t];case"clear":return t.splice(0),G}if(pt(t))switch(e){case"keys":return[...t.data.keys()];case"values":return[...t.data.values()];case"items":return[...t.data.entries()].map(([i,o])=>[i,o]);case"get":return t.data.get(Ne(r[0]??""))??r[1]??G;case"update":{if(pt(r[0]??G))for(let[i,o]of r[0].data)t.data.set(i,o);return G}case"pop":{let i=Ne(r[0]??""),o=t.data.get(i)??r[1]??G;return t.data.delete(i),o}case"clear":return t.data.clear(),G;case"copy":return At([...t.data.entries()]);case"setdefault":{let i=Ne(r[0]??"");return t.data.has(i)||t.data.set(i,r[1]??G),t.data.get(i)??G}}if(pt(t)&&t.data.has("name")&&t.data.get("name")==="posix")switch(e){case"getcwd":return this.cwd;case"getenv":return typeof r[0]=="string"?process.env[r[0]]??r[1]??G:G;case"listdir":return[];case"path":return t}if(pt(t))switch(e){case"join":return r.map(Ne).join("/").replace(/\/+/g,"/");case"exists":return!1;case"dirname":return Ne(r[0]??"").split("/").slice(0,-1).join("/")||"/";case"basename":return Ne(r[0]??"").split("/").pop()??"";case"abspath":return Ne(r[0]??"");case"splitext":{let i=Ne(r[0]??""),o=i.lastIndexOf(".");return o>0?[i.slice(0,o),i.slice(o)]:[i,""]}case"isfile":return!1;case"isdir":return!1}if(pt(t)&&t.data.has("version")&&t.data.get("version")===Ws&&e==="exit")throw new Li(r[0]??0);if(pt(t)){let i={sqrt:Math.sqrt,floor:Math.floor,ceil:Math.ceil,fabs:Math.abs,log:Math.log,log2:Math.log2,log10:Math.log10,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,pow:Math.pow,exp:Math.exp,hypot:Math.hypot};if(e in i){let o=i[e];return o(...r.map(a=>a))}if(e==="factorial"){let o=r[0]??0,a=1;for(;o>1;)a*=o--;return a}if(e==="gcd"){let o=Math.abs(r[0]??0),a=Math.abs(r[1]??0);for(;a;)[o,a]=[a,o%a];return o}}if(pt(t)){if(e==="dumps"){let i=pt(r[1]??G)?r[1]:void 0,o=i?i.data.get("indent"):void 0;return JSON.stringify(this.pyToJs(r[0]??G),null,o)}if(e==="loads")return this.jsToPy(JSON.parse(Ne(r[0]??"")))}if(Ni(t)){let i=t.attrs.get(e)??t.cls.methods.get(e)??G;if(In(i)){let o=new Map(i.closure);return o.set("self",t),i.params.slice(1).forEach((a,c)=>o.set(a,r[c]??G)),this.execBlock(i.body,o)}}throw new mt("AttributeError",`'${fr(t)}' object has no attribute '${e}'`)}pyStringFormat(t,e){let r=0;return t.replace(/%([diouxXeEfFgGcrs%])/g,(s,i)=>{if(i==="%")return"%";let o=e[r++];switch(i){case"d":case"i":return String(Math.trunc(o));case"f":return o.toFixed(6);case"s":return Ne(o??G);case"r":return Bt(o??G);default:return String(o)}})}pyToJs(t){return On(t)?null:pt(t)?Object.fromEntries([...t.data.entries()].map(([e,r])=>[e,this.pyToJs(r)])):Array.isArray(t)?t.map(e=>this.pyToJs(e)):t}jsToPy(t){return t==null?G:typeof t=="boolean"||typeof t=="number"||typeof t=="string"?t:Array.isArray(t)?t.map(e=>this.jsToPy(e)):typeof t=="object"?At(Object.entries(t).map(([e,r])=>[e,this.jsToPy(r)])):G}callBuiltin(t,e,r){if(r.has(t)){let s=r.get(t)??G;return In(s)?this.callFunc(s,e,r):Za(s)?this.instantiate(s,e,r):s}switch(t){case"print":return this.output.push(e.map(Ne).join(" ")+`
174
- `.replace(/\\n/g,"")),G;case"input":return this.output.push(Ne(e[0]??"")),"";case"int":{if(e.length===0)return 0;let s=e[1]??10,i=parseInt(Ne(e[0]??0),s);return Number.isNaN(i)?(()=>{throw new mt("ValueError","invalid literal for int()")})():i}case"float":{if(e.length===0)return 0;let s=parseFloat(Ne(e[0]??0));return Number.isNaN(s)?(()=>{throw new mt("ValueError","could not convert to float")})():s}case"str":return e.length===0?"":Ne(e[0]??G);case"bool":return e.length===0?!1:an(e[0]??G);case"list":return e.length===0?[]:vt(e[0]??[]);case"tuple":return e.length===0?[]:vt(e[0]??[]);case"set":return e.length===0?[]:[...new Set(vt(e[0]??[]).map(Bt))].map(s=>vt(e[0]??[]).find(o=>Bt(o)===s)??G);case"dict":return e.length===0?At():pt(e[0]??G)?e[0]:At();case"bytes":return typeof e[0]=="string"?e[0]:Ne(e[0]??"");case"bytearray":return e.length===0?"":Ne(e[0]??"");case"type":return e.length===1?`<class '${fr(e[0]??G)}'>`:G;case"isinstance":return fr(e[0]??G)===Ne(e[1]??"");case"issubclass":return!1;case"callable":return In(e[0]??G);case"hasattr":return pt(e[0]??G)?e[0].data.has(Ne(e[1]??"")):!1;case"getattr":return pt(e[0]??G)?e[0].data.get(Ne(e[1]??""))??e[2]??G:e[2]??G;case"setattr":return pt(e[0]??G)&&e[0].data.set(Ne(e[1]??""),e[2]??G),G;case"len":{let s=e[0]??G;if(typeof s=="string"||Array.isArray(s))return s.length;if(pt(s))return s.data.size;if(qr(s))return bd(s);throw new mt("TypeError",`object of type '${fr(s)}' has no len()`)}case"range":return e.length===1?Ja(0,e[0]):e.length===2?Ja(e[0],e[1]):Ja(e[0],e[1],e[2]);case"enumerate":{let s=e[1]??0;return vt(e[0]??[]).map((i,o)=>[o+s,i])}case"zip":{let s=e.map(vt),i=Math.min(...s.map(o=>o.length));return Array.from({length:i},(o,a)=>s.map(c=>c[a]??G))}case"map":{let s=e[0]??G;return vt(e[1]??[]).map(i=>In(s)?this.callFunc(s,[i],r):G)}case"filter":{let s=e[0]??G;return vt(e[1]??[]).filter(i=>In(s)?an(this.callFunc(s,[i],r)):an(i))}case"reduce":{let s=e[0]??G,i=vt(e[1]??[]);if(i.length===0)return e[2]??G;let o=e[2]!==void 0?e[2]:i[0];for(let a of e[2]!==void 0?i:i.slice(1))o=In(s)?this.callFunc(s,[o,a],r):G;return o}case"sorted":{let s=[...vt(e[0]??[])],i=e[1]??G,o=pt(i)?i.data.get("key")??G:i;return s.sort((a,c)=>{let f=In(o)?this.callFunc(o,[a],r):a,l=In(o)?this.callFunc(o,[c],r):c;return typeof f=="number"&&typeof l=="number"?f-l:Ne(f).localeCompare(Ne(l))}),s}case"reversed":return[...vt(e[0]??[])].reverse();case"any":return vt(e[0]??[]).some(an);case"all":return vt(e[0]??[]).every(an);case"sum":return vt(e[0]??[]).reduce((s,i)=>s+i,e[1]??0);case"max":return(e.length===1?vt(e[0]??[]):e).reduce((i,o)=>i>=o?i:o);case"min":return(e.length===1?vt(e[0]??[]):e).reduce((i,o)=>i<=o?i:o);case"abs":return Math.abs(e[0]??0);case"round":return e[1]!==void 0?parseFloat(e[0].toFixed(e[1])):Math.round(e[0]??0);case"divmod":{let s=e[0],i=e[1];return[Math.floor(s/i),s%i]}case"pow":return e[0]**e[1];case"hex":return`0x${e[0].toString(16)}`;case"oct":return`0o${e[0].toString(8)}`;case"bin":return`0b${e[0].toString(2)}`;case"ord":return Ne(e[0]??"").charCodeAt(0);case"chr":return String.fromCharCode(e[0]??0);case"id":return Math.floor(Math.random()*4294967295);case"hash":return typeof e[0]=="number"?e[0]:Ne(e[0]??"").split("").reduce((s,i)=>s*31+i.charCodeAt(0)|0,0);case"open":throw new mt("PermissionError","open() not available in virtual runtime");case"repr":return Bt(e[0]??G);case"iter":return e[0]??G;case"next":return Array.isArray(e[0])&&e[0].length>0?e[0].shift():e[1]??(()=>{throw new mt("StopIteration","")})();case"vars":return At([...r.entries()].map(([s,i])=>[s,i]));case"globals":return At([...r.entries()].map(([s,i])=>[s,i]));case"locals":return At([...r.entries()].map(([s,i])=>[s,i]));case"dir":{if(e.length===0)return[...r.keys()];let s=e[0]??G;return typeof s=="string"?["upper","lower","strip","split","join","replace","find","format","encode","startswith","endswith","count","isdigit","isalpha","title","capitalize"]:Array.isArray(s)?["append","extend","insert","pop","remove","index","count","sort","reverse","copy","clear"]:pt(s)?["keys","values","items","get","update","pop","clear","copy","setdefault"]:[]}case"Exception":case"ValueError":case"TypeError":case"KeyError":case"IndexError":case"AttributeError":case"NameError":case"RuntimeError":case"StopIteration":case"NotImplementedError":case"OSError":case"IOError":throw new mt(t,Ne(e[0]??""));case"exec":return this.execScript(Ne(e[0]??""),r),G;case"eval":return this.pyEval(Ne(e[0]??""),r);default:throw new mt("NameError",`name '${t}' is not defined`)}}callFunc(t,e,r){let s=new Map(t.closure);t.params.forEach((i,o)=>{if(i.startsWith("*")){s.set(i.slice(1),e.slice(o));return}s.set(i,e[o]??G)});try{return this.execBlock(t.body,s)}catch(i){if(i instanceof Wr)return i.value;throw i}}instantiate(t,e,r){let s={__pytype__:"instance",cls:t,attrs:new Map};return t.methods.get("__init__")&&this.callMethod(s,"__init__",e,r),s}execScript(t,e){let r=t.split(`
175
- `);this.execLines(r,0,e)}execLines(t,e,r){let s=e;for(;s<t.length;){let i=t[s];if(!i.trim()||i.trim().startsWith("#")){s++;continue}s=this.execStatement(t,s,r)}return s}execBlock(t,e){try{this.execLines(t,0,e)}catch(r){if(r instanceof Wr)return r.value;throw r}return G}getIndent(t){let e=0;for(let r of t)if(r===" ")e++;else if(r===" ")e+=4;else break;return e}collectBlock(t,e,r){let s=[];for(let i=e;i<t.length;i++){let o=t[i];if(!o.trim()){s.push("");continue}if(this.getIndent(o)<=r)break;s.push(o.slice(r+4))}return s}execStatement(t,e,r){let s=t[e],i=s.trim(),o=this.getIndent(s);if(i==="pass")return e+1;if(i==="break")throw new Pi;if(i==="continue")throw new Ti;let a=i.match(/^return(?:\s+(.+))?$/);if(a)throw new Wr(a[1]?this.pyEval(a[1],r):G);let c=i.match(/^raise(?:\s+(.+))?$/);if(c){if(c[1]){let N=this.pyEval(c[1],r);throw new mt(typeof N=="string"?N:fr(N),Ne(N))}throw new mt("RuntimeError","")}let f=i.match(/^assert\s+(.+?)(?:,\s*(.+))?$/);if(f){if(!an(this.pyEval(f[1],r)))throw new mt("AssertionError",f[2]?Ne(this.pyEval(f[2],r)):"");return e+1}let l=i.match(/^del\s+(.+)$/);if(l)return r.delete(l[1].trim()),e+1;let u=i.match(/^import\s+(\w+)(?:\s+as\s+(\w+))?$/);if(u){let[,N,b]=u,S=yd[N];if(S){let I=S(this.cwd);this.modules.set(N,I),r.set(b??N,I)}return e+1}let h=i.match(/^from\s+(\w+)\s+import\s+(.+)$/);if(h){let[,N,b]=h,S=yd[N];if(S){let I=S(this.cwd);if(b?.trim()==="*")for(let[v,R]of I.data)r.set(v,R);else for(let v of b.split(",").map(R=>R.trim()))r.set(v,I.data.get(v)??G)}return e+1}let p=i.match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(p){let[,N,b]=p,S=b.split(",").map(R=>R.trim()).filter(Boolean),I=this.collectBlock(t,e+1,o),v={__pytype__:"func",name:N,params:S,body:I,closure:new Map(r)};return r.set(N,v),e+1+I.length}let y=i.match(/^class\s+(\w+)(?:\(([^)]*)\))?\s*:$/);if(y){let[,N,b]=y,S=b?b.split(",").map(ne=>ne.trim()):[],I=this.collectBlock(t,e+1,o),v={__pytype__:"class",name:N,methods:new Map,bases:S},R=0;for(;R<I.length;){let z=I[R].trim().match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(z){let[,Y,te]=z,ce=te.split(",").map(B=>B.trim()).filter(Boolean),$=this.collectBlock(I,R+1,0);v.methods.set(Y,{__pytype__:"func",name:Y,params:ce,body:$,closure:new Map(r)}),R+=1+$.length}else R++}return r.set(N,v),e+1+I.length}if(i.startsWith("if ")&&i.endsWith(":")){let N=i.slice(3,-1).trim(),b=this.collectBlock(t,e+1,o),S=b.length+1;if(an(this.pyEval(N,r))){this.execBlock(b,new Map(r).also?.(R=>{for(let[ne,z]of r)R.set(ne,z)})??r),this.runBlockInScope(b,r);let v=e+1+b.length;for(;v<t.length;){let R=t[v].trim();if(this.getIndent(t[v])<o||!R.startsWith("elif")&&!R.startsWith("else"))break;let ne=this.collectBlock(t,v+1,o);v+=1+ne.length}return v}let I=e+1+b.length;for(;I<t.length;){let v=t[I],R=v.trim();if(this.getIndent(v)!==o)break;let ne=R.match(/^elif\s+(.+):$/);if(ne){let z=this.collectBlock(t,I+1,o);if(an(this.pyEval(ne[1],r))){for(this.runBlockInScope(z,r),I+=1+z.length;I<t.length;){let Y=t[I].trim();if(this.getIndent(t[I])!==o||!Y.startsWith("elif")&&!Y.startsWith("else"))break;let te=this.collectBlock(t,I+1,o);I+=1+te.length}return I}I+=1+z.length;continue}if(R==="else:"){let z=this.collectBlock(t,I+1,o);return this.runBlockInScope(z,r),I+1+z.length}break}return I}let E=i.match(/^for\s+(.+?)\s+in\s+(.+?)\s*:$/);if(E){let[,N,b]=E,S=vt(this.pyEval(b.trim(),r)),I=this.collectBlock(t,e+1,o),v=[],R=e+1+I.length;R<t.length&&t[R]?.trim()==="else:"&&(v=this.collectBlock(t,R+1,o),R+=1+v.length);let ne=!1;for(let z of S){if(N.includes(",")){let Y=N.split(",").map(ce=>ce.trim()),te=Array.isArray(z)?z:[z];Y.forEach((ce,$)=>r.set(ce,te[$]??G))}else r.set(N.trim(),z);try{this.runBlockInScope(I,r)}catch(Y){if(Y instanceof Pi){ne=!0;break}if(Y instanceof Ti)continue;throw Y}}return!ne&&v.length&&this.runBlockInScope(v,r),R}let x=i.match(/^while\s+(.+?)\s*:$/);if(x){let N=x[1],b=this.collectBlock(t,e+1,o),S=0;for(;an(this.pyEval(N,r))&&S++<1e5;)try{this.runBlockInScope(b,r)}catch(I){if(I instanceof Pi)break;if(I instanceof Ti)continue;throw I}return e+1+b.length}if(i==="try:"){let N=this.collectBlock(t,e+1,o),b=e+1+N.length,S=[],I=[],v=[];for(;b<t.length;){let ne=t[b],z=ne.trim();if(this.getIndent(ne)!==o)break;if(z.startsWith("except")){let Y=z.match(/^except(?:\s+(\w+)(?:\s+as\s+(\w+))?)?\s*:$/),te=Y?.[1]??null,ce=Y?.[2],$=this.collectBlock(t,b+1,o);S.push({exc:te,body:$}),ce&&r.set(ce,""),b+=1+$.length}else if(z==="else:")v=this.collectBlock(t,b+1,o),b+=1+v.length;else if(z==="finally:")I=this.collectBlock(t,b+1,o),b+=1+I.length;else break}let R=null;try{this.runBlockInScope(N,r),v.length&&this.runBlockInScope(v,r)}catch(ne){if(ne instanceof mt){R=ne;let z=!1;for(let Y of S)if(Y.exc===null||Y.exc===ne.type||Y.exc==="Exception"){this.runBlockInScope(Y.body,r),z=!0;break}if(!z)throw ne}else throw ne}finally{I.length&&this.runBlockInScope(I,r)}return b}let k=i.match(/^with\s+(.+?)\s+as\s+(\w+)\s*:$/);if(k){let N=this.collectBlock(t,e+1,o);return r.set(k[2],G),this.runBlockInScope(N,r),e+1+N.length}let D=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(\+=|-=|\*=|\/\/=|\/=|%=|\*\*=|&=|\|=)\s*(.+)$/);if(D){let[,N,b,S]=D,I=r.get(N)??0,v=this.pyEval(S,r),R;switch(b){case"+=":R=typeof I=="string"?I+Ne(v):I+v;break;case"-=":R=I-v;break;case"*=":R=I*v;break;case"/=":R=I/v;break;case"//=":R=Math.floor(I/v);break;case"%=":R=I%v;break;case"**=":R=I**v;break;default:R=v}return r.set(N,R),e+1}let H=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\[(.+)\]\s*=\s*(.+)$/);if(H){let[,N,b,S]=H,I=r.get(N)??G,v=this.pyEval(S,r)??G,R=this.pyEval(b,r)??G;return Array.isArray(I)?I[R]=v:pt(I)&&I.data.set(Ne(R),v),e+1}let C=i.match(/^([A-Za-z_][A-Za-z0-9_.]+)\s*=\s*(.+)$/);if(C){let N=C[1].lastIndexOf(".");if(N!==-1){let b=C[1].slice(0,N),S=C[1].slice(N+1),I=this.pyEval(C[2],r),v=this.pyEval(b,r);return pt(v)?v.data.set(S,I):Ni(v)&&v.attrs.set(S,I),e+1}}let F=i.match(/^([A-Za-z_][A-Za-z0-9_,\s]*),\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.+)$/);if(F){let N=this.pyEval(F[3],r),b=i.split("=")[0].split(",").map(I=>I.trim()),S=vt(N);return b.forEach((I,v)=>r.set(I,S[v]??G)),e+1}let V=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?::[^=]+)?\s*=\s*(.+)$/);if(V){let[,N,b]=V;return r.set(N,this.pyEval(b,r)),e+1}try{this.pyEval(i,r)}catch(N){if(N instanceof mt||N instanceof Li)throw N}return e+1}runBlockInScope(t,e){this.execLines(t,0,e)}run(t){let e=BA(this.cwd);try{this.execScript(t,e)}catch(r){return r instanceof Li?{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:r.code}:r instanceof mt?(this.stderr.push(r.toString()),{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:1}):r instanceof Wr?{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:0}:(this.stderr.push(`RuntimeError: ${r}`),{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:1})}return{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:0}}},xd={name:"python3",aliases:["python"],description:"Python 3 interpreter (virtual)",category:"system",params:["[--version] [-c <code>] [-V] [file]"],run:({args:n,shell:t,cwd:e})=>{if(!t.packageManager.isInstalled("python3"))return{stderr:`bash: python3: command not found
177
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\").replace(/\\'/g,"'").replace(/\\"/g,'"');let r=t.match(/^f(['"])([\s\S]*)\1$/);if(r){let f=r[2];return f=f.replace(/\{([^{}]+)\}/g,(l,u)=>{try{return Ne(this.pyEval(u.trim(),e))}catch{return`{${u}}`}}),f}let s=t.match(/^b(['"])(.*)\1$/s);if(s)return s[2];if(t.startsWith("[")&&t.endsWith("]")){let f=t.slice(1,-1).trim();if(!f)return[];let l=f.match(/^(.+?)\s+for\s+(\w+)\s+in\s+(.+?)(?:\s+if\s+(.+))?$/);if(l){let[,u,h,p,y]=l,E=Bt(this.pyEval(p.trim(),e)),b=[];for(let C of E){let N=new Map(e);N.set(h,C),!(y&&!fn(this.pyEval(y,N)))&&b.push(this.pyEval(u.trim(),N))}return b}return this.splitArgs(f).map(u=>this.pyEval(u,e))}if(t.startsWith("(")&&t.endsWith(")")){let f=t.slice(1,-1).trim();if(!f)return[];let l=this.splitArgs(f);return l.length===1&&!f.endsWith(",")?this.pyEval(l[0],e):l.map(u=>this.pyEval(u,e))}if(t.startsWith("{")&&t.endsWith("}")){let f=t.slice(1,-1).trim();if(!f)return yt();let l=yt();for(let u of this.splitArgs(f)){let h=u.indexOf(":");if(h===-1)continue;let p=Ne(this.pyEval(u.slice(0,h).trim(),e)),y=this.pyEval(u.slice(h+1).trim(),e);l.data.set(p,y)}return l}let i=t.match(/^not\s+(.+)$/);if(i)return!fn(this.pyEval(i[1],e));let o=[["or"],["and"],["in","not in","is not","is","==","!=","<=",">=","<",">"],["+","-"],["**"],["*","//","/","%"]];for(let f of o){let l=this.tryBinaryOp(t,f,e);if(l!==void 0)return l}if(t.startsWith("-")){let f=this.pyEval(t.slice(1),e);if(typeof f=="number")return-f}if(process.env.PY_DEBUG&&console.error("eval:",JSON.stringify(t)),t.endsWith("]")&&!t.startsWith("[")){let f=this.findMatchingBracket(t,"[");if(f!==-1){let l=this.pyEval(t.slice(0,f),e),u=t.slice(f+1,-1);return this.subscript(l,u,e)}}let a=t.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/);if(a){let[,f,l]=a,u=(l?.trim()?this.splitArgs(l):[]).map(h=>this.pyEval(h,e));return this.callBuiltin(f,u,e)}let c=this.findDotAccess(t);if(c){let{objExpr:f,attr:l,callPart:u}=c,h=this.pyEval(f,e);if(u!==void 0){let p=u.slice(1,-1),y=p.trim()?this.splitArgs(p).map(E=>this.pyEval(E,e)):[];return this.callMethod(h,l,y,e)}return this.getAttr(h,l,e)}if(/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)){if(e.has(t))return e.get(t);throw new Et("NameError",`name '${t}' is not defined`)}if(/^[A-Za-z_][A-Za-z0-9_.]+$/.test(t)){let f=t.split("."),l=e.get(f[0])??(()=>{throw new Et("NameError",`name '${f[0]}' is not defined`)})();for(let u of f.slice(1))l=this.getAttr(l,u,e);return l}return G}findMatchingBracket(t,e){let r=e==="["?"]":e==="("?")":"}",s=0;for(let i=t.length-1;i>=0;i--)if(t[i]===r&&s++,t[i]===e&&(s--,s===0))return i;return-1}findDotAccess(t){let e=0,r=!1,s="";for(let i=t.length-1;i>0;i--){let o=t[i];if(r){o===s&&t[i-1]!=="\\"&&(r=!1);continue}if(o==='"'||o==="'"){r=!0,s=o;continue}if(")]}".includes(o)){e++;continue}if("([{".includes(o)){e--;continue}if(e!==0||o!==".")continue;let a=t.slice(0,i).trim(),f=t.slice(i+1).match(/^(\w+)(\([\s\S]*\))?$/);if(f&&!/^-?\d+$/.test(a))return{objExpr:a,attr:f[1],callPart:f[2]}}return null}tryBinaryOp(t,e,r){let s=0,i=!1,o="";for(let a=t.length-1;a>=0;a--){let c=t[a];if(i){c===o&&t[a-1]!=="\\"&&(i=!1);continue}if(c==='"'||c==="'"){i=!0,o=c;continue}if(")]}".includes(c)){s++;continue}if("([{".includes(c)){s--;continue}if(s===0){for(let f of e)if(t.slice(a,a+f.length)===f){if(f==="*"&&(t[a+1]==="*"||t[a-1]==="*"))continue;let l=t[a-1],u=t[a+f.length];if(/^[a-z]/.test(f)&&(l&&/\w/.test(l)||u&&/\w/.test(u)))continue;let p=t.slice(0,a).trim(),y=t.slice(a+f.length).trim();if(!p||!y)continue;return this.applyBinaryOp(f,p,y,r)}}}}applyBinaryOp(t,e,r,s){if(t==="and"){let a=this.pyEval(e,s);return fn(a)?this.pyEval(r,s):a}if(t==="or"){let a=this.pyEval(e,s);return fn(a)?a:this.pyEval(r,s)}let i=this.pyEval(e,s),o=this.pyEval(r,s);switch(t){case"+":return typeof i=="string"&&typeof o=="string"?i+o:Array.isArray(i)&&Array.isArray(o)?[...i,...o]:i+o;case"-":return i-o;case"*":if(typeof i=="string"&&typeof o=="number")return i.repeat(o);if(Array.isArray(i)&&typeof o=="number"){let a=[];for(let c=0;c<o;c++)a.push(...i);return a}return i*o;case"/":{if(o===0)throw new Et("ZeroDivisionError","division by zero");return i/o}case"//":{if(o===0)throw new Et("ZeroDivisionError","integer division or modulo by zero");return Math.floor(i/o)}case"%":{if(typeof i=="string")return this.pyStringFormat(i,Array.isArray(o)?o:[o]);if(o===0)throw new Et("ZeroDivisionError","integer division or modulo by zero");return i%o}case"**":return i**o;case"==":return Rt(i)===Rt(o)||i===o;case"!=":return Rt(i)!==Rt(o)&&i!==o;case"<":return i<o;case"<=":return i<=o;case">":return i>o;case">=":return i>=o;case"in":return this.pyIn(o,i);case"not in":return!this.pyIn(o,i);case"is":return i===o||Mn(i)&&Mn(o);case"is not":return!(i===o||Mn(i)&&Mn(o))}return G}pyIn(t,e){return typeof t=="string"?typeof e=="string"&&t.includes(e):Array.isArray(t)?t.some(r=>Rt(r)===Rt(e)):mt(t)?t.data.has(Ne(e)):!1}subscript(t,e,r){if(e.includes(":")){let i=e.split(":").map(c=>c.trim()),o=i[0]?this.pyEval(i[0],r):void 0,a=i[1]?this.pyEval(i[1],r):void 0;return typeof t=="string"||Array.isArray(t)?t.slice(o,a):G}let s=this.pyEval(e,r);if(Array.isArray(t)){let i=s;return i<0&&(i=t.length+i),t[i]??G}if(typeof t=="string"){let i=s;return i<0&&(i=t.length+i),t[i]??G}if(mt(t))return t.data.get(Ne(s))??G;throw new Et("TypeError",`'${ur(t)}' is not subscriptable`)}getAttr(t,e,r){return mt(t)?t.data.has(e)?t.data.get(e):e==="path"&&t.path?t.path:G:Li(t)?t.attrs.get(e)??G:typeof t=="string"?{__class__:{__pytype__:"class",name:"str"}}[e]??G:G}callMethod(t,e,r,s){if(typeof t=="string")switch(e){case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();case"strip":return(r[0]?t.replace(new RegExp(`[${r[0]}]+`,"g"),""):t).trim();case"lstrip":return t.trimStart();case"rstrip":return t.trimEnd();case"split":return t.split(typeof r[0]=="string"?r[0]:/\s+/).filter((i,o)=>o>0||i!=="");case"splitlines":return t.split(`
178
+ `);case"join":return Bt(r[0]??[]).map(Ne).join(t);case"replace":return t.replaceAll(Ne(r[0]??""),Ne(r[1]??""));case"startswith":return t.startsWith(Ne(r[0]??""));case"endswith":return t.endsWith(Ne(r[0]??""));case"find":return t.indexOf(Ne(r[0]??""));case"index":{let i=t.indexOf(Ne(r[0]??""));if(i===-1)throw new Et("ValueError","substring not found");return i}case"count":return t.split(Ne(r[0]??"")).length-1;case"format":return this.pyStringFormat(t,r);case"encode":return t;case"decode":return t;case"isdigit":return/^\d+$/.test(t);case"isalpha":return/^[a-zA-Z]+$/.test(t);case"isalnum":return/^[a-zA-Z0-9]+$/.test(t);case"isspace":return/^\s+$/.test(t);case"isupper":return t===t.toUpperCase()&&t!==t.toLowerCase();case"islower":return t===t.toLowerCase()&&t!==t.toUpperCase();case"center":{let i=r[0]??0,o=Ne(r[1]??" ");return t.padStart(Math.floor((i+t.length)/2),o).padEnd(i,o)}case"ljust":return t.padEnd(r[0]??0,Ne(r[1]??" "));case"rjust":return t.padStart(r[0]??0,Ne(r[1]??" "));case"zfill":return t.padStart(r[0]??0,"0");case"title":return t.replace(/\b\w/g,i=>i.toUpperCase());case"capitalize":return t[0]?.toUpperCase()+t.slice(1).toLowerCase();case"swapcase":return[...t].map(i=>i===i.toUpperCase()?i.toLowerCase():i.toUpperCase()).join("")}if(Array.isArray(t))switch(e){case"append":return t.push(r[0]??G),G;case"extend":for(let i of Bt(r[0]??[]))t.push(i);return G;case"insert":return t.splice(r[0]??0,0,r[1]??G),G;case"pop":{let i=r[0]!==void 0?r[0]:-1,o=i<0?t.length+i:i;return t.splice(o,1)[0]??G}case"remove":{let i=t.findIndex(o=>Rt(o)===Rt(r[0]??G));return i!==-1&&t.splice(i,1),G}case"index":{let i=t.findIndex(o=>Rt(o)===Rt(r[0]??G));if(i===-1)throw new Et("ValueError","is not in list");return i}case"count":return t.filter(i=>Rt(i)===Rt(r[0]??G)).length;case"sort":return t.sort((i,o)=>typeof i=="number"&&typeof o=="number"?i-o:Ne(i).localeCompare(Ne(o))),G;case"reverse":return t.reverse(),G;case"copy":return[...t];case"clear":return t.splice(0),G}if(mt(t))switch(e){case"keys":return[...t.data.keys()];case"values":return[...t.data.values()];case"items":return[...t.data.entries()].map(([i,o])=>[i,o]);case"get":return t.data.get(Ne(r[0]??""))??r[1]??G;case"update":{if(mt(r[0]??G))for(let[i,o]of r[0].data)t.data.set(i,o);return G}case"pop":{let i=Ne(r[0]??""),o=t.data.get(i)??r[1]??G;return t.data.delete(i),o}case"clear":return t.data.clear(),G;case"copy":return yt([...t.data.entries()]);case"setdefault":{let i=Ne(r[0]??"");return t.data.has(i)||t.data.set(i,r[1]??G),t.data.get(i)??G}}if(mt(t)&&t.data.has("name")&&t.data.get("name")==="posix")switch(e){case"getcwd":return this.cwd;case"getenv":return typeof r[0]=="string"?process.env[r[0]]??r[1]??G:G;case"listdir":return[];case"path":return t}if(mt(t))switch(e){case"join":return r.map(Ne).join("/").replace(/\/+/g,"/");case"exists":return!1;case"dirname":return Ne(r[0]??"").split("/").slice(0,-1).join("/")||"/";case"basename":return Ne(r[0]??"").split("/").pop()??"";case"abspath":return Ne(r[0]??"");case"splitext":{let i=Ne(r[0]??""),o=i.lastIndexOf(".");return o>0?[i.slice(0,o),i.slice(o)]:[i,""]}case"isfile":return!1;case"isdir":return!1}if(mt(t)&&t.data.has("version")&&t.data.get("version")===Vs&&e==="exit")throw new $i(r[0]??0);if(mt(t)){let i={sqrt:Math.sqrt,floor:Math.floor,ceil:Math.ceil,fabs:Math.abs,log:Math.log,log2:Math.log2,log10:Math.log10,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,atan2:Math.atan2,pow:Math.pow,exp:Math.exp,hypot:Math.hypot};if(e in i){let o=i[e];return o(...r.map(a=>a))}if(e==="factorial"){let o=r[0]??0,a=1;for(;o>1;)a*=o--;return a}if(e==="gcd"){let o=Math.abs(r[0]??0),a=Math.abs(r[1]??0);for(;a;)[o,a]=[a,o%a];return o}}if(mt(t)){if(e==="dumps"){let i=mt(r[1]??G)?r[1]:void 0,o=i?i.data.get("indent"):void 0;return JSON.stringify(this.pyToJs(r[0]??G),null,o)}if(e==="loads")return this.jsToPy(JSON.parse(Ne(r[0]??"")))}if(Li(t)){let i=t.attrs.get(e)??t.cls.methods.get(e)??G;if(kn(i)){let o=new Map(i.closure);return o.set("self",t),i.params.slice(1).forEach((a,c)=>o.set(a,r[c]??G)),this.execBlock(i.body,o)}}throw new Et("AttributeError",`'${ur(t)}' object has no attribute '${e}'`)}pyStringFormat(t,e){let r=0;return t.replace(/%([diouxXeEfFgGcrs%])/g,(s,i)=>{if(i==="%")return"%";let o=e[r++];switch(i){case"d":case"i":return String(Math.trunc(o));case"f":return o.toFixed(6);case"s":return Ne(o??G);case"r":return Rt(o??G);default:return String(o)}})}pyToJs(t){return Mn(t)?null:mt(t)?Object.fromEntries([...t.data.entries()].map(([e,r])=>[e,this.pyToJs(r)])):Array.isArray(t)?t.map(e=>this.pyToJs(e)):t}jsToPy(t){return t==null?G:typeof t=="boolean"||typeof t=="number"||typeof t=="string"?t:Array.isArray(t)?t.map(e=>this.jsToPy(e)):typeof t=="object"?yt(Object.entries(t).map(([e,r])=>[e,this.jsToPy(r)])):G}callBuiltin(t,e,r){if(r.has(t)){let s=r.get(t)??G;return kn(s)?this.callFunc(s,e,r):rc(s)?this.instantiate(s,e,r):s}switch(t){case"print":return this.output.push(e.map(Ne).join(" ")+`
179
+ `.replace(/\\n/g,"")),G;case"input":return this.output.push(Ne(e[0]??"")),"";case"int":{if(e.length===0)return 0;let s=e[1]??10,i=parseInt(Ne(e[0]??0),s);return Number.isNaN(i)?(()=>{throw new Et("ValueError","invalid literal for int()")})():i}case"float":{if(e.length===0)return 0;let s=parseFloat(Ne(e[0]??0));return Number.isNaN(s)?(()=>{throw new Et("ValueError","could not convert to float")})():s}case"str":return e.length===0?"":Ne(e[0]??G);case"bool":return e.length===0?!1:fn(e[0]??G);case"list":return e.length===0?[]:Bt(e[0]??[]);case"tuple":return e.length===0?[]:Bt(e[0]??[]);case"set":return e.length===0?[]:[...new Set(Bt(e[0]??[]).map(Rt))].map(s=>Bt(e[0]??[]).find(o=>Rt(o)===s)??G);case"dict":return e.length===0?yt():mt(e[0]??G)?e[0]:yt();case"bytes":return typeof e[0]=="string"?e[0]:Ne(e[0]??"");case"bytearray":return e.length===0?"":Ne(e[0]??"");case"type":return e.length===1?`<class '${ur(e[0]??G)}'>`:G;case"isinstance":return ur(e[0]??G)===Ne(e[1]??"");case"issubclass":return!1;case"callable":return kn(e[0]??G);case"hasattr":return mt(e[0]??G)?e[0].data.has(Ne(e[1]??"")):!1;case"getattr":return mt(e[0]??G)?e[0].data.get(Ne(e[1]??""))??e[2]??G:e[2]??G;case"setattr":return mt(e[0]??G)&&e[0].data.set(Ne(e[1]??""),e[2]??G),G;case"len":{let s=e[0]??G;if(typeof s=="string"||Array.isArray(s))return s.length;if(mt(s))return s.data.size;if(Kr(s))return Cd(s);throw new Et("TypeError",`object of type '${ur(s)}' has no len()`)}case"range":return e.length===1?nc(0,e[0]):e.length===2?nc(e[0],e[1]):nc(e[0],e[1],e[2]);case"enumerate":{let s=e[1]??0;return Bt(e[0]??[]).map((i,o)=>[o+s,i])}case"zip":{let s=e.map(Bt),i=Math.min(...s.map(o=>o.length));return Array.from({length:i},(o,a)=>s.map(c=>c[a]??G))}case"map":{let s=e[0]??G;return Bt(e[1]??[]).map(i=>kn(s)?this.callFunc(s,[i],r):G)}case"filter":{let s=e[0]??G;return Bt(e[1]??[]).filter(i=>kn(s)?fn(this.callFunc(s,[i],r)):fn(i))}case"reduce":{let s=e[0]??G,i=Bt(e[1]??[]);if(i.length===0)return e[2]??G;let o=e[2]!==void 0?e[2]:i[0];for(let a of e[2]!==void 0?i:i.slice(1))o=kn(s)?this.callFunc(s,[o,a],r):G;return o}case"sorted":{let s=[...Bt(e[0]??[])],i=e[1]??G,o=mt(i)?i.data.get("key")??G:i;return s.sort((a,c)=>{let f=kn(o)?this.callFunc(o,[a],r):a,l=kn(o)?this.callFunc(o,[c],r):c;return typeof f=="number"&&typeof l=="number"?f-l:Ne(f).localeCompare(Ne(l))}),s}case"reversed":return[...Bt(e[0]??[])].reverse();case"any":return Bt(e[0]??[]).some(fn);case"all":return Bt(e[0]??[]).every(fn);case"sum":return Bt(e[0]??[]).reduce((s,i)=>s+i,e[1]??0);case"max":return(e.length===1?Bt(e[0]??[]):e).reduce((i,o)=>i>=o?i:o);case"min":return(e.length===1?Bt(e[0]??[]):e).reduce((i,o)=>i<=o?i:o);case"abs":return Math.abs(e[0]??0);case"round":return e[1]!==void 0?parseFloat(e[0].toFixed(e[1])):Math.round(e[0]??0);case"divmod":{let s=e[0],i=e[1];return[Math.floor(s/i),s%i]}case"pow":return e[0]**e[1];case"hex":return`0x${e[0].toString(16)}`;case"oct":return`0o${e[0].toString(8)}`;case"bin":return`0b${e[0].toString(2)}`;case"ord":return Ne(e[0]??"").charCodeAt(0);case"chr":return String.fromCharCode(e[0]??0);case"id":return Math.floor(Math.random()*4294967295);case"hash":return typeof e[0]=="number"?e[0]:Ne(e[0]??"").split("").reduce((s,i)=>s*31+i.charCodeAt(0)|0,0);case"open":throw new Et("PermissionError","open() not available in virtual runtime");case"repr":return Rt(e[0]??G);case"iter":return e[0]??G;case"next":return Array.isArray(e[0])&&e[0].length>0?e[0].shift():e[1]??(()=>{throw new Et("StopIteration","")})();case"vars":return yt([...r.entries()].map(([s,i])=>[s,i]));case"globals":return yt([...r.entries()].map(([s,i])=>[s,i]));case"locals":return yt([...r.entries()].map(([s,i])=>[s,i]));case"dir":{if(e.length===0)return[...r.keys()];let s=e[0]??G;return typeof s=="string"?["upper","lower","strip","split","join","replace","find","format","encode","startswith","endswith","count","isdigit","isalpha","title","capitalize"]:Array.isArray(s)?["append","extend","insert","pop","remove","index","count","sort","reverse","copy","clear"]:mt(s)?["keys","values","items","get","update","pop","clear","copy","setdefault"]:[]}case"Exception":case"ValueError":case"TypeError":case"KeyError":case"IndexError":case"AttributeError":case"NameError":case"RuntimeError":case"StopIteration":case"NotImplementedError":case"OSError":case"IOError":throw new Et(t,Ne(e[0]??""));case"exec":return this.execScript(Ne(e[0]??""),r),G;case"eval":return this.pyEval(Ne(e[0]??""),r);default:throw new Et("NameError",`name '${t}' is not defined`)}}callFunc(t,e,r){let s=new Map(t.closure);t.params.forEach((i,o)=>{if(i.startsWith("*")){s.set(i.slice(1),e.slice(o));return}s.set(i,e[o]??G)});try{return this.execBlock(t.body,s)}catch(i){if(i instanceof qr)return i.value;throw i}}instantiate(t,e,r){let s={__pytype__:"instance",cls:t,attrs:new Map};return t.methods.get("__init__")&&this.callMethod(s,"__init__",e,r),s}execScript(t,e){let r=t.split(`
180
+ `);this.execLines(r,0,e)}execLines(t,e,r){let s=e;for(;s<t.length;){let i=t[s];if(!i.trim()||i.trim().startsWith("#")){s++;continue}s=this.execStatement(t,s,r)}return s}execBlock(t,e){try{this.execLines(t,0,e)}catch(r){if(r instanceof qr)return r.value;throw r}return G}getIndent(t){let e=0;for(let r of t)if(r===" ")e++;else if(r===" ")e+=4;else break;return e}collectBlock(t,e,r){let s=[];for(let i=e;i<t.length;i++){let o=t[i];if(!o.trim()){s.push("");continue}if(this.getIndent(o)<=r)break;s.push(o.slice(r+4))}return s}execStatement(t,e,r){let s=t[e],i=s.trim(),o=this.getIndent(s);if(i==="pass")return e+1;if(i==="break")throw new Ui;if(i==="continue")throw new Di;let a=i.match(/^return(?:\s+(.+))?$/);if(a)throw new qr(a[1]?this.pyEval(a[1],r):G);let c=i.match(/^raise(?:\s+(.+))?$/);if(c){if(c[1]){let P=this.pyEval(c[1],r);throw new Et(typeof P=="string"?P:ur(P),Ne(P))}throw new Et("RuntimeError","")}let f=i.match(/^assert\s+(.+?)(?:,\s*(.+))?$/);if(f){if(!fn(this.pyEval(f[1],r)))throw new Et("AssertionError",f[2]?Ne(this.pyEval(f[2],r)):"");return e+1}let l=i.match(/^del\s+(.+)$/);if(l)return r.delete(l[1].trim()),e+1;let u=i.match(/^import\s+(\w+)(?:\s+as\s+(\w+))?$/);if(u){let[,P,x]=u,w=Id[P];if(w){let I=w(this.cwd);this.modules.set(P,I),r.set(x??P,I)}return e+1}let h=i.match(/^from\s+(\w+)\s+import\s+(.+)$/);if(h){let[,P,x]=h,w=Id[P];if(w){let I=w(this.cwd);if(x?.trim()==="*")for(let[k,R]of I.data)r.set(k,R);else for(let k of x.split(",").map(R=>R.trim()))r.set(k,I.data.get(k)??G)}return e+1}let p=i.match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(p){let[,P,x]=p,w=x.split(",").map(R=>R.trim()).filter(Boolean),I=this.collectBlock(t,e+1,o),k={__pytype__:"func",name:P,params:w,body:I,closure:new Map(r)};return r.set(P,k),e+1+I.length}let y=i.match(/^class\s+(\w+)(?:\(([^)]*)\))?\s*:$/);if(y){let[,P,x]=y,w=x?x.split(",").map(ne=>ne.trim()):[],I=this.collectBlock(t,e+1,o),k={__pytype__:"class",name:P,methods:new Map,bases:w},R=0;for(;R<I.length;){let z=I[R].trim().match(/^def\s+(\w+)\s*\(([^)]*)\)\s*:$/);if(z){let[,Y,te]=z,ce=te.split(",").map(B=>B.trim()).filter(Boolean),$=this.collectBlock(I,R+1,0);k.methods.set(Y,{__pytype__:"func",name:Y,params:ce,body:$,closure:new Map(r)}),R+=1+$.length}else R++}return r.set(P,k),e+1+I.length}if(i.startsWith("if ")&&i.endsWith(":")){let P=i.slice(3,-1).trim(),x=this.collectBlock(t,e+1,o),w=x.length+1;if(fn(this.pyEval(P,r))){this.execBlock(x,new Map(r).also?.(R=>{for(let[ne,z]of r)R.set(ne,z)})??r),this.runBlockInScope(x,r);let k=e+1+x.length;for(;k<t.length;){let R=t[k].trim();if(this.getIndent(t[k])<o||!R.startsWith("elif")&&!R.startsWith("else"))break;let ne=this.collectBlock(t,k+1,o);k+=1+ne.length}return k}let I=e+1+x.length;for(;I<t.length;){let k=t[I],R=k.trim();if(this.getIndent(k)!==o)break;let ne=R.match(/^elif\s+(.+):$/);if(ne){let z=this.collectBlock(t,I+1,o);if(fn(this.pyEval(ne[1],r))){for(this.runBlockInScope(z,r),I+=1+z.length;I<t.length;){let Y=t[I].trim();if(this.getIndent(t[I])!==o||!Y.startsWith("elif")&&!Y.startsWith("else"))break;let te=this.collectBlock(t,I+1,o);I+=1+te.length}return I}I+=1+z.length;continue}if(R==="else:"){let z=this.collectBlock(t,I+1,o);return this.runBlockInScope(z,r),I+1+z.length}break}return I}let E=i.match(/^for\s+(.+?)\s+in\s+(.+?)\s*:$/);if(E){let[,P,x]=E,w=Bt(this.pyEval(x.trim(),r)),I=this.collectBlock(t,e+1,o),k=[],R=e+1+I.length;R<t.length&&t[R]?.trim()==="else:"&&(k=this.collectBlock(t,R+1,o),R+=1+k.length);let ne=!1;for(let z of w){if(P.includes(",")){let Y=P.split(",").map(ce=>ce.trim()),te=Array.isArray(z)?z:[z];Y.forEach((ce,$)=>r.set(ce,te[$]??G))}else r.set(P.trim(),z);try{this.runBlockInScope(I,r)}catch(Y){if(Y instanceof Ui){ne=!0;break}if(Y instanceof Di)continue;throw Y}}return!ne&&k.length&&this.runBlockInScope(k,r),R}let b=i.match(/^while\s+(.+?)\s*:$/);if(b){let P=b[1],x=this.collectBlock(t,e+1,o),w=0;for(;fn(this.pyEval(P,r))&&w++<1e5;)try{this.runBlockInScope(x,r)}catch(I){if(I instanceof Ui)break;if(I instanceof Di)continue;throw I}return e+1+x.length}if(i==="try:"){let P=this.collectBlock(t,e+1,o),x=e+1+P.length,w=[],I=[],k=[];for(;x<t.length;){let ne=t[x],z=ne.trim();if(this.getIndent(ne)!==o)break;if(z.startsWith("except")){let Y=z.match(/^except(?:\s+(\w+)(?:\s+as\s+(\w+))?)?\s*:$/),te=Y?.[1]??null,ce=Y?.[2],$=this.collectBlock(t,x+1,o);w.push({exc:te,body:$}),ce&&r.set(ce,""),x+=1+$.length}else if(z==="else:")k=this.collectBlock(t,x+1,o),x+=1+k.length;else if(z==="finally:")I=this.collectBlock(t,x+1,o),x+=1+I.length;else break}let R=null;try{this.runBlockInScope(P,r),k.length&&this.runBlockInScope(k,r)}catch(ne){if(ne instanceof Et){R=ne;let z=!1;for(let Y of w)if(Y.exc===null||Y.exc===ne.type||Y.exc==="Exception"){this.runBlockInScope(Y.body,r),z=!0;break}if(!z)throw ne}else throw ne}finally{I.length&&this.runBlockInScope(I,r)}return x}let C=i.match(/^with\s+(.+?)\s+as\s+(\w+)\s*:$/);if(C){let P=this.collectBlock(t,e+1,o);return r.set(C[2],G),this.runBlockInScope(P,r),e+1+P.length}let N=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(\+=|-=|\*=|\/\/=|\/=|%=|\*\*=|&=|\|=)\s*(.+)$/);if(N){let[,P,x,w]=N,I=r.get(P)??0,k=this.pyEval(w,r),R;switch(x){case"+=":R=typeof I=="string"?I+Ne(k):I+k;break;case"-=":R=I-k;break;case"*=":R=I*k;break;case"/=":R=I/k;break;case"//=":R=Math.floor(I/k);break;case"%=":R=I%k;break;case"**=":R=I**k;break;default:R=k}return r.set(P,R),e+1}let H=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\[(.+)\]\s*=\s*(.+)$/);if(H){let[,P,x,w]=H,I=r.get(P)??G,k=this.pyEval(w,r)??G,R=this.pyEval(x,r)??G;return Array.isArray(I)?I[R]=k:mt(I)&&I.data.set(Ne(R),k),e+1}let v=i.match(/^([A-Za-z_][A-Za-z0-9_.]+)\s*=\s*(.+)$/);if(v){let P=v[1].lastIndexOf(".");if(P!==-1){let x=v[1].slice(0,P),w=v[1].slice(P+1),I=this.pyEval(v[2],r),k=this.pyEval(x,r);return mt(k)?k.data.set(w,I):Li(k)&&k.attrs.set(w,I),e+1}}let M=i.match(/^([A-Za-z_][A-Za-z0-9_,\s]*),\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.+)$/);if(M){let P=this.pyEval(M[3],r),x=i.split("=")[0].split(",").map(I=>I.trim()),w=Bt(P);return x.forEach((I,k)=>r.set(I,w[k]??G)),e+1}let Q=i.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*(?::[^=]+)?\s*=\s*(.+)$/);if(Q){let[,P,x]=Q;return r.set(P,this.pyEval(x,r)),e+1}try{this.pyEval(i,r)}catch(P){if(P instanceof Et||P instanceof $i)throw P}return e+1}runBlockInScope(t,e){this.execLines(t,0,e)}run(t){let e=DA(this.cwd);try{this.execScript(t,e)}catch(r){return r instanceof $i?{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:r.code}:r instanceof Et?(this.stderr.push(r.toString()),{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:1}):r instanceof qr?{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:0}:(this.stderr.push(`RuntimeError: ${r}`),{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:1})}return{stdout:this.getOutput(),stderr:this.getStderr(),exitCode:0}}},vd={name:"python3",aliases:["python"],description:"Python 3 interpreter (virtual)",category:"system",params:["[--version] [-c <code>] [-V] [file]"],run:({args:n,shell:t,cwd:e})=>{if(!t.packageManager.isInstalled("python3"))return{stderr:`bash: python3: command not found
176
181
  Hint: install it with: apt install python3
177
- `,exitCode:127};if(se(n,["--version","-V"]))return{stdout:`${kA}
178
- `,exitCode:0};if(se(n,["--version-full"]))return{stdout:`${Ws}
182
+ `,exitCode:127};if(se(n,["--version","-V"]))return{stdout:`${LA}
183
+ `,exitCode:0};if(se(n,["--version-full"]))return{stdout:`${Vs}
179
184
  `,exitCode:0};let r=n.indexOf("-c");if(r!==-1){let i=n[r+1];if(!i)return{stderr:`python3: -c requires a code argument
180
185
  `,exitCode:1};let o=i.replace(/\\n/g,`
181
- `).replace(/\\t/g," "),a=new qs(e),{stdout:c,stderr:f,exitCode:l}=a.run(o);return{stdout:c||void 0,stderr:f||void 0,exitCode:l}}let s=n.find(i=>!i.startsWith("-"));if(s){let i=le(e,s);if(!t.vfs.exists(i))return{stderr:`python3: can't open file '${s}': [Errno 2] No such file or directory
182
- `,exitCode:2};let o=t.vfs.readFile(i),a=new qs(e),{stdout:c,stderr:f,exitCode:l}=a.run(o);return{stdout:c||void 0,stderr:f||void 0,exitCode:l}}return{stdout:`${Ws}
186
+ `).replace(/\\t/g," "),a=new Gs(e),{stdout:c,stderr:f,exitCode:l}=a.run(o);return{stdout:c||void 0,stderr:f||void 0,exitCode:l}}let s=n.find(i=>!i.startsWith("-"));if(s){let i=le(e,s);if(!t.vfs.exists(i))return{stderr:`python3: can't open file '${s}': [Errno 2] No such file or directory
187
+ `,exitCode:2};let o=t.vfs.readFile(i),a=new Gs(e),{stdout:c,stderr:f,exitCode:l}=a.run(o);return{stdout:c||void 0,stderr:f||void 0,exitCode:l}}return{stdout:`${Vs}
183
188
  Type "help", "copyright", "credits" or "license" for more information.
184
- >>> `,exitCode:0}}};var Sd={name:"read",description:"Read a line from stdin into variables",category:"shell",params:["[-r] [-p prompt] <var...>"],run:({args:n,stdin:t,env:e})=>{let r=n.indexOf("-p"),s=n.filter((a,c)=>a!=="-r"&&a!=="-p"&&n[c-1]!=="-p"),i=(t??"").split(`
189
+ >>> `,exitCode:0}}};var kd={name:"read",description:"Read a line from stdin into variables",category:"shell",params:["[-r] [-p prompt] <var...>"],run:({args:n,stdin:t,env:e})=>{let r=n.indexOf("-p"),s=n.filter((a,c)=>a!=="-r"&&a!=="-p"&&n[c-1]!=="-p"),i=(t??"").split(`
185
190
  `)[0]??"",o=se(n,["-r"])?i:i.replace(/\\(?:\r?\n|.)/g,a=>a[1]===`
186
- `||a[1]==="\r"?"":a[1]);if(!e)return{exitCode:0};if(s.length===0)e.vars.REPLY=o;else if(s.length===1)e.vars[s[0]]=o;else{let a=o.split(/\s+/);for(let c=0;c<s.length;c++)e.vars[s[c]]=c<s.length-1?a[c]??"":a.slice(c).join(" ")}return{exitCode:0}}};var wd={name:"rm",description:"Remove files or directories",category:"files",params:["[-r|-rf] <path>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"rm: missing operand",exitCode:1};let s=se(r,["-r","-rf","-fr"]),i=[];for(let o=0;;o+=1){let a=Xn(r,o,{flags:["-r","-rf","-fr"]});if(!a)break;i.push(a)}if(i.length===0)return{stderr:"rm: missing operand",exitCode:1};for(let o of i){let a=le(e,o);Oe(n,a,"rm"),t.vfs.remove(a,{recursive:s})}return{exitCode:0}}};var Id={name:"sed",description:"Stream editor for filtering and transforming text",category:"text",params:["-e <expr> [file]","s/pattern/replace/[g]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-i"]),o=en(r,["-e"])??r.find(x=>!x.startsWith("-")),a=r.filter(x=>!x.startsWith("-")&&x!==o).pop();if(!o)return{stderr:"sed: no expression",exitCode:1};let c=s??"";if(a){let x=le(e,a);try{c=t.vfs.readFile(x)}catch{return{stderr:`sed: ${a}: No such file or directory`,exitCode:1}}}let f=o.match(/^s([^a-zA-Z0-9])(.+?)\1(.*?)\1([gi]*)$/);if(!f)return{stderr:`sed: unrecognized command: ${o}`,exitCode:1};let[,,l,u,h]=f,p=(h??"").includes("i")?"gi":(h??"").includes("g")?"g":"",y;try{y=new RegExp(l,p||"")}catch{return{stderr:`sed: invalid regex: ${l}`,exitCode:1}}let E=((h??"").includes("g")||p.includes("g"),c.replace(y,u??""));if(i&&a){let x=le(e,a);return t.writeFileAsUser(n,x,E),{exitCode:0}}return{stdout:E,exitCode:0}}};var Cd={name:"set",description:"Display or set shell variables",category:"shell",params:["[VAR=value]"],run:({args:n,env:t})=>{if(n.length===0)return{stdout:Object.entries(t.vars).map(([r,s])=>`${r}=${s}`).join(`
187
- `),exitCode:0};for(let e of n)if(e.includes("=")){let r=e.indexOf("=");t.vars[e.slice(0,r)]=e.slice(r+1)}return{exitCode:0}}};async function kd(n,t,e,r,s,i,o){let a={exitCode:0},c=[],f=s,l=0;for(;l<n.length;){let h=n[l];if(a=await UA(h.pipeline,t,e,r,f,i,o),o.lastExitCode=a.exitCode??0,a.nextCwd&&(a.exitCode??0)===0&&(f=a.nextCwd),a.stdout&&c.push(a.stdout),a.closeSession||a.switchUser)return{...a,stdout:c.join("")||a.stdout};let p=h.op;if(!(!p||p===";")){if(p==="&&"){if((a.exitCode??0)!==0)for(;l<n.length&&n[l]?.op==="&&";)l++}else if(p==="||"&&(a.exitCode??0)===0)for(;l<n.length&&n[l]?.op==="||";)l++}l++}let u=c.join("");return{...a,stdout:u||a.stdout,nextCwd:f!==s?f:void 0}}async function UA(n,t,e,r,s,i,o){if(!n.isValid)return{stderr:n.error||"Syntax error",exitCode:1};if(n.commands.length===0)return{exitCode:0};let a=o??{vars:{},lastExitCode:0};return n.commands.length===1?DA(n.commands[0],t,e,r,s,i,a):$A(n.commands,t,e,r,s,i,a)}async function DA(n,t,e,r,s,i,o){let a;if(n.inputFile){let f=le(s,n.inputFile);try{a=i.vfs.readFile(f)}catch{return{stderr:`${n.inputFile}: No such file or directory`,exitCode:1}}}let c=await Ks(n.name,n.args,t,e,r,s,i,a,o);if(n.outputFile){let f=le(s,n.outputFile),l=c.stdout||"";try{if(n.appendOutput){let u=(()=>{try{return i.vfs.readFile(f)}catch{return""}})();i.writeFileAsUser(t,f,u+l)}else i.writeFileAsUser(t,f,l);return{...c,stdout:""}}catch{return{...c,stderr:`Failed to write to ${n.outputFile}`,exitCode:1}}}return c}async function $A(n,t,e,r,s,i,o){let a="",c=0;for(let f=0;f<n.length;f++){let l=n[f];if(f===0&&l.inputFile){let h=le(s,l.inputFile);try{a=i.vfs.readFile(h)}catch{return{stderr:`${l.inputFile}: No such file or directory`,exitCode:1}}}let u=await Ks(l.name,l.args,t,e,r,s,i,a,o);if(c=u.exitCode??0,f===n.length-1&&l.outputFile){let h=le(s,l.outputFile),p=u.stdout||"";try{if(l.appendOutput){let y=(()=>{try{return i.vfs.readFile(h)}catch{return""}})();i.writeFileAsUser(t,h,y+p)}else i.writeFileAsUser(t,h,p);a=""}catch{return{stderr:`Failed to write to ${l.outputFile}`,exitCode:1}}}else a=u.stdout||"";if(u.stderr&&c!==0)return{stderr:u.stderr,exitCode:c};if(u.closeSession||u.switchUser)return u}return{stdout:a,exitCode:c}}function Ui(n){let t=[],e="",r=!1,s="",i=0;for(;i<n.length;){let o=n[i],a=n[i+1];if((o==='"'||o==="'")&&!r){r=!0,s=o,i++;continue}if(r&&o===s){r=!1,s="",i++;continue}if(r){e+=o,i++;continue}if(o===" "){e&&(t.push(e),e=""),i++;continue}if((o===">"||o==="<")&&!r){e&&(t.push(e),e=""),o===">"&&a===">"?(t.push(">>"),i+=2):(t.push(o),i++);continue}e+=o,i++}return e&&t.push(e),t}function vd(n){let t=n.trim();if(!t)return{statements:[],isValid:!0};try{return{statements:OA(t),isValid:!0}}catch(e){return{statements:[],isValid:!1,error:e.message}}}function OA(n){let t=MA(n),e=[];for(let r of t){let i={pipeline:{commands:FA(r.text.trim()),isValid:!0}};r.op&&(i.op=r.op),e.push(i)}return e}function MA(n){let t=[],e="",r=0,s=!1,i="",o=0,a=c=>{e.trim()&&t.push({text:e,op:c}),e=""};for(;o<n.length;){let c=n[o],f=n.slice(o,o+2);if((c==='"'||c==="'")&&!s){s=!0,i=c,e+=c,o++;continue}if(s&&c===i){s=!1,e+=c,o++;continue}if(s){e+=c,o++;continue}if(c==="("){r++,e+=c,o++;continue}if(c===")"){r--,e+=c,o++;continue}if(r>0){e+=c,o++;continue}if(f==="&&"){a("&&"),o+=2;continue}if(f==="||"){a("||"),o+=2;continue}if(c===";"){a(";"),o++;continue}e+=c,o++}return a(),t}function FA(n){return HA(n).map(QA)}function HA(n){let t=[],e="",r=!1,s="";for(let o=0;o<n.length;o++){let a=n[o];if((a==='"'||a==="'")&&!r){r=!0,s=a,e+=a;continue}if(r&&a===s){r=!1,e+=a;continue}if(r){e+=a;continue}if(a==="|"&&n[o+1]!=="|"){if(!e.trim())throw new Error("Syntax error near unexpected token '|'");t.push(e.trim()),e=""}else e+=a}let i=e.trim();if(!i&&t.length>0)throw new Error("Syntax error near unexpected token '|'");return i&&t.push(i),t}function QA(n){let t=Ui(n);if(t.length===0)return{name:"",args:[]};let e=[],r,s,i=!1,o=0;for(;o<t.length;){let c=t[o];if(c==="<"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after <");r=t[o],o++}else if(c===">>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after >>");s=t[o],i=!0,o++}else if(c===">"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after >");s=t[o],i=!1,o++}else e.push(c),o++}return{name:(e[0]??"").toLowerCase(),args:e.slice(1),inputFile:r,outputFile:s,appendOutput:i}}function Kr(n,t){return{vars:{PATH:"/usr/local/bin:/usr/bin:/bin",HOME:`/home/${n}`,USER:n,LOGNAME:n,SHELL:"/bin/sh",TERM:"xterm-256color",HOSTNAME:t,PS1:"\\u@\\h:\\w\\$ "},lastExitCode:0}}function Bd(n,t,e,r){if(n.startsWith("/")){if(!e.vfs.exists(n))return null;try{let i=e.vfs.stat(n);return i.type!=="file"||!(i.mode&73)||(n.startsWith("/sbin/")||n.startsWith("/usr/sbin/"))&&r!=="root"?null:n}catch{return null}}let s=(t.vars.PATH??"/usr/local/bin:/usr/bin:/bin").split(":");for(let i of s){if((i==="/sbin"||i==="/usr/sbin")&&r!=="root")continue;let o=`${i}/${n}`;if(e.vfs.exists(o))try{let a=e.vfs.stat(o);if(a.type!=="file"||!(a.mode&73))continue;return o}catch{}}return null}async function Ks(n,t,e,r,s,i,o,a,c){let f=c.vars[`__alias_${n}`];if(f)return bt(`${f} ${t.join(" ")}`,e,r,s,i,o,a,c);let l=Cn(n);if(!l){let u=Bd(n,c,o,e);if(u){let h=o.vfs.readFile(u),p=h.match(/exec\s+builtin\s+(\S+)/);if(p){let E=Cn(p[1]);if(E)return await E.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:[n,...t].join(" "),mode:s,args:t,stdin:a,cwd:i,shell:o,env:c})}let y=Cn("sh");if(y)return await y.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:`sh -c ${JSON.stringify(h)}`,mode:s,args:["-c",h,"--",...t],stdin:a,cwd:i,shell:o,env:c})}return{stderr:`${n}: command not found`,exitCode:127}}try{return await l.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:[n,...t].join(" "),mode:s,args:t,stdin:a,cwd:i,shell:o,env:c})}catch(u){return{stderr:u instanceof Error?u.message:"Command failed",exitCode:1}}}async function bt(n,t,e,r,s,i,o,a){let c=n.trim();if(c.length===0)return{exitCode:0};let f=a??Kr(t,e),u=Ui(c)[0]?.toLowerCase()??"",h=f.vars[`__alias_${u}`],p=h?c.replace(u,h):c;if(/(?<![|&])[|](?![|])/.test(p)||p.includes(">")||p.includes("<")||p.includes("&&")||p.includes("||")||p.includes(";")){let C=vd(p);if(!C.isValid)return{stderr:C.error||"Syntax error",exitCode:1};try{return await kd(C.statements,t,e,r,s,i,f)}catch(F){return{stderr:F instanceof Error?F.message:"Execution failed",exitCode:1}}}let E=await Ds(p,f.vars,f.lastExitCode,C=>bt(C,t,e,r,s,i,void 0,f).then(F=>F.stdout??"")),x=Ui(E.trim()),k=x[0]?.toLowerCase()??"",D=x.slice(1),H=Cn(k);if(!H){let C=Bd(k,f,i,t);if(C){let F=i.vfs.readFile(C),V=F.match(/exec\s+builtin\s+(\S+)/);if(V){let b=V[1],S=Cn(b);if(S)return await S.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:[k,...D].join(" "),mode:r,args:D,stdin:o,cwd:s,shell:i,env:f})}let N=Cn("sh");if(N)return await N.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:`sh -c ${JSON.stringify(F)}`,mode:r,args:["-c",F,"--",...D],stdin:o,cwd:s,shell:i,env:f})}return{stderr:`${k}: command not found`,exitCode:127}}try{return await H.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:E,mode:r,args:D,stdin:o,cwd:s,shell:i,env:f})}catch(C){return{stderr:C instanceof Error?C.message:"Command failed",exitCode:1}}}async function ic(n,t,e,r){return Ds(n,t,e,s=>bt(s,r.authUser,r.hostname,r.mode,r.cwd,r.shell,void 0,r.env).then(i=>i.stdout??""))}function lr(n){let t=[],e=0;for(;e<n.length;){let r=n[e].trim();if(!r||r.startsWith("#")){e++;continue}if(r.startsWith("if ")||r==="if"){let s=r.replace(/^if\s+/,"").replace(/;\s*then\s*$/,"").trim(),i=[],o=[],a=[],c="then",f="";for(e++;e<n.length&&n[e]?.trim()!=="fi";){let l=n[e].trim();l.startsWith("elif ")?(c="elif",f=l.replace(/^elif\s+/,"").replace(/;\s*then\s*$/,"").trim(),o.push({cond:f,body:[]})):l==="else"?c="else":l!=="then"&&(c==="then"?i.push(l):c==="elif"&&o.length>0?o[o.length-1].body.push(l):a.push(l)),e++}t.push({type:"if",cond:s,then_:i,elif:o,else_:a})}else if(r.startsWith("for ")){let s=r.match(/^for\s+(\w+)\s+in\s+(.+?)(?:\s*;\s*do)?$/);if(s){let i=[];for(e++;e<n.length&&n[e]?.trim()!=="done";){let o=n[e].trim().replace(/^do\s+/,"");o&&o!=="do"&&i.push(o),e++}t.push({type:"for",var:s[1],list:s[2],body:i})}else t.push({type:"cmd",line:r})}else if(r.startsWith("while ")){let s=r.replace(/^while\s+/,"").replace(/;\s*do\s*$/,"").trim(),i=[];for(e++;e<n.length&&n[e]?.trim()!=="done";){let o=n[e].trim().replace(/^do\s+/,"");o&&o!=="do"&&i.push(o),e++}t.push({type:"while",cond:s,body:i})}else t.push({type:"cmd",line:r});e++}return t}async function rc(n,t){let e=await ic(n,t.env.vars,t.env.lastExitCode,t),r=e.match(/^\[?\s*(.+?)\s*\]?$/);if(r){let i=r[1],o=i.match(/^-([fdeznr])\s+(.+)$/);if(o){let[,f,l]=o,u=le(t.cwd,l);if(f==="f")return t.shell.vfs.exists(u)&&t.shell.vfs.stat(u).type==="file";if(f==="d")return t.shell.vfs.exists(u)&&t.shell.vfs.stat(u).type==="directory";if(f==="e")return t.shell.vfs.exists(u);if(f==="z")return(l??"").length===0;if(f==="n")return(l??"").length>0}let a=i.match(/^"?([^"]*)"?\s*(==|!=|=|<|>)\s*"?([^"]*)"?$/);if(a){let[,f,l,u]=a;if(l==="=="||l==="=")return f===u;if(l==="!=")return f!==u}let c=i.match(/^(\S+)\s+(-eq|-ne|-lt|-le|-gt|-ge)\s+(\S+)$/);if(c){let[,f,l,u]=c,h=Number(f),p=Number(u);if(l==="-eq")return h===p;if(l==="-ne")return h!==p;if(l==="-lt")return h<p;if(l==="-le")return h<=p;if(l==="-gt")return h>p;if(l==="-ge")return h>=p}}return((await bt(e,t.authUser,t.hostname,t.mode,t.cwd,t.shell,void 0,t.env)).exitCode??0)===0}async function ur(n,t){let e={exitCode:0},r="";for(let s of n)if(s.type==="cmd"){let i=await ic(s.line,t.env.vars,t.env.lastExitCode,t),o=/^([A-Za-z_][A-Za-z0-9_]*)=(.*)/,a=i.trim().split(/\s+/);if(a.length>0&&o.test(a[0])&&a.every(l=>o.test(l))){for(let l of a){let u=l.match(o);t.env.vars[u[1]]=u[2]}t.env.lastExitCode=0;continue}let c=await bt(i,t.authUser,t.hostname,t.mode,t.cwd,t.shell,void 0,t.env);if(t.env.lastExitCode=c.exitCode??0,c.stdout&&(r+=`${c.stdout}
188
- `),c.stderr)return{...c,stdout:r.trim()};e=c}else if(s.type==="if"){let i=!1;if(await rc(s.cond,t)){let o=await ur(lr(s.then_),t);o.stdout&&(r+=`${o.stdout}
189
- `),i=!0}else{for(let o of s.elif)if(await rc(o.cond,t)){let a=await ur(lr(o.body),t);a.stdout&&(r+=`${a.stdout}
190
- `),i=!0;break}if(!i&&s.else_.length>0){let o=await ur(lr(s.else_),t);o.stdout&&(r+=`${o.stdout}
191
- `)}}}else if(s.type==="for"){let o=(await ic(s.list,t.env.vars,t.env.lastExitCode,t)).trim().split(/\s+/);for(let a of o){t.env.vars[s.var]=a;let c=await ur(lr(s.body),t);if(c.stdout&&(r+=`${c.stdout}
192
- `),c.closeSession)return c}}else if(s.type==="while"){let i=0;for(;i<1e3&&await rc(s.cond,t);){let o=await ur(lr(s.body),t);if(o.stdout&&(r+=`${o.stdout}
193
- `),o.closeSession)return o;i++}}return{...e,stdout:r.trim()||e.stdout}}var Rd={name:"sh",aliases:["bash"],description:"Execute shell script or command",category:"shell",params:["-c <script>","[<file>]"],run:async n=>{let{args:t,shell:e,cwd:r}=n;if(se(t,"-c")){let i=t[t.indexOf("-c")+1]??"";if(!i)return{stderr:"sh: -c requires a script",exitCode:1};let o=i.split(/[;\n]/).map(c=>c.trim()).filter(c=>c&&!c.startsWith("#")),a=lr(o);return ur(a,n)}let s=t[0];if(s){let i=le(r,s);if(!e.vfs.exists(i))return{stderr:`sh: ${s}: No such file or directory`,exitCode:1};let a=e.vfs.readFile(i).split(`
194
- `).map(f=>f.trim()).filter(f=>f&&!f.startsWith("#")),c=lr(a);return ur(c,n)}return{stderr:"sh: invalid usage. Use: sh -c 'cmd' or sh <file>",exitCode:1}}};var Nd={name:"shift",description:"Shift positional parameters",category:"shell",params:["[n]"],run:({args:n,env:t})=>{if(!t)return{exitCode:0};let e=parseInt(n[0]??"1",10)||1,r=t.vars.__argv?.split("\0").filter(Boolean)??[];t.vars.__argv=r.slice(e).join("\0");let s=r.slice(e);for(let i=1;i<=9;i++)t.vars[String(i)]=s[i-1]??"";return{exitCode:0}}},Pd={name:"trap",description:"Trap signals and events",category:"shell",params:["[action] [signal...]"],run:({args:n,env:t})=>{if(!t||n.length===0)return{exitCode:0};let e=n[0]??"",r=n.slice(1);for(let s of r)t.vars[`__trap_${s.toUpperCase()}`]=e;return{exitCode:0}}},Td={name:"return",description:"Return from a shell function",category:"shell",params:["[n]"],run:({args:n,env:t})=>{let e=parseInt(n[0]??"0",10);return t&&(t.lastExitCode=e),{exitCode:e}}};var Ld={name:"sleep",description:"Delay execution",category:"system",params:["<seconds>"],run:async({args:n})=>{let t=parseFloat(n[0]??"1");return Number.isNaN(t)||t<0?{stderr:"sleep: invalid time",exitCode:1}:(await new Promise(e=>setTimeout(e,t*1e3)),{exitCode:0})}};var Ud={name:"sort",description:"Sort lines of text",category:"text",params:["[-r] [-n] [-u] [-k <col>] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-r"]),o=se(r,["-n"]),a=se(r,["-u"]),c=r.filter(y=>!y.startsWith("-")),u=[...(c.length>0?c.map(y=>{try{return Oe(n,le(e,y),"sort"),t.vfs.readFile(le(e,y))}catch{return""}}).join(`
191
+ `||a[1]==="\r"?"":a[1]);if(!e)return{exitCode:0};if(s.length===0)e.vars.REPLY=o;else if(s.length===1)e.vars[s[0]]=o;else{let a=o.split(/\s+/);for(let c=0;c<s.length;c++)e.vars[s[c]]=c<s.length-1?a[c]??"":a.slice(c).join(" ")}return{exitCode:0}}};var Bd={name:"rm",description:"Remove files or directories",category:"files",params:["[-r|-rf] <path>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"rm: missing operand",exitCode:1};let s=se(r,["-r","-rf","-fr"]),i=[];for(let o=0;;o+=1){let a=Jn(r,o,{flags:["-r","-rf","-fr"]});if(!a)break;i.push(a)}if(i.length===0)return{stderr:"rm: missing operand",exitCode:1};for(let o of i){let a=le(e,o);Oe(n,a,"rm"),t.vfs.remove(a,{recursive:s})}return{exitCode:0}}};var Rd={name:"sed",description:"Stream editor for filtering and transforming text",category:"text",params:["-e <expr> [file]","s/pattern/replace/[g]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-i"]),o=tn(r,["-e"])??r.find(b=>!b.startsWith("-")),a=r.filter(b=>!b.startsWith("-")&&b!==o).pop();if(!o)return{stderr:"sed: no expression",exitCode:1};let c=s??"";if(a){let b=le(e,a);try{c=t.vfs.readFile(b)}catch{return{stderr:`sed: ${a}: No such file or directory`,exitCode:1}}}let f=o.match(/^s([^a-zA-Z0-9])(.+?)\1(.*?)\1([gi]*)$/);if(!f)return{stderr:`sed: unrecognized command: ${o}`,exitCode:1};let[,,l,u,h]=f,p=(h??"").includes("i")?"gi":(h??"").includes("g")?"g":"",y;try{y=new RegExp(l,p||"")}catch{return{stderr:`sed: invalid regex: ${l}`,exitCode:1}}let E=((h??"").includes("g")||p.includes("g"),c.replace(y,u??""));if(i&&a){let b=le(e,a);return t.writeFileAsUser(n,b,E),{exitCode:0}}return{stdout:E,exitCode:0}}};var Nd={name:"set",description:"Display or set shell variables",category:"shell",params:["[VAR=value]"],run:({args:n,env:t})=>{if(n.length===0)return{stdout:Object.entries(t.vars).map(([r,s])=>`${r}=${s}`).join(`
192
+ `),exitCode:0};for(let e of n)if(e.includes("=")){let r=e.indexOf("=");t.vars[e.slice(0,r)]=e.slice(r+1)}return{exitCode:0}}};Wr();async function Pd(n,t,e,r,s,i,o){let a={exitCode:0},c=[],f=s,l=0;for(;l<n.length;){let h=n[l];if(a=await QA(h.pipeline,t,e,r,f,i,o),o.lastExitCode=a.exitCode??0,a.nextCwd&&(a.exitCode??0)===0&&(f=a.nextCwd),a.stdout&&c.push(a.stdout),a.closeSession||a.switchUser)return{...a,stdout:c.join("")||a.stdout};let p=h.op;if(!(!p||p===";")){if(p==="&&"){if((a.exitCode??0)!==0)for(;l<n.length&&n[l]?.op==="&&";)l++}else if(p==="||"&&(a.exitCode??0)===0)for(;l<n.length&&n[l]?.op==="||";)l++}l++}let u=c.join("");return{...a,stdout:u||a.stdout,nextCwd:f!==s?f:void 0}}async function QA(n,t,e,r,s,i,o){if(!n.isValid)return{stderr:n.error||"Syntax error",exitCode:1};if(n.commands.length===0)return{exitCode:0};let a=o??{vars:{},lastExitCode:0};return n.commands.length===1?WA(n.commands[0],t,e,r,s,i,a):qA(n.commands,t,e,r,s,i,a)}async function WA(n,t,e,r,s,i,o){let a;if(n.inputFile){let f=le(s,n.inputFile);try{a=i.vfs.readFile(f)}catch{return{stderr:`${n.inputFile}: No such file or directory`,exitCode:1}}}let c=await zs(n.name,n.args,t,e,r,s,i,a,o);if(n.outputFile){let f=le(s,n.outputFile),l=c.stdout||"";try{if(n.appendOutput){let u=(()=>{try{return i.vfs.readFile(f)}catch{return""}})();i.writeFileAsUser(t,f,u+l)}else i.writeFileAsUser(t,f,l);return{...c,stdout:""}}catch{return{...c,stderr:`Failed to write to ${n.outputFile}`,exitCode:1}}}return c}async function qA(n,t,e,r,s,i,o){let a="",c=0;for(let f=0;f<n.length;f++){let l=n[f];if(f===0&&l.inputFile){let h=le(s,l.inputFile);try{a=i.vfs.readFile(h)}catch{return{stderr:`${l.inputFile}: No such file or directory`,exitCode:1}}}let u=await zs(l.name,l.args,t,e,r,s,i,a,o);if(c=u.exitCode??0,f===n.length-1&&l.outputFile){let h=le(s,l.outputFile),p=u.stdout||"";try{if(l.appendOutput){let y=(()=>{try{return i.vfs.readFile(h)}catch{return""}})();i.writeFileAsUser(t,h,y+p)}else i.writeFileAsUser(t,h,p);a=""}catch{return{stderr:`Failed to write to ${l.outputFile}`,exitCode:1}}}else a=u.stdout||"";if(u.stderr&&c!==0)return{stderr:u.stderr,exitCode:c};if(u.closeSession||u.switchUser)return u}return{stdout:a,exitCode:c}}function Oi(n){let t=[],e="",r=!1,s="",i=0;for(;i<n.length;){let o=n[i],a=n[i+1];if((o==='"'||o==="'")&&!r){r=!0,s=o,i++;continue}if(r&&o===s){r=!1,s="",i++;continue}if(r){e+=o,i++;continue}if(o===" "){e&&(t.push(e),e=""),i++;continue}if(!r&&o==="2"&&a===">"){let c=n.slice(i+1);if(c.startsWith(">>&1")||c.startsWith(">> &1")){e&&(t.push(e),e=""),t.push("2>>&1"),i+=5;continue}if(c.startsWith(">&1")){e&&(t.push(e),e=""),t.push("2>&1"),i+=4;continue}if(c.startsWith(">>")){e&&(t.push(e),e=""),t.push("2>>"),i+=3;continue}if(c.startsWith(">")){e&&(t.push(e),e=""),t.push("2>"),i+=2;continue}}if((o===">"||o==="<")&&!r){e&&(t.push(e),e=""),o===">"&&a===">"?(t.push(">>"),i+=2):(t.push(o),i++);continue}e+=o,i++}return e&&t.push(e),t}function Td(n){let t=n.trim();if(!t)return{statements:[],isValid:!0};try{return{statements:KA(t),isValid:!0}}catch(e){return{statements:[],isValid:!1,error:e.message}}}function KA(n){let t=VA(n),e=[];for(let r of t){let i={pipeline:{commands:GA(r.text.trim()),isValid:!0}};r.op&&(i.op=r.op),e.push(i)}return e}function VA(n){let t=[],e="",r=0,s=!1,i="",o=0,a=c=>{e.trim()&&t.push({text:e,op:c}),e=""};for(;o<n.length;){let c=n[o],f=n.slice(o,o+2);if((c==='"'||c==="'")&&!s){s=!0,i=c,e+=c,o++;continue}if(s&&c===i){s=!1,e+=c,o++;continue}if(s){e+=c,o++;continue}if(c==="("){r++,e+=c,o++;continue}if(c===")"){r--,e+=c,o++;continue}if(r>0){e+=c,o++;continue}if(f==="&&"){a("&&"),o+=2;continue}if(f==="||"){a("||"),o+=2;continue}if(c===";"){a(";"),o++;continue}e+=c,o++}return a(),t}function GA(n){return zA(n).map(YA)}function zA(n){let t=[],e="",r=!1,s="";for(let o=0;o<n.length;o++){let a=n[o];if((a==='"'||a==="'")&&!r){r=!0,s=a,e+=a;continue}if(r&&a===s){r=!1,e+=a;continue}if(r){e+=a;continue}if(a==="|"&&n[o+1]!=="|"){if(!e.trim())throw new Error("Syntax error near unexpected token '|'");t.push(e.trim()),e=""}else e+=a}let i=e.trim();if(!i&&t.length>0)throw new Error("Syntax error near unexpected token '|'");return i&&t.push(i),t}function YA(n){let t=Oi(n);if(t.length===0)return{name:"",args:[]};let e=[],r,s,i=!1,o=0,a,c=!1,f=!1;for(;o<t.length;){let u=t[o];if(u==="<"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after <");r=t[o],o++}else if(u===">>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after >>");s=t[o],i=!0,o++}else if(u===">"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after >");s=t[o],i=!1,o++}else if(u==="2>&1")f=!0,o++;else if(u==="2>>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after 2>>");a=t[o],c=!0,o++}else if(u==="2>"){if(o++,o>=t.length)throw new Error("Syntax error: expected filename after 2>");a=t[o],c=!1,o++}else e.push(u),o++}return{name:(e[0]??"").toLowerCase(),args:e.slice(1),inputFile:r,outputFile:s,appendOutput:i,stderrFile:a,stderrAppend:c,stderrToStdout:f}}Wr();function Vr(n,t){return{vars:{PATH:"/usr/local/bin:/usr/bin:/bin",HOME:`/home/${n}`,USER:n,LOGNAME:n,SHELL:"/bin/sh",TERM:"xterm-256color",HOSTNAME:t,PS1:"\\u@\\h:\\w\\$ "},lastExitCode:0}}function Ld(n,t,e,r){if(n.startsWith("/")){if(!e.vfs.exists(n))return null;try{let i=e.vfs.stat(n);return i.type!=="file"||!(i.mode&73)||(n.startsWith("/sbin/")||n.startsWith("/usr/sbin/"))&&r!=="root"?null:n}catch{return null}}let s=(t.vars.PATH??"/usr/local/bin:/usr/bin:/bin").split(":");for(let i of s){if((i==="/sbin"||i==="/usr/sbin")&&r!=="root")continue;let o=`${i}/${n}`;if(e.vfs.exists(o))try{let a=e.vfs.stat(o);if(a.type!=="file"||!(a.mode&73))continue;return o}catch{}}return null}async function zs(n,t,e,r,s,i,o,a,c){let f=c.vars[`__alias_${n}`];if(f)return xt(`${f} ${t.join(" ")}`,e,r,s,i,o,a,c);let l=yn(n);if(!l){let u=Ld(n,c,o,e);if(u){let h=o.vfs.readFile(u),p=h.match(/exec\s+builtin\s+(\S+)/);if(p){let E=yn(p[1]);if(E)return await E.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:[n,...t].join(" "),mode:s,args:t,stdin:a,cwd:i,shell:o,env:c})}let y=yn("sh");if(y)return await y.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:`sh -c ${JSON.stringify(h)}`,mode:s,args:["-c",h,"--",...t],stdin:a,cwd:i,shell:o,env:c})}return{stderr:`${n}: command not found`,exitCode:127}}try{return await l.run({authUser:e,hostname:r,activeSessions:o.users.listActiveSessions(),rawInput:[n,...t].join(" "),mode:s,args:t,stdin:a,cwd:i,shell:o,env:c})}catch(u){return{stderr:u instanceof Error?u.message:"Command failed",exitCode:1}}}async function xt(n,t,e,r,s,i,o,a){let c=n.trim();if(c.length===0)return{exitCode:0};let f=a??Vr(t,e),u=Oi(c)[0]?.toLowerCase()??"",h=f.vars[`__alias_${u}`],p=h?c.replace(u,h):c,y=/\bfor\s+\w+\s+in\b/.test(p)||/\bwhile\s+/.test(p)||/\bif\s+/.test(p)||/\w+\s*\(\s*\)\s*\{/.test(p)||/\bfunction\s+\w+/.test(p)||/\(\(\s*.+\s*\)\)/.test(p),E=/(?<![|&])[|](?![|])/.test(p)||p.includes(">")||p.includes("<")||p.includes("&&")||p.includes("||")||p.includes(";");if(y&&u!=="sh"&&u!=="bash"||E){if(y&&u!=="sh"&&u!=="bash"){let Q=yn("sh");if(Q)return await Q.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:p,mode:r,args:["-c",p],stdin:void 0,cwd:s,shell:i,env:f})}let M=Td(p);if(!M.isValid)return{stderr:M.error||"Syntax error",exitCode:1};try{return await Pd(M.statements,t,e,r,s,i,f)}catch(Q){return{stderr:Q instanceof Error?Q.message:"Execution failed",exitCode:1}}}let b=await Pi(p,f.vars,f.lastExitCode,M=>xt(M,t,e,r,s,i,void 0,f).then(Q=>Q.stdout??"")),C=Oi(b.trim()),N=C[0]?.toLowerCase()??"",H=C.slice(1).flatMap(Ni),v=yn(N);if(!v){let M=Ld(N,f,i,t);if(M){let Q=i.vfs.readFile(M),P=Q.match(/exec\s+builtin\s+(\S+)/);if(P){let w=P[1],I=yn(w);if(I)return await I.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:[N,...H].join(" "),mode:r,args:H,stdin:o,cwd:s,shell:i,env:f})}let x=yn("sh");if(x)return await x.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:`sh -c ${JSON.stringify(Q)}`,mode:r,args:["-c",Q,"--",...H],stdin:o,cwd:s,shell:i,env:f})}return{stderr:`${N}: command not found`,exitCode:127}}try{return await v.run({authUser:t,hostname:e,activeSessions:i.users.listActiveSessions(),rawInput:b,mode:r,args:H,stdin:o,cwd:s,shell:i,env:f})}catch(M){return{stderr:M instanceof Error?M.message:"Command failed",exitCode:1}}}async function cc(n,t,e,r){return Pi(n,t,e,s=>xt(s,r.authUser,r.hostname,r.mode,r.cwd,r.shell,void 0,r.env).then(i=>i.stdout??""))}function Zn(n){let t=[],e=0;for(;e<n.length;){let r=n[e].trim();if(!r||r.startsWith("#")){e++;continue}let s=r.match(/^(?:function\s+)?(\w+)\s*\(\s*\)\s*\{(.+)\}\s*$/),i=s??(r.match(/^(?:function\s+)?(\w+)\s*\(\s*\)\s*\{?\s*$/)||r.match(/^function\s+(\w+)\s*\{?\s*$/));if(i){let a=i[1],c=[];if(s){c.push(...s[2].split(";").map(f=>f.trim()).filter(Boolean)),t.push({type:"func",name:a,body:c}),e++;continue}for(e++;e<n.length&&n[e]?.trim()!=="}"&&e<n.length+1;){let f=n[e].trim().replace(/^do\s+/,"");f&&f!=="{"&&c.push(f),e++}e++,t.push({type:"func",name:a,body:c});continue}let o=r.match(/^\(\(\s*(.+?)\s*\)\)$/);if(o){t.push({type:"arith",expr:o[1]}),e++;continue}if(r.startsWith("if ")||r==="if"){let a=r.replace(/^if\s+/,"").replace(/;\s*then\s*$/,"").trim(),c=[],f=[],l=[],u="then",h="";for(e++;e<n.length&&n[e]?.trim()!=="fi";){let p=n[e].trim();p.startsWith("elif ")?(u="elif",h=p.replace(/^elif\s+/,"").replace(/;\s*then\s*$/,"").trim(),f.push({cond:h,body:[]})):p==="else"?u="else":p!=="then"&&(u==="then"?c.push(p):u==="elif"&&f.length>0?f[f.length-1].body.push(p):l.push(p)),e++}t.push({type:"if",cond:a,then_:c,elif:f,else_:l})}else if(r.startsWith("for ")){let a=r.match(/^for\s+(\w+)\s+in\s+(.+?)(?:\s*;\s*do)?$/);if(a){let c=[];for(e++;e<n.length&&n[e]?.trim()!=="done";){let f=n[e].trim().replace(/^do\s+/,"");f&&f!=="do"&&c.push(f),e++}t.push({type:"for",var:a[1],list:a[2],body:c})}else t.push({type:"cmd",line:r})}else if(r.startsWith("while ")){let a=r.replace(/^while\s+/,"").replace(/;\s*do\s*$/,"").trim(),c=[];for(e++;e<n.length&&n[e]?.trim()!=="done";){let f=n[e].trim().replace(/^do\s+/,"");f&&f!=="do"&&c.push(f),e++}t.push({type:"while",cond:a,body:c})}else t.push({type:"cmd",line:r});e++}return t}async function ac(n,t){let e=await cc(n,t.env.vars,t.env.lastExitCode,t),r=e.match(/^\[?\s*(.+?)\s*\]?$/);if(r){let i=r[1],o=i.match(/^-([fdeznr])\s+(.+)$/);if(o){let[,f,l]=o,u=le(t.cwd,l);if(f==="f")return t.shell.vfs.exists(u)&&t.shell.vfs.stat(u).type==="file";if(f==="d")return t.shell.vfs.exists(u)&&t.shell.vfs.stat(u).type==="directory";if(f==="e")return t.shell.vfs.exists(u);if(f==="z")return(l??"").length===0;if(f==="n")return(l??"").length>0}let a=i.match(/^"?([^"]*)"?\s*(==|!=|=|<|>)\s*"?([^"]*)"?$/);if(a){let[,f,l,u]=a;if(l==="=="||l==="=")return f===u;if(l==="!=")return f!==u}let c=i.match(/^(\S+)\s+(-eq|-ne|-lt|-le|-gt|-ge)\s+(\S+)$/);if(c){let[,f,l,u]=c,h=Number(f),p=Number(u);if(l==="-eq")return h===p;if(l==="-ne")return h!==p;if(l==="-lt")return h<p;if(l==="-le")return h<=p;if(l==="-gt")return h>p;if(l==="-ge")return h>=p}}return((await xt(e,t.authUser,t.hostname,t.mode,t.cwd,t.shell,void 0,t.env)).exitCode??0)===0}async function er(n,t){let e={exitCode:0},r="";for(let s of n)if(s.type==="cmd"){let i=await cc(s.line,t.env.vars,t.env.lastExitCode,t),o=/^([A-Za-z_][A-Za-z0-9_]*)=(.*)/,a=i.trim().split(/\s+/);if(a.length>0&&o.test(a[0])&&a.every(l=>o.test(l))){for(let l of a){let u=l.match(o);t.env.vars[u[1]]=u[2]}t.env.lastExitCode=0;continue}let c=await(async()=>{let f=i.trim().split(/\s+/)[0]??"",l=t.env.vars[`__func_${f}`];if(l){let u=i.trim().split(/\s+/).slice(1),h={...t.env.vars};u.forEach((E,b)=>{t.env.vars[String(b+1)]=E}),t.env.vars[0]=f;let p=l.split(`
193
+ `),y=await er(Zn(p),t);for(let E=1;E<=u.length;E++)delete t.env.vars[String(E)];return Object.assign(t.env.vars,{...h,...t.env.vars}),y}return xt(i,t.authUser,t.hostname,t.mode,t.cwd,t.shell,void 0,t.env)})();if(t.env.lastExitCode=c.exitCode??0,c.stdout&&(r+=`${c.stdout}
194
+ `),c.stderr)return{...c,stdout:r.trim()};e=c}else if(s.type==="if"){let i=!1;if(await ac(s.cond,t)){let o=await er(Zn(s.then_),t);o.stdout&&(r+=`${o.stdout}
195
+ `),i=!0}else{for(let o of s.elif)if(await ac(o.cond,t)){let a=await er(Zn(o.body),t);a.stdout&&(r+=`${a.stdout}
196
+ `),i=!0;break}if(!i&&s.else_.length>0){let o=await er(Zn(s.else_),t);o.stdout&&(r+=`${o.stdout}
197
+ `)}}}else if(s.type==="func")t.env.vars[`__func_${s.name}`]=s.body.join(`
198
+ `);else if(s.type==="arith"){let{expandSync:i}=await Promise.resolve().then(()=>(Wr(),Za)),o=i(s.expr,t.env.vars,t.env.lastExitCode),a=o.match(/^(\w+)\s*(\+\+|--)$/);if(a){let c=parseInt(t.env.vars[a[1]]??"0",10);t.env.vars[a[1]]=String(a[2]==="++"?c+1:c-1)}else{let c=o.match(/^(\w+)\s*([+\-*/])=\s*(.+)$/);if(c){let f=parseInt(t.env.vars[c[1]]??"0",10),l=parseInt(c[3],10),u={"+":f+l,"-":f-l,"*":f*l,"/":Math.floor(f/l)};t.env.vars[c[1]]=String(u[c[2]]??f)}}}else if(s.type==="for"){let i=await cc(s.list,t.env.vars,t.env.lastExitCode,t),{expandBraces:o}=await Promise.resolve().then(()=>(Wr(),Za)),a=i.trim().split(/\s+/).flatMap(o);for(let c of a){t.env.vars[s.var]=c;let f=await er(Zn(s.body),t);if(f.stdout&&(r+=`${f.stdout}
199
+ `),f.closeSession)return f}}else if(s.type==="while"){let i=0;for(;i<1e3&&await ac(s.cond,t);){let o=await er(Zn(s.body),t);if(o.stdout&&(r+=`${o.stdout}
200
+ `),o.closeSession)return o;i++}}return{...e,stdout:r.trim()||e.stdout}}function Ud(n){let t=[],e="",r=0,s=!1,i=!1,o=0;for(;o<n.length;){let c=n[o];if(!s&&!i){if(c==="'"){s=!0,e+=c,o++;continue}if(c==='"'){i=!0,e+=c,o++;continue}if(c==="{"){r++,e+=c,o++;continue}if(c==="}"){if(r--,e+=c,o++,r===0){let f=e.trim();for(f&&t.push(f),e="";o<n.length&&(n[o]===";"||n[o]===" ");)o++}continue}if(r===0&&(c===";"||c===`
201
+ `)){let f=e.trim();f&&!f.startsWith("#")&&t.push(f),e="",o++;continue}}else s&&c==="'"?s=!1:i&&c==='"'&&(i=!1);e+=c,o++}let a=e.trim();return a&&!a.startsWith("#")&&t.push(a),t}var Dd={name:"sh",aliases:["bash"],description:"Execute shell script or command",category:"shell",params:["-c <script>","[<file>]"],run:async n=>{let{args:t,shell:e,cwd:r}=n;if(se(t,"-c")){let i=t[t.indexOf("-c")+1]??"";if(!i)return{stderr:"sh: -c requires a script",exitCode:1};let o=Ud(i),a=Zn(o);return er(a,n)}let s=t[0];if(s){let i=le(r,s);if(!e.vfs.exists(i))return{stderr:`sh: ${s}: No such file or directory`,exitCode:1};let o=e.vfs.readFile(i),a=Ud(o),c=Zn(a);return er(c,n)}return{stderr:"sh: invalid usage. Use: sh -c 'cmd' or sh <file>",exitCode:1}}};var $d={name:"shift",description:"Shift positional parameters",category:"shell",params:["[n]"],run:({args:n,env:t})=>{if(!t)return{exitCode:0};let e=parseInt(n[0]??"1",10)||1,r=t.vars.__argv?.split("\0").filter(Boolean)??[];t.vars.__argv=r.slice(e).join("\0");let s=r.slice(e);for(let i=1;i<=9;i++)t.vars[String(i)]=s[i-1]??"";return{exitCode:0}}},Od={name:"trap",description:"Trap signals and events",category:"shell",params:["[action] [signal...]"],run:({args:n,env:t})=>{if(!t||n.length===0)return{exitCode:0};let e=n[0]??"",r=n.slice(1);for(let s of r)t.vars[`__trap_${s.toUpperCase()}`]=e;return{exitCode:0}}},Md={name:"return",description:"Return from a shell function",category:"shell",params:["[n]"],run:({args:n,env:t})=>{let e=parseInt(n[0]??"0",10);return t&&(t.lastExitCode=e),{exitCode:e}}};var Fd={name:"sleep",description:"Delay execution",category:"system",params:["<seconds>"],run:async({args:n})=>{let t=parseFloat(n[0]??"1");return Number.isNaN(t)||t<0?{stderr:"sleep: invalid time",exitCode:1}:(await new Promise(e=>setTimeout(e,t*1e3)),{exitCode:0})}};var Hd={name:"sort",description:"Sort lines of text",category:"text",params:["[-r] [-n] [-u] [-k <col>] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-r"]),o=se(r,["-n"]),a=se(r,["-u"]),c=r.filter(y=>!y.startsWith("-")),u=[...(c.length>0?c.map(y=>{try{return Oe(n,le(e,y),"sort"),t.vfs.readFile(le(e,y))}catch{return""}}).join(`
195
202
  `):s??"").split(`
196
203
  `).filter(Boolean)].sort((y,E)=>o?Number(y)-Number(E):y.localeCompare(E)),h=i?u.reverse():u;return{stdout:(a?[...new Set(h)]:h).join(`
197
- `),exitCode:0}}};var Dd={name:"source",aliases:["."],description:"Execute commands from a file in the current shell environment",category:"shell",params:["<file> [args...]"],run:async({args:n,authUser:t,hostname:e,cwd:r,shell:s,env:i})=>{let o=n[0];if(!o)return{stderr:"source: missing filename",exitCode:1};let a=le(r,o);if(!s.vfs.exists(a))return{stderr:`source: ${o}: No such file or directory`,exitCode:1};let c=s.vfs.readFile(a),f=0;for(let l of c.split(`
198
- `)){let u=l.trim();if(!u||u.startsWith("#"))continue;let h=await bt(u,t,e,"shell",r,s,void 0,i);if(f=h.exitCode??0,h.closeSession||h.switchUser)return h}return{exitCode:f}}};var $d={name:"su",description:"Switch user",category:"users",params:["[-] [-c <cmd>] [username]"],run:async({authUser:n,shell:t,args:e,hostname:r,mode:s,cwd:i})=>{let o=e.includes("-")||e.includes("-l")||e.includes("--login"),a=e.indexOf("-c"),c=a!==-1?e[a+1]:void 0,l=e.filter((u,h)=>h!==a&&h!==a+1).filter(u=>u!=="-"&&u!=="-l"&&u!=="--login").find(u=>!u.startsWith("-"))??"root";return t.users.listUsers().includes(l)?n==="root"?c?bt(c,l,r,s,o?`/home/${l}`:i,t):{switchUser:l,nextCwd:o?`/home/${l}`:void 0,exitCode:0}:t.users.isSudoer(n)?{sudoChallenge:{username:l,targetUser:l,commandLine:c??null,loginShell:o,prompt:"Password: "},exitCode:0}:{stderr:`su: permission denied
204
+ `),exitCode:0}}};var Qd={name:"source",aliases:["."],description:"Execute commands from a file in the current shell environment",category:"shell",params:["<file> [args...]"],run:async({args:n,authUser:t,hostname:e,cwd:r,shell:s,env:i})=>{let o=n[0];if(!o)return{stderr:"source: missing filename",exitCode:1};let a=le(r,o);if(!s.vfs.exists(a))return{stderr:`source: ${o}: No such file or directory`,exitCode:1};let c=s.vfs.readFile(a),f=0;for(let l of c.split(`
205
+ `)){let u=l.trim();if(!u||u.startsWith("#"))continue;let h=await xt(u,t,e,"shell",r,s,void 0,i);if(f=h.exitCode??0,h.closeSession||h.switchUser)return h}return{exitCode:f}}};var Wd={name:"su",description:"Switch user",category:"users",params:["[-] [-c <cmd>] [username]"],run:async({authUser:n,shell:t,args:e,hostname:r,mode:s,cwd:i})=>{let o=e.includes("-")||e.includes("-l")||e.includes("--login"),a=e.indexOf("-c"),c=a!==-1?e[a+1]:void 0,l=e.filter((u,h)=>h!==a&&h!==a+1).filter(u=>u!=="-"&&u!=="-l"&&u!=="--login").find(u=>!u.startsWith("-"))??"root";return t.users.listUsers().includes(l)?n==="root"?c?xt(c,l,r,s,o?`/home/${l}`:i,t):{switchUser:l,nextCwd:o?`/home/${l}`:void 0,exitCode:0}:t.users.isSudoer(n)?{sudoChallenge:{username:l,targetUser:l,commandLine:c??null,loginShell:o,prompt:"Password: "},exitCode:0}:{stderr:`su: permission denied
199
206
  `,exitCode:1}:{stderr:`su: user '${l}' does not exist
200
- `,exitCode:1}}};function WA(n){let{flags:t,flagsWithValues:e,positionals:r}=Yt(n,{flags:["-i","-S"],flagsWithValue:["-u","--user"]}),s=t.has("-i"),i=e.get("-u")||e.get("--user")||"root",o=r.length>0?r.join(" "):null;return{targetUser:i,loginShell:s,commandLine:o}}var Od={name:"sudo",description:"Execute as superuser",category:"users",params:["<command...>"],run:async({authUser:n,hostname:t,mode:e,cwd:r,shell:s,args:i})=>{let{targetUser:o,loginShell:a,commandLine:c}=WA(i);if(n!=="root"&&!s.users.isSudoer(n))return{stderr:"sudo: permission denied",exitCode:1};let f=o||"root",l=`[sudo] password for ${n}: `;return n==="root"?!c&&a?{switchUser:f,nextCwd:`/home/${f}`,exitCode:0}:c?bt(c,f,t,e,a?`/home/${f}`:r,s):{stderr:"sudo: missing command",exitCode:1}:{sudoChallenge:{username:n,targetUser:f,commandLine:c,loginShell:a,prompt:l},exitCode:0}}};var Md={name:"tail",description:"Output last lines",category:"text",params:["[-n <lines>] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=en(r,["-n"]),o=r.find(u=>/^-\d+$/.test(u)),a=typeof i=="string"?parseInt(i,10):o?parseInt(o.slice(1),10):10,c=r.filter(u=>!u.startsWith("-")&&u!==i&&u!==String(a)),f=u=>{let h=u.split(`
207
+ `,exitCode:1}}};function jA(n){let{flags:t,flagsWithValues:e,positionals:r}=jt(n,{flags:["-i","-S"],flagsWithValue:["-u","--user"]}),s=t.has("-i"),i=e.get("-u")||e.get("--user")||"root",o=r.length>0?r.join(" "):null;return{targetUser:i,loginShell:s,commandLine:o}}var qd={name:"sudo",description:"Execute as superuser",category:"users",params:["<command...>"],run:async({authUser:n,hostname:t,mode:e,cwd:r,shell:s,args:i})=>{let{targetUser:o,loginShell:a,commandLine:c}=jA(i);if(n!=="root"&&!s.users.isSudoer(n))return{stderr:"sudo: permission denied",exitCode:1};let f=o||"root",l=`[sudo] password for ${n}: `;return n==="root"?!c&&a?{switchUser:f,nextCwd:`/home/${f}`,exitCode:0}:c?xt(c,f,t,e,a?`/home/${f}`:r,s):{stderr:"sudo: missing command",exitCode:1}:{sudoChallenge:{username:n,targetUser:f,commandLine:c,loginShell:a,prompt:l},exitCode:0}}};var Kd={name:"tail",description:"Output last lines",category:"text",params:["[-n <lines>] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=tn(r,["-n"]),o=r.find(u=>/^-\d+$/.test(u)),a=typeof i=="string"?parseInt(i,10):o?parseInt(o.slice(1),10):10,c=r.filter(u=>!u.startsWith("-")&&u!==i&&u!==String(a)),f=u=>{let h=u.split(`
201
208
  `),p=u.endsWith(`
202
209
  `),y=p?h.slice(0,-1):h;return y.slice(Math.max(0,y.length-a)).join(`
203
210
  `)+(p?`
204
211
  `:"")};if(c.length===0)return{stdout:f(s??""),exitCode:0};let l=[];for(let u of c){let h=le(e,u);try{Oe(n,h,"tail"),l.push(f(t.vfs.readFile(h)))}catch{return{stderr:`tail: ${u}: No such file or directory`,exitCode:1}}}return{stdout:l.join(`
205
- `),exitCode:0}}};var Fd={name:"tar",description:"Archive utility",category:"archive",params:["[-czf|-xzf|-tf] <archive> [files...]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=[],i=!1;for(let h of r)if(/^-[a-zA-Z]{2,}$/.test(h))for(let p of h.slice(1))s.push(`-${p}`);else if(!i&&/^[cxtdru]{1,}[a-zA-Z]*$/.test(h)&&!h.includes("/")&&!h.startsWith("-")){i=!0;for(let p of h)s.push(`-${p}`)}else s.push(h);let o=s.includes("-c"),a=s.includes("-x"),c=s.includes("-t"),f=s.indexOf("-f"),l=f!==-1?s[f+1]:s.find(h=>h.endsWith(".tar")||h.endsWith(".tar.gz")||h.endsWith(".tgz"));if(!o&&!a&&!c)return{stderr:`tar: must specify -c, -x, or -t
212
+ `),exitCode:0}}};var Vd={name:"tar",description:"Archive utility",category:"archive",params:["[-czf|-xzf|-tf] <archive> [files...]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=[],i=!1;for(let h of r)if(/^-[a-zA-Z]{2,}$/.test(h))for(let p of h.slice(1))s.push(`-${p}`);else if(!i&&/^[cxtdru]{1,}[a-zA-Z]*$/.test(h)&&!h.includes("/")&&!h.startsWith("-")){i=!0;for(let p of h)s.push(`-${p}`)}else s.push(h);let o=s.includes("-c"),a=s.includes("-x"),c=s.includes("-t"),f=s.indexOf("-f"),l=f!==-1?s[f+1]:s.find(h=>h.endsWith(".tar")||h.endsWith(".tar.gz")||h.endsWith(".tgz"));if(!o&&!a&&!c)return{stderr:`tar: must specify -c, -x, or -t
206
213
  `,exitCode:1};if(!l)return{stderr:`tar: no archive specified
207
- `,exitCode:1};let u=le(e,l);if(o){let h=new Set;f!==-1&&h.add(f+1);let p=s.filter((E,x)=>!E.startsWith("-")&&E!==l&&!h.has(x)),y={};for(let E of p){let x=le(e,E);try{if(t.vfs.stat(x).type==="file")y[E]=t.vfs.readFile(x);else{let D=(H,C)=>{for(let F of t.vfs.list(H)){let V=`${H}/${F}`,N=`${C}/${F}`;t.vfs.stat(V).type==="file"?y[N]=t.vfs.readFile(V):D(V,N)}};D(x,E)}}catch{return{stderr:`tar: ${E}: No such file or directory`,exitCode:1}}}return t.writeFileAsUser(n,u,JSON.stringify(y)),{exitCode:0}}if(c||a){let h;try{h=JSON.parse(t.vfs.readFile(u))}catch{return{stderr:`tar: ${l}: cannot open archive`,exitCode:1}}if(c)return{stdout:Object.keys(h).join(`
208
- `),exitCode:0};for(let[p,y]of Object.entries(h))t.writeFileAsUser(n,le(e,p),y);return{exitCode:0}}return{stderr:"tar: must specify -c, -x, or -t",exitCode:1}}};var Hd={name:"tee",description:"Read stdin, write to stdout and files",category:"text",params:["[-a] <file...>"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-a"]),o=r.filter(c=>!c.startsWith("-")),a=s??"";for(let c of o){let f=le(e,c);if(i){let l=(()=>{try{return t.vfs.readFile(f)}catch{return""}})();t.writeFileAsUser(n,f,l+a)}else t.writeFileAsUser(n,f,a)}return{stdout:a,exitCode:0}}};function Vr(n,t,e){if(n[n.length-1]==="]"&&(n=n.slice(0,-1)),n[0]==="["&&(n=n.slice(1)),n.length===0)return!1;if(n[0]==="!")return!Vr(n.slice(1),t,e);let r=n.indexOf("-a");if(r!==-1)return Vr(n.slice(0,r),t,e)&&Vr(n.slice(r+1),t,e);let s=n.indexOf("-o");if(s!==-1)return Vr(n.slice(0,s),t,e)||Vr(n.slice(s+1),t,e);if(n.length===2){let[i,o=""]=n,c=(f=>f.startsWith("/")?f:`${e}/${f}`.replace(/\/+/g,"/"))(o);switch(i){case"-e":return t.vfs.exists(c);case"-f":return t.vfs.exists(c)&&t.vfs.stat(c).type==="file";case"-d":return t.vfs.exists(c)&&t.vfs.stat(c).type==="directory";case"-r":return t.vfs.exists(c);case"-w":return t.vfs.exists(c);case"-x":return t.vfs.exists(c)&&!!(t.vfs.stat(c).mode&73);case"-s":return t.vfs.exists(c)&&t.vfs.stat(c).type==="file"&&t.vfs.stat(c).size>0;case"-z":return o.length===0;case"-n":return o.length>0;case"-L":return t.vfs.isSymlink(c)}}if(n.length===3){let[i="",o,a=""]=n,c=Number(i),f=Number(a);switch(o){case"=":case"==":return i===a;case"!=":return i!==a;case"<":return i<a;case">":return i>a;case"-eq":return c===f;case"-ne":return c!==f;case"-lt":return c<f;case"-le":return c<=f;case"-gt":return c>f;case"-ge":return c>=f}}return n.length===1?(n[0]??"").length>0:!1}var Qd={name:"test",aliases:["["],description:"Evaluate conditional expression",category:"shell",params:["<expression>"],run:({args:n,shell:t,cwd:e})=>{try{return{exitCode:Vr([...n],t,e)?0:1}}catch{return{stderr:"test: malformed expression",exitCode:2}}}};var Wd={name:"touch",description:"Create or update files",category:"files",params:["<file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"touch: missing file operand",exitCode:1};for(let s of r){let i=le(e,s);Oe(n,i,"touch"),t.vfs.exists(i)||t.writeFileAsUser(n,i,"")}return{exitCode:0}}};function qA(n){return n.replace(/\\n/g,`
209
- `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function qd(n){let t=[],e=qA(n),r=0;for(;r<e.length;){if(r+2<e.length&&e[r+1]==="-"){let s=e.charCodeAt(r),i=e.charCodeAt(r+2);if(s<=i){for(let o=s;o<=i;o++)t.push(String.fromCharCode(o));r+=3;continue}}t.push(e[r]),r++}return t}var Kd={name:"tr",description:"Translate or delete characters",category:"text",params:["[-d] [-s] <set1> [set2]"],run:({args:n,stdin:t})=>{let e=se(n,["-d"]),r=se(n,["-s"]),s=n.filter(c=>!c.startsWith("-")),i=qd(s[0]??""),o=qd(s[1]??""),a=t??"";if(e){let c=new Set(i);a=[...a].filter(f=>!c.has(f)).join("")}else if(o.length>0){let c=new Map;for(let f=0;f<i.length;f++)c.set(i[f],o[f]??o[o.length-1]??"");a=[...a].map(f=>c.get(f)??f).join("")}if(r&&o.length>0){let c=new Set(o);a=a.replace(/(.)\1+/g,(f,l)=>c.has(l)?l:f)}return{stdout:a,exitCode:0}}};var Vd={name:"tree",description:"Display directory tree",category:"navigation",params:["[path]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=le(e,Xn(r,0)??e);return Oe(n,s,"tree"),{stdout:t.vfs.tree(s),exitCode:0}}};var Gd={name:"true",description:"Return success exit code",category:"shell",params:[],run:()=>({exitCode:0})},zd={name:"false",description:"Return failure exit code",category:"shell",params:[],run:()=>({exitCode:1})};var Yd={name:"type",description:"Describe how a command would be interpreted",category:"shell",params:["<command...>"],run:({args:n,shell:t,env:e})=>{if(n.length===0)return{stderr:"type: missing argument",exitCode:1};let r=(e?.vars?.PATH??"/usr/local/bin:/usr/bin:/bin").split(":"),s=[],i=0;for(let o of n){if(Cn(o)){s.push(`${o} is a shell builtin`);continue}let a=!1;for(let c of r){let f=`${c}/${o}`;if(t.vfs.exists(f)){s.push(`${o} is ${f}`),a=!0;break}}a||(s.push(`${o}: not found`),i=1)}return{stdout:s.join(`
210
- `),exitCode:i}}};var jd={name:"uname",description:"Print system information",category:"system",params:["[-a] [-s] [-r] [-m]"],run:({shell:n,args:t})=>{let e=se(t,["-a"]),r="Linux",s=n.properties?.kernel??"5.15.0",i=n.properties?.arch??"x86_64",o=n.hostname;return e?{stdout:`${r} ${o} ${s} #1 SMP ${i} GNU/Linux`,exitCode:0}:se(t,["-r"])?{stdout:s,exitCode:0}:se(t,["-m"])?{stdout:i,exitCode:0}:{stdout:r,exitCode:0}}};var Xd={name:"uniq",description:"Report or filter out repeated lines",category:"text",params:["[-c] [-d] [-u] [file]"],run:({args:n,stdin:t})=>{let e=se(n,["-c"]),r=se(n,["-d"]),s=se(n,["-u"]),i=(t??"").split(`
214
+ `,exitCode:1};let u=le(e,l);if(o){let h=new Set;f!==-1&&h.add(f+1);let p=s.filter((E,b)=>!E.startsWith("-")&&E!==l&&!h.has(b)),y={};for(let E of p){let b=le(e,E);try{if(t.vfs.stat(b).type==="file")y[E]=t.vfs.readFile(b);else{let N=(H,v)=>{for(let M of t.vfs.list(H)){let Q=`${H}/${M}`,P=`${v}/${M}`;t.vfs.stat(Q).type==="file"?y[P]=t.vfs.readFile(Q):N(Q,P)}};N(b,E)}}catch{return{stderr:`tar: ${E}: No such file or directory`,exitCode:1}}}return t.writeFileAsUser(n,u,JSON.stringify(y)),{exitCode:0}}if(c||a){let h;try{h=JSON.parse(t.vfs.readFile(u))}catch{return{stderr:`tar: ${l}: cannot open archive`,exitCode:1}}if(c)return{stdout:Object.keys(h).join(`
215
+ `),exitCode:0};for(let[p,y]of Object.entries(h))t.writeFileAsUser(n,le(e,p),y);return{exitCode:0}}return{stderr:"tar: must specify -c, -x, or -t",exitCode:1}}};var Gd={name:"tee",description:"Read stdin, write to stdout and files",category:"text",params:["[-a] <file...>"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-a"]),o=r.filter(c=>!c.startsWith("-")),a=s??"";for(let c of o){let f=le(e,c);if(i){let l=(()=>{try{return t.vfs.readFile(f)}catch{return""}})();t.writeFileAsUser(n,f,l+a)}else t.writeFileAsUser(n,f,a)}return{stdout:a,exitCode:0}}};function Gr(n,t,e){if(n[n.length-1]==="]"&&(n=n.slice(0,-1)),n[0]==="["&&(n=n.slice(1)),n.length===0)return!1;if(n[0]==="!")return!Gr(n.slice(1),t,e);let r=n.indexOf("-a");if(r!==-1)return Gr(n.slice(0,r),t,e)&&Gr(n.slice(r+1),t,e);let s=n.indexOf("-o");if(s!==-1)return Gr(n.slice(0,s),t,e)||Gr(n.slice(s+1),t,e);if(n.length===2){let[i,o=""]=n,c=(f=>f.startsWith("/")?f:`${e}/${f}`.replace(/\/+/g,"/"))(o);switch(i){case"-e":return t.vfs.exists(c);case"-f":return t.vfs.exists(c)&&t.vfs.stat(c).type==="file";case"-d":return t.vfs.exists(c)&&t.vfs.stat(c).type==="directory";case"-r":return t.vfs.exists(c);case"-w":return t.vfs.exists(c);case"-x":return t.vfs.exists(c)&&!!(t.vfs.stat(c).mode&73);case"-s":return t.vfs.exists(c)&&t.vfs.stat(c).type==="file"&&t.vfs.stat(c).size>0;case"-z":return o.length===0;case"-n":return o.length>0;case"-L":return t.vfs.isSymlink(c)}}if(n.length===3){let[i="",o,a=""]=n,c=Number(i),f=Number(a);switch(o){case"=":case"==":return i===a;case"!=":return i!==a;case"<":return i<a;case">":return i>a;case"-eq":return c===f;case"-ne":return c!==f;case"-lt":return c<f;case"-le":return c<=f;case"-gt":return c>f;case"-ge":return c>=f}}return n.length===1?(n[0]??"").length>0:!1}var zd={name:"test",aliases:["["],description:"Evaluate conditional expression",category:"shell",params:["<expression>"],run:({args:n,shell:t,cwd:e})=>{try{return{exitCode:Gr([...n],t,e)?0:1}}catch{return{stderr:"test: malformed expression",exitCode:2}}}};var Yd={name:"touch",description:"Create or update files",category:"files",params:["<file>"],run:({authUser:n,shell:t,cwd:e,args:r})=>{if(r.length===0)return{stderr:"touch: missing file operand",exitCode:1};for(let s of r){let i=le(e,s);Oe(n,i,"touch"),t.vfs.exists(i)||t.writeFileAsUser(n,i,"")}return{exitCode:0}}};function XA(n){return n.replace(/\\n/g,`
216
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function jd(n){let t=[],e=XA(n),r=0;for(;r<e.length;){if(r+2<e.length&&e[r+1]==="-"){let s=e.charCodeAt(r),i=e.charCodeAt(r+2);if(s<=i){for(let o=s;o<=i;o++)t.push(String.fromCharCode(o));r+=3;continue}}t.push(e[r]),r++}return t}var Xd={name:"tr",description:"Translate or delete characters",category:"text",params:["[-d] [-s] <set1> [set2]"],run:({args:n,stdin:t})=>{let e=se(n,["-d"]),r=se(n,["-s"]),s=n.filter(c=>!c.startsWith("-")),i=jd(s[0]??""),o=jd(s[1]??""),a=t??"";if(e){let c=new Set(i);a=[...a].filter(f=>!c.has(f)).join("")}else if(o.length>0){let c=new Map;for(let f=0;f<i.length;f++)c.set(i[f],o[f]??o[o.length-1]??"");a=[...a].map(f=>c.get(f)??f).join("")}if(r&&o.length>0){let c=new Set(o);a=a.replace(/(.)\1+/g,(f,l)=>c.has(l)?l:f)}return{stdout:a,exitCode:0}}};var Jd={name:"tree",description:"Display directory tree",category:"navigation",params:["[path]"],run:({authUser:n,shell:t,cwd:e,args:r})=>{let s=le(e,Jn(r,0)??e);return Oe(n,s,"tree"),{stdout:t.vfs.tree(s),exitCode:0}}};var Zd={name:"true",description:"Return success exit code",category:"shell",params:[],run:()=>({exitCode:0})},eh={name:"false",description:"Return failure exit code",category:"shell",params:[],run:()=>({exitCode:1})};var th={name:"type",description:"Describe how a command would be interpreted",category:"shell",params:["<command...>"],run:({args:n,shell:t,env:e})=>{if(n.length===0)return{stderr:"type: missing argument",exitCode:1};let r=(e?.vars?.PATH??"/usr/local/bin:/usr/bin:/bin").split(":"),s=[],i=0;for(let o of n){if(yn(o)){s.push(`${o} is a shell builtin`);continue}let a=!1;for(let c of r){let f=`${c}/${o}`;if(t.vfs.exists(f)){s.push(`${o} is ${f}`),a=!0;break}}a||(s.push(`${o}: not found`),i=1)}return{stdout:s.join(`
217
+ `),exitCode:i}}};var nh={name:"uname",description:"Print system information",category:"system",params:["[-a] [-s] [-r] [-m]"],run:({shell:n,args:t})=>{let e=se(t,["-a"]),r="Linux",s=n.properties?.kernel??"5.15.0",i=n.properties?.arch??"x86_64",o=n.hostname;return e?{stdout:`${r} ${o} ${s} #1 SMP ${i} GNU/Linux`,exitCode:0}:se(t,["-r"])?{stdout:s,exitCode:0}:se(t,["-m"])?{stdout:i,exitCode:0}:{stdout:r,exitCode:0}}};var rh={name:"uniq",description:"Report or filter out repeated lines",category:"text",params:["[-c] [-d] [-u] [file]"],run:({args:n,stdin:t})=>{let e=se(n,["-c"]),r=se(n,["-d"]),s=se(n,["-u"]),i=(t??"").split(`
211
218
  `),o=[],a=0;for(;a<i.length;){let c=a;for(;c<i.length&&i[c]===i[a];)c++;let f=c-a,l=i[a];if(r&&f===1){a=c;continue}if(s&&f>1){a=c;continue}o.push(e?`${String(f).padStart(4)} ${l}`:l),a=c}return{stdout:o.join(`
212
- `),exitCode:0}}};var Jd={name:"unset",description:"Remove shell variable",category:"shell",params:["<VAR>"],run:({args:n,env:t})=>{for(let e of n)delete t.vars[e];return{exitCode:0}}};var Zd={name:"uptime",description:"Tell how long the system has been running",category:"system",params:["[-p] [-s]"],run:({args:n,shell:t})=>{let e=se(n,["-p"]),r=se(n,["-s"]),s=Math.floor((Date.now()-t.startTime)/1e3),i=Math.floor(s/86400),o=Math.floor(s%86400/3600),a=Math.floor(s%3600/60);if(r)return{stdout:new Date(t.startTime).toISOString().slice(0,19).replace("T"," "),exitCode:0};if(e){let h=[];return i>0&&h.push(`${i} day${i>1?"s":""}`),o>0&&h.push(`${o} hour${o>1?"s":""}`),h.push(`${a} minute${a!==1?"s":""}`),{stdout:`up ${h.join(", ")}`,exitCode:0}}let c=new Date().toTimeString().slice(0,8),f=i>0?`${i} day${i>1?"s":""}, ${String(o).padStart(2)}:${String(a).padStart(2,"0")}`:`${String(o).padStart(2)}:${String(a).padStart(2,"0")}`,l=t.users.listActiveSessions().length,u=(Math.random()*.5).toFixed(2);return{stdout:` ${c} up ${f}, ${l} user${l!==1?"s":""}, load average: ${u}, ${u}, ${u}`,exitCode:0}}};var eh={name:"wc",description:"Count words/lines/bytes",category:"text",params:["[-l] [-w] [-c] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-l"]),o=se(r,["-w"]),a=se(r,["-c"]),c=!i&&!o&&!a,f=r.filter(h=>!h.startsWith("-")),l=(h,p)=>{let y=h.split(`
219
+ `),exitCode:0}}};var ih={name:"unset",description:"Remove shell variable",category:"shell",params:["<VAR>"],run:({args:n,env:t})=>{for(let e of n)delete t.vars[e];return{exitCode:0}}};var sh={name:"uptime",description:"Tell how long the system has been running",category:"system",params:["[-p] [-s]"],run:({args:n,shell:t})=>{let e=se(n,["-p"]),r=se(n,["-s"]),s=Math.floor((Date.now()-t.startTime)/1e3),i=Math.floor(s/86400),o=Math.floor(s%86400/3600),a=Math.floor(s%3600/60);if(r)return{stdout:new Date(t.startTime).toISOString().slice(0,19).replace("T"," "),exitCode:0};if(e){let h=[];return i>0&&h.push(`${i} day${i>1?"s":""}`),o>0&&h.push(`${o} hour${o>1?"s":""}`),h.push(`${a} minute${a!==1?"s":""}`),{stdout:`up ${h.join(", ")}`,exitCode:0}}let c=new Date().toTimeString().slice(0,8),f=i>0?`${i} day${i>1?"s":""}, ${String(o).padStart(2)}:${String(a).padStart(2,"0")}`:`${String(o).padStart(2)}:${String(a).padStart(2,"0")}`,l=t.users.listActiveSessions().length,u=(Math.random()*.5).toFixed(2);return{stdout:` ${c} up ${f}, ${l} user${l!==1?"s":""}, load average: ${u}, ${u}, ${u}`,exitCode:0}}};var oh={name:"wc",description:"Count words/lines/bytes",category:"text",params:["[-l] [-w] [-c] [file...]"],run:({authUser:n,shell:t,cwd:e,args:r,stdin:s})=>{let i=se(r,["-l"]),o=se(r,["-w"]),a=se(r,["-c"]),c=!i&&!o&&!a,f=r.filter(h=>!h.startsWith("-")),l=(h,p)=>{let y=h.split(`
213
220
  `).length-(h.endsWith(`
214
- `)?1:0),E=h.trim().split(/\s+/).filter(Boolean).length,x=Buffer.byteLength(h,"utf8"),k=[];return(c||i)&&k.push(String(y).padStart(7)),(c||o)&&k.push(String(E).padStart(7)),(c||a)&&k.push(String(x).padStart(7)),p&&k.push(` ${p}`),k.join("")};if(f.length===0)return{stdout:l(s??"",""),exitCode:0};let u=[];for(let h of f){let p=le(e,h);try{Oe(n,p,"wc");let y=t.vfs.readFile(p);u.push(l(y,h))}catch{return{stderr:`wc: ${h}: No such file or directory`,exitCode:1}}}return{stdout:u.join(`
215
- `),exitCode:0}}};var th={name:"wget",description:"File downloader (pure fetch)",category:"network",params:["[options] <url>"],run:async({authUser:n,cwd:t,args:e,shell:r})=>{let{flagsWithValues:s,positionals:i}=Yt(e,{flagsWithValue:["-O","--output-document","-o","--output-file","-P","--directory-prefix","--tries","--timeout"]});if(se(e,["-h","--help"]))return{stdout:["Usage: wget [option]... [URL]..."," -O, --output-document=FILE Write to FILE ('-' for stdout)"," -P, --directory-prefix=DIR Save files in DIR"," -q, --quiet Quiet mode"," -v, --verbose Verbose output (default)"," -c, --continue Continue partial download"," --tries=N Retry N times"," --timeout=N Timeout in seconds"].join(`
221
+ `)?1:0),E=h.trim().split(/\s+/).filter(Boolean).length,b=Buffer.byteLength(h,"utf8"),C=[];return(c||i)&&C.push(String(y).padStart(7)),(c||o)&&C.push(String(E).padStart(7)),(c||a)&&C.push(String(b).padStart(7)),p&&C.push(` ${p}`),C.join("")};if(f.length===0)return{stdout:l(s??"",""),exitCode:0};let u=[];for(let h of f){let p=le(e,h);try{Oe(n,p,"wc");let y=t.vfs.readFile(p);u.push(l(y,h))}catch{return{stderr:`wc: ${h}: No such file or directory`,exitCode:1}}}return{stdout:u.join(`
222
+ `),exitCode:0}}};var ah={name:"wget",description:"File downloader (pure fetch)",category:"network",params:["[options] <url>"],run:async({authUser:n,cwd:t,args:e,shell:r})=>{let{flagsWithValues:s,positionals:i}=jt(e,{flagsWithValue:["-O","--output-document","-o","--output-file","-P","--directory-prefix","--tries","--timeout"]});if(se(e,["-h","--help"]))return{stdout:["Usage: wget [option]... [URL]..."," -O, --output-document=FILE Write to FILE ('-' for stdout)"," -P, --directory-prefix=DIR Save files in DIR"," -q, --quiet Quiet mode"," -v, --verbose Verbose output (default)"," -c, --continue Continue partial download"," --tries=N Retry N times"," --timeout=N Timeout in seconds"].join(`
216
223
  `),exitCode:0};if(se(e,["-V","--version"]))return{stdout:"GNU Wget 1.21.3 (virtual) built on Fortune GNU/Linux.",exitCode:0};let o=i[0];if(!o)return{stderr:`wget: missing URL
217
224
  Usage: wget [OPTION]... [URL]...`,exitCode:1};let a=o.startsWith("http://")||o.startsWith("https://")?o:`http://${o}`;if(!a)return{stderr:`wget: missing URL
218
- Usage: wget [OPTION]... [URL]...`,exitCode:1};let c=s.get("-O")??s.get("--output-document")??null,f=s.get("-P")??s.get("--directory-prefix")??null,l=se(e,["-q","--quiet"]),u=c==="-"?null:c??tu(a),h=u?le(t,f?`${f}/${u}`:u):null;h&&Oe(n,h,"wget");let p=[];l||(p.push(`--${new Date().toISOString()}-- ${a}`),p.push(`Resolving ${new URL(a).host}...`),p.push(`Connecting to ${new URL(a).host}...`));let y;try{y=await fetch(a,{headers:{"User-Agent":"Wget/1.21.3 (Fortune GNU/Linux)"}})}catch(x){let k=x instanceof Error?x.message:String(x);return p.push(`wget: unable to resolve host: ${k}`),{stderr:p.join(`
225
+ Usage: wget [OPTION]... [URL]...`,exitCode:1};let c=s.get("-O")??s.get("--output-document")??null,f=s.get("-P")??s.get("--directory-prefix")??null,l=se(e,["-q","--quiet"]),u=c==="-"?null:c??iu(a),h=u?le(t,f?`${f}/${u}`:u):null;h&&Oe(n,h,"wget");let p=[];l||(p.push(`--${new Date().toISOString()}-- ${a}`),p.push(`Resolving ${new URL(a).host}...`),p.push(`Connecting to ${new URL(a).host}...`));let y;try{y=await fetch(a,{headers:{"User-Agent":"Wget/1.21.3 (Fortune GNU/Linux)"}})}catch(b){let C=b instanceof Error?b.message:String(b);return p.push(`wget: unable to resolve host: ${C}`),{stderr:p.join(`
219
226
  `),exitCode:4}}if(!y.ok)return p.push(`ERROR ${y.status}: ${y.statusText}`),{stderr:p.join(`
220
- `),exitCode:8};let E;try{E=await y.text()}catch{return{stderr:"wget: failed to read response",exitCode:1}}if(!l){let x=y.headers.get("content-type")??"application/octet-stream";p.push(`HTTP request sent, awaiting response... ${y.status} ${y.statusText}`),p.push(`Length: ${E.length} [${x}]`)}return c==="-"?{stdout:E,stderr:p.join(`
227
+ `),exitCode:8};let E;try{E=await y.text()}catch{return{stderr:"wget: failed to read response",exitCode:1}}if(!l){let b=y.headers.get("content-type")??"application/octet-stream";p.push(`HTTP request sent, awaiting response... ${y.status} ${y.statusText}`),p.push(`Length: ${E.length} [${b}]`)}return c==="-"?{stdout:E,stderr:p.join(`
221
228
  `)||void 0,exitCode:0}:h?(r.writeFileAsUser(n,h,E),l||p.push(`Saving to: '${h}'
222
229
  ${h} 100%[==================>] ${E.length} B`),{stderr:p.join(`
223
- `)||void 0,exitCode:0}):{stdout:E,exitCode:0}}};var nh={name:"which",description:"Locate a command in PATH",category:"shell",params:["<command...>"],run:({args:n,shell:t,env:e})=>{if(n.length===0)return{stderr:"which: missing argument",exitCode:1};let r=(e?.vars?.PATH??"/usr/local/bin:/usr/bin:/bin").split(":"),s=[],i=!1;for(let o of n){let a=!1;for(let c of r){let f=`${c}/${o}`;if(t.vfs.exists(f)&&t.vfs.stat(f).type==="file"){s.push(f),a=!0;break}}a||(i=!0)}return s.length===0?{exitCode:1}:{stdout:s.join(`
224
- `),exitCode:i?1:0}}};function Vs(n){let t=n.toLocaleString("en-US",{weekday:"short"}),e=n.toLocaleString("en-US",{month:"short"}),r=n.getDate().toString().padStart(2,"0"),s=n.getHours().toString().padStart(2,"0"),i=n.getMinutes().toString().padStart(2,"0"),o=n.getSeconds().toString().padStart(2,"0"),a=n.getFullYear();return`${t} ${e} ${r} ${s}:${i}:${o} ${a}`}var rh={name:"who",description:"Show active sessions",category:"system",params:[],run:({shell:n})=>({stdout:n.users.listActiveSessions().map(e=>{let r=new Date(e.startedAt),s=Number.isNaN(r.getTime())?e.startedAt:Vs(r);return`${e.username} ${e.tty} ${s} (${e.remoteAddress||"unknown"})`}).join(`
225
- `),exitCode:0})};var ih={name:"whoami",description:"Print current user",category:"system",params:[],run:({authUser:n})=>({stdout:n,exitCode:0})};var sh={name:"xargs",description:"Build and execute command lines from stdin",category:"text",params:["[command] [args...]"],run:async({authUser:n,hostname:t,mode:e,cwd:r,args:s,stdin:i,shell:o,env:a})=>{let c=s[0]??"echo",f=s.slice(1),l=(i??"").trim().split(/\s+/).filter(Boolean);if(l.length===0)return{exitCode:0};let u=[c,...f,...l].join(" ");return bt(u,n,t,e,r,o,void 0,a)}};var KA=[_d,fu,Yu,Vd,cu,Wd,wd,Ju,du,Zu,qu,Ku,lu,Vu,ku,Bu,Id,ou,Ud,Xd,eh,Tu,Md,pu,Kd,Hd,sh,_u,Fd,Nu,Pu,au,ih,rh,Fu,Qu,Ru,jd,Ed,Wu,Eu,xu,gu,Ld,md,Su,wu,Cu,Cd,Jd,Rd,uu,Iu,td,Hu,hu,th,Xl,gd,Au,Od,$d,ld,iu,su,yu,bu,nh,Yd,Xu,Zl,eu,Qd,Dd,Mu,Ad,Sd,mu,Nd,Pd,Td,Gd,zd,hd,pd,dd,xd,Zd,vu,ju],oh=[],Di=new Map,Gs=null,VA=Ou(()=>oc().map(n=>n.name));function sc(){Di.clear();for(let n of oc()){Di.set(n.name,n);for(let t of n.aliases??[])Di.set(t,n)}Gs=Array.from(Di.keys()).sort()}function oc(){return[...KA,...oh,VA]}function ec(n){let t={...n,name:n.name.trim().toLowerCase(),aliases:n.aliases?.map(r=>r.trim().toLowerCase())};if([t.name,...t.aliases??[]].some(r=>r.length===0||/\s/.test(r)))throw new Error("Command names must be non-empty and contain no spaces");oh.push(t),sc()}function tc(n,t,e){return{name:n,params:t,run:e}}function nc(){return Gs||sc(),Gs}function ja(){return oc()}function Cn(n){return Gs||sc(),Di.get(n.toLowerCase())}var Gr=Vt(require("node:os"),1);function ye(n,t,e=493){n.exists(t)||n.mkdir(t,e)}function st(n,t,e,r=420){n.exists(t)||n.writeFile(t,e,{mode:r})}function GA(n,t,e){ye(n,"/etc"),st(n,"/etc/os-release",`${['NAME="Fortune GNU/Linux"',`PRETTY_NAME="${e.os}"`,"ID=fortune","ID_LIKE=debian",'HOME_URL="https://github.com/itsrealfortune/typescript-virtual-container"',"VERSION_CODENAME=aurora",'VERSION_ID="1.0"'].join(`
230
+ `)||void 0,exitCode:0}):{stdout:E,exitCode:0}}};var ch={name:"which",description:"Locate a command in PATH",category:"shell",params:["<command...>"],run:({args:n,shell:t,env:e})=>{if(n.length===0)return{stderr:"which: missing argument",exitCode:1};let r=(e?.vars?.PATH??"/usr/local/bin:/usr/bin:/bin").split(":"),s=[],i=!1;for(let o of n){let a=!1;for(let c of r){let f=`${c}/${o}`;if(t.vfs.exists(f)&&t.vfs.stat(f).type==="file"){s.push(f),a=!0;break}}a||(i=!0)}return s.length===0?{exitCode:1}:{stdout:s.join(`
231
+ `),exitCode:i?1:0}}};function Ys(n){let t=n.toLocaleString("en-US",{weekday:"short"}),e=n.toLocaleString("en-US",{month:"short"}),r=n.getDate().toString().padStart(2,"0"),s=n.getHours().toString().padStart(2,"0"),i=n.getMinutes().toString().padStart(2,"0"),o=n.getSeconds().toString().padStart(2,"0"),a=n.getFullYear();return`${t} ${e} ${r} ${s}:${i}:${o} ${a}`}var fh={name:"who",description:"Show active sessions",category:"system",params:[],run:({shell:n})=>({stdout:n.users.listActiveSessions().map(e=>{let r=new Date(e.startedAt),s=Number.isNaN(r.getTime())?e.startedAt:Ys(r);return`${e.username} ${e.tty} ${s} (${e.remoteAddress||"unknown"})`}).join(`
232
+ `),exitCode:0})};var lh={name:"whoami",description:"Print current user",category:"system",params:[],run:({authUser:n})=>({stdout:n,exitCode:0})};var uh={name:"xargs",description:"Build and execute command lines from stdin",category:"text",params:["[command] [args...]"],run:async({authUser:n,hostname:t,mode:e,cwd:r,args:s,stdin:i,shell:o,env:a})=>{let c=s[0]??"echo",f=s.slice(1),l=(i??"").trim().split(/\s+/).filter(Boolean);if(l.length===0)return{exitCode:0};let u=[c,...f,...l].join(" ");return xt(u,n,t,e,r,o,void 0,a)}};var JA=[wd,du,ed,Jd,uu,Yd,Bd,rd,gu,id,zu,Yu,hu,ju,Xu,Nu,Tu,Rd,fu,Hd,rh,oh,$u,Kd,Au,Xd,Gd,uh,xu,Vd,Uu,Du,lu,lh,fh,qu,Vu,Lu,nh,Sd,Gu,bu,Iu,Eu,Fd,bd,vu,ku,Ru,Nd,ih,Dd,pu,Bu,od,Ku,mu,ah,eu,_d,_u,qd,Wd,gd,au,cu,Su,wu,ch,th,nd,nu,ru,zd,Qd,Wu,xd,kd,yu,$d,Od,Md,Zd,eh,Ed,yd,Ad,vd,sh,Pu,td],dh=[],Mi=new Map,js=null,ZA=Qu(()=>lc().map(n=>n.name));function fc(){Mi.clear();for(let n of lc()){Mi.set(n.name,n);for(let t of n.aliases??[])Mi.set(t,n)}js=Array.from(Mi.keys()).sort()}function lc(){return[...JA,...dh,ZA]}function ic(n){let t={...n,name:n.name.trim().toLowerCase(),aliases:n.aliases?.map(r=>r.trim().toLowerCase())};if([t.name,...t.aliases??[]].some(r=>r.length===0||/\s/.test(r)))throw new Error("Command names must be non-empty and contain no spaces");dh.push(t),fc()}function sc(n,t,e){return{name:n,params:t,run:e}}function oc(){return js||fc(),js}function ec(){return lc()}function yn(n){return js||fc(),Mi.get(n.toLowerCase())}var zr=Gt(require("node:os"),1);function _e(n,t,e=493){n.exists(t)||n.mkdir(t,e)}function st(n,t,e,r=420){n.exists(t)||n.writeFile(t,e,{mode:r})}function eE(n,t,e){_e(n,"/etc"),st(n,"/etc/os-release",`${['NAME="Fortune GNU/Linux"',`PRETTY_NAME="${e.os}"`,"ID=fortune","ID_LIKE=debian",'HOME_URL="https://github.com/itsrealfortune/typescript-virtual-container"',"VERSION_CODENAME=aurora",'VERSION_ID="1.0"'].join(`
226
233
  `)}
227
234
  `),st(n,"/etc/debian_version",`12.0
228
235
  `),st(n,"/etc/hostname",`${t}
@@ -233,54 +240,54 @@ ${h} 100%[==================>] ${E.length} B`),{stderr:p.join(`
233
240
  `)}
234
241
  `),st(n,"/etc/issue",`Fortune GNU/Linux 1.0 \\n \\l
235
242
  `),st(n,"/etc/motd",["",`Welcome to ${e.os}`,`Kernel: ${e.kernel}`,""].join(`
236
- `)),ye(n,"/etc/apt"),ye(n,"/etc/apt/sources.list.d"),st(n,"/etc/apt/sources.list",`${["# Fortune GNU/Linux package sources","deb [virtual] fortune://packages.fortune.local aurora main contrib","deb [virtual] fortune://security.fortune.local aurora-security main"].join(`
243
+ `)),_e(n,"/etc/apt"),_e(n,"/etc/apt/sources.list.d"),st(n,"/etc/apt/sources.list",`${["# Fortune GNU/Linux package sources","deb [virtual] fortune://packages.fortune.local aurora main contrib","deb [virtual] fortune://security.fortune.local aurora-security main"].join(`
237
244
  `)}
238
- `),ye(n,"/etc/network"),st(n,"/etc/network/interfaces",`${["auto lo","iface lo inet loopback","","auto eth0","iface eth0 inet dhcp"].join(`
245
+ `),_e(n,"/etc/network"),st(n,"/etc/network/interfaces",`${["auto lo","iface lo inet loopback","","auto eth0","iface eth0 inet dhcp"].join(`
239
246
  `)}
240
247
  `),st(n,"/etc/resolv.conf",`nameserver 1.1.1.1
241
248
  nameserver 8.8.8.8
242
249
  `),st(n,"/etc/hosts",`${["127.0.0.1 localhost",`127.0.1.1 ${t}`,"::1 localhost ip6-localhost ip6-loopback"].join(`
243
250
  `)}
244
- `),ye(n,"/etc/cron.d"),ye(n,"/etc/init.d"),ye(n,"/etc/systemd"),ye(n,"/etc/systemd/system")}function ac(n,t){let e=t.listUsers(),r=["root:x:0:0:root:/root:/bin/bash","daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin","www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin","nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin"],s=1e3;for(let a of e)a!=="root"&&(r.push(`${a}:x:${s}:${s}::/home/${a}:/bin/bash`),s++);n.writeFile("/etc/passwd",`${r.join(`
251
+ `),_e(n,"/etc/cron.d"),_e(n,"/etc/init.d"),_e(n,"/etc/systemd"),_e(n,"/etc/systemd/system")}function uc(n,t){let e=t.listUsers(),r=["root:x:0:0:root:/root:/bin/bash","daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin","www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin","nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin"],s=1e3;for(let a of e)a!=="root"&&(r.push(`${a}:x:${s}:${s}::/home/${a}:/bin/bash`),s++);n.writeFile("/etc/passwd",`${r.join(`
245
252
  `)}
246
253
  `);let i=["root:x:0:","daemon:x:1:",`sudo:x:27:${e.filter(a=>t.isSudoer(a)).join(",")}`,`users:x:100:${e.filter(a=>a!=="root").join(",")}`,"nogroup:x:65534:"];n.writeFile("/etc/group",`${i.join(`
247
254
  `)}
248
255
  `);let o=["root:*:19000:0:99999:7:::","daemon:*:19000:0:99999:7:::"];for(let a of e)a!=="root"&&o.push(`${a}:!:19000:0:99999:7:::`);n.writeFile("/etc/shadow",`${o.join(`
249
256
  `)}
250
- `,{mode:416})}function ah(n){let t=n.match(/(\d+)$/);return 1e3+(t?.[1]?parseInt(t[1],10):0)}function ch(n,t,e,r,s,i,o){let a=`/proc/${t}`;ye(n,a),ye(n,`${a}/fd`),ye(n,`${a}/fdinfo`);let c=Math.floor((Date.now()-new Date(i).getTime())/1e3);n.writeFile(`${a}/cmdline`,`${s.replace(/\s+/g,"\0")}\0`),n.writeFile(`${a}/comm`,s.split(/\s+/)[0]??"bash"),n.writeFile(`${a}/status`,`${[`Name: ${s.split(/\s+/)[0]??"bash"}`,"State: S (sleeping)",`Pid: ${t}`,"PPid: 1","Uid: 0 0 0 0","Gid: 0 0 0 0","VmRSS: 4096 kB","VmSize: 16384 kB","Threads: 1"].join(`
257
+ `,{mode:416})}function hh(n){let t=n.match(/(\d+)$/);return 1e3+(t?.[1]?parseInt(t[1],10):0)}function ph(n,t,e,r,s,i,o){let a=`/proc/${t}`;_e(n,a),_e(n,`${a}/fd`),_e(n,`${a}/fdinfo`);let c=Math.floor((Date.now()-new Date(i).getTime())/1e3);n.writeFile(`${a}/cmdline`,`${s.replace(/\s+/g,"\0")}\0`),n.writeFile(`${a}/comm`,s.split(/\s+/)[0]??"bash"),n.writeFile(`${a}/status`,`${[`Name: ${s.split(/\s+/)[0]??"bash"}`,"State: S (sleeping)",`Pid: ${t}`,"PPid: 1","Uid: 0 0 0 0","Gid: 0 0 0 0","VmRSS: 4096 kB","VmSize: 16384 kB","Threads: 1"].join(`
251
258
  `)}
252
259
  `),n.writeFile(`${a}/stat`,`${t} (${s.split(/\s+/)[0]??"bash"}) S 1 ${t} ${t} 0 -1 4194304 0 0 0 0 ${c} 0 0 0 20 0 1 0 0 16384 4096 0
253
- `),n.writeFile(`${a}/environ`,`${Object.entries(o).map(([f,l])=>`${f}=${l}`).join("\0")}\0`),n.writeFile(`${a}/cwd`,`/home/${e}\0`),n.writeFile(`${a}/exe`,"/bin/bash\0"),n.writeFile(`${a}/fd/0`,""),n.writeFile(`${a}/fd/1`,""),n.writeFile(`${a}/fd/2`,"")}function zs(n,t,e,r,s){ye(n,"/proc");let i=Math.floor((Date.now()-r)/1e3);n.writeFile("/proc/uptime",`${i}.00 ${Math.floor(i*.9)}.00
254
- `);let o=Math.floor(Gr.totalmem()/1024),a=Math.floor(Gr.freemem()/1024),c=Math.floor(a*.95);n.writeFile("/proc/meminfo",`${[`MemTotal: ${String(o).padStart(10)} kB`,`MemFree: ${String(a).padStart(10)} kB`,`MemAvailable: ${String(c).padStart(10)} kB`,`Buffers: ${String(Math.floor(o*.02)).padStart(10)} kB`,`Cached: ${String(Math.floor(o*.15)).padStart(10)} kB`,`SwapTotal: ${String(Math.floor(o*.5)).padStart(10)} kB`,`SwapFree: ${String(Math.floor(o*.5)).padStart(10)} kB`].join(`
260
+ `),n.writeFile(`${a}/environ`,`${Object.entries(o).map(([f,l])=>`${f}=${l}`).join("\0")}\0`),n.writeFile(`${a}/cwd`,`/home/${e}\0`),n.writeFile(`${a}/exe`,"/bin/bash\0"),n.writeFile(`${a}/fd/0`,""),n.writeFile(`${a}/fd/1`,""),n.writeFile(`${a}/fd/2`,"")}function Xs(n,t,e,r,s){_e(n,"/proc");let i=Math.floor((Date.now()-r)/1e3);n.writeFile("/proc/uptime",`${i}.00 ${Math.floor(i*.9)}.00
261
+ `);let o=Math.floor(zr.totalmem()/1024),a=Math.floor(zr.freemem()/1024),c=Math.floor(a*.95);n.writeFile("/proc/meminfo",`${[`MemTotal: ${String(o).padStart(10)} kB`,`MemFree: ${String(a).padStart(10)} kB`,`MemAvailable: ${String(c).padStart(10)} kB`,`Buffers: ${String(Math.floor(o*.02)).padStart(10)} kB`,`Cached: ${String(Math.floor(o*.15)).padStart(10)} kB`,`SwapTotal: ${String(Math.floor(o*.5)).padStart(10)} kB`,`SwapFree: ${String(Math.floor(o*.5)).padStart(10)} kB`].join(`
255
262
  `)}
256
- `);let f=Gr.cpus(),l=[];for(let x=0;x<f.length;x++){let k=f[x];if(!k)continue;let D=k.speed.toFixed(3);l.push(`processor : ${x}`,`model name : ${k.model}`,`cpu MHz : ${D}`,"cache size : 8192 KB","")}n.writeFile("/proc/cpuinfo",`${l.join(`
263
+ `);let f=zr.cpus(),l=[];for(let b=0;b<f.length;b++){let C=f[b];if(!C)continue;let N=C.speed.toFixed(3);l.push(`processor : ${b}`,`model name : ${C.model}`,`cpu MHz : ${N}`,"cache size : 8192 KB","")}n.writeFile("/proc/cpuinfo",`${l.join(`
257
264
  `)}
258
265
  `),n.writeFile("/proc/version",`Linux version ${t.kernel} (fortune@build) (gcc version 12.2.0) #1 SMP
259
266
  `),n.writeFile("/proc/hostname",`${e}
260
267
  `);let u=(Math.random()*.5).toFixed(2),h=1+(s?.length??0);n.writeFile("/proc/loadavg",`${u} ${u} ${u} ${h}/${h} 1
261
- `),ye(n,"/proc/net"),st(n,"/proc/net/dev",`${["Inter-| Receive | Transmit"," face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed"," lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"," eth0: 131072 1024 0 0 0 0 0 0 65536 512 0 0 0 0 0 0"].join(`
268
+ `),_e(n,"/proc/net"),st(n,"/proc/net/dev",`${["Inter-| Receive | Transmit"," face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed"," lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"," eth0: 131072 1024 0 0 0 0 0 0 65536 512 0 0 0 0 0 0"].join(`
262
269
  `)}
263
- `),ch(n,1,"root","pts/0","/sbin/init",new Date(r).toISOString(),{});let p=s??[];for(let x of p){let k=ah(x.tty);ch(n,k,x.username,x.tty,"bash",x.startedAt,{USER:x.username,HOME:`/home/${x.username}`,TERM:"xterm-256color",SHELL:"/bin/bash"})}let y=p.length>0?ah(p[p.length-1].tty):1;if(n.exists("/proc/self"))try{n.remove("/proc/self")}catch{}let E=`/proc/${y}`;if(n.exists(E)){ye(n,"/proc/self"),ye(n,"/proc/self/fd");for(let x of n.list(E)){let k=`${E}/${x}`,D=`/proc/self/${x}`;try{n.stat(k).type==="file"&&n.writeFile(D,n.readFile(k))}catch{}}n.writeFile("/proc/self/status",n.exists(`${E}/status`)?n.readFile(`${E}/status`):"")}else ye(n,"/proc/self"),n.writeFile("/proc/self/cmdline","bash\0"),n.writeFile("/proc/self/comm","bash"),n.writeFile("/proc/self/status",`Name: bash
270
+ `),ph(n,1,"root","pts/0","/sbin/init",new Date(r).toISOString(),{});let p=s??[];for(let b of p){let C=hh(b.tty);ph(n,C,b.username,b.tty,"bash",b.startedAt,{USER:b.username,HOME:`/home/${b.username}`,TERM:"xterm-256color",SHELL:"/bin/bash"})}let y=p.length>0?hh(p[p.length-1].tty):1;if(n.exists("/proc/self"))try{n.remove("/proc/self")}catch{}let E=`/proc/${y}`;if(n.exists(E)){_e(n,"/proc/self"),_e(n,"/proc/self/fd");for(let b of n.list(E)){let C=`${E}/${b}`,N=`/proc/self/${b}`;try{n.stat(C).type==="file"&&n.writeFile(N,n.readFile(C))}catch{}}n.writeFile("/proc/self/status",n.exists(`${E}/status`)?n.readFile(`${E}/status`):"")}else _e(n,"/proc/self"),n.writeFile("/proc/self/cmdline","bash\0"),n.writeFile("/proc/self/comm","bash"),n.writeFile("/proc/self/status",`Name: bash
264
271
  State: S (sleeping)
265
272
  Pid: 1
266
273
  PPid: 0
267
- `),n.writeFile("/proc/self/environ",""),n.writeFile("/proc/self/cwd","/root\0"),n.writeFile("/proc/self/exe","/bin/bash\0")}function zA(n,t){ye(n,"/sys"),ye(n,"/sys/devices"),ye(n,"/sys/devices/virtual"),ye(n,"/sys/devices/virtual/dmi"),ye(n,"/sys/devices/virtual/dmi/id"),st(n,"/sys/devices/virtual/dmi/id/sys_vendor",`Fortune Systems
274
+ `),n.writeFile("/proc/self/environ",""),n.writeFile("/proc/self/cwd","/root\0"),n.writeFile("/proc/self/exe","/bin/bash\0")}function tE(n,t){_e(n,"/sys"),_e(n,"/sys/devices"),_e(n,"/sys/devices/virtual"),_e(n,"/sys/devices/virtual/dmi"),_e(n,"/sys/devices/virtual/dmi/id"),st(n,"/sys/devices/virtual/dmi/id/sys_vendor",`Fortune Systems
268
275
  `),st(n,"/sys/devices/virtual/dmi/id/product_name",`VirtualContainer v1
269
276
  `),st(n,"/sys/devices/virtual/dmi/id/board_name",`fortune-board
270
- `),ye(n,"/sys/class"),ye(n,"/sys/class/net"),ye(n,"/sys/kernel"),st(n,"/sys/kernel/hostname",`fortune-vm
277
+ `),_e(n,"/sys/class"),_e(n,"/sys/class/net"),_e(n,"/sys/kernel"),st(n,"/sys/kernel/hostname",`fortune-vm
271
278
  `),st(n,"/sys/kernel/osrelease",`${t.kernel}
272
279
  `),st(n,"/sys/kernel/ostype",`Linux
273
- `)}function YA(n){ye(n,"/dev"),st(n,"/dev/null","",438),st(n,"/dev/zero","",438),st(n,"/dev/random","",292),st(n,"/dev/urandom","",292),ye(n,"/dev/pts"),ye(n,"/dev/shm")}function jA(n){ye(n,"/usr"),ye(n,"/usr/bin"),ye(n,"/usr/sbin"),ye(n,"/usr/local"),ye(n,"/usr/local/bin"),ye(n,"/usr/local/lib"),ye(n,"/usr/local/share"),ye(n,"/usr/share"),ye(n,"/usr/share/doc"),ye(n,"/usr/share/man"),ye(n,"/usr/share/man/man1"),ye(n,"/usr/lib");let t=["sh","bash","ls","cat","echo","grep","find","sort","head","tail","cut","tr","sed","awk","wc","tee","tar","gzip","gunzip","touch","mkdir","rm","mv","cp","chmod","ln","pwd","env","date","sleep","id","whoami","hostname","uname","ps","kill","df","du","curl","wget","nano","diff","uniq","xargs","base64"];for(let e of t)st(n,`/usr/bin/${e}`,`#!/bin/sh
280
+ `)}function nE(n){_e(n,"/dev"),st(n,"/dev/null","",438),st(n,"/dev/zero","",438),st(n,"/dev/random","",292),st(n,"/dev/urandom","",292),_e(n,"/dev/pts"),_e(n,"/dev/shm")}function rE(n){_e(n,"/usr"),_e(n,"/usr/bin"),_e(n,"/usr/sbin"),_e(n,"/usr/local"),_e(n,"/usr/local/bin"),_e(n,"/usr/local/lib"),_e(n,"/usr/local/share"),_e(n,"/usr/share"),_e(n,"/usr/share/doc"),_e(n,"/usr/share/man"),_e(n,"/usr/share/man/man1"),_e(n,"/usr/lib");let t=["sh","bash","ls","cat","echo","grep","find","sort","head","tail","cut","tr","sed","awk","wc","tee","tar","gzip","gunzip","touch","mkdir","rm","mv","cp","chmod","ln","pwd","env","date","sleep","id","whoami","hostname","uname","ps","kill","df","du","curl","wget","nano","diff","uniq","xargs","base64"];for(let e of t)st(n,`/usr/bin/${e}`,`#!/bin/sh
274
281
  exec builtin ${e} "$@"
275
282
  `,493);st(n,"/usr/bin/lsb_release",`#!/bin/sh
276
283
  exec lsb_release "$@"
277
- `,493)}function XA(n){ye(n,"/var"),ye(n,"/var/log"),ye(n,"/var/tmp"),ye(n,"/var/run"),ye(n,"/var/cache"),ye(n,"/var/cache/apt"),ye(n,"/var/cache/apt/archives"),ye(n,"/var/lib"),ye(n,"/var/lib/apt"),ye(n,"/var/lib/apt/lists"),ye(n,"/var/lib/dpkg"),ye(n,"/var/lib/dpkg/info"),st(n,"/var/lib/dpkg/status",""),st(n,"/var/lib/dpkg/available",""),st(n,"/var/log/syslog",`${new Date().toUTCString()} fortune kernel: Virtual container started
278
- `),st(n,"/var/log/auth.log",""),st(n,"/var/log/dpkg.log",""),st(n,"/var/log/apt/history.log",""),st(n,"/var/log/apt/term.log","")}function JA(n){n.exists("/bin")||n.symlink("/usr/bin","/bin"),n.exists("/sbin")||n.symlink("/usr/sbin","/sbin"),n.exists("/lib")||ye(n,"/lib"),n.exists("/lib64")||ye(n,"/lib64")}function ZA(n){ye(n,"/tmp",1023)}function eE(n){ye(n,"/root",448),st(n,"/root/.bashrc",`${["# root .bashrc","export PS1='\\[\\033[0;31m\\]\\u@\\h\\[\\033[0m\\]:\\[\\033[0;34m\\]\\w\\[\\033[0m\\]# '","export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","alias ll='ls -la'","alias la='ls -A'"].join(`
284
+ `,493)}function iE(n){_e(n,"/var"),_e(n,"/var/log"),_e(n,"/var/tmp"),_e(n,"/var/run"),_e(n,"/var/cache"),_e(n,"/var/cache/apt"),_e(n,"/var/cache/apt/archives"),_e(n,"/var/lib"),_e(n,"/var/lib/apt"),_e(n,"/var/lib/apt/lists"),_e(n,"/var/lib/dpkg"),_e(n,"/var/lib/dpkg/info"),st(n,"/var/lib/dpkg/status",""),st(n,"/var/lib/dpkg/available",""),st(n,"/var/log/syslog",`${new Date().toUTCString()} fortune kernel: Virtual container started
285
+ `),st(n,"/var/log/auth.log",""),st(n,"/var/log/dpkg.log",""),st(n,"/var/log/apt/history.log",""),st(n,"/var/log/apt/term.log","")}function sE(n){n.exists("/bin")||n.symlink("/usr/bin","/bin"),n.exists("/sbin")||n.symlink("/usr/sbin","/sbin"),n.exists("/lib")||_e(n,"/lib"),n.exists("/lib64")||_e(n,"/lib64")}function oE(n){_e(n,"/tmp",1023)}function aE(n){_e(n,"/root",448),st(n,"/home/root/.bashrc",`${["# root .bashrc","export PS1='\\[\\033[0;31m\\]\\u@\\h\\[\\033[0m\\]:\\[\\033[0;34m\\]\\w\\[\\033[0m\\]# '","export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","alias ll='ls -la'","alias la='ls -A'"].join(`
279
286
  `)}
280
- `),st(n,"/root/.profile",`[ -f ~/.bashrc ] && . ~/.bashrc
281
- `),n.exists("/home/root")||n.symlink("/root","/home/root")}function tE(n){ye(n,"/opt"),ye(n,"/srv"),ye(n,"/mnt"),ye(n,"/media")}function fh(n,t,e,r,s){GA(n,e,r),zA(n,r),YA(n),jA(n),XA(n),JA(n),ZA(n),eE(n),tE(n),zs(n,r,e,s,[]),ac(n,t)}function lh(n){return n==="1"||n==="true"}function uh(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function nE(){return lh(process.env.DEV_MODE)||lh(process.env.RENDER_PERF)}function Jn(n){let t=nE();if(!t)return{enabled:t,mark:()=>{},done:()=>{}};let e=uh(),r=i=>{let o=uh()-e;console.log(`[perf][${n}] ${i}: ${o.toFixed(1)}ms`)};return{enabled:t,mark:r,done:(i="done")=>{r(i)}}}var _h=require("node:events"),Zn=Vt(require("node:fs"),1),kn=Vt(require("node:path"),1),dr=require("node:zlib");var lc=Buffer.from([86,70,83,33]),rE=1,dh=1,hh=2,cc=class{chunks=[];write(t){this.chunks.push(t)}writeUint8(t){let e=Buffer.allocUnsafe(1);e.writeUInt8(t,0),this.chunks.push(e)}writeUint16(t){let e=Buffer.allocUnsafe(2);e.writeUInt16LE(t,0),this.chunks.push(e)}writeUint32(t){let e=Buffer.allocUnsafe(4);e.writeUInt32LE(t,0),this.chunks.push(e)}writeFloat64(t){let e=Buffer.allocUnsafe(8);e.writeDoubleBE(t,0),this.chunks.push(e)}writeString(t){let e=Buffer.from(t,"utf8");this.writeUint16(e.length),this.chunks.push(e)}writeBytes(t){this.writeUint32(t.length),this.chunks.push(t)}toBuffer(){return Buffer.concat(this.chunks)}};function ph(n,t){if(t.type==="file"){let e=t;n.writeUint8(dh),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt.getTime()),n.writeFloat64(e.updatedAt.getTime()),n.writeUint8(e.compressed?1:0),n.writeBytes(e.content)}else{let e=t;n.writeUint8(hh),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt.getTime()),n.writeFloat64(e.updatedAt.getTime());let r=Array.from(e.children.values());n.writeUint32(r.length);for(let s of r)ph(n,s)}}function gh(n){let t=new cc;return t.write(lc),t.writeUint8(rE),ph(t,n),t.toBuffer()}var fc=class{constructor(t){this.buf=t}buf;pos=0;readUint8(){return this.buf.readUInt8(this.pos++)}readUint16(){let t=this.buf.readUInt16LE(this.pos);return this.pos+=2,t}readUint32(){let t=this.buf.readUInt32LE(this.pos);return this.pos+=4,t}readFloat64(){let t=this.buf.readDoubleBE(this.pos);return this.pos+=8,t}readString(){let t=this.readUint16(),e=this.buf.toString("utf8",this.pos,this.pos+t);return this.pos+=t,e}readBytes(){let t=this.readUint32(),e=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,e}remaining(){return this.buf.length-this.pos}};function mh(n){let t=n.readUint8(),e=n.readString(),r=n.readUint32(),s=new Date(n.readFloat64()),i=new Date(n.readFloat64());if(t===dh){let o=n.readUint8()===1,a=n.readBytes();return{type:"file",name:e,mode:r,createdAt:s,updatedAt:i,compressed:o,content:a}}if(t===hh){let o=n.readUint32(),a=new Map;for(let c=0;c<o;c++){let f=mh(n);a.set(f.name,f)}return{type:"directory",name:e,mode:r,createdAt:s,updatedAt:i,children:a}}throw new Error(`[VFS binary] Unknown node type: 0x${t.toString(16)}`)}function Ah(n){if(n.length<5)throw new Error("[VFS binary] Buffer too short");if(!n.slice(0,4).equals(lc))throw new Error("[VFS binary] Invalid magic \u2014 not a VFS binary snapshot");let e=new fc(n);for(let s=0;s<5;s++)e.readUint8();let r=mh(e);if(r.type!=="directory")throw new Error("[VFS binary] Root node must be a directory");return r}function Eh(n){return n.length>=4&&n.slice(0,4).equals(lc)}var Ys=Vt(require("node:path"),1);function _t(n){if(!n||n.trim()==="")return"/";let t=Ys.posix.normalize(n.startsWith("/")?n:`/${n}`);return t===""?"/":t}function iE(n){return n.split("/").filter(Boolean)}function Ft(n,t){let e=_t(t);if(e==="/")return n;let r=iE(e),s=n;for(let i of r){if(s.type!=="directory")throw new Error(`Path '${e}' does not exist.`);let o=s.children.get(i);if(!o)throw new Error(`Path '${e}' does not exist.`);s=o}return s}function zr(n,t,e,r){let s=_t(t);if(s==="/")throw new Error("Root path has no parent directory.");let i=Ys.posix.dirname(s),o=Ys.posix.basename(s);if(!o)throw new Error(`Invalid path '${t}'.`);e&&r(i);let a=Ft(n,i);if(a.type!=="directory")throw new Error(`Parent path '${i}' is not a directory.`);return{parent:a,name:o}}var uc=class n extends _h.EventEmitter{root;mode;snapshotFile;constructor(t={}){if(super(),this.mode=t.mode??"memory",this.mode==="fs"){if(!t.snapshotPath)throw new Error('VirtualFileSystem: "snapshotPath" is required when mode is "fs".');this.snapshotFile=kn.resolve(t.snapshotPath,"vfs-snapshot.vfsb")}else this.snapshotFile=null;this.root=this.makeDir("",493)}makeDir(t,e){let r=new Date;return{type:"directory",name:t,mode:e,createdAt:r,updatedAt:r,children:new Map}}makeFile(t,e,r,s){let i=new Date;return{type:"file",name:t,content:e,mode:r,compressed:s,createdAt:i,updatedAt:i}}mkdirRecursive(t,e){let r=_t(t);if(r==="/")return;let s=r.split("/").filter(Boolean),i=this.root,o="";for(let a of s){o+=`/${a}`;let c=i.children.get(a);if(!c)c=this.makeDir(a,e),i.children.set(a,c),this.emit("dir:create",{path:o,mode:e});else if(c.type!=="directory")throw new Error(`Cannot create directory '${o}': path is a file.`);i=c}}async restoreMirror(){if(!(this.mode!=="fs"||!this.snapshotFile)&&Zn.existsSync(this.snapshotFile))try{let t=Zn.readFileSync(this.snapshotFile);if(Eh(t))this.root=Ah(t);else{let e=JSON.parse(t.toString("utf8"));this.root=this.deserializeDir(e.root,""),console.info("[VirtualFileSystem] Migrating legacy JSON snapshot to binary format.")}this.emit("snapshot:restore",{path:this.snapshotFile})}catch(t){console.warn(`[VirtualFileSystem] Could not restore snapshot from ${this.snapshotFile}:`,t instanceof Error?t.message:String(t))}}async flushMirror(){if(this.mode!=="fs"||!this.snapshotFile){this.emit("mirror:flush");return}let t=kn.dirname(this.snapshotFile);Zn.mkdirSync(t,{recursive:!0});let e=gh(this.root);Zn.writeFileSync(this.snapshotFile,e),this.emit("mirror:flush",{path:this.snapshotFile})}getMode(){return this.mode}getSnapshotPath(){return this.snapshotFile}mkdir(t,e=493){let r=_t(t),s=(()=>{try{return Ft(this.root,r)}catch{return null}})();if(s&&s.type!=="directory")throw new Error(`Cannot create directory '${r}': path is a file.`);this.mkdirRecursive(r,e)}writeFile(t,e,r={}){let s=_t(t),{parent:i,name:o}=zr(this.root,s,!0,h=>this.mkdirRecursive(h,493)),a=i.children.get(o);if(a?.type==="directory")throw new Error(`Cannot write file '${s}': path is a directory.`);let c=Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"),f=r.compress??!1,l=f?(0,dr.gzipSync)(c):c,u=r.mode??420;if(a){let h=a;h.content=l,h.compressed=f,h.mode=u,h.updatedAt=new Date}else i.children.set(o,this.makeFile(o,l,u,f));this.emit("file:write",{path:s,size:l.length})}readFile(t){let e=_t(t),r=Ft(this.root,e);if(r.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let s=r,i=s.compressed?(0,dr.gunzipSync)(s.content):s.content;return this.emit("file:read",{path:e,size:i.length}),i.toString("utf8")}readFileRaw(t){let e=_t(t),r=Ft(this.root,e);if(r.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let s=r,i=s.compressed?(0,dr.gunzipSync)(s.content):s.content;return this.emit("file:read",{path:e,size:i.length}),i}exists(t){try{return Ft(this.root,_t(t)),!0}catch{return!1}}chmod(t,e){Ft(this.root,_t(t)).mode=e}stat(t){let e=_t(t),r=Ft(this.root,e),s=e==="/"?"":kn.posix.basename(e);if(r.type==="file"){let o=r;return{type:"file",name:s,path:e,mode:o.mode,createdAt:o.createdAt,updatedAt:o.updatedAt,compressed:o.compressed,size:o.content.length}}let i=r;return{type:"directory",name:s,path:e,mode:i.mode,createdAt:i.createdAt,updatedAt:i.updatedAt,childrenCount:i.children.size}}list(t="/"){let e=_t(t),r=Ft(this.root,e);if(r.type!=="directory")throw new Error(`Cannot list '${t}': not a directory.`);return Array.from(r.children.keys()).sort()}tree(t="/"){let e=_t(t),r=Ft(this.root,e);if(r.type!=="directory")throw new Error(`Cannot render tree for '${t}': not a directory.`);let s=t==="/"?"/":kn.posix.basename(e);return this.renderTreeLines(r,s)}renderTreeLines(t,e){let r=[e],s=Array.from(t.children.keys()).sort();for(let i=0;i<s.length;i++){let o=s[i],a=t.children.get(o),c=i===s.length-1,f=c?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",l=c?" ":"\u2502 ";if(r.push(`${f}${o}`),a.type==="directory"){let u=this.renderTreeLines(a,"").split(`
287
+ `),st(n,"/home/root/.profile",`[ -f ~/.bashrc ] && . ~/.bashrc
288
+ `)}function cE(n){_e(n,"/opt"),_e(n,"/srv"),_e(n,"/mnt"),_e(n,"/media")}function gh(n,t,e,r,s){eE(n,e,r),tE(n,r),nE(n),rE(n),iE(n),sE(n),oE(n),aE(n),cE(n),Xs(n,r,e,s,[]),uc(n,t)}function mh(n){return n==="1"||n==="true"}function Ah(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function fE(){return mh(process.env.DEV_MODE)||mh(process.env.RENDER_PERF)}function tr(n){let t=fE();if(!t)return{enabled:t,mark:()=>{},done:()=>{}};let e=Ah(),r=i=>{let o=Ah()-e;console.log(`[perf][${n}] ${i}: ${o.toFixed(1)}ms`)};return{enabled:t,mark:r,done:(i="done")=>{r(i)}}}var Ih=require("node:events"),at=Gt(require("node:fs"),1),nn=Gt(require("node:path"),1),dr=require("node:zlib");var pc=Buffer.from([86,70,83,33]),lE=1,Eh=1,yh=2,dc=class{chunks=[];write(t){this.chunks.push(t)}writeUint8(t){let e=Buffer.allocUnsafe(1);e.writeUInt8(t,0),this.chunks.push(e)}writeUint16(t){let e=Buffer.allocUnsafe(2);e.writeUInt16LE(t,0),this.chunks.push(e)}writeUint32(t){let e=Buffer.allocUnsafe(4);e.writeUInt32LE(t,0),this.chunks.push(e)}writeFloat64(t){let e=Buffer.allocUnsafe(8);e.writeDoubleBE(t,0),this.chunks.push(e)}writeString(t){let e=Buffer.from(t,"utf8");this.writeUint16(e.length),this.chunks.push(e)}writeBytes(t){this.writeUint32(t.length),this.chunks.push(t)}toBuffer(){return Buffer.concat(this.chunks)}};function _h(n,t){if(t.type==="file"){let e=t;n.writeUint8(Eh),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt.getTime()),n.writeFloat64(e.updatedAt.getTime()),n.writeUint8(e.compressed?1:0),n.writeBytes(e.content)}else{let e=t;n.writeUint8(yh),n.writeString(e.name),n.writeUint32(e.mode),n.writeFloat64(e.createdAt.getTime()),n.writeFloat64(e.updatedAt.getTime());let r=Array.from(e.children.values());n.writeUint32(r.length);for(let s of r)_h(n,s)}}function bh(n){let t=new dc;return t.write(pc),t.writeUint8(lE),_h(t,n),t.toBuffer()}var hc=class{constructor(t){this.buf=t}buf;pos=0;readUint8(){return this.buf.readUInt8(this.pos++)}readUint16(){let t=this.buf.readUInt16LE(this.pos);return this.pos+=2,t}readUint32(){let t=this.buf.readUInt32LE(this.pos);return this.pos+=4,t}readFloat64(){let t=this.buf.readDoubleBE(this.pos);return this.pos+=8,t}readString(){let t=this.readUint16(),e=this.buf.toString("utf8",this.pos,this.pos+t);return this.pos+=t,e}readBytes(){let t=this.readUint32(),e=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,e}remaining(){return this.buf.length-this.pos}};function xh(n){let t=n.readUint8(),e=n.readString(),r=n.readUint32(),s=new Date(n.readFloat64()),i=new Date(n.readFloat64());if(t===Eh){let o=n.readUint8()===1,a=n.readBytes();return{type:"file",name:e,mode:r,createdAt:s,updatedAt:i,compressed:o,content:a}}if(t===yh){let o=n.readUint32(),a=new Map;for(let c=0;c<o;c++){let f=xh(n);a.set(f.name,f)}return{type:"directory",name:e,mode:r,createdAt:s,updatedAt:i,children:a}}throw new Error(`[VFS binary] Unknown node type: 0x${t.toString(16)}`)}function Sh(n){if(n.length<5)throw new Error("[VFS binary] Buffer too short");if(!n.slice(0,4).equals(pc))throw new Error("[VFS binary] Invalid magic \u2014 not a VFS binary snapshot");let e=new hc(n);for(let s=0;s<5;s++)e.readUint8();let r=xh(e);if(r.type!=="directory")throw new Error("[VFS binary] Root node must be a directory");return r}function wh(n){return n.length>=4&&n.slice(0,4).equals(pc)}var Js=Gt(require("node:path"),1);function dt(n){if(!n||n.trim()==="")return"/";let t=Js.posix.normalize(n.startsWith("/")?n:`/${n}`);return t===""?"/":t}function uE(n){return n.split("/").filter(Boolean)}function Ht(n,t){let e=dt(t);if(e==="/")return n;let r=uE(e),s=n;for(let i of r){if(s.type!=="directory")throw new Error(`Path '${e}' does not exist.`);let o=s.children.get(i);if(!o)throw new Error(`Path '${e}' does not exist.`);s=o}return s}function Yr(n,t,e,r){let s=dt(t);if(s==="/")throw new Error("Root path has no parent directory.");let i=Js.posix.dirname(s),o=Js.posix.basename(s);if(!o)throw new Error(`Invalid path '${t}'.`);e&&r(i);let a=Ht(n,i);if(a.type!=="directory")throw new Error(`Parent path '${i}' is not a directory.`);return{parent:a,name:o}}var gc=class n extends Ih.EventEmitter{root;mode;snapshotFile;mounts=new Map;static isBrowser=typeof process>"u"||typeof process.versions?.node>"u";constructor(t={}){if(super(),this.mode=t.mode??"memory",this.mode==="fs"){if(!t.snapshotPath)throw new Error('VirtualFileSystem: "snapshotPath" is required when mode is "fs".');this.snapshotFile=nn.resolve(t.snapshotPath,"vfs-snapshot.vfsb")}else this.snapshotFile=null;this.root=this.makeDir("",493)}makeDir(t,e){let r=new Date;return{type:"directory",name:t,mode:e,createdAt:r,updatedAt:r,children:new Map}}makeFile(t,e,r,s){let i=new Date;return{type:"file",name:t,content:e,mode:r,compressed:s,createdAt:i,updatedAt:i}}mkdirRecursive(t,e){let r=dt(t);if(r==="/")return;let s=r.split("/").filter(Boolean),i=this.root,o="";for(let a of s){o+=`/${a}`;let c=i.children.get(a);if(!c)c=this.makeDir(a,e),i.children.set(a,c),this.emit("dir:create",{path:o,mode:e});else if(c.type!=="directory")throw new Error(`Cannot create directory '${o}': path is a file.`);i=c}}async restoreMirror(){if(!(this.mode!=="fs"||!this.snapshotFile)&&at.existsSync(this.snapshotFile))try{let t=at.readFileSync(this.snapshotFile);if(wh(t))this.root=Sh(t);else{let e=JSON.parse(t.toString("utf8"));this.root=this.deserializeDir(e.root,""),console.info("[VirtualFileSystem] Migrating legacy JSON snapshot to binary format.")}this.emit("snapshot:restore",{path:this.snapshotFile})}catch(t){console.warn(`[VirtualFileSystem] Could not restore snapshot from ${this.snapshotFile}:`,t instanceof Error?t.message:String(t))}}async flushMirror(){if(this.mode!=="fs"||!this.snapshotFile){this.emit("mirror:flush");return}let t=nn.dirname(this.snapshotFile);at.mkdirSync(t,{recursive:!0});let e=bh(this.root);at.writeFileSync(this.snapshotFile,e),this.emit("mirror:flush",{path:this.snapshotFile})}getMode(){return this.mode}getSnapshotPath(){return this.snapshotFile}mount(t,e,{readOnly:r=!0}={}){if(n.isBrowser)return;let s=dt(t),i=nn.resolve(e);if(!at.existsSync(i))throw new Error(`VirtualFileSystem.mount: host path does not exist: "${i}"`);if(!at.statSync(i).isDirectory())throw new Error(`VirtualFileSystem.mount: host path is not a directory: "${i}"`);this.mkdir(s),this.mounts.set(s,{hostPath:i,readOnly:r}),this.emit("mount",{vPath:s,hostPath:i,readOnly:r})}unmount(t){let e=dt(t);this.mounts.delete(e)&&this.emit("unmount",{vPath:e})}getMounts(){return[...this.mounts.entries()].map(([t,e])=>({vPath:t,...e}))}resolveMount(t){let e=dt(t),r=[...this.mounts.entries()].sort(([s],[i])=>i.length-s.length);for(let[s,i]of r)if(e===s||e.startsWith(`${s}/`)){let o=e.slice(s.length).replace(/^\//,""),a=o?nn.join(i.hostPath,o):i.hostPath;return{hostPath:i.hostPath,readOnly:i.readOnly,relPath:o,fullHostPath:a}}return null}mkdir(t,e=493){let r=dt(t),s=(()=>{try{return Ht(this.root,r)}catch{return null}})();if(s&&s.type!=="directory")throw new Error(`Cannot create directory '${r}': path is a file.`);this.mkdirRecursive(r,e)}writeFile(t,e,r={}){let s=this.resolveMount(t);if(s){if(s.readOnly)throw new Error(`EROFS: read-only file system, open '${s.fullHostPath}'`);let p=nn.dirname(s.fullHostPath);at.existsSync(p)||at.mkdirSync(p,{recursive:!0}),at.writeFileSync(s.fullHostPath,Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"));return}let i=dt(t),{parent:o,name:a}=Yr(this.root,i,!0,p=>this.mkdirRecursive(p,493)),c=o.children.get(a);if(c?.type==="directory")throw new Error(`Cannot write file '${i}': path is a directory.`);let f=Buffer.isBuffer(e)?e:Buffer.from(e,"utf8"),l=r.compress??!1,u=l?(0,dr.gzipSync)(f):f,h=r.mode??420;if(c){let p=c;p.content=u,p.compressed=l,p.mode=h,p.updatedAt=new Date}else o.children.set(a,this.makeFile(a,u,h,l));this.emit("file:write",{path:i,size:u.length})}readFile(t){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return at.readFileSync(e.fullHostPath,"utf8")}let r=dt(t),s=Ht(this.root,r);if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s,o=i.compressed?(0,dr.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o.toString("utf8")}readFileRaw(t){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))throw new Error(`ENOENT: no such file or directory, open '${e.fullHostPath}'`);return at.readFileSync(e.fullHostPath)}let r=dt(t),s=Ht(this.root,r);if(s.type!=="file")throw new Error(`Cannot read '${t}': not a file.`);let i=s,o=i.compressed?(0,dr.gunzipSync)(i.content):i.content;return this.emit("file:read",{path:r,size:o.length}),o}exists(t){let e=this.resolveMount(t);if(e)return at.existsSync(e.fullHostPath);try{return Ht(this.root,dt(t)),!0}catch{return!1}}chmod(t,e){Ht(this.root,dt(t)).mode=e}stat(t){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))throw new Error(`ENOENT: stat '${e.fullHostPath}'`);let a=at.statSync(e.fullHostPath),c=e.relPath.split("/").pop()??e.fullHostPath.split("/").pop()??"",f=a.mtime;return a.isDirectory()?{type:"directory",name:c,path:dt(t),mode:493,createdAt:a.birthtime,updatedAt:f,childrenCount:at.readdirSync(e.fullHostPath).length}:{type:"file",name:c,path:dt(t),mode:e.readOnly?292:420,createdAt:a.birthtime,updatedAt:f,compressed:!1,size:a.size}}let r=dt(t),s=Ht(this.root,r),i=r==="/"?"":nn.posix.basename(r);if(s.type==="file"){let a=s;return{type:"file",name:i,path:r,mode:a.mode,createdAt:a.createdAt,updatedAt:a.updatedAt,compressed:a.compressed,size:a.content.length}}let o=s;return{type:"directory",name:i,path:r,mode:o.mode,createdAt:o.createdAt,updatedAt:o.updatedAt,childrenCount:o.children.size}}list(t="/"){let e=this.resolveMount(t);if(e){if(!at.existsSync(e.fullHostPath))return[];try{return at.readdirSync(e.fullHostPath).sort()}catch{return[]}}let r=dt(t),s=Ht(this.root,r);if(s.type!=="directory")throw new Error(`Cannot list '${t}': not a directory.`);return Array.from(s.children.keys()).sort()}tree(t="/"){let e=dt(t),r=Ht(this.root,e);if(r.type!=="directory")throw new Error(`Cannot render tree for '${t}': not a directory.`);let s=t==="/"?"/":nn.posix.basename(e);return this.renderTreeLines(r,s)}renderTreeLines(t,e){let r=[e],s=Array.from(t.children.keys()).sort();for(let i=0;i<s.length;i++){let o=s[i],a=t.children.get(o),c=i===s.length-1,f=c?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",l=c?" ":"\u2502 ";if(r.push(`${f}${o}`),a.type==="directory"){let u=this.renderTreeLines(a,"").split(`
282
289
  `).slice(1).map(h=>`${l}${h}`);r.push(...u)}}return r.join(`
283
- `)}getUsageBytes(t="/"){return this.computeUsage(Ft(this.root,_t(t)))}computeUsage(t){if(t.type==="file")return t.content.length;let e=0;for(let r of t.children.values())e+=this.computeUsage(r);return e}compressFile(t){let e=Ft(this.root,_t(t));if(e.type!=="file")throw new Error(`Cannot compress '${t}': not a file.`);let r=e;r.compressed||(r.content=(0,dr.gzipSync)(r.content),r.compressed=!0,r.updatedAt=new Date)}decompressFile(t){let e=Ft(this.root,_t(t));if(e.type!=="file")throw new Error(`Cannot decompress '${t}': not a file.`);let r=e;r.compressed&&(r.content=(0,dr.gunzipSync)(r.content),r.compressed=!1,r.updatedAt=new Date)}symlink(t,e){let r=_t(e),s=t.startsWith("/")?_t(t):t,{parent:i,name:o}=zr(this.root,r,!0,c=>this.mkdirRecursive(c,493)),a={type:"file",name:o,content:Buffer.from(s,"utf8"),mode:41471,compressed:!1,createdAt:new Date,updatedAt:new Date};i.children.set(o,a),this.emit("symlink:create",{link:r,target:s})}isSymlink(t){try{let e=Ft(this.root,_t(t));return e.type==="file"&&e.mode===41471}catch{return!1}}resolveSymlink(t,e=8){let r=_t(t);for(let s=0;s<e;s++){try{let i=Ft(this.root,r);if(i.type==="file"&&i.mode===41471){let o=i.content.toString("utf8");r=o.startsWith("/")?o:_t(kn.posix.join(kn.posix.dirname(r),o));continue}}catch{break}return r}throw new Error(`Too many levels of symbolic links: ${t}`)}remove(t,e={}){let r=_t(t);if(r==="/")throw new Error("Cannot remove root directory.");let s=Ft(this.root,r);if(s.type==="directory"){let a=s;if(!e.recursive&&a.children.size>0)throw new Error(`Directory '${r}' is not empty. Use recursive option.`)}let{parent:i,name:o}=zr(this.root,r,!1,()=>{});i.children.delete(o),this.emit("node:remove",{path:r})}move(t,e){let r=_t(t),s=_t(e);if(r==="/"||s==="/")throw new Error("Cannot move root directory.");let i=Ft(this.root,r);if(this.exists(s))throw new Error(`Destination '${s}' already exists.`);this.mkdirRecursive(kn.posix.dirname(s),493);let{parent:o,name:a}=zr(this.root,s,!1,()=>{}),{parent:c,name:f}=zr(this.root,r,!1,()=>{});c.children.delete(f),i.name=a,o.children.set(a,i)}toSnapshot(){return{root:this.serializeDir(this.root)}}serializeDir(t){let e=[];for(let r of t.children.values())e.push(r.type==="file"?this.serializeFile(r):this.serializeDir(r));return{type:"directory",name:t.name,mode:t.mode,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),children:e}}serializeFile(t){return{type:"file",name:t.name,mode:t.mode,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),compressed:t.compressed,contentBase64:t.content.toString("base64")}}static fromSnapshot(t){let e=new n;return e.root=e.deserializeDir(t.root,""),e}importSnapshot(t){this.root=this.deserializeDir(t.root,""),this.emit("snapshot:import")}deserializeDir(t,e){let r={type:"directory",name:e,mode:t.mode,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt),children:new Map};for(let s of t.children)if(s.type==="file"){let i=s;r.children.set(i.name,{type:"file",name:i.name,mode:i.mode,createdAt:new Date(i.createdAt),updatedAt:new Date(i.updatedAt),compressed:i.compressed,content:Buffer.from(i.contentBase64,"base64")})}else{let i=this.deserializeDir(s,s.name);r.children.set(s.name,i)}return r}},yh=uc;var dc=[{name:"vim",version:"2:9.0.1378-2",section:"editors",description:"Vi IMproved - enhanced vi editor",shortDesc:"Vi IMproved",installedSizeKb:3812,files:[{path:"/usr/bin/vim",content:`#!/bin/sh
290
+ `)}getUsageBytes(t="/"){return this.computeUsage(Ht(this.root,dt(t)))}computeUsage(t){if(t.type==="file")return t.content.length;let e=0;for(let r of t.children.values())e+=this.computeUsage(r);return e}compressFile(t){let e=Ht(this.root,dt(t));if(e.type!=="file")throw new Error(`Cannot compress '${t}': not a file.`);let r=e;r.compressed||(r.content=(0,dr.gzipSync)(r.content),r.compressed=!0,r.updatedAt=new Date)}decompressFile(t){let e=Ht(this.root,dt(t));if(e.type!=="file")throw new Error(`Cannot decompress '${t}': not a file.`);let r=e;r.compressed&&(r.content=(0,dr.gunzipSync)(r.content),r.compressed=!1,r.updatedAt=new Date)}symlink(t,e){let r=dt(e),s=t.startsWith("/")?dt(t):t,{parent:i,name:o}=Yr(this.root,r,!0,c=>this.mkdirRecursive(c,493)),a={type:"file",name:o,content:Buffer.from(s,"utf8"),mode:41471,compressed:!1,createdAt:new Date,updatedAt:new Date};i.children.set(o,a),this.emit("symlink:create",{link:r,target:s})}isSymlink(t){try{let e=Ht(this.root,dt(t));return e.type==="file"&&e.mode===41471}catch{return!1}}resolveSymlink(t,e=8){let r=dt(t);for(let s=0;s<e;s++){try{let i=Ht(this.root,r);if(i.type==="file"&&i.mode===41471){let o=i.content.toString("utf8");r=o.startsWith("/")?o:dt(nn.posix.join(nn.posix.dirname(r),o));continue}}catch{break}return r}throw new Error(`Too many levels of symbolic links: ${t}`)}remove(t,e={}){let r=this.resolveMount(t);if(r){if(r.readOnly)throw new Error(`EROFS: read-only file system, unlink '${r.fullHostPath}'`);if(!at.existsSync(r.fullHostPath))throw new Error(`ENOENT: no such file or directory, unlink '${r.fullHostPath}'`);at.statSync(r.fullHostPath).isDirectory()?at.rmSync(r.fullHostPath,{recursive:e.recursive??!1}):at.unlinkSync(r.fullHostPath);return}let s=dt(t);if(s==="/")throw new Error("Cannot remove root directory.");let i=Ht(this.root,s);if(i.type==="directory"){let c=i;if(!e.recursive&&c.children.size>0)throw new Error(`Directory '${s}' is not empty. Use recursive option.`)}let{parent:o,name:a}=Yr(this.root,s,!1,()=>{});o.children.delete(a),this.emit("node:remove",{path:s})}move(t,e){let r=dt(t),s=dt(e);if(r==="/"||s==="/")throw new Error("Cannot move root directory.");let i=Ht(this.root,r);if(this.exists(s))throw new Error(`Destination '${s}' already exists.`);this.mkdirRecursive(nn.posix.dirname(s),493);let{parent:o,name:a}=Yr(this.root,s,!1,()=>{}),{parent:c,name:f}=Yr(this.root,r,!1,()=>{});c.children.delete(f),i.name=a,o.children.set(a,i)}toSnapshot(){return{root:this.serializeDir(this.root)}}serializeDir(t){let e=[];for(let r of t.children.values())e.push(r.type==="file"?this.serializeFile(r):this.serializeDir(r));return{type:"directory",name:t.name,mode:t.mode,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),children:e}}serializeFile(t){return{type:"file",name:t.name,mode:t.mode,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),compressed:t.compressed,contentBase64:t.content.toString("base64")}}static fromSnapshot(t){let e=new n;return e.root=e.deserializeDir(t.root,""),e}importSnapshot(t){this.root=this.deserializeDir(t.root,""),this.emit("snapshot:import")}deserializeDir(t,e){let r={type:"directory",name:e,mode:t.mode,createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt),children:new Map};for(let s of t.children)if(s.type==="file"){let i=s;r.children.set(i.name,{type:"file",name:i.name,mode:i.mode,createdAt:new Date(i.createdAt),updatedAt:new Date(i.updatedAt),compressed:i.compressed,content:Buffer.from(i.contentBase64,"base64")})}else{let i=this.deserializeDir(s,s.name);r.children.set(s.name,i)}return r}},Ch=gc;var mc=[{name:"vim",version:"2:9.0.1378-2",section:"editors",description:"Vi IMproved - enhanced vi editor",shortDesc:"Vi IMproved",installedSizeKb:3812,files:[{path:"/usr/bin/vim",content:`#!/bin/sh
284
291
  echo 'vim: use nano for editing in this environment'
285
292
  `,mode:493},{path:"/usr/bin/vi",content:`#!/bin/sh
286
293
  exec vim "$@"
@@ -369,19 +376,19 @@ echo 'journalctl: virtual stub'
369
376
  echo 'gzip: virtual stub'
370
377
  `,mode:493}]},{name:"neofetch",version:"7.1.0-1",section:"utils",description:"A command-line system information tool written in bash 3.2+",shortDesc:"command-line system information tool",installedSizeKb:256,files:[{path:"/usr/bin/neofetch",content:`#!/bin/sh
371
378
  echo 'neofetch: virtual stub'
372
- `,mode:493}]}],js=class{constructor(t,e){this.vfs=t;this.users=e}vfs;users;installed=new Map;registryPath="/var/lib/dpkg/status";logPath="/var/log/dpkg.log";aptLogPath="/var/log/apt/history.log";load(){if(!this.vfs.exists(this.registryPath))return;let t=this.vfs.readFile(this.registryPath);if(!t.trim())return;let e=t.split(/\n\n+/);for(let r of e){if(!r.trim())continue;let s=this.parseFields(r),i=s.Package;i&&this.installed.set(i,{name:i,version:s.Version??"unknown",architecture:s.Architecture??"amd64",maintainer:s.Maintainer??"Fortune Maintainers",description:s.Description??"",section:s.Section??"misc",installedSizeKb:Number(s["Installed-Size"]??0),installedAt:s["X-Installed-At"]??new Date().toISOString(),files:(s["X-Files"]??"").split("|").filter(Boolean)})}}persist(){let t=[];for(let e of this.installed.values())t.push([`Package: ${e.name}`,"Status: install ok installed","Priority: optional",`Section: ${e.section}`,`Installed-Size: ${e.installedSizeKb}`,`Maintainer: ${e.maintainer}`,`Architecture: ${e.architecture}`,`Version: ${e.version}`,`Description: ${e.description}`,`X-Installed-At: ${e.installedAt}`,`X-Files: ${e.files.join("|")}`].join(`
379
+ `,mode:493}]}],Zs=class{constructor(t,e){this.vfs=t;this.users=e}vfs;users;installed=new Map;registryPath="/var/lib/dpkg/status";logPath="/var/log/dpkg.log";aptLogPath="/var/log/apt/history.log";load(){if(!this.vfs.exists(this.registryPath))return;let t=this.vfs.readFile(this.registryPath);if(!t.trim())return;let e=t.split(/\n\n+/);for(let r of e){if(!r.trim())continue;let s=this.parseFields(r),i=s.Package;i&&this.installed.set(i,{name:i,version:s.Version??"unknown",architecture:s.Architecture??"amd64",maintainer:s.Maintainer??"Fortune Maintainers",description:s.Description??"",section:s.Section??"misc",installedSizeKb:Number(s["Installed-Size"]??0),installedAt:s["X-Installed-At"]??new Date().toISOString(),files:(s["X-Files"]??"").split("|").filter(Boolean)})}}persist(){let t=[];for(let e of this.installed.values())t.push([`Package: ${e.name}`,"Status: install ok installed","Priority: optional",`Section: ${e.section}`,`Installed-Size: ${e.installedSizeKb}`,`Maintainer: ${e.maintainer}`,`Architecture: ${e.architecture}`,`Version: ${e.version}`,`Description: ${e.description}`,`X-Installed-At: ${e.installedAt}`,`X-Files: ${e.files.join("|")}`].join(`
373
380
  `));this.vfs.writeFile(this.registryPath,`${t.join(`
374
381
 
375
382
  `)}
376
383
  `)}parseFields(t){let e={};for(let r of t.split(`
377
384
  `)){let s=r.indexOf(": ");s!==-1&&(e[r.slice(0,s)]=r.slice(s+2))}return e}log(t){let r=`${new Date().toISOString().replace("T"," ").slice(0,19)} ${t}
378
385
  `,s=this.vfs.exists(this.logPath)?this.vfs.readFile(this.logPath):"";this.vfs.writeFile(this.logPath,s+r)}aptLog(t,e){let r=new Date().toISOString(),s=this.vfs.exists(this.aptLogPath)?this.vfs.readFile(this.aptLogPath):"",i=[`Start-Date: ${r}`,`Commandline: apt-get ${t} ${e.join(" ")}`,`${t==="install"?"Install":"Remove"}: ${e.join(", ")}`,`End-Date: ${r}`,""].join(`
379
- `);this.vfs.writeFile(this.aptLogPath,s+i)}findInRegistry(t){return dc.find(e=>e.name.toLowerCase()===t.toLowerCase())}listAvailable(){return[...dc].sort((t,e)=>t.name.localeCompare(e.name))}listInstalled(){return[...this.installed.values()].sort((t,e)=>t.name.localeCompare(e.name))}isInstalled(t){return this.installed.has(t.toLowerCase())}installedCount(){return this.installed.size}install(t,e={}){let r=[],s=[],i=[],o=(c,f=new Set)=>{if(f.has(c)||(f.add(c),this.isInstalled(c)))return;let l=this.findInRegistry(c);if(!l){i.push(c);return}for(let u of l.depends??[])o(u,f);s.find(u=>u.name===l.name)||s.push(l)};for(let c of t)o(c);if(i.length>0)return{output:`E: Unable to locate package ${i.join(", ")}`,exitCode:100};if(s.length===0)return{output:t.map(c=>`${c} is already the newest version.`).join(`
386
+ `);this.vfs.writeFile(this.aptLogPath,s+i)}findInRegistry(t){return mc.find(e=>e.name.toLowerCase()===t.toLowerCase())}listAvailable(){return[...mc].sort((t,e)=>t.name.localeCompare(e.name))}listInstalled(){return[...this.installed.values()].sort((t,e)=>t.name.localeCompare(e.name))}isInstalled(t){return this.installed.has(t.toLowerCase())}installedCount(){return this.installed.size}install(t,e={}){let r=[],s=[],i=[],o=(c,f=new Set)=>{if(f.has(c)||(f.add(c),this.isInstalled(c)))return;let l=this.findInRegistry(c);if(!l){i.push(c);return}for(let u of l.depends??[])o(u,f);s.find(u=>u.name===l.name)||s.push(l)};for(let c of t)o(c);if(i.length>0)return{output:`E: Unable to locate package ${i.join(", ")}`,exitCode:100};if(s.length===0)return{output:t.map(c=>`${c} is already the newest version.`).join(`
380
387
  `),exitCode:0};let a=s.reduce((c,f)=>c+(f.installedSizeKb??0),0);e.quiet||r.push("Reading package lists... Done","Building dependency tree... Done","Reading state information... Done","The following NEW packages will be installed:",` ${s.map(c=>c.name).join(" ")}`,`0 upgraded, ${s.length} newly installed, 0 to remove and 0 not upgraded.`,`Need to get 0 B/${a} kB of archives.`,`After this operation, ${a} kB of additional disk space will be used.`,"");for(let c of s){e.quiet||(r.push(`Selecting previously unselected package ${c.name}.`),r.push("(Reading database ... 12345 files and directories currently installed.)"),r.push(`Preparing to unpack .../archives/${c.name}_${c.version}_amd64.deb ...`),r.push(`Unpacking ${c.name} (${c.version}) ...`));for(let l of c.files??[]){let u=l.path.slice(0,l.path.lastIndexOf("/"));u&&!this.vfs.exists(u)&&this.vfs.mkdir(u,493),this.vfs.writeFile(l.path,l.content,{mode:l.mode??420})}c.onInstall?.(this.vfs,this.users),e.quiet||r.push(`Setting up ${c.name} (${c.version}) ...`);let f=new Date().toISOString();this.installed.set(c.name,{name:c.name,version:c.version,architecture:c.architecture??"amd64",maintainer:c.maintainer??"Fortune Maintainers <pkg@fortune.local>",description:c.description,section:c.section??"misc",installedSizeKb:c.installedSizeKb??0,installedAt:f,files:(c.files??[]).map(l=>l.path)}),this.log(`install ${c.name} ${c.version}`)}return this.aptLog("install",s.map(c=>c.name)),this.persist(),e.quiet||r.push("Processing triggers for man-db (2.11.2-2) ..."),{output:r.join(`
381
388
  `),exitCode:0}}remove(t,e={}){let r=[],s=[];for(let i of t){let o=this.installed.get(i.toLowerCase());o?s.push(o):r.push(`Package '${i}' is not installed, so not removed`)}if(s.length===0)return{output:r.join(`
382
389
  `)||"Nothing to remove.",exitCode:0};e.quiet||r.push("Reading package lists... Done","Building dependency tree... Done","The following packages will be REMOVED:",` ${s.map(i=>i.name).join(" ")}`,`0 upgraded, 0 newly installed, ${s.length} to remove and 0 not upgraded.`);for(let i of s){e.quiet||r.push(`Removing ${i.name} (${i.version}) ...`);for(let a of i.files)if(!(!e.purge&&(a.startsWith("/etc/")||a.endsWith(".conf"))))try{this.vfs.exists(a)&&this.vfs.remove(a)}catch{}this.findInRegistry(i.name)?.onRemove?.(this.vfs),this.installed.delete(i.name),this.log(`remove ${i.name} ${i.version}`)}return this.aptLog("remove",s.map(i=>i.name)),this.persist(),{output:r.join(`
383
- `),exitCode:0}}search(t){let e=t.toLowerCase();return dc.filter(r=>r.name.includes(e)||r.description.toLowerCase().includes(e)||(r.shortDesc??"").toLowerCase().includes(e)).sort((r,s)=>r.name.localeCompare(s.name))}show(t){let e=this.findInRegistry(t);if(!e)return null;let r=this.installed.get(t);return[`Package: ${e.name}`,`Version: ${e.version}`,`Architecture: ${e.architecture??"amd64"}`,`Maintainer: ${e.maintainer??"Fortune Maintainers <pkg@fortune.local>"}`,`Installed-Size: ${e.installedSizeKb??0}`,`Depends: ${(e.depends??[]).join(", ")||"(none)"}`,`Section: ${e.section??"misc"}`,"Priority: optional",`Description: ${e.description}`,`Status: ${r?"install ok installed":"install ok not-installed"}`].join(`
384
- `)}};var An=require("node:crypto"),xh=require("node:events"),Sh=Vt(require("node:path"),1);function sE(){let n=process.env.SSH_MIMIC_FAST_PASSWORD_HASH;return!!n&&!["0","false","no","off"].includes(n.toLowerCase())}var Rt=Jn("VirtualUserManager"),Xs=class n extends xh.EventEmitter{constructor(e,r=!0){super();this.vfs=e;this.autoSudoForNewUsers=r;Rt.mark("constructor")}vfs;autoSudoForNewUsers;static recordCache=new Map;static fastPasswordHash=sE();usersPath="/etc/htpasswd";sudoersPath="/etc/sudoers";quotasPath="/etc/quotas";authDirPath="/.virtual-env-js/.auth";users=new Map;sudoers=new Set;quotas=new Map;activeSessions=new Map;nextTty=0;async initialize(){Rt.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(Rt.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){Rt.mark("clearQuota"),this.validateUsername(e),this.quotas.delete(e),await this.persist()}getQuotaBytes(e){return Rt.mark("getQuotaBytes"),this.quotas.get(e)??null}getUsageBytes(e){Rt.mark("getUsageBytes");let r=`/home/${e}`;return this.vfs.exists(r)?this.vfs.getUsageBytes(r):0}assertWriteWithinQuota(e,r,s){Rt.mark("assertWriteWithinQuota");let i=this.quotas.get(e);if(i===void 0)return;let o=bh(r),a=bh(`/home/${e}`);if(!(o===a||o.startsWith(`${a}/`)))return;let f=this.getUsageBytes(e),l=0;if(this.vfs.exists(o)){let p=this.vfs.stat(o);p.type==="file"&&(l=p.size)}let u=Buffer.isBuffer(s)?s.length:Buffer.byteLength(s,"utf8"),h=f-l+u;if(h>i)throw new Error(`quota exceeded for '${e}': ${h}/${i} bytes`)}verifyPassword(e,r){Rt.mark("verifyPassword");let s=this.users.get(e);if(!s)return this.hashPassword(r,""),!1;let i=this.hashPassword(r,s.salt),o=s.passwordHash;try{let a=Buffer.from(i,"hex"),c=Buffer.from(o,"hex");return a.length!==c.length?!1:(0,An.timingSafeEqual)(a,c)}catch{return i===o}}async addUser(e,r){if(Rt.mark("addUser"),this.validateUsername(e),this.validatePassword(r),this.users.has(e))return;this.users.set(e,this.createRecord(e,r)),this.autoSudoForNewUsers&&this.sudoers.add(e);let s=`/home/${e}`;this.vfs.exists(s)||(this.vfs.mkdir(s,493),this.vfs.writeFile(`${s}/README.txt`,`Welcome to the virtual environment, ${e}`)),await this.persist(),this.emit("user:add",{username:e})}getPasswordHash(e){Rt.mark("getPasswordHash");let r=this.users.get(e);return r?r.passwordHash:null}async setPassword(e,r){if(Rt.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(Rt.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 Rt.mark("isSudoer"),this.sudoers.has(e)}async addSudoer(e){if(Rt.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(Rt.mark("removeSudoer"),this.validateUsername(e),e==="root")throw new Error("sudoers: cannot remove root");this.sudoers.delete(e),await this.persist()}registerSession(e,r){Rt.mark("registerSession");let s={id:(0,An.randomUUID)(),username:e,tty:`pts/${this.nextTty++}`,remoteAddress:r,startedAt:new Date().toISOString()};return this.activeSessions.set(s.id,s),this.emit("session:register",{sessionId:s.id,username:e,remoteAddress:r}),s}unregisterSession(e){if(Rt.mark("unregisterSession"),!e)return;let r=this.activeSessions.get(e);this.activeSessions.delete(e),r&&this.emit("session:unregister",{sessionId:e,username:r.username}),this.activeSessions.delete(e)}updateSession(e,r,s){if(Rt.mark("updateSession"),!e)return;let i=this.activeSessions.get(e);i&&this.activeSessions.set(e,{...i,username:r,remoteAddress:s})}listActiveSessions(){return Rt.mark("listActiveSessions"),Array.from(this.activeSessions.values()).sort((e,r)=>e.startedAt.localeCompare(r.startedAt))}listUsers(){return Array.from(this.users.keys()).sort()}loadFromVfs(){if(this.users.clear(),!this.vfs.exists(this.usersPath))return;let e=this.vfs.readFile(this.usersPath);for(let r of e.split(`
390
+ `),exitCode:0}}search(t){let e=t.toLowerCase();return mc.filter(r=>r.name.includes(e)||r.description.toLowerCase().includes(e)||(r.shortDesc??"").toLowerCase().includes(e)).sort((r,s)=>r.name.localeCompare(s.name))}show(t){let e=this.findInRegistry(t);if(!e)return null;let r=this.installed.get(t);return[`Package: ${e.name}`,`Version: ${e.version}`,`Architecture: ${e.architecture??"amd64"}`,`Maintainer: ${e.maintainer??"Fortune Maintainers <pkg@fortune.local>"}`,`Installed-Size: ${e.installedSizeKb??0}`,`Depends: ${(e.depends??[]).join(", ")||"(none)"}`,`Section: ${e.section??"misc"}`,"Priority: optional",`Description: ${e.description}`,`Status: ${r?"install ok installed":"install ok not-installed"}`].join(`
391
+ `)}};var _n=require("node:crypto"),kh=require("node:events"),Bh=Gt(require("node:path"),1);function dE(){let n=process.env.SSH_MIMIC_FAST_PASSWORD_HASH;return!!n&&!["0","false","no","off"].includes(n.toLowerCase())}var Nt=tr("VirtualUserManager"),eo=class n extends kh.EventEmitter{constructor(e,r=!0){super();this.vfs=e;this.autoSudoForNewUsers=r;Nt.mark("constructor")}vfs;autoSudoForNewUsers;static recordCache=new Map;static fastPasswordHash=dE();usersPath="/etc/htpasswd";sudoersPath="/etc/sudoers";quotasPath="/etc/quotas";authDirPath="/.virtual-env-js/.auth";users=new Map;sudoers=new Set;quotas=new Map;activeSessions=new Map;nextTty=0;async initialize(){Nt.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(Nt.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){Nt.mark("clearQuota"),this.validateUsername(e),this.quotas.delete(e),await this.persist()}getQuotaBytes(e){return Nt.mark("getQuotaBytes"),this.quotas.get(e)??null}getUsageBytes(e){Nt.mark("getUsageBytes");let r=`/home/${e}`;return this.vfs.exists(r)?this.vfs.getUsageBytes(r):0}assertWriteWithinQuota(e,r,s){Nt.mark("assertWriteWithinQuota");let i=this.quotas.get(e);if(i===void 0)return;let o=vh(r),a=vh(`/home/${e}`);if(!(o===a||o.startsWith(`${a}/`)))return;let f=this.getUsageBytes(e),l=0;if(this.vfs.exists(o)){let p=this.vfs.stat(o);p.type==="file"&&(l=p.size)}let u=Buffer.isBuffer(s)?s.length:Buffer.byteLength(s,"utf8"),h=f-l+u;if(h>i)throw new Error(`quota exceeded for '${e}': ${h}/${i} bytes`)}verifyPassword(e,r){Nt.mark("verifyPassword");let s=this.users.get(e);if(!s)return this.hashPassword(r,""),!1;let i=this.hashPassword(r,s.salt),o=s.passwordHash;try{let a=Buffer.from(i,"hex"),c=Buffer.from(o,"hex");return a.length!==c.length?!1:(0,_n.timingSafeEqual)(a,c)}catch{return i===o}}async addUser(e,r){if(Nt.mark("addUser"),this.validateUsername(e),this.validatePassword(r),this.users.has(e))return;this.users.set(e,this.createRecord(e,r)),this.autoSudoForNewUsers&&this.sudoers.add(e);let s=`/home/${e}`;this.vfs.exists(s)||(this.vfs.mkdir(s,493),this.vfs.writeFile(`${s}/README.txt`,`Welcome to the virtual environment, ${e}`)),await this.persist(),this.emit("user:add",{username:e})}getPasswordHash(e){Nt.mark("getPasswordHash");let r=this.users.get(e);return r?r.passwordHash:null}async setPassword(e,r){if(Nt.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(Nt.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 Nt.mark("isSudoer"),this.sudoers.has(e)}async addSudoer(e){if(Nt.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(Nt.mark("removeSudoer"),this.validateUsername(e),e==="root")throw new Error("sudoers: cannot remove root");this.sudoers.delete(e),await this.persist()}registerSession(e,r){Nt.mark("registerSession");let s={id:(0,_n.randomUUID)(),username:e,tty:`pts/${this.nextTty++}`,remoteAddress:r,startedAt:new Date().toISOString()};return this.activeSessions.set(s.id,s),this.emit("session:register",{sessionId:s.id,username:e,remoteAddress:r}),s}unregisterSession(e){if(Nt.mark("unregisterSession"),!e)return;let r=this.activeSessions.get(e);this.activeSessions.delete(e),r&&this.emit("session:unregister",{sessionId:e,username:r.username}),this.activeSessions.delete(e)}updateSession(e,r,s){if(Nt.mark("updateSession"),!e)return;let i=this.activeSessions.get(e);i&&this.activeSessions.set(e,{...i,username:r,remoteAddress:s})}listActiveSessions(){return Nt.mark("listActiveSessions"),Array.from(this.activeSessions.values()).sort((e,r)=>e.startedAt.localeCompare(r.startedAt))}listUsers(){return Array.from(this.users.keys()).sort()}loadFromVfs(){if(this.users.clear(),!this.vfs.exists(this.usersPath))return;let e=this.vfs.readFile(this.usersPath);for(let r of e.split(`
385
392
  `)){let s=r.trim();if(s.length===0)continue;let i=s.split(":");if(i.length<3)continue;let[o,a,c]=i;!o||!a||!c||this.users.set(o,{username:o,salt:a,passwordHash:c})}}loadSudoersFromVfs(){if(this.sudoers.clear(),!this.vfs.exists(this.sudoersPath))return;let e=this.vfs.readFile(this.sudoersPath);for(let r of e.split(`
386
393
  `)){let s=r.trim();s.length>0&&this.sudoers.add(s)}}loadQuotasFromVfs(){if(this.quotas.clear(),!this.vfs.exists(this.quotasPath))return;let e=this.vfs.readFile(this.quotasPath);for(let r of e.split(`
387
394
  `)){let s=r.trim();if(s.length===0)continue;let[i,o]=s.split(":"),a=Number.parseInt(o??"",10);!i||!Number.isFinite(a)||a<0||this.quotas.set(i,a)}}async persist(){this.vfs.exists(this.authDirPath)||this.vfs.mkdir(this.authDirPath,448);let e=Array.from(this.users.values()).sort((o,a)=>o.username.localeCompare(a.username)).map(o=>[o.username,o.salt,o.passwordHash].join(":")).join(`
@@ -390,45 +397,45 @@ echo 'neofetch: virtual stub'
390
397
  `),i=!1;i=this.writeIfChanged(this.usersPath,e.length>0?`${e}
391
398
  `:"",384)||i,i=this.writeIfChanged(this.sudoersPath,r.length>0?`${r}
392
399
  `:"",384)||i,i=this.writeIfChanged(this.quotasPath,s.length>0?`${s}
393
- `:"",384)||i,i&&await this.vfs.flushMirror()}writeIfChanged(e,r,s){return this.vfs.exists(e)&&this.vfs.readFile(e)===r?(this.vfs.chmod(e,s),!1):(this.vfs.writeFile(e,r,{mode:s}),!0)}createRecord(e,r){let s=(0,An.createHash)("sha256").update(e).update(":").update(r).digest("hex"),i=n.recordCache.get(s);if(i)return i;let o=(0,An.randomBytes)(16).toString("hex"),a={username:e,salt:o,passwordHash:this.hashPassword(r,o)};return n.recordCache.set(s,a),a}hasPassword(e){Rt.mark("hasPassword");let r=this.users.get(e);if(!r)return!1;let s=this.hashPassword("",r.salt);return r.passwordHash===s?!1:!!r.passwordHash}hashPassword(e,r=""){return n.fastPasswordHash?(0,An.createHash)("sha256").update(r).update(e).digest("hex"):(0,An.scryptSync)(e,r||"",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")}authorizedKeys=new Map;addAuthorizedKey(e,r,s){Rt.mark("addAuthorizedKey");let i=this.authorizedKeys.get(e)??[];i.push({algo:r,data:s}),this.authorizedKeys.set(e,i),this.emit("key:add",{username:e,algo:r})}removeAuthorizedKeys(e){this.authorizedKeys.delete(e),this.emit("key:remove",{username:e})}getAuthorizedKeys(e){return this.authorizedKeys.get(e)??[]}};function bh(n){let t=Sh.posix.normalize(n);return t.startsWith("/")?t:`/${t}`}var Yr=require("node:fs/promises"),pc=Vt(require("node:path"),1);var Bh=require("node:child_process");var wh=require("node:fs/promises"),Js=Vt(require("node:path"),1);function hc(n){return`'${n.replace(/'/g,"'\\''")}'`}function $i(n){return n.replace(/\r\n/g,`
400
+ `:"",384)||i,i&&await this.vfs.flushMirror()}writeIfChanged(e,r,s){return this.vfs.exists(e)&&this.vfs.readFile(e)===r?(this.vfs.chmod(e,s),!1):(this.vfs.writeFile(e,r,{mode:s}),!0)}createRecord(e,r){let s=(0,_n.createHash)("sha256").update(e).update(":").update(r).digest("hex"),i=n.recordCache.get(s);if(i)return i;let o=(0,_n.randomBytes)(16).toString("hex"),a={username:e,salt:o,passwordHash:this.hashPassword(r,o)};return n.recordCache.set(s,a),a}hasPassword(e){Nt.mark("hasPassword");let r=this.users.get(e);if(!r)return!1;let s=this.hashPassword("",r.salt);return r.passwordHash===s?!1:!!r.passwordHash}hashPassword(e,r=""){return n.fastPasswordHash?(0,_n.createHash)("sha256").update(r).update(e).digest("hex"):(0,_n.scryptSync)(e,r||"",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")}authorizedKeys=new Map;addAuthorizedKey(e,r,s){Nt.mark("addAuthorizedKey");let i=this.authorizedKeys.get(e)??[];i.push({algo:r,data:s}),this.authorizedKeys.set(e,i),this.emit("key:add",{username:e,algo:r})}removeAuthorizedKeys(e){this.authorizedKeys.delete(e),this.emit("key:remove",{username:e})}getAuthorizedKeys(e){return this.authorizedKeys.get(e)??[]}};function vh(n){let t=Bh.posix.normalize(n);return t.startsWith("/")?t:`/${t}`}var jr=require("node:fs/promises"),Ec=Gt(require("node:path"),1);var Uh=require("node:child_process");var Rh=require("node:fs/promises"),to=Gt(require("node:path"),1);function Ac(n){return`'${n.replace(/'/g,"'\\''")}'`}function Fi(n){return n.replace(/\r\n/g,`
394
401
  `).replace(/\r/g,`
395
402
  `).replace(/\n/g,`\r
396
- `)}function Ih(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 Ch(n,t){return!t||t.trim()===""||t==="."?n:t.startsWith("/")?Js.posix.normalize(t):Js.posix.normalize(Js.posix.join(n,t))}async function kh(n){try{let e=(await(0,wh.readFile)(`/proc/${n}/task/${n}/children`,"utf8")).trim().split(/\s+/).filter(Boolean).map(s=>Number.parseInt(s,10)).filter(s=>Number.isInteger(s)&&s>0),r=await Promise.all(e.map(s=>kh(s)));return[...e,...r.flat()]}catch{return[]}}async function vh(n=process.pid){let t=await kh(n),e=Array.from(new Set(t)).sort((r,s)=>r-s);return e.length===0?null:e.join(",")}function Rh(n,t,e){let r=Ih(n,t),s=(0,Bh.spawn)("script",["-qfec",r,"/dev/null"],{stdio:["pipe","pipe","pipe"],env:{...process.env,TERM:process.env.TERM??"xterm-256color"}});return s.stdout.on("data",i=>{e.write(i.toString("utf8"))}),s.stderr.on("data",i=>{e.write(i.toString("utf8"))}),s}function Nh(n,t,e){return Rh(`nano -- ${hc(n)}`,t,e)}function Ph(n,t,e){return Rh(`htop -p ${hc(n)}`,t,e)}function Th(n,t,e){let r=[`Linux ${n} ${t.kernel} ${t.arch}`,"","The programs included with the Fortune GNU/Linux system are free software;","the exact distribution terms for each program are described in the","individual files in /usr/share/doc/*/copyright.","","Fortune GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent","permitted by applicable law."];if(e){let s=new Date(e.at),i=Number.isNaN(s.getTime())?e.at:Vs(s);r.push(`Last login: ${i} from ${e.from||"unknown"}`)}return r.push(""),`${r.map(s=>`${s}\r
397
- `).join("")}`}function Lh(n,t,e){let r=n==="root",s=r?"\x1B[31;1m":"\x1B[35;1m",i="\x1B[37;1m",o="\x1B[34;1m",a="\x1B[0m";return`${i}[${s}${n}${i}@${o}${t}${a} ${e}${i}]${a}${r?"#":"$"} `}function Uh(n,t,e,r,s,i="unknown",o={cols:80,rows:24},a){let c="",f=0,l=oE(a.vfs,e),u=null,h="",p=`/home/${e}`,y=Kr(e,r),E=null,x=null,k=()=>{let B=`/home/${e}`,T=p===B?"~":pc.posix.basename(p)||"/";return Lh(e,r,T)},D=Array.from(new Set(nc())).sort();console.log(`[${s}] Shell started for user '${e}' at ${i}`),(async()=>{let B=`/home/${e}/.bashrc`;if(a.vfs.exists(B))try{let T=a.vfs.readFile(B);for(let Q of T.split(`
398
- `)){let ee=Q.trim();!ee||ee.startsWith("#")||await bt(ee,e,r,"shell",p,a,void 0,y)}}catch{}})();function H(){let B=k();t.write(`\r${B}${c}\x1B[K`);let T=c.length-f;T>0&&t.write(`\x1B[${T}D`)}function C(){t.write("\r\x1B[K")}function F(B){x={...B,buffer:""},C(),t.write(B.prompt)}async function V(B){if(!x)return;let T=x;if(x=null,!B){t.write(`\r
403
+ `)}function Nh(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 Ph(n,t){return!t||t.trim()===""||t==="."?n:t.startsWith("/")?to.posix.normalize(t):to.posix.normalize(to.posix.join(n,t))}async function Th(n){try{let e=(await(0,Rh.readFile)(`/proc/${n}/task/${n}/children`,"utf8")).trim().split(/\s+/).filter(Boolean).map(s=>Number.parseInt(s,10)).filter(s=>Number.isInteger(s)&&s>0),r=await Promise.all(e.map(s=>Th(s)));return[...e,...r.flat()]}catch{return[]}}async function Lh(n=process.pid){let t=await Th(n),e=Array.from(new Set(t)).sort((r,s)=>r-s);return e.length===0?null:e.join(",")}function Dh(n,t,e){let r=Nh(n,t),s=(0,Uh.spawn)("script",["-qfec",r,"/dev/null"],{stdio:["pipe","pipe","pipe"],env:{...process.env,TERM:process.env.TERM??"xterm-256color"}});return s.stdout.on("data",i=>{e.write(i.toString("utf8"))}),s.stderr.on("data",i=>{e.write(i.toString("utf8"))}),s}function $h(n,t,e){return Dh(`nano -- ${Ac(n)}`,t,e)}function Oh(n,t,e){return Dh(`htop -p ${Ac(n)}`,t,e)}function Mh(n,t,e){let r=[`Linux ${n} ${t.kernel} ${t.arch}`,"","The programs included with the Fortune GNU/Linux system are free software;","the exact distribution terms for each program are described in the","individual files in /usr/share/doc/*/copyright.","","Fortune GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent","permitted by applicable law."];if(e){let s=new Date(e.at),i=Number.isNaN(s.getTime())?e.at:Ys(s);r.push(`Last login: ${i} from ${e.from||"unknown"}`)}return r.push(""),`${r.map(s=>`${s}\r
404
+ `).join("")}`}function Fh(n,t,e){let r=n==="root",s=r?"\x1B[31;1m":"\x1B[35;1m",i="\x1B[37;1m",o="\x1B[34;1m",a="\x1B[0m";return`${i}[${s}${n}${i}@${o}${t}${a} ${e}${i}]${a}${r?"#":"$"} `}function Hh(n,t,e,r,s,i="unknown",o={cols:80,rows:24},a){let c="",f=0,l=hE(a.vfs,e),u=null,h="",p=`/home/${e}`,y=Vr(e,r),E=null,b=null,C=()=>{let B=`/home/${e}`,L=p===B?"~":Ec.posix.basename(p)||"/";return Fh(e,r,L)},N=Array.from(new Set(oc())).sort();console.log(`[${s}] Shell started for user '${e}' at ${i}`),(async()=>{let B=`/home/${e}/.bashrc`;if(a.vfs.exists(B))try{let L=a.vfs.readFile(B);for(let K of L.split(`
405
+ `)){let ee=K.trim();!ee||ee.startsWith("#")||await xt(ee,e,r,"shell",p,a,void 0,y)}}catch{}})();function H(){let B=C();t.write(`\r${B}${c}\x1B[K`);let L=c.length-f;L>0&&t.write(`\x1B[${L}D`)}function v(){t.write("\r\x1B[K")}function M(B){b={...B,buffer:""},v(),t.write(B.prompt)}async function Q(B){if(!b)return;let L=b;if(b=null,!B){t.write(`\r
399
406
  Sorry, try again.\r
400
- `),H();return}if(!T.commandLine){e=T.targetUser,T.loginShell&&(p=`/home/${e}`),a.users.updateSession(s,e,i),t.write(`\r
401
- `),H();return}let Q=T.loginShell?`/home/${T.targetUser}`:p,ee=await Promise.resolve(bt(T.commandLine,T.targetUser,r,"shell",Q,a));if(t.write(`\r
402
- `),ee.openEditor){await b(ee.openEditor.targetPath,ee.openEditor.initialContent,ee.openEditor.tempPath);return}if(ee.openHtop){await S();return}ee.clearScreen&&t.write("\x1B[2J\x1B[H"),ee.stdout&&t.write(`${$i(ee.stdout)}\r
403
- `),ee.stderr&&t.write(`${$i(ee.stderr)}\r
404
- `),ee.switchUser?(e=ee.switchUser,p=ee.nextCwd??`/home/${e}`,a.users.updateSession(s,e,i)):ee.nextCwd&&(p=ee.nextCwd),await a.vfs.flushMirror(),H()}async function N(){if(!E)return;let B=E;if(B.kind==="nano"){try{let T=await(0,Yr.readFile)(B.tempPath,"utf8");a.writeFileAsUser(e,B.targetPath,T),await a.vfs.flushMirror()}catch{}await(0,Yr.unlink)(B.tempPath).catch(()=>{})}E=null,c="",f=0,t.write(`\r
405
- `),H()}async function b(B,T,Q){a.vfs.exists(B)&&await(0,Yr.writeFile)(Q,T,"utf8");let ee=Nh(Q,o,t);ee.on("error",fe=>{t.write(`nano: ${fe.message}\r
406
- `),N()}),ee.on("close",()=>{N()}),E={kind:"nano",targetPath:B,tempPath:Q,process:ee}}async function S(){let B=await vh();if(!B){t.write(`htop: no child_process processes to display\r
407
- `);return}let T=Ph(B,o,t);T.on("error",Q=>{t.write(`htop: ${Q.message}\r
408
- `),N()}),T.on("close",()=>{N()}),E={kind:"htop",targetPath:"",tempPath:"",process:T}}function I(B){c=B,f=c.length,H()}function v(B){c=`${c.slice(0,f)}${B}${c.slice(f)}`,f+=B.length,H()}function R(B,T){let Q=T;for(;Q>0&&!/\s/.test(B[Q-1]);)Q-=1;let ee=T;for(;ee<B.length&&!/\s/.test(B[ee]);)ee+=1;return{start:Q,end:ee}}function ne(B){let T=B.lastIndexOf("/"),Q=T>=0?B.slice(0,T+1):"",ee=T>=0?B.slice(T+1):B,fe=Ch(p,Q||".");try{return a.vfs.list(fe).filter(ie=>!ie.startsWith(".")).filter(ie=>ie.startsWith(ee)).map(ie=>{let Ye=pc.posix.join(fe,ie),tn=a.vfs.stat(Ye).type==="directory"?"/":"";return`${Q}${ie}${tn}`}).sort()}catch{return[]}}function z(){let{start:B,end:T}=R(c,f),Q=c.slice(B,f);if(Q.length===0)return;let fe=c.slice(0,B).trim().length===0?D.filter(ct=>ct.startsWith(Q)):[],ie=ne(Q),Ye=Array.from(new Set([...fe,...ie])).sort();if(Ye.length!==0){if(Ye.length===1){let ct=Ye[0],tn=ct.endsWith("/")?"":" ";c=`${c.slice(0,B)}${ct}${tn}${c.slice(T)}`,f=B+ct.length+tn.length,H();return}t.write(`\r
407
+ `),H();return}if(!L.commandLine){e=L.targetUser,L.loginShell&&(p=`/home/${e}`),a.users.updateSession(s,e,i),t.write(`\r
408
+ `),H();return}let K=L.loginShell?`/home/${L.targetUser}`:p,ee=await Promise.resolve(xt(L.commandLine,L.targetUser,r,"shell",K,a));if(t.write(`\r
409
+ `),ee.openEditor){await x(ee.openEditor.targetPath,ee.openEditor.initialContent,ee.openEditor.tempPath);return}if(ee.openHtop){await w();return}ee.clearScreen&&t.write("\x1B[2J\x1B[H"),ee.stdout&&t.write(`${Fi(ee.stdout)}\r
410
+ `),ee.stderr&&t.write(`${Fi(ee.stderr)}\r
411
+ `),ee.switchUser?(e=ee.switchUser,p=ee.nextCwd??`/home/${e}`,a.users.updateSession(s,e,i)):ee.nextCwd&&(p=ee.nextCwd),await a.vfs.flushMirror(),H()}async function P(){if(!E)return;let B=E;if(B.kind==="nano"){try{let L=await(0,jr.readFile)(B.tempPath,"utf8");a.writeFileAsUser(e,B.targetPath,L),await a.vfs.flushMirror()}catch{}await(0,jr.unlink)(B.tempPath).catch(()=>{})}E=null,c="",f=0,t.write(`\r
412
+ `),H()}async function x(B,L,K){a.vfs.exists(B)&&await(0,jr.writeFile)(K,L,"utf8");let ee=$h(K,o,t);ee.on("error",fe=>{t.write(`nano: ${fe.message}\r
413
+ `),P()}),ee.on("close",()=>{P()}),E={kind:"nano",targetPath:B,tempPath:K,process:ee}}async function w(){let B=await Lh();if(!B){t.write(`htop: no child_process processes to display\r
414
+ `);return}let L=Oh(B,o,t);L.on("error",K=>{t.write(`htop: ${K.message}\r
415
+ `),P()}),L.on("close",()=>{P()}),E={kind:"htop",targetPath:"",tempPath:"",process:L}}function I(B){c=B,f=c.length,H()}function k(B){c=`${c.slice(0,f)}${B}${c.slice(f)}`,f+=B.length,H()}function R(B,L){let K=L;for(;K>0&&!/\s/.test(B[K-1]);)K-=1;let ee=L;for(;ee<B.length&&!/\s/.test(B[ee]);)ee+=1;return{start:K,end:ee}}function ne(B){let L=B.lastIndexOf("/"),K=L>=0?B.slice(0,L+1):"",ee=L>=0?B.slice(L+1):B,fe=Ph(p,K||".");try{return a.vfs.list(fe).filter(ie=>!ie.startsWith(".")).filter(ie=>ie.startsWith(ee)).map(ie=>{let Ye=Ec.posix.join(fe,ie),rn=a.vfs.stat(Ye).type==="directory"?"/":"";return`${K}${ie}${rn}`}).sort()}catch{return[]}}function z(){let{start:B,end:L}=R(c,f),K=c.slice(B,f);if(K.length===0)return;let fe=c.slice(0,B).trim().length===0?N.filter(ft=>ft.startsWith(K)):[],ie=ne(K),Ye=Array.from(new Set([...fe,...ie])).sort();if(Ye.length!==0){if(Ye.length===1){let ft=Ye[0],rn=ft.endsWith("/")?"":" ";c=`${c.slice(0,B)}${ft}${rn}${c.slice(L)}`,f=B+ft.length+rn.length,H();return}t.write(`\r
409
416
  `),t.write(`${Ye.join(" ")}\r
410
- `),H()}}function Y(B){if(B.length===0)return;l.push(B),l.length>500&&(l=l.slice(l.length-500));let T=l.length>0?`${l.join(`
417
+ `),H()}}function Y(B){if(B.length===0)return;l.push(B),l.length>500&&(l=l.slice(l.length-500));let L=l.length>0?`${l.join(`
411
418
  `)}
412
- `:"";a.vfs.writeFile(`/home/${e}/.bash_history`,T)}function te(){let B=`/home/${e}/.lastlog.json`;if(!a.vfs.exists(B))return null;try{return JSON.parse(a.vfs.readFile(B))}catch{return null}}function ce(B){let T=`/home/${e}/.lastlog`;a.vfs.exists(T)||a.vfs.mkdir(T,448);let Q=`${T}/${e}.json`;a.vfs.writeFile(Q,JSON.stringify({at:B,from:i}))}function $(){let B=te(),T=new Date().toISOString();t.write(Th(r,n,B)),ce(T)}$(),H(),t.on("data",async B=>{if(E){E.process.stdin.write(B);return}if(x){let Q=B.toString("utf8");for(let ee=0;ee<Q.length;ee+=1){let fe=Q[ee];if(fe===""){x=null,t.write(`^C\r
413
- `),H();return}if(fe==="\x7F"||fe==="\b"){x.buffer=x.buffer.slice(0,-1);continue}if(fe==="\r"||fe===`
414
- `){let ie=x.buffer;if(x.buffer="",x.onPassword){let{result:ct,nextPrompt:tn}=await x.onPassword(ie,a);t.write(`\r
415
- `),ct!==null?(x=null,ct.stdout&&t.write(ct.stdout.replace(/\n/g,`\r
416
- `)),ct.stderr&&t.write(ct.stderr.replace(/\n/g,`\r
417
- `)),H()):(tn&&(x.prompt=tn),t.write(x.prompt));return}let Ye=a.users.verifyPassword(x.username,ie);await V(Ye);return}fe>=" "&&(x.buffer+=fe)}return}let T=B.toString("utf8");for(let Q=0;Q<T.length;Q+=1){let ee=T[Q];if(ee===""){c="",f=0,u=null,h="",t.write(`bye\r
419
+ `:"";a.vfs.writeFile(`/home/${e}/.bash_history`,L)}function te(){let B=`/home/${e}/.lastlog.json`;if(!a.vfs.exists(B))return null;try{return JSON.parse(a.vfs.readFile(B))}catch{return null}}function ce(B){let L=`/home/${e}/.lastlog`;a.vfs.writeFile(L,JSON.stringify({at:B,from:i}))}function $(){let B=te(),L=new Date().toISOString();t.write(Mh(r,n,B)),ce(L)}$(),H(),t.on("data",async B=>{if(E){E.process.stdin.write(B);return}if(b){let K=B.toString("utf8");for(let ee=0;ee<K.length;ee+=1){let fe=K[ee];if(fe===""){b=null,t.write(`^C\r
420
+ `),H();return}if(fe==="\x7F"||fe==="\b"){b.buffer=b.buffer.slice(0,-1);continue}if(fe==="\r"||fe===`
421
+ `){let ie=b.buffer;if(b.buffer="",b.onPassword){let{result:ft,nextPrompt:rn}=await b.onPassword(ie,a);t.write(`\r
422
+ `),ft!==null?(b=null,ft.stdout&&t.write(ft.stdout.replace(/\n/g,`\r
423
+ `)),ft.stderr&&t.write(ft.stderr.replace(/\n/g,`\r
424
+ `)),H()):(rn&&(b.prompt=rn),t.write(b.prompt));return}let Ye=a.users.verifyPassword(b.username,ie);await Q(Ye);return}fe>=" "&&(b.buffer+=fe)}return}let L=B.toString("utf8");for(let K=0;K<L.length;K+=1){let ee=L[K];if(ee===""){c="",f=0,u=null,h="",t.write(`bye\r
418
425
  `),Y("bye"),await a.vfs.flushMirror(),t.write(`logout\r
419
- `),t.exit(0),t.end();return}if(ee===" "){z();continue}if(ee==="\x1B"){let fe=T[Q+1],ie=T[Q+2],Ye=T[Q+3];if(fe==="["&&ie){if(ie==="A"){Q+=2,l.length>0&&(u===null?(h=c,u=l.length-1):u>0&&(u-=1),I(l[u]??""));continue}if(ie==="B"){Q+=2,u!==null&&(u<l.length-1?(u+=1,I(l[u]??"")):(u=null,I(h)));continue}if(ie==="C"){Q+=2,f<c.length&&(f+=1,t.write("\x1B[C"));continue}if(ie==="D"){Q+=2,f>0&&(f-=1,t.write("\x1B[D"));continue}if(ie==="3"&&Ye==="~"){Q+=3,f<c.length&&(c=`${c.slice(0,f)}${c.slice(f+1)}`,H());continue}}}if(ee===""){c="",f=0,u=null,h="",t.write(`^C\r
426
+ `),t.exit(0),t.end();return}if(ee===" "){z();continue}if(ee==="\x1B"){let fe=L[K+1],ie=L[K+2],Ye=L[K+3];if(fe==="["&&ie){if(ie==="A"){K+=2,l.length>0&&(u===null?(h=c,u=l.length-1):u>0&&(u-=1),I(l[u]??""));continue}if(ie==="B"){K+=2,u!==null&&(u<l.length-1?(u+=1,I(l[u]??"")):(u=null,I(h)));continue}if(ie==="C"){K+=2,f<c.length&&(f+=1,t.write("\x1B[C"));continue}if(ie==="D"){K+=2,f>0&&(f-=1,t.write("\x1B[D"));continue}if(ie==="3"&&Ye==="~"){K+=3,f<c.length&&(c=`${c.slice(0,f)}${c.slice(f+1)}`,H());continue}}}if(ee===""){c="",f=0,u=null,h="",t.write(`^C\r
420
427
  `),H();continue}if(ee==="\r"||ee===`
421
428
  `){let fe=c.trim();if(c="",f=0,u=null,h="",t.write(`\r
422
- `),fe.length>0){let ie=await Promise.resolve(bt(fe,e,r,"shell",p,a,void 0,y));if(Y(fe),ie.openEditor){await b(ie.openEditor.targetPath,ie.openEditor.initialContent,ie.openEditor.tempPath);return}if(ie.openHtop){await S();return}if(ie.sudoChallenge){F(ie.sudoChallenge);return}if(ie.clearScreen&&t.write("\x1B[2J\x1B[H"),ie.stdout&&t.write(`${$i(ie.stdout)}\r
423
- `),ie.stderr&&t.write(`${$i(ie.stderr)}\r
429
+ `),fe.length>0){let ie=await Promise.resolve(xt(fe,e,r,"shell",p,a,void 0,y));if(Y(fe),ie.openEditor){await x(ie.openEditor.targetPath,ie.openEditor.initialContent,ie.openEditor.tempPath);return}if(ie.openHtop){await w();return}if(ie.sudoChallenge){M(ie.sudoChallenge);return}if(ie.clearScreen&&t.write("\x1B[2J\x1B[H"),ie.stdout&&t.write(`${Fi(ie.stdout)}\r
430
+ `),ie.stderr&&t.write(`${Fi(ie.stderr)}\r
424
431
  `),ie.closeSession){t.write(`logout\r
425
- `),t.exit(ie.exitCode??0),t.end();return}ie.nextCwd&&(p=ie.nextCwd),ie.switchUser&&(e=ie.switchUser,p=ie.nextCwd??`/home/${e}`,a.users.updateSession(s,e,i),c="",f=0),await a.vfs.flushMirror()}H();continue}if(ee==="\x7F"||ee==="\b"){f>0&&(c=`${c.slice(0,f-1)}${c.slice(f)}`,f-=1,H());continue}v(ee)}}),t.on("close",()=>{E&&(E.process.kill("SIGTERM"),E=null)})}function oE(n,t){let e=`/home/${t}/.bash_history`;return n.exists(e)?n.readFile(e).split(`
426
- `).map(s=>s.trim()).filter(s=>s.length>0):(n.writeFile(e,""),[])}function aE(n){return typeof n=="object"&&n!==null&&"vfsInstance"in n&&$h(n.vfsInstance)}function $h(n){if(typeof n!="object"||n===null)return!1;let t=n;return typeof t.restoreMirror=="function"&&typeof t.flushMirror=="function"&&typeof t.writeFile=="function"&&typeof t.readFile=="function"&&typeof t.mkdir=="function"&&typeof t.exists=="function"&&typeof t.stat=="function"&&typeof t.list=="function"&&typeof t.remove=="function"&&typeof t.copy=="function"&&typeof t.move=="function"&&typeof t.touch=="function"}var cE={kernel:"1.0.0+itsrealfortune+1-amd64",os:"Fortune GNU/Linux x64",arch:"x86_64"},Oi=Jn("VirtualShell");function fE(){let n=process.env.SSH_MIMIC_AUTO_SUDO_NEW_USERS;return n?!["0","false","no","off"].includes(n.toLowerCase()):!0}var hr=class extends Dh.EventEmitter{vfs;users;packageManager;hostname;properties;startTime;initialized;constructor(t,e,r){super(),Oi.mark("constructor"),this.hostname=t,this.properties=e||cE,this.startTime=Date.now(),$h(r)?this.vfs=r:aE(r)?this.vfs=r.vfsInstance:this.vfs=new yh(r??{}),this.users=new Xs(this.vfs,fE()),this.packageManager=new js(this.vfs,this.users);let s=this.vfs,i=this.users,o=this.packageManager,a=this.properties,c=this.hostname,f=this.startTime;this.initialized=(async()=>{await s.restoreMirror(),await i.initialize(),fh(s,i,c,a,f),o.load(),this.emit("initialized")})()}async ensureInitialized(){Oi.mark("ensureInitialized"),await this.initialized}addCommand(t,e,r){let s=t.trim().toLowerCase();if(s.length===0||/\s/.test(s))throw new Error("Command name must be non-empty and contain no spaces");ec(tc(s,e,r))}executeCommand(t,e,r){Oi.mark("executeCommand"),bt(t,e,this.hostname,"shell",r,this),this.emit("command",{command:t,user:e,cwd:r})}startInteractiveSession(t,e,r,s,i){Oi.mark("startInteractiveSession"),this.emit("session:start",{user:e,sessionId:r,remoteAddress:s}),Uh(this.properties,t,e,this.hostname,r,s,i,this),this.refreshProcSessions()}refreshProcFs(){zs(this.vfs,this.properties,this.hostname,this.startTime,this.users.listActiveSessions())}refreshProcSessions(){zs(this.vfs,this.properties,this.hostname,this.startTime,this.users.listActiveSessions())}syncPasswd(){ac(this.vfs,this.users)}getVfs(){return this?.vfs??null}getUsers(){return this?.users??null}getHostname(){return this?.hostname}writeFileAsUser(t,e,r){Oi.mark("writeFileAsUser"),this.users.assertWriteWithinQuota(t,e,r),this.vfs.writeFile(e,r)}};function Oh(n){return n.replace(/\r\n/g,`
432
+ `),t.exit(ie.exitCode??0),t.end();return}ie.nextCwd&&(p=ie.nextCwd),ie.switchUser&&(e=ie.switchUser,p=ie.nextCwd??`/home/${e}`,a.users.updateSession(s,e,i),c="",f=0),await a.vfs.flushMirror()}H();continue}if(ee==="\x7F"||ee==="\b"){f>0&&(c=`${c.slice(0,f-1)}${c.slice(f)}`,f-=1,H());continue}k(ee)}}),t.on("close",()=>{E&&(E.process.kill("SIGTERM"),E=null)})}function hE(n,t){let e=`/home/${t}/.bash_history`;return n.exists(e)?n.readFile(e).split(`
433
+ `).map(s=>s.trim()).filter(s=>s.length>0):(n.writeFile(e,""),[])}function pE(n){return typeof n=="object"&&n!==null&&"vfsInstance"in n&&Wh(n.vfsInstance)}function Wh(n){if(typeof n!="object"||n===null)return!1;let t=n;return typeof t.restoreMirror=="function"&&typeof t.flushMirror=="function"&&typeof t.writeFile=="function"&&typeof t.readFile=="function"&&typeof t.mkdir=="function"&&typeof t.exists=="function"&&typeof t.stat=="function"&&typeof t.list=="function"&&typeof t.remove=="function"&&typeof t.copy=="function"&&typeof t.move=="function"&&typeof t.touch=="function"}var gE={kernel:"1.0.0+itsrealfortune+1-amd64",os:"Fortune GNU/Linux x64",arch:"x86_64"},Hi=tr("VirtualShell");function mE(){let n=process.env.SSH_MIMIC_AUTO_SUDO_NEW_USERS;return n?!["0","false","no","off"].includes(n.toLowerCase()):!0}var hr=class extends Qh.EventEmitter{vfs;users;packageManager;hostname;properties;startTime;initialized;constructor(t,e,r){super(),Hi.mark("constructor"),this.hostname=t,this.properties=e||gE,this.startTime=Date.now(),Wh(r)?this.vfs=r:pE(r)?this.vfs=r.vfsInstance:this.vfs=new Ch(r??{}),this.users=new eo(this.vfs,mE()),this.packageManager=new Zs(this.vfs,this.users);let s=this.vfs,i=this.users,o=this.packageManager,a=this.properties,c=this.hostname,f=this.startTime;this.initialized=(async()=>{await s.restoreMirror(),await i.initialize(),gh(s,i,c,a,f),o.load(),this.emit("initialized")})()}async ensureInitialized(){Hi.mark("ensureInitialized"),await this.initialized}addCommand(t,e,r){let s=t.trim().toLowerCase();if(s.length===0||/\s/.test(s))throw new Error("Command name must be non-empty and contain no spaces");ic(sc(s,e,r))}executeCommand(t,e,r){Hi.mark("executeCommand"),xt(t,e,this.hostname,"shell",r,this),this.emit("command",{command:t,user:e,cwd:r})}startInteractiveSession(t,e,r,s,i){Hi.mark("startInteractiveSession"),this.emit("session:start",{user:e,sessionId:r,remoteAddress:s}),Hh(this.properties,t,e,this.hostname,r,s,i,this),this.refreshProcSessions()}refreshProcFs(){Xs(this.vfs,this.properties,this.hostname,this.startTime,this.users.listActiveSessions())}mount(t,e,r={}){this.vfs.mount(t,e,r)}unmount(t){this.vfs.unmount(t)}getMounts(){return this.vfs.getMounts()}refreshProcSessions(){Xs(this.vfs,this.properties,this.hostname,this.startTime,this.users.listActiveSessions())}syncPasswd(){uc(this.vfs,this.users)}getVfs(){return this?.vfs??null}getUsers(){return this?.users??null}getHostname(){return this?.hostname}writeFileAsUser(t,e,r){Hi.mark("writeFileAsUser"),this.users.assertWriteWithinQuota(t,e,r),this.vfs.writeFile(e,r)}};function qh(n){return n.replace(/\r\n/g,`
427
434
  `).replace(/\r/g,`
428
435
  `).replace(/\n/g,`\r
429
- `)}function Mh(n,t,e,r,s){Promise.resolve(bt(t,e,r,"exec",`/home/${e}`,s,void 0,Kr(e,r))).then(i=>{i.stdout&&n.write(`${Oh(i.stdout)}\r
430
- `),i.stderr&&n.stderr.write(`${Oh(i.stderr)}\r
436
+ `)}function Kh(n,t,e,r,s){Promise.resolve(xt(t,e,r,"exec",`/home/${e}`,s,void 0,Vr(e,r))).then(i=>{i.stdout&&n.write(`${qh(i.stdout)}\r
437
+ `),i.stderr&&n.stderr.write(`${qh(i.stderr)}\r
431
438
  `),n.exit(i.exitCode??0),s.vfs.flushMirror(),n.end()}).catch(i=>{console.error("Exec error:",i),n.stderr.write(`Error: ${String(i)}\r
432
- `),n.exit(1),n.end()})}var Fh=require("node:crypto"),er=require("node:fs"),Zs=require("node:path");function gc(n=process.cwd()){let t=(0,Zs.resolve)(n,".ssh-mimic","host_rsa");if((0,er.existsSync)(t))return(0,er.readFileSync)(t,"utf8");let e=(0,Fh.generateKeyPairSync)("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs1",format:"pem"},publicKeyEncoding:{type:"pkcs1",format:"pem"}}).privateKey;return(0,er.mkdirSync)((0,Zs.dirname)(t),{recursive:!0}),(0,er.writeFileSync)(t,e,{mode:384}),e}var lE=Vt(za(),1);var mc=!!process.env.DEV_MODE,RS=mc?console.log.bind(console):()=>{},NS=mc?console.warn.bind(console):()=>{},PS=mc?console.error.bind(console):()=>{};var TS=Jn("SftpMimic");var Ac=Jn("SshMimic"),uE=!!process.env.DEV_MODE,Hh=uE?console.log.bind(console):()=>{},eo=class extends Qh.EventEmitter{port;server;shell;maxAuthAttempts;lockoutDurationMs;authAttempts=new Map;constructor({port:t,hostname:e="typescript-vm",shell:r=new hr(e),maxAuthAttempts:s=5,lockoutDurationMs:i=6e4}){super(),Ac.mark("constructor"),this.port=t,this.server=null,this.shell=r,this.maxAuthAttempts=s,this.lockoutDurationMs=i}isLockedOut(t){let e=this.authAttempts.get(t);return e?Date.now()<e.lockedUntil?!0:(e.lockedUntil>0&&this.authAttempts.delete(t),!1):!1}recordFailure(t){let e=this.authAttempts.get(t)??{attempts:0,lockedUntil:0};e.attempts+=1,e.attempts>=this.maxAuthAttempts&&(e.lockedUntil=Date.now()+this.lockoutDurationMs,this.emit("auth:lockout",{ip:t,until:new Date(e.lockedUntil)})),this.authAttempts.set(t,e)}recordSuccess(t){this.authAttempts.delete(t)}ensureHomeDir(t){let e=`/home/${t}`;this.shell.vfs.exists(e)||(this.shell.vfs.mkdir(e,493),this.shell.vfs.writeFile(`${e}/README.txt`,`Welcome to ${this.shell.hostname}
433
- `),this.shell.vfs.flushMirror())}async start(){Ac.mark("start");let t=this.shell,e=gc();return await t.ensureInitialized(),this.server=new Wh.Server({hostKeys:[e],ident:`SSH-2.0-${t.hostname}`},r=>{let s="root",i="unknown",o=null;this.emit("client:connect"),r.on("authentication",a=>{let c=a.username||"root";if(i=a.ip??i,this.isLockedOut(i)){this.emit("auth:failure",{username:c,remoteAddress:i,reason:"lockout"}),a.reject();return}if(a.method==="password"){if(!t.users.hasPassword(c)){s=c,o=t.users.registerSession(s,i).id,this.recordSuccess(i),this.emit("auth:success",{username:s,remoteAddress:i}),this.ensureHomeDir(s),a.accept();return}if(!a.password||a.password===""||!t.users.verifyPassword(c,a.password)){this.recordFailure(i),this.emit("auth:failure",{username:c,remoteAddress:i}),a.reject();return}s=c,o=t.users.registerSession(s,i).id,this.recordSuccess(i),this.emit("auth:success",{username:s,remoteAddress:i}),this.ensureHomeDir(s),a.accept();return}if(a.method==="publickey"){let f=t.users.getAuthorizedKeys(c);if(f.length===0){a.reject();return}let l=a.key;if(!f.some(h=>h.algo===l.algo&&h.data.equals(l.data))){this.recordFailure(i),this.emit("auth:failure",{username:c,remoteAddress:i,method:"publickey"}),a.reject();return}a.signature&&(s=c,o=t.users.registerSession(s,i).id,this.recordSuccess(i),this.emit("auth:success",{username:s,remoteAddress:i,method:"publickey"}),this.ensureHomeDir(s)),a.accept();return}a.reject(["password","publickey"])}),r.on("close",()=>{t.users.unregisterSession(o),this.emit("client:disconnect",{user:s}),o=null}),r.on("ready",()=>{r.on("session",a=>{let c=a(),f={cols:80,rows:24};c.on("pty",(l,u,h)=>{f.cols=h?.cols??f.cols,f.rows=h?.rows??f.rows,l()}),c.on("window-change",(l,u,h)=>{f.cols=h?.cols??f.cols,f.rows=h?.rows??f.rows}),c.on("shell",l=>{let u=l();t?.startInteractiveSession(u,s,o,i,f)}),c.on("exec",(l,u,h)=>{let p=l();p&&Mh(p,h.command.trim(),s,t.hostname,t)})})})}),new Promise((r,s)=>{this.server?.once("error",i=>s(i)),this.server?.listen(this.port,"0.0.0.0",()=>{Hh(`SSH Mimic listening on port ${this.port}`),this.emit("start",{port:this.port}),r(this.port)})})}stop(){Ac.mark("stop"),this.server&&this.server.close(()=>{Hh("SSH Mimic stopped"),this.emit("stop")})}clearLockout(t){this.authAttempts.delete(t)}};var qh=process.env.SSH_MIMIC_HOSTNAME??"typescript-vm",Kh=new hr(qh,void 0,{mode:"fs",snapshotPath:".vfs"});Kh.addCommand("demo",[],()=>({stdout:"This is a demo command. It does nothing useful.",exitCode:0}));new eo({port:2222,hostname:qh,shell:Kh}).start().catch(n=>{console.error("Failed to start SSH Mimic:",n),process.exit(1)});process.on("uncaughtException",n=>{console.log("Oh my god, something terrible happened: ",n)});process.on("unhandledRejection",(n,t)=>{console.log(" Oh Lord! We forgot to handle a promise rejection here: ",t),console.log(" The error was: ",n)});
439
+ `),n.exit(1),n.end()})}var Vh=require("node:crypto"),nr=require("node:fs"),no=require("node:path");function yc(n=process.cwd()){let t=(0,no.resolve)(n,".ssh-mimic","host_rsa");if((0,nr.existsSync)(t))return(0,nr.readFileSync)(t,"utf8");let e=(0,Vh.generateKeyPairSync)("rsa",{modulusLength:2048,privateKeyEncoding:{type:"pkcs1",format:"pem"},publicKeyEncoding:{type:"pkcs1",format:"pem"}}).privateKey;return(0,nr.mkdirSync)((0,no.dirname)(t),{recursive:!0}),(0,nr.writeFileSync)(t,e,{mode:384}),e}var AE=Gt(Ja(),1);var _c=!!process.env.DEV_MODE,OS=_c?console.log.bind(console):()=>{},MS=_c?console.warn.bind(console):()=>{},FS=_c?console.error.bind(console):()=>{};var HS=tr("SftpMimic");var bc=tr("SshMimic"),EE=!!process.env.DEV_MODE,Gh=EE?console.log.bind(console):()=>{},ro=class extends zh.EventEmitter{port;server;shell;maxAuthAttempts;lockoutDurationMs;authAttempts=new Map;constructor({port:t,hostname:e="typescript-vm",shell:r=new hr(e),maxAuthAttempts:s=5,lockoutDurationMs:i=6e4}){super(),bc.mark("constructor"),this.port=t,this.server=null,this.shell=r,this.maxAuthAttempts=s,this.lockoutDurationMs=i}isLockedOut(t){let e=this.authAttempts.get(t);return e?Date.now()<e.lockedUntil?!0:(e.lockedUntil>0&&this.authAttempts.delete(t),!1):!1}recordFailure(t){let e=this.authAttempts.get(t)??{attempts:0,lockedUntil:0};e.attempts+=1,e.attempts>=this.maxAuthAttempts&&(e.lockedUntil=Date.now()+this.lockoutDurationMs,this.emit("auth:lockout",{ip:t,until:new Date(e.lockedUntil)})),this.authAttempts.set(t,e)}recordSuccess(t){this.authAttempts.delete(t)}ensureHomeDir(t){let e=`/home/${t}`;this.shell.vfs.exists(e)||(this.shell.vfs.mkdir(e,493),this.shell.vfs.writeFile(`${e}/README.txt`,`Welcome to ${this.shell.hostname}
440
+ `),this.shell.vfs.flushMirror())}async start(){bc.mark("start");let t=this.shell,e=yc();return await t.ensureInitialized(),this.server=new Yh.Server({hostKeys:[e],ident:`SSH-2.0-${t.hostname}`},r=>{let s="root",i="unknown",o=null;this.emit("client:connect"),r.on("authentication",a=>{let c=a.username||"root";if(i=a.ip??i,this.isLockedOut(i)){this.emit("auth:failure",{username:c,remoteAddress:i,reason:"lockout"}),a.reject();return}if(a.method==="password"){if(!t.users.hasPassword(c)){s=c,o=t.users.registerSession(s,i).id,this.recordSuccess(i),this.emit("auth:success",{username:s,remoteAddress:i}),this.ensureHomeDir(s),a.accept();return}if(!a.password||a.password===""||!t.users.verifyPassword(c,a.password)){this.recordFailure(i),this.emit("auth:failure",{username:c,remoteAddress:i}),a.reject();return}s=c,o=t.users.registerSession(s,i).id,this.recordSuccess(i),this.emit("auth:success",{username:s,remoteAddress:i}),this.ensureHomeDir(s),a.accept();return}if(a.method==="publickey"){let f=t.users.getAuthorizedKeys(c);if(f.length===0){a.reject();return}let l=a.key;if(!f.some(h=>h.algo===l.algo&&h.data.equals(l.data))){this.recordFailure(i),this.emit("auth:failure",{username:c,remoteAddress:i,method:"publickey"}),a.reject();return}a.signature&&(s=c,o=t.users.registerSession(s,i).id,this.recordSuccess(i),this.emit("auth:success",{username:s,remoteAddress:i,method:"publickey"}),this.ensureHomeDir(s)),a.accept();return}a.reject(["password","publickey"])}),r.on("close",()=>{t.users.unregisterSession(o),this.emit("client:disconnect",{user:s}),o=null}),r.on("ready",()=>{r.on("session",a=>{let c=a(),f={cols:80,rows:24};c.on("pty",(l,u,h)=>{f.cols=h?.cols??f.cols,f.rows=h?.rows??f.rows,l()}),c.on("window-change",(l,u,h)=>{f.cols=h?.cols??f.cols,f.rows=h?.rows??f.rows}),c.on("shell",l=>{let u=l();t?.startInteractiveSession(u,s,o,i,f)}),c.on("exec",(l,u,h)=>{let p=l();p&&Kh(p,h.command.trim(),s,t.hostname,t)})})})}),new Promise((r,s)=>{this.server?.once("error",i=>s(i)),this.server?.listen(this.port,"0.0.0.0",()=>{Gh(`SSH Mimic listening on port ${this.port}`),this.emit("start",{port:this.port}),r(this.port)})})}stop(){bc.mark("stop"),this.server&&this.server.close(()=>{Gh("SSH Mimic stopped"),this.emit("stop")})}clearLockout(t){this.authAttempts.delete(t)}};var jh=process.env.SSH_MIMIC_HOSTNAME??"typescript-vm",Xh=new hr(jh,void 0,{mode:"fs",snapshotPath:".vfs"});Xh.addCommand("demo",[],()=>({stdout:"This is a demo command. It does nothing useful.",exitCode:0}));new ro({port:2222,hostname:jh,shell:Xh}).start().catch(n=>{console.error("Failed to start SSH Mimic:",n),process.exit(1)});process.on("uncaughtException",n=>{console.log("Oh my god, something terrible happened: ",n)});process.on("unhandledRejection",(n,t)=>{console.log(" Oh Lord! We forgot to handle a promise rejection here: ",t),console.log(" The error was: ",n)});
434
441
  //# sourceMappingURL=standalone-wo-sftp.js.map